cyclicFvsPatchField.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-2023 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 "cyclicFvsPatchField.H"
27 #include "GeometricField.H"
28 #include "surfaceMesh.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const fvPatch& p,
37 )
38 :
39  coupledFvsPatchField<Type>(p, iF),
40  cyclicPatch_(refCast<const cyclicFvPatch>(p))
41 {}
42 
43 
44 template<class Type>
46 (
47  const fvPatch& p,
49  const dictionary& dict
50 )
51 :
52  coupledFvsPatchField<Type>(p, iF, dict),
53  cyclicPatch_(refCast<const cyclicFvPatch>(p))
54 {
55  if (!isA<cyclicFvPatch>(p))
56  {
58  (
59  dict
60  ) << "patch " << this->patch().index() << " not cyclic type. "
61  << "Patch type = " << p.type()
62  << exit(FatalIOError);
63  }
64 }
65 
66 
67 template<class Type>
69 (
70  const cyclicFvsPatchField<Type>& ptf,
71  const fvPatch& p,
73  const fieldMapper& mapper
74 )
75 :
76  coupledFvsPatchField<Type>(ptf, p, iF, mapper),
77  cyclicPatch_(refCast<const cyclicFvPatch>(p))
78 {
79  if (!isA<cyclicFvPatch>(this->patch()))
80  {
82  << "Field type does not correspond to patch type for patch "
83  << this->patch().index() << "." << endl
84  << "Field type: " << typeName << endl
85  << "Patch type: " << this->patch().type()
86  << exit(FatalError);
87  }
88 }
89 
90 
91 template<class Type>
93 (
94  const cyclicFvsPatchField<Type>& ptf,
96 )
97 :
98  coupledFvsPatchField<Type>(ptf, iF),
99  cyclicPatch_(ptf.cyclicPatch_)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
105 template<class Type>
108 (
109  const Pstream::commsTypes commsType
110 ) const
111 {
112  const SurfaceField<Type>& gf =
113  refCast<const SurfaceField<Type>>(this->internalField());
114 
115  const cyclicFvPatch& cp = refCast<const cyclicFvPatch>(this->patch());
116 
117  tmp<Field<Type>> tresult
118  (
119  new Field<Type>(gf.boundaryField()[cp.nbrPatchIndex()])
120  );
121 
122  cp.transform().transform(tresult.ref(), tresult.ref());
123 
124  return tresult;
125 }
126 
127 
128 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:83
static const char *const typeName
Definition: Field.H:106
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
commsTypes
Types of communications.
Definition: UPstream.H:65
Foam::coupledFvsPatchField.
Cyclic-plane patch.
Definition: cyclicFvPatch.H:55
Foam::cyclicFvsPatchField.
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes commsType) const
Return patchField on the opposite patch of a coupled patch.
cyclicFvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:156
const fvPatch & patch() const
Return patch.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:129
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
IOerror FatalIOError
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
error FatalError
dictionary dict
volScalarField & p