Commit dfd611ae authored by Henry Weller's avatar Henry Weller
Browse files

surfaceTensionModels: New class hierarchy for run-time selectable surface tension models

These models have been particularly designed for use in the VoF solvers, both
incompressible and compressible.  Currently constant and temperature dependent
surface tension models are provided but it easy to write models in which the
surface tension is evaluated from any fields held by the mesh database.
parent 982300f0
......@@ -360,4 +360,17 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureThermo::alphaEff
}
bool Foam::twoPhaseMixtureThermo::read()
{
if (psiThermo::read())
{
return interfaceProperties::read();
}
else
{
return false;
}
}
// ************************************************************************* //
......@@ -285,6 +285,12 @@ public:
const scalarField& alphat,
const label patchi
) const;
// IO
//- Read base transportProperties dictionary
virtual bool read();
};
......
......@@ -162,7 +162,7 @@ public:
friend Ostream& operator<< <Type>
(
Ostream& os,
const Function1<Type>& de
const Function1<Type>& func
);
//- Write in dictionary format
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -40,4 +40,14 @@ immiscibleIncompressibleTwoPhaseMixture
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::immiscibleIncompressibleTwoPhaseMixture::read()
{
return
incompressibleTwoPhaseMixture::read()
&& interfaceProperties::read();
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -80,12 +80,7 @@ public:
}
//- Read base transportProperties dictionary
virtual bool read()
{
return
incompressibleTwoPhaseMixture::read()
&& interfaceProperties::read();
}
virtual bool read();
};
......
interfaceProperties.C
interfaceCompression/interfaceCompression.C
surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.C
surfaceTensionModels/surfaceTensionModel/newSurfaceTensionModel.C
surfaceTensionModels/constant/constantSurfaceTension.C
surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.C
LIB = $(FOAM_LIBBIN)/libinterfaceProperties
......@@ -167,7 +167,8 @@ Foam::interfaceProperties::interfaceProperties
alpha1.mesh().solverDict(alpha1.name()).lookup("cAlpha")
)
),
sigma_("sigma", dimensionSet(1, 0, -2, 0, 0), dict),
sigmaPtr_(surfaceTensionModel::New(dict, alpha1.mesh())),
deltaN_
(
......@@ -208,6 +209,13 @@ Foam::interfaceProperties::interfaceProperties
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::interfaceProperties::sigmaK() const
{
return sigmaPtr_->sigma()*K_;
}
Foam::tmp<Foam::surfaceScalarField>
Foam::interfaceProperties::surfaceTensionForce() const
{
......@@ -231,7 +239,7 @@ void Foam::interfaceProperties::correct()
bool Foam::interfaceProperties::read()
{
alpha1_.mesh().solverDict(alpha1_.name()).lookup("cAlpha") >> cAlpha_;
transportPropertiesDict_.lookup("sigma") >> sigma_;
sigmaPtr_->read(transportPropertiesDict_);
return true;
}
......
......@@ -40,6 +40,7 @@ SourceFiles
#define interfaceProperties_H
#include "IOdictionary.H"
#include "surfaceTensionModel.H"
#include "volFields.H"
#include "surfaceFields.H"
......@@ -63,7 +64,7 @@ class interfaceProperties
scalar cAlpha_;
//- Surface tension
dimensionedScalar sigma_;
autoPtr<surfaceTensionModel> sigmaPtr_;
//- Stabilisation for normalisation of the interface normal
const dimensionedScalar deltaN_;
......@@ -127,10 +128,7 @@ public:
return nHatf_;
}
tmp<volScalarField> sigmaK() const
{
return sigma_*K_;
}
tmp<volScalarField> sigmaK() const;
tmp<surfaceScalarField> surfaceTensionForce() const;
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "constantSurfaceTension.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceTensionModels
{
defineTypeNameAndDebug(constant, 0);
addToRunTimeSelectionTable(surfaceTensionModel, constant, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceTensionModels::constant::constant
(
const dictionary& dict,
const fvMesh& mesh
)
:
surfaceTensionModel(mesh),
sigma_("sigma", dimensionSet(1, 0, -2, 0, 0), dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceTensionModels::constant::~constant()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField>
Foam::surfaceTensionModels::constant::sigma() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"sigma",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
sigma_
)
);
}
bool Foam::surfaceTensionModels::constant::read(const dictionary& dict)
{
// Handle sub-dictionary format as a special case
if (dict.isDict("sigma"))
{
dict.subDict("sigma").lookup("sigma") >> sigma_;
}
else
{
dict.lookup("sigma") >> sigma_;
}
return true;
}
bool Foam::surfaceTensionModels::constant::writeData(Ostream& os) const
{
if (surfaceTensionModel::writeData(os))
{
os << sigma_ << token::END_STATEMENT << nl;
return os.good();
}
else
{
return false;
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceTensionModels::constant
Description
Uniform constant surface tension model.
Usage
Example of the surface tension specification:
\verbatim
sigma
{
type constant;
sigma 0.07;
}
\endverbatim
See also
Foam::surfaceTensionModel
SourceFiles
constantSurfaceTension.C
\*---------------------------------------------------------------------------*/
#ifndef constantSurfaceTension_H
#define constantSurfaceTension_H
#include "surfaceTensionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceTensionModels
{
/*---------------------------------------------------------------------------*\
Class constant Declaration
\*---------------------------------------------------------------------------*/
class constant
:
public surfaceTensionModel
{
// Private data
//- Surface tension coefficient
dimensionedScalar sigma_;
public:
//- Runtime type information
TypeName("constant");
// Constructors
//- Construct from dictionary and mesh
constant
(
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~constant();
// Member Functions
//- Surface tension coefficient
virtual tmp<volScalarField> sigma() const;
//- Update surface tension coefficient from given dictionary
virtual bool read(const dictionary& dict);
//- Write in dictionary format
virtual bool writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceTensionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "surfaceTensionModel.H"
#include "constantSurfaceTension.H"
// * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceTensionModel> Foam::surfaceTensionModel::New
(
const dictionary& dict,
const fvMesh& mesh
)
{
if (dict.isDict("sigma"))
{
const dictionary& sigmaDict = surfaceTensionModel::sigmaDict(dict);
word surfaceTensionModelType(sigmaDict.lookup("type"));
Info<< "Selecting surfaceTensionModel "
<< surfaceTensionModelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(surfaceTensionModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown surfaceTensionModelType type "
<< surfaceTensionModelType << endl << endl
<< "Valid surfaceTensionModel types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return cstrIter()(sigmaDict, mesh);
}
else
{
return autoPtr<surfaceTensionModel>
(
new surfaceTensionModels::constant(dict, mesh)
);
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "surfaceTensionModel.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfaceTensionModel, 0);
defineRunTimeSelectionTable(surfaceTensionModel, dictionary);
}
const Foam::dimensionSet Foam::surfaceTensionModel::dimSigma(1, 0, -2, 0, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceTensionModel::surfaceTensionModel(const fvMesh& mesh)
:
regIOobject
(
IOobject
(
typeName, mesh.name(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
)
),
mesh_(mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceTensionModel::~surfaceTensionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::surfaceTensionModel::writeData(Ostream& os) const
{
return os.good();
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceTensionModel
Description
Abstract base-class for surface tension models which return the surface
tension coefficient field.
Usage
Example of the surface tension specification:
\verbatim
sigma
{
type <surface tension model type>;
<coefficient name> <coefficient value>;
.
.
.