Update sampling to include surface and line sampling functionObjects

This commit is contained in:
henry
2008-05-01 16:09:21 +01:00
parent cd161a3385
commit 8bcbf3533a
93 changed files with 7071 additions and 564 deletions

View File

@ -1,21 +1,38 @@
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
sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.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/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

View File

@ -1,7 +1,8 @@
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 \

View File

@ -48,7 +48,7 @@ Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
IOobject::NO_WRITE
)
),
OutputFilter(name(), obr, *this, readFromFiles)
OutputFilter(OutputFilter::typeName, obr, *this, readFromFiles)
{}

View File

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\
/*---------------------------------------------------------------------------* \
========= |
\\ / 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);

View File

@ -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

View File

@ -0,0 +1,171 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "cloudSet.H"
#include "sampledSet.H"
#include "meshSearch.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cloudSet, 0);
addToRunTimeSelectionTable(sampledSet, cloudSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::cloudSet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const
{
forAll(sampleCoords_, sampleI)
{
label cellI = searchEngine().findCell(sampleCoords_[sampleI]);
if (cellI != -1)
{
samplingPts.append(sampleCoords_[sampleI]);
samplingCells.append(cellI);
samplingFaces.append(-1);
samplingSegments.append(0);
samplingCurveDist.append(1.0 * sampleI);
}
}
}
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::cloudSet::cloudSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const List<point>& sampleCoords
)
:
sampledSet(name, mesh, searchEngine, axis),
sampleCoords_(sampleCoords)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::cloudSet::cloudSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
sampleCoords_(dict.lookup("points"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cloudSet::~cloudSet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::point Foam::cloudSet::getRefPoint(const List<point>& pts) const
{
if (pts.size() > 0)
{
// Use first samplePt as starting point
return pts[0];
}
else
{
return vector::zero;
}
}
// ************************************************************************* //

View File

@ -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();
//- 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 copy construct
surfacesFunctionObject(const surfacesFunctionObject&);
//- 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
);
// Destructor
virtual ~cloudSet();
// Member Functions
//- start is called at the start of the time-loop
virtual bool start();
//- execute is called at each ++ or += of the time-loop
virtual bool execute();
//- Switch the function object on
virtual void on();
//- Switch the function object off
virtual void off();
//- 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;
};

View File

@ -0,0 +1,174 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
{
FatalErrorIn
(
"coordSet::coordSet(const word& name,"
"const word& axis, const List<scalar>& points,"
"const scalar refPoint)"
) << "Illegal axis specification " << axis_
<< " for sampling line " << name_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::coordSet::hasVectorAxis() const
{
return axis_ == "xyz";
}
Foam::scalar Foam::coordSet::scalarCoord
(
const label index
) const
{
const point& p = operator[](index);
if (axis_ == "x")
{
return p.x();
}
else if (axis_ == "y")
{
return p.y();
}
else if (axis_ == "z")
{
return p.z();
}
else if (axis_ == "distance")
{
// Use distance to reference point
return mag(p - refPoint_);
}
else
{
FatalErrorIn
(
"coordSet::scalarCoord(const label)"
) << "Illegal axis specification " << axis_
<< " for sampling line " << name_
<< exit(FatalError);
return 0;
}
}
Foam::point Foam::coordSet::vectorCoord(const label index) const
{
const point& p = operator[](index);
return p;
}
Foam::Ostream& Foam::coordSet::write(Ostream& os) const
{
os << "name:" << name_ << " axis:" << axis_ << " reference:" << refPoint_
<< endl
<< endl << "\t(coord)"
<< endl;
forAll(*this, sampleI)
{
os << '\t' << operator[](sampleI) << endl;
}
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::coordSet
Description
Holds list of sampling positions
SourceFiles
coordSet.C
\*---------------------------------------------------------------------------*/
#ifndef coordSet_H
#define coordSet_H
#include "pointField.H"
#include "word.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class coordSet Declaration
\*---------------------------------------------------------------------------*/
class coordSet
:
public pointField
{
protected:
//- Name
const word name_;
//- Axis write type
const word axis_;
//- Reference point for "distance" write specifier.
point refPoint_;
public:
// Constructors
//- Construct from components
coordSet
(
const word& name,
const word& axis
);
//- Construct from components
coordSet
(
const word& name,
const word& axis,
const List<point>& points,
const point& refPoint = point::zero
);
//- Construct from components
coordSet
(
const word& name,
const word& axis,
const scalarField& points,
const scalar refPoint = 0.0
);
// Member functions
const word& name() const
{
return name_;
}
const word& axis() const
{
return axis_;
}
const point& refPoint() const
{
return refPoint_;
}
//- Is axis specification a vector
bool hasVectorAxis() const;
//- Get coordinate of point according to axis specification.
// If axis="distance" can be: -distance to starting point (e.g.
// uniformSet) or -distance to first sampling point
// (e.g. cloudSet)
scalar scalarCoord
(
const label index
) const;
//- Get point according to axis="full" specification
vector vectorCoord
(
const label index
) const;
Ostream& write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,415 @@
/*---------------------------------------------------------------------------* \
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "curveSet.H"
#include "meshSearch.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "IDLList.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(curveSet, 0);
addToRunTimeSelectionTable(sampledSet, curveSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Sample till hits boundary.
bool Foam::curveSet::trackToBoundary
(
Particle<passiveParticle>& singleParticle,
label& sampleI,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurveDist
) const
{
// Alias
const point& trackPt = singleParticle.position();
while(true)
{
// Local geometry info
const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
const scalar smallDist = mag(tol*offset);
point oldPos = trackPt;
label facei = -1;
do
{
singleParticle.stepFraction() = 0;
singleParticle.track(sampleCoords_[sampleI+1]);
}
while
(
!singleParticle.onBoundary()
&& (mag(trackPt - oldPos) < smallDist)
);
if (singleParticle.onBoundary())
{
//Info<< "trackToBoundary : reached boundary"
// << " trackPt:" << trackPt << endl;
if
(
mag(trackPt - sampleCoords_[sampleI+1])
< smallDist
)
{
// Reached samplePt on boundary
//Info<< "trackToBoundary : boundary. also sampling."
// << " trackPt:" << trackPt << " sampleI+1:" << sampleI+1
// << endl;
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(facei);
// trackPt is at sampleI+1
samplingCurveDist.append(1.0*(sampleI+1));
}
return true;
}
// Reached samplePt in cell
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(-1);
// Convert trackPt to fraction inbetween sampleI and sampleI+1
scalar dist =
mag(trackPt - sampleCoords_[sampleI])
/ mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
samplingCurveDist.append(sampleI + dist);
// go to next samplePt
sampleI++;
if (sampleI == sampleCoords_.size() - 1)
{
// no more samples.
//Info<< "trackToBoundary : Reached end : sampleI now:" << sampleI
// << endl;
return false;
}
}
}
void Foam::curveSet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const
{
// Check sampling points
if (sampleCoords_.size() < 2)
{
FatalErrorIn("curveSet::calcSamples()")
<< "Incorrect sample specification. Too few points:"
<< sampleCoords_ << exit(FatalError);
}
point oldPoint = sampleCoords_[0];
for(label sampleI = 1; sampleI < sampleCoords_.size(); sampleI++)
{
if (mag(sampleCoords_[sampleI] - oldPoint) < SMALL)
{
FatalErrorIn("curveSet::calcSamples()")
<< "Incorrect sample specification."
<< " Point " << sampleCoords_[sampleI-1]
<< " at position " << sampleI-1
<< " and point " << sampleCoords_[sampleI]
<< " at position " << sampleI
<< " are too close" << exit(FatalError);
}
oldPoint = sampleCoords_[sampleI];
}
// current segment number
label segmentI = 0;
// starting index of current segment in samplePts
label startSegmentI = 0;
label sampleI = 0;
point lastSample(GREAT, GREAT, GREAT);
while(true)
{
// Get boundary intersection
point trackPt;
label trackCellI = -1;
label trackFaceI = -1;
do
{
const vector offset =
sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
const scalar smallDist = mag(tol*offset);
// Get all boundary intersections
List<pointIndexHit> bHits =
searchEngine().intersections
(
sampleCoords_[sampleI],
sampleCoords_[sampleI+1]
);
point bPoint(GREAT, GREAT, GREAT);
label bFaceI = -1;
if (bHits.size() > 0)
{
bPoint = bHits[0].hitPoint();
bFaceI = bHits[0].index();
}
// Get tracking point
bool isSample =
getTrackingPoint
(
sampleCoords_[sampleI+1] - sampleCoords_[sampleI],
sampleCoords_[sampleI],
bPoint,
bFaceI,
trackPt,
trackCellI,
trackFaceI
);
if (isSample && (mag(lastSample - trackPt) > smallDist))
{
//Info<< "calcSamples : getTrackingPoint returned valid sample "
// << " trackPt:" << trackPt
// << " trackFaceI:" << trackFaceI
// << " trackCellI:" << trackCellI
// << " sampleI:" << sampleI
// << " dist:" << dist
// << endl;
samplingPts.append(trackPt);
samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI);
// Convert sampling position to unique curve parameter. Get
// fraction of distance between sampleI and sampleI+1.
scalar dist =
mag(trackPt - sampleCoords_[sampleI])
/ mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
samplingCurveDist.append(sampleI + dist);
lastSample = trackPt;
}
if (trackCellI == -1)
{
// No intersection found. Go to next point
sampleI++;
}
} while((trackCellI == -1) && (sampleI < sampleCoords_.size() - 1));
if (sampleI == sampleCoords_.size() - 1)
{
//Info<< "calcSamples : Reached end of samples: "
// << " sampleI now:" << sampleI
// << endl;
break;
}
//
// Segment sampleI .. sampleI+1 intersected by domain
//
// Initialize tracking starting from sampleI
Cloud<passiveParticle> particles(mesh(), IDLList<passiveParticle>());
passiveParticle singleParticle
(
particles,
trackPt,
trackCellI
);
bool bReached = trackToBoundary
(
singleParticle,
sampleI,
samplingPts,
samplingCells,
samplingFaces,
samplingCurveDist
);
// fill sampleSegments
for(label i = samplingPts.size() - 1; i >= startSegmentI; --i)
{
samplingSegments.append(segmentI);
}
if (!bReached)
{
//Info<< "calcSamples : Reached end of samples: "
// << " sampleI now:" << sampleI
// << endl;
break;
}
lastSample = singleParticle.position();
// Find next boundary.
sampleI++;
if (sampleI == sampleCoords_.size() - 1)
{
//Info<< "calcSamples : Reached end of samples: "
// << " sampleI now:" << sampleI
// << endl;
break;
}
segmentI++;
startSegmentI = samplingPts.size();
}
}
void Foam::curveSet::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::curveSet::curveSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const List<point>& sampleCoords
)
:
sampledSet(name, mesh, searchEngine, axis),
sampleCoords_(sampleCoords)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::curveSet::curveSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
sampleCoords_(dict.lookup("points"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::curveSet::~curveSet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::point Foam::curveSet::getRefPoint(const List<point>& pts) const
{
if (pts.size() > 0)
{
// Use first samplePt as starting point
return pts[0];
}
else
{
return vector::zero;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::curveSet
Description
SourceFiles
curveSet.C
\*---------------------------------------------------------------------------*/
#ifndef curveSet_H
#define curveSet_H
#include "sampledSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class Particle;
/*---------------------------------------------------------------------------*\
Class curveSet Declaration
\*---------------------------------------------------------------------------*/
class curveSet
:
public sampledSet
{
// Private data
//- sampling points
List<point> sampleCoords_;
// Private Member Functions
//- Sample till hits boundary. Called with singleParticle at position
// inbetween sampleCoords_[sampleI] and sampleCoords_[sampleI+1].
// Returns false if end of samples reached.
bool trackToBoundary
(
Particle<passiveParticle>& singleParticle,
label& sampleI,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurveDist
) const;
//- Samples all point in sampleCoords_
// samplingSegments contains segmentNo for each sample.
void calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const;
//- Uses calcSamples to obtain samples. Copies them into *this.
void genSamples();
public:
//- Runtime type information
TypeName("curve");
// Constructors
//- Construct from components
curveSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const List<point>& samplePoints
);
//- Construct from dictionary
curveSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~curveSet();
// Member Functions
//- Get reference point
virtual point getRefPoint(const List<point>&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,393 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "faceOnlySet.H"
#include "meshSearch.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "IDLList.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faceOnlySet, 0);
addToRunTimeSelectionTable(sampledSet, faceOnlySet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Sample singly connected segment. Returns false if end_ reached.
bool Foam::faceOnlySet::trackToBoundary
(
Particle<passiveParticle>& singleParticle,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurveDist
) const
{
// distance vector between sampling points
const vector offset = end_ - start_;
const vector smallVec = tol*offset;
const scalar smallDist = mag(smallVec);
// Alias
const point& trackPt = singleParticle.position();
while(true)
{
point oldPoint = trackPt;
singleParticle.trackToFace(end_);
if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist)
{
// Reached face. Sample.
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(singleParticle.face());
samplingCurveDist.append(mag(trackPt - start_));
}
if (mag(trackPt - end_) < smallDist)
{
// end reached
return false;
}
else if (singleParticle.onBoundary())
{
// Boundary reached.
return true;
}
}
}
void Foam::faceOnlySet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const
{
// distance vector between sampling points
if (mag(end_ - start_) < SMALL)
{
FatalErrorIn("faceOnlySet::calcSamples()")
<< "Incorrect sample specification :"
<< " start equals end point." << endl
<< " start:" << start_
<< " end:" << end_
<< exit(FatalError);
}
const vector offset = (end_ - start_);
const vector normOffset = offset/mag(offset);
const vector smallVec = tol*offset;
const scalar smallDist = mag(smallVec);
// Get all boundary intersections
List<pointIndexHit> bHits =
searchEngine().intersections
(
start_ - smallVec,
end_ + smallVec
);
point bPoint(GREAT, GREAT, GREAT);
label bFaceI = -1;
if (bHits.size() > 0)
{
bPoint = bHits[0].hitPoint();
bFaceI = bHits[0].index();
}
// Get first tracking point. Use bPoint, bFaceI if provided.
point trackPt;
label trackCellI = -1;
label trackFaceI = -1;
//Info<< "before getTrackingPoint : bPoint:" << bPoint
// << " bFaceI:" << bFaceI << endl;
getTrackingPoint
(
offset,
start_,
bPoint,
bFaceI,
trackPt,
trackCellI,
trackFaceI
);
//Info<< "after getTrackingPoint : "
// << " trackPt:" << trackPt
// << " trackCellI:" << trackCellI
// << " trackFaceI:" << trackFaceI
// << endl;
if (trackCellI == -1)
{
// Line start_ - end_ does not intersect domain at all.
// (or is along edge)
// Set points and cell/face labels to empty lists
//Info<< "calcSamples : Both start_ and end_ outside domain"
// << endl;
return;
}
if (trackFaceI == -1)
{
// No boundary face. Check for nearish internal face
trackFaceI = findNearFace(trackCellI, trackPt, smallDist);
}
//Info<< "calcSamples : got first point to track from :"
// << " trackPt:" << trackPt
// << " trackCell:" << trackCellI
// << " trackFace:" << trackFaceI
// << endl;
//
// Track until hit end of all boundary intersections
//
// current segment number
label segmentI = 0;
// starting index of current segment in samplePts
label startSegmentI = 0;
// index in bHits; current boundary intersection
label bHitI = 1;
while(true)
{
if (trackFaceI != -1)
{
//Info<< "trackPt:" << trackPt << " on face so use." << endl;
samplingPts.append(trackPt);
samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI);
samplingCurveDist.append(mag(trackPt - start_));
}
// Initialize tracking starting from trackPt
Cloud<passiveParticle> particles(mesh(), IDLList<passiveParticle>());
passiveParticle singleParticle
(
particles,
trackPt,
trackCellI
);
bool reachedBoundary = trackToBoundary
(
singleParticle,
samplingPts,
samplingCells,
samplingFaces,
samplingCurveDist
);
// fill sampleSegments
for(label i = samplingPts.size() - 1; i >= startSegmentI; --i)
{
samplingSegments.append(segmentI);
}
if (!reachedBoundary)
{
//Info<< "calcSamples : Reached end of samples: "
// << " samplePt now:" << singleParticle.position()
// << endl;
break;
}
// Go past boundary intersection where tracking stopped
// Use coordinate comparison instead of face comparison for
// accuracy reasons
bool foundValidB = false;
while (bHitI < bHits.size())
{
scalar dist =
(bHits[bHitI].hitPoint() - singleParticle.position())
& normOffset;
//Info<< "Finding next boundary : "
// << "bPoint:" << bHits[bHitI].hitPoint()
// << " tracking:" << singleParticle.position()
// << " dist:" << dist
// << endl;
if (dist > smallDist)
{
// hitpoint is past tracking position
foundValidB = true;
break;
}
else
{
bHitI++;
}
}
if (!foundValidB)
{
// No valid boundary intersection found beyond tracking position
break;
}
// Update starting point for tracking
trackFaceI = bHits[bHitI].index();
trackPt = pushIn(bHits[bHitI].hitPoint(), trackFaceI);
trackCellI = getBoundaryCell(trackFaceI);
segmentI++;
startSegmentI = samplingPts.size();
}
}
void Foam::faceOnlySet::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();
// Copy into *this
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faceOnlySet::faceOnlySet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end
)
:
sampledSet(name, mesh, searchEngine, axis),
start_(start),
end_(end)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::faceOnlySet::faceOnlySet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
start_(dict.lookup("start")),
end_(dict.lookup("end"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceOnlySet::~faceOnlySet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::point Foam::faceOnlySet::getRefPoint(const List<point>& pts) const
{
return start_;
}
// ************************************************************************* //

View File

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::faceOnlySet
Description
SourceFiles
faceOnlySet.C
\*---------------------------------------------------------------------------*/
#ifndef faceOnlySet_H
#define faceOnlySet_H
#include "sampledSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class Particle;
/*---------------------------------------------------------------------------*\
Class faceOnlySet Declaration
\*---------------------------------------------------------------------------*/
class faceOnlySet
:
public sampledSet
{
// Private data
//- Starting point
point start_;
//- End point
point end_;
// Private Member Functions
//- Samples from startTrackPt/CellI. Updates particle/samplePt/sampleI
// and puts
// samples in the DynamicLists. Returns false if end of all samples
// reached
bool trackToBoundary
(
Particle<passiveParticle>& singleParticle,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurve
) const;
//- Samples from start_ to end_. samplingSegments contains segmentNo
// for each sample.
void calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const;
//- Uses calcSamples to obtain samples. Copies them into *this.
void genSamples();
public:
//- Runtime type information
TypeName("face");
// Constructors
//- Construct from components
faceOnlySet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end
);
//- Construct from dictionary
faceOnlySet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~faceOnlySet();
// Member Functions
const point& start() const
{
return start_;
}
const point& end() const
{
return end_;
}
//- Get reference point
virtual point getRefPoint(const List<point>&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,165 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "midPointSet.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(midPointSet, 0);
addToRunTimeSelectionTable(sampledSet, midPointSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Rework faceOnlySet samples.
// Take two consecutive samples
void Foam::midPointSet::genSamples()
{
// Generate midpoints.
List<point> midPoints(2*size());
labelList midCells(2*size());
labelList midSegments(2*size());
scalarList midCurveDist(2*size());
label midI = 0;
label sampleI = 0;
while(true)
{
// calculate midpoint between sampleI and sampleI+1 (if in same segment)
while
(
(sampleI < size() - 1)
&& (segments_[sampleI] == segments_[sampleI+1])
)
{
midPoints[midI] =
0.5*(operator[](sampleI) + operator[](sampleI+1));
label cell1 = getCell(faces_[sampleI], midPoints[midI]);
label cell2 = getCell(faces_[sampleI+1], midPoints[midI]);
if (cell1 != cell2)
{
FatalErrorIn("midPointSet::genSamples()")
<< " sampleI:" << sampleI
<< " midI:" << midI
<< " sampleI:" << sampleI
<< " pts[sampleI]:" << operator[](sampleI)
<< " face[sampleI]:" << faces_[sampleI]
<< " pts[sampleI+1]:" << operator[](sampleI+1)
<< " face[sampleI+1]:" << faces_[sampleI+1]
<< " cell1:" << cell1
<< " cell2:" << cell2
<< abort(FatalError);
}
midCells[midI] = cell1;
midSegments[midI] = segments_[sampleI];
midCurveDist[midI] = mag(midPoints[midI] - start());
midI++;
sampleI++;
}
if (sampleI == size() - 1)
{
break;
}
sampleI++;
}
midPoints.setSize(midI);
midCells.setSize(midI);
midSegments.setSize(midI);
midCurveDist.setSize(midI);
setSamples
(
midPoints,
midCells,
labelList(midCells.size(), -1),
midSegments,
midCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::midPointSet::midPointSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end
)
:
faceOnlySet(name, mesh, searchEngine, axis, start, end)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::midPointSet::midPointSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
faceOnlySet(name, mesh, searchEngine, dict)
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::midPointSet::~midPointSet()
{}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::midPointSet
Description
SourceFiles
midPointSet.C
\*---------------------------------------------------------------------------*/
#ifndef midPointSet_H
#define midPointSet_H
#include "faceOnlySet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class particle;
class meshSearch;
/*---------------------------------------------------------------------------*\
Class midPointSet Declaration
\*---------------------------------------------------------------------------*/
class midPointSet
:
public faceOnlySet
{
// Private Member Functions
void genSamples();
public:
//- Runtime type information
TypeName("midPoint");
// Constructors
//- Construct from components
midPointSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end
);
//- Construct from dictionary
midPointSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~midPointSet();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,191 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "midPointAndFaceSet.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(midPointAndFaceSet, 0);
addToRunTimeSelectionTable(sampledSet, midPointAndFaceSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Rework faceOnlySet samples.
// Take two consecutive samples
void Foam::midPointAndFaceSet::genSamples()
{
// Generate midpoints and add to face points
List<point> newSamplePoints(3*size());
labelList newSampleCells(3*size());
labelList newSampleFaces(3*size());
labelList newSampleSegments(3*size());
scalarList newSampleCurveDist(3*size());
label newSampleI = 0;
label sampleI = 0;
while(true)
{
// sampleI is start of segment
// Add sampleI
newSamplePoints[newSampleI] = operator[](sampleI);
newSampleCells[newSampleI] = cells_[sampleI];
newSampleFaces[newSampleI] = faces_[sampleI];
newSampleSegments[newSampleI] = segments_[sampleI];
newSampleCurveDist[newSampleI] = curveDist_[sampleI];
newSampleI++;
while
(
(sampleI < size() - 1)
&& (segments_[sampleI] == segments_[sampleI+1])
)
{
// Add mid point
const point mid = 0.5*(operator[](sampleI) + operator[](sampleI+1));
label cell1 = getCell(faces_[sampleI], mid);
label cell2 = getCell(faces_[sampleI+1], mid);
if (cell1 != cell2)
{
FatalErrorIn("midPointAndFaceSet::genSamples()")
<< " sampleI:" << sampleI
<< " newSampleI:" << newSampleI
<< " pts[sampleI]:" << operator[](sampleI)
<< " face[sampleI]:" << faces_[sampleI]
<< " pts[sampleI+1]:" << operator[](sampleI+1)
<< " face[sampleI+1]:" << faces_[sampleI+1]
<< " cell1:" << cell1
<< " cell2:" << cell2
<< abort(FatalError);
}
newSamplePoints[newSampleI] = mid;
newSampleCells[newSampleI] = cell1;
newSampleFaces[newSampleI] = -1;
newSampleSegments[newSampleI] = segments_[sampleI];
newSampleCurveDist[newSampleI] =
mag(newSamplePoints[newSampleI] - start());
newSampleI++;
// Add sampleI+1
newSamplePoints[newSampleI] = operator[](sampleI+1);
newSampleCells[newSampleI] = cells_[sampleI+1];
newSampleFaces[newSampleI] = faces_[sampleI+1];
newSampleSegments[newSampleI] = segments_[sampleI+1];
newSampleCurveDist[newSampleI] =
mag(newSamplePoints[newSampleI] - start());
newSampleI++;
sampleI++;
}
if (sampleI == size() - 1)
{
break;
}
sampleI++;
}
newSamplePoints.setSize(newSampleI);
newSampleCells.setSize(newSampleI);
newSampleFaces.setSize(newSampleI);
newSampleSegments.setSize(newSampleI);
newSampleCurveDist.setSize(newSampleI);
setSamples
(
newSamplePoints,
newSampleCells,
newSampleFaces,
newSampleSegments,
newSampleCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::midPointAndFaceSet::midPointAndFaceSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end
)
:
faceOnlySet(name, mesh, searchEngine, axis, start, end)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::midPointAndFaceSet::midPointAndFaceSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
faceOnlySet(name, mesh, searchEngine, dict)
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::midPointAndFaceSet::~midPointAndFaceSet()
{}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::midPointAndFaceSet
Description
SourceFiles
midPointAndFaceSet.C
\*---------------------------------------------------------------------------*/
#ifndef midPointAndFaceSet_H
#define midPointAndFaceSet_H
#include "faceOnlySet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class particle;
class meshSearch;
/*---------------------------------------------------------------------------*\
Class midPointAndFaceSet Declaration
\*---------------------------------------------------------------------------*/
class midPointAndFaceSet
:
public faceOnlySet
{
// Private Member Functions
void genSamples();
public:
//- Runtime type information
TypeName("midPointAndFace");
// Constructors
//- Construct from components
midPointAndFaceSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end
);
//- Construct from dictionary
midPointAndFaceSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~midPointAndFaceSet();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,467 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "sampledSet.H"
#include "polyMesh.H"
#include "primitiveMesh.H"
#include "meshSearch.H"
#include "writer.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
const scalar sampledSet::tol = 1e-6;
defineTypeNameAndDebug(sampledSet, 0);
defineRunTimeSelectionTable(sampledSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::sampledSet::getBoundaryCell(const label faceI) const
{
return mesh().faceOwner()[faceI];
}
Foam::label Foam::sampledSet::getCell
(
const label faceI,
const point& sample
) const
{
if (faceI == -1)
{
FatalErrorIn
(
"sampledSet::getCell(const label, const point&)"
) << "Illegal face label " << faceI
<< abort(FatalError);
}
if (faceI >= mesh().nInternalFaces())
{
label cellI = getBoundaryCell(faceI);
if (!mesh().pointInCell(sample, cellI))
{
FatalErrorIn
(
"sampledSet::getCell(const label, const point&)"
) << "Found cell " << cellI << " using face " << faceI
<< ". But cell does not contain point " << sample
<< abort(FatalError);
}
return cellI;
}
else
{
// Try owner and neighbour to see which one contains sample
label cellI = mesh().faceOwner()[faceI];
if (mesh().pointInCell(sample, cellI))
{
return cellI;
}
else
{
cellI = mesh().faceNeighbour()[faceI];
if (mesh().pointInCell(sample, cellI))
{
return cellI;
}
else
{
FatalErrorIn
(
"sampledSet::getCell(const label, const point&)"
) << "None of the neighbours of face "
<< faceI << " contains point " << sample
<< abort(FatalError);
return -1;
}
}
}
}
Foam::scalar Foam::sampledSet::calcSign
(
const label faceI,
const point& sample
) const
{
vector vec = sample - mesh().faceCentres()[faceI];
scalar magVec = mag(vec);
if (magVec < VSMALL)
{
// sample on face centre. Regard as inside
return -1;
}
vec /= magVec;
vector n = mesh().faceAreas()[faceI];
n /= mag(n) + VSMALL;
return n & vec;
}
// Return face (or -1) of face which is within smallDist of sample
Foam::label Foam::sampledSet::findNearFace
(
const label cellI,
const point& sample,
const scalar smallDist
) const
{
const cell& myFaces = mesh().cells()[cellI];
forAll(myFaces, myFaceI)
{
const face& f = mesh().faces()[myFaces[myFaceI]];
pointHit inter = f.nearestPoint(sample, mesh().points());
scalar dist;
if (inter.hit())
{
dist = mag(inter.hitPoint() - sample);
}
else
{
dist = mag(inter.missPoint() - sample);
}
if (dist < smallDist)
{
return myFaces[myFaceI];
}
}
return -1;
}
// 'Pushes' point facePt (which is almost on face) in direction of cell centre
// so it is clearly inside.
Foam::point Foam::sampledSet::pushIn
(
const point& facePt,
const label faceI
) const
{
label cellI = mesh().faceOwner()[faceI];
const point& cellCtr = mesh().cellCentres()[cellI];
point newSample =
facePt + tol*(cellCtr - facePt);
if (!searchEngine().pointInCell(newSample, cellI))
{
FatalErrorIn
(
"sampledSet::pushIn(const point&, const label)"
) << "After pushing " << facePt << " to " << newSample
<< " it is still outside faceI " << faceI << endl
<< "Please change your starting point"
<< abort(FatalError);
}
//Info<< "pushIn : moved " << facePt << " to " << newSample
// << endl;
return newSample;
}
// Calculates start of tracking given samplePt and first boundary intersection
// (bPoint, bFaceI). bFaceI == -1 if no boundary intersection.
// Returns true if trackPt is sampling point
bool Foam::sampledSet::getTrackingPoint
(
const vector& offset,
const point& samplePt,
const point& bPoint,
const label bFaceI,
point& trackPt,
label& trackCellI,
label& trackFaceI
) const
{
const scalar smallDist = mag(tol*offset);
bool isGoodSample = false;
if (bFaceI == -1)
{
// No boundary intersection. Try and find cell samplePt is in
trackCellI = mesh().findCell(samplePt);
if
(
(trackCellI == -1)
|| !mesh().pointInCell(samplePt, trackCellI)
)
{
// Line samplePt - end_ does not intersect domain at all.
// (or is along edge)
//Info<< "getTrackingPoint : samplePt outside domain : "
// << " samplePt:" << samplePt
// << endl;
trackCellI = -1;
trackFaceI = -1;
isGoodSample = false;
}
else
{
// start is inside. Use it as tracking point
//Info<< "getTrackingPoint : samplePt inside :"
// << " samplePt:" << samplePt
// << " trackCellI:" << trackCellI
// << endl;
trackPt = samplePt;
trackFaceI = -1;
isGoodSample = true;
}
}
else if (mag(samplePt - bPoint) < smallDist)
{
//Info<< "getTrackingPoint : samplePt:" << samplePt
// << " close to bPoint:"
// << bPoint << endl;
// samplePt close to bPoint. Snap to it
trackPt = pushIn(bPoint, bFaceI);
trackFaceI = bFaceI;
trackCellI = getBoundaryCell(trackFaceI);
isGoodSample = true;
}
else
{
scalar sign = calcSign(bFaceI, samplePt);
if (sign < 0)
{
// samplePt inside or marginally outside.
trackPt = samplePt;
trackFaceI = -1;
trackCellI = mesh().findCell(trackPt);
isGoodSample = true;
}
else
{
// samplePt outside. use bPoint
trackPt = pushIn(bPoint, bFaceI);
trackFaceI = bFaceI;
trackCellI = getBoundaryCell(trackFaceI);
isGoodSample = false;
}
}
if (debug)
{
Info<< "sampledSet::getTrackingPoint :"
<< " offset:" << offset
<< " samplePt:" << samplePt
<< " bPoint:" << bPoint
<< " bFaceI:" << bFaceI
<< endl << " Calculated first tracking point :"
<< " trackPt:" << trackPt
<< " trackCellI:" << trackCellI
<< " trackFaceI:" << trackFaceI
<< " isGoodSample:" << isGoodSample
<< endl;
}
return isGoodSample;
}
void Foam::sampledSet::setSamples
(
const List<point>& samplingPts,
const labelList& samplingCells,
const labelList& samplingFaces,
const labelList& samplingSegments,
const scalarList& samplingCurveDist
)
{
setSize(samplingPts.size());
cells_.setSize(samplingCells.size());
faces_.setSize(samplingFaces.size());
segments_.setSize(samplingSegments.size());
curveDist_.setSize(samplingCurveDist.size());
if
(
(cells_.size() != size())
|| (faces_.size() != size())
|| (segments_.size() != size())
|| (curveDist_.size() != size())
)
{
FatalErrorIn("sampledSet::setSamples()")
<< "sizes not equal : "
<< " points:" << size()
<< " cells:" << cells_.size()
<< " faces:" << faces_.size()
<< " segments:" << segments_.size()
<< " curveDist:" << curveDist_.size()
<< abort(FatalError);
}
forAll(samplingPts, sampleI)
{
operator[](sampleI) = samplingPts[sampleI];
}
cells_ = samplingCells;
faces_ = samplingFaces;
segments_ = samplingSegments;
curveDist_ = samplingCurveDist;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSet::sampledSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis
)
:
coordSet(name, axis),
mesh_(mesh),
searchEngine_(searchEngine),
segments_(0),
curveDist_(0),
cells_(0),
faces_(0)
{}
Foam::sampledSet::sampledSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
coordSet(name, dict.lookup("axis")),
mesh_(mesh),
searchEngine_(searchEngine),
segments_(0),
curveDist_(0),
cells_(0),
faces_(0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledSet::~sampledSet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::sampledSet> Foam::sampledSet::New
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
{
word sampleType(dict.lookup("type"));
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(sampleType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"sampledSet::New(const word&, "
"const polyMesh&, meshSearch&, const dictionary&)"
) << "Unknown sample type " << sampleType
<< endl << endl
<< "Valid sample types : " << endl
<< wordConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<sampledSet>
(
cstrIter()
(
name,
mesh,
searchEngine,
dict
)
);
}
Foam::Ostream& Foam::sampledSet::write(Ostream& os) const
{
coordSet::write(os);
os << endl << "\t(cellI)\t(faceI)" << endl;
forAll(*this, sampleI)
{
os << '\t' << cells_[sampleI]
<< '\t' << faces_[sampleI]
<< endl;
}
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,301 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::sampledSet
Description
Holds list of sampling points which is filled at construction time.
Various implementations of this base class to e.g. get sampling points
at uniform distance along a line (uniformSet) or directly specified
(cloudSet)
Each 'sampledSet' has a name and a specifier of how the axis should be
write (x/y/z component or all 3 components)
SourceFiles
sampledSet.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSet_H
#define sampledSet_H
#include "pointField.H"
#include "word.H"
#include "labelList.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "coordSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class polyMesh;
class meshSearch;
/*---------------------------------------------------------------------------*\
Class sampledSet Declaration
\*---------------------------------------------------------------------------*/
class sampledSet
:
public coordSet
{
// Private data
//- Reference to mesh
const polyMesh& mesh_;
//- Reference to mesh searching class
meshSearch& searchEngine_;
protected:
//- Segment numbers
labelList segments_;
//- Parameter along sample curve. Uniquely identifies position
// along sampling. Used for combining parallel results.
scalarList curveDist_;
//- Cell numbers
labelList cells_;
//- Face numbers (-1 if not known)
labelList faces_;
// Protected Member Functions
//- Returns cell next to boundary face
label getBoundaryCell(const label) const;
//- Returns cell using face and containing sample
label getCell
(
const label faceI,
const point& sample
) const;
//- Calculates inproduct of face normal and vector sample-face centre
// <0 if sample inside.
scalar calcSign(const label faceI, const point& sample) const;
//- Returns face label (or -1) of face which is close to sample
label findNearFace
(
const label cellI,
const point& sample,
const scalar smallDist
) const;
//- Moves sample in direction of -n to it is 'inside' of faceI
point pushIn
(
const point& sample,
const label faceI
) const;
//- Calculates start of tracking given samplePt and first boundary
// intersection
// (bPoint, bFaceI) (bFaceI == -1 if no boundary intersection)
// Returns true if trackPt is valid sampling point. Sets trackPt,
// trackFaceI, trackCellI (-1 if no tracking point found)
bool getTrackingPoint
(
const vector& offset,
const point& samplePt,
const point& bPoint,
const label bFaceI,
point& trackPt,
label& trackCellI,
label& trackFaceI
) const;
//- Sets sample data
void setSamples
(
const List<point>& samplingPts,
const labelList& samplingCells,
const labelList& samplingFaces,
const labelList& samplingSegments,
const scalarList& samplingCurveDist
);
public:
//- Runtime type information
TypeName("sampledSet");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
sampledSet,
word,
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
),
(name, mesh, searchEngine, dict)
);
//- Class used for the read-construction of
// PtrLists of sampledSet
class iNew
{
const polyMesh& mesh_;
meshSearch& searchEngine_;
public:
iNew(const polyMesh& mesh, meshSearch& searchEngine)
:
mesh_(mesh),
searchEngine_(searchEngine)
{}
autoPtr<sampledSet> operator()(Istream& is) const
{
word name(is);
dictionary dict(is);
return sampledSet::New(name, mesh_, searchEngine_, dict);
}
};
// Static data
//- Tolerance when comparing points. Usually relative to difference
// between start_ and end_
const static scalar tol;
// Constructors
//- Construct from components
sampledSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis
);
//- Construct from dictionary
sampledSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
//- Clone
autoPtr<sampledSet> clone() const
{
notImplemented("autoPtr<sampledSet> clone() const");
return autoPtr<sampledSet>(NULL);
}
// Selectors
//- Return a reference to the selected sampledSet
static autoPtr<sampledSet> New
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~sampledSet();
// Member Functions
const polyMesh& mesh() const
{
return mesh_;
}
meshSearch& searchEngine() const
{
return searchEngine_;
}
const labelList& segments() const
{
return segments_;
}
const scalarList& curveDist() const
{
return curveDist_;
}
const labelList& cells() const
{
return cells_;
}
const labelList& faces() const
{
return faces_;
}
//- Given all sampling points (on all processors) return reference point
virtual point getRefPoint(const List<point>&) const = 0;
//- Output for debugging
Ostream& write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Typedef
IOsampledSets
Description
Instance of the generic IOOutputFilter for sampledSets.
\*---------------------------------------------------------------------------*/
#ifndef IOsampledSets_H
#define IOsampledSets_H
#include "sampledSets.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<sampledSets> IOsampledSets;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,368 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "sampledSets.H"
#include "dictionary.H"
#include "Time.H"
#include "volFields.H"
#include "ListListOps.H"
#include "SortableList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledSets, 0);
}
bool Foam::sampledSets::verbose_ = false;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::sampledSets::checkFieldTypes()
{
wordList fieldTypes(fieldNames_.size());
// check files for a particular time
if (loadFromFiles_)
{
forAll(fieldNames_, fieldi)
{
IOobject io
(
fieldNames_[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[fieldi] = io.headerClassName();
}
else
{
fieldTypes[fieldi] = "(notFound)";
}
}
}
else
{
// check objectRegistry
forAll(fieldNames_, fieldi)
{
objectRegistry::const_iterator iter =
mesh_.find(fieldNames_[fieldi]);
if (iter != mesh_.objectRegistry::end())
{
fieldTypes[fieldi] = iter()->type();
}
else
{
fieldTypes[fieldi] = "(notFound)";
}
}
}
label nFields = 0;
// classify fieldTypes
nFields += grep(scalarFields_, fieldTypes);
nFields += grep(vectorFields_, fieldTypes);
nFields += grep(sphericalTensorFields_, fieldTypes);
nFields += grep(symmTensorFields_, fieldTypes);
nFields += grep(tensorFields_, fieldTypes);
if (Pstream::master)
{
if (debug)
{
Pout<< "timeName = " << mesh_.time().timeName() << nl
<< "scalarFields " << scalarFields_ << nl
<< "vectorFields " << vectorFields_ << nl
<< "sphTensorFields " << sphericalTensorFields_ << nl
<< "symTensorFields " << symmTensorFields_ <<nl
<< "tensorFields " << tensorFields_ <<nl;
}
if (nFields > 0)
{
if (debug)
{
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName()
<< nl << endl;
}
mkDir(outputPath_/mesh_.time().timeName());
}
}
return nFields > 0;
}
void Foam::sampledSets::combineSampledSets
(
PtrList<coordSet>& masterSampledSets,
labelListList& indexSets
)
{
// Combine sampleSets from processors. Sort by curveDist. Return
// ordering in indexSets.
// Note: only master results are valid
masterSampledSets_.clear();
masterSampledSets_.setSize(size());
indexSets_.setSize(size());
const PtrList<sampledSet>& sampledSets = *this;
forAll(sampledSets, seti)
{
const sampledSet& samplePts = sampledSets[seti];
// Collect data from all processors
List<List<point> > gatheredPts(Pstream::nProcs());
gatheredPts[Pstream::myProcNo()] = samplePts;
Pstream::gatherList(gatheredPts);
List<labelList> gatheredSegments(Pstream::nProcs());
gatheredSegments[Pstream::myProcNo()] = samplePts.segments();
Pstream::gatherList(gatheredSegments);
List<scalarList> gatheredDist(Pstream::nProcs());
gatheredDist[Pstream::myProcNo()] = samplePts.curveDist();
Pstream::gatherList(gatheredDist);
// Combine processor lists into one big list.
List<point> allPts
(
ListListOps::combine<List<point> >
(
gatheredPts, accessOp<List<point> >()
)
);
labelList allSegments
(
ListListOps::combine<labelList>
(
gatheredSegments, accessOp<labelList>()
)
);
scalarList allCurveDist
(
ListListOps::combine<scalarList>
(
gatheredDist, accessOp<scalarList>()
)
);
// Sort curveDist and use to fill masterSamplePts
SortableList<scalar> sortedDist(allCurveDist);
indexSets[seti] = sortedDist.indices();
// Get reference point (note: only master has all points)
point refPt;
if (allPts.size() > 0)
{
refPt = samplePts.getRefPoint(allPts);
}
else
{
refPt = vector::zero;
}
masterSampledSets.set
(
seti,
new coordSet
(
samplePts.name(),
samplePts.axis(),
IndirectList<point>(allPts, indexSets[seti]),
refPt
)
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSets::sampledSets
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
PtrList<sampledSet>(),
name_(name),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
outputPath_(fileName::null),
searchEngine_(mesh_, true),
pMeshPtr_(NULL),
pInterpPtr_(NULL),
fieldNames_(),
interpolationScheme_(word::null),
writeFormat_(word::null)
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/name_;
}
else
{
outputPath_ = mesh_.time().path()/name_;
}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledSets::~sampledSets()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sampledSets::verbose(const bool verbosity)
{
verbose_ = verbosity;
}
void Foam::sampledSets::write()
{
if (size() && checkFieldTypes())
{
sampleAndWrite(scalarFields_);
sampleAndWrite(vectorFields_);
sampleAndWrite(sphericalTensorFields_);
sampleAndWrite(symmTensorFields_);
sampleAndWrite(tensorFields_);
}
}
void Foam::sampledSets::read(const dictionary& dict)
{
dict_ = dict;
fieldNames_ = wordList(dict_.lookup("fields"));
interpolationScheme_ = "cell";
if (dict_.found("interpolationScheme"))
{
dict_.lookup("interpolationScheme") >> interpolationScheme_;
}
writeFormat_ = "null";
if (dict_.found("setFormat"))
{
dict_.lookup("setFormat") >> writeFormat_;
}
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
PtrList<sampledSet> newList
(
dict_.lookup("sets"),
sampledSet::iNew(mesh_, searchEngine_)
);
transfer(newList);
combineSampledSets(masterSampledSets_, indexSets_);
if (Pstream::master() && debug)
{
Pout<< "sample fields:" << fieldNames_ << nl
<< "sample sets:" << nl << "(" << nl;
forAll(*this, si)
{
Pout << " " << operator[](si) << endl;
}
Pout << ")" << endl;
}
}
void Foam::sampledSets::correct()
{
pMeshPtr_.clear();
pInterpPtr_.clear();
searchEngine_.correct();
PtrList<sampledSet> newList
(
dict_.lookup("sets"),
sampledSet::iNew(mesh_, searchEngine_)
);
transfer(newList);
combineSampledSets(masterSampledSets_, indexSets_);
}
void Foam::sampledSets::updateMesh(const mapPolyMesh&)
{
correct();
}
void Foam::sampledSets::movePoints(const pointField&)
{
correct();
}
void Foam::sampledSets::readUpdate(const polyMesh::readUpdateState state)
{
if (state != polyMesh::UNCHANGED)
{
correct();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,315 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::sampledSets
Description
Set of sets to sample.
Call sampledSets.write() to sample&write files.
SourceFiles
sampledSets.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSets_H
#define sampledSets_H
#include "sampledSet.H"
#include "volFieldsFwd.H"
#include "meshSearch.H"
#include "interpolation.H"
#include "coordSet.H"
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class objectRegistry;
class dictionary;
class fvMesh;
class volPointInterpolation;
/*---------------------------------------------------------------------------*\
Class sampledSets Declaration
\*---------------------------------------------------------------------------*/
class sampledSets
:
public PtrList<sampledSet>
{
// Private classes
//- Class used for grouping field types
template<class Type>
class fieldGroup
:
public wordList
{
public:
//- Set formatter
autoPtr<writer<Type> > formatter;
//- Construct null
fieldGroup()
:
wordList(0),
formatter(NULL)
{}
void clear()
{
wordList::clear();
formatter.clear();
}
};
//- Class used for sampling volFields
template <class Type>
class volFieldSampler
:
public List<Field<Type> >
{
//- Name of this collection of values
const word name_;
public:
//- Construct interpolating field to the sampleSets
volFieldSampler
(
const volPointInterpolation&,
const word& interpolationScheme,
const GeometricField<Type, fvPatchField, volMesh>& field,
const PtrList<sampledSet>&
);
//- Construct mapping field to the sampleSets
volFieldSampler
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const PtrList<sampledSet>&
);
//- Construct from components
volFieldSampler
(
const List<Field<Type> >& values,
const word& name
);
//- Return the field name
const word& name() const
{
return name_;
}
};
// Static data members
//- output verbosity
static bool verbose_;
// 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_;
//- Keep the dictionary to recreate sets for moving mesh cases
dictionary dict_;
//- Load fields from files (not from objectRegistry)
bool loadFromFiles_;
//- Output path
fileName outputPath_;
//- Mesh search engine
meshSearch searchEngine_;
//- pointMesh for interpolation
autoPtr<pointMesh> pMeshPtr_;
//- volPointInterpolation for interpolation
autoPtr<volPointInterpolation> pInterpPtr_;
// Read from dictonary
//- Names of fields to sample
wordList fieldNames_;
//- Interpolation scheme to use
word interpolationScheme_;
//- Output format to use
word writeFormat_;
// Categorized scalar/vector/tensor fields
fieldGroup<scalar> scalarFields_;
fieldGroup<vector> vectorFields_;
fieldGroup<sphericalTensor> sphericalTensorFields_;
fieldGroup<symmTensor> symmTensorFields_;
fieldGroup<tensor> tensorFields_;
// Merging structures
PtrList<coordSet> masterSampledSets_;
labelListList indexSets_;
// Private Member Functions
//- Classify field types, return true if nFields > 0
bool checkFieldTypes();
//- Find the fields in the list of the given type, return count
template<class Type>
label grep
(
fieldGroup<Type>& fieldList,
const wordList& fieldTypes
) const;
//- Combine points from all processors. Sort by curveDist and produce
// index list. Valid result only on master processor.
void combineSampledSets
(
PtrList<coordSet>& masterSampledSets,
labelListList& indexSets
);
//- Combine values from all processors.
// Valid result only on master processor.
template<class T>
void combineSampledValues
(
const PtrList<volFieldSampler<T> >& sampledFields,
const labelListList& indexSets,
PtrList<volFieldSampler<T> >& masterFields
);
template<class Type>
void writeSampleFile
(
const coordSet& masterSampleSet,
const PtrList<volFieldSampler<Type> >& masterFields,
const label setI,
const fileName& timeDir,
const writer<Type>& formatter
);
template<class Type>
void sampleAndWrite(fieldGroup<Type>& fields);
//- Disallow default bitwise copy construct and assignment
sampledSets(const sampledSets&);
void operator=(const sampledSets&);
public:
//- Runtime type information
TypeName("sets");
// Constructors
//- Construct for given objectRegistry and dictionary
// allow the possibility to load fields from files
sampledSets
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor
virtual ~sampledSets();
// 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);
//- Sample and write
virtual void write();
//- Read the sampledSets
virtual void read(const dictionary&);
//- Correct for mesh changes
void correct();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh point-motion
virtual void movePoints(const pointField&);
//- Update for changes of mesh due to readUpdate
virtual void readUpdate(const polyMesh::readUpdateState state);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "sampledSetsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,353 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "sampledSets.H"
#include "volFields.H"
#include "volPointInterpolation.H"
#include "ListListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Type>
Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
(
const volPointInterpolation& pInterp,
const word& interpolationScheme,
const GeometricField<Type, fvPatchField, volMesh>& field,
const PtrList<sampledSet>& samplers
)
:
List<Field<Type> >(samplers.size()),
name_(field.name())
{
autoPtr<interpolation<Type> > interpolator
(
interpolation<Type>::New(interpolationScheme, pInterp, field)
);
forAll(samplers, seti)
{
Field<Type>& values = this->operator[](seti);
const sampledSet& samples = samplers[seti];
values.setSize(samples.size());
forAll(samples, samplei)
{
const point& samplePt = samples[samplei];
label celli = samples.cells()[samplei];
label facei = samples.faces()[samplei];
values[samplei] = interpolator().interpolate
(
samplePt,
celli,
facei
);
}
}
}
template <class Type>
Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const PtrList<sampledSet>& samplers
)
:
List<Field<Type> >(samplers.size()),
name_(field.name())
{
forAll(samplers, seti)
{
Field<Type>& values = this->operator[](seti);
const sampledSet& samples = samplers[seti];
values.setSize(samples.size());
forAll(samples, samplei)
{
values[samplei] = field[samples.cells()[samplei]];
}
}
}
template <class Type>
Foam::sampledSets::volFieldSampler<Type>::volFieldSampler
(
const List<Field<Type> >& values,
const word& name
)
:
List<Field<Type> >(values),
name_(name)
{}
template<class Type>
Foam::label Foam::sampledSets::grep
(
fieldGroup<Type>& fieldList,
const wordList& fieldTypes
) const
{
fieldList.setSize(fieldNames_.size());
label nFields = 0;
forAll(fieldNames_, fieldi)
{
if
(
fieldTypes[fieldi]
== GeometricField<Type, fvPatchField, volMesh>::typeName
)
{
fieldList[nFields] = fieldNames_[fieldi];
nFields++;
}
}
fieldList.setSize(nFields);
return nFields;
}
template<class Type>
void Foam::sampledSets::writeSampleFile
(
const coordSet& masterSampleSet,
const PtrList<volFieldSampler<Type> >& masterFields,
const label seti,
const fileName& timeDir,
const writer<Type>& formatter
)
{
wordList valueSetNames(masterFields.size());
List<const Field<Type>*> valueSets(masterFields.size());
forAll(masterFields, fieldi)
{
valueSetNames[fieldi] = masterFields[fieldi].name();
valueSets[fieldi] = &masterFields[fieldi][seti];
}
fileName fName
(
timeDir/formatter.getFileName(masterSampleSet, valueSetNames)
);
formatter.write
(
masterSampleSet,
valueSetNames,
valueSets,
OFstream(fName)()
);
}
template<class T>
void Foam::sampledSets::combineSampledValues
(
const PtrList<volFieldSampler<T> >& sampledFields,
const labelListList& indexSets,
PtrList<volFieldSampler<T> >& masterFields
)
{
forAll(sampledFields, fieldi)
{
List<Field<T> > masterValues(indexSets.size());
forAll(indexSets, seti)
{
// Collect data from all processors
List<Field<T> > gatheredData(Pstream::nProcs());
gatheredData[Pstream::myProcNo()] = sampledFields[fieldi][seti];
Pstream::gatherList(gatheredData);
if (Pstream::master())
{
Field<T> allData
(
ListListOps::combine<Field<T> >
(
gatheredData,
Foam::accessOp<Field<T> >()
)
);
masterValues[seti] =
IndirectList<T>(allData, indexSets[seti])();
}
}
masterFields.set
(
fieldi,
new volFieldSampler<T>
(
masterValues,
sampledFields[fieldi].name()
)
);
}
}
template<class Type>
void Foam::sampledSets::sampleAndWrite
(
fieldGroup<Type>& fields
)
{
if (fields.size())
{
bool interpolate = interpolationScheme_ != "cell";
if (interpolate && (!pMeshPtr_.valid() || !pInterpPtr_.valid()))
{
// set up interpolation
pMeshPtr_.reset(new pointMesh(mesh_));
pInterpPtr_.reset(new volPointInterpolation(mesh_, pMeshPtr_()));
}
// Create or use existing writer
if (!fields.formatter.valid())
{
fields.formatter = writer<Type>::New(writeFormat_);
}
// Storage for interpolated values
PtrList<volFieldSampler<Type> > sampledFields(fields.size());
forAll(fields, fieldi)
{
if (Pstream::master() && verbose_)
{
Pout<< "sampledSets::sampleAndWrite: "
<< fields[fieldi] << endl;
}
if (loadFromFiles_)
{
GeometricField<Type, fvPatchField, volMesh> vf
(
IOobject
(
fields[fieldi],
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
mesh_
);
if (interpolate)
{
sampledFields.set
(
fieldi,
new volFieldSampler<Type>
(
pInterpPtr_(),
interpolationScheme_,
vf,
*this
)
);
}
else
{
sampledFields.set
(
fieldi,
new volFieldSampler<Type>(vf, *this)
);
}
}
else
{
if (interpolate)
{
sampledFields.set
(
fieldi,
new volFieldSampler<Type>
(
pInterpPtr_(),
interpolationScheme_,
mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh> >
(fields[fieldi]),
*this
)
);
}
else
{
sampledFields.set
(
fieldi,
new volFieldSampler<Type>
(
mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh> >
(fields[fieldi]),
*this
)
);
}
}
}
// Combine sampled fields from processors.
// Note: only master results are valid
PtrList<volFieldSampler<Type> > masterFields(sampledFields.size());
combineSampledValues(sampledFields, indexSets_, masterFields);
if (Pstream::master())
{
forAll(masterSampledSets_, seti)
{
writeSampleFile
(
masterSampledSets_[seti],
masterFields,
seti,
outputPath_/mesh_.time().timeName(),
fields.formatter()
);
}
}
}
}
// ************************************************************************* //

View File

@ -24,18 +24,18 @@ License
\*---------------------------------------------------------------------------*/
#include "surfacesFunctionObject.H"
#include "sampledSetsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(surfacesFunctionObject, 0);
defineNamedTemplateTypeNameAndDebug(sampledSetsFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
surfacesFunctionObject,
sampledSetsFunctionObject,
dictionary
);
}

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Typedef
Foam::sampledSetsFunctionObject
Description
FunctionObject wrapper around sets to allow them to be created via the
functions list 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

@ -0,0 +1,498 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "uniformSet.H"
#include "meshSearch.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "IDLList.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(uniformSet, 0);
addToRunTimeSelectionTable(sampledSet, uniformSet, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Finds along line (samplePt + t * offset) next sample beyond or equal to
// currentPt.
// Updates samplePt, sampleI
bool Foam::uniformSet::nextSample
(
const point& currentPt,
const vector& offset,
const scalar smallDist,
point& samplePt,
label& sampleI
) const
{
bool pointFound = false;
const vector normOffset = offset/mag(offset);
samplePt += offset;
sampleI++;
for(; sampleI < nPoints_; sampleI++)
{
scalar s = (samplePt - currentPt) & normOffset;
if (s > -smallDist)
{
// samplePt is close to or beyond currentPt -> use it
pointFound = true;
break;
}
samplePt += offset;
}
return pointFound;
}
// Sample singly connected segment. Returns false if end_ reached.
bool Foam::uniformSet::trackToBoundary
(
Particle<passiveParticle>& singleParticle,
point& samplePt,
label& sampleI,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurveDist
) const
{
// distance vector between sampling points
const vector offset = (end_ - start_)/(nPoints_ - 1);
const vector smallVec = tol*offset;
const scalar smallDist = mag(smallVec);
// Alias
const point& trackPt = singleParticle.position();
while(true)
{
// Find next samplePt on/after trackPt. Update samplePt, sampleI
if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
{
// no more samples.
if (debug)
{
Info<< "trackToBoundary : Reached end : samplePt now:"
<< samplePt << " sampleI now:" << sampleI << endl;
}
return false;
}
if (mag(samplePt - trackPt) < smallDist)
{
// trackPt corresponds with samplePt. Store and use next samplePt
if (debug)
{
Info<< "trackToBoundary : samplePt corresponds to trackPt : "
<< " trackPt:" << trackPt << " samplePt:" << samplePt
<< endl;
}
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(-1);
samplingCurveDist.append(mag(trackPt - start_));
// go to next samplePt
if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
{
// no more samples.
if (debug)
{
Info<< "trackToBoundary : Reached end : "
<< " samplePt now:" << samplePt
<< " sampleI now:" << sampleI
<< endl;
}
return false;
}
}
if (debug)
{
Info<< "Searching along trajectory from "
<< " trackPt:" << trackPt
<< " trackCellI:" << singleParticle.cell()
<< " to:" << samplePt << endl;
}
point oldPos = trackPt;
label facei = -1;
do
{
singleParticle.stepFraction() = 0;
singleParticle.track(samplePt);
if (debug)
{
Info<< "Result of tracking "
<< " trackPt:" << trackPt
<< " trackCellI:" << singleParticle.cell()
<< " trackFaceI:" << singleParticle.face()
<< " onBoundary:" << singleParticle.onBoundary()
<< " samplePt:" << samplePt
<< " smallDist:" << smallDist
<< endl;
}
}
while
(
!singleParticle.onBoundary()
&& (mag(trackPt - oldPos) < smallDist)
);
if (singleParticle.onBoundary())
{
//Info<< "trackToBoundary : reached boundary" << endl;
if (mag(trackPt - samplePt) < smallDist)
{
//Info<< "trackToBoundary : boundary is also sampling point"
// << endl;
// Reached samplePt on boundary
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(facei);
samplingCurveDist.append(mag(trackPt - start_));
}
return true;
}
//Info<< "trackToBoundary : reached internal sampling point" << endl;
// Reached samplePt in cell or on internal face
samplingPts.append(trackPt);
samplingCells.append(singleParticle.cell());
samplingFaces.append(-1);
samplingCurveDist.append(mag(trackPt - start_));
// go to next samplePt
}
}
void Foam::uniformSet::calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const
{
// distance vector between sampling points
if ((nPoints_ < 2) || (mag(end_ - start_) < SMALL))
{
FatalErrorIn("uniformSet::calcSamples()")
<< "Incorrect sample specification. Either too few points or"
<< " start equals end point." << endl
<< "nPoints:" << nPoints_
<< " start:" << start_
<< " end:" << end_
<< exit(FatalError);
}
const vector offset = (end_ - start_)/(nPoints_ - 1);
const vector normOffset = offset/mag(offset);
const vector smallVec = tol*offset;
const scalar smallDist = mag(smallVec);
// Get all boundary intersections
List<pointIndexHit> bHits =
searchEngine().intersections
(
start_ - smallVec,
end_ + smallVec
);
point bPoint(GREAT, GREAT, GREAT);
label bFaceI = -1;
if (bHits.size() > 0)
{
bPoint = bHits[0].hitPoint();
bFaceI = bHits[0].index();
}
// Get first tracking point. Use bPoint, bFaceI if provided.
point trackPt;
label trackCellI = -1;
label trackFaceI = -1;
bool isSample =
getTrackingPoint
(
offset,
start_,
bPoint,
bFaceI,
trackPt,
trackCellI,
trackFaceI
);
if (trackCellI == -1)
{
// Line start_ - end_ does not intersect domain at all.
// (or is along edge)
// Set points and cell/face labels to empty lists
return;
}
if (isSample)
{
samplingPts.append(start_);
samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI);
samplingCurveDist.append(0.0);
}
//
// Track until hit end of all boundary intersections
//
// current segment number
label segmentI = 0;
// starting index of current segment in samplePts
label startSegmentI = 0;
label sampleI = 0;
point samplePt = start_;
// index in bHits; current boundary intersection
label bHitI = 1;
while(true)
{
// Initialize tracking starting from trackPt
Cloud<passiveParticle> particles(mesh(), IDLList<passiveParticle>());
passiveParticle singleParticle
(
particles,
trackPt,
trackCellI
);
bool reachedBoundary = trackToBoundary
(
singleParticle,
samplePt,
sampleI,
samplingPts,
samplingCells,
samplingFaces,
samplingCurveDist
);
// fill sampleSegments
for(label i = samplingPts.size() - 1; i >= startSegmentI; --i)
{
samplingSegments.append(segmentI);
}
if (!reachedBoundary)
{
if (debug)
{
Info<< "calcSamples : Reached end of samples: "
<< " samplePt now:" << samplePt
<< " sampleI now:" << sampleI
<< endl;
}
break;
}
bool foundValidB = false;
while (bHitI < bHits.size())
{
scalar dist =
(bHits[bHitI].hitPoint() - singleParticle.position())
& normOffset;
if (debug)
{
Info<< "Finding next boundary : "
<< "bPoint:" << bHits[bHitI].hitPoint()
<< " tracking:" << singleParticle.position()
<< " dist:" << dist
<< endl;
}
if (dist > smallDist)
{
// hitpoint is past tracking position
foundValidB = true;
break;
}
else
{
bHitI++;
}
}
if (!foundValidB)
{
// No valid boundary intersection found beyond tracking position
break;
}
// Update starting point for tracking
trackFaceI = bFaceI;
trackPt = pushIn(bPoint, trackFaceI);
trackCellI = getBoundaryCell(trackFaceI);
segmentI++;
startSegmentI = samplingPts.size();
}
}
void Foam::uniformSet::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::uniformSet::uniformSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end,
const label nPoints
)
:
sampledSet(name, mesh, searchEngine, axis),
start_(start),
end_(end),
nPoints_(nPoints)
{
genSamples();
if (debug)
{
write(Info);
}
}
Foam::uniformSet::uniformSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampledSet(name, mesh, searchEngine, dict),
start_(dict.lookup("start")),
end_(dict.lookup("end")),
nPoints_(readLabel(dict.lookup("nPoints")))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::uniformSet::~uniformSet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::point Foam::uniformSet::getRefPoint(const List<point>& pts) const
{
// Use start point as reference for 'distance'
return start_;
}
// ************************************************************************* //

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------* \
========= |
\\ / 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
Class
Foam::uniformSet
Description
SourceFiles
uniformSet.C
\*---------------------------------------------------------------------------*/
#ifndef uniformSet_H
#define uniformSet_H
#include "sampledSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class Particle;
/*---------------------------------------------------------------------------*\
Class uniformSet Declaration
\*---------------------------------------------------------------------------*/
class uniformSet
:
public sampledSet
{
// Private data
//- Starting point
point start_;
//- End point
point end_;
//- Number of points
label nPoints_;
// Private Member Functions
//- Calculates - starting at samplePt - the first sampling point
// on or after currentPt. smallDist is the tolerance used to compare
// positions. Returns false if end of samples reached.
bool nextSample
(
const point& currentPt,
const vector& offset,
const scalar smallDist,
point& samplePt,
label& sampleI
) const;
//- Samples from startTrackPt/CellI. Updates particle/samplePt/sampleI
// and puts
// samples in the DynamicLists. Returns false if end of all samples
// reached
bool trackToBoundary
(
Particle<passiveParticle>& singleParticle,
point& samplePt,
label& sampleI,
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurveDist
) const;
//- Samples from start_ to end_. samplingSegments contains segmentNo
// for each sample.
void calcSamples
(
DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces,
DynamicList<label>& samplingSegments,
DynamicList<scalar>& samplingCurveDist
) const;
//- Uses calcSamples to obtain samples. Copies them into *this.
void genSamples();
public:
//- Runtime type information
TypeName("uniform");
// Constructors
//- Construct from components
uniformSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const word& axis,
const point& start,
const point& end,
const label nPoints
);
//- Construct from dictionary
uniformSet
(
const word& name,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~uniformSet();
// Member Functions
//- Get reference point
virtual point getRefPoint(const List<point>&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "gnuplot.H"
#include "clock.H"
#include "coordSet.H"
#include "fileName.H"
#include "OFstream.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::gnuplot<Type>::gnuplot()
:
writer<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::gnuplot<Type>::~gnuplot()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::gnuplot<Type>::getFileName
(
const coordSet& points,
const wordList& valueSetNames
) const
{
return this->getBaseName(points, valueSetNames) + ".gplt";
}
template<class Type>
void Foam::gnuplot<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
const List<const Field<Type>*>& valueSets,
Ostream& os
) const
{
os << "set term postscript color" << endl
<< "set output \"" << points.name() << ".ps\"" << endl
<< "plot";
bool firstField = true;
forAll(valueSets, i)
{
if (!firstField)
{
os << ',';
}
firstField = false;
os << "'-' title \"" << valueSetNames[i] << "\" with lines";
}
os << endl;
forAll(valueSets, i)
{
os << endl;
writeTable(points, *valueSets[i], os);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::gnuplot
Description
SourceFiles
gnuplot.C
\*---------------------------------------------------------------------------*/
#ifndef gnuplot_H
#define gnuplot_H
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class gnuplot Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class gnuplot
:
public writer<Type>
{
public:
//- Runtime type information
TypeName("gnuplot");
// Constructors
//- Construct null
gnuplot();
// Destructor
virtual ~gnuplot();
// Member Functions
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "gnuplot.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "gnuplotWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(gnuplot);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
InClass
Foam::gnuplotWriters
Description
SourceFiles
gnuplotWriters.C
\*---------------------------------------------------------------------------*/
#ifndef gnuplotWriters_H
#define gnuplotWriters_H
#include "gnuplot.H"
#include "writers.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef gnuplot<scalar> gnuplotScalarWriter;
typedef gnuplot<vector> gnuplotVectorWriter;
typedef gnuplot<tensor> gnuplotTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "jplot.H"
#include "clock.H"
#include "coordSet.H"
#include "fileName.H"
#include "OFstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::jplot<Type>::writeHeader(Ostream& os) const
{
return os
<< "# JPlot input file" << endl
<< "#" << endl
<< endl
<< "# Generated by sample on " << clock::date().c_str() << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::jplot<Type>::jplot()
:
writer<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::jplot<Type>::~jplot()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::jplot<Type>::getFileName
(
const coordSet& points,
const wordList& valueSetNames
) const
{
return this->getBaseName(points, valueSetNames) + ".dat";
}
template<class Type>
void Foam::jplot<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
const List<const Field<Type>*>& valueSets,
Ostream& os
) const
{
os << "# JPlot file" << endl
<< "# column 1: " << points.name() << endl;
forAll(valueSets, i)
{
os << "# column " << i + 2 << ": " << valueSetNames[i] << endl;
}
// Collect sets into columns
List<const List<Type>*> columns(valueSets.size());
forAll(valueSets, i)
{
columns[i] = valueSets[i];
}
writeTable(points, columns, os);
}
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::jplot
Description
SourceFiles
jplot.C
\*---------------------------------------------------------------------------*/
#ifndef jplot_H
#define jplot_H
#include "writer.H"
#include "vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class jplot Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class jplot
:
public writer<Type>
{
// Private Member Functions
//- Write header
Ostream& writeHeader(Ostream& os) const;
public:
//- Runtime type information
TypeName("jplot");
// Constructors
//- Construct null
jplot();
// Destructor
virtual ~jplot();
// Member Functions
// Access
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "jplot.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "jplotWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(jplot);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
InClass
Foam::jplotWriters
Description
SourceFiles
jplotWriters.C
\*---------------------------------------------------------------------------*/
#ifndef jplotWriters_H
#define jplotWriters_H
#include "jplot.H"
#include "writers.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef jplot<scalar> jplotScalarWriter;
typedef jplot<vector> jplotVectorWriter;
typedef jplot<tensor> jplotTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "raw.H"
#include "coordSet.H"
#include "fileName.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::raw<Type>::raw()
:
writer<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::raw<Type>::~raw()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::raw<Type>::getFileName
(
const coordSet& points,
const wordList& valueSetNames
) const
{
return this->getBaseName(points, valueSetNames) + ".xy";
}
template<class Type>
void Foam::raw<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
const List<const Field<Type>*>& valueSets,
Ostream& os
) const
{
// Collect sets into columns
List<const List<Type>*> columns(valueSets.size());
forAll(valueSets, i)
{
columns[i] = valueSets[i];
}
writeTable(points, columns, os);
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::raw
Description
SourceFiles
raw.C
\*---------------------------------------------------------------------------*/
#ifndef raw_H
#define raw_H
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class raw Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class raw
:
public writer<Type>
{
public:
//- Runtime type information
TypeName("raw");
// Constructors
//- Construct null
raw();
// Destructor
virtual ~raw();
// Member Functions
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "raw.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -22,10 +22,12 @@ 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 "rawWriters.H"
#include "addToRunTimeSelectionTable.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -22,21 +22,22 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
rawWriters
InClass
Foam::rawWriters
Description
SourceFiles
rawWriters.C
\*---------------------------------------------------------------------------*/
#ifndef rawWriters_H
#define rawWriters_H
#include "raw.H"
#include "surfaceWriters.H"
#include "writers.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,8 +49,6 @@ namespace Foam
typedef raw<scalar> rawScalarWriter;
typedef raw<vector> rawVectorWriter;
typedef raw<sphericalTensor> rawSphericalTensorWriter;
typedef raw<symmTensor> rawSymmTensorWriter;
typedef raw<tensor> rawTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,205 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "writer.H"
#include "coordSet.H"
#include "OFstream.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
autoPtr<writer<Type> > writer<Type>::New(const word& writeType)
{
typename wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
->find(writeType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"writer::New(const word&)"
) << "Unknown write type " << writeType
<< endl << endl
<< "Valid write types : " << endl
<< wordConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<writer<Type> >(cstrIter()());
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
fileName writer<Type>::getBaseName
(
const coordSet& points,
const wordList& valueSets
) const
{
fileName fName(points.name());
forAll(valueSets, i)
{
fName += '_' + valueSets[i];
}
return fName;
}
template<class Type>
void writer<Type>::writeCoord
(
const coordSet& points,
const label pointI,
Ostream& os
) const
{
if (points.hasVectorAxis())
{
write(points.vectorCoord(pointI), os);
}
else
{
write(points.scalarCoord(pointI), os);
}
}
template<class Type>
void writer<Type>::writeTable
(
const coordSet& points,
const List<Type>& values,
Ostream& os
) const
{
forAll(points, pointI)
{
writeCoord(points, pointI, os);
os << token::SPACE;
write(values[pointI], os);
os << endl;
}
}
template<class Type>
void writer<Type>::writeTable
(
const coordSet& points,
const List<const List<Type>*>& valuesPtrList,
Ostream& os
) const
{
forAll(points, pointI)
{
writeCoord(points, pointI, os);
forAll(valuesPtrList, i)
{
os << token::SPACE;
const List<Type>& values = *valuesPtrList[i];
write(values[pointI], os);
}
os << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct null
template<class Type>
writer<Type>::writer()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
writer<Type>::~writer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::writer<Type>::write(const scalar value, Ostream& os) const
{
return os << value;
}
template<class Type>
Foam::Ostream& Foam::writer<Type>::write(const vector& value, Ostream& os) const
{
for (direction d=0; d<vector::nComponents; d++)
{
os << value.component(d);
if (d <= vector::nComponents-1)
{
os << token::TAB;
}
}
return os;
}
template<class Type>
Foam::Ostream& Foam::writer<Type>::write(const tensor& value, Ostream& os) const
{
for (direction d=0; d<tensor::nComponents; d++)
{
os << value.component(d);
if (d <= tensor::nComponents-1)
{
os << token::TAB;
}
}
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,239 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::writer
Description
base class for graphics format writing. Entry points are
- write(..). Write to an Ostream a table of points with corresponding
values.
- write(scalar/vector/tensor). Write single scalar/vector/tensor.
Default is to write space separated components.
Example:
// Construct writer of xmgr type
autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
// Output list of points and corresponding values
scalarFormatter().write
(
coordSet
(
points, // sample coordinates
"someLine", // name of coordSet
"distance", // write coordinates as distance to refPoint
points[0] // reference point
),
"U.component(0)", // name of values
vals // values
);
SourceFiles
writer.C
\*---------------------------------------------------------------------------*/
#ifndef writer_H
#define writer_H
#include "fileName.H"
#include "wordList.H"
#include "vector.H"
#include "tensor.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "Field.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class coordSet;
/*---------------------------------------------------------------------------*\
Class writer Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class writer
{
protected:
//- Generates filename from coordSet and sampled fields
fileName getBaseName(const coordSet&, const wordList&) const;
void writeCoord
(
const coordSet& samples,
const label sampleI,
Ostream& os
) const;
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
// columns 2 is the value. Uses write() function
// to write coordinate in correct format.
void writeTable
(
const coordSet&,
const List<Type>&,
Ostream& os
) const;
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
// columns 2..n are the values. Uses write() function
// to write coordinate in correct format.
void writeTable
(
const coordSet&,
const List<const List<Type>*>&,
Ostream& os
) const;
public:
//- Runtime type information
TypeName("writer");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
writer,
word,
(),
()
);
// Selectors
//- Return a reference to the selected writer
static autoPtr<writer> New
(
const word& writeFormat
);
// Constructors
//- Construct null
writer();
// Destructor
virtual ~writer() = 0;
// Member Functions
// Access
// Write
//- Generate file name with correct extension
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const = 0;
//- General entry point for writing.
// The data is organized in a set of point with one or
// more values per point
virtual void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream&
) const = 0;
//- Write scalar as ascii
virtual Ostream& write(const scalar, Ostream&) const;
//- Write vector. Tab separated ascii
virtual Ostream& write(const vector&, Ostream&) const;
//- Write tensor. Tab separated ascii
virtual Ostream& write(const tensor&, Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "writer.C"
#endif
// Only used internally
#define makeTypeWritersTypeName(type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0);
// Used externally sometimes
#define makeWritersTypeName(typeWriter) \
\
makeTypeWritersTypeName(typeWriter##ScalarWriter); \
makeTypeWritersTypeName(typeWriter##VectorWriter); \
makeTypeWritersTypeName(typeWriter##TensorWriter);
// Define type info for single template instantiation (e.g. vector)
#define makeWriterTypes(WriterType, type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0); \
\
addToRunTimeSelectionTable \
( \
WriterType, type, word \
);
// Define type info info for scalar, vector etc. instantiations
#define makeWriters(typeWriter) \
\
makeWriterTypes(scalarWriter, typeWriter##ScalarWriter); \
makeWriterTypes(vectorWriter, typeWriter##VectorWriter); \
makeWriterTypes(tensorWriter, typeWriter##TensorWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "writers.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineNamedTemplateTypeNameAndDebug(scalarWriter, 0);
defineTemplateRunTimeSelectionTable(scalarWriter, word);
defineNamedTemplateTypeNameAndDebug(vectorWriter, 0);
defineTemplateRunTimeSelectionTable(vectorWriter, word);
defineNamedTemplateTypeNameAndDebug(sphericalTensorWriter, 0);
defineTemplateRunTimeSelectionTable(sphericalTensorWriter, word);
defineNamedTemplateTypeNameAndDebug(symmTensorWriter, 0);
defineTemplateRunTimeSelectionTable(symmTensorWriter, word);
defineNamedTemplateTypeNameAndDebug(tensorWriter, 0);
defineTemplateRunTimeSelectionTable(tensorWriter, word);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
InClass
Foam::writer
Description
\*---------------------------------------------------------------------------*/
#ifndef writers_H
#define writers_H
#include "writer.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef writer<scalar> scalarWriter;
typedef writer<vector> vectorWriter;
typedef writer<sphericalTensor> sphericalTensorWriter;
typedef writer<symmTensor> symmTensorWriter;
typedef writer<tensor> tensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "xmgr.H"
#include "coordSet.H"
#include "fileName.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::xmgr<Type>::xmgr()
:
writer<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::xmgr<Type>::~xmgr()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::xmgr<Type>::getFileName
(
const coordSet& points,
const wordList& valueSetNames
) const
{
return this->getBaseName(points, valueSetNames) + ".agr";
}
template<class Type>
void Foam::xmgr<Type>::write
(
const coordSet& points,
const wordList& valueSetNames,
const List<const Field<Type>*>& valueSets,
Ostream& os
) const
{
os << "@title \"" << points.name() << '"' << endl
<< "@xaxis label " << '"' << points.axis() << '"' << endl;
forAll(valueSets, i)
{
os << "@s" << i << " legend " << '"'
<< valueSetNames[i] << '"' << endl
<< "@target G0.S" << i << endl
<< "@type xy" << endl;
writeTable(points, *valueSets[i], os);
os << endl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
Foam::xmgr
Description
SourceFiles
xmgr.C
\*---------------------------------------------------------------------------*/
#ifndef xmgr_H
#define xmgr_H
#include "writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class xmgr Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class xmgr
:
public writer<Type>
{
public:
//- Runtime type information
TypeName("xmgr");
// Constructors
//- Construct null
xmgr();
// Destructor
virtual ~xmgr();
// Member Functions
// Write
virtual fileName getFileName
(
const coordSet&,
const wordList&
) const;
void write
(
const coordSet&,
const wordList&,
const List<const Field<Type>*>&,
Ostream& os
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "xmgr.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "xmgrWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(xmgr);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
InClass
Foam::xmgrWriters
Description
SourceFiles
xmgrWriters.C
\*---------------------------------------------------------------------------*/
#ifndef xmgrWriters_H
#define xmgrWriters_H
#include "xmgr.H"
#include "writers.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef xmgr<scalar> xmgrScalarWriter;
typedef xmgr<vector> xmgrVectorWriter;
typedef xmgr<tensor> xmgrTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -41,7 +41,6 @@ namespace Foam
addNamedToRunTimeSelectionTable(sampledSurface, sampledPatch, word, patch);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledPatch::createGeometry()
@ -98,79 +97,11 @@ void Foam::sampledPatch::createGeometry()
}
}
Pout << *this << endl;
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPatch::sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
// One value per face
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
if (debug)
{
const Field<Type>& bField = vField.boundaryField()[patchIndex()];
forAll(patchFaceLabels_, elemI)
{
values[elemI] = bField[patchFaceLabels_[elemI]];
}
print(Pout);
Pout << endl;
}
return tvalues;
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPatch::interpolateField
(
const interpolation<Type>& interpolator
) const
{
// One value per vertex
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
{
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
const labelList& own = mesh().faceOwner();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
label faceI = patchFaceLabels()[cutFaceI] + patch.start();
label cellI = own[faceI];
values[pointI] = interpolator.interpolate
(
points()[pointI],
cellI,
faceI
);
pointDone[pointI] = true;
}
}
}
}
return tvalues;
}
@ -178,13 +109,13 @@ Foam::sampledPatch::interpolateField
Foam::sampledPatch::sampledPatch
(
const polyMesh& mesh,
const word& name,
const polyMesh& mesh,
const word& patchName,
const bool triangulate
)
:
sampledSurface(mesh, name, triangulate),
sampledSurface(name, mesh, triangulate),
patchName_(patchName),
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
points_(0),
@ -197,11 +128,12 @@ Foam::sampledPatch::sampledPatch
Foam::sampledPatch::sampledPatch
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
sampledSurface(mesh, dict),
sampledSurface(name, mesh, dict),
patchName_(dict.lookup("patchName")),
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
points_(0),
@ -229,10 +161,6 @@ void Foam::sampledPatch::correct(const bool meshChanged)
}
//
// sample volume field
//
Foam::tmp<Foam::scalarField>
Foam::sampledPatch::sample
(
@ -282,10 +210,6 @@ Foam::sampledPatch::sample
}
//
// interpolate
//
Foam::tmp<Foam::scalarField>
Foam::sampledPatch::interpolate
(
@ -343,6 +267,5 @@ void Foam::sampledPatch::print(Ostream& os) const
<< " points:" << points().size();
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
sampledPatch
Foam::sampledPatch
Description
@ -84,10 +84,11 @@ class sampledPatch
tmp<Field<Type> >
interpolateField(const interpolation<Type>&) const;
public:
//- Runtime type information
TypeName("sampledPatch");
TypeName("sampledPatch");
// Constructors
@ -95,8 +96,8 @@ public:
//- Construct from components
sampledPatch
(
const polyMesh& mesh,
const word& name,
const polyMesh& mesh,
const word& patchName,
const bool triangulate = true
);
@ -104,6 +105,7 @@ public:
//- Construct from dictionary
sampledPatch
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
);
@ -210,12 +212,8 @@ public:
const interpolation<tensor>&
) const;
// Write
//- Write
virtual void print(Ostream&) const;
};
@ -225,6 +223,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "sampledPatchTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,103 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "sampledPatch.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPatch::sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
// One value per face
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
{
const Field<Type>& bField = vField.boundaryField()[patchIndex()];
forAll(patchFaceLabels_, elemI)
{
values[elemI] = bField[patchFaceLabels_[elemI]];
}
}
return tvalues;
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPatch::interpolateField
(
const interpolation<Type>& interpolator
) const
{
// One value per vertex
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
{
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
const labelList& own = mesh().faceOwner();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
label faceI = patchFaceLabels()[cutFaceI] + patch.start();
label cellI = own[faceI];
values[pointI] = interpolator.interpolate
(
points()[pointI],
cellI,
faceI
);
pointDone[pointI] = true;
}
}
}
}
return tvalues;
}
// ************************************************************************* //

View File

@ -39,7 +39,6 @@ namespace Foam
addNamedToRunTimeSelectionTable(sampledSurface, sampledPlane, word, plane);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledPlane::createGeometry()
@ -79,56 +78,11 @@ void Foam::sampledPlane::createGeometry()
}
}
print(Pout);
Pout << endl;
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPlane::sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
return tmp<Field<Type> >(new Field<Type>(vField, meshCells()));
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPlane::interpolateField
(
const interpolation<Type>& interpolator
) const
{
// One value per point
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
if (debug)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
values[pointI] = interpolator.interpolate
(
points()[pointI],
meshCells()[cutFaceI]
);
pointDone[pointI] = true;
}
}
print(Pout);
Pout << endl;
}
return tvalues;
}
@ -136,14 +90,14 @@ Foam::sampledPlane::interpolateField
Foam::sampledPlane::sampledPlane
(
const polyMesh& mesh,
const word& name,
const polyMesh& mesh,
const plane& planeDesc,
const word& zoneName,
const bool triangulate
)
:
sampledSurface(mesh, name, triangulate),
sampledSurface(name, mesh, triangulate),
cuttingPlane(planeDesc),
zoneName_(zoneName),
faces_(0),
@ -153,7 +107,7 @@ Foam::sampledPlane::sampledPlane
if (zoneName_.size())
{
zoneId = mesh.cellZones().findZoneID(zoneName_);
if (zoneId < 0)
if (debug && zoneId < 0)
{
Info<< "cellZone \"" << zoneName_
<< "\" not found - using entire mesh"
@ -161,7 +115,6 @@ Foam::sampledPlane::sampledPlane
}
}
if (zoneId < 0)
{
reCut(mesh);
@ -171,18 +124,18 @@ Foam::sampledPlane::sampledPlane
reCut(mesh, mesh.cellZones()[zoneId]);
}
createGeometry();
}
Foam::sampledPlane::sampledPlane
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
sampledSurface(mesh, dict),
sampledSurface(name, mesh, dict),
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
zoneName_(word::null),
faces_(0),
@ -207,7 +160,7 @@ Foam::sampledPlane::sampledPlane
{
dict.lookup("zone") >> zoneName_;
zoneId = mesh.cellZones().findZoneID(zoneName_);
if (zoneId < 0)
if (debug && zoneId < 0)
{
Info<< "cellZone \"" << zoneName_
<< "\" not found - using entire mesh"
@ -262,10 +215,6 @@ void Foam::sampledPlane::correct(const bool meshChanged)
}
//
// sample volume field
//
Foam::tmp<Foam::scalarField>
Foam::sampledPlane::sample
(
@ -315,10 +264,6 @@ Foam::sampledPlane::sample
}
//
// interpolate
//
Foam::tmp<Foam::scalarField>
Foam::sampledPlane::interpolate
(
@ -377,4 +322,5 @@ void Foam::sampledPlane::print(Ostream& os) const
<< " points:" << points().size();
}
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
sampledPlane
Foam::sampledPlane
Description
@ -80,10 +80,11 @@ class sampledPlane
tmp<Field<Type> >
interpolateField(const interpolation<Type>&) const;
public:
//- Runtime type information
TypeName("sampledPlane");
TypeName("sampledPlane");
// Constructors
@ -91,8 +92,8 @@ public:
//- Construct from components
sampledPlane
(
const polyMesh& mesh,
const word& name,
const polyMesh& mesh,
const plane& planeDesc,
const word& zoneName = word::null,
const bool triangulate = true
@ -101,6 +102,7 @@ public:
//- Construct from dictionary
sampledPlane
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
);
@ -213,12 +215,8 @@ public:
const interpolation<tensor>&
) const;
// Write
//- Write
virtual void print(Ostream&) const;
};
@ -228,6 +226,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "sampledPlaneTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "sampledPlane.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPlane::sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
return tmp<Field<Type> >(new Field<Type>(vField, meshCells()));
}
template <class Type>
Foam::tmp<Foam::Field<Type> >
Foam::sampledPlane::interpolateField
(
const interpolation<Type>& interpolator
) const
{
// One value per point
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const face& f = faces()[cutFaceI];
forAll(f, faceVertI)
{
label pointI = f[faceVertI];
if (!pointDone[pointI])
{
values[pointI] = interpolator.interpolate
(
points()[pointI],
meshCells()[cutFaceI]
);
pointDone[pointI] = true;
}
}
}
return tvalues;
}
// ************************************************************************* //

View File

@ -22,8 +22,6 @@ 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 "sampledSurface.H"
@ -39,7 +37,9 @@ namespace Foam
defineRunTimeSelectionTable(sampledSurface, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sampledSurface::clearGeom() const
{
deleteDemandDrivenData(SfPtr_);
@ -117,18 +117,23 @@ void Foam::sampledSurface::makeCf() const
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::sampledSurface>
Foam::sampledSurface::New
(
const word& sampleType,
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
{
word sampleType(dict.lookup("type"));
if (debug)
{
Info<< "Selecting sampled type " << sampleType << endl;
}
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
->find(sampleType);
wordConstructorTablePtr_->find(sampleType);
if (cstrIter == wordConstructorTablePtr_->end())
{
@ -145,11 +150,7 @@ Foam::sampledSurface::New
return autoPtr<sampledSurface>
(
cstrIter()
(
mesh,
dict
)
cstrIter()(name, mesh, dict)
);
}
@ -174,16 +175,15 @@ bool Foam::sampledSurface::getBool
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from mesh, name
Foam::sampledSurface::sampledSurface
(
const polyMesh& mesh,
const word& name,
const polyMesh& mesh,
const bool triangulate
)
:
mesh_(mesh),
name_(name),
mesh_(mesh),
triangulate_(triangulate),
interpolate_(false),
SfPtr_(NULL),
@ -192,15 +192,15 @@ Foam::sampledSurface::sampledSurface
{}
// Construct from dictionary
Foam::sampledSurface::sampledSurface
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
name_(name),
mesh_(mesh),
name_(type()),
triangulate_(getBool(dict, "triangulate", true)),
interpolate_(getBool(dict, "interpolate", false)),
SfPtr_(NULL),
@ -221,6 +221,7 @@ Foam::sampledSurface::~sampledSurface()
clearGeom();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::vectorField& Foam::sampledSurface::Sf() const
@ -310,6 +311,7 @@ void Foam::sampledSurface::print(Ostream& os) const
os << type();
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream &os, const sampledSurface& s)
@ -319,4 +321,5 @@ Foam::Ostream& Foam::operator<<(Ostream &os, const sampledSurface& s)
return os;
}
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
sampledSurface
Foam::sampledSurface
Description
@ -60,12 +60,12 @@ class sampledSurface
{
// Private data
//- Reference to mesh
const polyMesh& mesh_;
//- Name of sample surface
word name_;
//- Reference to mesh
const polyMesh& mesh_;
//- Make triangles or keep faces
const bool triangulate_;
@ -92,6 +92,7 @@ class sampledSurface
template<class Type>
void checkFieldSize(const Field<Type>& field) const;
// Make geometric data
void makeSf() const;
@ -121,16 +122,18 @@ class sampledSurface
template<class ReturnType, class Type>
tmp<Field<ReturnType> > project(const tmp<Field<Type> >&) const;
protected:
// Protected static functions
virtual void clearGeom() const;
public:
//- Runtime type information
TypeName("sampledSurface");
TypeName("sampledSurface");
// Declare run-time constructor selection table
@ -141,10 +144,11 @@ public:
sampledSurface,
word,
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
),
(mesh, dict)
(name, mesh, dict)
);
@ -177,11 +181,11 @@ public:
autoPtr<sampledSurface> operator()(Istream& is) const
{
word sampleType(is);
word name(is);
dictionary dict(is);
rewriteDict(dict, true);
return sampledSurface::New(sampleType, mesh_, dict);
return sampledSurface::New(name, mesh_, dict);
}
};
@ -191,14 +195,15 @@ public:
//- Construct from mesh, name
sampledSurface
(
const polyMesh& mesh,
const word& name,
const polyMesh& mesh,
const bool triangulate = true
);
//- Construct from dictionary
sampledSurface
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
);
@ -249,7 +254,7 @@ public:
return interpolate_;
}
//- triangulation requested for surface
//- Triangulation requested for surface
bool triangulate() const
{
return triangulate_;
@ -273,61 +278,62 @@ public:
//- Return face centres as vectorField
virtual const vectorField& Cf() const;
//- integration of a field across the surface
//- Integration of a field across the surface
template<class Type>
Type integrate(const Field<Type>&) const;
//- integration of a field across the surface
//- Integration of a field across the surface
template<class Type>
Type integrate(const tmp<Field<Type> >&) const;
//- area-averaged value of a field across the surface
//- Area-averaged value of a field across the surface
template<class Type>
Type average(const Field<Type>&) const;
//- area-averaged value of a field across the surface
//- Area-averaged value of a field across the surface
template<class Type>
Type average(const tmp<Field<Type> >&) const;
//- project field onto surface
tmp<Field<scalar> > project(const Field<scalar>&) const;
tmp<Field<scalar> > project(const Field<vector>&) const;
tmp<Field<vector> > project(const Field<sphericalTensor>&) const;
tmp<Field<vector> > project(const Field<symmTensor>&) const;
tmp<Field<vector> > project(const Field<tensor>&) const;
// Project field onto surface
//- sample field on surface
tmp<Field<scalar> > project(const Field<scalar>&) const;
tmp<Field<scalar> > project(const Field<vector>&) const;
tmp<Field<vector> > project(const Field<sphericalTensor>&) const;
tmp<Field<vector> > project(const Field<symmTensor>&) const;
tmp<Field<vector> > project(const Field<tensor>&) const;
//- Sample field on surface
virtual tmp<scalarField> sample
(
const volScalarField&
) const = 0;
//- sample field on surface
//- Sample field on surface
virtual tmp<vectorField> sample
(
const volVectorField&
) const = 0;
//- sample field on surface
//- Sample field on surface
virtual tmp<sphericalTensorField> sample
(
const volSphericalTensorField&
) const = 0;
//- sample field on surface
//- Sample field on surface
virtual tmp<symmTensorField> sample
(
const volSymmTensorField&
) const = 0;
//- sample field on surface
//- Sample field on surface
virtual tmp<tensorField> sample
(
const volTensorField&
) const = 0;
//- interpolate field on surface
//- Interpolate field on surface
virtual tmp<scalarField> interpolate
(
const interpolation<scalar>&
@ -340,42 +346,37 @@ public:
const interpolation<vector>&
) const = 0;
//- interpolate field on surface
//- Interpolate field on surface
virtual tmp<sphericalTensorField> interpolate
(
const interpolation<sphericalTensor>&
) const = 0;
//- interpolate field on surface
//- Interpolate field on surface
virtual tmp<symmTensorField> interpolate
(
const interpolation<symmTensor>&
) const = 0;
//- interpolate field on surface
//- Interpolate field on surface
virtual tmp<tensorField> interpolate
(
const interpolation<tensor>&
) const = 0;
// Edit
//- Rename
virtual void rename(const word& newName)
{
name_ = newName;
}
// Write
//- Write
virtual void print(Ostream&) const;
// IOstream operators
// IOstream operators
friend Ostream& operator<<(Ostream&, const sampledSurface&);
};

View File

@ -79,8 +79,8 @@ bool Foam::sampledSurfaces::checkFieldTypes()
IOobject io
(
fieldNames_[fieldI],
obr_.time().timeName(),
refCast<const polyMesh>(obr_),
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
@ -102,9 +102,9 @@ bool Foam::sampledSurfaces::checkFieldTypes()
forAll(fieldNames_, fieldI)
{
objectRegistry::const_iterator iter =
obr_.find(fieldNames_[fieldI]);
mesh_.find(fieldNames_[fieldI]);
if (iter != obr_.end())
if (iter != mesh_.objectRegistry::end())
{
fieldTypes[fieldI] = iter()->type();
}
@ -129,7 +129,7 @@ bool Foam::sampledSurfaces::checkFieldTypes()
{
if (debug)
{
Pout<< "timeName = " << obr_.time().timeName() << nl
Pout<< "timeName = " << mesh_.time().timeName() << nl
<< "scalarFields " << scalarFields_ << nl
<< "vectorFields " << vectorFields_ << nl
<< "sphTensorFields " << sphericalTensorFields_ << nl
@ -139,10 +139,14 @@ bool Foam::sampledSurfaces::checkFieldTypes()
if (nFields > 0)
{
Pout<< "Creating directory " << outputPath_/obr_.time().timeName()
<< nl << endl;
if (debug)
{
Pout<< "Creating directory "
<< outputPath_/mesh_.time().timeName()
<< nl << endl;
}
mkDir(outputPath_/obr_.time().timeName());
mkDir(outputPath_/mesh_.time().timeName());
}
}
@ -160,9 +164,7 @@ void Foam::sampledSurfaces::mergeSurfaces()
// Merge close points (1E-10 of mesh bounding box)
const scalar mergeTol = 1e-10;
const polyMesh& mesh = refCast<const polyMesh>(obr_);
const boundBox& bb = mesh.globalData().bb();
const boundBox& bb = mesh_.globalData().bb();
scalar mergeDim = mergeTol * mag(bb.max() - bb.min());
if (Pstream::master() && debug)
@ -265,8 +267,8 @@ Foam::sampledSurfaces::sampledSurfaces
:
PtrList<sampledSurface>(),
name_(name),
obr_(obr),
loadFromFiles_(loadFromFiles_),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
outputPath_(fileName::null),
pMeshPtr_(NULL),
pInterpPtr_(NULL),
@ -282,11 +284,11 @@ Foam::sampledSurfaces::sampledSurfaces
{
if (Pstream::parRun())
{
outputPath_ = obr_.time().path()/".."/name_;
outputPath_ = mesh_.time().path()/".."/name_;
}
else
{
outputPath_ = obr_.time().path()/name_;
outputPath_ = mesh_.time().path()/name_;
}
read(dict);
@ -340,7 +342,7 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
PtrList<sampledSurface> newList
(
dict.lookup("surfaces"),
sampledSurface::iNew(refCast<const polyMesh>(obr_))
sampledSurface::iNew(mesh_)
);
transfer(newList);
@ -387,4 +389,13 @@ void Foam::sampledSurfaces::movePoints(const pointField&)
}
void Foam::sampledSurfaces::readUpdate(const polyMesh::readUpdateState state)
{
if (state != polyMesh::UNCHANGED)
{
correct();
}
}
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
sampledSurfaces
Foam::sampledSurfaces
Description
Set of surfaces to sample.
@ -39,7 +39,7 @@ SourceFiles
#include "sampledSurface.H"
#include "surfaceWriter.H"
#include "volFields.H"
#include "volFieldsFwd.H"
#include "volPointInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,7 +47,7 @@ SourceFiles
namespace Foam
{
class objectRegistry;
class fvMesh;
class dictionary;
/*---------------------------------------------------------------------------*\
@ -67,7 +67,8 @@ class sampledSurfaces
public wordList
{
public:
//- surface formatter
//- Surface formatter
autoPtr<surfaceWriter<Type> > formatter;
//- Construct null
@ -105,9 +106,9 @@ class sampledSurfaces
{
wordList::operator=(fieldNames);
}
};
//- Class used for surface merging information
class mergeInfo
{
@ -120,8 +121,8 @@ class sampledSurfaces
// Static data members
//- output verbosity
static bool verbose_;
//- output verbosity
static bool verbose_;
// Private data
@ -130,8 +131,8 @@ class sampledSurfaces
// Also used as the name of the sampledSurfaces directory.
word name_;
//- Const reference to objectRegistry
const objectRegistry& obr_;
//- Const reference to fvMesh
const fvMesh& mesh_;
//- Load fields from files (not from objectRegistry)
bool loadFromFiles_;
@ -160,7 +161,7 @@ class sampledSurfaces
// surfaces
//- information for merging surfaces
//- Information for merging surfaces
List<mergeInfo> mergeList_;
@ -176,15 +177,12 @@ class sampledSurfaces
// Private Member Functions
//- classify field types, return true if nFields > 0
//- Classify field types, return true if nFields > 0
bool checkFieldTypes();
//- merge points on surfaces
//- Merge points on surfaces
void mergeSurfaces();
//- Correct for mesh changes
void correct();
//- Find the fields in the list of the given type, return count
template<class Type>
label grep
@ -193,7 +191,7 @@ class sampledSurfaces
const wordList& fieldTypes
) const;
//- set interpolator for the field
//- Set interpolator for the field
template<class Type>
autoPtr<interpolation<Type> > setInterpolator
(
@ -243,7 +241,13 @@ public:
// Member Functions
//- set verbosity level
//- Return name of the set of probes
virtual const word& name() const
{
return name_;
}
//- set verbosity level
void verbose(const bool verbosity = true);
//- Sample and write
@ -252,11 +256,17 @@ public:
//- Read the sampledSurfaces
virtual void read(const dictionary&);
//- Correct for mesh changes
void correct();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&);
//- Update for mesh point-motion
virtual void movePoints(const pointField&);
//- Update for changes of mesh due to readUpdate
virtual void readUpdate(const polyMesh::readUpdateState state);
};

View File

@ -28,8 +28,6 @@ License
#include "volFields.H"
#include "ListListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
@ -70,11 +68,9 @@ Foam::sampledSurfaces::setInterpolator
{
if (!pMeshPtr_.valid() || !pInterpPtr_.valid())
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
// set up interpolation
pMeshPtr_.reset(new pointMesh(mesh));
pInterpPtr_.reset(new volPointInterpolation(mesh, pMeshPtr_()));
pMeshPtr_.reset(new pointMesh(mesh_));
pInterpPtr_.reset(new volPointInterpolation(mesh_, pMeshPtr_()));
}
// interpolator for this field
@ -207,13 +203,13 @@ void Foam::sampledSurfaces::sampleAndWrite
IOobject
(
fields[fieldI],
obr_.time().timeName(),
refCast<const polyMesh>(obr_),
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
refCast<const fvMesh>(obr_)
mesh_
),
fields.formatter()
);
@ -221,17 +217,19 @@ void Foam::sampledSurfaces::sampleAndWrite
else
{
objectRegistry::const_iterator iter =
obr_.find(fields[fieldI]);
mesh_.find(fields[fieldI]);
if
(
iter != obr_.end()
&& iter()->type() == GeometricField<Type, fvPatchField, volMesh>::typeName
iter != mesh_.objectRegistry::end()
&& iter()->type()
== GeometricField<Type, fvPatchField, volMesh>::typeName
)
{
sampleAndWrite
(
obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
mesh_.lookupObject
<GeometricField<Type, fvPatchField, volMesh> >
(
fields[fieldI]
),
@ -239,14 +237,9 @@ void Foam::sampledSurfaces::sampleAndWrite
);
}
}
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "sampledSurfacesFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(sampledSurfacesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
sampledSurfacesFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -23,19 +23,19 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
surfacesFunctionObject
Foam::sampledSurfacesFunctionObject
Description
FunctionObject wrapper around surfaces to allow them to be created via the
functions list within controlDict.
SourceFiles
surfacesFunctionObject.C
sampledSurfacesFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef surfacesFunctionObject_H
#define surfacesFunctionObject_H
#ifndef sampledSurfacesFunctionObject_H
#define sampledSurfacesFunctionObject_H
#include "sampledSurfaces.H"
#include "OutputFilterFunctionObject.H"
@ -44,7 +44,8 @@ SourceFiles
namespace Foam
{
typedef OutputFilterFunctionObject<sampledSurfaces> surfacesFunctionObject;
typedef OutputFilterFunctionObject<sampledSurfaces>
sampledSurfacesFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,164 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*----------------------------------------------------------------------------*/
#include "surfacesFunctionObject.H"
#include "addToRunTimeSelectionTable.H"
#include "IOsampledSurfaces.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfacesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
surfacesFunctionObject,
dictionary
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::surfacesFunctionObject::extractDict()
{
if (dict_.found("region"))
{
dict_.lookup("region") >> regionName_;
}
if (dict_.found("dictionary"))
{
dict_.lookup("dictionary") >> dictName_;
}
if (dict_.found("interval"))
{
dict_.lookup("interval") >> interval_;
}
if (dict_.found("enabled"))
{
dict_.lookup("enabled") >> execution_;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfacesFunctionObject::surfacesFunctionObject
(
const Time& t,
const dictionary& dict
)
:
functionObject(),
time_(t),
dict_(dict),
regionName_(polyMesh::defaultRegion),
dictName_(),
interval_(0),
execution_(true)
{
extractDict();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// any possible side-effects?
bool Foam::surfacesFunctionObject::start()
{
extractDict();
if (execution_)
{
if (dictName_.size())
{
ptr_.reset
(
new IOsampledSurfaces
(
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new sampledSurfaces
(
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
}
return true;
}
bool Foam::surfacesFunctionObject::execute()
{
if (execution_ && (interval_ <= 1 || !(time_.timeIndex() % interval_)) )
{
ptr_->write();
}
return true;
}
void Foam::surfacesFunctionObject::on()
{
execution_ = true;
}
void Foam::surfacesFunctionObject::off()
{
execution_ = false;
}
bool Foam::surfacesFunctionObject::read(const dictionary& dict)
{
if (dict_ != dict)
{
dict_ = dict;
return start();
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
dx
Foam::dx
Description

View File

@ -34,7 +34,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(dx);
makeSurfaceWriters(dx);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -34,7 +34,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(foamFile);
makeSurfaceWriters(foamFile);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
null
Foam::null
Description

View File

@ -34,7 +34,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(null);
makeSurfaceWriters(null);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "raw.H"
#include "rawSurfaceWriter.H"
#include "fileName.H"
#include "OFstream.H"
#include "faceList.H"
@ -34,7 +34,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::raw<Type>::writeGeometry
void Foam::rawSurfaceWriter<Type>::writeGeometry
(
const pointField& points,
const label& pointI,
@ -48,7 +48,7 @@ void Foam::raw<Type>::writeGeometry
template<class Type>
void Foam::raw<Type>::writeGeometry
void Foam::rawSurfaceWriter<Type>::writeGeometry
(
const pointField& points,
const faceList& faces,
@ -63,7 +63,7 @@ void Foam::raw<Type>::writeGeometry
// Write scalarField in raw format
template<class Type>
void Foam::raw<Type>::writeData
void Foam::rawSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
@ -108,7 +108,7 @@ void Foam::raw<Type>::writeData
// Write vectorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
void Foam::rawSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
@ -131,7 +131,7 @@ void Foam::raw<Type>::writeData
<< nl;
}
os << "# x y z "
os << "# x y z "
<< fieldName << "_x "
<< fieldName << "_y "
<< fieldName << "_z "
@ -158,7 +158,7 @@ void Foam::raw<Type>::writeData
// Write sphericalTensorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
void Foam::rawSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
@ -205,7 +205,7 @@ void Foam::raw<Type>::writeData
// Write symmTensorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
void Foam::rawSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
@ -258,7 +258,7 @@ void Foam::raw<Type>::writeData
// Write tensorField in raw format
template<class Type>
void Foam::raw<Type>::writeData
void Foam::rawSurfaceWriter<Type>::writeData
(
const fileName& fieldName,
const pointField& points,
@ -312,7 +312,7 @@ void Foam::raw<Type>::writeData
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::raw<Type>::raw()
Foam::rawSurfaceWriter<Type>::rawSurfaceWriter()
:
surfaceWriter<Type>()
{}
@ -321,14 +321,14 @@ Foam::raw<Type>::raw()
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::raw<Type>::~raw()
Foam::rawSurfaceWriter<Type>::~rawSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::raw<Type>::write
void Foam::rawSurfaceWriter<Type>::write
(
const fileName& samplePath,
const fileName& timeDir,

View File

@ -23,17 +23,17 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
raw
Foam::rawSurfaceWriter
Description
SourceFiles
raw.C
rawSurfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef raw_H
#define raw_H
#ifndef rawSurfaceWriter_H
#define rawSurfaceWriter_H
#include "surfaceWriter.H"
@ -47,11 +47,10 @@ namespace Foam
\*---------------------------------------------------------------------------*/
template<class Type>
class raw
class rawSurfaceWriter
:
public surfaceWriter<Type>
{
// Private Member Functions
void writeGeometry
@ -60,7 +59,7 @@ class raw
const label& pointI,
Ostream& os
) const;
void writeGeometry
(
const pointField& points,
@ -68,7 +67,7 @@ class raw
const label& faceI,
Ostream& os
) const;
void writeData
(
const fileName& fieldName,
@ -124,11 +123,12 @@ public:
// Constructors
//- Construct null
raw();
rawSurfaceWriter();
// Destructor
virtual ~raw();
virtual ~rawSurfaceWriter();
// Member Functions
@ -157,7 +157,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "raw.C"
# include "rawSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
#include "rawSurfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriters(rawSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Class
rawSurfaceWriters
Description
SourceFiles
rawSurfaceWriters.C
\*---------------------------------------------------------------------------*/
#ifndef rawSurfaceWriters_H
#define rawSurfaceWriters_H
#include "rawSurfaceWriter.H"
#include "surfaceWriters.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef rawSurfaceWriter<scalar> rawSurfaceWriterScalarWriter;
typedef rawSurfaceWriter<vector> rawSurfaceWriterVectorWriter;
typedef rawSurfaceWriter<sphericalTensor> rawSurfaceWriterSphericalTensorWriter;
typedef rawSurfaceWriter<symmTensor> rawSurfaceWriterSymmTensorWriter;
typedef rawSurfaceWriter<tensor> rawSurfaceWriterTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
stl
Foam::stl
Description

View File

@ -34,7 +34,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(stl);
makeSurfaceWriters(stl);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
surfaceWriter
Foam::surfaceWriter
Description
@ -118,38 +118,38 @@ public:
#endif
// Only used internally
#define makeTypeWritersTypeName(type) \
\
#define makeTypeSurfaceWritersTypeName(type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0);
// Used externally sometimes
#define makeWritersTypeName(typeWriter) \
\
makeTypeWritersTypeName(typeWriter##ScalarWriter); \
makeTypeWritersTypeName(typeWriter##VectorWriter); \
makeTypeWritersTypeName(typeWriter##SphericalTensorWriter); \
makeTypeWritersTypeName(typeWriter##SymmTensorWriter); \
makeTypeWritersTypeName(typeWriter##TensorWriter);
#define makeSurfaceWritersTypeName(typeWriter) \
\
makeTypeSurfaceWritersTypeName(typeWriter##ScalarWriter); \
makeTypeSurfaceWritersTypeName(typeWriter##VectorWriter); \
makeTypeSurfaceWritersTypeName(typeWriter##SphericalTensorWriter); \
makeTypeSurfaceWritersTypeName(typeWriter##SymmTensorWriter); \
makeTypeSurfaceWritersTypeName(typeWriter##TensorWriter);
// Define type info for single template instantiation (e.g. vector)
#define makeWriterTypes(WriterType, type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0); \
\
addToRunTimeSelectionTable \
( \
WriterType, type, word \
#define makeSurfaceWriterTypes(WriterType, type) \
\
defineNamedTemplateTypeNameAndDebug(type, 0); \
\
addToRunTimeSelectionTable \
( \
WriterType, type, word \
);
// Define type info info for scalar, vector etc. instantiations
#define makeWriters(typeWriter) \
\
makeWriterTypes(scalarWriter, typeWriter##ScalarWriter); \
makeWriterTypes(vectorWriter, typeWriter##VectorWriter); \
makeWriterTypes(sphericalTensorWriter, typeWriter##SphericalTensorWriter); \
makeWriterTypes(symmTensorWriter, typeWriter##SymmTensorWriter);\
makeWriterTypes(tensorWriter, typeWriter##TensorWriter);
#define makeSurfaceWriters(typeWriter) \
\
makeSurfaceWriterTypes(scalarWriter, typeWriter##ScalarWriter); \
makeSurfaceWriterTypes(vectorWriter, typeWriter##VectorWriter); \
makeSurfaceWriterTypes(sphericalTensorWriter, typeWriter##SphericalTensorWriter);\
makeSurfaceWriterTypes(symmTensorWriter, typeWriter##SymmTensorWriter); \
makeSurfaceWriterTypes(tensorWriter, typeWriter##TensorWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
vtk
Foam::vtk
Description
@ -51,7 +51,6 @@ class vtk
:
public surfaceWriter<Type>
{
// Private Member Functions
void writeGeometry
@ -113,6 +112,7 @@ public:
//- Construct null
vtk();
// Destructor
virtual ~vtk();

View File

@ -34,7 +34,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeWriters(vtk);
makeSurfaceWriters(vtk);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //