This commit is contained in:
henry
2008-05-01 17:02:29 +01:00
parent f13d2060dc
commit 0e5a8b809e
115 changed files with 414 additions and 14678 deletions

View File

@ -1,24 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
axis
{
type word;
description "Form of distance data";
default distance;
valueList
(
distance
x
y
z
xyz
);
}
// ************************************************************************* //

View File

@ -1,21 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
cloud
{
type dictionary;
description "Samples a set of specified points";
entries
{
include "name.cfg";
include "axis.cfg";
include "points.cfg";
}
}
// ************************************************************************* //

View File

@ -1,21 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
curve
{
type dictionary;
description "Samples a set of specified points that are tracked along a curve";
entries
{
include "name.cfg";
include "axis.cfg";
include "points.cfg";
}
}
// ************************************************************************* //

View File

@ -1,15 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
end
{
type vector;
description "End point on sampling line";
}
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
face
{
type dictionary;
description "One sampling point per face intersection";
entries
{
include "name.cfg";
include "axis.cfg";
include "start.cfg";
include "end.cfg";
}
}
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
midPoint
{
type dictionary;
description "One sampling point per cell, between two face intersections";
entries
{
include "name.cfg";
include "axis.cfg";
include "start.cfg";
include "end.cfg";
}
}
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
midPointAndFace
{
type dictionary;
description "One sampling point per intersected face and one per cell, between two face intersections";
entries
{
include "name.cfg";
include "axis.cfg";
include "start.cfg";
include "end.cfg";
}
}
// ************************************************************************* //

View File

@ -1,15 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
nPoints
{
type label;
description "Number of points on sampling line";
}
// ************************************************************************* //

View File

@ -1,15 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
name
{
type word;
description "Name of sampling set";
}
// ************************************************************************* //

View File

@ -1,16 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
points
{
type list;
description "List of points to be sampled";
elementType vector;
}
// ************************************************************************* //

View File

@ -1,71 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// sample tool definition
description "Line sampling";
sampleDict
{
type dictionary;
description "sample control dictionary";
dictionaryPath "system";
entries
{
arguments
{
type rootCaseTimeArguments;
}
interpolationScheme
{
type word;
description "Sampling interpolation scheme";
default cellPoint;
valueList
(
cell
cellPoint
cellPointFace
);
}
writeFormat
{
type word;
description "Output format of data";
default raw;
valueList
(
raw
gnuplot
xmgr
jplot
);
}
sampleSets
{
type list;
description "List of sampling sets";
elementType
{
include "sampleSet.cfg";
}
}
fields
{
type list;
description "List of fields to be sampled";
elementType word;
}
}
}
// ************************************************************************* //

View File

@ -1,23 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
sampleSet
{
type selection;
entries
{
include "uniform.cfg";
include "face.cfg";
include "midPoint.cfg";
include "midPointAndFace.cfg";
include "curve.cfg";
include "cloud.cfg";
}
}
// ************************************************************************* //

View File

@ -1,15 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
start
{
type vector;
description "Start point on sampling line";
}
// ************************************************************************* //

View File

@ -1,43 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
tensorFieldSample
{
type compound;
description "Tensor field to be sampled";
entries
{
name
{
type word;
description "Field name";
}
component
{
type word;
description "Tensor component(s)";
valueList
(
xx
xy
xz
yx
yy
yz
zx
zy
zz
mag
full
);
}
}
}
// ************************************************************************* //

View File

@ -1,23 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
uniform
{
type dictionary;
description "Uniform distribution of points on a line";
entries
{
include "name.cfg";
include "axis.cfg";
include "start.cfg";
include "end.cfg";
include "nPoints.cfg";
}
}
// ************************************************************************* //

View File

@ -1,37 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
vectorFieldSample
{
type compound;
description "Vector field to be sampled";
entries
{
name
{
type word;
description "Field name";
}
component
{
type word;
description "Vector component(s)";
valueList
(
x
y
z
mag
full
);
}
}
}
// ************************************************************************* //

View File

@ -1,19 +0,0 @@
combineSampleSets.C
sample.C
writers/writer/writers.C
writers/xmgr/xmgrWriters.C
writers/gnuplot/gnuplotWriters.C
writers/jplot/jplotWriters.C
writers/raw/rawWriters.C
sampleSets/coordSet/coordSet.C
sampleSets/sampleSet/sampleSet.C
sampleSets/cloud/cloudSet.C
sampleSets/face/faceOnlySet.C
sampleSets/curve/curveSet.C
sampleSets/uniform/uniformSet.C
sampleSets/midPoint/midPointSet.C
sampleSets/midPointAndFace/midPointAndFaceSet.C
EXE = $(FOAM_APPBIN)/sample

View File

@ -1,16 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-IsampleSets/sampleSet \
-IsampleSets/coordSet \
-IsampleSets/face \
-Iwriters/writer \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
EXE_LIBS = \
-lsampling \
-lmeshTools \
-llagrangian \
-lfiniteVolume

View File

@ -1,120 +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 "Pstream.H"
#include "ListListOps.H"
#include "combineSampleSets.H"
#include "SortableList.H"
#include "IndirectList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// Combine points from all processors. Sort by curveDist and produce
// index list. Valid result only on master processor.
void combineSampleSets
(
const PtrList<sampleSet>& sampleSets,
PtrList<coordSet>& masterSampleSets,
labelListList& indexSets
)
{
forAll(sampleSets, setI)
{
const sampleSet& samplePts = sampleSets[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;
}
masterSampleSets.set
(
setI,
new coordSet
(
samplePts.name(),
samplePts.axis(),
IndirectList<point>(allPts, indexSets[setI]),
refPt
)
);
}
}
// ************************************************************************* //

View File

@ -1,60 +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
InClass
Foam::combineSampleSets
Description
Various utility functions for collection of samples on processors.
SourceFiles
combineSampleSets.C
\*---------------------------------------------------------------------------*/
#ifndef combineSampleSets_H
#define combineSampleSets_H
#include "labelList.H"
#include "PtrList.H"
#include "coordSet.H"
#include "sampleSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Combine points from all processors. Sort by curveDist and produce
// index list. Valid result only on master processor.
void combineSampleSets
(
const Foam::PtrList<Foam::sampleSet>& sampleSets,
Foam::PtrList<Foam::coordSet>& masterSampleSets,
Foam::labelListList& indexSets
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,86 +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 "combineSampleValues.H"
#include "Pstream.H"
#include "ListListOps.H"
#include "IndirectList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// Combine values from all processors. Valid result only on master processor.
template<class T>
void combineSampleValues
(
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()
)
);
}
}
// ************************************************************************* //

View File

@ -1,65 +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
InClass
Foam::combineSampleValues
Description
Various utility functions for collection of samples on processors.
SourceFiles
combineSampleValues.C
\*---------------------------------------------------------------------------*/
#ifndef combineSampleValues_H
#define combineSampleValues_H
#include "labelList.H"
#include "PtrList.H"
#include "volFieldSampler.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Combine values from all processors. Valid result only on master processor.
template<class T>
void combineSampleValues
(
const Foam::PtrList<Foam::volFieldSampler<T> >& sampledFields,
const Foam::labelListList& indexSets,
Foam::PtrList<Foam::volFieldSampler<T> >& masterFields
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "combineSampleValues.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,887 +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
Description
Sample field data with a choice of interpolation schemes, sampling options
and write formats.
interpolationScheme : choice of
cell : use cell-centre value only; constant over cells
cellPoint : use cell-centre and vertex values
cellPointFace : use cell-centre, vertex and face values.
sample: choice of
uniform evenly distributed points on line
face one point per face intersection
midPoint one point per cell, inbetween two face intersections
midPointAndFace combination of face and midPoint
curve specified points, not nessecary on line, uses
tracking
cloud specified points, uses findCell
writeFormat : choice of
xmgr
jplot
gnuplot
raw
\*---------------------------------------------------------------------------*/
#include "Pstream.H"
#include "argList.H"
#include "OSspecific.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "meshSearch.H"
#include "interpolation.H"
#include "volPointInterpolation.H"
#include "writer.H"
#include "sampleSet.H"
#include "volFieldSampler.H"
#include "dictionaryEntry.H"
#include "combineSampleSets.H"
#include "combineSampleValues.H"
using namespace Foam;
template<class Type>
void writeSampleFile
(
const coordSet& masterSampleSet,
const PtrList<volFieldSampler<Type> >& masterFields,
const label setI,
const fileName& timeDir,
const word& writeFormat
)
{
if (masterFields.size() > 0)
{
wordList valueSetNames(masterFields.size());
List<const Field<Type>*> valueSets(masterFields.size());
forAll(masterFields, fieldI)
{
valueSetNames[fieldI] = masterFields[fieldI].name();
valueSets[fieldI] = &masterFields[fieldI][setI];
}
autoPtr<writer<Type> > formatter
(
writer<Type>::New(writeFormat)
);
fileName fName
(
timeDir/formatter().getFileName(masterSampleSet, valueSetNames)
);
Info<< "Writing fields to " << fName << endl;
formatter().write
(
masterSampleSet,
valueSetNames,
valueSets,
OFstream(fName)()
);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
//
// Hack: initialize Cloud to initialize the processor table so from
// now on we can use cloud on single processors only.
//
Cloud<passiveParticle> dummyCloud(mesh, IDLList<passiveParticle>());
// Read control dictionary
IOdictionary sampleDict
(
IOobject
(
"sampleDict",
runTime.system(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
const word interpolationScheme(sampleDict.lookup("interpolationScheme"));
const wordList fieldNames = sampleDict.lookup("fields");
//
// Construct writers
//
word writeFormat(sampleDict.lookup("writeFormat"));
//
// Construct interpolation dictionary (same interpolation for all fields)
//
dictionary interpolationSchemes;
forAll(fieldNames, fieldI)
{
interpolationSchemes.add
(
fieldNames[fieldI],
interpolationScheme
);
}
// Set up interpolation
autoPtr<pointMesh> pMeshPtr(new pointMesh(mesh));
autoPtr<volPointInterpolation> pInterpPtr
(
new volPointInterpolation(mesh, pMeshPtr())
);
// Set up mesh searching
meshSearch searchEngine(mesh, true);
fileName samplePath;
if (Pstream::master())
{
if (Pstream::parRun())
{
samplePath = runTime.path()/".."/"samples";
}
else
{
samplePath = runTime.path()/"samples";
}
if (exists(samplePath))
{
Info<< "Deleting samples/ directory" << endl << endl;
rmDir(samplePath);
}
}
fileName oldPointsDir("constant");
for (label i=startTime; i<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << endl;
//
// Handle geometry/topology changes
//
polyMesh::readUpdateState state = mesh.readUpdate();
if
(
state == polyMesh::POINTS_MOVED
|| state == polyMesh::TOPO_CHANGE
)
{
// Geometry and topology changes
searchEngine.correct();
pMeshPtr.reset(new pointMesh(mesh));
pInterpPtr.reset(new volPointInterpolation(mesh, pMeshPtr()));
}
//
// Construct sampling point generators
//
PtrList<sampleSet> sampleSets
(
sampleDict.lookup("sampleSets"),
sampleSet::iNew(mesh, searchEngine)
);
if (sampleSets.size() < 1)
{
FatalErrorIn(args.executable())
<< "No sampleSets provided in sampleDict"
<< exit(FatalError);
}
// Storage for interpolated values
PtrList<volFieldSampler<scalar> > sampledScalarFields
(
fieldNames.size()
);
PtrList<volFieldSampler<vector> > sampledVectorFields
(
fieldNames.size()
);
PtrList<volFieldSampler<sphericalTensor> > sampledSphericalTensorFields
(
fieldNames.size()
);
PtrList<volFieldSampler<symmTensor> > sampledSymmTensorFields
(
fieldNames.size()
);
PtrList<volFieldSampler<tensor> > sampledTensorFields
(
fieldNames.size()
);
//
// Do actual interpolation
//
label nScalarFields = 0;
label nVectorFields = 0;
label nSphericalTensorFields = 0;
label nSymmTensorFields = 0;
label nTensorFields = 0;
forAll(fieldNames, fieldI)
{
const word& fieldName = fieldNames[fieldI];
IOobject fieldHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Determine number of processor actually having this field
label fieldFound = (fieldHeader.headerOk() ? 1 : 0);
reduce(fieldFound, sumOp<label>());
if (fieldFound == Pstream::nProcs())
{
if
(
fieldHeader.headerClassName() == volScalarField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volScalarField sField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
sField,
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName() == volVectorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volVectorField vField(fieldHeader, mesh);
sampledVectorFields.set
(
nVectorFields,
new volFieldSampler<vector>
(
pInterpPtr(),
interpolationSchemes,
vField,
sampleSets
)
);
nVectorFields++;
}
else if
(
fieldHeader.headerClassName()
== volSphericalTensorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSphericalTensorField tField(fieldHeader, mesh);
sampledSphericalTensorFields.set
(
nSphericalTensorFields,
new volFieldSampler<sphericalTensor>
(
pInterpPtr(),
interpolationSchemes,
tField,
sampleSets
)
);
nSphericalTensorFields++;
}
else if
(
fieldHeader.headerClassName()
== volSymmTensorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSymmTensorField tField(fieldHeader, mesh);
sampledSymmTensorFields.set
(
nSymmTensorFields,
new volFieldSampler<symmTensor>
(
pInterpPtr(),
interpolationSchemes,
tField,
sampleSets
)
);
nSymmTensorFields++;
}
else if
(
fieldHeader.headerClassName() == volTensorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volTensorField tField(fieldHeader, mesh);
sampledTensorFields.set
(
nTensorFields,
new volFieldSampler<tensor>
(
pInterpPtr(),
interpolationSchemes,
tField,
sampleSets
)
);
nTensorFields++;
}
}
else if (fieldFound != 0)
{
FatalErrorIn(args.executable())
<< "Did not find field " << fieldName
<< " on all processors" << exit(FatalError);
}
else if (fieldName.find('(') != string::npos)
{
if (fieldName.find("component") != string::npos)
{
string baseFieldName(fieldName(0, fieldName.find('.')));
IOobject fieldHeader
(
baseFieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Determine number of processor actually having this field
label fieldFound = (fieldHeader.headerOk() ? 1 : 0);
reduce(fieldFound, sumOp<label>());
if (fieldFound == Pstream::nProcs())
{
if
(
fieldHeader.headerClassName()
== volVectorField::typeName
)
{
size_t cmptPos(fieldName.find_last_of("012"));
if (cmptPos == string::npos)
{
FatalErrorIn(args.executable())
<< "cannot find component index for "
<< fieldName << exit(FatalError);
}
direction cmpt =
atoi(string(fieldName[cmptPos]).c_str());
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volVectorField vField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
vField.component(cmpt)(),
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName()
== volSymmTensorField::typeName
)
{
size_t cmptPos(fieldName.find_last_of("0123456"));
if (cmptPos == string::npos)
{
FatalErrorIn(args.executable())
<< "cannot find component index for "
<< fieldName
<< exit(FatalError);
}
direction cmpt =
atoi(string(fieldName[cmptPos]).c_str());
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSymmTensorField tField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
tField.component(cmpt)(),
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName()
== volTensorField::typeName
)
{
size_t cmptPos(fieldName.find_last_of("012345678"));
if (cmptPos == string::npos)
{
FatalErrorIn(args.executable())
<< "cannot find component index for "
<< fieldName
<< exit(FatalError);
}
direction cmpt =
atoi(string(fieldName[cmptPos]).c_str());
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volTensorField tField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
tField.component(cmpt)(),
sampleSets
)
);
nScalarFields++;
}
else
{
FatalErrorIn(args.executable())
<< "component function not supported for field "
<< fieldName << " of type "
<< fieldHeader.headerClassName()
<< exit(FatalError);
}
}
else if (fieldFound != 0)
{
FatalErrorIn(args.executable())
<< "Did not find field " << baseFieldName
<< " on all processors" << exit(FatalError);
}
}
else if (fieldName.find("mag") != string::npos)
{
string baseFieldName
(
fieldName(fieldName.find('(') + 1,
fieldName.find(')') - fieldName.find('(') - 1)
);
IOobject fieldHeader
(
baseFieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Determine number of processor actually having this field
label fieldFound = (fieldHeader.headerOk() ? 1 : 0);
reduce(fieldFound, sumOp<label>());
if (fieldFound == Pstream::nProcs())
{
if
(
fieldHeader.headerClassName()
== volScalarField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volScalarField sField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
mag(sField),
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName()
== volVectorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volVectorField vField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
mag(vField),
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName()
== volSphericalTensorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSphericalTensorField tField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
mag(tField),
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName()
== volSymmTensorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volSymmTensorField tField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
mag(tField),
sampleSets
)
);
nScalarFields++;
}
else if
(
fieldHeader.headerClassName()
== volTensorField::typeName
)
{
Info<< "Sampling " << fieldHeader.headerClassName()
<< ' ' << fieldName << endl;
volTensorField tField(fieldHeader, mesh);
sampledScalarFields.set
(
nScalarFields,
new volFieldSampler<scalar>
(
pInterpPtr(),
interpolationSchemes,
mag(tField),
sampleSets
)
);
nScalarFields++;
}
else
{
FatalErrorIn(args.executable())
<< "mag function not supported for field "
<< fieldName << " of type "
<< fieldHeader.headerClassName()
<< exit(FatalError);
}
}
else if (fieldFound != 0)
{
FatalErrorIn(args.executable())
<< "Did not find field " << baseFieldName
<< " on all processors" << exit(FatalError);
}
}
}
}
// Set the sampledFields to the correct size
sampledScalarFields.setSize(nScalarFields);
sampledVectorFields.setSize(nVectorFields);
sampledSphericalTensorFields.setSize(nSphericalTensorFields);
sampledSymmTensorFields.setSize(nSymmTensorFields);
sampledTensorFields.setSize(nTensorFields);
//
// Now we have all results
// - sampleSets : list of all sampling sets
// - sampledXXXFields : list of all sampled fields
//
// Combine sampleSets from processors. Sort by curveDist. Return
// ordering in indexSets.
// Note: only master results are valid
PtrList<coordSet> masterSampleSets(sampleSets.size());
labelListList indexSets(sampleSets.size());
combineSampleSets(sampleSets, masterSampleSets, indexSets);
// Combine sampled fields from processors.
// Note: only master results are valid
PtrList<volFieldSampler<scalar> > masterScalarFields
(
sampledScalarFields.size()
);
combineSampleValues(sampledScalarFields, indexSets, masterScalarFields);
PtrList<volFieldSampler<vector> > masterVectorFields
(
sampledVectorFields.size()
);
combineSampleValues(sampledVectorFields, indexSets, masterVectorFields);
PtrList<volFieldSampler<sphericalTensor> > masterSphericalTensorFields
(
sampledSphericalTensorFields.size()
);
combineSampleValues
(
sampledSphericalTensorFields,
indexSets,
masterSphericalTensorFields
);
PtrList<volFieldSampler<symmTensor> > masterSymmTensorFields
(
sampledSymmTensorFields.size()
);
combineSampleValues
(
sampledSymmTensorFields,
indexSets,
masterSymmTensorFields
);
PtrList<volFieldSampler<tensor> > masterTensorFields
(
sampledTensorFields.size()
);
combineSampleValues(sampledTensorFields, indexSets, masterTensorFields);
//
// Write each set, each Field type (scalar/vector/tensor) to separate
// file.
//
if (Pstream::master())
{
fileName timeDir(samplePath/runTime.timeName());
// Mirror the time structure under "samples"
mkDir(timeDir);
forAll(masterSampleSets, setI)
{
writeSampleFile
(
masterSampleSets[setI],
masterScalarFields,
setI,
timeDir,
writeFormat
);
writeSampleFile
(
masterSampleSets[setI],
masterVectorFields,
setI,
timeDir,
writeFormat
);
writeSampleFile
(
masterSampleSets[setI],
masterSphericalTensorFields,
setI,
timeDir,
writeFormat
);
writeSampleFile
(
masterSampleSets[setI],
masterSymmTensorFields,
setI,
timeDir,
writeFormat
);
writeSampleFile
(
masterSampleSets[setI],
masterTensorFields,
setI,
timeDir,
writeFormat
);
}
Info<< endl;
}
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,119 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.0 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam";
case "cavity";
instance "system";
local "";
class dictionary;
object sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// interpolationScheme : choice of
// cell : use cell-centre value only; constant over cells
// cellPoint : use cell-centre and vertex values
// cellPointFace : use cell-centre, vertex and face values.
// 1] vertex values determined from neighbouring cell-centre values
// 2] face values determined using the current face interpolation scheme
// for the field (linear, gamma, etc.)
interpolationScheme cellPoint;
// writeFormat : choice of
// xmgr
// jplot
// gnuplot
// raw
writeFormat raw;
// sampling definition:
//
// Dictionary with fields
// type : type of sampling method
// name : name of samples. Used e.g. as filename
// axis : how to write point coordinate
// ... : depending on method
//
//
// sample: choice of
// uniform evenly distributed points on line
// face one point per face intersection
// midPoint one point per cell, inbetween two face intersections
// midPointAndFace combination of face and midPoint
//
// curve specified points, not nessecary on line, uses
// tracking
// cloud specified points, uses findCell
//
//
// axis: how to write point coordinate. Choice of
// - x/y/z: x/y/z coordinate only
// - xyz: three columns
// (probably does not make sense for anything but raw)
// - distance: distance from start of sampling line (if uses line) or
// distance from first specified sampling point
//
// type specific:
// uniform, face, midPoint, midPointAndFace : start and end coordinate
// uniform: extra number of sampling points
// curve, cloud: list of coordinates
sampleSets
(
uniform
{
name lineX1;
axis distance;
//- cavity
start (0.02 0.051 0.005);
end (0.06 0.051 0.005);
nPoints 10;
}
face
{
name lineX2;
axis x;
//- flangeHex
//start (0 20 -20);
//end (0 20 10);
//- nablaCavity
//start (-1 0.05 0.005);
//end ( 1 0.05 0.005);
//- cavity
start (0.0 0.51 0.005);
end (2 0.51 0.005);
nPoints 10;
}
);
// Fields to sample.
fields
(
p
mag(U)
U.component(1)
R.component(0)
);
// ************************************************************************* //

View File

@ -1,177 +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
Description
\*---------------------------------------------------------------------------*/
#include "cloudSet.H"
#include "sampleSet.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(sampleSet, 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 * * * * * * * * * * * * * * //
// Construct from components
Foam::cloudSet::cloudSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const List<point>& sampleCoords
)
:
sampleSet(mesh, searchEngine, name, axis),
sampleCoords_(sampleCoords)
{
genSamples();
if (debug)
{
write(Info);
}
}
// Construct from dictionary
Foam::cloudSet::cloudSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampleSet(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

@ -1,126 +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
Class
Foam::cloudSet
Description
SourceFiles
cloudSet.C
\*---------------------------------------------------------------------------*/
#ifndef cloudSet_H
#define cloudSet_H
#include "sampleSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class particle;
/*---------------------------------------------------------------------------*\
Class cloudSet Declaration
\*---------------------------------------------------------------------------*/
class cloudSet
:
public sampleSet
{
// Private data
//- Sampling points
List<point> sampleCoords_;
// Private Member Functions
//- Samples all points in sampleCoords.
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("cloud");
// Constructors
//- Construct from components
cloudSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const List<point>& sampleCoords
);
//- Construct from dictionary
cloudSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~cloudSet();
// Member Functions
//- Get reference point
virtual point getRefPoint(const List<point>&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

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

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

@ -1,421 +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
Description
\*---------------------------------------------------------------------------*/
#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(sampleSet, 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 * * * * * * * * * * * * * * //
// Construct from components
Foam::curveSet::curveSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const List<point>& sampleCoords
)
:
sampleSet(mesh, searchEngine, name, axis),
sampleCoords_(sampleCoords)
{
genSamples();
if (debug)
{
write(Info);
}
}
// Construct from dictionary
Foam::curveSet::curveSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampleSet(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

@ -1,139 +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
Class
Foam::curveSet
Description
SourceFiles
curveSet.C
\*---------------------------------------------------------------------------*/
#ifndef curveSet_H
#define curveSet_H
#include "sampleSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class Particle;
/*---------------------------------------------------------------------------*\
Class curveSet Declaration
\*---------------------------------------------------------------------------*/
class curveSet
:
public sampleSet
{
// 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 polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const List<point>& samplePoints
);
//- Construct from dictionary
curveSet
(
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

@ -1,396 +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
Description
\*---------------------------------------------------------------------------*/
#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(sampleSet, 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 * * * * * * * * * * * * * * //
// Construct from components
Foam::faceOnlySet::faceOnlySet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end
)
:
sampleSet(mesh, searchEngine, name, axis),
start_(start),
end_(end)
{
genSamples();
if (debug)
{
write(Info);
}
}
// Construct from dictionary
Foam::faceOnlySet::faceOnlySet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampleSet(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

@ -1,153 +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
Class
Foam::faceOnlySet
Description
SourceFiles
faceOnlySet.C
\*---------------------------------------------------------------------------*/
#ifndef faceOnlySet_H
#define faceOnlySet_H
#include "sampleSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class Particle;
/*---------------------------------------------------------------------------*\
Class faceOnlySet Declaration
\*---------------------------------------------------------------------------*/
class faceOnlySet
:
public sampleSet
{
// 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 polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end
);
//- Construct from dictionary
faceOnlySet
(
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

@ -1,169 +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 "midPointSet.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(midPointSet, 0);
addToRunTimeSelectionTable(sampleSet, 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 * * * * * * * * * * * * * * //
// Construct from components
Foam::midPointSet::midPointSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end
)
:
faceOnlySet(mesh, searchEngine, name, axis, start, end)
{
genSamples();
if (debug)
{
write(Info);
}
}
// Construct from dictionary
Foam::midPointSet::midPointSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
faceOnlySet(mesh, searchEngine, dict)
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::midPointSet::~midPointSet()
{}
// ************************************************************************* //

View File

@ -1,104 +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
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 polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end
);
//- Construct from dictionary
midPointSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~midPointSet();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,197 +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
Description
\*---------------------------------------------------------------------------*/
#include "midPointAndFaceSet.H"
#include "DynamicList.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(midPointAndFaceSet, 0);
addToRunTimeSelectionTable(sampleSet, 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 * * * * * * * * * * * * * * //
// Construct from components
Foam::midPointAndFaceSet::midPointAndFaceSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end
)
:
faceOnlySet(mesh, searchEngine, name, axis, start, end)
{
genSamples();
if (debug)
{
write(Info);
}
}
// Construct from dictionary
Foam::midPointAndFaceSet::midPointAndFaceSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
faceOnlySet(mesh, searchEngine, dict)
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::midPointAndFaceSet::~midPointAndFaceSet()
{}
// ************************************************************************* //

View File

@ -1,105 +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
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 polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end
);
//- Construct from dictionary
midPointAndFaceSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~midPointAndFaceSet();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,467 +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
Description
\*---------------------------------------------------------------------------*/
#include "sampleSet.H"
#include "polyMesh.H"
#include "primitiveMesh.H"
#include "meshSearch.H"
#include "writer.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
const scalar sampleSet::tol = 1e-6;
defineTypeNameAndDebug(sampleSet, 0);
defineRunTimeSelectionTable(sampleSet, word);
autoPtr<sampleSet> sampleSet::New
(
const word& sampleType,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
{
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_
->find(sampleType);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorIn
(
"sampleSet::New(const word&, "
"const polyMesh&, meshSearch&, const dictionary&)"
) << "Unknown sample type " << sampleType
<< endl << endl
<< "Valid sample types : " << endl
<< wordConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<sampleSet>
(
cstrIter()
(
mesh,
searchEngine,
dict
)
);
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::sampleSet::getBoundaryCell(const label faceI) const
{
return mesh().faceOwner()[faceI];
}
Foam::label Foam::sampleSet::getCell
(
const label faceI,
const point& sample
) const
{
if (faceI == -1)
{
FatalErrorIn
(
"sampleSet::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
(
"sampleSet::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
(
"sampleSet::getCell(const label, const point&)"
) << "None of the neighbours of face "
<< faceI << " contains point " << sample
<< abort(FatalError);
return -1;
}
}
}
}
Foam::scalar Foam::sampleSet::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::sampleSet::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::sampleSet::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
(
"sampleSet::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::sampleSet::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<< "sampleSet::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::sampleSet::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("sampleSet::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 * * * * * * * * * * * * * * //
// Construct from mesh, name
Foam::sampleSet::sampleSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis
)
:
coordSet(name, axis),
mesh_(mesh),
searchEngine_(searchEngine),
segments_(0),
curveDist_(0),
cells_(0),
faces_(0)
{}
// Construct from dictionary
Foam::sampleSet::sampleSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
coordSet(dict.lookup("name"), dict.lookup("axis")),
mesh_(mesh),
searchEngine_(searchEngine),
segments_(0),
curveDist_(0),
cells_(0),
faces_(0)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampleSet::~sampleSet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Ostream& Foam::sampleSet::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

@ -1,296 +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
Class
Foam::sampleSet
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 'sampleSet' has a name and a specifier of how the axis should be
write (x/y/z component or all 3 components)
SourceFiles
sampleSet.C
\*---------------------------------------------------------------------------*/
#ifndef sampleSet_H
#define sampleSet_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 sampleSet Declaration
\*---------------------------------------------------------------------------*/
class sampleSet
:
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("sampleSet");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
sampleSet,
word,
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
),
(mesh, searchEngine, dict)
);
//- Class used for the read-construction of
// PtrLists of sampleSet
class iNew
{
const polyMesh& mesh_;
meshSearch& searchEngine_;
public:
iNew(const polyMesh& mesh, meshSearch& searchEngine)
:
mesh_(mesh),
searchEngine_(searchEngine)
{}
autoPtr<sampleSet> operator()(Istream& is) const
{
word sampleType(is);
dictionary dict(is);
return sampleSet::New(sampleType, mesh_, searchEngine_, dict);
}
};
// Static data
//- Tolerance when comparing points. Usually relative to difference
// between start_ and end_
const static scalar tol;
// Constructors
//- Construct from mesh, name
sampleSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis
);
//- Construct from dictionary
sampleSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
//- Clone
autoPtr<sampleSet> clone() const
{
notImplemented("autoPtr<sampleSet> clone() const");
return autoPtr<sampleSet>(NULL);
}
// Selectors
//- Return a reference to the selected sampleSet
static autoPtr<sampleSet> New
(
const word& sampleType,
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
);
// Destructor
virtual ~sampleSet();
// 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

@ -1,499 +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 "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(sampleSet, 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 * * * * * * * * * * * * * * //
// Construct from components
Foam::uniformSet::uniformSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end,
const label nPoints
)
:
sampleSet(mesh, searchEngine, name, axis),
start_(start),
end_(end),
nPoints_(nPoints)
{
genSamples();
if (debug)
{
write(Info);
}
}
// Construct from dictionary
Foam::uniformSet::uniformSet
(
const polyMesh& mesh,
meshSearch& searchEngine,
const dictionary& dict
)
:
sampleSet(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

@ -1,160 +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
Class
Foam::uniformSet
Description
SourceFiles
uniformSet.C
\*---------------------------------------------------------------------------*/
#ifndef uniformSet_H
#define uniformSet_H
#include "sampleSet.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class passiveParticle;
template<class Type> class Particle;
/*---------------------------------------------------------------------------*\
Class uniformSet Declaration
\*---------------------------------------------------------------------------*/
class uniformSet
:
public sampleSet
{
// 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 polyMesh& mesh,
meshSearch& searchEngine,
const word& name,
const word& axis,
const point& start,
const point& end,
const label nPoints
);
//- Construct from dictionary
uniformSet
(
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

@ -1,158 +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 "fvCFD.H"
#include "meshSearch.H"
#include "interpolation.H"
#include "volPointInterpolation.H"
#include "PtrList.H"
#include "writer.H"
#include "sampleSet.H"
#include "volFieldSampler.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
//
// 1. Sampling and writing.
//
// Set up mesh searching
meshSearch searchEngine(mesh, true);
// Construct sample points generator
dictionary sampleDict;
sampleDict.add("name", "lineX1");
sampleDict.add("axis", "distance");
sampleDict.add("start", point(0.02, 0.051, 0.005));
sampleDict.add("end", point(0.06, 0.051, 0.005));
sampleDict.add("nPoints", 10);
PtrList<sampleSet> sampleSets(1);
sampleSets.set
(
0,
sampleSet::New
(
"uniform",
mesh,
searchEngine,
sampleDict
).ptr()
);
// Load field
volScalarField sField
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
mesh
);
// Set up interpolation
pointMesh pMesh(mesh);
volPointInterpolation pInterp(mesh, pMesh);
// Do actual sampling
dictionary interpolationSchemes;
interpolationSchemes.add("p", "cell");
volFieldSampler<scalar> sampleVals
(
pInterp,
interpolationSchemes,
sField,
sampleSets
);
// Construct writer and write
autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
scalarFormatter().write
(
".",
sampleSets[0],
sampleVals.name(),
sampleVals[0]
);
//
// 2. No sampling, just using writing
//
List<point> points(5);
points[0] = point(0, 0, 0);
points[1] = point(1, 1, 1);
points[2] = point(2, 2, 2);
points[3] = point(3, 3, 3);
points[4] = point(4, 4, 4);
scalarList vals(5);
vals[0] = 0.0;
vals[1] = 0.1;
vals[2] = 0.2;
vals[3] = 0.3;
vals[4] = 0.4;
scalarFormatter().write
(
".",
coordSet
(
"someLine",
"distance",
points,
points[0]
),
"U.component(0)",
vals
);
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -1,91 +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
Description
\*---------------------------------------------------------------------------*/
#include "volFieldSampler.H"
#include "volPointInterpolation.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template <class Type>
Foam::volFieldSampler<Type>::volFieldSampler
(
const volPointInterpolation& pInterp,
const dictionary& interpolationSchemes,
const GeometricField<Type, fvPatchField, volMesh>& field,
const PtrList<sampleSet>& samplers
)
:
List<Field<Type> >(samplers.size()),
name_(field.name())
{
autoPtr<interpolation<Type> > interpolator
(
interpolation<Type>::New(interpolationSchemes, pInterp, field)
);
forAll(samplers, setI)
{
Field<Type>& values = this->operator[](setI);
const sampleSet& 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
);
}
}
}
// Construct from components
template <class Type>
Foam::volFieldSampler<Type>::volFieldSampler
(
const List<Field<Type> >& values,
const word& name
)
:
List<Field<Type> >(values),
name_(name)
{}
// ************************************************************************* //

View File

@ -1,109 +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
Class
Foam::volFieldSampler
Description
Samples a volField given a list of sampleSets (i.e. points).
SourceFiles
volFieldSampler.C
\*---------------------------------------------------------------------------*/
#ifndef volFieldSampler_H
#define volFieldSampler_H
#include "sampleSet.H"
#include "List.H"
#include "PtrList.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class volPointInterpolation;
class dictionary;
/*---------------------------------------------------------------------------*\
Class volFieldSampler Declaration
\*---------------------------------------------------------------------------*/
template <class Type>
class volFieldSampler
:
public List<Field<Type> >
{
//- Name of this collection of values
const word name_;
public:
// Constructors
//- Construct from sampleSet, interpolator, Field
volFieldSampler
(
const volPointInterpolation&,
const dictionary& interpolationSchemes,
const GeometricField<Type, fvPatchField, volMesh>& field,
const PtrList<sampleSet>&
);
//- Construct from components
volFieldSampler
(
const List<Field<Type> >& values,
const word& name
);
// Member functions
const word& name() const
{
return name_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "volFieldSampler.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,100 +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 "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

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

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

View File

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

@ -1,106 +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 "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

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

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

View File

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

@ -1,83 +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 "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

@ -1,105 +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
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;
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

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

View File

@ -1,62 +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
InClass
Foam::rawWriters
Description
SourceFiles
rawWriters.C
\*---------------------------------------------------------------------------*/
#ifndef rawWriters_H
#define rawWriters_H
#include "raw.H"
#include "writers.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef raw<scalar> rawScalarWriter;
typedef raw<vector> rawVectorWriter;
typedef raw<tensor> rawTensorWriter;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,205 +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 "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

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

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

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

@ -1,89 +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 "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

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

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

View File

@ -1,62 +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
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
// ************************************************************************* //