mixedFaPatchField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 Wikki Ltd
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::mixedFaPatchField
29 
30 Description
31  This boundary condition provides a base class for 'mixed' type boundary
32  conditions, i.e. conditions that mix fixed value and patch-normal gradient
33  conditions.
34 
35 Usage
36  \table
37  Property | Description | Required | Default
38  refValue | fixed value | yes |
39  refGradient | patch normal gradient | yes |
40  valueFraction | value weighting (0-1) | yes |
41  \endtable
42 
43 Author
44  Zeljko Tukovic, FMENA
45  Hrvoje Jasak, Wikki Ltd.
46 
47 SourceFiles
48  mixedFaPatchField.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef Foam_mixedFaPatchField_H
53 #define Foam_mixedFaPatchField_H
54 
55 #include "faPatchField.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class mixedFaPatchField Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class Type>
67 class mixedFaPatchField
68 :
69  public faPatchField<Type>
70 {
71  // Private Data
72 
73  //- Value field
74  Field<Type> refValue_;
75 
76  //- Normal gradient field
77  Field<Type> refGrad_;
78 
79  //- Fraction (0-1) of value used for boundary condition
80  scalarField valueFraction_;
81 
82 protected:
83 
84  //- Read the "refValue", "refGradient" and "valueFraction" entries
85  //- into their respective places.
86  // The reading can be optional (default), mandatory etc.
87  // If refValue is to be read, refGradient and valueFraction must
88  // also exist.
89  // \returns True on success
90  bool readMixedEntries
91  (
92  const dictionary& dict,
94  );
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("mixed");
101 
102 
103  // Constructors
104 
105  //- Construct from patch and internal field
107  (
108  const faPatch&,
110  );
111 
112  //- Construct from patch and internal field,
113  //- initialise as zero-gradient
115  (
116  const faPatch&,
118  const Foam::zero
119  );
120 
121  //- Construct from patch, internal field and dictionary
123  (
124  const faPatch&,
126  const dictionary&,
130  );
131 
132  //- Construct by mapping the given mixedFaPatchField onto a new patch
134  (
136  const faPatch&,
138  const faPatchFieldMapper&
139  );
140 
141  //- Construct as copy
143  (
145  );
146 
147  //- Construct and return a clone
148  virtual tmp<faPatchField<Type>> clone() const
149  {
150  return tmp<faPatchField<Type>>
151  (
152  new mixedFaPatchField<Type>(*this)
153  );
154  }
155 
156  //- Construct as copy setting internal field reference
158  (
161  );
162 
163  //- Construct and return a clone setting internal field reference
165  (
167  ) const
168  {
169  return tmp<faPatchField<Type>>
170  (
171  new mixedFaPatchField<Type>(*this, iF)
172  );
173  }
174 
175 
176  // Member Functions
177 
178  //- True: the patch field fixes a value.
179  virtual bool fixesValue() const { return true; }
180 
181 
182  // Return defining fields
183 
184  virtual Field<Type>& refValue()
185  {
186  return refValue_;
187  }
188 
189  virtual const Field<Type>& refValue() const
190  {
191  return refValue_;
192  }
193 
194  virtual Field<Type>& refGrad()
195  {
196  return refGrad_;
197  }
198 
199  virtual const Field<Type>& refGrad() const
200  {
201  return refGrad_;
202  }
203 
204  virtual scalarField& valueFraction()
205  {
206  return valueFraction_;
207  }
208 
209  virtual const scalarField& valueFraction() const
210  {
211  return valueFraction_;
212  }
213 
214 
215  // Mapping functions
216 
217  //- Map (and resize as needed) from self given a mapping object
218  virtual void autoMap
219  (
220  const faPatchFieldMapper&
221  );
222 
223  //- Reverse map the given faPatchField onto this faPatchField
224  virtual void rmap
225  (
226  const faPatchField<Type>&,
227  const labelList&
228  );
229 
230 
231  // Evaluation functions
232 
233  //- Return gradient at boundary
234  virtual tmp<Field<Type>> snGrad() const;
235 
236  //- Evaluate the patch field
237  virtual void evaluate
238  (
239  const Pstream::commsTypes commsType =
241  );
242 
243  //- Return the matrix diagonal coefficients corresponding to the
244  // evaluation of the value of this patchField with given weights
246  (
247  const tmp<scalarField>&
248  ) const;
249 
250  //- Return the matrix source coefficients corresponding to the
251  // evaluation of the value of this patchField with given weights
253  (
254  const tmp<scalarField>&
255  ) const;
256 
257  //- Return the matrix diagonal coefficients corresponding to the
258  // evaluation of the gradient of this patchField
259  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
260 
261  //- Return the matrix source coefficients corresponding to the
262  // evaluation of the gradient of this patchField
263  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
264 
265 
266  //- Write
267  virtual void write(Ostream&) const;
268 
269 
270  // Member Operators
271 
272  virtual void operator=(const UList<Type>&) {}
273 
274  virtual void operator=(const faPatchField<Type>&) {}
275  virtual void operator+=(const faPatchField<Type>&) {}
276  virtual void operator-=(const faPatchField<Type>&) {}
277  virtual void operator*=(const faPatchField<scalar>&) {}
278  virtual void operator/=(const faPatchField<scalar>&) {}
279 
280  virtual void operator+=(const Field<Type>&) {}
281  virtual void operator-=(const Field<Type>&) {}
282 
283  virtual void operator*=(const Field<scalar>&) {}
284  virtual void operator/=(const Field<scalar>&) {}
285 
286  virtual void operator=(const Type&) {}
287  virtual void operator+=(const Type&) {}
288  virtual void operator-=(const Type&) {}
289  virtual void operator*=(const scalar) {}
290  virtual void operator/=(const scalar) {}
291 };
292 
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 } // End namespace Foam
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #ifdef NoRepository
301  #include "mixedFaPatchField.C"
302 #endif
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
dictionary dict
"blocking" : (MPI_Bsend, MPI_Recv)
commsTypes
Communications types.
Definition: UPstream.H:72
virtual void operator=(const UList< Type > &)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void operator-=(const faPatchField< Type > &)
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
virtual bool fixesValue() const
True: the patch field fixes a value.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
virtual void operator/=(const faPatchField< scalar > &)
virtual Field< Type > & refValue()
bool readMixedEntries(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "refValue", "refGradient" and "valueFraction" entries into their respective places...
Generic templated field type.
Definition: Field.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual scalarField & valueFraction()
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
virtual void operator+=(const faPatchField< Type > &)
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
virtual void operator*=(const faPatchField< scalar > &)
mixedFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual void write(Ostream &) const
Write.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Reading is optional [identical to READ_IF_PRESENT].
virtual tmp< faPatchField< Type > > clone() const
Construct and return a clone.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
A FieldMapper for finite-area patch fields.
virtual Field< Type > & refGrad()
Namespace for OpenFOAM.
TypeName("mixed")
Runtime type information.
readOption
Enumeration defining read preferences.