Commit 2843ceff authored by william's avatar william
Browse files

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

parent 87115af2
......@@ -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
......
......@@ -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
......
......@@ -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_;
}
// ************************************************************************* //
......@@ -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;
};
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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;
};
......
......@@ -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
blendingMethod(dict)
{
forAllConstIter(wordList, phaseNames, iter)
{
const word nameFull
(
IOobject::groupName("maxFullyDispersedAlpha", phase1.name())
)
),
maxPartlyDispersedAlpha1_
(
"maxPartlyDispersedAlpha1",
dimless,
dict.lookup
IOobject::groupName("maxFullyDispersedAlpha", *iter)
);
maxFullyDispersedAlpha_.insert
(
IOobject::groupName("maxPartlyDispersedAlpha", phase1.name())
)
),
maxFullyDispersedAlpha2_
(
"maxFullyDispersedAlpha2",
dimless,
dict.lookup
*iter,
dimensionedScalar
(
nameFull,
dimless,
dict.lookup(nameFull)
)
);
const word namePart
(
IOobject::groupName("maxFullyDispersedAlpha", phase2.name())
)
),
maxPartlyDispersedAlpha2_
(
"maxPartlyDispersedAlpha2",
dimless,
dict.lookup
IOobject::groupName("maxPartlyDispersedAlpha", *iter)
);
maxPartlyDispersedAlpha_.insert
(
IOobject::groupName("maxPartlyDispersedAlpha", phase2.name())
)
)
{
if
(
maxFullyDispersedAlpha1_ > maxPartlyDispersedAlpha1_
|| maxFullyDispersedAlpha2_ > maxPartlyDispersedAlpha2_
)
{
FatalErrorIn
*iter,
dimensionedScalar
(
namePart,
dimless,
dict.lookup(namePart)
)
);
if
(
"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);
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
......
......@@ -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