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_)
|
||||
{
|
||||
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,10 +89,28 @@ void Foam::writeRegisteredObject::write()
|
||||
{
|
||||
forAll(objectNames_, i)
|
||||
{
|
||||
const regIOobject& obj =
|
||||
obr_.lookupObject<regIOobject>(objectNames_[i]);
|
||||
if (obr_.foundObject<regIOobject>(objectNames_[i]))
|
||||
{
|
||||
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_;
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fieldValues::cellSource::operationType, 5>::
|
||||
const char* NamedEnum<fieldValues::cellSource::operationType, 7>::
|
||||
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_;
|
||||
|
||||
}
|
||||
|
||||
@ -103,11 +103,13 @@ public:
|
||||
opSum,
|
||||
opVolAverage,
|
||||
opVolIntegrate,
|
||||
opWeightedAverage
|
||||
opWeightedAverage,
|
||||
opMin,
|
||||
opMax
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 7> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -91,6 +91,16 @@ Type Foam::fieldValues::cellSource::processValues
|
||||
result = sum(values*weightField)/sum(weightField);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = min(values);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = max(values);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Do nothing
|
||||
|
||||
@ -51,14 +51,23 @@ functions
|
||||
{
|
||||
type faceSource;
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
|
||||
enabled true;
|
||||
outputControl outputTime;
|
||||
|
||||
// Output to log&file (true) or to file only
|
||||
log true;
|
||||
|
||||
// Output field values as well
|
||||
valueOutput true;
|
||||
|
||||
// Patch or faceZone to sample
|
||||
source patch;
|
||||
sourceName movingWall;
|
||||
// source faceZone;
|
||||
// sourceName f0;
|
||||
|
||||
// Operation: areaAverage/sum/weightedAverage ...
|
||||
operation areaAverage;
|
||||
fields
|
||||
(
|
||||
|
||||
@ -49,13 +49,14 @@ namespace Foam
|
||||
fieldValues::faceSource::sourceTypeNames_;
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fieldValues::faceSource::operationType, 5>::
|
||||
const char* NamedEnum<fieldValues::faceSource::operationType, 7>::
|
||||
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_;
|
||||
|
||||
}
|
||||
|
||||
@ -106,11 +106,13 @@ public:
|
||||
opSum,
|
||||
opAreaAverage,
|
||||
opAreaIntegrate,
|
||||
opWeightedAverage
|
||||
opWeightedAverage,
|
||||
opMin,
|
||||
opMax
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 5> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 7> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -103,6 +103,16 @@ Type Foam::fieldValues::faceSource::processValues
|
||||
result = sum(values*weightField)/sum(weightField);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = min(values);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = max(values);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Do nothing
|
||||
|
||||
@ -89,14 +89,29 @@ void Foam::readFields::read(const dictionary& dict)
|
||||
|
||||
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)
|
||||
{
|
||||
setField<scalar>(fieldSet_[fieldI]);
|
||||
setField<vector>(fieldSet_[fieldI]);
|
||||
setField<sphericalTensor>(fieldSet_[fieldI]);
|
||||
setField<symmTensor>(fieldSet_[fieldI]);
|
||||
setField<tensor>(fieldSet_[fieldI]);
|
||||
// If necessary load field
|
||||
loadField<scalar>(fieldSet_[fieldI], vsf_, ssf_);
|
||||
loadField<vector>(fieldSet_[fieldI], vvf_, svf_);
|
||||
loadField<sphericalTensor>(fieldSet_[fieldI], vSpheretf_, sSpheretf_);
|
||||
loadField<symmTensor>(fieldSet_[fieldI], vSymmtf_, sSymmtf_);
|
||||
loadField<tensor>(fieldSet_[fieldI], vtf_, stf_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ SourceFiles
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -68,9 +70,22 @@ protected:
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Fields to assess min/max
|
||||
//- Fields to load
|
||||
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
|
||||
|
||||
@ -81,7 +96,12 @@ protected:
|
||||
void operator=(const readFields&);
|
||||
|
||||
template<class Type>
|
||||
void setField(const word& fieldName);
|
||||
void loadField
|
||||
(
|
||||
const word&,
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -31,7 +31,12 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
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, fvsPatchField, surfaceMesh> sfType;
|
||||
@ -40,23 +45,20 @@ void Foam::readFields::setField(const word& fieldName)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
@ -74,9 +76,11 @@ void Foam::readFields::setField(const word& fieldName)
|
||||
&& fieldHeader.headerClassName() == vfType::typeName
|
||||
)
|
||||
{
|
||||
// store field on the mesh database
|
||||
// store field locally
|
||||
Info<< " Reading " << fieldName << endl;
|
||||
obr_.store(new vfType(fieldHeader, mesh));
|
||||
label sz = vflds.size();
|
||||
vflds.setSize(sz+1);
|
||||
vflds.set(sz, new vfType(fieldHeader, mesh));
|
||||
}
|
||||
else if
|
||||
(
|
||||
@ -84,9 +88,12 @@ void Foam::readFields::setField(const word& fieldName)
|
||||
&& fieldHeader.headerClassName() == sfType::typeName
|
||||
)
|
||||
{
|
||||
// store field on the mesh database
|
||||
// store field locally
|
||||
Info<< " Reading " << fieldName << endl;
|
||||
obr_.store(new sfType(fieldHeader, mesh));
|
||||
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