cyclicACMIFvPatchField.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2019 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::cyclicACMIFvPatchField
29 
30 Group
31  grpCoupledBoundaryConditions
32 
33 Description
34  This boundary condition enforces a cyclic condition between a pair of
35  boundaries, whereby communication between the patches is performed using
36  an arbitrarily coupled mesh interface (ACMI) interpolation.
37 
38 Usage
39  Example of the boundary condition specification:
40  \verbatim
41  <patchName>
42  {
43  type cyclicACMI;
44  }
45  \endverbatim
46 
47 See also
48  Foam::AMIInterpolation
49 
50 SourceFiles
51  cyclicACMIFvPatchField.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef cyclicACMIFvPatchField_H
56 #define cyclicACMIFvPatchField_H
57 
58 #include "coupledFvPatchField.H"
60 #include "cyclicACMIFvPatch.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class cyclicACMIFvPatchField Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class Type>
73 :
74  virtual public cyclicACMILduInterfaceField,
75  public coupledFvPatchField<Type>
76 {
77  // Private data
78 
79  //- Local reference cast into the cyclic patch
80  const cyclicACMIFvPatch& cyclicACMIPatch_;
81 
82 
83  // Private Member Functions
84 
85  //- Return neighbour side field given internal fields
86  template<class Type2>
87  tmp<Field<Type2>> neighbourSideField
88  (
89  const Field<Type2>&
90  ) const;
91 
92  //- Return new matrix coeffs
93  tmp<Field<scalar>> coeffs
94  (
95  fvMatrix<Type>& matrix,
96  const Field<scalar>&,
97  const label
98  ) const;
99 
100 
101 
102 public:
103 
104  //- Runtime type information
105  TypeName(cyclicACMIFvPatch::typeName_());
106 
107 
108  // Constructors
109 
110  //- Construct from patch and internal field
112  (
113  const fvPatch&,
115  );
116 
117  //- Construct from patch, internal field and dictionary
119  (
120  const fvPatch&,
122  const dictionary&
123  );
124 
125  //- Construct by mapping given cyclicACMIFvPatchField onto a new patch
127  (
129  const fvPatch&,
131  const fvPatchFieldMapper&
132  );
133 
134  //- Construct as copy
136 
137  //- Construct and return a clone
138  virtual tmp<fvPatchField<Type>> clone() const
139  {
140  return tmp<fvPatchField<Type>>
141  (
143  );
144  }
145 
146  //- Construct as copy setting internal field reference
148  (
151  );
152 
153  //- Construct and return a clone setting internal field reference
155  (
157  ) const
158  {
159  return tmp<fvPatchField<Type>>
160  (
161  new cyclicACMIFvPatchField<Type>(*this, iF)
162  );
163  }
164 
165 
166  // Member functions
167 
168  // Access
169 
170  //- Return local reference cast into the cyclic AMI patch
171  const cyclicACMIFvPatch& cyclicACMIPatch() const
172  {
173  return cyclicACMIPatch_;
174  }
175 
176 
177  // Evaluation functions
178 
179  //- Return true if coupled. Note that the underlying patch
180  // is not coupled() - the points don't align
181  virtual bool coupled() const;
182 
183  //- Return true if this patch field fixes a value
184  // Needed to check if a level has to be specified while solving
185  // Poisson equations
186  virtual bool fixesValue() const
187  {
188  const scalarField& mask =
189  cyclicACMIPatch_.cyclicACMIPatch().mask();
190 
191  if (gMax(mask) > 1e-5)
192  {
193  // regions connected
194  return false;
195  }
196  else
197  {
198  // fully separated
199  return nonOverlapPatchField().fixesValue();
200  }
201  }
202 
203 
204  //- Return neighbour coupled internal cell data
205  virtual tmp<Field<Type>> patchNeighbourField() const;
206 
207  //- Return reference to neighbour patchField
209 
210  //- Return reference to non-overlapping patchField
212 
213  //- Update result field based on interface functionality
214  virtual void updateInterfaceMatrix
215  (
216  solveScalarField& result,
217  const bool add,
218  const lduAddressing& lduAddr,
219  const label patchId,
220  const solveScalarField& psiInternal,
221  const scalarField& coeffs,
222  const direction cmpt,
223  const Pstream::commsTypes commsType
224  ) const;
225 
226  //- Update result field based on interface functionality
227  virtual void updateInterfaceMatrix
228  (
229  Field<Type>&,
230  const bool add,
231  const lduAddressing& lduAddr,
232  const label patchId,
233  const Field<Type>&,
234  const scalarField&,
235  const Pstream::commsTypes commsType
236  ) const;
237 
238  //- Manipulate matrix
239  virtual void manipulateMatrix(fvMatrix<Type>& matrix);
240 
241  //- Manipulate matrix
242  virtual void manipulateMatrix
243  (
244  fvMatrix<Type>& m,
245  const label iMatrix,
246  const direction cmpt
247  );
248 
249  //- Update the coefficients associated with the patch field
250  virtual void updateCoeffs();
251 
252 
253  // Cyclic AMI coupled interface functions
254 
255  //- Does the patch field perform the transformation
256  virtual bool doTransform() const
257  {
258  return
259  !(cyclicACMIPatch_.parallel() || pTraits<Type>::rank == 0);
260  }
261 
262  //- Return face transformation tensor
263  virtual const tensorField& forwardT() const
264  {
265  return cyclicACMIPatch_.forwardT();
266  }
267 
268  //- Return neighbour-cell transformation tensor
269  virtual const tensorField& reverseT() const
270  {
271  return cyclicACMIPatch_.reverseT();
272  }
273 
274  //- Return rank of component for transform
275  virtual int rank() const
276  {
277  return pTraits<Type>::rank;
278  }
279 
280 
281  // I-O
282 
283  //- Write
284  virtual void write(Ostream& os) const;
285 };
286 
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 } // End namespace Foam
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 #ifdef NoRepository
295  #include "cyclicACMIFvPatchField.C"
296 #endif
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #endif
301 
302 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::cyclicACMIFvPatchField::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicACMIFvPatchField.H:268
Foam::cyclicACMIFvPatchField::nonOverlapPatchField
const fvPatchField< Type > & nonOverlapPatchField() const
Return reference to non-overlapping patchField.
Definition: cyclicACMIFvPatchField.C:212
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::cyclicACMIFvPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: cyclicACMIFvPatchField.H:255
Foam::cyclicACMIFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
Definition: cyclicACMIFvPatchField.H:71
Foam::cyclicACMIFvPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: cyclicACMIFvPatch.H:155
cyclicACMIFvPatchField.C
Foam::cyclicACMILduInterfaceField
Abstract base class for cyclic ACMI coupled interfaces.
Definition: cyclicACMILduInterfaceField.H:51
Foam::cyclicACMIFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: cyclicACMIFvPatchField.C:444
Foam::cyclicACMIFvPatchField::neighbourPatchField
const cyclicACMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Definition: cyclicACMIFvPatchField.C:195
Foam::cyclicACMIFvPatchField::TypeName
TypeName(cyclicACMIFvPatch::typeName_())
Runtime type information.
Foam::cyclicACMIFvPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicACMIFvPatch.H:161
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::cyclicACMIFvPatch::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicACMIFvPatch.H:167
Foam::cyclicACMIFvPatchField::coupled
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
Definition: cyclicACMIFvPatchField.C:153
Foam::cyclicACMIFvPatchField::manipulateMatrix
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
Definition: cyclicACMIFvPatchField.C:294
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::solveScalarField
Field< solveScalar > solveScalarField
Definition: primitiveFieldsFwd.H:53
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
os
OBJstream os(runTime.globalPath()/outputName)
cyclicACMILduInterfaceField.H
Foam::cyclicACMIFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: cyclicACMIFvPatchField.H:137
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cyclicACMIFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: cyclicACMIFvPatchField.C:227
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::cyclicACMIFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: cyclicACMIFvPatchField.H:274
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::cyclicACMIFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicACMIFvPatchField.C:459
Foam::cyclicACMIFvPatch::cyclicACMIPatch
const cyclicACMIPolyPatch & cyclicACMIPatch() const
Return local reference cast into the cyclic patch.
Definition: cyclicACMIFvPatch.H:111
Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField
cyclicACMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicACMIFvPatchField.C:37
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::cyclicACMIFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
Definition: cyclicACMIFvPatchField.C:161
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
cyclicACMIFvPatch.H
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
patchId
label patchId(-1)
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::cyclicACMIFvPatchField::cyclicACMIPatch
const cyclicACMIFvPatch & cyclicACMIPatch() const
Return local reference cast into the cyclic AMI patch.
Definition: cyclicACMIFvPatchField.H:170
coupledFvPatchField.H
Foam::cyclicACMIFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicACMIFvPatchField.H:262
Foam::cyclicACMIPolyPatch::mask
const scalarField & mask() const
Mask field where 1 = overlap(coupled), 0 = no-overlap.
Definition: cyclicACMIPolyPatchI.H:54
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::cyclicACMIFvPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: cyclicACMIFvPatchField.H:185
Foam::cyclicACMIFvPatch
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI)
Definition: cyclicACMIFvPatch.H:54