Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
sergio
2016-11-16 16:27:36 -08:00
642 changed files with 30806 additions and 23229 deletions

View File

@ -114,6 +114,7 @@ Foam::functionObjects::blendingFactor::~blendingFactor()
bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
{
fieldExpression::read(dict);
writeFile::read(dict);
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
dict.readIfPresent("tolerance", tolerance_);

View File

@ -936,37 +936,33 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
}
// Print a bit
if (log)
Info<< type() << ": Communicating with regions:" << endl;
forAll(regionGroupNames_, rgi)
{
Info<< type() << ": Communicating with regions:" << endl;
forAll(regionGroupNames_, rgi)
//const wordList& regionNames = regionGroupRegions_[rgi];
const word& compName = regionGroupNames_[rgi];
Info<< "Region: " << compName << endl << incrIndent;
const labelList& groups = regionToGroups_[compName];
forAll(groups, i)
{
//const wordList& regionNames = regionGroupRegions_[rgi];
const word& compName = regionGroupNames_[rgi];
label groupi = groups[i];
const wordRe& groupName = groupNames_[groupi];
Info<< "Region: " << compName << endl << incrIndent;
const labelList& groups = regionToGroups_[compName];
forAll(groups, i)
{
label groupi = groups[i];
const wordRe& groupName = groupNames_[groupi];
Info<< indent << "patchGroup: " << groupName << "\t"
<< endl
<< incrIndent
<< indent << "Reading fields: "
<< groupReadFields_[groupi]
<< endl
<< indent << "Writing fields: "
<< groupWriteFields_[groupi]
<< endl
<< decrIndent;
}
Info<< decrIndent;
Info<< indent << "patchGroup: " << groupName << "\t"
<< endl
<< incrIndent
<< indent << "Reading fields: "
<< groupReadFields_[groupi]
<< endl
<< indent << "Writing fields: "
<< groupWriteFields_[groupi]
<< endl
<< decrIndent;
}
Info<< endl;
Info<< decrIndent;
}
Info<< endl;
// Note: we should not have to make directories since the geometry

View File

@ -108,8 +108,7 @@ void Foam::functionObjects::fieldAverage::initialize()
void Foam::functionObjects::fieldAverage::restart()
{
Log
<< " Restarting averaging at time " << obr_.time().timeName()
Log << " Restarting averaging at time " << obr_.time().timeName()
<< nl << endl;
totalIter_.clear();
@ -159,8 +158,7 @@ void Foam::functionObjects::fieldAverage::calcAverages()
restart();
}
Log
<< type() << " " << name() << " write:" << nl
Log << type() << " " << name() << " write:" << nl
<< " Calculating averages" << nl;
addMeanSqrToPrime2Mean<scalar, scalar>();
@ -221,14 +219,14 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
totalTime_.clear();
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
if ((restartOnRestart_ || restartOnOutput_) && log)
if (restartOnRestart_ || restartOnOutput_)
{
Info<< " Starting averaging at time " << obr_.time().timeName()
<< nl;
}
else
{
Log << " Restarting averaging for fields:" << nl;
Info<< " Restarting averaging for fields:" << nl;
forAll(faItems_, fieldi)
@ -242,15 +240,13 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
Log
<< " " << fieldName
Info<< " " << fieldName
<< " iters = " << totalIter_[fieldi]
<< " time = " << totalTime_[fieldi] << nl;
}
else
{
Log
<< " " << fieldName
Info<< " " << fieldName
<< ": starting averaging at time "
<< obr_.time().timeName() << endl;
}
@ -299,7 +295,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
initialised_ = false;
Log << type() << " " << name() << ":" << nl;
Info<< type() << " " << name() << ":" << nl;
dict.readIfPresent("restartOnRestart", restartOnRestart_);
dict.readIfPresent("restartOnOutput", restartOnOutput_);
@ -309,8 +305,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
if (periodicRestart_)
{
dict.lookup("restartPeriod") >> restartPeriod_;
Log
<< " Restart period " << restartPeriod_
Info<< " Restart period " << restartPeriod_
<< nl << endl;
}
@ -324,15 +319,14 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
}
else
{
Log
<< " Restart scheduled at time " << restartTime_
Info<< " Restart scheduled at time " << restartTime_
<< nl << endl;
}
}
readAveragingProperties();
Log << endl;
Info<< endl;
return true;
}

View File

@ -60,7 +60,7 @@ fieldCoordinateSystemTransform
{
read(dict);
Log << type() << " " << name << ":" << nl
Info<< type() << " " << name << ":" << nl
<< " Applying transformation from global Cartesian to local "
<< coordSys_ << nl << endl;
}

View File

@ -122,6 +122,7 @@ Foam::functionObjects::fieldMinMax::~fieldMinMax()
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
location_ = dict.lookupOrDefault<Switch>("location", true);

View File

@ -128,7 +128,6 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
region1Ptr_.reset
@ -210,9 +209,9 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::write()
applyOperation<symmTensor>(type1, name1, name2, entry1, entry2, found);
applyOperation<tensor>(type1, name1, name2, entry1, entry2, found);
if (log && !found)
if (!found)
{
Info<< "Operation between "
Log << "Operation between "
<< name1 << " with result " << entry1 << " and "
<< name2 << " with result " << entry2 << " not applied"
<< endl;

View File

@ -488,7 +488,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
if (weightFieldName_ == "none")
{
dict.lookup("orientedWeightField") >> weightFieldName_;
Log << " weight field = " << weightFieldName_ << nl;
Info<< " weight field = " << weightFieldName_ << nl;
orientWeightField_ = true;
}
else

View File

@ -328,8 +328,11 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
(
outputDir(),
regionTypeNames_[regionType_] + ("_" + regionName_),
points,
faces,
meshedSurfRef
(
points,
faces
),
fieldName,
allValues,
false

View File

@ -21,28 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
flowType
Group
grpPostProcessingUtilities
Description
Calculates and writes the flowType of velocity field U.
The -noWrite option has no meaning.
The flow type parameter is obtained according to the following equation:
\verbatim
|D| - |Omega|
lambda = -------------
|D| + |Omega|
-1 = rotational flow
0 = simple shear flow
1 = planar extensional flow
\endverbatim
\*---------------------------------------------------------------------------*/
#include "flowType.H"

View File

@ -727,22 +727,18 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
}
}
// Provide some output
if (log)
Info<< type() << " " << name() << " output:" << nl;
forAll(faceZoneName_, zonei)
{
Info<< type() << " " << name() << " output:" << nl;
const word& zoneName = faceZoneName_[zonei];
scalar zoneArea = faceArea_[zonei];
forAll(faceZoneName_, zonei)
{
const word& zoneName = faceZoneName_[zonei];
scalar zoneArea = faceArea_[zonei];
Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl;
}
Info<< endl;
Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl;
}
Info<< endl;
return true;
}

View File

@ -93,6 +93,7 @@ Foam::functionObjects::histogram::~histogram()
bool Foam::functionObjects::histogram::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
dict.lookup("field") >> fieldName_;
dict.lookup("max") >> max_;

View File

@ -55,7 +55,7 @@ void Foam::functionObjects::mapFields::createInterpolation
const fvMesh& meshTarget = mesh_;
const word mapRegionName(dict.lookup("mapRegion"));
Log << name() << ':' << nl
Info<< name() << ':' << nl
<< " Reading mesh " << mapRegionName << endl;
mapRegionPtr_.reset
@ -97,12 +97,12 @@ void Foam::functionObjects::mapFields::createInterpolation
// Optionally override
if (dict.readIfPresent("patchMapMethod", patchMapMethodName))
{
Log << " Patch mapping method: " << patchMapMethodName << endl;
Info<< " Patch mapping method: " << patchMapMethodName << endl;
}
bool consistent = readBool(dict.lookup("consistent"));
Log << " Creating mesh to mesh interpolation" << endl;
Info<< " Creating mesh to mesh interpolation" << endl;
if (consistent)
{

View File

@ -281,7 +281,7 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict)
reverseFieldMap_.insert(sampleFldName, fldName);
}
Log << type() << " " << name()
Info<< type() << " " << name()
<< ": Sampling " << fieldMap_.size() << " fields" << endl;
// Do analysis

View File

@ -138,10 +138,10 @@ writeSpeciesRR()
prodFilePtr_() << "delta T : "<< mesh_.time().deltaT().value() << nl << nl;
consIntFilePtr_() << "start time : " << startTime_ << tab
<< "end time :" << endTime_ << nl;
<< "end time :" << endTime_ << nl;
prodIntFilePtr_() << "start time : " << startTime_ << tab
<< "end time :" << endTime_ << nl;
<< "end time :" << endTime_ << nl;
for (label reactioni = 0; reactioni < nReactions_; ++reactioni)
{
@ -202,7 +202,7 @@ reactionsSensitivityAnalysis
if (mesh_.nCells() != 1)
{
FatalErrorInFunction
<< "Function object only applicable to single cell cases "
<< "Function object only applicable to single cell cases"
<< abort(FatalError);
}
@ -243,9 +243,9 @@ reactionsSensitivityAnalysis
}
else
{
FatalErrorInFunction
<< " Not chemistry model found. "
<< " Object available are : " << mesh_.names()
FatalErrorInFunction
<< " No chemistry model found. "
<< " Objects available are : " << mesh_.names()
<< exit(FatalError);
}
}

View File

@ -60,7 +60,7 @@ bool Foam::functionObjects::readFields::loadField(const word& fieldName)
IOobject::NO_WRITE
);
if (fieldHeader.typeHeaderOk<VolFieldType>(false))
if (fieldHeader.typeHeaderOk<VolFieldType>(true))
{
// Store field on mesh database
Log << " Reading " << fieldName << endl;
@ -68,7 +68,7 @@ bool Foam::functionObjects::readFields::loadField(const word& fieldName)
mesh_.objectRegistry::store(vfPtr);
return true;
}
else if (fieldHeader.typeHeaderOk<SurfaceFieldType>(false))
else if (fieldHeader.typeHeaderOk<SurfaceFieldType>(true))
{
// Store field on mesh database
Log << " Reading " << fieldName << endl;

View File

@ -354,6 +354,7 @@ Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution()
bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
dict.lookup("field") >> alphaName_;
dict.lookup("patches") >> patchNames_;
@ -371,7 +372,7 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
{
coordSysPtr_.reset(new coordinateSystem(obr_, dict));
Log << "Transforming all vectorFields with coordinate system "
Info<< "Transforming all vectorFields with coordinate system "
<< coordSysPtr_().name() << endl;
}

View File

@ -162,7 +162,7 @@ bool Foam::functionObjects::streamLine::read(const dictionary& dict)
nSubCycle_ = max(nSubCycle_, 1);
Log << " automatic track length specified through"
Info<< " automatic track length specified through"
<< " number of sub cycles : " << nSubCycle_ << nl
<< endl;
}

View File

@ -157,19 +157,19 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
fieldSet_.insert(wordList(dict.lookup("fields")));
}
Log << type() << " " << name() << ": ";
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
{
Log << "storing fields:" << nl;
Info<< "storing fields:" << nl;
forAllConstIter(wordHashSet, fieldSet_, iter)
{
Log << " " << modelName << ':' << iter.key() << nl;
Info<< " " << modelName << ':' << iter.key() << nl;
}
Log << endl;
Info<< endl;
}
else
{
Log << "no fields requested to be stored" << nl << endl;
Info<< "no fields requested to be stored" << nl << endl;
}
return true;

View File

@ -143,7 +143,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
wordReList(dict.lookupOrDefault("patches", wordReList()))
);
Log << type() << " " << name() << ":" << nl;
Info<< type() << " " << name() << ":" << nl;
if (patchSet_.empty())
{
@ -155,7 +155,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
}
}
Log << " processing all wall patches" << nl << endl;
Info<< " processing all wall patches" << nl << endl;
}
else
{
@ -177,7 +177,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
}
}
Log << endl;
Info<< endl;
patchSet_ = filteredPatchSet;
}

View File

@ -180,7 +180,7 @@ void Foam::functionObjects::forces::initialise()
if (!foundObject<volVectorField>(fDName_))
{
FatalErrorInFunction
<< "Could not find " << fDName_ << " in database."
<< "Could not find " << fDName_ << " in database"
<< exit(FatalError);
}
}
@ -194,14 +194,15 @@ void Foam::functionObjects::forces::initialise()
)
{
FatalErrorInFunction
<< "Could not find " << UName_ << ", " << pName_
<< "Could not find U: " << UName_ << " or p:" << pName_
<< " in database"
<< exit(FatalError);
}
if (rhoName_ != "rhoInf" && !foundObject<volScalarField>(rhoName_))
{
FatalErrorInFunction
<< "Could not find " << rhoName_
<< "Could not find rho:" << rhoName_
<< exit(FatalError);
}
}
@ -269,13 +270,13 @@ void Foam::functionObjects::forces::initialiseBins()
{
binPoints_[i] = (i + 0.5)*binDir_*binDx_;
}
}
// Allocate storage for forces and moments
forAll(force_, i)
{
force_[i].setSize(nBin_, vector::zero);
moment_[i].setSize(nBin_, vector::zero);
}
// Allocate storage for forces and moments
forAll(force_, i)
{
force_[i].setSize(nBin_, vector::zero);
moment_[i].setSize(nBin_, vector::zero);
}
}
@ -732,7 +733,7 @@ Foam::functionObjects::forces::forces
)
:
fvMeshFunctionObject(name, runTime, dict),
writeFile(mesh_, name, name, dict),
writeFile(mesh_, name),
force_(3),
moment_(3),
forceFilePtr_(),
@ -780,7 +781,7 @@ Foam::functionObjects::forces::forces
)
:
fvMeshFunctionObject(name, obr, dict),
writeFile(mesh_, name, name, dict),
writeFile(mesh_, name),
force_(3),
moment_(3),
forceFilePtr_(),
@ -845,7 +846,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
initialised_ = false;
Info << type() << " " << name() << ":" << nl;
Info<< type() << " " << name() << ":" << nl;
directForceDensity_ = dict.lookupOrDefault("directForceDensity", false);
@ -888,11 +889,11 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
dict.readIfPresent("porosity", porosity_);
if (porosity_)
{
Info << " Including porosity effects" << endl;
Info<< " Including porosity effects" << endl;
}
else
{
Info << " Not including porosity effects" << endl;
Info<< " Not including porosity effects" << endl;
}
if (dict.found("binData"))
@ -908,9 +909,10 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
}
else if (nBin_ == 0)
{
// Case of no bins equates to a single bin to collect all data
nBin_ = 1;
}
else if ((nBin_ == 0) || (nBin_ == 1))
else
{
binDict.lookup("cumulative") >> binCumulative_;
binDict.lookup("direction") >> binDir_;
@ -918,21 +920,11 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
}
}
if (nBin_ == 1)
{
// Allocate storage for forces and moments
forAll(force_, i)
{
force_[i].setSize(1, vector::zero);
moment_[i].setSize(1, vector::zero);
}
}
writeFields_ = dict.lookupOrDefault("writeFields", false);
if (writeFields_)
{
Info << " Fields will be written" << endl;
Info<< " Fields will be written" << endl;
volVectorField* forcePtr
(

View File

@ -89,20 +89,23 @@ addGeometryToScene
return;
}
const dictionary dict =
geometryBase::parent_.getObjectProperty
(
functionObject_,
fieldName_,
dictionary::null
);
dictionary dict;
if (!geometryBase::parent_.getObjectDict(functionObject_, fieldName_, dict))
{
WarningInFunction
<< "Unable to find function object " << functionObject_
<< " output for field " << fieldName_
<< ". Line will not be processed"
<< endl;
return;
}
fileName fName;
if (!dict.readIfPresent("file", fName))
{
WarningInFunction
<< "Unable to find function object " << functionObject_
<< " output for field " << fieldName_
<< "Unable to read file name from function object "
<< functionObject_ << " for field " << fieldName_
<< ". Line will not be processed"
<< endl;
return;

View File

@ -93,21 +93,24 @@ addGeometryToScene
return;
}
const dictionary dict =
geometryBase::parent_.getObjectProperty
(
functionObject_,
fieldName_,
dictionary::null
);
dictionary dict;
if (!geometryBase::parent_.getObjectDict(functionObject_, fieldName_, dict))
{
WarningInFunction
<< "Unable to find function object " << functionObject_
<< " output for field " << fieldName_
<< ". Surface will not be processed"
<< endl;
return;
}
fileName fName;
if (!dict.readIfPresent("file", fName))
{
WarningInFunction
<< "Unable to find function object " << functionObject_
<< " output for field " << fieldName_
<< ". functionObjectSurface will not be processed"
<< "Unable to read file name from function object "
<< functionObject_ << " for field " << fieldName_
<< ". Surface will not be processed"
<< endl;
return;
}

View File

@ -120,9 +120,7 @@ bool Foam::functionObjects::icoUncoupledKinematicCloud::read
const dictionary& dict
)
{
fvMeshFunctionObject::read(dict);
return true;
return fvMeshFunctionObject::read(dict);
}

View File

@ -1,6 +1,7 @@
abort/abort.C
codedFunctionObject/codedFunctionObject.C
ensightWrite/ensightWrite.C
removeRegisteredObject/removeRegisteredObject.C

View File

@ -1,5 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
@ -7,6 +9,8 @@ EXE_INC = \
LIB_LIBS = \
-lfiniteVolume \
-lconversion \
-lsampling \
-lfluidThermophysicalModels \
-lcompressibleTransportModels \
-lODE

View File

@ -0,0 +1,329 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "ensightWrite.H"
#include "Time.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(ensightWrite, 0);
addToRunTimeSelectionTable
(
functionObject,
ensightWrite,
dictionary
);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::functionObjects::ensightWrite::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::ensightWrite::process(const word& fieldName)
{
int state = 0;
writeVolField<scalar>(fieldName, state);
writeVolField<vector>(fieldName, state);
writeVolField<sphericalTensor>(fieldName, state);
writeVolField<symmTensor>(fieldName, state);
writeVolField<tensor>(fieldName, state);
return state;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::ensightWrite::ensightWrite
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
writeOpts_
(
dict.found("format")
? IOstream::formatEnum(dict.lookup("format"))
: runTime.writeFormat()
),
caseOpts_(writeOpts_.format()),
selectFields_(),
dirName_("ensightWrite"),
consecutive_(false)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::ensightWrite::~ensightWrite()
{
if (ensCase_.valid())
{
// finalize case
ensCase().write();
ensCase_.clear();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
//
// writer options
//
writeOpts_.noPatches
(
dict.lookupOrDefault<Switch>("noPatches", false)
);
writeOpts_.deprecatedOrder
(
dict.lookupOrDefault<Switch>("deprecatedOrder", false)
);
if (dict.found("patches"))
{
wordReList lst(dict.lookup("patches"));
uniqWords(lst);
writeOpts_.patchSelection(lst);
}
if (dict.found("faceZones"))
{
wordReList lst(dict.lookup("faceZones"));
uniqWords(lst);
writeOpts_.faceZoneSelection(lst);
}
//
// case options
//
caseOpts_.width(dict.lookupOrDefault<label>("width", 8));
// remove existing output directory
caseOpts_.overwrite(dict.lookupOrDefault<Switch>("overwrite", false));
//
// other options
//
dict.readIfPresent("directory", dirName_);
consecutive_ = dict.lookupOrDefault<Switch>("consecutive", false);
//
// output fields
//
dict.lookup("fields") >> selectFields_;
uniqWords(selectFields_);
return true;
}
bool Foam::functionObjects::ensightWrite::execute()
{
return true;
}
bool Foam::functionObjects::ensightWrite::write()
{
const Time& t = obr_.time();
if (!ensCase_.valid())
{
// Define sub-directory name to use for EnSight data.
// The path to the ensight directory is at case level only
// - For parallel cases, data only written from master
fileName ensightDir = dirName_;
if (!ensightDir.isAbsolute())
{
ensightDir = t.rootPath()/t.globalCaseName()/ensightDir;
}
ensCase_.reset
(
new ensightCase
(
ensightDir,
t.globalCaseName(),
caseOpts_
)
);
}
if (!ensMesh_.valid())
{
ensMesh_.reset(new ensightMesh(mesh_, writeOpts_));
if (ensMesh_().needsUpdate())
{
ensMesh_().correct();
}
// assume static geometry - need to fix later
autoPtr<ensightGeoFile> os = ensCase_().newGeometry(false);
ensMesh_().write(os);
}
else if (ensMesh_().needsUpdate())
{
// appears to have moved
ensMesh_().correct();
autoPtr<ensightGeoFile> os = ensCase_().newGeometry(true);
ensMesh_().write(os);
}
Log << type() << " " << name() << " write: (";
if (consecutive_)
{
ensCase().nextTime(t.value());
}
else
{
ensCase().setTime(t.value(), t.timeIndex());
}
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());
}
Log << " )" << endl;
if (missing.size())
{
WarningInFunction
<< "Missing field " << missing << endl;
}
if (ignored.size())
{
WarningInFunction
<< "Unprocessed field " << ignored << endl;
}
return true;
}
bool Foam::functionObjects::ensightWrite::end()
{
if (ensCase_.valid())
{
// finalize case
ensCase().write();
ensCase_.clear();
}
return true;
}
void Foam::functionObjects::ensightWrite::updateMesh(const mapPolyMesh& mpm)
{
// fvMeshFunctionObject::updateMesh(mpm);
if (ensMesh_.valid())
{
ensMesh_().expire();
}
}
void Foam::functionObjects::ensightWrite::movePoints(const polyMesh& mpm)
{
// fvMeshFunctionObject::updateMesh(mpm);
if (ensMesh_.valid())
{
ensMesh_().expire();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,227 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::functionObjects::ensightWrite
Group
grpUtilitiesFunctionObjects
Description
Writes fields in ensight format.
Example of function object specification:
\verbatim
ensight
{
type ensightWrite;
libs ("libutilityFunctionObjects.so");
writeControl writeTime;
writeInterval 1;
format binary;
overwrite true;
width 12;
directory "EnSight";
fields
(
U
p
);
}
\endverbatim
\heading Function object usage
\table
Property | Description | Required | Default value
type | Type name: ensightWrite | yes |
fields | Fields to output | yes |
writeControl | Output control | recommended | timeStep
directory | The output directory name | no | "ensightWrite"
overwrite | Remove existing directory | no | false
format | ASCII or binary format | no | same as simulation
width | Mask width for \c data/XXXX | no | 8
noPatches | Suppress writing patches | no | false
patches | Select patches to write | no |
faceZones | Select faceZones to write | no |
deprecatedOrder | Old ordering of volume cells | no | false
consecutive | Consecutive output numbering | no | false
\endtable
Note that if the \c patches entry is an empty list, this will select all
patches and suppress writing the internalMesh.
Consecutive output numbering can be used in conjunction with \c overwrite.
SourceFiles
ensightWrite.C
ensightWriteTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_ensightWrite_H
#define functionObjects_ensightWrite_H
#include "fvMeshFunctionObject.H"
#include "ensightCase.H"
#include "ensightMesh.H"
#include "wordReList.H"
#include "interpolation.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class dictionary;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class ensightWrite Declaration
\*---------------------------------------------------------------------------*/
class ensightWrite
:
public fvMeshFunctionObject
{
// Private data
//- Writer options
ensightMesh::options writeOpts_;
ensightCase::options caseOpts_;
//- Name of fields to process
wordReList selectFields_;
//- Output directory name
fileName dirName_;
//- Consecutive output numbering
bool consecutive_;
//- Ensight case handler
autoPtr<ensightCase> ensCase_;
//- Ensight mesh handler
autoPtr<ensightMesh> ensMesh_;
// Private Member Functions
//- Eliminate duplicate 'word' entries
static void uniqWords(wordReList&);
//- Ensight case handler
ensightCase& ensCase()
{
return ensCase_();
}
//- Ensight mesh handler
ensightMesh& ensMesh()
{
return ensMesh_();
}
//- Apply for the volume field type
template<class Type>
int writeVolField(const word& inputName, int& state);
//- Process by trying to apply for various volume field types.
int process(const word& inputName);
//- Disallow default bitwise copy construct
ensightWrite(const ensightWrite&) = delete;
//- Disallow default bitwise assignment
void operator=(const ensightWrite&) = delete;
public:
//- Runtime type information
TypeName("ensightWrite");
// Constructors
//- Construct from runTime and dictionary.
ensightWrite
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~ensightWrite();
// Member Functions
//- Read the ensightWrite specification
virtual bool read(const dictionary&);
//- Do nothing
virtual bool execute();
//- Write fields
virtual bool write();
//- Execute at the final time-loop, flush case file
virtual bool end();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh point-motion
virtual void movePoints(const polyMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ensightWriteTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "Time.H"
#include "ensightOutput.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
int Foam::functionObjects::ensightWrite::writeVolField
(
const word& inputName,
int& state
)
{
// State: return 0 (not-processed), -1 (skip), +1 ok
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
// Already done, or not available
if (state || !foundObject<VolFieldType>(inputName))
{
return state;
}
autoPtr<ensightFile> os = ensCase().newData<Type>(inputName);
ensightOutput::writeField<Type>
(
lookupObject<VolFieldType>(inputName),
ensMesh(),
os
);
Log << " " << inputName;
state = +1;
return state;
}
// ************************************************************************* //

View File

@ -67,9 +67,9 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
}
// Check if the property exist (resume old calculation)
// or of it is new.
// or of it is new
dictionary probeDict;
if (getDict(typeName, probeDict))
if (getDict(name, probeDict))
{
probeDict.lookup("Tc") >> Ttc_;
}
@ -172,7 +172,7 @@ bool Foam::functionObjects::thermoCoupleProbes::write()
dictionary probeDict;
probeDict.add("Tc", Ttc_);
setProperty(typeName, probeDict);
setProperty(name(), probeDict);
return true;
}

View File

@ -111,7 +111,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
lastIndex_ = -1;
fileToUpdate_.expand();
Log << type() << " " << name() << " output:" << nl
Info<< type() << " " << name() << " output:" << nl
<< " time vs file list:" << endl;
forAll(timeVsFile_, i)
@ -124,7 +124,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
<< nl << exit(FatalError);
}
Log << " " << timeVsFile_[i].first() << tab
Info<< " " << timeVsFile_[i].first() << tab
<< timeVsFile_[i].second() << endl;
}