Loading...
Searching...
No Matches
interfaceTrackingFvMesh.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) 2019 Zeljko Tukovic, FSB Zagreb.
9 Copyright (C) 2020-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::interfaceTrackingFvMesh
29
30Description
31 The interfaceTrackingFvMesh
32
33SourceFiles
34 interfaceTrackingFvMesh.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef interfaceTrackingFvMesh_H
39#define interfaceTrackingFvMesh_H
40
42#include "regIOobject.H"
43#include "faCFD.H"
44#include "volFields.H"
45#include "surfaceFields.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
54/*---------------------------------------------------------------------------*\
55 Class interfaceTrackingFvMesh Declaration
56\*---------------------------------------------------------------------------*/
57
58class interfaceTrackingFvMesh
59:
60 public dynamicMotionSolverFvMesh
61{
62 // Private Data
63
64 //- Finite area mesh
65 autoPtr<faMesh> aMeshPtr_;
66
67 //- Free surface patch index
68 label fsPatchIndex_;
69
70 //- Free surface faPatch-es which do not move
71 wordList fixedFreeSurfacePatches_;
72
73 //- Free surface faPatch-es where wave shuld not reflect
74 wordList nonReflectingFreeSurfacePatches_;
75
76 //- Free surface patches for which point normals must be corrected
77 wordList pointNormalsCorrectionPatches_;
78
79 //- Is it free-surface points displacement direction
80 // parallel with free-surface point normals
81 Switch normalMotionDir_;
82
83 //- Free-surface points displacement direction
84 // if not normal motion direction
85 vector motionDir_;
86
87 //- Interface smoothing at the beginning of time step
88 Switch smoothing_;
89
90 //- Pure free-surface
91 Switch pureFreeSurface_;
92
93 //- Rigid free-surface
94 Switch rigidFreeSurface_;
95
96 //- Correct contact line point normals
97 Switch correctContactLineNormals_;
98
99 //- Surface tension coefficient of pure free-surface
100 dimensionedScalar sigma0_;
101
102 //- Fluid density
104
105 //- Current interface tracking time index
106 label timeIndex_;
107
108 //- Free-surface velocity field
109 mutable std::unique_ptr<areaVectorField> UsPtr_;
110
111 //- Points which are attached to the free-surface A side faces
112 // and which defines the free-surface shape
113 mutable std::unique_ptr<vectorIOField> controlPointsPtr_;
114
115 //- Field which additionally determines
116 // the motion of free-surface points
117 mutable std::unique_ptr<labelList> motionPointsMaskPtr_;
118
119 //- Displacement direction of free-surface points
120 mutable std::unique_ptr<vectorField> pointsDisplacementDirPtr_;
121
122 //- Displacement direction of free-surface control points
123 mutable std::unique_ptr<vectorField> facesDisplacementDirPtr_;
124
125 //- Free-surface net flux
126 mutable std::unique_ptr<areaScalarField> fsNetPhiPtr_;
127
128 //- Free-surface flux
129 mutable std::unique_ptr<edgeScalarField> phisPtr_;
130
131 //- Free-surface surfactant concetration
132 mutable std::unique_ptr<areaScalarField> surfactConcPtr_;
133
134 //- Volume surfactant concetration
135 mutable std::unique_ptr<volScalarField> bulkSurfactConcPtr_;
136
137 //- Surface tension field
138 mutable std::unique_ptr<areaScalarField> surfaceTensionPtr_;
139
140 //- Surfactant properties
141 mutable std::unique_ptr<surfactantProperties> surfactantPtr_;
142
143 //- Contact angle
144 mutable std::unique_ptr<areaScalarField> contactAnglePtr_;
145
146
147 // Private Member Functions
148
149 // Make demand-driven data
150
151 //- Create free surface velocity field
152 void makeUs() const;
153
154 //- Create control points
155 void makeControlPoints();
156
157 //- Create motion points mask
158 void makeMotionPointsMask();
159
160 //- Create points and control point motion direction
161 void makeDirections();
162
163 //- Create free surface net flux
164 void makeFsNetPhi() const;
165
166 //- Create free-surface flux
167 void makePhis();
168
169 //- Create surfactant volume concentration field
170 void makeBulkSurfactConc() const;
171
172 //- Create surfactant concentration field
173 void makeSurfactConc() const;
174
175 //- Create surface tension field
176 void makeSurfaceTension() const;
177
178 //- Create surfactant properties
179 void makeSurfactant() const;
180
181 //- Create contact angle
182 void makeContactAngle();
183
184 //- No copy construct
185 interfaceTrackingFvMesh(const interfaceTrackingFvMesh&) = delete;
186
187 //- No copy assignment
188 void operator=(const interfaceTrackingFvMesh&) = delete;
189
190 //- Initialize data
191 void initializeData();
192
193 //- Update control points end displacement directions
194 void updateDisplacementDirections();
195
196 //- Initialize control points position
197 void initializeControlPointsPosition();
198
199 //- Calculate free surface points displacement
200 // for given new control points position
201 tmp<vectorField> pointDisplacement();
202
203 //- Calc least sqare plane point and normal
204 tmp<vectorField> lsPlanePointAndNormal
205 (
206 const vectorField& points,
207 const vector& origin,
208 const vector& axis
209 ) const;
210
211 //- Smooth free-surface mesh
212 void smoothFreeSurfaceMesh();
213
214 //- Update free-surface flux
215 void updateSurfaceFlux();
216
217 //- Update free-surface surfactant concentration
218 void updateSurfactantConcentration();
219
220 //- Calculate total pressure force
221 vector totalPressureForce() const;
222
223 //- Calculate total viscous force
224 vector totalViscousForce() const;
225
226 //- Calculate total surface tension force
227 vector totalSurfaceTensionForce() const;
228
229 //- Maximal surface tension based Courant number
230 scalar maxCourantNumber();
231
232 //- Update properties
233 void updateProperties();
234
235 //- Correct free surface point normals at contact line
236 void correctContactLinePointNormals();
237
238 //- Correct free surface point displacement next to fixed contact line
239 void correctPointDisplacement
240 (
241 const scalarField& sweptVolCorr,
242 vectorField& displacement
243 );
244
245public:
246
247 //- Runtime type information
248 TypeName("interfaceTrackingFvMesh");
249
250
251 // Constructors
252
253 //- Construct from IOobject
254 interfaceTrackingFvMesh(const IOobject& io, const bool doInit=true);
255/*
256 //- Construct from components without boundary.
257 // Boundary is added using addFvPatches() member function
258 interfaceTrackingFvMesh
259 (
260 const IOobject& io,
261 pointField&& points,
262 faceList&& faces,
263 labelList&& allOwner,
264 labelList&& allNeighbour,
265 const bool syncPar = true
266 );
267*/
268
269 //- Destructor
271
272
273 // Member Functions
274
275 //- Initialise all non-demand-driven data
276 virtual bool init(const bool doInit);
277
278 fvMesh& mesh()
279 {
280 return *this;
281 }
282
283 const fvMesh& mesh() const
284 {
285 return *this;
286 }
287
288 //- Return reference to finite area mesh
289 faMesh& aMesh()
290 {
291 return aMeshPtr_();
292 }
293
294 //- Return reference to finite area mesh
295 const faMesh& aMesh() const
296 {
297 return aMeshPtr_();
298 }
299
300 const label& fsPatchIndex() const
301 {
302 return fsPatchIndex_;
303 }
304
305 //- Pure free-surface
306 Switch pureFreeSurface() const noexcept
307 {
308 return pureFreeSurface_;
309 }
310
311 //- Rigid free-surface
312 Switch rigidFreeSurface() const noexcept
313 {
314 return rigidFreeSurface_;
315 }
316
317 //- Rigid free-surface
318 Switch& rigidFreeSurface() noexcept
319 {
320 return rigidFreeSurface_;
321 }
322
323 //- Correct contact line point normals
324 Switch correctContactLineNormals() const noexcept
325 {
326 return correctContactLineNormals_;
327 }
328
329 //- Correct contact line point normals
331 {
332 return correctContactLineNormals_;
333 }
334
335 //- Surface tension coefficient of pure free-surface
336 const dimensionedScalar& sigma() const
337 {
338 return sigma0_;
339 }
340
341 //- Return free-surface velocity field
343
344 //- Return free-surface velocity field
345 const areaVectorField& Us() const;
346
347 //- Return free-surface net flux
348 const areaScalarField& fsNetPhi() const;
349
350 //- Return free-surface net flux
352
353 //- Correct surface velocity boundary conditions
355
356 //- Update free-surface velocity field
357 void updateUs();
359 //- Return constant reference to velocity field
360 const volVectorField& U() const;
361
362 //- Return constant reference to pressure field
363 const volScalarField& p() const;
364
365 //- Return constant reference to velocity field
366 const surfaceScalarField& phi() const;
367
368 //- Return free surface normal derivative of velocity
370
371 //- Return free surface normal derivative of normal velocity comp
374 //- Return free surface pressure jump
376
377 //- Return control points
379
380 //- Return reference to motion points mask field
382
383 //- Return reference to point displacement direction field
385
386 //- Return reference to control points displacement direction field
388
389 //- Motion direction swithc
390 bool normalMotionDir() const
391 {
392 return normalMotionDir_;
393 }
394
395 //- Return free-surface fluid flux field
398 //- Return free-surface surfactant concentration field
400
401 //- Return free-surface surfactant concentration field
403
404 //- Return volume surfactant concentration field
406
407 //- Return volume surfactant concentration field
409
410 //- Return surface tension field
412
413 //- Return surface tension field
414 const areaScalarField& surfaceTension() const;
415
416 //- Return surface tension gradient
419 //- Return surfactant properties
420 const surfactantProperties& surfactant() const;
421
422 //- Update the mesh for both mesh motion and topology change
423 virtual bool update();
424
425 //- Clear control points
426 void clearControlPoints()
427 {
428 controlPointsPtr_.reset(nullptr);
429 }
430
431 //- Write VTK freeSurface mesh
432 void writeVTK() const;
433
434 //- Write VTK freeSurface control points
436};
437
438
439// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
440
441} // End namespace Foam
442
443// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
444
445#endif
446
447// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
vectorField & controlPoints()
Return control points.
void correctUsBoundaryConditions()
Correct surface velocity boundary conditions.
Switch pureFreeSurface() const noexcept
Pure free-surface.
areaVectorField & Us()
Return free-surface velocity field.
TypeName("interfaceTrackingFvMesh")
Runtime type information.
const areaScalarField & fsNetPhi() const
Return free-surface net flux.
const surfaceScalarField & phi() const
Return constant reference to velocity field.
tmp< scalarField > freeSurfaceSnGradUn()
Return free surface normal derivative of normal velocity comp.
vectorField & pointsDisplacementDir()
Return reference to point displacement direction field.
Switch rigidFreeSurface() const noexcept
Rigid free-surface.
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
const volVectorField & U() const
Return constant reference to velocity field.
Switch correctContactLineNormals() const noexcept
Correct contact line point normals.
void writeVTK() const
Write VTK freeSurface mesh.
void updateUs()
Update free-surface velocity field.
areaScalarField & surfaceTension()
Return surface tension field.
vectorField & facesDisplacementDir()
Return reference to control points displacement direction field.
void writeVTKControlPoints()
Write VTK freeSurface control points.
faMesh & aMesh()
Return reference to finite area mesh.
virtual bool update()
Update the mesh for both mesh motion and topology change.
Switch & correctContactLineNormals() noexcept
Correct contact line point normals.
interfaceTrackingFvMesh(const IOobject &io, pointField &&points, faceList &&faces, labelList &&allOwner, labelList &&allNeighbour, const bool syncPar=true)
const dimensionedScalar & sigma() const
Surface tension coefficient of pure free-surface.
tmp< areaVectorField > surfaceTensionGrad()
Return surface tension gradient.
Switch & rigidFreeSurface() noexcept
Rigid free-surface.
labelList & motionPointsMask()
Return reference to motion points mask field.
volScalarField & bulkSurfactantConcentration()
Return volume surfactant concentration field.
bool normalMotionDir() const
Motion direction swithc.
const volScalarField & p() const
Return constant reference to pressure field.
const surfactantProperties & surfactant() const
Return surfactant properties.
areaScalarField & surfactantConcentration()
Return free-surface surfactant concentration field.
edgeScalarField & Phis()
Return free-surface fluid flux field.
tmp< scalarField > freeSurfacePressureJump()
Return free surface pressure jump.
tmp< vectorField > freeSurfaceSnGradU()
Return free surface normal derivative of velocity.
const faMesh & aMesh() const
Return reference to finite area mesh.
void clearControlPoints()
Clear control points.
virtual const faceList & faces() const
Return raw faces.
Definition polyMesh.C:1088
A class for managing temporary objects.
Definition tmp.H:75
const auto & io
const pointField & points
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
GeometricField< vector, fvPatchField, volMesh > volVectorField
List< label > labelList
A List of labels.
Definition List.H:62
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< face > faceList
List of faces.
Definition faceListFwd.H:41
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Field< vector > vectorField
Specialisation of Field<T> for vector.
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Vector< scalar > vector
Definition vector.H:57
Foam::surfaceFields.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68