Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
8bcbf353
Commit
8bcbf353
authored
May 01, 2008
by
henry
Browse files
Update sampling to include surface and line sampling functionObjects
parent
cd161a33
Changes
92
Hide whitespace changes
Inline
Side-by-side
src/sampling/Make/files
View file @
8bcbf353
probes/probes.C
probes/probesFunctionObject.C
sampledSet/coordSet/coordSet.C
sampledSet/sampledSet/sampledSet.C
sampledSet/cloud/cloudSet.C
sampledSet/face/faceOnlySet.C
sampledSet/curve/curveSet.C
sampledSet/uniform/uniformSet.C
sampledSet/midPoint/midPointSet.C
sampledSet/midPointAndFace/midPointAndFaceSet.C
sampledSet/sampledSets/sampledSets.C
sampledSet/sampledSetsFunctionObject/sampledSetsFunctionObject.C
sampledSet/writers/writer/writers.C
sampledSet/writers/xmgr/xmgrWriters.C
sampledSet/writers/gnuplot/gnuplotWriters.C
sampledSet/writers/jplot/jplotWriters.C
sampledSet/writers/raw/rawWriters.C
cuttingPlane/cuttingPlane.C
sampledSurface/patch/sampledPatch.C
sampledSurface/plane/sampledPlane.C
sampledSurface/surface/sampledSurface.C
sampledSurface/surfaces/sampledSurfaces.C
sampledSurface/surfacesFunctionObject/surfacesFunctionObject.C
surface
W
riters/surfaceWriters.C
surface
W
riters/foamFile/foamFileWriters.C
surface
W
riters/dx/dxWriters.C
surface
W
riters/raw/rawWriters.C
surface
W
riters/vtk/vtkWriters.C
surface
W
riters/stl/stlWriters.C
surface
W
riters/null/nullWriters.C
sampledSurface/s
ampledS
urface/sampledSurface.C
sampledSurface/s
ampledS
urfaces/sampledSurfaces.C
sampledSurface/s
ampledS
urfacesFunctionObject/s
ampledS
urfacesFunctionObject.C
s
ampledS
urface
/w
riters/surfaceWriters.C
s
ampledS
urface
/w
riters/foamFile/foamFileWriters.C
s
ampledS
urface
/w
riters/dx/dxWriters.C
s
ampledS
urface
/w
riters/raw/raw
Surface
Writers.C
s
ampledS
urface
/w
riters/vtk/vtkWriters.C
s
ampledS
urface
/w
riters/stl/stlWriters.C
s
ampledS
urface
/w
riters/null/nullWriters.C
graphField/writePatchGraph.C
graphField/writeCellGraph.C
...
...
src/sampling/Make/options
View file @
8bcbf353
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
LIB_LIBS = \
-lfiniteVolume \
...
...
src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C
View file @
8bcbf353
...
...
@@ -48,7 +48,7 @@ Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
IOobject
::
NO_WRITE
)
),
OutputFilter
(
n
ame
()
,
obr
,
*
this
,
readFromFiles
)
OutputFilter
(
OutputFilter
::
typeN
ame
,
obr
,
*
this
,
readFromFiles
)
{}
...
...
src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H
View file @
8bcbf353
/*---------------------------------------------------------------------------*\
/*---------------------------------------------------------------------------*
\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
...
...
@@ -99,14 +99,14 @@ public:
virtual
void
write
();
//- Update for changes of mesh
void
updateMesh
(
const
mapPolyMesh
&
mpm
)
virtual
void
updateMesh
(
const
mapPolyMesh
&
mpm
)
{
read
();
OutputFilter
::
updateMesh
(
mpm
);
}
//- Update for changes of mesh
void
movePoints
(
const
pointField
&
points
)
virtual
void
movePoints
(
const
pointField
&
points
)
{
read
();
OutputFilter
::
movePoints
(
points
);
...
...
src/sampling/probes/probes.H
View file @
8bcbf353
...
...
@@ -40,6 +40,7 @@ SourceFiles
#include
"HashPtrTable.H"
#include
"OFstream.H"
#include
"polyMesh.H"
#include
"pointField.H"
#include
"volFieldsFwd.H"
...
...
@@ -207,6 +208,10 @@ public:
virtual
void
movePoints
(
const
pointField
&
)
{}
//- Update for changes of mesh due to readUpdate
virtual
void
readUpdate
(
const
polyMesh
::
readUpdateState
state
)
{}
//- Sample a volume field at all locations
template
<
class
Type
>
tmp
<
Field
<
Type
>
>
sample
...
...
src/sampling/sampledS
urface/surfacesFunctionObject/surfacesFunctionObject.C.save
→
src/sampling/sampledS
et/cloud/cloudSet.C
View file @
8bcbf353
...
...
@@ -22,143 +22,150 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------
-
*/
\*---------------------------------------------------------------------------*/
#include "surfacesFunctionObject.H"
#include
"cloudSet.H"
#include
"sampledSet.H"
#include
"meshSearch.H"
#include
"DynamicList.H"
#include
"polyMesh.H"
#include
"addToRunTimeSelectionTable.H"
#include "
IOsampledSurfaces
.H"
#include
"
word
.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace
Foam
{
defineTypeNameAndDebug(surfacesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
surfacesFunctionObject,
dictionary
);
defineTypeNameAndDebug
(
cloudSet
,
0
);
addToRunTimeSelectionTable
(
sampledSet
,
cloudSet
,
word
);
}
// * * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * //
// * * * * * * * * * * * * *
Private Member Functions
* * * * * * * * * * * //
void Foam::surfacesFunctionObject::extractDict()
void
Foam
::
cloudSet
::
calcSamples
(
DynamicList
<
point
>&
samplingPts
,
DynamicList
<
label
>&
samplingCells
,
DynamicList
<
label
>&
samplingFaces
,
DynamicList
<
label
>&
samplingSegments
,
DynamicList
<
scalar
>&
samplingCurveDist
)
const
{
if (dict_.found("region")
)
forAll
(
sampleCoords_
,
sampleI
)
{
dict_.lookup("region") >> regionName_;
}
label
cellI
=
searchEngine
().
findCell
(
sampleCoords_
[
sampleI
]);
if (dict_.found("dictionary"))
{
dict_.lookup("dictionary") >> dictName_;
if
(
cellI
!=
-
1
)
{
samplingPts
.
append
(
sampleCoords_
[
sampleI
]);
samplingCells
.
append
(
cellI
);
samplingFaces
.
append
(
-
1
);
samplingSegments
.
append
(
0
);
samplingCurveDist
.
append
(
1
.
0
*
sampleI
);
}
}
}
if (dict_.found("interval"))
{
dict_.lookup("interval") >> interval_;
}
if (dict_.found("enabled"))
{
dict_.lookup("enabled") >> execution_;
}
void
Foam
::
cloudSet
::
genSamples
()
{
// Storage for sample points
DynamicList
<
point
>
samplingPts
;
DynamicList
<
label
>
samplingCells
;
DynamicList
<
label
>
samplingFaces
;
DynamicList
<
label
>
samplingSegments
;
DynamicList
<
scalar
>
samplingCurveDist
;
calcSamples
(
samplingPts
,
samplingCells
,
samplingFaces
,
samplingSegments
,
samplingCurveDist
);
samplingPts
.
shrink
();
samplingCells
.
shrink
();
samplingFaces
.
shrink
();
samplingSegments
.
shrink
();
samplingCurveDist
.
shrink
();
setSamples
(
samplingPts
,
samplingCells
,
samplingFaces
,
samplingSegments
,
samplingCurveDist
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
surfacesFunctionObject::surfacesFunctionObjec
t
Foam
::
cloudSet
::
cloudSe
t
(
const Time& t,
const dictionary& dict
const
word
&
name
,
const
polyMesh
&
mesh
,
meshSearch
&
searchEngine
,
const
word
&
axis
,
const
List
<
point
>&
sampleCoords
)
:
functionObject(),
time_(t),
dict_(dict),
regionName_(polyMesh::defaultRegion),
dictName_(),
interval_(0),
execution_(true)
sampledSet
(
name
,
mesh
,
searchEngine
,
axis
),
sampleCoords_
(
sampleCoords
)
{
extractDict();
}
genSamples
();
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// any possible side-effects?
bool Foam::surfacesFunctionObject::start()
{
extractDict();
if (execution_)
if
(
debug
)
{
if (dictName_.size())
{
ptr_.reset
(
new IOsampledSurfaces
(
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new sampledSurfaces
(
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
write
(
Info
);
}
return true;
}
bool Foam::surfacesFunctionObject::execute()
Foam
::
cloudSet
::
cloudSet
(
const
word
&
name
,
const
polyMesh
&
mesh
,
meshSearch
&
searchEngine
,
const
dictionary
&
dict
)
:
sampledSet
(
name
,
mesh
,
searchEngine
,
dict
),
sampleCoords_
(
dict
.
lookup
(
"points"
))
{
if (execution_ && (interval_ <= 1 || !(time_.timeIndex() % interval_)) )
genSamples
();
if
(
debug
)
{
ptr_->
write();
write
(
Info
);
}
return true;
}
void Foam::surfacesFunctionObject::on()
{
execution_ = true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam
::
cloudSet
::~
cloudSet
()
{}
void Foam::surfacesFunctionObject::off()
{
execution_ = false;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::surfacesFunctionObject::read(const dictionary& dict)
Foam
::
point
Foam
::
cloudSet
::
getRefPoint
(
const
List
<
point
>&
pts
)
const
{
if (
dict_ != dict
)
if
(
pts
.
size
()
>
0
)
{
dict_ = dict;
return
start()
;
// Use first samplePt as starting point
return
pts
[
0
]
;
}
else
{
return
false
;
return
vector
::
zero
;
}
}
// ************************************************************************* //
src/sampling/sampledS
urface/surfacesFunctionObject/surfacesFunctionObject.H.save
→
src/sampling/sampledS
et/cloud/cloudSet.H
View file @
8bcbf353
...
...
@@ -23,96 +23,96 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
surfacesFunctionObjec
t
Foam::cloudSe
t
Description
FunctionObject wrapper around surfaces to allow them to be created via the
functions list within controlDict.
SourceFiles
surfacesFunctionObjec
t.C
cloudSe
t.C
\*---------------------------------------------------------------------------*/
#ifndef
surfacesFunctionObjec
t_H
#define
surfacesFunctionObjec
t_H
#ifndef
cloudSe
t_H
#define
cloudSe
t_H
#include "
functionObjec
t.H"
#include "
dictionary
.H"
#include
"
sampledSe
t.H"
#include
"
DynamicList
.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
class sampledSurfaces;
// Forward declaration of classes
class
passiveParticle
;
template
<
class
Type
>
class
particle
;
/*---------------------------------------------------------------------------*\
Class surfacesFunctionObjec
t Declaration
Class cloudSe
t Declaration
\*---------------------------------------------------------------------------*/
class
surfacesFunctionObjec
t
class
cloudSe
t
:
public
functionObjec
t
public
sampledSe
t
{
// Private data
const Time& time_;
dictionary dict_;
word regionName_;
word dictName_;
//- Sampling points
List
<
point
>
sampleCoords_
;
//- the execution interval (in time steps)
// a value <= 1 means execute at every time step
label interval_;
//- Switch for the execution of the functionObjects
bool execution_;
autoPtr<sampledSurfaces> ptr_;
// Private Member Functions
//- extract relevant dictionary entries
void extractDict();
//- Disallow default bitwise copy construct
surfacesFunctionObject(const surfacesFunctionObject&);
//- Samples all points in sampleCoords.
void
calcSamples
(
DynamicList
<
point
>&
samplingPts
,
DynamicList
<
label
>&
samplingCells
,
DynamicList
<
label
>&
samplingFaces
,
DynamicList
<
label
>&
samplingSegments
,
DynamicList
<
scalar
>&
samplingCurveDist
)
const
;
//-
Disallow default bitwise assignment
void
operator=(const surfacesFunctionObject&
);
//-
Uses calcSamples to obtain samples. Copies them into *this.
void
genSamples
(
);
public:
//- Runtime type information
TypeName("surfaces");
TypeName
(
"cloud"
);
// Constructors
//- Construct from components
surfacesFunctionObjec
t
cloudSe
t
(
const Time&,
const dictionary&
const
word
&
name
,
const
polyMesh
&
mesh
,
meshSearch
&
searchEngine
,
const
word
&
axis
,
const
List
<
point
>&
sampleCoords
);
//- Construct from dictionary
cloudSet
(
const
word
&
name
,
const
polyMesh
&
mesh
,
meshSearch
&
searchEngine
,
const
dictionary
&
dict
);
// Member Functions
//- start is called at the start of the time-loop
virtual bool start();
// Destructor
//- execute is called at each ++ or += of the time-loop
virtual bool execute();
virtual
~
cloudSet
();
//- Switch the function object on
virtual void on();
//- Switch the function object off
virtual void off();
// Member Functions
//-
Read and set the function object if its data has changed
virtual
bool read(const dictionary& dict)
;
//-
Get reference point
virtual
point
getRefPoint
(
const
List
<
point
>&
)
const
;
};
...
...
src/sampling/sampledSet/coordSet/coordSet.C
0 → 100644
View file @
8bcbf353
/*---------------------------------------------------------------------------*\
========= |
\\ / 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_
==