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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2018-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 \*---------------------------------------------------------------------------*/
28 
29 #include "contactAngleForce.H"
31 #include "fvcGrad.H"
32 #include "unitConversion.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace regionModels
40 {
41 namespace surfaceFilmModels
42 {
43 
44 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45 
46 defineTypeNameAndDebug(contactAngleForce, 0);
47 
48 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
49 
50 void contactAngleForce::initialise()
51 {
52  const wordRes zeroForcePatches
53  (
54  coeffDict_.getOrDefault<wordRes>("zeroForcePatches", wordRes())
55  );
56 
57  if (zeroForcePatches.size())
58  {
59  const polyBoundaryMesh& pbm = filmModel_.regionMesh().boundaryMesh();
60  const scalar dLim = coeffDict_.get<scalar>("zeroForceDistance");
61 
62  Info<< " Assigning zero contact force within " << dLim
63  << " of patches:" << endl;
64 
65  labelHashSet patchIDs = pbm.patchSet(zeroForcePatches);
66 
67  for (const label patchi : patchIDs)
68  {
69  Info<< " " << pbm[patchi].name() << endl;
70  }
71 
72  // Temporary implementation until run-time selection covers this case
73  patchDistMethods::meshWave dist(filmModel_.regionMesh(), patchIDs);
75  (
76  IOobject
77  (
78  "y",
83  false
84  ),
86  dimensionedScalar("y", dimLength, GREAT)
87  );
88  dist.correct(y);
89 
90  mask_ = pos0(y - dimensionedScalar("dLim", dimLength, dLim));
91  }
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
96 
97 contactAngleForce::contactAngleForce
98 (
99  const word& typeName,
101  const dictionary& dict
102 )
103 :
104  force(typeName, film, dict),
105  Ccf_(coeffDict_.get<scalar>("Ccf")),
106  mask_
107  (
108  IOobject
109  (
110  typeName + ":contactForceMask",
111  filmModel_.time().timeName(),
112  filmModel_.regionMesh(),
115  ),
116  filmModel_.regionMesh(),
117  dimensionedScalar("mask", dimless, 1.0)
118  )
119 {
120  initialise();
121 }
122 
123 
124 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
125 
127 {}
128 
129 
130 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
131 
133 {
134  tmp<volVectorField> tForce
135  (
136  new volVectorField
137  (
138  IOobject
139  (
140  typeName + ":contactForce",
145  ),
148  )
149  );
150 
151  vectorField& force = tForce.ref().primitiveFieldRef();
152 
153  const labelUList& own = filmModel_.regionMesh().owner();
154  const labelUList& nbr = filmModel_.regionMesh().neighbour();
155 
156  const scalarField& magSf = filmModel_.magSf();
157 
160 
161  const tmp<volScalarField> ttheta = theta();
162  const volScalarField& theta = ttheta();
163 
164  const volVectorField gradAlpha(fvc::grad(alpha));
165 
166  forAll(nbr, facei)
167  {
168  const label cellO = own[facei];
169  const label cellN = nbr[facei];
170 
171  label celli = -1;
172  if ((alpha[cellO] > 0.5) && (alpha[cellN] < 0.5))
173  {
174  celli = cellO;
175  }
176  else if ((alpha[cellO] < 0.5) && (alpha[cellN] > 0.5))
177  {
178  celli = cellN;
179  }
180 
181  if (celli != -1 && mask_[celli] > 0.5)
182  {
183  const scalar invDx = filmModel_.regionMesh().deltaCoeffs()[facei];
184  const vector n =
185  gradAlpha[celli]/(mag(gradAlpha[celli]) + ROOTVSMALL);
186  const scalar cosTheta = cos(degToRad(theta[celli]));
187  force[celli] += Ccf_*n*sigma[celli]*(1 - cosTheta)/invDx;
188  }
189  }
190 
191  forAll(alpha.boundaryField(), patchi)
192  {
193  if (!filmModel_.isCoupledPatch(patchi))
194  {
195  const fvPatchField<scalar>& alphaPf = alpha.boundaryField()[patchi];
196  const fvPatchField<scalar>& maskPf = mask_.boundaryField()[patchi];
197  const fvPatchField<scalar>& sigmaPf = sigma.boundaryField()[patchi];
198  const fvPatchField<scalar>& thetaPf = theta.boundaryField()[patchi];
199  const scalarField& invDx = alphaPf.patch().deltaCoeffs();
200  const labelUList& faceCells = alphaPf.patch().faceCells();
201 
202  forAll(alphaPf, facei)
203  {
204  if (maskPf[facei] > 0.5)
205  {
206  label cellO = faceCells[facei];
207 
208  if ((alpha[cellO] > 0.5) && (alphaPf[facei] < 0.5))
209  {
210  const vector n =
211  gradAlpha[cellO]
212  /(mag(gradAlpha[cellO]) + ROOTVSMALL);
213  const scalar cosTheta = cos(degToRad(thetaPf[facei]));
214  force[cellO] +=
215  Ccf_*n*sigmaPf[facei]*(1 - cosTheta)/invDx[facei];
216  }
217  }
218  }
219  }
220  }
221 
222  force /= magSf;
223 
225  {
226  tForce().write();
227  }
228 
230  (
232  );
233 
234  tfvm.ref() += tForce;
235 
236  return tfvm;
237 }
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 } // End namespace surfaceFilmModels
243 } // End namespace regionModels
244 } // End namespace Foam
245 
246 // ************************************************************************* //
Foam::fvPatchField< scalar >
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
contactAngleForce.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::subModelBase::coeffDict_
const dictionary coeffDict_
Coefficients dictionary.
Definition: subModelBase.H:82
Foam::regionModels::regionModel::time
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:40
unitConversion.H
Unit conversion functions.
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::dimForce
const dimensionSet dimForce
Foam::surfaceInterpolation::deltaCoeffs
virtual const surfaceScalarField & deltaCoeffs() const
Return reference to cell-centre difference coefficients.
Definition: surfaceInterpolation.C:113
Foam::regionModels::surfaceFilmModels::contactAngleForce::correct
virtual tmp< fvVectorMatrix > correct(volVectorField &U)
Correct.
Definition: contactAngleForce.C:132
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel::sigma
virtual const volScalarField & sigma() const =0
Return the film surface tension [N/m].
Foam::regionModels::surfaceFilmModels::contactAngleForce::theta
virtual tmp< volScalarField > theta() const =0
Return the contact angle field.
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::fvVectorMatrix
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:47
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::regionModels::regionModel::isCoupledPatch
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:134
Foam::Field< vector >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::TimeState::writeTime
bool writeTime() const noexcept
True if this is a write time.
Definition: TimeStateI.H:67
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::regionModels::singleLayerRegion::magSf
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
Definition: singleLayerRegion.C:223
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel::alpha
virtual const volScalarField & alpha() const =0
Return the film coverage, 1 = covered, 0 = uncovered / [].
meshWavePatchDistMethod.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fvMesh::neighbour
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:413
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::fvMesh::owner
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
Definition: fvMesh.H:407
Foam::regionModels::surfaceFilmModels::defineTypeNameAndDebug
defineTypeNameAndDebug(kinematicSingleLayer, 0)
U
U
Definition: pEqn.H:72
Foam::Vector< scalar >
Foam::regionModels::surfaceFilmModels::force
Base class for film (stress-based) force models.
Definition: force.H:57
fvcGrad.H
Calculate the gradient of the given field.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fvPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Definition: fvPatch.C:196
Foam::UList< label >
Foam::fvPatch::faceCells
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:113
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::fvPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:357
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
Foam::regionModels::surfaceFilmModels::filmSubModelBase::filmModel_
surfaceFilmRegionModel & filmModel_
Reference to the film surface film model.
Definition: filmSubModelBase.H:65
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:148
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::regionModels::surfaceFilmModels::contactAngleForce::~contactAngleForce
virtual ~contactAngleForce()
Destructor.
Definition: contactAngleForce.C:126
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265