patchTransformedInterpolation.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2015 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "pointFields.H"
32 #include "symmTensor2D.H"
33 #include "tensor2D.H"
34 #include "syncTools.H"
35 #include "volPointInterpolation.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(patchTransformedInterpolation, 0);
42 
44  (
45  motionInterpolation,
46  patchTransformedInterpolation,
47  Istream
48  );
49 }
50 
51 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 Foam::labelList Foam::patchTransformedInterpolation::getPatches
54 (
55  Istream& entry
56 ) const
57 {
58  wordList patchNames(entry);
59 
60  labelList patches(patchNames.size(), -1);
61 
62  forAll(patchNames, patchI)
63  {
64  patches[patchI] =
66  (
67  patchNames[patchI]
68  );
69 
70  if (patches[patchI] == -1)
71  {
73  << "patch \"" << patchNames[patchI]
74  << "\" not found" << exit(FatalError);
75  }
76  }
77 
78  return patches;
79 }
80 
81 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
82 
84 (
85  const fvMesh& mesh,
86  Istream& entry
87 )
88 :
90  patches_(getPatches(entry))
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 
97 {}
98 
99 
100 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
101 
103 (
104  const volScalarField&,
106 ) const
107 {
109 }
110 
111 
113 (
114  const volVectorField& cellDisplacement,
115  pointVectorField& pointDisplacement
116 ) const
117 {
118  const pointField& points(mesh().points());
119  const label nPoints(points.size());
120 
122  (
123  cellDisplacement,
124  pointDisplacement
125  );
126 
127  pointDisplacement.correctBoundaryConditions();
128 
129  vectorField pointRotation(nPoints, Zero);
130  scalarField pointExpansion(nPoints, Zero);
131 
132  labelList pointDisplacementNSum(nPoints, Zero);
133  vectorField pointDisplacementSum(nPoints, Zero);
134 
135  forAll(patches_, patchI)
136  {
137  const polyPatch& patch(mesh().boundaryMesh()[patches_[patchI]]);
138 
139  forAll(patch, pFaceI)
140  {
141  const face& f(patch[pFaceI]);
142 
143  const label cellI(patch.faceCells()[pFaceI]);
144  const cell& c(mesh().cells()[cellI]);
145  const labelList cPoints(c.labels(mesh().faces()));
146 
147  // Consider movement around the face centre
148  const point& xOrigin(patch.faceCentres()[pFaceI]);
149 
150  // Mean translation
151  const vector uMean(f.average(points, pointDisplacement));
152 
153  // Calculate rotation and expansion for each point
154  forAll(f, fPointI)
155  {
156  const label pointI(f[fPointI]);
157  const vector& x(points[pointI]);
158  const vector r(x - xOrigin);
159  const vector u(pointDisplacement[pointI] - uMean);
160 
161  pointRotation[pointI] = 2*(r ^ u)/magSqr(r);
162  pointExpansion[pointI] = (r & u)/magSqr(r);
163  }
164 
165  // Mean rotation and expansion
166  const vector omegaMean(f.average(points, pointRotation));
167  const scalar divMean(f.average(points, pointExpansion));
168 
169  // Apply mean solid body motion to all cell points
170  forAll(cPoints, cPointI)
171  {
172  const label pointI(cPoints[cPointI]);
173  const vector& x(points[pointI]);
174  const vector r(x - xOrigin);
175 
176  pointDisplacementNSum[pointI] += 1;
177  pointDisplacementSum[pointI] +=
178  uMean + (omegaMean ^ r) + (divMean*r);
179  }
180  }
181  }
182 
184  (
185  mesh(),
186  pointDisplacementNSum,
187  plusEqOp<label>(),
188  label(0)
189  );
190 
192  (
193  mesh(),
194  pointDisplacementSum,
197  );
198 
199  forAll(points, pointI)
200  {
201  if (pointDisplacementNSum[pointI])
202  {
203  pointDisplacement[pointI] =
204  pointDisplacementSum[pointI]/pointDisplacementNSum[pointI];
205  }
206  }
207 
208  // Correct the faces
209  pointDisplacement.correctBoundaryConditions();
210 }
211 
212 
213 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
symmTensor2D.H
Foam::patchTransformedInterpolation::patchTransformedInterpolation
patchTransformedInterpolation(const fvMesh &mesh, Istream &entry)
Construct from an fvMesh and an Istream.
Definition: patchTransformedInterpolation.C:84
Foam::MeshObject< fvMesh, UpdateableMeshObject, volPointInterpolation >::New
static const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
tensor2D.H
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::volPointInterpolation::interpolate
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
syncTools.H
Foam::syncTools::syncPointList
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
Definition: syncToolsTemplates.C:721
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::patchTransformedInterpolation::~patchTransformedInterpolation
virtual ~patchTransformedInterpolation()
Destructor.
Definition: patchTransformedInterpolation.C:96
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
patchTransformedInterpolation.H
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
patchNames
wordList patchNames(nPatches)
Foam::polyBoundaryMesh::findPatchID
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
Definition: polyBoundaryMesh.C:765
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchTransformedInterpolation::interpolate
virtual void interpolate(const volScalarField &, pointScalarField &) const
Interpolate the given scalar cell displacement.
Definition: patchTransformedInterpolation.C:103
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
volPointInterpolation.H
Foam::motionInterpolation
Base class for interpolation of cell displacement fields, generated by fvMotionSolvers,...
Definition: motionInterpolation.H:52
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
f
labelList f(nPoints)
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::motionInterpolation::mesh
const fvMesh & mesh() const
Return const-reference to the mesh.
Definition: motionInterpolation.H:119
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
points
const pointField & points
Definition: gmvOutputHeader.H:1
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::zero
static const Vector< scalar > zero
Definition: VectorSpace.H:115
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:62
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::plusEqOp
Definition: ops.H:72
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:54
pointFields.H