contactAngleForce.C
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) 2020-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "contactAngleForce.H"
30 #include "faCFD.H"
31 #include "unitConversion.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace regionModels
39 {
40 namespace areaSurfaceFilmModels
41 {
42 
43 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 contactAngleForce::contactAngleForce
50 (
51  const word& typeName,
52  liquidFilmBase& film,
53  const dictionary& dict
54 )
55 :
56  force(typeName, film, dict),
57  Ccf_(coeffDict_.get<scalar>("Ccf")),
58  hCrit_(coeffDict_.getOrDefault<scalar>("hCrit", GREAT))
59 {}
60 
61 
62 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
63 
65 {
66  auto tforce = tmp<areaVectorField>::New
67  (
68  IOobject
69  (
70  IOobject::scopedName(typeName, "contactForce"),
71  film().regionMesh().time().timeName(),
72  film().regionMesh().thisDb(),
76  ),
77  film().regionMesh(),
79  );
80  vectorField& force = tforce.ref().primitiveFieldRef();
81 
82  const labelUList& own = film().regionMesh().owner();
83  const labelUList& nei = film().regionMesh().neighbour();
84 
86  const scalarField& magSff = magSf.field();
87 
88  const edgeScalarField& invDx = film().regionMesh().deltaCoeffs();
89 
90  const areaScalarField& sigma = film().sigma();
91  const areaScalarField& mu = film().mu();
92  const areaScalarField& rhof = film().rho();
93  const areaVectorField& Uf = film().Uf();
94  const areaScalarField& hf = film().h();
95 
96  tmp<areaScalarField> talpha = film().alpha();
97  const areaScalarField& alpha = talpha();
98 
99  tmp<areaScalarField> ttheta = theta();
100  const areaScalarField& theta = ttheta();
101 
102  tmp<areaVectorField> tgradAlpha = fac::grad(alpha);
103  const areaVectorField& gradAlpha = tgradAlpha();
104 
105  forAll(nei, edgei)
106  {
107  const label faceO = own[edgei];
108  const label faceN = nei[edgei];
109 
110  label facei = -1;
111  if ((alpha[faceO] > 0.5) && (alpha[faceN] < 0.5))
112  {
113  facei = faceO;
114  }
115  else if ((alpha[faceO] < 0.5) && (alpha[faceN] > 0.5))
116  {
117  facei = faceN;
118  }
119 
120  if (facei != -1)
121  {
122  const vector n(normalised(gradAlpha[facei]));
123  const scalar cosTheta = cos(degToRad(theta[facei]));
124 
125  // (MHDX:Eq. 13)
126  force[facei] +=
127  Ccf_*n*sigma[facei]*(1 - cosTheta)
128  /invDx[edgei]/rhof[facei]/magSff[facei];
129 
130  // (NDPC:Eq. 11)
131  if (hf[facei] > hCrit_)
132  {
133  force[facei] -= mu[facei]*Uf[facei]/hCrit_;
134  }
135  }
136  }
137 
138  for (const faPatchScalarField& sigmaBf : sigma.boundaryField())
139  {
140  const faPatch& p = sigmaBf.patch();
141 
142  if (!p.coupled())
143  {
144  const labelUList& faces = p.edgeFaces();
145 
146  forAll(sigmaBf, edgei)
147  {
148  const label face0 = faces[edgei];
149  force[face0] = Zero;
150  }
151  }
152  }
153 
154  if (film().regionMesh().time().writeTime())
155  {
156  tforce().write();
157  gradAlpha.write();
158  }
159 
161 
162  tfvm.ref() += tforce;
163 
164  return tfvm;
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace areaSurfaceFilmModels
171 } // End namespace regionModels
172 } // End namespace Foam
173 
174 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Base-class for film contact angle force models.
dictionary dict
const edgeScalarField & deltaCoeffs() const
Return reference to difference factors array.
const areaScalarField & h() const
Access const reference h.
virtual tmp< areaScalarField > theta() const =0
Return the contact angle field.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual const areaScalarField & sigma() const =0
Access const reference sigma.
Unit conversion functions.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
const DimensionedField< scalar, areaMesh > & S() const
Return face areas.
Definition: faMesh.C:914
Base class for film (stress-based) force models.
Definition: force.H:52
Ignore writing from objectRegistry::writeObject()
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Definition: quaternionI.H:674
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
defineTypeNameAndDebug(kinematicThinFilm, 0)
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Macros for easy insertion into run-time selection tables.
virtual bool writeTime() const
Flag to indicate when to write a property.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
const labelUList & neighbour() const
Internal face neighbour.
Definition: faMesh.H:1114
word timeName
Definition: getTimeIndex.H:3
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition: IOobjectI.H:40
dimensionedScalar cos(const dimensionedScalar &ds)
virtual tmp< faVectorMatrix > correct(areaVectorField &U)
Correct.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const areaVectorField & Uf() const
Access const reference Uf.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
const faMesh & regionMesh() const
Return the region mesh database.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
autoPtr< surfaceVectorField > Uf
const dimensionSet dimForce
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
const dimensionSet dimDensity
const labelUList & owner() const
Internal face owner.
Definition: faMesh.H:1106
const Field< Type > & field() const noexcept
Return const-reference to the field values.
const dimensionedScalar mu
Atomic mass unit.
U
Definition: pEqn.H:72
virtual const areaScalarField & rho() const =0
Access const reference rho.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
Nothing to be read.
label n
virtual const areaScalarField & mu() const =0
Access const reference mu.
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
tmp< areaScalarField > alpha() const
Wet indicator using h0.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
surfaceScalarField rhof(fvc::interpolate(rho, "div(phi,rho)"))
Do not request registration (bool: false)
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Namespace for OpenFOAM.
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:51
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127
const liquidFilmBase & film() const
Return const access to the film surface film model.