Loading...
Searching...
No Matches
regionFaIBM.H
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) 2022-2025 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
26Class
27 Foam::regionModels::areaSurfaceFilmModels::regionFaIBM
28
29Description
30 Immersed Boundary Method (IBM) for finite area (FA). Multiple IBM surfaces
31 can be defined, each represented by a triangulated surface mesh.
32 Boundary motion is supported via a solidBodyMotionFunction.
33
34Usage
35 Example usage in constant/regionFaIBMPropeties
36
37 \verbatim
38 regionFaIBM1
39 {
40 type regionFaIBM;
41 surface <surfaceFileName>;
42
43 solidBodyMotionFunction <motionType>
44 // Additional motion type information...
45
46 // Optional
47
48 // Solve type for stencil weights; default = direct
49 solveType direct; // or invDistance
50
51 // Stencil radius factor; default = 1.5
52 rFactor 2.0;
53 }
54 regionFaIBM2
55 {
56 ...
57 }
58 \endverbatim
59
60
61SeeAlso
62 Foam::solidBodyMotionFunction
63
64SourceFiles
65 regionFaIBM.cxx
66 regionFaIBM.txx
67
68\*---------------------------------------------------------------------------*/
69
70#ifndef Foam_FA_regionFaIBM_H
71#define Foam_FA_regionFaIBM_H
72
73#include "areaFields.H"
74#include "triSurfaceMesh.H"
75#include "indexedOctree.H"
77#include "Enum.H"
78
79// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80
81namespace Foam
82{
83
84// Forward Declarations
85class Time;
86
87namespace regionModels
88{
90{
92/*---------------------------------------------------------------------------*\
93 Class regionFaIBM Declaration
94\*---------------------------------------------------------------------------*/
95
96class regionFaIBM
97{
98public:
99
100 // Data Types
101
102 //- Solve type for stencil weights
103 enum class solveType
104 {
105 invDistance, //<! Inverse distance weighting
106 direct //<! Direct solve
107 };
108
109
110 // Member Functions
111
112 //- Dump the stencil to file
113 static void dumpStencil
114 (
115 const fileName& fname,
116 const mapDistribute& mapDist,
117 const labelListList& stencil,
118 const pointField& centres
119 );
120
121
122protected:
123
124 // Protected Data
127
128 //- Selection names for solveType
129 static const Enum<solveType> solveTypeNames;
131
132 //- Reference to the finite area mesh
133 const faMesh& aMesh_;
134
135 //- regionFaIBM surface described by a triSurfaceMesh
136 // Note: this should be a closed surface since we perform point
137 // inside/outside tests
139
140 //- Reference points for surface motion
141 const pointField points0_;
142
143 //- Parallel map to apply the regionFaIBM stencil
145
146 //- Surface motion as a function of time
148
149 //- Octree for face search
151
152 //- Integration time step
153 scalar deltaT_;
155 //- Time at last update
156 scalar updateTimeOld_;
157
158 //- Last transformation
160
161 //- Transformation to go to state at last step
163
164 //- Face types indicator field
166
167 //- Forcing faces
170 //- Inside faces
172
173 //- Solve type
175
176 //- Stencil radius factor
177 scalar rFactor_;
178
179 //- Interpolation stencil
181
182 //- Interpolation weights
185 //- Distance weights used when calculating uStar
187
188
189 // Protected Member Functions
190
191 //- Move the immersed boundary
192 bool moveBody();
193
194 //- Set the face types indicator field and derived info
195 void setFaceTypes();
196
197 //- Retrieve the velocity at a point on the moving surface
200 //- Set the regionFaIBM stencil addressing
202 (
203 const pointField& forcingFaceCentres,
204 const scalarField& forcingFaceAreas,
205 pointField& mirrorPoints
206 );
207
208 //- Set the regionFaIBM stencil weights
209 void setStencilWeights(const pointField& mirrorPoints);
210
211
212public:
213
214 //- Runtime type information
215 TypeName("IBM");
216
217 // Constructors
218
219 //- Construct from Time and dictionary
221 (
222 const Time& runTime,
223 const faMesh& aMesh,
225 );
226
227
228 //- Destructor
229 virtual ~regionFaIBM() = default;
230
231
232 // Member Functions
233
234 //- Update mesh
235 void updateMesh();
236
237 //- Correct the regionFaIBM model
238 bool correct(const areaVectorField& Us, areaVectorField& Ustar);
239
240 //- Apply the zero filter to an area field
241 template<class Type>
242 void zeroFilter(Type& fld) const;
243
244 //- Add to mask; Sets a value of 1 for participating faces
245 void addToMask(areaScalarField& mask) const;
246};
248// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249
250#ifdef NoRepository
251 #include "regionFaIBM.txx"
252#endif
253
254// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255
256} // End namespace areaSurfaceFilmModels
257} // End namespace regionModels
258} // End namespace Foam
259
260// ************************************************************************* //
261
262#endif
263
264// ************************************************************************* //
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))
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
A class for handling file names.
Definition fileName.H:75
Class containing processor-to-processor mapping information.
labelField faceTypes_
Face types indicator field.
scalarListList weights_
Interpolation weights.
bool correct(const areaVectorField &Us, areaVectorField &Ustar)
Correct the regionFaIBM model.
vector setVelocityFromSurface(const pointIndexHit &hit) const
Retrieve the velocity at a point on the moving surface.
triSurfaceMesh surface_
regionFaIBM surface described by a triSurfaceMesh
septernion invTransformDelta_
Transformation to go to state at last step.
scalarList h_
Distance weights used when calculating uStar.
treeDataPrimitivePatch< uindirectPrimitivePatch > treeType
regionFaIBM(const Time &runTime, const faMesh &aMesh, const dictionary &dict)
Construct from Time and dictionary.
void addToMask(areaScalarField &mask) const
Add to mask; Sets a value of 1 for participating faces.
autoPtr< mapDistribute > mapPtr_
Parallel map to apply the regionFaIBM stencil.
autoPtr< indexedOctree< treeType > > treePtr_
Octree for face search.
void setFaceTypes()
Set the face types indicator field and derived info.
static const Enum< solveType > solveTypeNames
Selection names for solveType.
autoPtr< solidBodyMotionFunction > SBMFPtr_
Surface motion as a function of time.
labelListList stencil_
Interpolation stencil.
const pointField points0_
Reference points for surface motion.
const faMesh & aMesh_
Reference to the finite area mesh.
void setStencilWeights(const pointField &mirrorPoints)
Set the regionFaIBM stencil weights.
void zeroFilter(Type &fld) const
Apply the zero filter to an area field.
void setStencilAddressing(const pointField &forcingFaceCentres, const scalarField &forcingFaceAreas, pointField &mirrorPoints)
Set the regionFaIBM stencil addressing.
static void dumpStencil(const fileName &fname, const mapDistribute &mapDist, const labelListList &stencil, const pointField &centres)
Dump the stencil to file.
Septernion class used to perform translations and rotations in 3D space.
Definition septernion.H:63
Encapsulation of data needed to search on PrimitivePatches.
IOoject and searching on triSurface.
thermo correct()
engineTime & runTime
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Field< label > labelField
Specialisation of Field<T> for label.
Definition labelField.H:48
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68