GIT: resolve merge errors to ddt2, zeroGradient functionObjects

- the function objects are from issue #224 and issue #235
This commit is contained in:
Mark Olesen 2016-09-30 11:26:58 +02:00
parent 3c86995198
commit 1e00bd7f45
6 changed files with 140 additions and 143 deletions

View File

@ -121,7 +121,76 @@ int Foam::functionObjects::ddt2::process(const word& fieldName)
}
void Foam::functionObjects::ddt2::process()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::ddt2::ddt2
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
selectFields_(),
resultName_(word::null),
blacklist_(),
results_(),
mag_(dict.lookupOrDefault<Switch>("mag", false))
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::ddt2::~ddt2()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::ddt2::read(const dictionary& dict)
{
if (word(mesh_.ddtScheme("default")) == "steadyState")
{
WarningInFunction
<< typeName << " function object not appropriate for steady-state"
<< endl;
return false;
}
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> selectFields_;
uniqWords(selectFields_);
resultName_ = dict.lookupOrDefault<word>
(
"result",
( mag_ ? "mag(ddt(@@))" : "magSqr(ddt(@@))" )
);
if (checkFormatName(resultName_))
{
blacklist_.set
(
string::quotemeta<regExp>
(
resultName_
).replace("@@", "(.+)")
);
return true;
}
else
{
blacklist_.clear();
return false;
}
}
bool Foam::functionObjects::ddt2::execute()
{
results_.clear();
@ -163,80 +232,6 @@ void Foam::functionObjects::ddt2::process()
WarningInFunction
<< "Unprocessed field " << ignored << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::ddt2::ddt2
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
selectFields_(),
resultName_(word::null),
blacklist_(),
results_(),
mag_(dict.lookupOrDefault<Switch>("mag", false))
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::ddt2::~ddt2()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::ddt2::read(const dictionary& dict)
{
if (word(mesh_.ddtScheme("default")) == "steadyState")
{
WarningInFunction
<< typeName << " function object not appropriate for steady-state"
<< endl;
return false;
}
dict.lookup("fields") >> selectFields_;
uniqWords(selectFields_);
resultName_ = dict.lookupOrDefault<word>
(
"result",
( mag_ ? "mag(ddt(@@))" : "magSqr(ddt(@@))" )
);
if (checkFormatName(resultName_))
{
blacklist_.set
(
string::quotemeta<regExp>
(
resultName_
).replace("@@", "(.+)")
);
return true;
}
else
{
blacklist_.clear();
return false;
}
}
bool Foam::functionObjects::ddt2::execute()
{
results_.clear();
process();
return true;
}
@ -244,9 +239,13 @@ bool Foam::functionObjects::ddt2::execute()
bool Foam::functionObjects::ddt2::write()
{
if (results_.size())
{
Log << type() << ' ' << name() << " write:" << endl;
}
// Consistent output order
const wordList outputList = results_.sortedToc();
forAll(outputList, i)
{
const word& fieldName = outputList[i];
@ -255,8 +254,7 @@ bool Foam::functionObjects::ddt2::write()
{
const regIOobject& io = lookupObject<regIOobject>(fieldName);
Log << type() << " " << name()
<< " write: writing field " << fieldName << endl;
Log << " " << fieldName << endl;
io.write();
}

View File

@ -68,7 +68,7 @@ Description
SourceFiles
ddt2.C
IOddt2.H
ddt2Templates.C
\*---------------------------------------------------------------------------*/
@ -137,9 +137,6 @@ class ddt2
//- Process by trying to apply for various volume field types.
int process(const word& inputName);
//- Calculate the ddt2 fields
void process();
//- Disallow default bitwise copy construct
ddt2(const ddt2&) = delete;
@ -171,7 +168,7 @@ public:
// Member Functions
//- Return name of the ddt2 function object
//- Read the ddt2 specification
virtual bool read(const dictionary&);
//- Calculate the ddt2 fields

View File

@ -27,6 +27,8 @@ License
#include "dimensionedType.H"
#include "fvcDdt.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class FieldType>
int Foam::functionObjects::ddt2::apply(const word& inputName, int& state)
{
@ -76,10 +78,8 @@ int Foam::functionObjects::ddt2::apply(const word& inputName, int& state)
store(outputName, tddt2);
}
volScalarField& output = const_cast<volScalarField&>
(
lookupObject<volScalarField>(outputName)
);
volScalarField& output =
const_cast<volScalarField&>(lookupObject<volScalarField>(outputName));
if (mag_)
{
@ -91,7 +91,7 @@ int Foam::functionObjects::ddt2::apply(const word& inputName, int& state)
}
// Could add additional statistics here
Log << type() << " " << name()
Log << type() << ' ' << name()
<< " field " << outputName
<< " average: " << gAverage(output) << endl;

View File

@ -108,7 +108,45 @@ int Foam::functionObjects::zeroGradient::process(const word& fieldName)
}
void Foam::functionObjects::zeroGradient::process()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::zeroGradient::zeroGradient
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
selectFields_(),
resultName_(string::null),
results_()
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::zeroGradient::~zeroGradient()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> selectFields_;
uniqWords(selectFields_);
resultName_ = dict.lookupOrDefault<word>("result", type() + "(@@)");
return checkFormatName(resultName_);
}
bool Foam::functionObjects::zeroGradient::execute()
{
results_.clear();
@ -150,57 +188,20 @@ void Foam::functionObjects::zeroGradient::process()
WarningInFunction
<< "Unprocessed field " << ignored << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::zeroGradient::zeroGradient
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
selectFields_(),
resultName_(string::null),
results_()
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::zeroGradient::~zeroGradient()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
{
dict.lookup("fields") >> selectFields_;
uniqWords(selectFields_);
resultName_ = dict.lookupOrDefault<word>("result", type() + "(@@)");
return checkFormatName(resultName_);
}
bool Foam::functionObjects::zeroGradient::execute()
{
results_.clear();
return true;
}
bool Foam::functionObjects::zeroGradient::write()
{
if (results_.size())
{
Log << type() << ' ' << name() << " write:" << endl;
}
// Consistent output order
const wordList outputList = results_.sortedToc();
forAll(outputList, i)
{
const word& fieldName = outputList[i];
@ -209,8 +210,7 @@ bool Foam::functionObjects::zeroGradient::write()
{
const regIOobject& io = lookupObject<regIOobject>(fieldName);
Log << type() << " " << name()
<< " write: writing field " << fieldName << endl;
Log << " " << fieldName << endl;
io.write();
}

View File

@ -65,8 +65,7 @@ Description
SourceFiles
zeroGradient.C
zeroGradientFunctionObject.C
IOzeroGradient.H
zeroGradientTemplates.C
\*---------------------------------------------------------------------------*/
@ -114,7 +113,10 @@ class zeroGradient
static void uniqWords(wordReList&);
//- Accept unless field only has empty/zero-gradient/processor patches
//- Accept unless field only has constraint patches
// (ie, empty/zero-gradient/processor).
// This should also avoid fields that were already processed by
// zeroGradient.
template<class Type>
static bool accept(const GeometricField<Type, fvPatchField, volMesh>&);
@ -125,9 +127,6 @@ class zeroGradient
//- Process by trying to apply for various volume field types.
int process(const word& inputName);
//- Calculate the zeroGradient fields
void process();
//- Disallow default bitwise copy construct
zeroGradient(const zeroGradient&) = delete;

View File

@ -27,6 +27,8 @@ License
#include "Time.H"
#include "zeroGradientFvPatchField.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
bool Foam::functionObjects::zeroGradient::accept
(
@ -38,10 +40,10 @@ bool Foam::functionObjects::zeroGradient::accept
forAll(patches, patchi)
{
const fvPatchField<Type>& p = patches[patchi];
const polyPatch& pp = p.patch().patch();
return !polyPatch::constraintType(pp.type());
if (!polyPatch::constraintType(patches[patchi].patch().patch().type()))
{
return true;
}
}
return false;
@ -104,6 +106,7 @@ int Foam::functionObjects::zeroGradient::apply
VolFieldType& output =
const_cast<VolFieldType&>(lookupObject<VolFieldType>(outputName));
output = input;
output.correctBoundaryConditions();