ENH: orientedFields - refectored and simplified usage

This commit is contained in:
Andrew Heather
2017-05-24 12:26:12 +01:00
parent ff132ff5f6
commit b5ed93a40a
34 changed files with 370 additions and 281 deletions

View File

@ -120,13 +120,14 @@ int main(int argc, char *argv[])
"cSf_pos", "cSf_pos",
interpolate(c, pos, T.name())*mesh.magSf() interpolate(c, pos, T.name())*mesh.magSf()
); );
cSf_pos.oriented().oriented() = true; cSf_pos.setOriented();
surfaceScalarField cSf_neg surfaceScalarField cSf_neg
( (
"cSf_neg", "cSf_neg",
interpolate(c, neg, T.name())*mesh.magSf() interpolate(c, neg, T.name())*mesh.magSf()
); );
cSf_neg.oriented().oriented() = true; cSf_neg.setOriented();
surfaceScalarField ap surfaceScalarField ap
( (

View File

@ -101,13 +101,14 @@ int main(int argc, char *argv[])
"cSf_pos", "cSf_pos",
interpolate(c, pos, T.name())*mesh.magSf() interpolate(c, pos, T.name())*mesh.magSf()
); );
cSf_pos.oriented().oriented() = true; cSf_pos.setOriented();
surfaceScalarField cSf_neg surfaceScalarField cSf_neg
( (
"cSf_neg", "cSf_neg",
interpolate(c, neg, T.name())*mesh.magSf() interpolate(c, neg, T.name())*mesh.magSf()
); );
cSf_neg.oriented().oriented() = true; cSf_neg.setOriented();
surfaceScalarField ap surfaceScalarField ap
( (

View File

@ -13,8 +13,6 @@ if (nAlphaSubCycles > 1)
dimensionedScalar("0", rhoPhi.dimensions(), 0) dimensionedScalar("0", rhoPhi.dimensions(), 0)
); );
rhoPhiSum.oriented().oriented() = true;
for for
( (
subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles); subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);

View File

@ -21,8 +21,6 @@
dimensionedScalar("0", rhoPhi.dimensions(), 0) dimensionedScalar("0", rhoPhi.dimensions(), 0)
); );
rhoPhiSum.oriented().oriented() = true;
for for
( (
subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles); subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles);

View File

@ -113,8 +113,7 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
1e-8/pow(average(mesh_.V()), 1.0/3.0) 1e-8/pow(average(mesh_.V()), 1.0/3.0)
) )
{ {
rhoPhi_.oriented().oriented() = true; rhoPhi_.setOriented();
calcAlphas(); calcAlphas();
alphas_.write(); alphas_.write();
correct(); correct();
@ -700,7 +699,7 @@ Foam::multiphaseMixtureThermo::surfaceTensionForce() const
); );
surfaceScalarField& stf = tstf.ref(); surfaceScalarField& stf = tstf.ref();
stf.oriented().oriented() = true; stf.setOriented();
forAllConstIter(PtrDictionary<phaseModel>, phases_, phase1) forAllConstIter(PtrDictionary<phaseModel>, phases_, phase1)
{ {

View File

@ -104,7 +104,6 @@ int main(int argc, char *argv[])
mesh, mesh,
dimensionedScalar("0", dimMass/dimTime, 0) dimensionedScalar("0", dimMass/dimTime, 0)
); );
rhoPhi.oriented().oriented() = true;
mixture->correct(); mixture->correct();

View File

@ -13,8 +13,6 @@ if (nAlphaSubCycles > 1)
dimensionedScalar("0", rhoPhi.dimensions(), 0) dimensionedScalar("0", rhoPhi.dimensions(), 0)
); );
rhoPhiSum.oriented().oriented() = true;
tmp<volScalarField> trSubDeltaT; tmp<volScalarField> trSubDeltaT;
if (LTS) if (LTS)

View File

@ -12,7 +12,6 @@ if (nAlphaSubCycles > 1)
mesh, mesh,
dimensionedScalar("0", rhoPhi.dimensions(), 0) dimensionedScalar("0", rhoPhi.dimensions(), 0)
); );
rhoPhiSum.oriented().oriented() = true;
for for
( (

View File

@ -100,8 +100,6 @@ int main(int argc, char *argv[])
mesh, mesh,
dimensionedScalar("0", dimMass/dimTime, 0) dimensionedScalar("0", dimMass/dimTime, 0)
); );
rhoPhi.oriented().oriented() = true;
mixture->correct(); mixture->correct();

View File

@ -39,7 +39,6 @@ surfaceScalarField phi
mesh, mesh,
dimensionedScalar("phi", dimArea*dimVelocity, 0) dimensionedScalar("phi", dimArea*dimVelocity, 0)
); );
phi.oriented().oriented() = true;
multiphaseSystem fluid(U, phi); multiphaseSystem fluid(U, phi);

View File

@ -815,8 +815,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension
) )
) )
); );
tSurfaceTension.ref().setOriented();
tSurfaceTension.ref().oriented().oriented() = true;
forAllConstIter(PtrDictionary<phaseModel>, phases_, iter) forAllConstIter(PtrDictionary<phaseModel>, phases_, iter)
{ {
@ -920,8 +919,6 @@ void Foam::multiphaseSystem::solve()
) )
); );
alphaPhiSums[phasei].oriented().oriented() = true;
phasei++; phasei++;
} }

View File

@ -113,7 +113,7 @@ Foam::phaseModel::phaseModel
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0) dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
) )
{ {
alphaPhi_.oriented().oriented() = true; alphaPhi_.setOriented();
const word phiName = IOobject::groupName("phi", name_); const word phiName = IOobject::groupName("phi", name_);

View File

@ -57,7 +57,6 @@
mesh, mesh,
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0) dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
); );
phiHbyA.oriented().oriented() = true;
volScalarField rho("rho", fluid.rho()); volScalarField rho("rho", fluid.rho());
surfaceScalarField ghSnGradRho(ghf*fvc::snGrad(rho)*mesh.magSf()); surfaceScalarField ghSnGradRho(ghf*fvc::snGrad(rho)*mesh.magSf());

View File

@ -128,7 +128,7 @@ Foam::multiphaseMixture::multiphaseMixture
1e-8/pow(average(mesh_.V()), 1.0/3.0) 1e-8/pow(average(mesh_.V()), 1.0/3.0)
) )
{ {
rhoPhi_.oriented().oriented() = true; rhoPhi_.setOriented();
calcAlphas(); calcAlphas();
alphas_.write(); alphas_.write();
@ -275,7 +275,7 @@ Foam::multiphaseMixture::surfaceTensionForce() const
); );
surfaceScalarField& stf = tstf.ref(); surfaceScalarField& stf = tstf.ref();
stf.oriented().oriented() = true; stf.setOriented();
forAllConstIter(PtrDictionary<phase>, phases_, iter1) forAllConstIter(PtrDictionary<phase>, phases_, iter1)
{ {
@ -338,8 +338,6 @@ void Foam::multiphaseMixture::solve()
dimensionedScalar("0", rhoPhi_.dimensions(), 0) dimensionedScalar("0", rhoPhi_.dimensions(), 0)
); );
rhoPhiSum.oriented().oriented() = true;
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
for for

View File

@ -455,8 +455,7 @@ Foam::BlendedInterfacialModel<ModelType>::Ff() const
dimensionedScalar("zero", ModelType::dimF*dimArea, 0) dimensionedScalar("zero", ModelType::dimF*dimArea, 0)
) )
); );
x.ref().setOriented();
x.ref().oriented().oriented() = true;
if (model_.valid()) if (model_.valid())
{ {

View File

@ -365,7 +365,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::Ff
) )
); );
tFf.ref().oriented().oriented() = true; tFf.ref().setOriented();
return tFf; return tFf;
} }
@ -626,7 +626,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::setPhiD
) )
); );
phiDs[phasei].oriented().oriented() = true; phiDs[phasei].setOriented();
} }
return phiDs[phasei]; return phiDs[phasei];

View File

@ -200,8 +200,8 @@ Foam::MovingPhaseModel<BasePhaseModel>::MovingPhaseModel
dimensionedScalar("0", dimDensity/dimTime, 0) dimensionedScalar("0", dimDensity/dimTime, 0)
) )
{ {
alphaPhi_.oriented().oriented() = true; alphaPhi_.setOriented();
alphaRhoPhi_.oriented().oriented() = true; alphaRhoPhi_.setOriented();
phi_.writeOpt() = IOobject::AUTO_WRITE; phi_.writeOpt() = IOobject::AUTO_WRITE;
correctKinematics(); correctKinematics();

View File

@ -558,7 +558,7 @@ Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseSystem::surfaceTension
) )
); );
tSurfaceTension.ref().oriented().oriented() = true; tSurfaceTension.ref().setOriented();
forAll(phases(), phasej) forAll(phases(), phasej)
{ {
@ -665,8 +665,6 @@ void Foam::multiphaseSystem::solve()
dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0) dimensionedScalar("0", dimensionSet(0, 3, -1, 0, 0), 0)
) )
); );
alphaPhiSums[phasei].oriented().oriented() = true;
} }
for for

View File

@ -169,8 +169,6 @@ while (pimple.correct())
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0) dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
); );
phiHbyA.oriented().oriented() = true;
forAll(phases, phasei) forAll(phases, phasei)
{ {
phaseModel& phase = phases[phasei]; phaseModel& phase = phases[phasei];

View File

@ -14,7 +14,6 @@ if (nAlphaSubCycles > 1)
mesh, mesh,
dimensionedScalar("0", rhoPhi.dimensions(), 0) dimensionedScalar("0", rhoPhi.dimensions(), 0)
); );
rhoPhiSum.oriented().oriented() = true;
for for
( (

View File

@ -109,8 +109,8 @@ Foam::phaseModel::phaseModel
dimensionedScalar("0", dimensionSet(1, 0, -1, 0, 0), 0) dimensionedScalar("0", dimensionSet(1, 0, -1, 0, 0), 0)
) )
{ {
alphaPhi_.oriented().oriented() = true; alphaPhi_.setOriented();
alphaRhoPhi_.oriented().oriented() = true; alphaRhoPhi_.setOriented();
thermo_->validate("phaseModel " + name_, "h", "e"); thermo_->validate("phaseModel " + name_, "h", "e");

View File

@ -60,7 +60,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField
Field<Type>(field), Field<Type>(field),
mesh_(mesh), mesh_(mesh),
dimensions_(dims), dimensions_(dims),
oriented_(false) oriented_()
{ {
if (field.size() && field.size() != GeoMesh::size(mesh)) if (field.size() && field.size() != GeoMesh::size(mesh))
{ {
@ -86,7 +86,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField
Field<Type>(GeoMesh::size(mesh)), Field<Type>(GeoMesh::size(mesh)),
mesh_(mesh), mesh_(mesh),
dimensions_(dims), dimensions_(dims),
oriented_(false) oriented_()
{ {
if (checkIOFlags) if (checkIOFlags)
{ {
@ -108,7 +108,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField
Field<Type>(GeoMesh::size(mesh), dt.value()), Field<Type>(GeoMesh::size(mesh), dt.value()),
mesh_(mesh), mesh_(mesh),
dimensions_(dt.dimensions()), dimensions_(dt.dimensions()),
oriented_(false) oriented_()
{ {
if (checkIOFlags) if (checkIOFlags)
{ {

View File

@ -266,12 +266,15 @@ public:
//- Return non-const access to dimensions //- Return non-const access to dimensions
inline dimensionSet& dimensions(); inline dimensionSet& dimensions();
//- Return oriented flag //- Return oriented type
inline const orientedType& oriented() const; inline const orientedType& oriented() const;
//- Return non-const access to the oriented flag //- Return non-const access to the oriented type
inline orientedType& oriented(); inline orientedType& oriented();
//- Set the oriented flag
inline void setOriented(const bool oriented = true);
inline const Field<Type>& field() const; inline const Field<Type>& field() const;
inline Field<Type>& field(); inline Field<Type>& field();

View File

@ -71,6 +71,16 @@ inline Foam::orientedType& Foam::DimensionedField<Type, GeoMesh>::oriented()
} }
template<class Type, class GeoMesh>
inline void Foam::DimensionedField<Type, GeoMesh>::setOriented
(
const bool oriented
)
{
oriented_.setOriented(oriented);
}
template<class Type, class GeoMesh> template<class Type, class GeoMesh>
inline const Foam::Field<Type>& inline const Foam::Field<Type>&
Foam::DimensionedField<Type, GeoMesh>::field() const Foam::DimensionedField<Type, GeoMesh>::field() const

View File

@ -37,7 +37,7 @@ void Foam::DimensionedField<Type, GeoMesh>::readField
) )
{ {
dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions"))); dimensions_.reset(dimensionSet(fieldDict.lookup("dimensions")));
fieldDict.template readIfPresent<bool>("oriented", oriented_.oriented()); oriented_.read(fieldDict);
Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_)); Field<Type> f(fieldDictEntry, fieldDict, GeoMesh::size(mesh_));
this->transfer(f); this->transfer(f);
@ -76,7 +76,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
Field<Type>(0), Field<Type>(0),
mesh_(mesh), mesh_(mesh),
dimensions_(dimless), dimensions_(dimless),
oriented_(false) oriented_()
{ {
readField(dictionary(readStream(typeName)), fieldDictEntry); readField(dictionary(readStream(typeName)), fieldDictEntry);
} }
@ -95,7 +95,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
Field<Type>(0), Field<Type>(0),
mesh_(mesh), mesh_(mesh),
dimensions_(dimless), dimensions_(dimless),
oriented_(false) oriented_()
{ {
readField(fieldDict, fieldDictEntry); readField(fieldDict, fieldDictEntry);
} }
@ -111,7 +111,7 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData
) const ) const
{ {
os.writeEntry("dimensions", dimensions()); os.writeEntry("dimensions", dimensions());
if (oriented_.oriented()) os.writeEntry("oriented", oriented()); oriented_.writeEntry(os);
os<< nl << nl; os<< nl << nl;

View File

@ -25,29 +25,72 @@ License
#include "orientedType.H" #include "orientedType.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* NamedEnum
<
orientedType::orientedOption,
3
>::names[] =
{
"oriented",
"unoriented",
"unknown"
};
}
const Foam::NamedEnum<Foam::orientedType::orientedOption, 3>
Foam::orientedType::orientedOptionNames;
bool Foam::orientedType::checkType
(
const orientedType& ot1,
const orientedType& ot2
)
{
if
(
(ot1.oriented() == UNKNOWN)
|| (ot2.oriented() == UNKNOWN)
|| (ot1.oriented() == ot2.oriented())
)
{
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::orientedType::orientedType() Foam::orientedType::orientedType()
: :
oriented_(false) oriented_(UNKNOWN)
{} {}
Foam::orientedType::orientedType(const orientedType& of) Foam::orientedType::orientedType(const orientedType& ot)
: :
oriented_(of.oriented_) oriented_(ot.oriented_)
{} {}
Foam::orientedType::orientedType(const bool oriented) Foam::orientedType::orientedType(const bool oriented)
: :
oriented_(oriented) oriented_(oriented ? ORIENTED : UNORIENTED)
{} {}
Foam::orientedType::orientedType(Istream& is) Foam::orientedType::orientedType(Istream& is)
: :
oriented_(readBool(is)) oriented_(orientedOptionNames.read(is))
{ {
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
} }
@ -55,312 +98,339 @@ Foam::orientedType::orientedType(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool& Foam::orientedType::oriented() Foam::orientedType::orientedOption& Foam::orientedType::oriented()
{ {
return oriented_; return oriented_;
} }
bool Foam::orientedType::oriented() const Foam::orientedType::orientedOption Foam::orientedType::oriented() const
{ {
return oriented_; return oriented_;
} }
void Foam::orientedType::setOriented(const bool oriented)
{
oriented_ = oriented ? ORIENTED : UNORIENTED;
}
void Foam::orientedType::read(const dictionary& dict)
{
if (dict.found("oriented"))
{
oriented_ = orientedOptionNames.read(dict.lookup("oriented"));
}
else
{
oriented_ = UNKNOWN;
}
}
void Foam::orientedType::writeEntry(Ostream& os) const
{
if (oriented_ == ORIENTED)
{
os.writeEntry("oriented", orientedOptionNames[oriented_]);
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::orientedType::operator=(const orientedType& of) void Foam::orientedType::operator=(const orientedType& ot)
{ {
oriented_ = of.oriented(); // Oriented state is inherited on assignment
oriented_ = ot.oriented();
} }
void Foam::orientedType::operator+=(const orientedType& of) void Foam::orientedType::operator+=(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; // Set the oriented status if it was unknown
if (oriented_ != of.oriented()) if (oriented_ == UNKNOWN)
{ {
FatalErrorInFunction oriented_ = ot.oriented();
<< "Operator += is undefined for oriented and unoriented types. "
<< "oriented:" << oriented_ << ", of:" << of.oriented()
<< abort(FatalError);
} }
// No change to oriented_ flag if (!checkType(*this, ot))
}
void Foam::orientedType::operator-=(const orientedType& of)
{
//InfoInFunction << "of:" << of.oriented() << endl;
if (oriented_ != of.oriented())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Operator -= is undefined for oriented and unoriented types. " << "Operator += is undefined for "
<< "oriented:" << oriented_ << ", of:" << of.oriented() << orientedOptionNames[oriented_] << " and "
<< orientedOptionNames[ot.oriented()] << " types"
<< abort(FatalError); << abort(FatalError);
} }
// No change to oriented_ flag
} }
void Foam::orientedType::operator*=(const orientedType& of) void Foam::orientedType::operator-=(const orientedType& ot)
{ {
oriented_ = oriented_ ^ of.oriented(); // Set the oriented status if it was unknown
if (oriented_ == UNKNOWN)
{
oriented_ = ot.oriented();
}
if (!checkType(*this, ot))
{
FatalErrorInFunction
<< "Operator -= is undefined for "
<< orientedOptionNames[oriented_] << " and "
<< orientedOptionNames[ot.oriented()] << " types"
<< abort(FatalError);
}
} }
void Foam::orientedType::operator/=(const orientedType& of) void Foam::orientedType::operator*=(const orientedType& ot)
{ {
oriented_ = oriented_ ^ of.oriented(); const orientedType& ot1 = *this;
if (ot1() ^ ot())
{
oriented_ = ORIENTED;
}
else
{
oriented_ = UNORIENTED;
}
}
void Foam::orientedType::operator/=(const orientedType& ot)
{
const orientedType& ot1 = *this;
if (ot1() ^ ot())
{
oriented_ = ORIENTED;
}
else
{
oriented_ = UNORIENTED;
}
} }
void Foam::orientedType::operator*=(const scalar s) void Foam::orientedType::operator*=(const scalar s)
{ {
//InfoInFunction << "oriented_: " << oriented_ << endl;
// No change to oriented_ flag // No change to oriented_ flag
} }
void Foam::orientedType::operator/=(const scalar s) void Foam::orientedType::operator/=(const scalar s)
{ {
//InfoInFunction << "oriented_: " << oriented_ << endl;
// No change to oriented_ flag // No change to oriented_ flag
} }
bool Foam::orientedType::operator()() const bool Foam::orientedType::operator()() const
{ {
//InfoInFunction << "oriented_: " << oriented_ << endl; return oriented_ == ORIENTED;
return oriented_;
} }
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
Foam::orientedType Foam::max(const orientedType& of1, const orientedType& of2) Foam::orientedType Foam::max(const orientedType& ot1, const orientedType& ot2)
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; if (!orientedType::checkType(ot1, ot2))
if (of1.oriented() != of2.oriented())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "max is undefined for oriented and unoriented types. " << "Operator max is undefined for "
<< "of1:" << of1.oriented() << ", of2:" << of2.oriented() << orientedType::orientedOptionNames[ot1.oriented()] << " and "
<< orientedType::orientedOptionNames[ot2.oriented()] << " types"
<< abort(FatalError); << abort(FatalError);
} }
return of1; return ot1;
} }
Foam::orientedType Foam::min(const orientedType& of1, const orientedType& of2) Foam::orientedType Foam::min(const orientedType& ot1, const orientedType& ot2)
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; if (!orientedType::checkType(ot1, ot2))
if (of1.oriented() != of2.oriented())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "min is undefined for oriented and unoriented types. " << "Operator min is undefined for "
<< "of1:" << of1.oriented() << ", of2:" << of2.oriented() << orientedType::orientedOptionNames[ot1.oriented()] << " and "
<< orientedType::orientedOptionNames[ot2.oriented()] << "types"
<< abort(FatalError); << abort(FatalError);
} }
return of1; return ot1;
} }
Foam::orientedType Foam::cmptMultiply Foam::orientedType Foam::cmptMultiply
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; return ot1 ^ ot2;
return orientedType(of1.oriented() ^ of2.oriented());
} }
Foam::orientedType Foam::cmptDivide Foam::orientedType Foam::cmptDivide
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; return ot1 ^ ot2;
return orientedType(of1.oriented() ^ of2.oriented());
} }
Foam::orientedType Foam::cmptAv(const orientedType& of) Foam::orientedType Foam::cmptAv(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::pow(const orientedType& of, const scalar r) Foam::orientedType Foam::pow(const orientedType& ot, const scalar r)
{ {
//InfoInFunction << "of:" << of.oriented() << endl;
// Undefined??? // Undefined???
// - only defined for integers where: // - only defined for integers where:
// - odd powers = oriented_ = yes (if of is oriented) // - odd powers = oriented_ = yes (if ot is oriented)
// - even powers = oriented_ = no // - even powers = oriented_ = no
return of; return ot;
} }
Foam::orientedType Foam::sqr(const orientedType& of) Foam::orientedType Foam::sqr(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl;
return orientedType(false); return orientedType(false);
} }
Foam::orientedType Foam::pow3(const orientedType& of) Foam::orientedType Foam::pow3(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return orientedType(of.oriented());
} }
Foam::orientedType Foam::pow4(const orientedType& of) Foam::orientedType Foam::pow4(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl;
return orientedType(false); return orientedType(false);
} }
Foam::orientedType Foam::pow5(const orientedType& of) Foam::orientedType Foam::pow5(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return orientedType(of.oriented());
} }
Foam::orientedType Foam::pow6(const orientedType& of) Foam::orientedType Foam::pow6(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl;
return orientedType(false); return orientedType(false);
} }
Foam::orientedType Foam::pow025(const orientedType& of) Foam::orientedType Foam::pow025(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return orientedType(of.oriented());
} }
Foam::orientedType Foam::sqrt(const orientedType& of) Foam::orientedType Foam::sqrt(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::cbrt(const orientedType& of) Foam::orientedType Foam::cbrt(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::magSqr(const orientedType& of) Foam::orientedType Foam::magSqr(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl;
return orientedType(false); return orientedType(false);
} }
Foam::orientedType Foam::mag(const orientedType& of) Foam::orientedType Foam::mag(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl;
return orientedType(false); return orientedType(false);
} }
Foam::orientedType Foam::sign(const orientedType& of) Foam::orientedType Foam::sign(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::pos(const orientedType& of) Foam::orientedType Foam::pos(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::neg(const orientedType& of) Foam::orientedType Foam::neg(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::posPart(const orientedType& of) Foam::orientedType Foam::posPart(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::negPart(const orientedType& of) Foam::orientedType Foam::negPart(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::inv(const orientedType& of) Foam::orientedType Foam::inv(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::trans(const orientedType& of) Foam::orientedType Foam::trans(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
Foam::orientedType Foam::atan2 Foam::orientedType Foam::atan2
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; if (!orientedType::checkType(ot1, ot2))
if (of1.oriented() != of2.oriented())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "atan2 is undefined for oriented and unoriented types. " << "Operator atan2 is undefined for "
<< "of1:" << of1.oriented() << ", of2:" << of2.oriented() << orientedType::orientedOptionNames[ot1.oriented()] << " and "
<< orientedType::orientedOptionNames[ot2.oriented()] << "types"
<< abort(FatalError); << abort(FatalError);
} }
return of1; return ot1;
} }
Foam::orientedType Foam::transform(const orientedType& of) Foam::orientedType Foam::transform(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return of;
} }
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, orientedType& of) Foam::Istream& Foam::operator>>(Istream& is, orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; ot.oriented_ = orientedType::orientedOptionNames.read(is);
is >> of.oriented_;
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
@ -368,10 +438,9 @@ Foam::Istream& Foam::operator>>(Istream& is, orientedType& of)
} }
Foam::Ostream& Foam::operator<<(Ostream& os, const orientedType& of) Foam::Ostream& Foam::operator<<(Ostream& os, const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; os << orientedType::orientedOptionNames[ot.oriented()];
os << of.oriented();
os.check(FUNCTION_NAME); os.check(FUNCTION_NAME);
@ -383,114 +452,109 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const orientedType& of)
Foam::orientedType Foam::operator+ Foam::orientedType Foam::operator+
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; if (!orientedType::checkType(ot1, ot2))
if (of1.oriented() != of2.oriented())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Operator + is undefined for oriented and unoriented types. " << "Operator + is undefined for "
<< "of1:" << of1.oriented() << ", of2:" << of2.oriented() << orientedType::orientedOptionNames[ot1.oriented()] << " and "
<< orientedType::orientedOptionNames[ot2.oriented()] << " types"
<< abort(FatalError); << abort(FatalError);
} }
return orientedType(of1.oriented() || of2.oriented()); // Note use of () operators to convert to boolean op
return orientedType(ot1() || ot2());
} }
Foam::orientedType Foam::operator-(const orientedType& of) Foam::orientedType Foam::operator-(const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return orientedType(of);
} }
Foam::orientedType Foam::operator- Foam::orientedType Foam::operator-
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; if (!orientedType::checkType(ot1, ot2))
if (of1.oriented() != of2.oriented())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Operator - is undefined for oriented and unoriented types. " << "Operator - is undefined for "
<< "of1:" << of1.oriented() << ", of2:" << of2.oriented() << orientedType::orientedOptionNames[ot1.oriented()] << " and "
<< orientedType::orientedOptionNames[ot2.oriented()] << " types"
<< abort(FatalError); << abort(FatalError);
} }
return orientedType(of1.oriented() || of2.oriented()); // Note use of () operators to convert to boolean op
return orientedType(ot1() || ot2());
} }
Foam::orientedType Foam::operator*(const scalar s, const orientedType& of) Foam::orientedType Foam::operator*(const scalar s, const orientedType& ot)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return orientedType(of);
} }
Foam::orientedType Foam::operator/(const orientedType& of, const scalar s) Foam::orientedType Foam::operator/(const orientedType& ot, const scalar s)
{ {
//InfoInFunction << "of:" << of.oriented() << endl; return ot;
return orientedType(of);
} }
Foam::orientedType Foam::operator/ Foam::orientedType Foam::operator/
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; return ot1 ^ ot2;
return orientedType(of1.oriented() ^ of2.oriented());
} }
Foam::orientedType Foam::operator* Foam::orientedType Foam::operator*
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; return ot1 ^ ot2;
return orientedType(of1.oriented() ^ of2.oriented());
} }
Foam::orientedType Foam::operator^ Foam::orientedType Foam::operator^
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; // Note use of () operators to convert to boolean op
return orientedType(of1.oriented() ^ of2.oriented()); return orientedType(ot1() ^ ot2());
} }
Foam::orientedType Foam::operator& Foam::orientedType Foam::operator&
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl; return ot1 ^ ot2;
return orientedType(of1.oriented() ^ of2.oriented());
} }
Foam::orientedType Foam::operator&& Foam::orientedType Foam::operator&&
( (
const orientedType& of1, const orientedType& ot1,
const orientedType& of2 const orientedType& ot2
) )
{ {
//InfoInFunction << "of1:" << of1.oriented() << ", of2:" << of2.oriented() << endl;
return orientedType(false); return orientedType(false);
} }

View File

@ -37,6 +37,8 @@ SourceFiles
#include "Istream.H" #include "Istream.H"
#include "Ostream.H" #include "Ostream.H"
#include "dictionary.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,27 +54,43 @@ Istream& operator>>(Istream&, orientedType&);
Ostream& operator<<(Ostream&, const orientedType&); Ostream& operator<<(Ostream&, const orientedType&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class dimensioned Declaration Class orientedType Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class orientedType class orientedType
{ {
public:
// Public data types
//- Enumeration defining the valid oriented flags
enum orientedOption
{
ORIENTED,
UNORIENTED,
UNKNOWN
};
static const NamedEnum<orientedOption, 3> orientedOptionNames;
private:
// Private data // Private data
//- Oriented flag //- Oriented flag
bool oriented_; orientedOption oriented_;
public: public:
// Constructors // Constructors
//- Null constructor - flag initialised to false //- Null constructor - flag initialised to false
orientedType(); orientedType();
//- Copy constructor //- Copy constructor
orientedType(const orientedType& of); orientedType(const orientedType& ot);
//- Construct from bool //- Construct from bool
orientedType(const bool oriented); orientedType(const bool oriented);
@ -83,21 +101,37 @@ public:
// Member functions // Member functions
//- Return true if can operate on this pair of oriented types
static bool checkType
(
const orientedType& ot1,
const orientedType& ot2
);
//- Return non-const reference to the oriented flag //- Return non-const reference to the oriented flag
bool& oriented(); orientedOption& oriented();
//- Return const reference to the oriented flag //- Return const reference to the oriented flag
bool oriented() const; orientedOption oriented() const;
//- Set the oriented flag
void setOriented(const bool oriented = true);
//- Read the oriented state from dictionary
void read(const dictionary& dict);
//- Write the oriented flag entry
void writeEntry(Ostream& os) const;
// Member operators // Member operators
void operator=(const orientedType& of); void operator=(const orientedType& ot);
void operator+=(const orientedType& of); void operator+=(const orientedType& ot);
void operator-=(const orientedType& of); void operator-=(const orientedType& ot);
void operator*=(const orientedType& of); void operator*=(const orientedType& ot);
void operator/=(const orientedType& of); void operator/=(const orientedType& ot);
void operator*=(const scalar s); void operator*=(const scalar s);
void operator/=(const scalar s); void operator/=(const scalar s);
bool operator()() const; bool operator()() const;
@ -105,57 +139,57 @@ public:
// IOstream operators // IOstream operators
friend Istream& operator>>(Istream& is, orientedType& of); friend Istream& operator>>(Istream& is, orientedType& ot);
friend Ostream& operator<<(Ostream& os, const orientedType& of); friend Ostream& operator<<(Ostream& os, const orientedType& ot);
}; };
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
orientedType max(const orientedType& of1, const orientedType& of2); orientedType max(const orientedType& ot1, const orientedType& ot2);
orientedType min(const orientedType& of1, const orientedType& of2); orientedType min(const orientedType& ot1, const orientedType& ot2);
orientedType cmptMultiply(const orientedType& of1, const orientedType& of2); orientedType cmptMultiply(const orientedType& ot1, const orientedType& ot2);
orientedType cmptDivide(const orientedType& of1, const orientedType& of); orientedType cmptDivide(const orientedType& ot1, const orientedType& ot);
orientedType cmptAv(const orientedType& of); orientedType cmptAv(const orientedType& ot);
orientedType pow(const orientedType& of, const scalar r); orientedType pow(const orientedType& ot, const scalar r);
orientedType sqr(const orientedType& of); orientedType sqr(const orientedType& ot);
orientedType pow3(const orientedType& of); orientedType pow3(const orientedType& ot);
orientedType pow4(const orientedType& of); orientedType pow4(const orientedType& ot);
orientedType pow5(const orientedType& of); orientedType pow5(const orientedType& ot);
orientedType pow6(const orientedType& of); orientedType pow6(const orientedType& ot);
orientedType pow025(const orientedType& of); orientedType pow025(const orientedType& ot);
orientedType sqrt(const orientedType& of); orientedType sqrt(const orientedType& ot);
orientedType cbrt(const orientedType& of); orientedType cbrt(const orientedType& ot);
orientedType magSqr(const orientedType& of); orientedType magSqr(const orientedType& ot);
orientedType mag(const orientedType& of); orientedType mag(const orientedType& ot);
orientedType sign(const orientedType& of); orientedType sign(const orientedType& ot);
orientedType pos(const orientedType& of); orientedType pos(const orientedType& ot);
orientedType neg(const orientedType& of); orientedType neg(const orientedType& ot);
orientedType posPart(const orientedType& of); orientedType posPart(const orientedType& ot);
orientedType negPart(const orientedType& of); orientedType negPart(const orientedType& ot);
orientedType inv(const orientedType& of); orientedType inv(const orientedType& ot);
orientedType trans(const orientedType& of); orientedType trans(const orientedType& ot);
orientedType atan2(const orientedType& of1, const orientedType& of2); orientedType atan2(const orientedType& ot1, const orientedType& ot2);
orientedType transform(const orientedType& of); orientedType transform(const orientedType& ot);
orientedType operator-(const orientedType& of); orientedType operator-(const orientedType& ot);
orientedType operator*(const scalar s, const orientedType& of); orientedType operator*(const scalar s, const orientedType& ot);
orientedType operator/(const orientedType& of, const scalar s); orientedType operator/(const orientedType& ot, const scalar s);
orientedType operator+(const orientedType& of1, const orientedType& of2); orientedType operator+(const orientedType& ot1, const orientedType& ot2);
orientedType operator-(const orientedType& of1, const orientedType& of2); orientedType operator-(const orientedType& ot1, const orientedType& ot2);
orientedType operator/(const orientedType& of1, const orientedType& of2); orientedType operator/(const orientedType& ot1, const orientedType& ot2);
orientedType operator*(const orientedType& of1, const orientedType& of2); orientedType operator*(const orientedType& ot1, const orientedType& ot2);
orientedType operator^(const orientedType& of1, const orientedType& of2); orientedType operator^(const orientedType& ot1, const orientedType& ot2);
orientedType operator&(const orientedType& of1, const orientedType& of2); orientedType operator&(const orientedType& ot1, const orientedType& ot2);
orientedType operator&&(const orientedType& of1, const orientedType& of2); orientedType operator&&(const orientedType& ot1, const orientedType& ot2);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1195,7 +1195,7 @@ CrankNicolsonDdtScheme<Type>::fvcDdtPhiCorr
"ddt0(" + phi.name() + ')', "ddt0(" + phi.name() + ')',
phi.dimensions() phi.dimensions()
); );
dphidt0.oriented().oriented() = true; dphidt0.setOriented();
dimensionedScalar rDtCoef = rDtCoef_(ddt0); dimensionedScalar rDtCoef = rDtCoef_(ddt0);
@ -1440,7 +1440,7 @@ tmp<surfaceScalarField> CrankNicolsonDdtScheme<Type>::meshPhi
dimVolume dimVolume
); );
meshPhi0.oriented().oriented() = true; meshPhi0.setOriented();
if (evaluate(meshPhi0)) if (evaluate(meshPhi0))
{ {

View File

@ -124,7 +124,7 @@ snGradScheme<Type>::snGrad
) )
); );
GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref(); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref();
ssf.oriented().oriented() = true; ssf.setOriented();
// set reference to difference factors array // set reference to difference factors array
const scalarField& deltaCoeffs = tdeltaCoeffs(); const scalarField& deltaCoeffs = tdeltaCoeffs();

View File

@ -892,7 +892,7 @@ flux() const
GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux = GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux =
tfieldFlux.ref(); tfieldFlux.ref();
fieldFlux.oriented().oriented() = true; fieldFlux.setOriented();
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{ {

View File

@ -68,7 +68,7 @@ void Foam::fvMesh::makeSf() const
faceAreas() faceAreas()
); );
SfPtr_->oriented().oriented() = true; SfPtr_->setOriented();
} }
@ -400,7 +400,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const
) )
); );
surfaceVectorField& delta = tdelta.ref(); surfaceVectorField& delta = tdelta.ref();
delta.oriented().oriented() = true; delta.setOriented();
const volVectorField& C = this->C(); const volVectorField& C = this->C();
const labelUList& owner = this->owner(); const labelUList& owner = this->owner();
@ -438,7 +438,7 @@ const Foam::surfaceScalarField& Foam::fvMesh::phi() const
(*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0); (*phiPtr_) = dimensionedScalar("0", dimVolume/dimTime, 0.0);
} }
phiPtr_->oriented().oriented() = true; phiPtr_->setOriented();
return *phiPtr_; return *phiPtr_;
} }

View File

@ -72,9 +72,9 @@ void MapInternalField<Type, MeshMapper, surfaceMesh>::operator()
// Passing in oriented flag so that oriented fields (e.g. phi) are negated // Passing in oriented flag so that oriented fields (e.g. phi) are negated
// if flipped. Un-oriented fields, e.g U interpolated to faces (Uf) are not // if flipped. Un-oriented fields, e.g U interpolated to faces (Uf) are not
// touched // touched
field.autoMap(mapper.surfaceMap(), field.oriented().oriented()); field.autoMap(mapper.surfaceMap(), field.oriented()());
if (field.oriented().oriented()) if (field.oriented()())
{ {
// Flip the flux // Flip the flux
const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc(); const labelList flipFaces = mapper.surfaceMap().flipFaceFlux().toc();

View File

@ -154,7 +154,7 @@ void Foam::surfaceInterpolation::makeWeights() const
dimless dimless
); );
surfaceScalarField& weights = *weights_; surfaceScalarField& weights = *weights_;
weights.oriented().oriented() = true; weights.setOriented();
// Set local references to mesh data // Set local references to mesh data
// Note that we should not use fvMesh sliced fields at this point yet // Note that we should not use fvMesh sliced fields at this point yet
@ -226,7 +226,7 @@ void Foam::surfaceInterpolation::makeDeltaCoeffs() const
dimless/dimLength dimless/dimLength
); );
surfaceScalarField& deltaCoeffs = *deltaCoeffs_; surfaceScalarField& deltaCoeffs = *deltaCoeffs_;
deltaCoeffs.oriented().oriented() = true; deltaCoeffs.setOriented();
// Set local references to mesh data // Set local references to mesh data
@ -277,7 +277,7 @@ void Foam::surfaceInterpolation::makeNonOrthDeltaCoeffs() const
dimless/dimLength dimless/dimLength
); );
surfaceScalarField& nonOrthDeltaCoeffs = *nonOrthDeltaCoeffs_; surfaceScalarField& nonOrthDeltaCoeffs = *nonOrthDeltaCoeffs_;
nonOrthDeltaCoeffs.oriented().oriented() = true; nonOrthDeltaCoeffs.setOriented();
// Set local references to mesh data // Set local references to mesh data
@ -342,7 +342,7 @@ void Foam::surfaceInterpolation::makeNonOrthCorrectionVectors() const
dimless dimless
); );
surfaceVectorField& corrVecs = *nonOrthCorrectionVectors_; surfaceVectorField& corrVecs = *nonOrthCorrectionVectors_;
corrVecs.oriented().oriented() = true; corrVecs.setOriented();
// Set local references to mesh data // Set local references to mesh data
const volVectorField& C = mesh_.C(); const volVectorField& C = mesh_.C();

View File

@ -291,7 +291,7 @@ Foam::fvFieldDecomposer::decomposeField
) )
); );
if (resF.oriented().oriented()) if (resF.oriented()())
{ {
bf[patchi] *= faceSign_[patchi]; bf[patchi] *= faceSign_[patchi];
} }
@ -313,7 +313,7 @@ Foam::fvFieldDecomposer::decomposeField
) )
); );
if (resF.oriented().oriented()) if (resF.oriented()())
{ {
bf[patchi] *= faceSign_[patchi]; bf[patchi] *= faceSign_[patchi];
} }