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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-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 
28 #include "cyclicPointPatchField.H"
29 #include "Swap.H"
30 #include "transformField.H"
31 #include "pointFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const pointPatch& p,
40 )
41 :
43  cyclicPatch_(refCast<const cyclicPointPatch>(p))
44 {}
45 
46 
47 template<class Type>
49 (
50  const pointPatch& p,
52  const dictionary& dict
53 )
54 :
56  cyclicPatch_(refCast<const cyclicPointPatch>(p, dict))
57 {
58  if (!isType<cyclicPointPatch>(p))
59  {
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  (
126  this->internalField()
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
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Swap
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Definition: DynamicList.H:429
Foam::coupledPointPatchField
A Coupled boundary condition for pointField.
Definition: coupledPointPatchField.H:52
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::cyclicPointPatch
Cyclic patch for post-processing.
Definition: cyclicPointPatch.H:52
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
Foam::cyclicPointPatch::neighbPatch
const cyclicPointPatch & neighbPatch() const
Return neighbour point patch.
Definition: cyclicPointPatch.H:129
transformField.H
Spatial transformation functions for primitive fields.
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::facePointPatch::index
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
Definition: facePointPatch.H:166
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
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Swap.H
Swap arguments as per std::swap, but in Foam namespace.
Foam::Field
Generic templated field type.
Definition: Field.H:63
fld
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))
Definition: gmvOutputLagrangian.H:23
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
cyclicPointPatchField.H
Foam::cyclicPointPatchField
Cyclic front and back plane patch field.
Definition: cyclicPointPatchField.H:52
Foam::cyclicPointPatchField::cyclicPointPatchField
cyclicPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Definition: cyclicPointPatchField.C:37
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< edge >
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
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:54