cyclicACMIFvPatchField.C
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-2017 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 \*---------------------------------------------------------------------------*/
28 
29 #include "cyclicACMIFvPatchField.H"
30 #include "transformField.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
43  cyclicACMIPatch_(refCast<const cyclicACMIFvPatch>(p))
44 {}
45 
46 
47 template<class Type>
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
56  coupledFvPatchField<Type>(p, iF, dict, dict.found("value")),
57  cyclicACMIPatch_(refCast<const cyclicACMIFvPatch>(p, dict))
58 {
59  if (!isA<cyclicACMIFvPatch>(p))
60  {
62  << " patch type '" << p.type()
63  << "' not constraint type '" << typeName << "'"
64  << "\n for patch " << p.name()
65  << " of field " << this->internalField().name()
66  << " in file " << this->internalField().objectPath()
67  << exit(FatalIOError);
68  }
69 
70  if (!dict.found("value") && this->coupled())
71  {
72  // Extra check: make sure that the non-overlap patch is before
73  // this so it has actually been read - evaluate will crash otherwise
74 
77  (
78  this->primitiveField()
79  );
80  if (!fld.boundaryField().set(cyclicACMIPatch_.nonOverlapPatchID()))
81  {
83  << " patch " << p.name()
84  << " of field " << this->internalField().name()
85  << " refers to non-overlap patch "
86  << cyclicACMIPatch_.cyclicACMIPatch().nonOverlapPatchName()
87  << " which is not constructed yet." << nl
88  << " Either supply an initial value or change the ordering"
89  << " in the file"
90  << exit(FatalIOError);
91  }
92 
93  this->evaluate(Pstream::commsTypes::blocking);
94  }
95 }
96 
97 
98 template<class Type>
100 (
101  const cyclicACMIFvPatchField<Type>& ptf,
102  const fvPatch& p,
104  const fvPatchFieldMapper& mapper
105 )
106 :
108  coupledFvPatchField<Type>(ptf, p, iF, mapper),
109  cyclicACMIPatch_(refCast<const cyclicACMIFvPatch>(p))
110 {
111  if (!isA<cyclicACMIFvPatch>(this->patch()))
112  {
114  << "' not constraint type '" << typeName << "'"
115  << "\n for patch " << p.name()
116  << " of field " << this->internalField().name()
117  << " in file " << this->internalField().objectPath()
118  << exit(FatalIOError);
119  }
120 }
121 
122 
123 
124 template<class Type>
126 (
128 )
129 :
132  cyclicACMIPatch_(ptf.cyclicACMIPatch_)
133 {}
134 
135 
136 template<class Type>
138 (
139  const cyclicACMIFvPatchField<Type>& ptf,
141 )
142 :
144  coupledFvPatchField<Type>(ptf, iF),
145  cyclicACMIPatch_(ptf.cyclicACMIPatch_)
146 {}
147 
148 
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 
151 template<class Type>
153 {
154  return cyclicACMIPatch_.coupled();
155 }
156 
157 
158 template<class Type>
161 {
162  const Field<Type>& iField = this->primitiveField();
163  const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
164  tmp<Field<Type>> tpnf
165  (
166  cyclicACMIPatch_.interpolate
167  (
169  (
170  iField,
171  cpp.neighbPatch().faceCells()
172  )
173  )
174  );
175 
176  if (doTransform())
177  {
178  tpnf.ref() = transform(forwardT(), tpnf());
179  }
180 
181  return tpnf;
182 }
183 
184 
185 template<class Type>
188 {
191  (
192  this->primitiveField()
193  );
194 
195  return refCast<const cyclicACMIFvPatchField<Type>>
196  (
197  fld.boundaryField()[cyclicACMIPatch_.neighbPatchID()]
198  );
199 }
200 
201 
202 template<class Type>
205 {
208  (
209  this->primitiveField()
210  );
211 
212  return fld.boundaryField()[cyclicACMIPatch_.nonOverlapPatchID()];
213 }
214 
215 
216 template<class Type>
218 (
219  solveScalarField& result,
220  const bool add,
221  const solveScalarField& psiInternal,
222  const scalarField& coeffs,
223  const direction cmpt,
224  const Pstream::commsTypes
225 ) const
226 {
227  const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
228 
229  // Note: only applying coupled contribution
230 
231  const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells();
232 
233  solveScalarField pnf(psiInternal, nbrFaceCellsCoupled);
234 
235  // Transform according to the transformation tensors
236  transformCoupleField(pnf, cmpt);
237 
238  pnf = cyclicACMIPatch_.interpolate(pnf);
239 
240  this->addToInternalField(result, !add, coeffs, pnf);
241 }
242 
243 
244 template<class Type>
246 (
247  Field<Type>& result,
248  const bool add,
249  const Field<Type>& psiInternal,
250  const scalarField& coeffs,
251  const Pstream::commsTypes
252 ) const
253 {
254  const cyclicACMIPolyPatch& cpp = cyclicACMIPatch_.cyclicACMIPatch();
255 
256  // Note: only applying coupled contribution
257 
258  const labelUList& nbrFaceCellsCoupled = cpp.neighbPatch().faceCells();
259 
260  Field<Type> pnf(psiInternal, nbrFaceCellsCoupled);
261 
262  // Transform according to the transformation tensors
263  transformCoupleField(pnf);
264 
265  pnf = cyclicACMIPatch_.interpolate(pnf);
266 
267  this->addToInternalField(result, !add, coeffs, pnf);
268 }
269 
270 
271 template<class Type>
273 (
274  fvMatrix<Type>& matrix
275 )
276 {
277  const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
278 
279  // Nothing to be done by the AMI, but re-direct to non-overlap patch
280  // with non-overlap patch weights
281  const fvPatchField<Type>& npf = nonOverlapPatchField();
282 
283  const_cast<fvPatchField<Type>&>(npf).manipulateMatrix(matrix, 1.0 - mask);
284 }
285 
286 
287 template<class Type>
289 {
290  // Update non-overlap patch - some will implement updateCoeffs, and
291  // others will implement evaluate
292 
293  // Pass in (1 - mask) to give non-overlap patch the chance to do
294  // manipulation of non-face based data
295 
296  const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask();
297  const fvPatchField<Type>& npf = nonOverlapPatchField();
298  const_cast<fvPatchField<Type>&>(npf).updateWeightedCoeffs(1.0 - mask);
299 }
300 
301 
302 template<class Type>
304 {
306  this->writeEntry("value", os);
307 }
308 
309 
310 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::cyclicACMIFvPatchField::nonOverlapPatchField
const fvPatchField< Type > & nonOverlapPatchField() const
Return reference to non-overlapping patchField.
Definition: cyclicACMIFvPatchField.C:204
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::cyclicACMIFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
Definition: cyclicACMIFvPatchField.H:71
Foam::FatalIOError
IOerror FatalIOError
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
Foam::cyclicACMILduInterfaceField
Abstract base class for cyclic ACMI coupled interfaces.
Definition: cyclicACMILduInterfaceField.H:51
transformField.H
Spatial transformation functions for primitive fields.
Foam::cyclicACMIFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: cyclicACMIFvPatchField.C:288
Foam::cyclicACMIFvPatchField::neighbourPatchField
const cyclicACMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Definition: cyclicACMIFvPatchField.C:187
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::cyclicACMIFvPatchField::coupled
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
Definition: cyclicACMIFvPatchField.C:152
Foam::cyclicACMIFvPatchField::manipulateMatrix
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
Definition: cyclicACMIFvPatchField.C:273
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::cyclicACMIFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: cyclicACMIFvPatchField.C:218
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:363
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::cyclicACMIPolyPatch::neighbPatch
virtual const cyclicACMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
Definition: cyclicACMIPolyPatch.C:743
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::cyclicACMIFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicACMIFvPatchField.C:303
Foam::cyclicACMIFvPatchField::cyclicACMIFvPatchField
cyclicACMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicACMIFvPatchField.C:36
Foam::UList< label >
Foam::cyclicACMIFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
Definition: cyclicACMIFvPatchField.C:160
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:76
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::cyclicACMIPolyPatch
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI).
Definition: cyclicACMIPolyPatch.H:79
Foam::GeometricField< Type, fvPatchField, volMesh >
cyclicACMIFvPatchField.H
Foam::stringOps::evaluate
string evaluate(const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:37
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54