1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Implementation of Free surface (interface) tracking method
33 freeSurfacePointDisplacement.C
36 \*---------------------------------------------------------------------------*/
43 #include "IOdictionary.H"
44 #include "volFieldsFwd.H"
45 #include "surfaceFieldsFwd.H"
47 #include "IOpatchToPatchInterpolation.H"
48 #include "dynamicFvMesh.H"
50 #include "surfactantProperties.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 /*---------------------------------------------------------------------------*\
58 Class freeSurface Declaration
59 \*---------------------------------------------------------------------------*/
67 //- Reference to fvMesh
70 //- Reference to density field
71 const volScalarField& rho_;
73 //- Reference to velocity field
76 //- Reference to pressure field
79 //- Reference to fluid flux field
80 const surfaceScalarField& phi_;
82 //- Current time index for free-surface
85 //- Are there exist two fluids in the free-surface model
88 //- Is it free-surface points displacement direction
89 // parallel with free-surface point normals
90 Switch normalMotionDir_;
92 //- Free-surface points displacement direction
93 // if not normal motion direction
96 //- Is it free-surface clean of surfactant
97 Switch cleanInterface_;
99 //- ID of the fvMesh patch which represents
100 // A side of the free-surface
103 //- ID of the fvMesh patch which represents
104 // B side of the free-surface
107 //- Viscosity of fluid A
108 dimensionedScalar muFluidA_;
110 //- Viscosity of fluid B
111 dimensionedScalar muFluidB_;
113 //- Density of fluid A
114 dimensionedScalar rhoFluidA_;
116 //- Density of fluid B
117 dimensionedScalar rhoFluidB_;
119 //- Reference to gravitational acceleration
120 dimensionedVector g_;
122 //- Surface tension for the clean free-surface
123 dimensionedScalar cleanInterfaceSurfTension_;
125 //- Free surface patches which do not move
126 wordList fixedFreeSurfacePatches_;
128 //- Free surface patches for witch point normals
130 wordList pointNormalsCorrectionPatches_;
132 //- Number of free-surface correctors
133 label nFreeSurfCorr_;
135 //- Interface smoothing at the begining of time step
138 // Demand-driven data
140 //- Patch to patch interpolation object which deals with
141 // interpolation of flow variables between two free-surface
142 // (interface) patches
143 mutable IOpatchToPatchInterpolation* interpolatorABPtr_;
145 //- Patch to patch interpolation object which deals with
146 // interpolation of flow variables between two free-surface
147 // (interface) patches
148 mutable IOpatchToPatchInterpolation* interpolatorBAPtr_;
150 //- Points which are attached to the free-surface A side faces
151 // and which defines the free-surface shape
152 mutable vectorIOField* controlPointsPtr_;
154 //- Field which additionally determines
155 // the motion of free-surface points
156 mutable labelList* motionPointsMaskPtr_;
158 //- Displacement direction of free-surface points
159 mutable vectorField* pointsDisplacementDirPtr_;
161 //- Displacement direction of free-surface control points
162 mutable vectorField* facesDisplacementDirPtr_;
164 //- Total displacement of free-surface points
166 mutable vectorIOField* totalDisplacementPtr_;
168 //- Finite area mesh which consists
169 // free-surface side A faces
170 mutable faMesh* aMeshPtr_;
172 //- Free-surface velocity field
173 mutable areaVectorField* UsPtr_;
175 //- Free-surface fluid flux
176 mutable edgeScalarField* phisPtr_;
178 //- Free-surface surfactant concetration
179 mutable areaScalarField* surfactConcPtr_;
181 //- Surface tension field
182 mutable areaScalarField* surfaceTensionPtr_;
184 //- Surfactant properties
185 mutable surfactantProperties* surfactantPtr_;
188 mutable volScalarField* fluidIndicatorPtr_;
190 // Private Member Functions
192 // Make demand-driven data
194 void makeInterpolators();
195 void makeControlPoints();
196 void makeMotionPointsMask();
197 void makeDirections();
198 void makeTotalDisplacement();
199 void readTotalDisplacement();
200 void makeFaMesh() const;
205 void makeSurfactConc() const;
206 void makeSurfaceTension() const;
207 void makeSurfactant() const;
208 void makeFluidIndicator();
210 //- Clear all demand-driven data
213 //- Disallow default bitwise copy construct
214 freeSurface(const freeSurface&);
216 //- Disallow default bitwise assignment
217 void operator=(const freeSurface&);
219 //- Move control ponts for deltaH and calculate
220 // free surface points displacement
221 // for given new control points position
222 tmp<vectorField> pointDisplacement(const scalarField& deltaH);
224 // Calc least sqare plane point and normal
225 tmp<vectorField> lsPlanePointAndNormal
227 const vectorField& points,
228 const vector& origin,
234 // Declare name of the class and it's debug switch
235 ClassName("freeSurface");
243 const volScalarField& rho,
246 const surfaceScalarField& phi
258 //- Return reference to fvMesh
259 dynamicFvMesh& mesh()
264 //- Return reference to fvMesh
265 const dynamicFvMesh& mesh() const
270 //- Return reference to DB
271 const Time& DB() const
273 return U_.mesh().time();
276 //- Return reference to velocity field
277 const volScalarField& rho() const
282 //- Return reference to velocity field
288 //- Return reference to velocity field
289 const volVectorField& U() const
294 //- Return reference to pressure field
300 //- Return reference to pressure field
301 const volScalarField& p() const
306 //- Are there exist two fluid
307 // in the free-surface model
308 bool twoFluids() const
313 //- Motion direction swithc
314 bool normalMotionDir() const
316 return normalMotionDir_;
319 //- Is it interface clean
320 bool cleanInterface() const
322 return cleanInterface_;
325 //- ID of patch which represent A side
327 const label& aPatchID() const
332 //- ID of patch which represent B side
334 const label& bPatchID() const
339 //- Viscosity of fluid A
340 const dimensionedScalar& muFluidA() const
345 //- Viscosity of fluid B
346 const dimensionedScalar& muFluidB() const
351 //- Density of fluid A
352 const dimensionedScalar& rhoFluidA() const
357 //- Densiti of fluid B
358 const dimensionedScalar& rhoFluidB() const
364 const dimensionedVector& g() const
369 //- Surface tension for clean interface
370 const dimensionedScalar& cleanInterfaceSurfTension() const
372 return cleanInterfaceSurfTension_;
375 //- Return reference to interpolator from free surface side A to
376 // free surface side B
377 const IOpatchToPatchInterpolation& interpolatorAB();
379 //- Return reference to interpolator from free surface side B to
380 // free surface side A
381 const IOpatchToPatchInterpolation& interpolatorBA();
383 //- Return control points
384 vectorField& controlPoints();
386 //- Return reference to motion points mask field
387 labelList& motionPointsMask();
389 //- Return reference to point displacement direction field
390 vectorField& pointsDisplacementDir();
392 //- Return reference to control points displacement direction field
393 vectorField& facesDisplacementDir();
395 //- Return total points displacement
396 vectorField& totalDisplacement();
398 //- Return reference to finite area mesh
401 //- Return reference to finite area mesh
402 const faMesh& aMesh() const;
404 //- Return free-surface velocity field
405 areaVectorField& Us();
407 //- Return free-surface velocity field
408 const areaVectorField& Us() const;
410 //- Return free-surface fluid flux field
411 edgeScalarField& Phis();
413 //- Return free-surface surfactant concentration field
414 areaScalarField& surfactantConcentration();
416 //- Return free-surface surfactant concentration field
417 const areaScalarField& surfactantConcentration() const;
419 //- Return surface tension field
420 areaScalarField& surfaceTension();
422 //- Return surface tension field
423 const areaScalarField& surfaceTension() const;
425 //- Return surface tension gradient
426 tmp<areaVectorField> surfaceTensionGrad();
428 //- Return surfactant properties
429 const surfactantProperties& surfactant() const;
431 //- Return referenct to fluid indicator
432 const volScalarField& fluidIndicator();
434 //- Update control points end displacement directions
435 void updateDisplacementDirections();
437 //- Predict interface points position
438 bool predictPoints();
440 //- Correct interface points position
441 bool correctPoints();
443 //- Move only free-surface points
444 bool movePoints(const scalarField& interfacePHi);
446 //- Move mesh points for old time free-surface points displacement
447 bool moveMeshPointsForOldFreeSurfDisplacement();
450 bool moveMeshPoints();
452 //- Update free-surface boundary conditions
453 void updateBoundaryConditions();
455 //- Correct free-surface pressure
456 void updatePressure();
458 //- Correct free-surface velocity
459 void updateVelocity();
461 //- Update free-surface flux
462 void updateSurfaceFlux();
464 //- Update free-surface surfactant concentration
465 void updateSurfactantConcentration();
467 //- Correct surface velocity boundary conditions
468 void correctUsBoundaryConditions();
470 //- Calculate total pressure force
471 vector totalPressureForce() const;
473 //- Calculate total viscous force
474 vector totalViscousForce() const;
476 //- Calculate total surface tension force
477 vector totalSurfaceTensionForce() const;
479 //- Calculate free-surface undulation indicator
480 tmp<scalarField> undulationIndicator();
482 //- Smooth free-surface
485 //- Chech free-surface faces flatness
486 tmp<scalarField> checkFaceFlatness();
488 //- Initialize control points position
489 void initializeControlPointsPosition();
491 //- Maximal surface tension based Courant number
492 scalar maxCourantNumber();
494 //- Update properties
495 void updateProperties();
497 //- Write VTK freeSurface mesh
498 void writeVTK() const;
500 //- Write VTK freeSurface control points
501 void writeVTKControlPoints();
505 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
507 } // End namespace Foam
509 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
513 // ************************************************************************* //