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 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 Class
28  Foam::interfaceTrackingFvMesh
29 
30 Description
31  The interfaceTrackingFvMesh
32 
33 SourceFiles
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"
46 #include "surfactantProperties.H"
48 #include "demandDrivenData.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class interfaceTrackingFvMesh Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
62 {
63  // Private Data
64 
65  //- Finite area mesh
66  autoPtr<faMesh> aMeshPtr_;
67 
68  //- Free surface patch index
69  label fsPatchIndex_;
70 
71  //- Free surface faPatch-es which do not move
72  wordList fixedFreeSurfacePatches_;
73 
74  //- Free surface faPatch-es where wave shuld not reflect
75  wordList nonReflectingFreeSurfacePatches_;
76 
77  //- Free surface patches for which point normals must be corrected
78  wordList pointNormalsCorrectionPatches_;
79 
80  //- Is it free-surface points displacement direction
81  // parallel with free-surface point normals
82  Switch normalMotionDir_;
83 
84  //- Free-surface points displacement direction
85  // if not normal motion direction
86  vector motionDir_;
87 
88  //- Interface smoothing at the beginning of time step
89  Switch smoothing_;
90 
91  //- Pure free-surface
92  Switch pureFreeSurface_;
93 
94  //- Rigid free-surface
95  Switch rigidFreeSurface_;
96 
97  //- Correct contact line point normals
98  Switch correctContactLineNormals_;
99 
100  //- Surface tension coefficient of pure free-surface
101  dimensionedScalar sigma0_;
102 
103  //- Fluid density
104  dimensionedScalar rho_;
105 
106  //- Current interface tracking time index
107  label timeIndex_;
108 
109  //- Free-surface velocity field
110  mutable areaVectorField* UsPtr_;
111 
112  //- Points which are attached to the free-surface A side faces
113  // and which defines the free-surface shape
114  mutable vectorIOField* controlPointsPtr_;
115 
116  //- Field which additionally determines
117  // the motion of free-surface points
118  mutable labelList* motionPointsMaskPtr_;
119 
120  //- Displacement direction of free-surface points
121  mutable vectorField* pointsDisplacementDirPtr_;
122 
123  //- Displacement direction of free-surface control points
124  mutable vectorField* facesDisplacementDirPtr_;
125 
126  //- Free-surface net flux
127  mutable areaScalarField* fsNetPhiPtr_;
128 
129  //- Free-surface flux
130  mutable edgeScalarField* phisPtr_;
131 
132  //- Free-surface surfactant concetration
133  mutable areaScalarField* surfactConcPtr_;
134 
135  //- Volume surfactant concetration
136  mutable volScalarField* bulkSurfactConcPtr_;
137 
138  //- Surface tension field
139  mutable areaScalarField* surfaceTensionPtr_;
140 
141  //- Surfactant properties
142  mutable surfactantProperties* surfactantPtr_;
143 
144  //- Contact angle
145  mutable areaScalarField* contactAnglePtr_;
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
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 
245 public:
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  const Switch& pureFreeSurface() const
307  {
308  return pureFreeSurface_;
309  }
310 
311  //- Rigid free-surface
312  const Switch& rigidFreeSurface() const
313  {
314  return rigidFreeSurface_;
315  }
316 
317  //- Rigid free-surface
319  {
320  return rigidFreeSurface_;
321  }
322 
323  //- Correct contact line point normals
324  const Switch& correctContactLineNormals() const
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
342  areaVectorField& Us();
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();
358 
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
373 
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
397 
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
418 
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  deleteDemandDrivenData(controlPointsPtr_);
429  }
430 
431  //- Write VTK freeSurface mesh
432  void writeVTK() const;
433 
434  //- Write VTK freeSurface control points
435  void writeVTKControlPoints();
436 };
437 
438 
439 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
440 
441 } // End namespace Foam
442 
443 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
444 
445 #endif
446 
447 // ************************************************************************* //
regIOobject.H
volFields.H
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::interfaceTrackingFvMesh::aMesh
const faMesh & aMesh() const
Return reference to finite area mesh.
Definition: interfaceTrackingFvMesh.H:294
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::interfaceTrackingFvMesh::aMesh
faMesh & aMesh()
Return reference to finite area mesh.
Definition: interfaceTrackingFvMesh.H:288
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::interfaceTrackingFvMesh::bulkSurfactantConcentration
volScalarField & bulkSurfactantConcentration()
Return volume surfactant concentration field.
Definition: interfaceTrackingFvMesh.C:1986
faCFD.H
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
Foam::interfaceTrackingFvMesh::surfactantConcentration
areaScalarField & surfactantConcentration()
Return free-surface surfactant concentration field.
Definition: interfaceTrackingFvMesh.C:1962
Foam::interfaceTrackingFvMesh::sigma
const dimensionedScalar & sigma() const
Surface tension coefficient of pure free-surface.
Definition: interfaceTrackingFvMesh.H:335
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
singlePhaseTransportModel.H
Foam::interfaceTrackingFvMesh::pureFreeSurface
const Switch & pureFreeSurface() const
Pure free-surface.
Definition: interfaceTrackingFvMesh.H:305
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::interfaceTrackingFvMesh
The interfaceTrackingFvMesh.
Definition: interfaceTrackingFvMesh.H:58
Foam::interfaceTrackingFvMesh::writeVTK
void writeVTK() const
Write VTK freeSurface mesh.
Definition: interfaceTrackingFvMesh.C:2271
Foam::interfaceTrackingFvMesh::correctContactLineNormals
const Switch & correctContactLineNormals() const
Correct contact line point normals.
Definition: interfaceTrackingFvMesh.H:323
surfaceFields.H
Foam::surfaceFields.
Foam::interfaceTrackingFvMesh::fsPatchIndex
const label & fsPatchIndex() const
Definition: interfaceTrackingFvMesh.H:299
Foam::interfaceTrackingFvMesh::freeSurfacePressureJump
tmp< scalarField > freeSurfacePressureJump()
Return free surface pressure jump.
Definition: interfaceTrackingFvMesh.C:1875
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::interfaceTrackingFvMesh::updateUs
void updateUs()
Update free-surface velocity field.
Definition: interfaceTrackingFvMesh.C:1779
Foam::interfaceTrackingFvMesh::mesh
fvMesh & mesh()
Definition: interfaceTrackingFvMesh.H:277
surfactantProperties.H
Foam::interfaceTrackingFvMesh::surfaceTensionGrad
tmp< areaVectorField > surfaceTensionGrad()
Return surface tension gradient.
Definition: interfaceTrackingFvMesh.C:2046
Foam::Field< vector >
Foam::interfaceTrackingFvMesh::p
const volScalarField & p() const
Return constant reference to pressure field.
Definition: interfaceTrackingFvMesh.C:1801
Foam::interfaceTrackingFvMesh::pointsDisplacementDir
vectorField & pointsDisplacementDir()
Return reference to point displacement direction field.
Definition: interfaceTrackingFvMesh.C:1929
Foam::interfaceTrackingFvMesh::correctContactLineNormals
Switch & correctContactLineNormals()
Correct contact line point normals.
Definition: interfaceTrackingFvMesh.H:329
Foam::interfaceTrackingFvMesh::rigidFreeSurface
const Switch & rigidFreeSurface() const
Rigid free-surface.
Definition: interfaceTrackingFvMesh.H:311
Foam::interfaceTrackingFvMesh::U
const volVectorField & U() const
Return constant reference to velocity field.
Definition: interfaceTrackingFvMesh.C:1795
Foam::interfaceTrackingFvMesh::rigidFreeSurface
Switch & rigidFreeSurface()
Rigid free-surface.
Definition: interfaceTrackingFvMesh.H:317
Foam::dimensioned< scalar >
Foam::interfaceTrackingFvMesh::fsNetPhi
const areaScalarField & fsNetPhi() const
Return free-surface net flux.
Definition: interfaceTrackingFvMesh.C:1721
Foam::interfaceTrackingFvMesh::freeSurfaceSnGradU
tmp< vectorField > freeSurfaceSnGradU()
Return free surface normal derivative of velocity.
Definition: interfaceTrackingFvMesh.C:1814
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::surfactantProperties
Definition: surfactantProperties.H:50
Foam::interfaceTrackingFvMesh::freeSurfaceSnGradUn
tmp< scalarField > freeSurfaceSnGradUn()
Return free surface normal derivative of normal velocity comp.
Definition: interfaceTrackingFvMesh.C:1857
Foam::interfaceTrackingFvMesh::surfaceTension
areaScalarField & surfaceTension()
Return surface tension field.
Definition: interfaceTrackingFvMesh.C:2010
Foam::interfaceTrackingFvMesh::normalMotionDir
bool normalMotionDir() const
Motion direction swithc.
Definition: interfaceTrackingFvMesh.H:389
Foam::interfaceTrackingFvMesh::motionPointsMask
labelList & motionPointsMask()
Return reference to motion points mask field.
Definition: interfaceTrackingFvMesh.C:1918
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::interfaceTrackingFvMesh::TypeName
TypeName("interfaceTrackingFvMesh")
Runtime type information.
dynamicMotionSolverFvMesh.H
Foam::Vector< scalar >
Foam::List< word >
Foam::interfaceTrackingFvMesh::writeVTKControlPoints
void writeVTKControlPoints()
Write VTK freeSurface control points.
Definition: interfaceTrackingFvMesh.C:2284
Foam::interfaceTrackingFvMesh::facesDisplacementDir
vectorField & facesDisplacementDir()
Return reference to control points displacement direction field.
Definition: interfaceTrackingFvMesh.C:1940
Foam::interfaceTrackingFvMesh::clearControlPoints
void clearControlPoints()
Clear control points.
Definition: interfaceTrackingFvMesh.H:425
Foam::interfaceTrackingFvMesh::correctUsBoundaryConditions
void correctUsBoundaryConditions()
Correct surface velocity boundary conditions.
Definition: interfaceTrackingFvMesh.C:1732
Foam::interfaceTrackingFvMesh::phi
const surfaceScalarField & phi() const
Return constant reference to velocity field.
Definition: interfaceTrackingFvMesh.C:1807
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::interfaceTrackingFvMesh::controlPoints
vectorField & controlPoints()
Return control points.
Definition: interfaceTrackingFvMesh.C:1907
Foam::interfaceTrackingFvMesh::update
virtual bool update()
Update the mesh for both mesh motion and topology change.
Definition: interfaceTrackingFvMesh.C:2075
Foam::interfaceTrackingFvMesh::surfactant
const surfactantProperties & surfactant() const
Return surfactant properties.
Definition: interfaceTrackingFvMesh.C:2034
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::interfaceTrackingFvMesh::mesh
const fvMesh & mesh() const
Definition: interfaceTrackingFvMesh.H:282
Foam::interfaceTrackingFvMesh::Us
areaVectorField & Us()
Return free-surface velocity field.
Definition: interfaceTrackingFvMesh.C:1688
Foam::interfaceTrackingFvMesh::init
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: interfaceTrackingFvMesh.C:1662
Foam::interfaceTrackingFvMesh::Phis
edgeScalarField & Phis()
Return free-surface fluid flux field.
Definition: interfaceTrackingFvMesh.C:1951
Foam::interfaceTrackingFvMesh::~interfaceTrackingFvMesh
* ~interfaceTrackingFvMesh()
Destructor.
Definition: interfaceTrackingFvMesh.C:1643
Foam::dynamicMotionSolverFvMesh
The dynamicMotionSolverFvMesh.
Definition: dynamicMotionSolverFvMesh.H:53