porousZone : use new dictionary lookup methods

This commit is contained in:
Mark Olesen
2008-06-23 10:15:17 +02:00
parent b6279461fb
commit 0462cfedd5
2 changed files with 71 additions and 70 deletions

View File

@ -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()));
if (maxCmpt < 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) for (label cmpt=0; cmpt < vector::nComponents; ++cmpt)
{ {
if (resist[cmpt] < 0) if (val[cmpt] < 0)
{ {
resist[cmpt] *= -maxCmpt; 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,67 +106,57 @@ 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"));
subDict.lookup("d") >> d;
adjustNegativeResistance(d.value());
}
if (subDict.found("f"))
{
// f = dimensionedVector("f", subDict.lookup("f"));
subDict.lookup("f") >> f;
adjustNegativeResistance(f.value());
}
if (D_.dimensions() != d.dimensions()) if (D_.dimensions() != d.dimensions())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)", "Foam::porousZone::porousZone"
"(const fvMesh&, const word&, const dictionary&)",
dict_ dict_
) << "incorrect dimensions for d: " << d.dimensions() ) << "incorrect dimensions for d: " << d.dimensions()
<< " should be " << D_.dimensions() << " should be " << D_.dimensions()
<< exit(FatalIOError); << exit(FatalIOError);
} }
adjustNegativeResistance(d);
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();
}
dimensionedVector f(vector::zero);
if (dictPtr->readIfPresent("f", f))
{
if (F_.dimensions() != f.dimensions()) if (F_.dimensions() != f.dimensions())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)", "Foam::porousZone::porousZone"
"(const fvMesh&, const word&, const dictionary&)",
dict_ dict_
) << "incorrect dimensions for f: " << f.dimensions() ) << "incorrect dimensions for f: " << f.dimensions()
<< " should be " << F_.dimensions() << " should be " << F_.dimensions()
<< exit(FatalIOError); << exit(FatalIOError);
} }
D_.value().xx() = d.value().x(); adjustNegativeResistance(f);
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 // leading 0.5 is from 1/2 * rho
F_.value().xx() = 0.5*f.value().x(); F_.value().xx() = 0.5*f.value().x();
@ -165,6 +164,7 @@ Foam::porousZone::porousZone
F_.value().zz() = 0.5*f.value().z(); F_.value().zz() = 0.5*f.value().z();
F_.value() = (E & F_ & E.T()).value(); F_.value() = (E & F_ & E.T()).value();
} }
}
// provide some feedback for the user // provide some feedback for the user
// writeDict(Info, false); // writeDict(Info, false);
@ -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"

View File

@ -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>