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-------------------------------------------------------------------------------
10License
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
34template<class Type>
36(
37 const pointPatch& p,
39)
40:
41 coupledPointPatchField<Type>(p, iF),
42 cyclicPatch_(refCast<const cyclicPointPatch>(p))
43{}
44
45
46template<class Type>
48(
49 const pointPatch& p,
51 const dictionary& dict
52)
53:
54 coupledPointPatchField<Type>(p, iF, dict),
55 cyclicPatch_(refCast<const cyclicPointPatch>(p, dict))
56{
57 if (!isType<cyclicPointPatch>(p))
58 {
60 << "patch " << this->patch().index() << " not cyclic type. "
61 << "Patch type = " << p.type()
63 }
64}
65
66
67template<class Type>
69(
71 const pointPatch& p,
73 const pointPatchFieldMapper& mapper
74)
75:
76 coupledPointPatchField<Type>(ptf, p, iF, mapper),
77 cyclicPatch_(refCast<const cyclicPointPatch>(p))
78{
79 if (!isType<cyclicPointPatch>(this->patch()))
80 {
82 << "Field type does not correspond to patch type for patch "
83 << this->patch().index() << "." << endl
84 << "Field type: " << typeName << endl
85 << "Patch type: " << this->patch().type()
86 << exit(FatalError);
87 }
88}
89
90
91template<class Type>
93(
96)
97:
98 coupledPointPatchField<Type>(ptf, iF),
99 cyclicPatch_(ptf.cyclicPatch_)
100{}
101
102
103// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104
105template<class Type>
107(
109 Field<Type>& pField
110) const
111{
112 // Get neighbouring pointPatch
113 const cyclicPointPatch& nbrPatch = cyclicPatch_.neighbPatch();
114
115 if (cyclicPatch_.cyclicPatch().owner())
116 {
117 // We inplace modify pField. To prevent the other side (which gets
118 // evaluated at a later date) using already changed values we do
119 // all swaps on the side that gets evaluated first.
120
121 // Get neighbouring pointPatchField
123 refCast<const GeometricField<Type, pointPatchField, pointMesh>>
124 (
125 this->internalField()
126 );
127
128 const cyclicPointPatchField<Type>& nbr =
129 refCast<const cyclicPointPatchField<Type>>
130 (
131 fld.boundaryField()[nbrPatch.index()]
132 );
133
134
135 Field<Type> pf(this->patchInternalField(pField));
136 Field<Type> nbrPf(nbr.patchInternalField(pField));
137
138 const edgeList& pairs = cyclicPatch_.transformPairs();
139
140 if (doTransform())
141 {
142 // Transform both sides.
143 forAll(pairs, pairi)
144 {
145 label pointi = pairs[pairi][0];
146 label nbrPointi = pairs[pairi][1];
147
148 Type tmp = pf[pointi];
149 pf[pointi] = transform(forwardT()[0], nbrPf[nbrPointi]);
150 nbrPf[nbrPointi] = transform(reverseT()[0], tmp);
151 }
152 }
153 else
154 {
155 forAll(pairs, pairi)
156 {
157 Swap(pf[pairs[pairi][0]], nbrPf[pairs[pairi][1]]);
158 }
159 }
160 this->addToInternalField(pField, pf);
161 nbr.addToInternalField(pField, nbrPf);
162 }
163}
164
165
166// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
Generic GeometricField class.
commsTypes
Types of communications.
Definition: UPstream.H:67
A Coupled boundary condition for pointField.
Cyclic front and back plane patch field.
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
Cyclic patch for post-processing.
const cyclicPointPatch & neighbPatch() const
Return neighbour point patch.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
Foam::pointPatchFieldMapper.
const pointPatch & patch() const
Return patch.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
virtual label index() const =0
Return the index of this patch in the pointBoundaryMesh.
A class for managing temporary objects.
Definition: tmp.H:65
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Definition: DynamicList.H:408
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Spatial transformation functions for primitive fields.