Loading...
Searching...
No Matches
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)
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{
58 {
60 << "patch " << this->patch().index() << " not cyclic type. "
61 << "Patch type = " << p.type()
63 }
64}
65
66
67template<class Type>
69(
70 const cyclicPointPatchField<Type>& ptf,
71 const pointPatch& p,
72 const DimensionedField<Type, pointMesh>& iF,
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(
94 const cyclicPointPatchField<Type>& ptf,
95 const DimensionedField<Type, pointMesh>& iF
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
124 (
125 this->internalField()
126 );
127
128 const cyclicPointPatchField<Type>& nbr =
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 Foam::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;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-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 that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Generic GeometricField class.
commsTypes
Communications types.
Definition UPstream.H:81
A Coupled boundary condition for pointField.
coupledPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Cyclic front and back plane patch field.
virtual bool doTransform() const
Does the patch field perform the transformation.
cyclicPointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
virtual void swapAddSeparated(const Pstream::commsTypes commsType, Field< Type > &) const
Complete swap of patch point values and add to local values.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual const tensorField & forwardT() const
Return face transformation tensor.
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:133
virtual label index() const
Return the index of this patch in the pointBoundaryMesh.
label index() const noexcept
The index of this patch in the boundaryMesh.
const pointPatch & patch() const noexcept
Return the patch.
Foam::pointPatchFieldMapper.
void patchInternalField(const UList< Type1 > &internalData, const labelUList &addressing, UList< Type1 > &pfld) const
Extract field using specified addressing.
void addToInternalField(Field< Type1 > &iF, const Field< Type1 > &pF) const
Given the internal field and a patch field, add the patch field to the internal field.
const DimensionedField< Type, pointMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Basic pointPatch represents a set of points from the mesh.
Definition pointPatch.H:67
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
List< edge > edgeList
List of edge.
Definition edgeList.H:32
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
Exchange contents of lists - see DynamicList::swap().
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
bool isType(const U &obj)
Check if typeid of the object and Type are identical.
Definition typeInfo.H:112
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
Spatial transformation functions for primitive fields.