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 | Copyright (C) 2013 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 
27 #include "Swap.H"
28 #include "transformField.H"
29 #include "pointFields.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const pointPatch& p,
38 )
39 :
41  cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
42  ppiPtr_(NULL),
43  nbrPpiPtr_(NULL)
44 {}
45 
46 
47 template<class Type>
49 (
50  const pointPatch& p,
52  const dictionary& dict
53 )
54 :
56  cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
57  ppiPtr_(NULL),
58  nbrPpiPtr_(NULL)
59 {
60  if (!isType<cyclicACMIPointPatch>(p))
61  {
63  (
64  "cyclicACMIPointPatchField<Type>::cyclicACMIPointPatchField\n"
65  "(\n"
66  " const pointPatch&,\n"
67  " const DimensionedField<Type, pointMesh>&,\n"
68  " const dictionary&\n"
69  ")\n",
70  dict
71  ) << "patch " << this->patch().index() << " not cyclicACMI type. "
72  << "Patch type = " << p.type()
73  << exit(FatalIOError);
74  }
75 }
76 
77 
78 template<class Type>
80 (
82  const pointPatch& p,
84  const pointPatchFieldMapper& mapper
85 )
86 :
87  coupledPointPatchField<Type>(ptf, p, iF, mapper),
88  cyclicACMIPatch_(refCast<const cyclicACMIPointPatch>(p)),
89  ppiPtr_(NULL),
90  nbrPpiPtr_(NULL)
91 {
92  if (!isType<cyclicACMIPointPatch>(this->patch()))
93  {
95  (
96  "cyclicACMIPointPatchField<Type>::cyclicACMIPointPatchField\n"
97  "(\n"
98  " const cyclicACMIPointPatchField<Type>&,\n"
99  " const pointPatch&,\n"
100  " const DimensionedField<Type, pointMesh>&,\n"
101  " const pointPatchFieldMapper&\n"
102  ")\n"
103  ) << "Field type does not correspond to patch type for patch "
104  << this->patch().index() << "." << endl
105  << "Field type: " << typeName << endl
106  << "Patch type: " << this->patch().type()
107  << exit(FatalError);
108  }
109 }
110 
111 
112 template<class Type>
114 (
117 )
118 :
120  cyclicACMIPatch_(ptf.cyclicACMIPatch_),
121  ppiPtr_(NULL),
122  nbrPpiPtr_(NULL)
123 {}
124 
125 
126 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 
128 template<class Type>
130 (
131  const Pstream::commsTypes,
132  Field<Type>& pField
133 ) const
134 {
135  if (cyclicACMIPatch_.cyclicACMIPatch().owner())
136  {
137  // We inplace modify pField. To prevent the other side (which gets
138  // evaluated at a later date) using already changed values we do
139  // all swaps on the side that gets evaluated first.
140 
141  // Get neighbouring pointPatch
142  const cyclicACMIPointPatch& nbrPatch = cyclicACMIPatch_.neighbPatch();
143 
144  // Get neighbouring pointPatchField
146  refCast<const GeometricField<Type, pointPatchField, pointMesh> >
147  (
149  );
150 
152  refCast<const cyclicACMIPointPatchField<Type> >
153  (
154  fld.boundaryField()[nbrPatch.index()]
155  );
156 
157 
158  Field<Type> ptFld(this->patchInternalField(pField));
159  Field<Type> nbrPtFld(nbr.patchInternalField(pField));
160 
161 
162  if (doTransform())
163  {
164  const tensor& forwardT = this->forwardT()[0];
165  const tensor& reverseT = this->reverseT()[0];
166 
167  transform(ptFld, reverseT, ptFld);
168  transform(nbrPtFld, forwardT, nbrPtFld);
169  }
170 
171  // convert point field to face field, AMI interpolate, then
172  // face back to point
173  {
174  // add neighbour side contribution to owner
175  Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld));
176 
177  const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch();
178 
179  // interpolate to owner
180  nbrFcFld = cami.interpolate(nbrFcFld);
181 
182  // add to internal field
183  this->addToInternalField
184  (
185  pField,
186  ppi().faceToPointInterpolate(nbrFcFld)()
187  );
188  }
189 
190  {
191  // add owner side contribution to neighbour
192  Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld));
193 
194  const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch();
195 
196  // interpolate to neighbour
197  fcFld = cami.neighbPatch().cyclicAMIPolyPatch::interpolate(fcFld);
198 
199  // add to internal field
200  nbr.addToInternalField
201  (
202  pField,
203  nbrPpi().faceToPointInterpolate(fcFld)()
204  );
205  }
206  }
207 }
208 
209 
210 // ************************************************************************* //
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
Cyclic patch for Arbitrary Mesh Interface (AMI)
Cyclic AMI point patch - place holder only.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A Coupled boundary condition for pointField.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
dictionary dict
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOerror FatalIOError
volScalarField & p
Definition: createFields.H:51
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
commsTypes
Types of communications.
Definition: UPstream.H:64
Spatial transformation functions for primitive fields.
Swap its arguments.
tmp< Field< Type > > interpolate(const Field< Type > &fld, const UList< Type > &defaultValues=UList< Type >()) const
Interpolate field.
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::pointPatchFieldMapper.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject( name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE ))
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
rDeltaT dimensionedInternalField()
Generic GeometricField class.
error FatalError
Cyclic ACMI front and back plane patch field.
cyclicACMIPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
const cyclicACMIPointPatch & neighbPatch() const
Return neighbour point patch.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.