mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
porousZone : use new dictionary lookup methods
This commit is contained in:
@ -32,15 +32,28 @@ License
|
|||||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// adjust negative resistance values to be multiplier of max value
|
// adjust negative resistance values to be multiplier of max value
|
||||||
void Foam::porousZone::adjustNegativeResistance(vector& resist)
|
void Foam::porousZone::adjustNegativeResistance(dimensionedVector& resist)
|
||||||
{
|
{
|
||||||
scalar maxCmpt = max(0, cmptMax(resist));
|
scalar maxCmpt = max(0, cmptMax(resist.value()));
|
||||||
|
|
||||||
for (label cmpt=0; cmpt < vector::nComponents; ++cmpt)
|
if (maxCmpt < 0)
|
||||||
{
|
{
|
||||||
if (resist[cmpt] < 0)
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::porousZone::porousZone::adjustNegativeResistance"
|
||||||
|
"(dimensionedVector&)"
|
||||||
|
) << "negative resistances! " << resist
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vector& val = resist.value();
|
||||||
|
for (label cmpt=0; cmpt < vector::nComponents; ++cmpt)
|
||||||
{
|
{
|
||||||
resist[cmpt] *= -maxCmpt;
|
if (val[cmpt] < 0)
|
||||||
|
{
|
||||||
|
val[cmpt] *= -maxCmpt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,24 +84,20 @@ Foam::porousZone::porousZone
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::porousZone::porousZone"
|
"Foam::porousZone::porousZone"
|
||||||
"(const fvMesh&, const Istream&)"
|
"(const fvMesh&, const word&, const dictionary&)"
|
||||||
) << "cannot find porous cellZone " << name_
|
) << "cannot find porous cellZone " << name_
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// local-to-global transformation tensor
|
|
||||||
const tensor& E = coordSys_.R();
|
|
||||||
|
|
||||||
// porosity
|
// porosity
|
||||||
if (dict_.found("porosity"))
|
if (dict_.readIfPresent("porosity", porosity_))
|
||||||
{
|
{
|
||||||
dict_.lookup("porosity") >> porosity_;
|
|
||||||
|
|
||||||
if (porosity_ <= 0.0 || porosity_ > 1.0)
|
if (porosity_ <= 0.0 || porosity_ > 1.0)
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
|
"Foam::porousZone::porousZone"
|
||||||
|
"(const fvMesh&, const word&, const dictionary&)",
|
||||||
dict_
|
dict_
|
||||||
)
|
)
|
||||||
<< "out-of-range porosity value " << porosity_
|
<< "out-of-range porosity value " << porosity_
|
||||||
@ -97,73 +106,64 @@ Foam::porousZone::porousZone
|
|||||||
}
|
}
|
||||||
|
|
||||||
// powerLaw coefficients
|
// powerLaw coefficients
|
||||||
if (dict_.found("powerLaw"))
|
if (const dictionary* dictPtr = dict_.subDictPtr("powerLaw"))
|
||||||
{
|
{
|
||||||
const dictionary& subDict = dict_.subDict("powerLaw");
|
dictPtr->readIfPresent("C0", C0_);
|
||||||
if (subDict.found("C0"))
|
dictPtr->readIfPresent("C1", C1_);
|
||||||
{
|
|
||||||
subDict.lookup("C0") >> C0_;
|
|
||||||
}
|
|
||||||
if (subDict.found("C1"))
|
|
||||||
{
|
|
||||||
subDict.lookup("C1") >> C1_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Darcy-Forchheimer coefficients
|
// Darcy-Forchheimer coefficients
|
||||||
if (dict_.found("Darcy"))
|
if (const dictionary* dictPtr = dict_.subDictPtr("Darcy"))
|
||||||
{
|
{
|
||||||
const dictionary& subDict = dict_.subDict("Darcy");
|
// local-to-global transformation tensor
|
||||||
|
const tensor& E = coordSys_.R();
|
||||||
|
|
||||||
dimensionedVector d("d", D_.dimensions(), vector::zero);
|
dimensionedVector d(vector::zero);
|
||||||
dimensionedVector f("f", F_.dimensions(), vector::zero);
|
if (dictPtr->readIfPresent("d", d))
|
||||||
|
|
||||||
if (subDict.found("d"))
|
|
||||||
{
|
{
|
||||||
// d = dimensionedVector("d", subDict.lookup("d"));
|
if (D_.dimensions() != d.dimensions())
|
||||||
subDict.lookup("d") >> d;
|
{
|
||||||
adjustNegativeResistance(d.value());
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"Foam::porousZone::porousZone"
|
||||||
|
"(const fvMesh&, const word&, const dictionary&)",
|
||||||
|
dict_
|
||||||
|
) << "incorrect dimensions for d: " << d.dimensions()
|
||||||
|
<< " should be " << D_.dimensions()
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
adjustNegativeResistance(d);
|
||||||
if (subDict.found("f"))
|
|
||||||
{
|
D_.value().xx() = d.value().x();
|
||||||
// f = dimensionedVector("f", subDict.lookup("f"));
|
D_.value().yy() = d.value().y();
|
||||||
subDict.lookup("f") >> f;
|
D_.value().zz() = d.value().z();
|
||||||
adjustNegativeResistance(f.value());
|
D_.value() = (E & D_ & E.T()).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (D_.dimensions() != d.dimensions())
|
dimensionedVector f(vector::zero);
|
||||||
|
if (dictPtr->readIfPresent("f", f))
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
if (F_.dimensions() != f.dimensions())
|
||||||
(
|
{
|
||||||
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
|
FatalIOErrorIn
|
||||||
dict_
|
(
|
||||||
) << "incorrect dimensions for d: " << d.dimensions()
|
"Foam::porousZone::porousZone"
|
||||||
<< " should be " << D_.dimensions()
|
"(const fvMesh&, const word&, const dictionary&)",
|
||||||
<< exit(FatalIOError);
|
dict_
|
||||||
|
) << "incorrect dimensions for f: " << f.dimensions()
|
||||||
|
<< " should be " << F_.dimensions()
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustNegativeResistance(f);
|
||||||
|
|
||||||
|
// leading 0.5 is from 1/2 * rho
|
||||||
|
F_.value().xx() = 0.5*f.value().x();
|
||||||
|
F_.value().yy() = 0.5*f.value().y();
|
||||||
|
F_.value().zz() = 0.5*f.value().z();
|
||||||
|
F_.value() = (E & F_ & E.T()).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (F_.dimensions() != f.dimensions())
|
|
||||||
{
|
|
||||||
FatalIOErrorIn
|
|
||||||
(
|
|
||||||
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
|
|
||||||
dict_
|
|
||||||
) << "incorrect dimensions for f: " << f.dimensions()
|
|
||||||
<< " should be " << F_.dimensions()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
D_.value().xx() = d.value().x();
|
|
||||||
D_.value().yy() = d.value().y();
|
|
||||||
D_.value().zz() = d.value().z();
|
|
||||||
D_.value() = (E & D_ & E.T()).value();
|
|
||||||
|
|
||||||
// leading 0.5 is from 1/2 * rho
|
|
||||||
F_.value().xx() = 0.5*f.value().x();
|
|
||||||
F_.value().yy() = 0.5*f.value().y();
|
|
||||||
F_.value().zz() = 0.5*f.value().z();
|
|
||||||
F_.value() = (E & F_ & E.T()).value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// provide some feedback for the user
|
// provide some feedback for the user
|
||||||
@ -179,7 +179,8 @@ Foam::porousZone::porousZone
|
|||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
|
"Foam::porousZone::porousZone"
|
||||||
|
"(const fvMesh&, const word&, const dictionary&)",
|
||||||
dict_
|
dict_
|
||||||
) << "neither powerLaw (C0/C1) "
|
) << "neither powerLaw (C0/C1) "
|
||||||
"nor Darcy-Forchheimer law (d/f) specified"
|
"nor Darcy-Forchheimer law (d/f) specified"
|
||||||
|
|||||||
@ -128,7 +128,7 @@ class porousZone
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- adjust negative resistance values to be multiplier of max value
|
//- adjust negative resistance values to be multiplier of max value
|
||||||
static void adjustNegativeResistance(vector& resist);
|
static void adjustNegativeResistance(dimensionedVector& resist);
|
||||||
|
|
||||||
//- Power-law resistance
|
//- Power-law resistance
|
||||||
template<class RhoFieldType>
|
template<class RhoFieldType>
|
||||||
|
|||||||
Reference in New Issue
Block a user