cyclicPointPatchField.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) 2011 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 "cyclicPointPatchField.H"
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  cyclicPatch_(refCast<const cyclicPointPatch>(p))
42 {}
43 
44 
45 template<class Type>
47 (
48  const pointPatch& p,
50  const dictionary& dict
51 )
52 :
54  cyclicPatch_(refCast<const cyclicPointPatch>(p))
55 {
56  if (!isType<cyclicPointPatch>(p))
57  {
59  (
60  "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
61  "(\n"
62  " const pointPatch& p,\n"
63  " const Field<Type>& field,\n"
64  " const dictionary& dict\n"
65  ")\n",
66  dict
67  ) << "patch " << this->patch().index() << " not cyclic type. "
68  << "Patch type = " << p.type()
69  << exit(FatalIOError);
70  }
71 }
72 
73 
74 template<class Type>
76 (
77  const cyclicPointPatchField<Type>& ptf,
78  const pointPatch& p,
80  const pointPatchFieldMapper& mapper
81 )
82 :
83  coupledPointPatchField<Type>(ptf, p, iF, mapper),
84  cyclicPatch_(refCast<const cyclicPointPatch>(p))
85 {
86  if (!isType<cyclicPointPatch>(this->patch()))
87  {
89  (
90  "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
91  "(\n"
92  " const cyclicPointPatchField<Type>& ptf,\n"
93  " const pointPatch& p,\n"
94  " const DimensionedField<Type, pointMesh>& iF,\n"
95  " const pointPatchFieldMapper& mapper\n"
96  ")\n"
97  ) << "Field type does not correspond to patch type for patch "
98  << this->patch().index() << "." << endl
99  << "Field type: " << typeName << endl
100  << "Patch type: " << this->patch().type()
101  << exit(FatalError);
102  }
103 }
104 
105 
106 template<class Type>
108 (
109  const cyclicPointPatchField<Type>& ptf,
111 )
112 :
114  cyclicPatch_(ptf.cyclicPatch_)
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 template<class Type>
122 (
123  const Pstream::commsTypes,
124  Field<Type>& pField
125 ) const
126 {
127  // Get neighbouring pointPatch
128  const cyclicPointPatch& nbrPatch = cyclicPatch_.neighbPatch();
129 
130  if (cyclicPatch_.cyclicPatch().owner())
131  {
132  // We inplace modify pField. To prevent the other side (which gets
133  // evaluated at a later date) using already changed values we do
134  // all swaps on the side that gets evaluated first.
135 
136  // Get neighbouring pointPatchField
138  refCast<const GeometricField<Type, pointPatchField, pointMesh> >
139  (
141  );
142 
143  const cyclicPointPatchField<Type>& nbr =
144  refCast<const cyclicPointPatchField<Type> >
145  (
146  fld.boundaryField()[nbrPatch.index()]
147  );
148 
149 
150  Field<Type> pf(this->patchInternalField(pField));
151  Field<Type> nbrPf(nbr.patchInternalField(pField));
152 
153  const edgeList& pairs = cyclicPatch_.transformPairs();
154 
155  if (doTransform())
156  {
157  // Transform both sides.
158  forAll(pairs, pairi)
159  {
160  label pointi = pairs[pairi][0];
161  label nbrPointi = pairs[pairi][1];
162 
163  Type tmp = pf[pointi];
164  pf[pointi] = transform(forwardT()[0], nbrPf[nbrPointi]);
165  nbrPf[nbrPointi] = transform(reverseT()[0], tmp);
166  }
167  }
168  else
169  {
170  forAll(pairs, pairi)
171  {
172  Swap(pf[pairs[pairi][0]], nbrPf[pairs[pairi][1]]);
173  }
174  }
175  this->addToInternalField(pField, pf);
176  nbr.addToInternalField(pField, nbrPf);
177  }
178 }
179 
180 
181 // ************************************************************************* //
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
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.
Cyclic patch for post-processing.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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
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
const cyclicPointPatch & neighbPatch() const
Return neighbour point patch.
commsTypes
Types of communications.
Definition: UPstream.H:64
#define forAll(list, i)
Definition: UList.H:421
Spatial transformation functions for primitive fields.
Swap its arguments.
Pre-declare SubField and related Field type.
Definition: Field.H:57
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
void Swap(T &a, T &b)
Definition: Swap.H:43
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
cyclicPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Cyclic front and back plane patch field.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
A class for managing temporary objects.
Definition: PtrList.H:118