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
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  fvMesh& mesh()
276  {
277  return *this;
278  }
279 
280  const fvMesh& mesh() const
281  {
282  return *this;
283  }
284 
285  //- Return reference to finite area mesh
286  faMesh& aMesh()
287  {
288  return aMeshPtr_();
289  }
290 
291  //- Return reference to finite area mesh
292  const faMesh& aMesh() const
293  {
294  return aMeshPtr_();
295  }
296 
297  const label& fsPatchIndex() const
298  {
299  return fsPatchIndex_;
300  }
301 
302  //- Pure free-surface
303  const Switch& pureFreeSurface() const
304  {
305  return pureFreeSurface_;
306  }
307 
308  //- Rigid free-surface
309  const Switch& rigidFreeSurface() const
310  {
311  return rigidFreeSurface_;
312  }
313 
314  //- Rigid free-surface
316  {
317  return rigidFreeSurface_;
318  }
319 
320  //- Correct contact line point normals
321  const Switch& correctContactLineNormals() const
322  {
323  return correctContactLineNormals_;
324  }
325 
326  //- Correct contact line point normals
328  {
329  return correctContactLineNormals_;
330  }
331 
332  //- Surface tension coefficient of pure free-surface
333  const dimensionedScalar& sigma() const
334  {
335  return sigma0_;
336  }
337 
338  //- Return free-surface velocity field
339  areaVectorField& Us();
340 
341  //- Return free-surface velocity field
342  const areaVectorField& Us() const;
343 
344  //- Return free-surface net flux
345  const areaScalarField& fsNetPhi() const;
346 
347  //- Return free-surface net flux
349 
350  //- Correct surface velocity boundary conditions
352 
353  //- Update free-surface velocity field
354  void updateUs();
355 
356  //- Return constant reference to velocity field
357  const volVectorField& U() const;
358 
359  //- Return constant reference to pressure field
360  const volScalarField& p() const;
361 
362  //- Return constant reference to velocity field
363  const surfaceScalarField& phi() const;
364 
365  //- Return free surface normal derivative of velocity
367 
368  //- Return free surface normal derivative of normal velocity comp
370 
371  //- Return free surface pressure jump
373 
374  //- Return control points
376 
377  //- Return reference to motion points mask field
379 
380  //- Return reference to point displacement direction field
382 
383  //- Return reference to control points displacement direction field
385 
386  //- Motion direction swithc
387  bool normalMotionDir() const
388  {
389  return normalMotionDir_;
390  }
391 
392  //- Return free-surface fluid flux field
394 
395  //- Return free-surface surfactant concentration field
397 
398  //- Return free-surface surfactant concentration field
400 
401  //- Return volume surfactant concentration field
403 
404  //- Return volume surfactant concentration field
406 
407  //- Return surface tension field
409 
410  //- Return surface tension field
411  const areaScalarField& surfaceTension() const;
412 
413  //- Return surface tension gradient
415 
416  //- Return surfactant properties
417  const surfactantProperties& surfactant() const;
418 
419  //- Update the mesh for both mesh motion and topology change
420  virtual bool update();
421 
422  //- Clear control points
423  void clearControlPoints()
424  {
425  deleteDemandDrivenData(controlPointsPtr_);
426  }
427 
428  //- Write VTK freeSurface mesh
429  void writeVTK() const;
430 
431  //- Write VTK freeSurface control points
432  void writeVTKControlPoints();
433 };
434 
435 
436 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
437 
438 } // End namespace Foam
439 
440 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441 
442 #endif
443 
444 // ************************************************************************* //
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:291
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::interfaceTrackingFvMesh::aMesh
faMesh & aMesh()
Return reference to finite area mesh.
Definition: interfaceTrackingFvMesh.H:285
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:1988
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:1964
Foam::interfaceTrackingFvMesh::sigma
const dimensionedScalar & sigma() const
Surface tension coefficient of pure free-surface.
Definition: interfaceTrackingFvMesh.H:332
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:302
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:2273
Foam::interfaceTrackingFvMesh::correctContactLineNormals
const Switch & correctContactLineNormals() const
Correct contact line point normals.
Definition: interfaceTrackingFvMesh.H:320
surfaceFields.H
Foam::surfaceFields.
Foam::interfaceTrackingFvMesh::fsPatchIndex
const label & fsPatchIndex() const
Definition: interfaceTrackingFvMesh.H:296
Foam::interfaceTrackingFvMesh::freeSurfacePressureJump
tmp< scalarField > freeSurfacePressureJump()
Return free surface pressure jump.
Definition: interfaceTrackingFvMesh.C:1877
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::interfaceTrackingFvMesh::updateUs
void updateUs()
Update free-surface velocity field.
Definition: interfaceTrackingFvMesh.C:1781
Foam::interfaceTrackingFvMesh::mesh
fvMesh & mesh()
Definition: interfaceTrackingFvMesh.H:274
surfactantProperties.H
Foam::interfaceTrackingFvMesh::surfaceTensionGrad
tmp< areaVectorField > surfaceTensionGrad()
Return surface tension gradient.
Definition: interfaceTrackingFvMesh.C:2048
Foam::Field< vector >
Foam::interfaceTrackingFvMesh::p
const volScalarField & p() const
Return constant reference to pressure field.
Definition: interfaceTrackingFvMesh.C:1803
Foam::interfaceTrackingFvMesh::pointsDisplacementDir
vectorField & pointsDisplacementDir()
Return reference to point displacement direction field.
Definition: interfaceTrackingFvMesh.C:1931
Foam::interfaceTrackingFvMesh::correctContactLineNormals
Switch & correctContactLineNormals()
Correct contact line point normals.
Definition: interfaceTrackingFvMesh.H:326
Foam::interfaceTrackingFvMesh::rigidFreeSurface
const Switch & rigidFreeSurface() const
Rigid free-surface.
Definition: interfaceTrackingFvMesh.H:308
Foam::interfaceTrackingFvMesh::U
const volVectorField & U() const
Return constant reference to velocity field.
Definition: interfaceTrackingFvMesh.C:1797
Foam::interfaceTrackingFvMesh::rigidFreeSurface
Switch & rigidFreeSurface()
Rigid free-surface.
Definition: interfaceTrackingFvMesh.H:314
Foam::dimensioned< scalar >
Foam::interfaceTrackingFvMesh::fsNetPhi
const areaScalarField & fsNetPhi() const
Return free-surface net flux.
Definition: interfaceTrackingFvMesh.C:1723
Foam::interfaceTrackingFvMesh::freeSurfaceSnGradU
tmp< vectorField > freeSurfaceSnGradU()
Return free surface normal derivative of velocity.
Definition: interfaceTrackingFvMesh.C:1816
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
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:1859
Foam::interfaceTrackingFvMesh::surfaceTension
areaScalarField & surfaceTension()
Return surface tension field.
Definition: interfaceTrackingFvMesh.C:2012
Foam::interfaceTrackingFvMesh::normalMotionDir
bool normalMotionDir() const
Motion direction swithc.
Definition: interfaceTrackingFvMesh.H:386
Foam::interfaceTrackingFvMesh::motionPointsMask
labelList & motionPointsMask()
Return reference to motion points mask field.
Definition: interfaceTrackingFvMesh.C:1920
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1094
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:2353
Foam::interfaceTrackingFvMesh::facesDisplacementDir
vectorField & facesDisplacementDir()
Return reference to control points displacement direction field.
Definition: interfaceTrackingFvMesh.C:1942
Foam::interfaceTrackingFvMesh::clearControlPoints
void clearControlPoints()
Clear control points.
Definition: interfaceTrackingFvMesh.H:422
Foam::interfaceTrackingFvMesh::correctUsBoundaryConditions
void correctUsBoundaryConditions()
Correct surface velocity boundary conditions.
Definition: interfaceTrackingFvMesh.C:1734
Foam::interfaceTrackingFvMesh::phi
const surfaceScalarField & phi() const
Return constant reference to velocity field.
Definition: interfaceTrackingFvMesh.C:1809
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:77
Foam::interfaceTrackingFvMesh::controlPoints
vectorField & controlPoints()
Return control points.
Definition: interfaceTrackingFvMesh.C:1909
Foam::interfaceTrackingFvMesh::update
virtual bool update()
Update the mesh for both mesh motion and topology change.
Definition: interfaceTrackingFvMesh.C:2077
Foam::interfaceTrackingFvMesh::surfactant
const surfactantProperties & surfactant() const
Return surfactant properties.
Definition: interfaceTrackingFvMesh.C:2036
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::interfaceTrackingFvMesh::mesh
const fvMesh & mesh() const
Definition: interfaceTrackingFvMesh.H:279
Foam::interfaceTrackingFvMesh::Us
areaVectorField & Us()
Return free-surface velocity field.
Definition: interfaceTrackingFvMesh.C:1690
Foam::interfaceTrackingFvMesh::Phis
edgeScalarField & Phis()
Return free-surface fluid flux field.
Definition: interfaceTrackingFvMesh.C:1953
Foam::interfaceTrackingFvMesh::~interfaceTrackingFvMesh
~interfaceTrackingFvMesh()
Destructor.
Definition: interfaceTrackingFvMesh.C:1671
Foam::dynamicMotionSolverFvMesh
The dynamicMotionSolverFvMesh.
Definition: dynamicMotionSolverFvMesh.H:53