Commit 8bcbf353 authored by henry's avatar henry
Browse files

Update sampling to include surface and line sampling functionObjects

parent cd161a33
probes/probes.C
probes/probesFunctionObject.C
sampledSet/coordSet/coordSet.C
sampledSet/sampledSet/sampledSet.C
sampledSet/cloud/cloudSet.C
sampledSet/face/faceOnlySet.C
sampledSet/curve/curveSet.C
sampledSet/uniform/uniformSet.C
sampledSet/midPoint/midPointSet.C
sampledSet/midPointAndFace/midPointAndFaceSet.C
sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/writers/writer/writers.C
sampledSet/writers/xmgr/xmgrWriters.C
sampledSet/writers/gnuplot/gnuplotWriters.C
sampledSet/writers/jplot/jplotWriters.C
sampledSet/writers/raw/rawWriters.C
cuttingPlane/cuttingPlane.C
sampledSurface/patch/sampledPatch.C
sampledSurface/plane/sampledPlane.C
sampledSurface/surface/sampledSurface.C
sampledSurface/surfaces/sampledSurfaces.C
sampledSurface/surfacesFunctionObject/surfacesFunctionObject.C
surfaceWriters/surfaceWriters.C
surfaceWriters/foamFile/foamFileWriters.C
surfaceWriters/dx/dxWriters.C
surfaceWriters/raw/rawWriters.C
surfaceWriters/vtk/vtkWriters.C
surfaceWriters/stl/stlWriters.C
surfaceWriters/null/nullWriters.C
sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
sampledSurface/writers/surfaceWriters.C
sampledSurface/writers/foamFile/foamFileWriters.C
sampledSurface/writers/dx/dxWriters.C
sampledSurface/writers/raw/rawSurfaceWriters.C
sampledSurface/writers/vtk/vtkWriters.C
sampledSurface/writers/stl/stlWriters.C
sampledSurface/writers/null/nullWriters.C
graphField/writePatchGraph.C
graphField/writeCellGraph.C
......
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
LIB_LIBS = \
-lfiniteVolume \
......
......@@ -48,7 +48,7 @@ Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
IOobject::NO_WRITE
)
),
OutputFilter(name(), obr, *this, readFromFiles)
OutputFilter(OutputFilter::typeName, obr, *this, readFromFiles)
{}
......
/*---------------------------------------------------------------------------*\
/*---------------------------------------------------------------------------* \
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
......@@ -99,14 +99,14 @@ public:
virtual void write();
//- Update for changes of mesh
void updateMesh(const mapPolyMesh& mpm)
virtual void updateMesh(const mapPolyMesh& mpm)
{
read();
OutputFilter::updateMesh(mpm);
}
//- Update for changes of mesh
void movePoints(const pointField& points)
virtual void movePoints(const pointField& points)
{
read();
OutputFilter::movePoints(points);
......
......@@ -40,6 +40,7 @@ SourceFiles
#include "HashPtrTable.H"
#include "OFstream.H"
#include "polyMesh.H"
#include "pointField.H"
#include "volFieldsFwd.H"
......@@ -207,6 +208,10 @@ public:
virtual void movePoints(const pointField&)
{}
//- Update for changes of mesh due to readUpdate
virtual void readUpdate(const polyMesh::readUpdateState state)
{}
//- Sample a volume field at all locations
template<class Type>
tmp<Field<Type> > sample
......
......@@ -22,143 +22,150 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*----------------------------------------------------------------------------*/
\*---------------------------------------------------------------------------*/
#include "surfacesFunctionObject.H"
#include "cloudSet.H"
#include "sampledSet.H"
#include "meshSearch.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "IOsampledSurfaces.H"
#include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfacesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
surfacesFunctionObject,
dictionary
);
defineTypeNameAndDebug(cloudSet, 0);
addToRunTimeSelectionTable(sampledSet, cloudSet, word);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::surfacesFunctionObject::extractDict()
void Foam::cloudSet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const
{
if (dict_.found("region"))
forAll(sampleCoords_, sampleI)
{
dict_.lookup("region") >> regionName_;
}
label cellI = searchEngine().findCell(sampleCoords_[sampleI]);
if (dict_.found("dictionary"))
{
dict_.lookup("dictionary") >> dictName_;
if (cellI != -1)
{
samplingPts.append(sampleCoords_[sampleI]);
samplingCells.append(cellI);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);
}
}
}
if (dict_.found("interval"))
{
dict_.lookup("interval") >> interval_;
}
if (dict_.found("enabled"))
{
dict_.lookup("enabled") >> execution_;
}
void Foam::cloudSet::genSamples()
{
// Storage for sample points
DynamicList<point> samplingPts;
DynamicList<label> samplingCells;
DynamicList<label> samplingFaces;
DynamicList<label> samplingSegments;
DynamicList<scalar> samplingCurveDist;
calcSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
samplingPts.shrink();
samplingCells.shrink();
samplingFaces.shrink();
samplingSegments.shrink();
samplingCurveDist.shrink();
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfacesFunctionObject::surfacesFunctionObject
Foam::cloudSet::cloudSet
(
const Time& t,
const dictionary& dict
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const List<point>& sampleCoords
)
:
functionObject(),
time_(t),
dict_(dict),
regionName_(polyMesh::defaultRegion),
dictName_(),
interval_(0),
execution_(true)
sampledSet(name, mesh, searchEngine, axis),
sampleCoords_(sampleCoords)
{
extractDict();
}
genSamples();
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// any possible side-effects?
bool Foam::surfacesFunctionObject::start()
{
extractDict();
if (execution_)
if (debug)
{
if (dictName_.size())
{
ptr_.reset
(
new IOsampledSurfaces
(
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new sampledSurfaces
(
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
write(Info);
}
return true;
}
bool Foam::surfacesFunctionObject::execute()
Foam::cloudSet::cloudSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
sampleCoords_(dict.lookup("points"))
{
if (execution_ && (interval_ <= 1 || !(time_.timeIndex() % interval_)) )
genSamples();
if (debug)
{
ptr_->write();
write(Info);
}
return true;
}
void Foam::surfacesFunctionObject::on()
{
execution_ = true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cloudSet::~cloudSet()
{}
void Foam::surfacesFunctionObject::off()
{
execution_ = false;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::surfacesFunctionObject::read(const dictionary& dict)
Foam::point Foam::cloudSet::getRefPoint(const List<point>& pts) const
{
if (dict_ != dict)
if (pts.size() > 0)
{
dict_ = dict;
return start();
// Use first samplePt as starting point
return pts[0];
}
else
{
return false;
return vector::zero;
}
}
// ************************************************************************* //
......@@ -23,96 +23,96 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
surfacesFunctionObject
Foam::cloudSet
Description
FunctionObject wrapper around surfaces to allow them to be created via the
functions list within controlDict.
SourceFiles
surfacesFunctionObject.C
cloudSet.C
\*---------------------------------------------------------------------------*/
#ifndef surfacesFunctionObject_H
#define surfacesFunctionObject_H
#ifndef cloudSet_H
#define cloudSet_H
#include "functionObject.H"
#include "dictionary.H"
#include "sampledSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class sampledSurfaces;
// Forward declaration of classes
class passiveParticle;
template<class Type> class particle;
/*---------------------------------------------------------------------------*\
Class surfacesFunctionObject Declaration
Class cloudSet Declaration
\*---------------------------------------------------------------------------*/
class surfacesFunctionObject
class cloudSet
:
public functionObject
public sampledSet
{
// Private data
const Time& time_;
dictionary dict_;
word regionName_;
word dictName_;
//- Sampling points
List<point> sampleCoords_;
//- the execution interval (in time steps)
// a value <= 1 means execute at every time step
label interval_;
//- Switch for the execution of the functionObjects
bool execution_;
autoPtr<sampledSurfaces> ptr_;
// Private Member Functions
//- extract relevant dictionary entries
void extractDict();
//- Disallow default bitwise copy construct
surfacesFunctionObject(const surfacesFunctionObject&);
//- Samples all points in sampleCoords.
void calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const;
//- Disallow default bitwise assignment
void operator=(const surfacesFunctionObject&);
//- Uses calcSamples to obtain samples. Copies them into *this.
void genSamples();
public:
//- Runtime type information
TypeName("surfaces");
TypeName("cloud");
// Constructors
//- Construct from components
surfacesFunctionObject
cloudSet
(
const Time&,
const dictionary&
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const List<point>& sampleCoords
);
//- Construct from dictionary
cloudSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Member Functions
//- start is called at the start of the time-loop
virtual bool start();
// Destructor
//- execute is called at each ++ or += of the time-loop
virtual bool execute();
virtual ~cloudSet();
//- Switch the function object on
virtual void on();
//- Switch the function object off
virtual void off();
// Member Functions
//- Read and set the function object if its data has changed
virtual bool read(const dictionary& dict);
//- Get reference point
virtual point getRefPoint(const List<point>&) const;
};
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "coordSet.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from components
Foam::coordSet::coordSet
(
const word& name,
const word& axis
)
:
pointField(0),
name_(name),
axis_(axis),
refPoint_(vector::zero)
{}
//- Construct from components
Foam::coordSet::coordSet
(
const word& name,
const word& axis,
const List<point>& points,
const point& refPoint
)
:
pointField(points),
name_(name),
axis_(axis),
refPoint_(refPoint)
{}
//- Construct from components
Foam::coordSet::coordSet
(
const word& name,
const word& axis,
const scalarField& points,
const scalar refPoint
)
:
pointField(points.size(), point::zero),
name_(name),
axis_(axis),
refPoint_(point::zero)
{
if (axis_ == "x" || axis_ == "distance")
{
refPoint_.x() = refPoint;
replace(point::X, points);
}
else if (axis_ == "y")
{
replace(point::Y, points);
}
else if (axis_ == "z")
{
replace(point::Z, points);
}
else
{