functionObjects: rewritten to all be derived from 'functionObject'

- Avoids the need for the 'OutputFilterFunctionObject' wrapper
  - Time-control for execution and writing is now provided by the
    'timeControlFunctionObject' which instantiates the processing
    'functionObject' and controls its operation.
  - Alternative time-control functionObjects can now be written and
    selected at run-time without the need to compile wrapped version of
    EVERY existing functionObject which would have been required in the
    old structure.
  - The separation of 'execute' and 'write' functions is now formalized in the
    'functionObject' base-class and all derived classes implement the
    two functions.
  - Unnecessary implementations of functions with appropriate defaults
    in the 'functionObject' base-class have been removed reducing
    clutter and simplifying implementation of new functionObjects.
  - The 'coded' 'functionObject' has also been updated, simplified and tested.
  - Further simplification is now possible by creating some general
    intermediate classes derived from 'functionObject'.
This commit is contained in:
Henry Weller
2016-05-15 16:40:01 +01:00
parent ce0cd35185
commit 78d2971b21
230 changed files with 2731 additions and 8756 deletions

View File

@ -1,7 +1,6 @@
probes/probes.C
probes/patchProbes.C
probes/probesGrouping.C
probes/probesFunctionObject/probesFunctionObject.C
sampledSet/circle/circleSet.C
sampledSet/cloud/cloudSet.C
@ -14,7 +13,6 @@ sampledSet/patchSeed/patchSeedSet.C
sampledSet/sampledSet/sampledSet.C
sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSets/sampledSetsGrouping.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/triSurfaceMeshPointSet/triSurfaceMeshPointSet.C
sampledSet/uniform/uniformSet.C
sampledSet/array/arraySet.C
@ -33,7 +31,6 @@ sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
sampledSurface/thresholdCellFaces/thresholdCellFaces.C
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C

View File

@ -4,6 +4,7 @@ EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
@ -14,4 +15,5 @@ LIB_LIBS = \
-lfileFormats \
-ltriSurface \
-llagrangian \
-ldynamicMesh \
-lconversion

View File

@ -265,28 +265,34 @@ void Foam::meshToMesh::calculate(const word& methodName)
}
// set up as a reverse distribute
mapDistribute::distribute
mapDistributeBase::distribute
(
Pstream::nonBlocking,
List<labelPair>(),
tgtRegion_.nCells(),
map.constructMap(),
false,
map.subMap(),
false,
tgtToSrcCellAddr_,
ListPlusEqOp<label>(),
flipOp(),
labelList()
);
// set up as a reverse distribute
mapDistribute::distribute
mapDistributeBase::distribute
(
Pstream::nonBlocking,
List<labelPair>(),
tgtRegion_.nCells(),
map.constructMap(),
false,
map.subMap(),
false,
tgtToSrcCellWght_,
ListPlusEqOp<scalar>(),
flipOp(),
scalarList()
);

View File

@ -29,12 +29,21 @@ License
#include "mappedPatchBase.H"
#include "treeBoundBox.H"
#include "treeDataFace.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(patchProbes, 0);
addToRunTimeSelectionTable
(
functionObject,
patchProbes,
dictionary
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -181,6 +190,26 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchProbes::patchProbes
(
const word& name,
const Time& t,
const dictionary& dict
)
:
probes(name, t, dict)
{
// When constructing probes above it will have called the
// probes::findElements (since the virtual mechanism not yet operating).
// Not easy to workaround (apart from feeding through flag into constructor)
// so clear out any cells found for now.
elementList_.clear();
faceList_.clear();
read(dict);
}
Foam::patchProbes::patchProbes
(
const word& name,
@ -189,7 +218,7 @@ Foam::patchProbes::patchProbes
const bool loadFromFiles
)
:
probes(name, obr, dict, loadFromFiles)
probes(name, obr, dict)
{
// When constructing probes above it will have called the
// probes::findElements (since the virtual mechanism not yet operating).
@ -208,7 +237,7 @@ Foam::patchProbes::~patchProbes()
{}
void Foam::patchProbes::write()
bool Foam::patchProbes::write()
{
if (this->size() && prepare())
{
@ -224,12 +253,15 @@ void Foam::patchProbes::write()
sampleAndWriteSurfaceFields(surfaceSymmTensorFields_);
sampleAndWriteSurfaceFields(surfaceTensorFields_);
}
return true;
}
void Foam::patchProbes::read(const dictionary& dict)
bool Foam::patchProbes::read(const dictionary& dict)
{
dict.lookup("patchName") >> patchName_;
probes::read(dict);
return probes::read(dict);
}

View File

@ -128,6 +128,14 @@ public:
// Constructors
//- Construct from Time and dictionary
patchProbes
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
patchProbes
@ -146,15 +154,16 @@ public:
//- Public members
//- Sample and write
virtual void write();
virtual bool write();
//- Read
virtual void read(const dictionary&);
virtual bool read(const dictionary&);
//- Find elements containing patchProbes
virtual void findElements(const fvMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -29,12 +29,20 @@ License
#include "Time.H"
#include "IOmanip.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(probes, 0);
addToRunTimeSelectionTable
(
functionObject,
probes,
dictionary
);
}
@ -187,7 +195,7 @@ Foam::label Foam::probes::prepare()
fileName probeDir;
fileName probeSubDir = name_;
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
@ -267,6 +275,34 @@ Foam::label Foam::probes::prepare()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::probes::probes
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(name),
pointField(0),
mesh_
(
refCast<const fvMesh>
(
t.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
),
loadFromFiles_(false),
fieldSelection_(),
fixedLocations_(true),
interpolationScheme_("cell")
{
read(dict);
}
Foam::probes::probes
(
const word& name,
@ -275,8 +311,8 @@ Foam::probes::probes
const bool loadFromFiles
)
:
functionObject(name),
pointField(0),
name_(name),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
fieldSelection_(),
@ -295,38 +331,7 @@ Foam::probes::~probes()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::probes::execute()
{}
void Foam::probes::end()
{}
void Foam::probes::timeSet()
{}
void Foam::probes::write()
{
if (size() && prepare())
{
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
sampleAndWrite(symmTensorFields_);
sampleAndWrite(tensorFields_);
sampleAndWriteSurfaceFields(surfaceScalarFields_);
sampleAndWriteSurfaceFields(surfaceVectorFields_);
sampleAndWriteSurfaceFields(surfaceSphericalTensorFields_);
sampleAndWriteSurfaceFields(surfaceSymmTensorFields_);
sampleAndWriteSurfaceFields(surfaceTensorFields_);
}
}
void Foam::probes::read(const dictionary& dict)
bool Foam::probes::read(const dictionary& dict)
{
dict.lookup("probeLocations") >> *this;
dict.lookup("fields") >> fieldSelection_;
@ -347,6 +352,35 @@ void Foam::probes::read(const dictionary& dict)
findElements(mesh_);
prepare();
return true;
}
bool Foam::probes::execute(const bool postProcess)
{
return true;
}
bool Foam::probes::write(const bool postProcess)
{
if (size() && prepare())
{
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
sampleAndWrite(symmTensorFields_);
sampleAndWrite(tensorFields_);
sampleAndWriteSurfaceFields(surfaceScalarFields_);
sampleAndWriteSurfaceFields(surfaceVectorFields_);
sampleAndWriteSurfaceFields(surfaceSphericalTensorFields_);
sampleAndWriteSurfaceFields(surfaceSymmTensorFields_);
sampleAndWriteSurfaceFields(surfaceTensorFields_);
}
return true;
}

View File

@ -40,6 +40,7 @@ SourceFiles
#ifndef probes_H
#define probes_H
#include "functionObject.H"
#include "HashPtrTable.H"
#include "OFstream.H"
#include "polyMesh.H"
@ -55,6 +56,7 @@ namespace Foam
{
// Forward declaration of classes
class Time;
class objectRegistry;
class dictionary;
class fvMesh;
@ -66,6 +68,7 @@ class mapPolyMesh;
class probes
:
public functionObject,
public pointField
{
protected:
@ -89,10 +92,6 @@ protected:
// Private data
//- Name of this set of probes,
// Also used as the name of the probes directory.
word name_;
//- Const reference to fvMesh
const fvMesh& mesh_;
@ -200,13 +199,21 @@ public:
// Constructors
//- Construct from Time and dictionary
probes
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
probes
(
const word& name,
const objectRegistry&,
const dictionary&,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles = false
);
@ -217,12 +224,6 @@ public:
// Member Functions
//- Return name of the set of probes
virtual const word& name() const
{
return name_;
}
//- Return names of fields to probe
virtual const wordReList& fieldNames() const
{
@ -247,20 +248,14 @@ public:
return elementList_;
}
//- Read the probes
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute(const bool postProcess = false);
//- Sample and write
virtual void write();
//- Read the probes
virtual void read(const dictionary&);
virtual bool write(const bool postProcess = false);
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&);

View File

@ -1,49 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 "probesFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(probesFunctionObject, 0);
defineNamedTemplateTypeNameAndDebug(patchProbesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
probesFunctionObject,
dictionary
);
addToRunTimeSelectionTable
(
functionObject,
patchProbesFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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::probesFunctionObject
Description
FunctionObject wrapper around probes to allow them to be created via the
functions entry within controlDict.
SourceFiles
probesFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef probesFunctionObject_H
#define probesFunctionObject_H
#include "probes.H"
#include "patchProbes.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<probes> probesFunctionObject;
typedef OutputFilterFunctionObject<patchProbes> patchProbesFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -31,6 +31,7 @@ License
#include "SortableList.H"
#include "volPointInterpolation.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,9 +39,16 @@ namespace Foam
{
defineTypeNameAndDebug(sampledSets, 0);
bool sampledSets::verbose_ = false;
addToRunTimeSelectionTable
(
functionObject,
sampledSets,
dictionary
);
}
bool Foam::sampledSets::verbose_ = false;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -130,6 +138,48 @@ void Foam::sampledSets::combineSampledSets
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSets::sampledSets
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(name),
PtrList<sampledSet>(),
mesh_
(
refCast<const fvMesh>
(
t.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
),
loadFromFiles_(false),
outputPath_(fileName::null),
searchEngine_(mesh_),
interpolationScheme_(word::null),
writeFormat_(word::null)
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath_ = outputPath_/mesh_.name();
}
read(dict);
}
Foam::sampledSets::sampledSets
(
const word& name,
@ -138,8 +188,8 @@ Foam::sampledSets::sampledSets
const bool loadFromFiles
)
:
functionObject(name),
PtrList<sampledSet>(),
name_(name),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
outputPath_(fileName::null),
@ -149,11 +199,11 @@ Foam::sampledSets::sampledSets
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_;
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name_;
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion)
{
@ -178,19 +228,13 @@ void Foam::sampledSets::verbose(const bool verbosity)
}
void Foam::sampledSets::execute()
{}
bool Foam::sampledSets::execute(const bool postProcess)
{
return true;
}
void Foam::sampledSets::end()
{}
void Foam::sampledSets::timeSet()
{}
void Foam::sampledSets::write()
bool Foam::sampledSets::write(const bool postProcess)
{
if (size())
{
@ -230,10 +274,12 @@ void Foam::sampledSets::write()
sampleAndWrite(tensorFields_);
}
}
return true;
}
void Foam::sampledSets::read(const dictionary& dict)
bool Foam::sampledSets::read(const dictionary& dict)
{
dict_ = dict;
@ -276,6 +322,8 @@ void Foam::sampledSets::read(const dictionary& dict)
}
Pout<< ")" << endl;
}
return true;
}

View File

@ -36,6 +36,7 @@ SourceFiles
#ifndef sampledSets_H
#define sampledSets_H
#include "functionObject.H"
#include "sampledSet.H"
#include "volFieldsFwd.H"
#include "meshSearch.H"
@ -49,6 +50,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class Time;
class objectRegistry;
class dictionary;
class fvMesh;
@ -59,6 +62,7 @@ class fvMesh;
class sampledSets
:
public functionObject,
public PtrList<sampledSet>
{
// Private classes
@ -153,10 +157,6 @@ class sampledSets
// Private data
//- Name of this set of sets,
// Also used as the name of the sampledSets directory.
word name_;
//- Const reference to fvMesh
const fvMesh& mesh_;
@ -256,6 +256,14 @@ public:
// Constructors
//- Construct from Time and dictionary
sampledSets
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary
// allow the possibility to load fields from files
sampledSets
@ -273,29 +281,17 @@ public:
// Member Functions
//- Return name of the set of probes
virtual const word& name() const
{
return name_;
}
//- Set verbosity level
void verbose(const bool verbosity = true);
//- Read the sampledSets
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute(const bool postProcess = false);
//- Sample and write
virtual void write();
//- Read the sampledSets
virtual void read(const dictionary&);
virtual bool write(const bool postProcess = false);
//- Correct for mesh changes
void correct();

View File

@ -1,34 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
functions
{
// Example of sampling on a line
lines
{
type sets;
functionObjectLibs ("libsampling.so");
writeControl writeTime;
setFormat gnuplot;
fields (p U);
interpolationScheme cellPoint;
sets
(
diagonal
{
type midPoint;
axis x;
start (-0.0206 -0.0254 -0.0005);
end (0.29 0.0254 0.0005);
}
);
}
}

View File

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 "sampledSetsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(sampledSetsFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSetsFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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::sampledSetsFunctionObject
Description
FunctionObject wrapper around sets to allow them to be created via the
functions entry within controlDict.
SourceFiles
sampledSetsFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSetsFunctionObject_H
#define sampledSetsFunctionObject_H
#include "sampledSets.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<sampledSets>
sampledSetsFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -31,12 +31,20 @@ License
#include "volPointInterpolation.H"
#include "PatchTools.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledSurfaces, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSurfaces,
dictionary
);
}
bool Foam::sampledSurfaces::verbose_ = false;
@ -85,6 +93,45 @@ void Foam::sampledSurfaces::writeGeometry() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSurfaces::sampledSurfaces
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(name),
PtrList<sampledSurface>(),
mesh_
(
refCast<const fvMesh>
(
t.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
),
loadFromFiles_(false),
outputPath_(fileName::null),
fieldSelection_(),
interpolationScheme_(word::null),
mergeList_(),
formatter_(NULL)
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
read(dict);
}
Foam::sampledSurfaces::sampledSurfaces
(
const word& name,
@ -93,8 +140,8 @@ Foam::sampledSurfaces::sampledSurfaces
const bool loadFromFiles
)
:
functionObject(name),
PtrList<sampledSurface>(),
name_(name),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
outputPath_(fileName::null),
@ -105,11 +152,11 @@ Foam::sampledSurfaces::sampledSurfaces
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_;
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name_;
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
read(dict);
@ -130,19 +177,13 @@ void Foam::sampledSurfaces::verbose(const bool verbosity)
}
void Foam::sampledSurfaces::execute()
{}
bool Foam::sampledSurfaces::execute(const bool postProcess)
{
return true;
}
void Foam::sampledSurfaces::end()
{}
void Foam::sampledSurfaces::timeSet()
{}
void Foam::sampledSurfaces::write()
bool Foam::sampledSurfaces::write(const bool postProcess)
{
if (size())
{
@ -184,10 +225,12 @@ void Foam::sampledSurfaces::write()
sampleAndWrite<surfaceSymmTensorField>(objects);
sampleAndWrite<surfaceTensorField>(objects);
}
return true;
}
void Foam::sampledSurfaces::read(const dictionary& dict)
bool Foam::sampledSurfaces::read(const dictionary& dict)
{
bool surfacesFound = dict.found("surfaces");
@ -243,6 +286,8 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
}
Pout<< ")" << endl;
}
return true;
}

View File

@ -37,6 +37,7 @@ SourceFiles
#ifndef sampledSurfaces_H
#define sampledSurfaces_H
#include "functionObject.H"
#include "sampledSurface.H"
#include "surfaceWriter.H"
#include "volFieldsFwd.H"
@ -49,6 +50,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class Time;
class fvMesh;
class dictionary;
@ -58,11 +61,11 @@ class dictionary;
class sampledSurfaces
:
public functionObject,
public PtrList<sampledSurface>
{
// Private classes
//- Class used for surface merging information
class mergeInfo
{
@ -92,10 +95,6 @@ class sampledSurfaces
// Private data
//- Name of this set of surfaces,
// Also used as the name of the sampledSurfaces directory.
const word name_;
//- Const reference to fvMesh
const fvMesh& mesh_;
@ -176,6 +175,14 @@ public:
// Constructors
//- Construct from Time and dictionary
sampledSurfaces
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary
// allow the possibility to load fields from files
sampledSurfaces
@ -205,30 +212,17 @@ public:
// Return false if no surfaces required an update.
virtual bool update();
//- Return name of the set of surfaces
virtual const word& name() const
{
return name_;
}
//- Set verbosity level
void verbose(const bool verbosity = true);
//- Read the sampledSurfaces dictionary
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute(const bool postProcess = false);
//- Sample and write
virtual void write();
//- Read the sampledSurfaces dictionary
virtual void read(const dictionary&);
virtual bool write(const bool postProcess = false);
//- Update for changes of mesh - expires the surfaces
virtual void updateMesh(const mapPolyMesh&);

View File

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 "sampledSurfacesFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(sampledSurfacesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSurfacesFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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::sampledSurfacesFunctionObject
Description
FunctionObject wrapper around surfaces to allow them to be created via the
functions entry within controlDict.
SourceFiles
sampledSurfacesFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSurfacesFunctionObject_H
#define sampledSurfacesFunctionObject_H
#include "sampledSurfaces.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<sampledSurfaces>
sampledSurfacesFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //