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 -------------------------------------------------------------------------------
10 License
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 
34 template<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 
48 template<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 
71 template<class Type>
73 (
74  const cyclicACMIPointPatchField<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  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()
93  }
94 }
95 
96 
97 template<class Type>
99 (
100  const cyclicACMIPointPatchField<Type>& ptf,
101  const DimensionedField<Type, pointMesh>& iF
102 )
103 :
104  coupledPointPatchField<Type>(ptf, iF),
105  cyclicACMIPatch_(ptf.cyclicACMIPatch_),
106  ppiPtr_(nullptr),
107  nbrPpiPtr_(nullptr)
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 
113 template<class Type>
115 (
116  const Pstream::commsTypes,
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 // ************************************************************************* //
dictionary dict
Cyclic AMI point patch - place holder only.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
const pointPatch & patch() const noexcept
Return the patch.
commsTypes
Communications types.
Definition: UPstream.H:77
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition: typeInfo.H:172
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
cyclicACMIPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
Spatial transformation functions for primitive fields.
Generic templated field type.
Definition: Field.H:62
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:637
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
virtual label index() const =0
Return the index of this patch in the pointBoundaryMesh.
A Coupled boundary condition for pointField.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Cyclic ACMI front and back plane patch field.
const cyclicACMIPointPatch & neighbPatch() const
Return neighbour point patch.
volScalarField & p
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
Tensor of scalars, i.e. Tensor<scalar>.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...