cyclicACMIPointPatchField.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-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 cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(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 cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p, dict)),
58 ppiPtr_(nullptr),
59 nbrPpiPtr_(nullptr)
60{
61 if (!isType<cyclicACMIPointPatch>(p))
62 {
64 << "patch " << this->patch().index() << " not cyclicACMI type. "
65 << "Patch type = " << p.type()
67 }
68}
69
70
71template<class Type>
73(
75 const pointPatch& p,
77 const pointPatchFieldMapper& mapper
78)
79:
80 coupledPointPatchField<Type>(ptf, p, iF, mapper),
81 cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
82 ppiPtr_(nullptr),
83 nbrPpiPtr_(nullptr)
84{
85 if (!isType<cyclicACMIPointPatch>(this->patch()))
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(
102)
103:
104 coupledPointPatchField<Type>(ptf, iF),
105 cyclicACMIPatch_(ptf.cyclicACMIPatch_),
106 ppiPtr_(nullptr),
107 nbrPpiPtr_(nullptr)
108{}
109
110
111// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112
113template<class Type>
115(
117 Field<Type>& pField
118) const
119{
120 if (cyclicACMIPatch_.cyclicACMIPatch().owner())
121 {
122 // We inplace modify pField. To prevent the other side (which gets
123 // evaluated at a later date) using already changed values we do
124 // all swaps on the side that gets evaluated first.
125
126 // Get neighbouring pointPatch
127 const cyclicACMIPointPatch& nbrPatch = cyclicACMIPatch_.neighbPatch();
128
129 // Get neighbouring pointPatchField
131 refCast<const GeometricField<Type, pointPatchField, pointMesh>>
132 (
133 this->internalField()
134 );
135
137 refCast<const cyclicACMIPointPatchField<Type>>
138 (
139 fld.boundaryField()[nbrPatch.index()]
140 );
141
142
143 Field<Type> ptFld(this->patchInternalField(pField));
144 Field<Type> nbrPtFld(nbr.patchInternalField(pField));
145
146
147 if (doTransform())
148 {
149 const tensor& forwardT = this->forwardT()[0];
150 const tensor& reverseT = this->reverseT()[0];
151
152 transform(ptFld, reverseT, ptFld);
153 transform(nbrPtFld, forwardT, nbrPtFld);
154 }
155
156 // convert point field to face field, AMI interpolate, then
157 // face back to point
158 {
159 // add neighbour side contribution to owner
160 Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
161
162 const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch();
163
164 // interpolate to owner
165 nbrFcFld = cami.interpolate(nbrFcFld);
166
167 // add to internal field
168 this->addToInternalField
169 (
170 pField,
171 ppi().faceToPointInterpolate(nbrFcFld)()
172 );
173 }
174
175 {
176 // add owner side contribution to neighbour
177 Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
178
179 const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch();
180
181 // interpolate to neighbour
182 fcFld = cami.neighbPatch().cyclicAMIPolyPatch::interpolate(fcFld);
183
184 // add to internal field
185 nbr.addToInternalField
186 (
187 pField,
188 nbrPpi().faceToPointInterpolate(fcFld)()
189 );
190 }
191 }
192}
193
194
195// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-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.
Definition: Field.H:82
Generic GeometricField class.
commsTypes
Types of communications.
Definition: UPstream.H:67
A Coupled boundary condition for pointField.
Cyclic ACMI front and back plane patch field.
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
Cyclic AMI point patch - place holder only.
const cyclicACMIPointPatch & neighbPatch() const
Return neighbour point patch.
Cyclic patch for Arbitrary Mesh Interface (AMI)
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
tmp< Field< Type > > interpolate(const Field< Type > &fld, const UList< Type > &defaultValues=UList< Type >()) const
Interpolate field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
Foam::pointPatchFieldMapper.
const pointPatch & patch() const
Return patch.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
virtual label index() const =0
Return the index of this patch in the pointBoundaryMesh.
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
Spatial transformation functions for primitive fields.