cyclicAMIFvsPatchField.C
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) 2011-2021 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 \*---------------------------------------------------------------------------*/
25 
26 #include "cyclicAMIFvsPatchField.H"
27 #include "GeometricField.H"
28 #include "surfaceMesh.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const fvPatch& p,
37 )
38 :
40  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
41 {}
42 
43 
44 template<class Type>
46 (
48  const fvPatch& p,
50  const fvPatchFieldMapper& mapper
51 )
52 :
53  coupledFvsPatchField<Type>(ptf, p, iF, mapper),
54  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
55 {
56  if (!isA<cyclicAMIFvPatch>(this->patch()))
57  {
59  << "Field type does not correspond to patch type for patch "
60  << this->patch().index() << "." << endl
61  << "Field type: " << typeName << endl
62  << "Patch type: " << this->patch().type()
63  << exit(FatalError);
64  }
65 }
66 
67 
68 template<class Type>
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
77  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
78 {
79  if (!isA<cyclicAMIFvPatch>(p))
80  {
82  (
83  dict
84  ) << "patch " << this->patch().index() << " not cyclicAMI type. "
85  << "Patch type = " << p.type()
86  << exit(FatalIOError);
87  }
88 }
89 
90 
91 template<class Type>
93 (
96 )
97 :
99  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
105 template<class Type>
107 {
108  return cyclicAMIPatch_.coupled();
109 }
110 
111 
112 template<class Type>
115 (
116  const Pstream::commsTypes commsType
117 ) const
118 {
120  const geoField& gf = refCast<const geoField>(this->internalField());
121 
122  const cyclicAMIFvPatch& cp = refCast<const cyclicAMIFvPatch>(this->patch());
123 
124  const Field<Type>& pnf = gf.boundaryField()[cp.nbrPatchID()];
125 
126  tmp<Field<Type>> tpnf;
127  if (cp.applyLowWeightCorrection())
128  {
129  tpnf = cyclicAMIPatch_.interpolate(pnf, *this);
130  }
131  else
132  {
133  tpnf = cyclicAMIPatch_.interpolate(pnf);
134  }
135 
136  cp.transform().transform(tpnf.ref(), tpnf());
137 
138  return tpnf;
139 }
140 
141 
142 // ************************************************************************* //
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
commsTypes
Types of communications.
Definition: UPstream.H:64
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
Cyclic patch for Arbitrary Mesh Interface (AMI)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:753
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Generic GeometricField class.
virtual bool coupled() const
Return true if running parallel.
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes commsType) const
Return patchField on the opposite patch of a coupled patch.
cyclicAMIFvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
Foam::coupledFvsPatchField.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Foam::cyclicAMIFvsPatchField.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
IOerror FatalIOError