externalCoupledTemperatureMixedFvPatchScalarField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2013-2016 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 Group
28  grpCoupledBoundaryConditions
29 
30 Description
31  This boundary condition provides a temperature interface to an external
32  application. Values are transferred as plain text files, where OpenFOAM
33  data is written as:
34 
35  \verbatim
36  # Patch: <patch name>
37  <magSf1> <value1> <qDot1> <htc1>
38  <magSf2> <value2> <qDot2> <htc2>
39  <magSf3> <value3> <qDot3> <htc2>
40  ...
41  <magSfN> <valueN> <qDotN> <htcN>
42  \endverbatim
43 
44  and received as the constituent pieces of the `mixed' condition, i.e.
45 
46  \verbatim
47  # Patch: <patch name>
48  <value1> <gradient1> <valueFraction1>
49  <value2> <gradient2> <valueFraction2>
50  <value3> <gradient3> <valueFraction3>
51  ...
52  <valueN> <gradientN> <valueFractionN>
53  \endverbatim
54 
55  Data is sent/received as a single file for all patches from the directory
56 
57  \verbatim
58  $FOAM_CASE/<commsDir>
59  \endverbatim
60 
61  At start-up, the boundary creates a lock file, i.e..
62 
63  \verbatim
64  OpenFOAM.lock
65  \endverbatim
66 
67  ... to signal the external source to wait. During the boundary condition
68  update, boundary values are written to file, e.g.
69 
70  \verbatim
71  <fileName>.out
72  \endverbatim
73 
74  The lock file is then removed, instructing the external source to take
75  control of the program execution. When ready, the external program
76  should create the return values, e.g. to file
77 
78  \verbatim
79  <fileName>.in
80  \endverbatim
81 
82  ... and then re-instate the lock file. The boundary condition will then
83  read the return values, and pass program execution back to OpenFOAM.
84 
85 
86 Usage
87  \table
88  Property | Description | Required | Default value
89  commsDir | communications directory | yes |
90  fileName | transfer file name | yes |
91  waitInterval | interval [s] between file checks | no | 1
92  timeOut | time after which error invoked [s] |no |100*waitInterval
93  calcFrequency | calculation frequency | no | 1
94  log | log program control | no | no
95  \endtable
96 
97  Example of the boundary condition specification:
98  \verbatim
99  <patchName>
100  {
101  type externalCoupledTemperature;
102  commsDir "$FOAM_CASE/comms";
103  fileName data;
104  calcFrequency 1;
105  }
106  \endverbatim
107 
108 See also
109  mixedFvPatchField
110  externalCoupledMixedFvPatchField
111 
112 SourceFiles
113  externalCoupledTemperatureMixedFvPatchScalarField.C
114 
115 \*---------------------------------------------------------------------------*/
116 
117 #ifndef externalCoupledTemperatureMixedFvPatchScalarField_H
118 #define externalCoupledTemperatureMixedFvPatchScalarField_H
119 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 namespace Foam
125 {
126 
127 class IFstream;
128 
129 /*---------------------------------------------------------------------------*\
130  Class externalCoupledTemperatureMixedFvPatchScalarField Declaration
131 \*---------------------------------------------------------------------------*/
132 
133 class externalCoupledTemperatureMixedFvPatchScalarField
134 :
135  public externalCoupledMixedFvPatchField<scalar>
136 {
137 
138 protected:
139 
140  // Protected Member Functions
141 
142  //- Write header to transfer file
143  virtual void writeHeader(OFstream& os) const;
144 
145 
146 public:
147 
148  //- Runtime type information
149  TypeName("externalCoupledTemperature");
150 
151 
152  // Constructors
153 
154  //- Construct from patch and internal field
156  (
157  const fvPatch&,
158  const DimensionedField<scalar, volMesh>&
159  );
160 
161  //- Construct from patch, internal field and dictionary
163  (
164  const fvPatch&,
165  const DimensionedField<scalar, volMesh>&,
166  const dictionary&
167  );
168 
169  //- Construct by mapping given
170  // externalCoupledTemperatureMixedFvPatchScalarField onto a new patch
172  (
174  const fvPatch&,
176  const fvPatchFieldMapper&
177  );
178 
179  //- Construct as copy
181  (
183  );
184 
185  //- Construct and return a clone
186  virtual tmp<fvPatchField<scalar>> clone() const
187  {
189  (
191  );
192  }
193 
194  //- Construct as copy setting internal field reference
196  (
199  );
200 
201  //- Construct and return a clone setting internal field reference
203  (
205  ) const
206  {
208  (
210  (
211  *this,
212  iF
213  )
214  );
215  }
216 
217 
218  //- Destructor
221 
222  // Member functions
223 
224  // Evaluation functions
225 
226  //- Evaluate the patch field
227  virtual void evaluate
228  (
229  const Pstream::commsTypes commsType=Pstream::blocking
230  );
231 
232  //- Transfer data for external source
233  virtual void transferData(OFstream& os) const;
234 
235 
236  //- Write
237  virtual void write(Ostream&) const;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
commsTypes
Types of communications.
Definition: UPstream.H:64
Output to file stream.
Definition: OFstream.H:81
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 transferData(OFstream &os) const
Transfer data for external source.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Foam::fvPatchFieldMapper.
virtual tmp< fvPatchField< scalar > > clone() const
Construct and return a clone.
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:53
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void writeHeader(OFstream &os) const
Write header to transfer file.
TypeName("externalCoupledTemperature")
Runtime type information.
A class for managing temporary objects.
Definition: PtrList.H:54
Namespace for OpenFOAM.