GIT: Resolved conflicts arising from merge with develop branch

This commit is contained in:
Andrew Heather
2016-09-26 10:57:34 +01:00
48 changed files with 2484 additions and 1295 deletions

View File

@ -0,0 +1,223 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "zeroGradient.H"
#include "volFields.H"
#include "dictionary.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(zeroGradient, 0);
addToRunTimeSelectionTable
(
functionObject,
zeroGradient,
dictionary
);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::zeroGradient::checkFormatName(const word& str)
{
if (str.find("@@") == string::npos)
{
WarningInFunction
<< "Bad result naming "
<< "(no '@@' token found), deactivating."
<< nl << endl;
return false;
}
else if (str == "@@")
{
WarningInFunction
<< "Bad result naming "
<< "(only a '@@' token found), deactivating."
<< nl
<< endl;
return false;
}
else
{
return true;
}
}
void Foam::functionObjects::zeroGradient::uniqWords(wordReList& lst)
{
boolList retain(lst.size());
wordHashSet uniq;
forAll(lst, i)
{
const wordRe& select = lst[i];
retain[i] =
(
select.isPattern()
|| uniq.insert(static_cast<const word&>(select))
);
}
inplaceSubset(retain, lst);
}
int Foam::functionObjects::zeroGradient::process(const word& fieldName)
{
int state = 0;
apply<scalar>(fieldName, state);
apply<vector>(fieldName, state);
apply<sphericalTensor>(fieldName, state);
apply<symmTensor>(fieldName, state);
apply<tensor>(fieldName, state);
return state;
}
void Foam::functionObjects::zeroGradient::process()
{
results_.clear();
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
DynamicList<word> missing(selectFields_.size());
DynamicList<word> ignored(selectFields_.size());
// check exact matches first
forAll(selectFields_, i)
{
const wordRe& select = selectFields_[i];
if (!select.isPattern())
{
const word& fieldName = static_cast<const word&>(select);
if (!candidates.erase(fieldName))
{
missing.append(fieldName);
}
else if (process(fieldName) < 1)
{
ignored.append(fieldName);
}
}
}
forAllConstIter(wordHashSet, candidates, iter)
{
process(iter.key());
}
if (missing.size())
{
WarningInFunction
<< "Missing field " << missing << endl;
}
if (ignored.size())
{
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()
{
// Consistent output order
const wordList outputList = results_.sortedToc();
forAll(outputList, i)
{
const word& fieldName = outputList[i];
if (foundObject<regIOobject>(fieldName))
{
const regIOobject& io = lookupObject<regIOobject>(fieldName);
Log << type() << " " << name()
<< " write: writing field " << fieldName << endl;
io.write();
}
}
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,188 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::zeroGradient
Group
grpFVFunctionObjects
Description
This function object creates a volume field with zero-gradient
boundary conditions from another volume field.
The result can be used, for example, to post-process near-wall
field values.
Example of function object specification:
\verbatim
zeroGrad
{
type zeroGradient;
libs ("libfieldFunctionObjects.so");
fields (U "(T|k|epsilon|omega)");
result @@nearWall;
...
}
\endverbatim
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: zeroGradient | yes |
fields | Name of fields to process | yes |
result | Name of results | no | zeroGradient(@@)
log | Log to standard output | no | no
\endtable
A list of fields can contain exact names or regular expressions.
The token '\@\@' in the result name is replaced by the name of the source
field.
The function object will skip over fields that would not benefit
- ie, only processor, empty, zeroGradient, symmetry patches.
This check should also prevent processing fields multiple times.
SourceFiles
zeroGradient.C
zeroGradientFunctionObject.C
IOzeroGradient.H
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_zeroGradient_H
#define functionObjects_zeroGradient_H
#include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H"
#include "OFstream.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class zeroGradient Declaration
\*---------------------------------------------------------------------------*/
class zeroGradient
:
public fvMeshFunctionObject
{
// Private data
//- Name of fields to process
wordReList selectFields_;
//- Formatting for the result fields.
word resultName_;
//- Hashed names of result fields, and their type
HashTable<word> results_;
// Private Member Functions
//- Check that the word contains the appropriate substitution token(s).
static bool checkFormatName(const word&);
//- Eliminate duplicate 'word' entries
static void uniqWords(wordReList&);
//- Accept unless field only has empty/zero-gradient/processor patches
template<class Type>
static bool accept(const GeometricField<Type, fvPatchField, volMesh>&);
//- Apply for the volume field type
template<class Type>
int apply(const word& inputName, int& state);
//- 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;
//- Disallow default bitwise assignment
void operator=(const zeroGradient&) = delete;
public:
//- Runtime type information
TypeName("zeroGradient");
// Constructors
//- Construct from Time and dictionary
zeroGradient
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~zeroGradient();
// Member Functions
//- Read the zeroGradient specification
virtual bool read(const dictionary& dict);
//- Calculate the zeroGradient fields
virtual bool execute();
//- Write the zeroGradient fields
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "zeroGradientTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "polyPatch.H"
#include "Time.H"
#include "zeroGradientFvPatchField.H"
template<class Type>
bool Foam::functionObjects::zeroGradient::accept
(
const GeometricField<Type, fvPatchField, volMesh>& input
)
{
const typename GeometricField<Type, fvPatchField, volMesh>::Boundary&
patches = input.boundaryField();
forAll(patches, patchi)
{
const fvPatchField<Type>& p = patches[patchi];
const polyPatch& pp = p.patch().patch();
return !polyPatch::constraintType(pp.type());
}
return false;
}
template<class Type>
int Foam::functionObjects::zeroGradient::apply
(
const word& inputName,
int& state
)
{
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
// State: return 0 (not-processed), -1 (skip), +1 ok
// Already done, or not available
if (state || !foundObject<VolFieldType>(inputName))
{
return state;
}
const VolFieldType& input = lookupObject<VolFieldType>(inputName);
if (!returnReduce(accept(input), orOp<bool>()))
{
state = -1;
return state;
}
word outputName(resultName_);
outputName.replace("@@", inputName);
// Also save the field-type, just in case we want it later
results_.set(outputName, VolFieldType::typeName);
if (!foundObject<VolFieldType>(outputName))
{
tmp<VolFieldType> tzg
(
new VolFieldType
(
IOobject
(
outputName,
time_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensioned<Type>("0", input.dimensions(), Zero),
zeroGradientFvPatchField<Type>::typeName
)
);
store(outputName, tzg);
}
VolFieldType& output =
const_cast<VolFieldType&>(lookupObject<VolFieldType>(outputName));
output = input;
output.correctBoundaryConditions();
state = +1;
return state;
}
// ************************************************************************* //