ENH: twoPhaseEulerFoam: made blending methods multiphase, and associated them with model types

This commit is contained in:
william
2014-01-24 09:09:51 +00:00
parent 87115af2d0
commit 2843ceff2f
13 changed files with 250 additions and 205 deletions

View File

@ -57,7 +57,7 @@ template<class modelType>
Foam::BlendedInterfacialModel<modelType>::BlendedInterfacialModel
(
const phasePair::dictTable& modelTable,
const dictionary& blendingDict,
const blendingMethod& blending,
const phasePair& pair,
const orderedPhasePair& pair1In2,
const orderedPhasePair& pair2In1
@ -66,21 +66,7 @@ Foam::BlendedInterfacialModel<modelType>::BlendedInterfacialModel
pair_(pair),
pair1In2_(pair1In2),
pair2In1_(pair2In1),
blending_
(
blendingMethod::New
(
blendingDict,
pair1In2_.dispersed(),
pair1In2_.continuous()
)
),
residualAlpha_
(
"residualAlpha",
dimless,
blendingDict.lookup("residualAlpha")
)
blending_(blending)
{
if (modelTable.found(pair_))
{
@ -137,12 +123,12 @@ Foam::BlendedInterfacialModel<modelType>::K() const
if (model_.valid() || model1In2_.valid())
{
f1 = blending_->f1();
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
}
if (model_.valid() || model2In1_.valid())
{
f2 = blending_->f2();
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
}
tmp<volScalarField> x
@ -177,7 +163,7 @@ Foam::BlendedInterfacialModel<modelType>::K() const
if (model_.valid() || model1In2_.valid() || model2In1_.valid())
{
x() *= max(pair_.phase1()*pair_.phase2(), residualAlpha_);
x() *= max(pair_.phase1()*pair_.phase2(), blending_.residualAlpha());
correctFixedFluxBCs(x());
}
@ -195,12 +181,12 @@ Foam::BlendedInterfacialModel<modelType>::F() const
if (model_.valid() || model1In2_.valid())
{
f1 = blending_->f1();
f1 = blending_.f1(pair1In2_.dispersed(), pair2In1_.dispersed());
}
if (model_.valid() || model2In1_.valid())
{
f2 = blending_->f2();
f2 = blending_.f2(pair1In2_.dispersed(), pair2In1_.dispersed());
}
tmp<GeometricField<Type, fvPatchField, volMesh> > x

View File

@ -75,10 +75,7 @@ private:
autoPtr<modelType> model2In1_;
//- Blending model
autoPtr<blendingMethod> blending_;
//- Residual phase fraction
const dimensionedScalar residualAlpha_;
const blendingMethod& blending_;
// Private Member Functions
@ -105,7 +102,7 @@ public:
BlendedInterfacialModel
(
const phasePair::dictTable& modelTable,
const dictionary& blendingDict,
const blendingMethod& blending,
const phasePair& pair,
const orderedPhasePair& pair1In2,
const orderedPhasePair& pair2In1

View File

@ -38,13 +38,10 @@ namespace Foam
Foam::blendingMethod::blendingMethod
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const dictionary& dict
)
:
phase1_(phase1),
phase2_(phase2)
residualAlpha_("residualAlpha", dimless, dict.lookup("residualAlpha"))
{}
@ -54,4 +51,12 @@ Foam::blendingMethod::~blendingMethod()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::dimensionedScalar& Foam::blendingMethod::residualAlpha() const
{
return residualAlpha_;
}
// ************************************************************************* //

View File

@ -49,24 +49,12 @@ namespace Foam
class blendingMethod
{
// Private Member Functions
//- Disallow default bitwise copy construct
blendingMethod(const blendingMethod&);
//- Disallow default bitwise assignment
void operator=(const blendingMethod&);
protected:
// Protected data
//- Phase 1
const phaseModel& phase1_;
//- Phase 2
const phaseModel& phase2_;
//- Residual phase fraction
const dimensionedScalar residualAlpha_;
public:
@ -83,21 +71,18 @@ public:
dictionary,
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
),
(dict, phase1, phase2)
(dict, phaseNames)
);
// Constructors
//- Construct from a dictionary and two phases
//- Construct from a dictionary
blendingMethod
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const dictionary& dict
);
@ -106,8 +91,7 @@ public:
static autoPtr<blendingMethod> New
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
);
@ -117,11 +101,22 @@ public:
// Member Functions
//- Residual phase fraction
const dimensionedScalar& residualAlpha() const;
//- Factor for first phase
virtual tmp<volScalarField> f1() const = 0;
virtual tmp<volScalarField> f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const = 0;
//- Factor for second phase
virtual tmp<volScalarField> f2() const = 0;
virtual tmp<volScalarField> f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const = 0;
};

View File

@ -30,14 +30,12 @@ License
Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
)
{
word blendingMethodType(dict.lookup("type"));
Info<< "Selecting blendingMethod for "
<< phase1.name() << " and " << phase2.name() << ": "
Info<< "Selecting " << dict.dictName() << " blending method: "
<< blendingMethodType << endl;
dictionaryConstructorTable::iterator cstrIter =
@ -53,7 +51,7 @@ Foam::autoPtr<Foam::blendingMethod> Foam::blendingMethod::New
<< exit(FatalError);
}
return cstrIter()(dict, phase1, phase2);
return cstrIter()(dict, phaseNames);
}

View File

@ -48,36 +48,33 @@ namespace blendingMethods
Foam::blendingMethods::hyperbolic::hyperbolic
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
)
:
blendingMethod(dict, phase1, phase2),
maxDispersedAlpha1_
(
"maxDispersedAlpha1",
dimless,
dict.lookup
(
IOobject::groupName("maxDispersedAlpha", phase1.name())
)
),
maxDispersedAlpha2_
(
"maxDispersedAlpha2",
dimless,
dict.lookup
(
IOobject::groupName("maxDispersedAlpha", phase2.name())
)
),
blendingMethod(dict),
transitionAlphaScale_
(
"transitionAlphaScale",
dimless,
dict.lookup("transitionAlphaScale")
)
{}
{
forAllConstIter(wordList, phaseNames, iter)
{
const word name(IOobject::groupName("maxDispersedAlpha", *iter));
maxDispersedAlpha_.insert
(
*iter,
dimensionedScalar
(
name,
dimless,
dict.lookup(name)
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -88,7 +85,11 @@ Foam::blendingMethods::hyperbolic::~hyperbolic()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::hyperbolic::f1() const
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::hyperbolic::f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const
{
return
(
@ -96,13 +97,17 @@ Foam::tmp<Foam::volScalarField> Foam::blendingMethods::hyperbolic::f1() const
+ tanh
(
(4/transitionAlphaScale_)
*(phase1_ - maxDispersedAlpha1_)
*(phase1 - maxDispersedAlpha_[phase1.name()])
)
)/2;
}
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::hyperbolic::f2() const
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::hyperbolic::f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const
{
return
(
@ -110,7 +115,7 @@ Foam::tmp<Foam::volScalarField> Foam::blendingMethods::hyperbolic::f2() const
+ tanh
(
(4/transitionAlphaScale_)
*(maxDispersedAlpha2_ - phase2_)
*(maxDispersedAlpha_[phase2.name()] - phase2)
)
)/2;
}

View File

@ -53,11 +53,8 @@ class hyperbolic
{
// Private data
//- Maximum fraction of phase 1 which can be considered dispersed
const dimensionedScalar maxDispersedAlpha1_;
//- Maximum fraction of phase 2 which can be considered dispersed
const dimensionedScalar maxDispersedAlpha2_;
//- Maximum fraction of phases which can be considered dispersed
HashTable<dimensionedScalar, word, word::hash> maxDispersedAlpha_;
//- Width of the transition
const dimensionedScalar transitionAlphaScale_;
@ -71,12 +68,11 @@ public:
// Constructors
//- Construct from a dictionary and two phases
//- Construct from a dictionary and a list of phase names
hyperbolic
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
);
@ -86,11 +82,19 @@ public:
// Member Functions
//- Factor for primary phase
virtual tmp<volScalarField> f1() const;
//- Factor for first phase
virtual tmp<volScalarField> f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const;
//- Factor for secondary phase
virtual tmp<volScalarField> f2() const;
//- Factor for second phase
virtual tmp<volScalarField> f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const;
};

View File

@ -48,65 +48,63 @@ namespace blendingMethods
Foam::blendingMethods::linear::linear
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
)
:
blendingMethod(dict, phase1, phase2),
maxFullyDispersedAlpha1_
(
"maxFullyDispersedAlpha1",
dimless,
dict.lookup
(
IOobject::groupName("maxFullyDispersedAlpha", phase1.name())
)
),
maxPartlyDispersedAlpha1_
(
"maxPartlyDispersedAlpha1",
dimless,
dict.lookup
(
IOobject::groupName("maxPartlyDispersedAlpha", phase1.name())
)
),
maxFullyDispersedAlpha2_
(
"maxFullyDispersedAlpha2",
dimless,
dict.lookup
(
IOobject::groupName("maxFullyDispersedAlpha", phase2.name())
)
),
maxPartlyDispersedAlpha2_
(
"maxPartlyDispersedAlpha2",
dimless,
dict.lookup
(
IOobject::groupName("maxPartlyDispersedAlpha", phase2.name())
)
)
blendingMethod(dict)
{
if
(
maxFullyDispersedAlpha1_ > maxPartlyDispersedAlpha1_
|| maxFullyDispersedAlpha2_ > maxPartlyDispersedAlpha2_
)
forAllConstIter(wordList, phaseNames, iter)
{
FatalErrorIn
const word nameFull
(
"Foam::blendingMethods::linear::linear"
"("
"const dictionary& dict,"
"const phaseModel& phase1,"
"const phaseModel& phase2"
")"
) << "The supplied fully dispersed volume fraction is greater than "
<< "the partly dispersed value"
<< endl << exit(FatalError);
IOobject::groupName("maxFullyDispersedAlpha", *iter)
);
maxFullyDispersedAlpha_.insert
(
*iter,
dimensionedScalar
(
nameFull,
dimless,
dict.lookup(nameFull)
)
);
const word namePart
(
IOobject::groupName("maxPartlyDispersedAlpha", *iter)
);
maxPartlyDispersedAlpha_.insert
(
*iter,
dimensionedScalar
(
namePart,
dimless,
dict.lookup(namePart)
)
);
if
(
maxFullyDispersedAlpha_[*iter]
> maxPartlyDispersedAlpha_[*iter]
)
{
FatalErrorIn
(
"Foam::blendingMethods::linear::linear"
"("
"const dictionary& dict,"
"const wordList& phaseNames"
")"
) << "The supplied fully dispersed volume fraction for "
<< *iter
<< " is greater than the partly dispersed value."
<< endl << exit(FatalError);
}
}
}
@ -119,15 +117,24 @@ Foam::blendingMethods::linear::~linear()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::linear::f1() const
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::linear::f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const
{
const dimensionedScalar
maxFullAlpha(maxFullyDispersedAlpha_[phase1.name()]);
const dimensionedScalar
maxPartAlpha(maxPartlyDispersedAlpha_[phase1.name()]);
return
min
(
max
(
(phase1_ - maxFullyDispersedAlpha1_)
/(maxPartlyDispersedAlpha1_ - maxFullyDispersedAlpha1_ + SMALL),
(phase1 - maxFullAlpha)
/(maxPartAlpha - maxFullAlpha + SMALL),
0.0
),
1.0
@ -135,15 +142,24 @@ Foam::tmp<Foam::volScalarField> Foam::blendingMethods::linear::f1() const
}
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::linear::f2() const
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::linear::f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const
{
const dimensionedScalar
maxFullAlpha(maxFullyDispersedAlpha_[phase2.name()]);
const dimensionedScalar
maxPartAlpha(maxPartlyDispersedAlpha_[phase2.name()]);
return
min
(
max
(
(maxPartlyDispersedAlpha2_ - phase2_)
/(maxPartlyDispersedAlpha2_ - maxFullyDispersedAlpha2_ + SMALL),
(maxPartAlpha - phase2)
/(maxPartAlpha - maxFullAlpha + SMALL),
0.0
),
1.0

View File

@ -53,17 +53,13 @@ class linear
{
// Private data
//- Max fraction of phase 1 which can be considered fully dispersed
const dimensionedScalar maxFullyDispersedAlpha1_;
//- Maximum fraction of phases which can be considered fully dispersed
HashTable<dimensionedScalar, word, word::hash>
maxFullyDispersedAlpha_;
//- Max fraction of phase 1 which can be considered partly dispersed
const dimensionedScalar maxPartlyDispersedAlpha1_;
//- Max fraction of phase 2 which can be considered fully dispersed
const dimensionedScalar maxFullyDispersedAlpha2_;
//- Max fraction of phase 2 which can be considered partly dispersed
const dimensionedScalar maxPartlyDispersedAlpha2_;
//- Maximum fraction of phases which can be considered partly dispersed
HashTable<dimensionedScalar, word, word::hash>
maxPartlyDispersedAlpha_;
public:
@ -78,8 +74,7 @@ public:
linear
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
);
@ -90,10 +85,18 @@ public:
// Member Functions
//- Factor for primary phase
virtual tmp<volScalarField> f1() const;
virtual tmp<volScalarField> f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const;
//- Factor for secondary phase
virtual tmp<volScalarField> f2() const;
virtual tmp<volScalarField> f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const;
};

View File

@ -48,11 +48,10 @@ namespace blendingMethods
Foam::blendingMethods::noBlending::noBlending
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
)
:
blendingMethod(dict, phase1, phase2),
blendingMethod(dict),
continuousPhase_(dict.lookup("continuousPhase"))
{}
@ -65,9 +64,13 @@ Foam::blendingMethods::noBlending::~noBlending()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::noBlending::f1() const
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::noBlending::f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const
{
const fvMesh& mesh(phase1_.mesh());
const fvMesh& mesh(phase1.mesh());
return
tmp<volScalarField>
@ -85,16 +88,20 @@ Foam::tmp<Foam::volScalarField> Foam::blendingMethods::noBlending::f1() const
(
"f",
dimless,
phase1_.name() == continuousPhase_
phase1.name() == continuousPhase_
)
)
);
}
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::noBlending::f2() const
Foam::tmp<Foam::volScalarField> Foam::blendingMethods::noBlending::f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const
{
return f1();
return f1(phase1, phase2);
}

View File

@ -69,8 +69,7 @@ public:
noBlending
(
const dictionary& dict,
const phaseModel& phase1,
const phaseModel& phase2
const wordList& phaseNames
);
@ -81,10 +80,18 @@ public:
// Member Functions
//- Factor for primary phase
virtual tmp<volScalarField> f1() const;
virtual tmp<volScalarField> f1
(
const phaseModel& phase1,
const phaseModel& phase2
) const;
//- Factor for secondary phase
virtual tmp<volScalarField> f2() const;
virtual tmp<volScalarField> f2
(
const phaseModel& phase1,
const phaseModel& phase2
) const;
};

View File

@ -46,6 +46,9 @@ License
#include "fvmLaplacian.H"
#include "fixedValueFvsPatchFields.H"
#include "blendingMethod.H"
#include "HashPtrTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::twoPhaseSystem::twoPhaseSystem
@ -120,6 +123,23 @@ Foam::twoPhaseSystem::twoPhaseSystem
phase2_.volScalarField::operator=(scalar(1) - phase1_);
// Blending
// ~~~~~~~~
forAllConstIter(dictionary, subDict("blending"), iter)
{
blendingMethods_.insert
(
iter().dict().dictName(),
blendingMethod::New
(
iter().dict(),
wordList(lookup("phases"))
)
);
}
// Pairs
// ~~~~~
@ -165,17 +185,15 @@ Foam::twoPhaseSystem::twoPhaseSystem
// Models
// ~~~~~~
const dictionary& blendingDict(subDict("blending"));
drag_.set
(
new BlendedInterfacialModel<dragModel>
(
lookup("drag"),
(
blendingDict.isDict("drag")
? blendingDict.subDict("drag")
: blendingDict.subDict("default")
blendingMethods_.found("drag")
? blendingMethods_["drag"]
: blendingMethods_["default"]
),
pair_,
pair1In2_,
@ -189,9 +207,9 @@ Foam::twoPhaseSystem::twoPhaseSystem
(
lookup("virtualMass"),
(
blendingDict.isDict("virtualMass")
? blendingDict.subDict("virtualMass")
: blendingDict.subDict("default")
blendingMethods_.found("virtualMass")
? blendingMethods_["virtualMass"]
: blendingMethods_["default"]
),
pair_,
pair1In2_,
@ -205,9 +223,9 @@ Foam::twoPhaseSystem::twoPhaseSystem
(
lookup("heatTransfer"),
(
blendingDict.isDict("heatTransfer")
? blendingDict.subDict("heatTransfer")
: blendingDict.subDict("default")
blendingMethods_.found("heatTransfer")
? blendingMethods_["heatTransfer"]
: blendingMethods_["default"]
),
pair_,
pair1In2_,
@ -221,9 +239,9 @@ Foam::twoPhaseSystem::twoPhaseSystem
(
lookup("lift"),
(
blendingDict.isDict("lift")
? blendingDict.subDict("lift")
: blendingDict.subDict("default")
blendingMethods_.found("lift")
? blendingMethods_["lift"]
: blendingMethods_["default"]
),
pair_,
pair1In2_,
@ -237,9 +255,9 @@ Foam::twoPhaseSystem::twoPhaseSystem
(
lookup("wallLubrication"),
(
blendingDict.isDict("wallLubrication")
? blendingDict.subDict("wallLubrication")
: blendingDict.subDict("default")
blendingMethods_.found("wallLubrication")
? blendingMethods_["wallLubrication"]
: blendingMethods_["default"]
),
pair_,
pair1In2_,
@ -253,9 +271,9 @@ Foam::twoPhaseSystem::twoPhaseSystem
(
lookup("turbulentDispersion"),
(
blendingDict.isDict("turbulentDispersion")
? blendingDict.subDict("turbulentDispersion")
: blendingDict.subDict("default")
blendingMethods_.found("turbulentDispersion")
? blendingMethods_["turbulentDispersion"]
: blendingMethods_["default"]
),
pair_,
pair1In2_,

View File

@ -53,6 +53,7 @@ class liftModel;
class wallLubricationModel;
class turbulentDispersionModel;
class blendingMethod;
template <class modelType> class BlendedInterfacialModel;
/*---------------------------------------------------------------------------*\
@ -94,6 +95,9 @@ private:
//- Phase pair for phase 2 dispersed in phase 1
autoPtr<orderedPhasePair> pair2In1_;
//- Blending methods
HashTable<autoPtr<blendingMethod>, word, word::hash> blendingMethods_;
//- Drag model
autoPtr<BlendedInterfacialModel<dragModel> > drag_;