All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2020 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 constitutent 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 and internal field
153  (
154  const fvPatch&,
155  const DimensionedField<scalar, volMesh>&
156  );
157 
158  //- Construct from patch, internal field and dictionary
160  (
161  const fvPatch&,
162  const DimensionedField<scalar, volMesh>&,
163  const dictionary&
164  );
165 
166  //- Construct by mapping given
167  // externalCoupledTemperatureMixedFvPatchScalarField onto a new patch
169  (
171  const fvPatch&,
173  const fvPatchFieldMapper&
174  );
175 
176  //- Copy constructor
178  (
180  );
181 
182  //- Construct and return a clone
183  virtual tmp<fvPatchField<scalar>> clone() const
184  {
186  (
188  );
189  }
190 
191  //- Copy constructor setting internal field reference
193  (
196  );
197 
198  //- Construct and return a clone setting internal field reference
200  (
202  ) const
203  {
205  (
207  (
208  *this,
209  iF
210  )
211  );
212  }
213 
214 
215  //- Destructor
218 
219  // Member Functions
220 
221  //- Evaluate the patch field
222  virtual void evaluate
223  (
225  );
226 
227  //- Transfer data for external source
228  virtual void transferData(OFstream& os) const;
229 
230  //- Write
231  virtual void write(Ostream&) const;
232 };
233 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
commsTypes
Types of communications.
Definition: UPstream.H:64
Output to file stream.
Definition: OFstream.H:82
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
externalCoupledTemperatureMixedFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Foam::fvPatchFieldMapper.
This boundary condition provides a temperature interface to an external application. Values are transferred as plain text files, where OpenFOAM data is written as:
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual void writeHeader(OFstream &os) const
Write header to transfer file.
virtual void transferData(OFstream &os) const
Transfer data for external source.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< fvPatchField< scalar > > clone() const
Construct and return a clone.
TypeName("externalCoupledTemperature")
Runtime type information.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.