Loading...
Searching...
No Matches
cyclicAMIPointPatchField.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) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
29#include "transformField.H"
30#include "pointFields.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<class Type>
36(
37 const pointPatch& p,
39)
40:
41 coupledPointPatchField<Type>(p, iF),
42 cyclicAMIPatch_(refCast<const cyclicAMIPointPatch>(p)),
43 ppiPtr_(nullptr),
44 nbrPpiPtr_(nullptr)
45{}
46
47
48template<class Type>
50(
51 const pointPatch& p,
53 const dictionary& dict
54)
55:
56 coupledPointPatchField<Type>(p, iF, dict),
57 cyclicAMIPatch_(refCast<const cyclicAMIPointPatch>(p, dict)),
58 ppiPtr_(nullptr),
59 nbrPpiPtr_(nullptr)
60{
62 {
64 << "patch " << this->patch().index() << " not cyclicAMI type. "
65 << "Patch type = " << p.type()
67 }
68}
69
70
71template<class Type>
73(
74 const cyclicAMIPointPatchField<Type>& ptf,
75 const pointPatch& p,
76 const DimensionedField<Type, pointMesh>& iF,
77 const pointPatchFieldMapper& mapper
78)
79:
80 coupledPointPatchField<Type>(ptf, p, iF, mapper),
81 cyclicAMIPatch_(refCast<const cyclicAMIPointPatch>(p)),
82 ppiPtr_(nullptr),
83 nbrPpiPtr_(nullptr)
84{
86 {
88 << "Field type does not correspond to patch type for patch "
89 << this->patch().index() << "." << endl
90 << "Field type: " << typeName << endl
91 << "Patch type: " << this->patch().type()
92 << exit(FatalError);
93 }
94}
95
96
97template<class Type>
99(
100 const cyclicAMIPointPatchField<Type>& ptf,
101 const DimensionedField<Type, pointMesh>& iF
102)
103:
104 coupledPointPatchField<Type>(ptf, iF),
105 cyclicAMIPatch_(ptf.cyclicAMIPatch_),
106 ppiPtr_(nullptr),
107 nbrPpiPtr_(nullptr)
108{}
109
110
111// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112
113template<class Type>
115{
116 return cyclicAMIPatch_.coupled();
117}
118
119
120template<class Type>
122(
124 Field<Type>& pField
125) const
126{
127 if (cyclicAMIPatch_.cyclicAMIPatch().owner())
128 {
129 // We inplace modify pField. To prevent the other side (which gets
130 // evaluated at a later date) using already changed values we do
131 // all swaps on the side that gets evaluated first.
132
133 // Get neighbouring pointPatch
134 const cyclicAMIPointPatch& nbrPatch = cyclicAMIPatch_.neighbPatch();
135
136 // Get neighbouring pointPatchField
139 (
140 this->internalField()
141 );
142
145 (
146 fld.boundaryField()[nbrPatch.index()]
147 );
148
149
150 Field<Type> ptFld(this->patchInternalField(pField));
151 Field<Type> nbrPtFld(nbr.patchInternalField(pField));
152
153
154 if (doTransform())
155 {
156 const tensor& forwardT = this->forwardT()[0];
157 const tensor& reverseT = this->reverseT()[0];
158
159 transform(ptFld, reverseT, ptFld);
160 transform(nbrPtFld, forwardT, nbrPtFld);
161 }
162
163 // convert point field to face field, AMI interpolate, then
164 // face back to point
165 {
166 // add neighbour side contribution to owner
167 Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
168
169 // interpolate to owner
170 if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection())
171 {
172 Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
173
174 nbrFcFld =
175 cyclicAMIPatch_.cyclicAMIPatch().interpolate
176 (
177 nbrFcFld,
178 fcFld
179 );
180 }
181 else
182 {
183 nbrFcFld =
184 cyclicAMIPatch_.cyclicAMIPatch().interpolate(nbrFcFld);
185 }
186
187 // add to internal field
188 this->addToInternalField
189 (
190 pField,
191 ppi().faceToPointInterpolate(nbrFcFld)()
192 );
193 }
194
195 {
196 // add owner side contribution to neighbour
197 Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
198
199 // interpolate to neighbour
200 if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection())
201 {
202 Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
203
204 fcFld =
205 cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
206 (
207 fcFld,
208 nbrFcFld
209 );
210 }
211 else
212 {
213 fcFld =
214 cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate
215 (
216 fcFld
217 );
218 }
219
220 // add to internal field
221 nbr.addToInternalField
222 (
223 pField,
224 nbrPpi().faceToPointInterpolate(fcFld)()
225 );
226 }
227 }
228}
229
230
231// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Generic GeometricField class.
commsTypes
Communications types.
Definition UPstream.H:81
A Coupled boundary condition for pointField.
coupledPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Cyclic AMI front and back plane patch field.
virtual bool doTransform() const
Does the patch field perform the transformation.
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
cyclicAMIPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual bool coupled() const
Return true if coupled. Note that the underlying patch is not coupled() - the points don't align.
virtual const tensorField & forwardT() const
Return face transformation tensor.
Cyclic AMI point patch - place holder only.
const cyclicAMIPointPatch & neighbPatch() const
Return neighbour point patch.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
label index() const noexcept
The index of this patch in the boundaryMesh.
const pointPatch & patch() const noexcept
Return the patch.
Foam::pointPatchFieldMapper.
void patchInternalField(const UList< Type1 > &internalData, const labelUList &addressing, UList< Type1 > &pfld) const
Extract field using specified addressing.
void addToInternalField(Field< Type1 > &iF, const Field< Type1 > &pF) const
Given the internal field and a patch field, add the patch field to the internal field.
const DimensionedField< Type, pointMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Basic pointPatch represents a set of points from the mesh.
Definition pointPatch.H:67
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Tensor< scalar > tensor
Definition symmTensor.H:57
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
Definition typeInfo.H:112
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
dictionary dict
Spatial transformation functions for primitive fields.