Loading...
Searching...
No Matches
fvGeometryScheme.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) 2020-2022 OpenCFD Ltd.
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
28#include "fvGeometryScheme.H"
29#include "fvMesh.H"
30#include "surfaceFields.H"
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38 defineRunTimeSelectionTable(fvGeometryScheme, dict);
39}
40
41
42// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43
45{
46 if (!mesh_.moving())
47 {
48 return false;
49 }
50
51 const pointField& oldPoints = mesh_.oldPoints();
52 const pointField& currPoints = mesh_.points();
53
54 if (oldPoints.size() != currPoints.size())
55 {
57 << "Old and current points sizes must be the same. "
58 << "Old points:" << oldPoints.size()
59 << " Current points:" << currPoints.size()
60 << abort(FatalError);
61 }
62
63 const faceList& faces = mesh_.faces();
64 const scalar rdt = 1.0/mesh_.time().deltaTValue();
65
66 auto tmeshPhi(const_cast<fvMesh&>(mesh_).setPhi());
67 if (tmeshPhi)
68 {
69 auto& meshPhi = tmeshPhi.ref();
70 auto& meshPhii = meshPhi.primitiveFieldRef();
71 forAll(meshPhii, facei)
72 {
73 const face& f = faces[facei];
74 meshPhii[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
75 }
76
77 auto& meshPhiBf = meshPhi.boundaryFieldRef();
78 for (auto& meshPhip : meshPhiBf)
79 {
80 if (!meshPhip.size())
81 {
82 // Empty patches
83 continue;
84 }
85
86 const auto& pp = meshPhip.patch().patch();
87
88 forAll(pp, facei)
89 {
90 const face& f = pp[facei];
91 meshPhip[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
92 }
93 }
94 }
96 return true;
97}
98
99
100// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
101
103(
104 const fvMesh& mesh,
105 const dictionary& dict,
106 const word& defaultScheme
107)
108{
109 const entry* eptr = dict.findEntry("method", keyType::LITERAL);
110 const word schemeName
111 (
112 eptr
113 ? word(eptr->stream())
114 : dict.getOrDefault<word>("type", defaultScheme)
115 );
116
117 DebugInFunction << "Geometry scheme = " << schemeName << endl;
118
119 auto* ctorPtr = dictConstructorTable(schemeName);
120
121 if (!ctorPtr)
122 {
124 (
125 dict,
126 "fvGeometryScheme",
127 schemeName,
128 *dictConstructorTablePtr_
129 ) << exit(FatalIOError);
130 }
132 return ctorPtr(mesh, dict);
133}
134
135
136// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137
139{
140 if (mesh_.moving())
141 {
142 // Set the mesh motion fluxes
143 setMeshPhi();
144
145 // Clear out old geometry
146 // Note: this recreates the old primitiveMesh::movePoints behaviour
147 const_cast<fvMesh&>(mesh_).primitiveMesh::clearGeom();
148 }
149}
150
151
152void Foam::fvGeometryScheme::updateMesh(const mapPolyMesh& mpm)
153{}
154
155
156// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Abstract base class for geometry calculation schemes.
const fvMesh & mesh_
Hold reference to mesh.
bool setMeshPhi() const
Set the mesh motion flux.
virtual void movePoints()
Update basic geometric properties from provided points.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh for topology changes.
const fvMesh & mesh() const
Return mesh reference.
static tmp< fvGeometryScheme > New(const fvMesh &mesh, const dictionary &dict, const word &defaultScheme)
Return new tmp interpolation scheme.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
@ LITERAL
String literal.
Definition keyType.H:82
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool moving() const noexcept
Is mesh moving.
Definition polyMesh.H:732
virtual const pointField & oldPoints() const
Return old points (mesh motion).
Definition polyMesh.C:1113
virtual const pointField & points() const
Return raw points.
Definition polyMesh.C:1063
void clearGeom()
Clear geometry.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
#define DebugInFunction
Report an information message using Foam::Info.
tmp< surfaceScalarField > meshPhi(const volVectorField &U)
Definition fvcMeshPhi.C:29
Namespace for OpenFOAM.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
labelList f(nPoints)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
Foam::surfaceFields.