externalCoupledTemperatureMixedFvPatchScalarField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::externalCoupledTemperatureMixedFvPatchScalarField
26 
27 Description
28  This boundary condition provides a temperature interface to an external
29  application. Values are transferred as plain text files, where OpenFOAM
30  data is written as:
31 
32  \verbatim
33  # Patch: <patch name>
34  <magSf1> <value1> <qDot1> <htc1>
35  <magSf2> <value2> <qDot2> <htc2>
36  <magSf3> <value3> <qDot3> <htc2>
37  ...
38  <magSfN> <valueN> <qDotN> <htcN>
39  \endverbatim
40 
41  and received as the constituent pieces of the `mixed' condition, i.e.
42 
43  \verbatim
44  # Patch: <patch name>
45  <value1> <gradient1> <valueFraction1>
46  <value2> <gradient2> <valueFraction2>
47  <value3> <gradient3> <valueFraction3>
48  ...
49  <valueN> <gradientN> <valueFractionN>
50  \endverbatim
51 
52  Data is sent/received as a single file for all patches from the directory
53 
54  \verbatim
55  $FOAM_CASE/<commsDir>
56  \endverbatim
57 
58  At start-up, the boundary creates a lock file, i.e..
59 
60  \verbatim
61  OpenFOAM.lock
62  \endverbatim
63 
64  ... to signal the external source to wait. During the boundary condition
65  update, boundary values are written to file, e.g.
66 
67  \verbatim
68  <fileName>.out
69  \endverbatim
70 
71  The lock file is then removed, instructing the external source to take
72  control of the program execution. When ready, the external program
73  should create the return values, e.g. to file
74 
75  \verbatim
76  <fileName>.in
77  \endverbatim
78 
79  ... and then re-instate the lock file. The boundary condition will then
80  read the return values, and pass program execution back to OpenFOAM.
81 
82 
83 Usage
84  \table
85  Property | Description | Required | Default value
86  commsDir | communications directory | yes |
87  file | transfer file name | yes |
88  waitInterval | interval [s] between file checks | no | 1
89  timeOut | time after which error invoked [s] |no |100*waitInterval
90  calcFrequency | calculation frequency | no | 1
91  log | log program control | no | no
92  \endtable
93 
94  Example of the boundary condition specification:
95  \verbatim
96  <patchName>
97  {
98  type externalCoupledTemperature;
99  commsDir "$FOAM_CASE/comms";
100  file data;
101  calcFrequency 1;
102  }
103  \endverbatim
104 
105 See also
106  mixedFvPatchField
107  externalCoupledMixedFvPatchField
108 
109 SourceFiles
110  externalCoupledTemperatureMixedFvPatchScalarField.C
111 
112 \*---------------------------------------------------------------------------*/
113 
114 #ifndef externalCoupledTemperatureMixedFvPatchScalarField_H
115 #define externalCoupledTemperatureMixedFvPatchScalarField_H
116 
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 namespace Foam
122 {
123 
124 class IFstream;
125 
126 /*---------------------------------------------------------------------------*\
127  Class externalCoupledTemperatureMixedFvPatchScalarField Declaration
128 \*---------------------------------------------------------------------------*/
129 
130 class externalCoupledTemperatureMixedFvPatchScalarField
131 :
132  public externalCoupledMixedFvPatchField<scalar>
133 {
134 
135 protected:
136 
137  // Protected Member Functions
138 
139  //- Write header to transfer file
140  virtual void writeHeader(OFstream& os) const;
141 
142 
143 public:
144 
145  //- Runtime type information
146  TypeName("externalCoupledTemperature");
147 
148 
149  // Constructors
150 
151  //- Construct from patch, internal field and dictionary
153  (
154  const fvPatch&,
155  const DimensionedField<scalar, volMesh>&,
156  const dictionary&
157  );
158 
159  //- Construct by mapping given
160  // externalCoupledTemperatureMixedFvPatchScalarField onto a new patch
162  (
164  const fvPatch&,
166  const fvPatchFieldMapper&
167  );
168 
169  //- Disallow copy without setting internal field reference
171  (
173  ) = delete;
174 
175  //- Copy constructor setting internal field reference
177  (
180  );
181 
182  //- Construct and return a clone setting internal field reference
184  (
186  ) const
187  {
189  (
191  (
192  *this,
193  iF
194  )
195  );
196  }
197 
198 
199  //- Destructor
201 
202 
203  // Member Functions
204 
205  //- Evaluate the patch field
206  virtual void evaluate
207  (
209  );
210 
211  //- Transfer data for external source
212  virtual void transferData(OFstream& os) const;
213 
214  //- Write
215  virtual void write(Ostream&) const;
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Output to file stream.
Definition: OFstream.H:86
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
This boundary condition provides a temperature interface to an external application....
externalCoupledTemperatureMixedFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void writeHeader(OFstream &os) const
Write header to transfer file.
virtual void transferData(OFstream &os) const
Transfer data for external source.
TypeName("externalCoupledTemperature")
Runtime type information.
Foam::fvPatchFieldMapper.
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:203
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.