mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: functionObjects improvements.
- readFields works seamlessly on-the-fly and as postprocessor - new surfaceInterpolateFields to create interpolated field - writeRegisteredObject only check upon writing, not upon startup - add min,max to faceSource
This commit is contained in:
@ -67,28 +67,6 @@ void Foam::writeRegisteredObject::read(const dictionary& dict)
|
|||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
dict.lookup("objectNames") >> objectNames_;
|
dict.lookup("objectNames") >> objectNames_;
|
||||||
|
|
||||||
forAll(objectNames_, i)
|
|
||||||
{
|
|
||||||
if (obr_.foundObject<regIOobject>(objectNames_[i]))
|
|
||||||
{
|
|
||||||
regIOobject& obj =
|
|
||||||
const_cast<regIOobject&>
|
|
||||||
(
|
|
||||||
obr_.lookupObject<regIOobject>(objectNames_[i])
|
|
||||||
);
|
|
||||||
obj.writeOpt() = IOobject::NO_WRITE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorIn
|
|
||||||
(
|
|
||||||
"Foam::writeRegisteredObject::read(const dictionary&)"
|
|
||||||
) << "Object " << objectNames_[i] << " not found in "
|
|
||||||
<< "database. Available objects are:" << nl << obr_.toc()
|
|
||||||
<< nl << exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +89,27 @@ void Foam::writeRegisteredObject::write()
|
|||||||
{
|
{
|
||||||
forAll(objectNames_, i)
|
forAll(objectNames_, i)
|
||||||
{
|
{
|
||||||
const regIOobject& obj =
|
if (obr_.foundObject<regIOobject>(objectNames_[i]))
|
||||||
obr_.lookupObject<regIOobject>(objectNames_[i]);
|
{
|
||||||
obj.write();
|
regIOobject& obj =
|
||||||
|
const_cast<regIOobject&>
|
||||||
|
(
|
||||||
|
obr_.lookupObject<regIOobject>(objectNames_[i])
|
||||||
|
);
|
||||||
|
// Switch off automatic writing to prevent double write
|
||||||
|
obj.writeOpt() = IOobject::NO_WRITE;
|
||||||
|
obj.write();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"Foam::writeRegisteredObject::read(const dictionary&)"
|
||||||
|
) << "Object " << objectNames_[i] << " not found in "
|
||||||
|
<< "database. Available objects are:" << nl << obr_.toc()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,13 +45,14 @@ namespace Foam
|
|||||||
fieldValues::cellSource::sourceTypeNames_;
|
fieldValues::cellSource::sourceTypeNames_;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* NamedEnum<fieldValues::cellSource::operationType, 5>::
|
const char* NamedEnum<fieldValues::cellSource::operationType, 7>::
|
||||||
names[] =
|
names[] =
|
||||||
{
|
{
|
||||||
"none", "sum", "volAverage", "volIntegrate", "weightedAverage"
|
"none", "sum", "volAverage",
|
||||||
|
"volIntegrate", "weightedAverage", "min", "max"
|
||||||
};
|
};
|
||||||
|
|
||||||
const NamedEnum<fieldValues::cellSource::operationType, 5>
|
const NamedEnum<fieldValues::cellSource::operationType, 7>
|
||||||
fieldValues::cellSource::operationTypeNames_;
|
fieldValues::cellSource::operationTypeNames_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,11 +103,13 @@ public:
|
|||||||
opSum,
|
opSum,
|
||||||
opVolAverage,
|
opVolAverage,
|
||||||
opVolIntegrate,
|
opVolIntegrate,
|
||||||
opWeightedAverage
|
opWeightedAverage,
|
||||||
|
opMin,
|
||||||
|
opMax
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
static const NamedEnum<operationType, 7> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -91,6 +91,16 @@ Type Foam::fieldValues::cellSource::processValues
|
|||||||
result = sum(values*weightField)/sum(weightField);
|
result = sum(values*weightField)/sum(weightField);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case opMin:
|
||||||
|
{
|
||||||
|
result = min(values);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case opMax:
|
||||||
|
{
|
||||||
|
result = max(values);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
@ -51,14 +51,23 @@ functions
|
|||||||
{
|
{
|
||||||
type faceSource;
|
type faceSource;
|
||||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
enabled true;
|
enabled true;
|
||||||
outputControl outputTime;
|
outputControl outputTime;
|
||||||
|
|
||||||
|
// Output to log&file (true) or to file only
|
||||||
log true;
|
log true;
|
||||||
|
|
||||||
|
// Output field values as well
|
||||||
valueOutput true;
|
valueOutput true;
|
||||||
|
|
||||||
|
// Patch or faceZone to sample
|
||||||
source patch;
|
source patch;
|
||||||
sourceName movingWall;
|
sourceName movingWall;
|
||||||
// source faceZone;
|
// source faceZone;
|
||||||
// sourceName f0;
|
// sourceName f0;
|
||||||
|
|
||||||
|
// Operation: areaAverage/sum/weightedAverage ...
|
||||||
operation areaAverage;
|
operation areaAverage;
|
||||||
fields
|
fields
|
||||||
(
|
(
|
||||||
|
|||||||
@ -49,13 +49,14 @@ namespace Foam
|
|||||||
fieldValues::faceSource::sourceTypeNames_;
|
fieldValues::faceSource::sourceTypeNames_;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* NamedEnum<fieldValues::faceSource::operationType, 5>::
|
const char* NamedEnum<fieldValues::faceSource::operationType, 7>::
|
||||||
names[] =
|
names[] =
|
||||||
{
|
{
|
||||||
"none", "sum", "areaAverage", "areaIntegrate", "weightedAverage"
|
"none", "sum", "areaAverage",
|
||||||
|
"areaIntegrate", "weightedAverage", "min", "max"
|
||||||
};
|
};
|
||||||
|
|
||||||
const NamedEnum<fieldValues::faceSource::operationType, 5>
|
const NamedEnum<fieldValues::faceSource::operationType, 7>
|
||||||
fieldValues::faceSource::operationTypeNames_;
|
fieldValues::faceSource::operationTypeNames_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,11 +106,13 @@ public:
|
|||||||
opSum,
|
opSum,
|
||||||
opAreaAverage,
|
opAreaAverage,
|
||||||
opAreaIntegrate,
|
opAreaIntegrate,
|
||||||
opWeightedAverage
|
opWeightedAverage,
|
||||||
|
opMin,
|
||||||
|
opMax
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Operation type names
|
//- Operation type names
|
||||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
static const NamedEnum<operationType, 7> operationTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -103,6 +103,16 @@ Type Foam::fieldValues::faceSource::processValues
|
|||||||
result = sum(values*weightField)/sum(weightField);
|
result = sum(values*weightField)/sum(weightField);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case opMin:
|
||||||
|
{
|
||||||
|
result = min(values);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case opMax:
|
||||||
|
{
|
||||||
|
result = max(values);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
@ -89,14 +89,29 @@ void Foam::readFields::read(const dictionary& dict)
|
|||||||
|
|
||||||
void Foam::readFields::execute()
|
void Foam::readFields::execute()
|
||||||
{
|
{
|
||||||
Info<< type() << " " << name_ << ":" << nl;
|
//Info<< type() << " " << name_ << ":" << nl;
|
||||||
|
|
||||||
|
// Clear out any previously loaded fields
|
||||||
|
vsf_.clear();
|
||||||
|
vvf_.clear();
|
||||||
|
vSpheretf_.clear();
|
||||||
|
vSymmtf_.clear();
|
||||||
|
vtf_.clear();
|
||||||
|
|
||||||
|
ssf_.clear();
|
||||||
|
svf_.clear();
|
||||||
|
sSpheretf_.clear();
|
||||||
|
sSymmtf_.clear();
|
||||||
|
stf_.clear();
|
||||||
|
|
||||||
forAll(fieldSet_, fieldI)
|
forAll(fieldSet_, fieldI)
|
||||||
{
|
{
|
||||||
setField<scalar>(fieldSet_[fieldI]);
|
// If necessary load field
|
||||||
setField<vector>(fieldSet_[fieldI]);
|
loadField<scalar>(fieldSet_[fieldI], vsf_, ssf_);
|
||||||
setField<sphericalTensor>(fieldSet_[fieldI]);
|
loadField<vector>(fieldSet_[fieldI], vvf_, svf_);
|
||||||
setField<symmTensor>(fieldSet_[fieldI]);
|
loadField<sphericalTensor>(fieldSet_[fieldI], vSpheretf_, sSpheretf_);
|
||||||
setField<tensor>(fieldSet_[fieldI]);
|
loadField<symmTensor>(fieldSet_[fieldI], vSymmtf_, sSymmtf_);
|
||||||
|
loadField<tensor>(fieldSet_[fieldI], vtf_, stf_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "pointFieldFwd.H"
|
#include "pointFieldFwd.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -68,9 +70,22 @@ protected:
|
|||||||
//- on/off switch
|
//- on/off switch
|
||||||
bool active_;
|
bool active_;
|
||||||
|
|
||||||
//- Fields to assess min/max
|
//- Fields to load
|
||||||
wordList fieldSet_;
|
wordList fieldSet_;
|
||||||
|
|
||||||
|
//- Loaded fields
|
||||||
|
PtrList<volScalarField> vsf_;
|
||||||
|
PtrList<volVectorField> vvf_;
|
||||||
|
PtrList<volSphericalTensorField> vSpheretf_;
|
||||||
|
PtrList<volSymmTensorField> vSymmtf_;
|
||||||
|
PtrList<volTensorField> vtf_;
|
||||||
|
|
||||||
|
PtrList<surfaceScalarField> ssf_;
|
||||||
|
PtrList<surfaceVectorField> svf_;
|
||||||
|
PtrList<surfaceSphericalTensorField> sSpheretf_;
|
||||||
|
PtrList<surfaceSymmTensorField> sSymmtf_;
|
||||||
|
PtrList<surfaceTensorField> stf_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
@ -81,7 +96,12 @@ protected:
|
|||||||
void operator=(const readFields&);
|
void operator=(const readFields&);
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void setField(const word& fieldName);
|
void loadField
|
||||||
|
(
|
||||||
|
const word&,
|
||||||
|
PtrList<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||||
|
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -31,7 +31,12 @@ License
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::readFields::setField(const word& fieldName)
|
void Foam::readFields::loadField
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
PtrList<GeometricField<Type, fvPatchField, volMesh> >& vflds,
|
||||||
|
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& sflds
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
|
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
|
||||||
@ -40,53 +45,55 @@ void Foam::readFields::setField(const word& fieldName)
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Field " << fieldName << " already in database" << endl;
|
Info<< "readFields : Field " << fieldName << " already in database"
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfType& vf = const_cast<vfType&>(obr_.lookupObject<vfType>(fieldName));
|
|
||||||
vf.checkOut();
|
|
||||||
}
|
}
|
||||||
if (obr_.foundObject<sfType>(fieldName))
|
else if (obr_.foundObject<sfType>(fieldName))
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Field " << fieldName << " already in database" << endl;
|
Info<< "readFields : Field " << fieldName << " already in database"
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
sfType& sf = const_cast<sfType&>(obr_.lookupObject<sfType>(fieldName));
|
|
||||||
sf.checkOut();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
|
||||||
|
|
||||||
IOobject fieldHeader
|
|
||||||
(
|
|
||||||
fieldName,
|
|
||||||
mesh.time().timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
);
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
fieldHeader.headerOk()
|
|
||||||
&& fieldHeader.headerClassName() == vfType::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// store field on the mesh database
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
Info<< " Reading " << fieldName << endl;
|
|
||||||
obr_.store(new vfType(fieldHeader, mesh));
|
IOobject fieldHeader
|
||||||
}
|
(
|
||||||
else if
|
fieldName,
|
||||||
(
|
mesh.time().timeName(),
|
||||||
fieldHeader.headerOk()
|
mesh,
|
||||||
&& fieldHeader.headerClassName() == sfType::typeName
|
IOobject::MUST_READ,
|
||||||
)
|
IOobject::NO_WRITE
|
||||||
{
|
);
|
||||||
// store field on the mesh database
|
|
||||||
Info<< " Reading " << fieldName << endl;
|
if
|
||||||
obr_.store(new sfType(fieldHeader, mesh));
|
(
|
||||||
|
fieldHeader.headerOk()
|
||||||
|
&& fieldHeader.headerClassName() == vfType::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// store field locally
|
||||||
|
Info<< " Reading " << fieldName << endl;
|
||||||
|
label sz = vflds.size();
|
||||||
|
vflds.setSize(sz+1);
|
||||||
|
vflds.set(sz, new vfType(fieldHeader, mesh));
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldHeader.headerOk()
|
||||||
|
&& fieldHeader.headerClassName() == sfType::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// store field locally
|
||||||
|
Info<< " Reading " << fieldName << endl;
|
||||||
|
label sz = sflds.size();
|
||||||
|
sflds.setSize(sz+1);
|
||||||
|
sflds.set(sz, new sfType(fieldHeader, mesh));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,49 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
||||||
|
|
||||||
|
Typedef
|
||||||
|
Foam::IOsurfaceInterpolateFields
|
||||||
|
|
||||||
|
Description
|
||||||
|
Instance of the generic IOOutputFilter for surfaceInterpolateFields.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef IOsurfaceInterpolateFields_H
|
||||||
|
#define IOsurfaceInterpolateFields_H
|
||||||
|
|
||||||
|
#include "surfaceInterpolateFields.H"
|
||||||
|
#include "IOOutputFilter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
typedef IOOutputFilter<surfaceInterpolateFields> IOsurfaceInterpolateFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,121 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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 "surfaceInterpolateFields.H"
|
||||||
|
//#include "dictionary.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(surfaceInterpolateFields, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::surfaceInterpolateFields::surfaceInterpolateFields
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool loadFromFiles
|
||||||
|
)
|
||||||
|
:
|
||||||
|
name_(name),
|
||||||
|
obr_(obr),
|
||||||
|
active_(true),
|
||||||
|
fieldSet_()
|
||||||
|
{
|
||||||
|
// Check if the available mesh is an fvMesh otherise deactivate
|
||||||
|
if (!isA<fvMesh>(obr_))
|
||||||
|
{
|
||||||
|
active_ = false;
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"surfaceInterpolateFields::surfaceInterpolateFields"
|
||||||
|
"("
|
||||||
|
"const word&, "
|
||||||
|
"const objectRegistry&, "
|
||||||
|
"const dictionary&, "
|
||||||
|
"const bool"
|
||||||
|
")"
|
||||||
|
) << "No fvMesh available, deactivating."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
read(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::surfaceInterpolateFields::~surfaceInterpolateFields()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::surfaceInterpolateFields::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (active_)
|
||||||
|
{
|
||||||
|
dict.lookup("fields") >> fieldSet_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::surfaceInterpolateFields::execute()
|
||||||
|
{
|
||||||
|
//Info<< type() << " " << name_ << ":" << nl;
|
||||||
|
|
||||||
|
// Clear out any previously loaded fields
|
||||||
|
ssf_.clear();
|
||||||
|
svf_.clear();
|
||||||
|
sSpheretf_.clear();
|
||||||
|
sSymmtf_.clear();
|
||||||
|
stf_.clear();
|
||||||
|
|
||||||
|
interpolateFields<scalar>(ssf_);
|
||||||
|
interpolateFields<vector>(svf_);
|
||||||
|
interpolateFields<sphericalTensor>(sSpheretf_);
|
||||||
|
interpolateFields<symmTensor>(sSymmtf_);
|
||||||
|
interpolateFields<tensor>(stf_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::surfaceInterpolateFields::end()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::surfaceInterpolateFields::write()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,167 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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::surfaceInterpolateFields
|
||||||
|
|
||||||
|
Description
|
||||||
|
Reads fields from the time folders and adds them to the mesh database
|
||||||
|
for further post-processing.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
surfaceInterpolateFields.C
|
||||||
|
IOsurfaceInterpolateFields.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef surfaceInterpolateFields_H
|
||||||
|
#define surfaceInterpolateFields_H
|
||||||
|
|
||||||
|
#include "OFstream.H"
|
||||||
|
//#include "pointFieldFwd.H"
|
||||||
|
#include "surfaceFields.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
class objectRegistry;
|
||||||
|
class dictionary;
|
||||||
|
class mapPolyMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class surfaceInterpolateFields Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class surfaceInterpolateFields
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Name of this set of surfaceInterpolateFields object
|
||||||
|
word name_;
|
||||||
|
|
||||||
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
|
//- on/off switch
|
||||||
|
bool active_;
|
||||||
|
|
||||||
|
//- Fields to process
|
||||||
|
//wordList fieldSet_;
|
||||||
|
List<Tuple2<word, word> > fieldSet_;
|
||||||
|
|
||||||
|
//- Locally constructed fields
|
||||||
|
PtrList<surfaceScalarField> ssf_;
|
||||||
|
PtrList<surfaceVectorField> svf_;
|
||||||
|
PtrList<surfaceSphericalTensorField> sSpheretf_;
|
||||||
|
PtrList<surfaceSymmTensorField> sSymmtf_;
|
||||||
|
PtrList<surfaceTensorField> stf_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
surfaceInterpolateFields(const surfaceInterpolateFields&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const surfaceInterpolateFields&);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void interpolateFields
|
||||||
|
(
|
||||||
|
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("surfaceInterpolateFields");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct for given objectRegistry and dictionary.
|
||||||
|
// Allow the possibility to load fields from files
|
||||||
|
surfaceInterpolateFields
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const objectRegistry&,
|
||||||
|
const dictionary&,
|
||||||
|
const bool loadFromFiles = false
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~surfaceInterpolateFields();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return name of the surfaceInterpolateFields object
|
||||||
|
virtual const word& name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Read the field min/max data
|
||||||
|
virtual void read(const dictionary&);
|
||||||
|
|
||||||
|
//- Execute, currently does nothing
|
||||||
|
virtual void execute();
|
||||||
|
|
||||||
|
//- Execute at the final time-loop, currently does nothing
|
||||||
|
virtual void end();
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write();
|
||||||
|
|
||||||
|
//- Update for changes of mesh
|
||||||
|
virtual void updateMesh(const mapPolyMesh&)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Update for changes of mesh
|
||||||
|
virtual void movePoints(const pointField&)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "surfaceInterpolateFieldsTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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 "surfaceInterpolateFieldsFunctionObject.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineNamedTemplateTypeNameAndDebug(surfaceInterpolateFieldsFunctionObject, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
functionObject,
|
||||||
|
surfaceInterpolateFieldsFunctionObject,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
||||||
|
|
||||||
|
Typedef
|
||||||
|
Foam::surfaceInterpolateFieldsFunctionObject
|
||||||
|
|
||||||
|
Description
|
||||||
|
FunctionObject wrapper around surfaceInterpolateFields to allow them to be created via
|
||||||
|
the functions entry within controlDict.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
surfaceInterpolateFieldsFunctionObject.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef surfaceInterpolateFieldsFunctionObject_H
|
||||||
|
#define surfaceInterpolateFieldsFunctionObject_H
|
||||||
|
|
||||||
|
#include "surfaceInterpolateFields.H"
|
||||||
|
#include "OutputFilterFunctionObject.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
typedef OutputFilterFunctionObject<surfaceInterpolateFields>
|
||||||
|
surfaceInterpolateFieldsFunctionObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 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 "surfaceInterpolateFields.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "linear.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::surfaceInterpolateFields::interpolateFields
|
||||||
|
(
|
||||||
|
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& sflds
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
|
||||||
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
|
||||||
|
|
||||||
|
// Convert field to map
|
||||||
|
HashTable<word> fieldMap(2*fieldSet_.size());
|
||||||
|
forAll(fieldSet_, i)
|
||||||
|
{
|
||||||
|
fieldMap.insert(fieldSet_[i].first(), fieldSet_[i].second());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HashTable<const vfType*> flds(obr_.lookupClass<vfType>());
|
||||||
|
|
||||||
|
forAllConstIter(typename HashTable<const vfType*>, flds, iter)
|
||||||
|
{
|
||||||
|
const vfType& fld = *iter();
|
||||||
|
|
||||||
|
if (fieldMap.found(fld.name()))
|
||||||
|
{
|
||||||
|
//const word sName = "interpolate(" + fld.name() + ')';
|
||||||
|
const word& sName = fieldMap[fld.name()];
|
||||||
|
|
||||||
|
if (obr_.found(sName))
|
||||||
|
{
|
||||||
|
Info<< " a surfaceField " << sName << " already exists"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label sz = sflds.size();
|
||||||
|
sflds.setSize(sz+1);
|
||||||
|
sflds.set(sz, new sfType(sName, linearInterpolate(fld)));
|
||||||
|
|
||||||
|
Info<< " interpolated " << fld.name() << " to create "
|
||||||
|
<< sflds[sz].name() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user