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-2015 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  dict
61  ) << "patch " << this->patch().index() << " not cyclic type. "
62  << "Patch type = " << p.type()
63  << exit(FatalIOError);
64  }
65 }
66 
67 
68 template<class Type>
70 (
71  const cyclicPointPatchField<Type>& ptf,
72  const pointPatch& p,
74  const pointPatchFieldMapper& mapper
75 )
76 :
77  coupledPointPatchField<Type>(ptf, p, iF, mapper),
78  cyclicPatch_(refCast<const cyclicPointPatch>(p))
79 {
80  if (!isType<cyclicPointPatch>(this->patch()))
81  {
83  << "Field type does not correspond to patch type for patch "
84  << this->patch().index() << "." << endl
85  << "Field type: " << typeName << endl
86  << "Patch type: " << this->patch().type()
87  << exit(FatalError);
88  }
89 }
90 
91 
92 template<class Type>
94 (
95  const cyclicPointPatchField<Type>& ptf,
97 )
98 :
100  cyclicPatch_(ptf.cyclicPatch_)
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
106 template<class Type>
108 (
109  const Pstream::commsTypes,
110  Field<Type>& pField
111 ) const
112 {
113  // Get neighbouring pointPatch
114  const cyclicPointPatch& nbrPatch = cyclicPatch_.neighbPatch();
115 
116  if (cyclicPatch_.cyclicPatch().owner())
117  {
118  // We inplace modify pField. To prevent the other side (which gets
119  // evaluated at a later date) using already changed values we do
120  // all swaps on the side that gets evaluated first.
121 
122  // Get neighbouring pointPatchField
124  refCast<const GeometricField<Type, pointPatchField, pointMesh> >
125  (
127  );
128 
129  const cyclicPointPatchField<Type>& nbr =
130  refCast<const cyclicPointPatchField<Type> >
131  (
132  fld.boundaryField()[nbrPatch.index()]
133  );
134 
135 
136  Field<Type> pf(this->patchInternalField(pField));
137  Field<Type> nbrPf(nbr.patchInternalField(pField));
138 
139  const edgeList& pairs = cyclicPatch_.transformPairs();
140 
141  if (doTransform())
142  {
143  // Transform both sides.
144  forAll(pairs, pairi)
145  {
146  label pointi = pairs[pairi][0];
147  label nbrPointi = pairs[pairi][1];
148 
149  Type tmp = pf[pointi];
150  pf[pointi] = transform(forwardT()[0], nbrPf[nbrPointi]);
151  nbrPf[nbrPointi] = transform(reverseT()[0], tmp);
152  }
153  }
154  else
155  {
156  forAll(pairs, pairi)
157  {
158  Swap(pf[pairs[pairi][0]], nbrPf[pairs[pairi][1]]);
159  }
160  }
161  this->addToInternalField(pField, pf);
162  nbr.addToInternalField(pField, nbrPf);
163  }
164 }
165 
166 
167 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::coupledPointPatchField
A Coupled boundary condition for pointField.
Definition: coupledPointPatchField.H:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
Foam::cyclicPointPatch
Cyclic patch for post-processing.
Definition: cyclicPointPatch.H:50
Foam::cyclicPointPatch::neighbPatch
const cyclicPointPatch & neighbPatch() const
Return neighbour point patch.
Definition: cyclicPointPatch.H:127
transformField.H
Spatial transformation functions for primitive fields.
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:46
Foam::facePointPatch::index
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
Definition: facePointPatch.H:168
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::cyclicPointPatchField::swapAddSeparated
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
Definition: cyclicPointPatchField.C:108
Swap.H
Swap its arguments.
Foam::label
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
Foam::Field< Type >
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
fld
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))
cyclicPointPatchField.H
Foam::cyclicPointPatchField
Cyclic front and back plane patch field.
Definition: cyclicPointPatchField.H:50
Foam::cyclicPointPatchField::cyclicPointPatchField
cyclicPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Definition: cyclicPointPatchField.C:35
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::cyclicPointPatchField::cyclicPatch_
const cyclicPointPatch & cyclicPatch_
Local reference cast into the cyclic patch.
Definition: cyclicPointPatchField.H:57
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::Swap
void Swap(T &a, T &b)
Definition: Swap.H:43
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
pointFields.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51