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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "contactAngleForce.H"
28 #include "fvcGrad.H"
29 #include "unitConversion.H"
30 #include "fvPatchField.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace regionModels
38 {
39 namespace surfaceFilmModels
40 {
41 
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 
46 
47 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
48 
50 {
51  const wordReList zeroForcePatches(coeffDict_.lookup("zeroForcePatches"));
52 
53  if (zeroForcePatches.size())
54  {
56  scalar dLim = readScalar(coeffDict_.lookup("zeroForceDistance"));
57 
58  Info<< " Assigning zero contact force within " << dLim
59  << " of patches:" << endl;
60 
61  labelHashSet patchIDs = pbm.patchSet(zeroForcePatches);
62 
63  forAllConstIter(labelHashSet, patchIDs, iter)
64  {
65  label patchI = iter.key();
66  Info<< " " << pbm[patchI].name() << endl;
67  }
68 
69  // Temporary implementation until run-time selection covers this case
72  (
73  IOobject
74  (
75  "y",
80  false
81  ),
83  dimensionedScalar("y", dimLength, GREAT)
84  );
85  dist.correct(y);
86 
87  mask_ = pos(y - dimensionedScalar("dLim", dimLength, dLim));
88  }
89 }
90 
91 
92 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
93 
95 (
96  surfaceFilmModel& owner,
97  const dictionary& dict
98 )
99 :
100  force(typeName, owner, dict),
101  Ccf_(readScalar(coeffDict_.lookup("Ccf"))),
102  rndGen_(label(0), -1),
103  distribution_
104  (
106  (
107  coeffDict_.subDict("contactAngleDistribution"),
108  rndGen_
109  )
110  ),
111  mask_
112  (
113  IOobject
114  (
115  typeName + ":contactForceMask",
116  owner_.time().timeName(),
117  owner_.regionMesh(),
120  ),
121  owner_.regionMesh(),
122  dimensionedScalar("mask", dimless, 1.0)
123  )
124 {
125  initialise();
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
130 
132 {}
133 
134 
135 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
136 
138 {
139  tmp<volVectorField> tForce
140  (
141  new volVectorField
142  (
143  IOobject
144  (
145  typeName + ":contactForce",
146  owner_.time().timeName(),
147  owner_.regionMesh(),
150  ),
151  owner_.regionMesh(),
153  )
154  );
155 
156  vectorField& force = tForce().internalField();
157 
158  const labelUList& own = owner_.regionMesh().owner();
159  const labelUList& nbr = owner_.regionMesh().neighbour();
160 
161  const scalarField& magSf = owner_.magSf();
162 
163  const volScalarField& alpha = owner_.alpha();
164  const volScalarField& sigma = owner_.sigma();
165 
166  volVectorField gradAlpha(fvc::grad(alpha));
167 
168  forAll(nbr, faceI)
169  {
170  const label cellO = own[faceI];
171  const label cellN = nbr[faceI];
172 
173  label cellI = -1;
174  if ((alpha[cellO] > 0.5) && (alpha[cellN] < 0.5))
175  {
176  cellI = cellO;
177  }
178  else if ((alpha[cellO] < 0.5) && (alpha[cellN] > 0.5))
179  {
180  cellI = cellN;
181  }
182 
183  if (cellI != -1 && mask_[cellI] > 0.5)
184  {
185  const scalar invDx = owner_.regionMesh().deltaCoeffs()[faceI];
186  const vector n =
187  gradAlpha[cellI]/(mag(gradAlpha[cellI]) + ROOTVSMALL);
188  scalar theta = cos(degToRad(distribution_->sample()));
189  force[cellI] += Ccf_*n*sigma[cellI]*(1.0 - theta)/invDx;
190  }
191  }
192 
193  forAll(alpha.boundaryField(), patchI)
194  {
195  if (!owner().isCoupledPatch(patchI))
196  {
197  const fvPatchField<scalar>& alphaf = alpha.boundaryField()[patchI];
198  const fvPatchField<scalar>& maskf = mask_.boundaryField()[patchI];
199  const scalarField& invDx = alphaf.patch().deltaCoeffs();
200  const labelUList& faceCells = alphaf.patch().faceCells();
201 
202  forAll(alphaf, faceI)
203  {
204  if (maskf[faceI] > 0.5)
205  {
206  label cellO = faceCells[faceI];
207 
208  if ((alpha[cellO] > 0.5) && (alphaf[faceI] < 0.5))
209  {
210  const vector n =
211  gradAlpha[cellO]
212  /(mag(gradAlpha[cellO]) + ROOTVSMALL);
213  scalar theta = cos(degToRad(distribution_->sample()));
214  force[cellO] +=
215  Ccf_*n*sigma[cellO]*(1.0 - theta)/invDx[faceI];
216  }
217  }
218  }
219  }
220  }
221 
222  force /= magSf;
223 
224  if (owner_.regionMesh().time().outputTime())
225  {
226  tForce().write();
227  }
228 
231 
232  tfvm() += tForce;
233 
234  return tfvm;
235 }
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace surfaceFilmModels
241 } // End namespace regionModels
242 } // End namespace Foam
243 
244 // ************************************************************************* //
Foam::fvPatchField< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmModel::sigma
virtual const volScalarField & sigma() const =0
Return the film surface tension [N/m].
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::regionModels::surfaceFilmModels::contactAngleForce::mask_
volScalarField mask_
Mask over which force is applied.
Definition: contactAngleForce.H:75
Foam::TimeState::outputTime
bool outputTime() const
Return true if this is an output time (primary or secondary)
Definition: TimeState.C:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::regionModels::surfaceFilmModels::contactAngleForce::contactAngleForce
contactAngleForce(const contactAngleForce &)
Disallow default bitwise copy construct.
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::regionModels::surfaceFilmModels::contactAngleForce::Ccf_
scalar Ccf_
Coefficient applied to the contact angle force.
Definition: contactAngleForce.H:66
Foam::regionModels::surfaceFilmModels::contactAngleForce::initialise
void initialise()
Initialise.
Definition: contactAngleForce.C:49
Foam::subModelBase::coeffDict_
const dictionary coeffDict_
Coefficients dictionary.
Definition: subModelBase.H:79
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::regionModels::regionModel::time
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:37
unitConversion.H
Unit conversion functions.
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::distributionModels::distributionModel::New
static autoPtr< distributionModel > New(const dictionary &dict, cachedRandom &rndGen)
Selector.
Definition: distributionModelNew.C:32
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
Foam::regionModels::surfaceFilmModels::filmSubModelBase::owner
const surfaceFilmModel & owner() const
Return const access to the owner surface film model.
Definition: filmSubModelBaseI.H:37
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::regionModels::surfaceFilmModels::contactAngleForce::distribution_
const autoPtr< distributionModels::distributionModel > distribution_
Parcel size PDF model.
Definition: contactAngleForce.H:72
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::dimForce
const dimensionSet dimForce
Foam::surfaceInterpolation::deltaCoeffs
const surfaceScalarField & deltaCoeffs() const
Return reference to cell-centre difference coefficients.
Definition: surfaceInterpolation.C:89
Foam::HashSet< label, Hash< label > >
Foam::regionModels::surfaceFilmModels::contactAngleForce::correct
virtual tmp< fvVectorMatrix > correct(volVectorField &U)
Correct.
Definition: contactAngleForce.C:137
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
U
U
Definition: pEqn.H:46
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::fvVectorMatrix
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::Info
messageStream Info
Foam::regionModels::singleLayerRegion::magSf
virtual const volScalarField & magSf() const
Return the face area magnitudes / [m2].
Definition: singleLayerRegion.C:220
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
meshWavePatchDistMethod.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fvMesh::neighbour
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:288
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fvMesh::owner
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
Foam::regionModels::surfaceFilmModels::defineTypeNameAndDebug
defineTypeNameAndDebug(kinematicSingleLayer, 0)
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::Vector< scalar >
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::regionModels::surfaceFilmModels::force
Base class for film (stress-based) force models.
Definition: force.H:55
fvcGrad.H
Calculate the gradient of the given field.
Foam::fvPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Return the face - cell distance coeffient.
Definition: fvPatch.C:164
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::patchDistMethods::meshWave::correct
virtual bool correct(volScalarField &y)
Correct the given distance-to-patch field.
Definition: meshWavePatchDistMethod.C:76
Foam::regionModels::surfaceFilmModels::filmSubModelBase::owner_
surfaceFilmModel & owner_
Reference to the owner surface film model.
Definition: filmSubModelBase.H:63
Foam::regionModels::surfaceFilmModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(surfaceFilmModel, kinematicSingleLayer, mesh)
Foam::constant::physicoChemical::sigma
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
Foam::fvPatch::faceCells
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:93
contactAngleForce.H
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
Foam::fvPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:300
Foam::regionModels::surfaceFilmModels::surfaceFilmModel
Base class for surface film models.
Definition: surfaceFilmModel.H:61
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::polyBoundaryMesh::patchSet
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
Definition: polyBoundaryMesh.C:750
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
Foam::patchDistMethods::meshWave
Fast topological mesh-wave method for calculating the distance to nearest patch for all cells and bou...
Definition: meshWavePatchDistMethod.H:73
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::regionModels::surfaceFilmModels::contactAngleForce::~contactAngleForce
virtual ~contactAngleForce()
Destructor.
Definition: contactAngleForce.C:131
Foam::regionModels::surfaceFilmModels::surfaceFilmModel::alpha
virtual const volScalarField & alpha() const =0
Return the film coverage, 1 = covered, 0 = uncovered / [].
y
scalar y
Definition: LISASMDCalcMethod1.H:14
contactAngleForce
Film contact angle force.
fvPatchField.H
Foam::degToRad
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Definition: unitConversion.H:45
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256
Foam::regionModels::regionModel::regionMesh
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190