mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
29
src/sampling/Make/files
Normal file
29
src/sampling/Make/files
Normal file
@ -0,0 +1,29 @@
|
||||
probes/probes.C
|
||||
probes/probesFunctionObject.C
|
||||
|
||||
cuttingPlane/cuttingPlane.C
|
||||
|
||||
sampledSurface/patch/sampledPatch.C
|
||||
sampledSurface/plane/sampledPlane.C
|
||||
sampledSurface/surface/sampledSurface.C
|
||||
sampledSurface/surfaces/sampledSurfaces.C
|
||||
sampledSurface/surfacesFunctionObject/surfacesFunctionObject.C
|
||||
|
||||
surfaceWriters/surfaceWriters.C
|
||||
surfaceWriters/foamFile/foamFileWriters.C
|
||||
surfaceWriters/dx/dxWriters.C
|
||||
surfaceWriters/raw/rawWriters.C
|
||||
surfaceWriters/vtk/vtkWriters.C
|
||||
surfaceWriters/stl/stlWriters.C
|
||||
surfaceWriters/null/nullWriters.C
|
||||
|
||||
graphField/writePatchGraph.C
|
||||
graphField/writeCellGraph.C
|
||||
graphField/makeGraph.C
|
||||
|
||||
meshToMesh = meshToMeshInterpolation/meshToMesh
|
||||
$(meshToMesh)/meshToMesh.C
|
||||
$(meshToMesh)/calculateMeshToMeshAddressing.C
|
||||
$(meshToMesh)/calculateMeshToMeshWeights.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libsampling
|
||||
9
src/sampling/Make/options
Normal file
9
src/sampling/Make/options
Normal file
@ -0,0 +1,9 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/triSurface/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-ltriSurface
|
||||
456
src/sampling/cuttingPlane/cuttingPlane.C
Normal file
456
src/sampling/cuttingPlane/cuttingPlane.C
Normal file
@ -0,0 +1,456 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "cuttingPlane.H"
|
||||
#include "primitiveMesh.H"
|
||||
#include "linePointRef.H"
|
||||
#include "meshTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Find cut cells
|
||||
void Foam::cuttingPlane::calcCutCells
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const scalarField& dotProducts,
|
||||
const labelList& cellIdLabels
|
||||
)
|
||||
{
|
||||
const labelListList& cellEdges = mesh.cellEdges();
|
||||
const edgeList& edges = mesh.edges();
|
||||
|
||||
label listSize = cellEdges.size();
|
||||
if (&cellIdLabels)
|
||||
{
|
||||
listSize = cellIdLabels.size();
|
||||
}
|
||||
|
||||
cutCells_.setSize(listSize);
|
||||
label cutcellI(0);
|
||||
|
||||
// Find the cut cells by detecting any cell that uses points with
|
||||
// opposing dotProducts.
|
||||
for (label listI = 0; listI < listSize; ++listI)
|
||||
{
|
||||
label cellI = listI;
|
||||
if (&cellIdLabels)
|
||||
{
|
||||
cellI = cellIdLabels[listI];
|
||||
}
|
||||
|
||||
const labelList& cEdges = cellEdges[cellI];
|
||||
|
||||
label nCutEdges = 0;
|
||||
|
||||
forAll(cEdges, i)
|
||||
{
|
||||
const edge& e = edges[cEdges[i]];
|
||||
|
||||
if
|
||||
(
|
||||
(dotProducts[e[0]] < 0 && dotProducts[e[1]] > 0)
|
||||
|| (dotProducts[e[1]] < 0 && dotProducts[e[0]] > 0)
|
||||
)
|
||||
{
|
||||
nCutEdges++;
|
||||
|
||||
if (nCutEdges > 2)
|
||||
{
|
||||
cutCells_[cutcellI++] = cellI;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set correct list size
|
||||
cutCells_.setSize(cutcellI);
|
||||
}
|
||||
|
||||
|
||||
// Determine for each edge the intersection point. Calculates
|
||||
// - cutPoints_ : coordinates of all intersection points
|
||||
// - edgePoint : per edge -1 or the index into cutPoints_
|
||||
Foam::labelList Foam::cuttingPlane::intersectEdges
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const scalarField& dotProducts
|
||||
)
|
||||
{
|
||||
// Use the dotProducts to find out the cut edges.
|
||||
const edgeList& edges = mesh.edges();
|
||||
const pointField& points = mesh.points();
|
||||
|
||||
// Per edge -1 or the label of the intersection point
|
||||
labelList edgePoint(edges.size(), -1);
|
||||
|
||||
DynamicList<point> dynCuttingPoints(4*cutCells_.size());
|
||||
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
if
|
||||
(
|
||||
(dotProducts[e[0]] < 0 && dotProducts[e[1]] > 0)
|
||||
|| (dotProducts[e[1]] < 0 && dotProducts[e[0]] > 0)
|
||||
)
|
||||
{
|
||||
// Edge is cut.
|
||||
const point& p0 = points[e[0]];
|
||||
const point& p1 = points[e[1]];
|
||||
|
||||
scalar alpha = lineIntersect(linePointRef(p0, p1));
|
||||
|
||||
dynCuttingPoints.append((1-alpha)*p0 + alpha*p1);
|
||||
edgePoint[edgeI] = dynCuttingPoints.size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
dynCuttingPoints.shrink();
|
||||
cutPoints_.transfer(dynCuttingPoints);
|
||||
dynCuttingPoints.clear();
|
||||
|
||||
return edgePoint;
|
||||
}
|
||||
|
||||
|
||||
// Coming from startEdgeI cross the edge to the other face
|
||||
// across to the next cut edge.
|
||||
bool Foam::cuttingPlane::walkCell
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& edgePoint,
|
||||
const label cellI,
|
||||
const label startEdgeI,
|
||||
DynamicList<label>& faceVerts
|
||||
)
|
||||
{
|
||||
label faceI = -1;
|
||||
label edgeI = startEdgeI;
|
||||
|
||||
label nIter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
faceVerts.append(edgePoint[edgeI]);
|
||||
|
||||
// Cross edge to other face
|
||||
faceI = meshTools::otherFace(mesh, cellI, faceI, edgeI);
|
||||
|
||||
// Find next cut edge on face.
|
||||
const labelList& fEdges = mesh.faceEdges()[faceI];
|
||||
|
||||
label nextEdgeI = -1;
|
||||
|
||||
//Note: here is where we should check for whether there are more
|
||||
// than 2 intersections with the face (warped/non-convex face).
|
||||
// If so should e.g. decompose the cells on both faces and redo
|
||||
// the calculation.
|
||||
|
||||
forAll(fEdges, i)
|
||||
{
|
||||
label edge2I = fEdges[i];
|
||||
|
||||
if (edge2I != edgeI && edgePoint[edge2I] != -1)
|
||||
{
|
||||
nextEdgeI = edge2I;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextEdgeI == -1)
|
||||
{
|
||||
// Did not find another cut edge on faceI. Do what?
|
||||
WarningIn("Foam::cuttingPlane::walkCell")
|
||||
<< "Did not find closed walk along surface of cell " << cellI
|
||||
<< " starting from edge " << startEdgeI
|
||||
<< " in " << nIter << " iterations." << nl
|
||||
<< "Collected cutPoints so far:" << faceVerts
|
||||
<< endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
edgeI = nextEdgeI;
|
||||
|
||||
nIter++;
|
||||
|
||||
if (nIter > 1000)
|
||||
{
|
||||
WarningIn("Foam::cuttingPlane::walkCell")
|
||||
<< "Did not find closed walk along surface of cell " << cellI
|
||||
<< " starting from edge " << startEdgeI
|
||||
<< " in " << nIter << " iterations." << nl
|
||||
<< "Collected cutPoints so far:" << faceVerts
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
} while (edgeI != startEdgeI);
|
||||
|
||||
|
||||
if (faceVerts.size() >= 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("Foam::cuttingPlane::walkCell")
|
||||
<< "Did not find closed walk along surface of cell " << cellI
|
||||
<< " starting from edge " << startEdgeI << nl
|
||||
<< "Collected cutPoints so far:" << faceVerts
|
||||
<< endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// For every cut cell determine a walk through all? its cuts.
|
||||
void Foam::cuttingPlane::walkCellCuts
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& edgePoint
|
||||
)
|
||||
{
|
||||
cutFaces_.setSize(cutCells_.size());
|
||||
label cutFaceI = 0;
|
||||
|
||||
forAll(cutCells_, i)
|
||||
{
|
||||
label cellI = cutCells_[i];
|
||||
|
||||
// Find the starting edge to walk from.
|
||||
const labelList& cEdges = mesh.cellEdges()[cellI];
|
||||
|
||||
label startEdgeI = -1;
|
||||
|
||||
forAll(cEdges, cEdgeI)
|
||||
{
|
||||
label edgeI = cEdges[cEdgeI];
|
||||
|
||||
if (edgePoint[edgeI] != -1)
|
||||
{
|
||||
startEdgeI = edgeI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for the unexpected ...
|
||||
if (startEdgeI == -1)
|
||||
{
|
||||
FatalErrorIn("Foam::cuttingPlane::walkCellCuts")
|
||||
<< "Cannot find cut edge for cut cell " << cellI
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Walk from starting edge around the circumference of the cell.
|
||||
DynamicList<label> faceVerts(2*mesh.faces()[cellI].size());
|
||||
bool okCut = walkCell
|
||||
(
|
||||
mesh,
|
||||
edgePoint,
|
||||
cellI,
|
||||
startEdgeI,
|
||||
faceVerts
|
||||
);
|
||||
|
||||
if (okCut)
|
||||
{
|
||||
faceVerts.shrink();
|
||||
|
||||
face cutFace(faceVerts);
|
||||
|
||||
// Orient face.
|
||||
if ((cutFace.normal(cutPoints_) && normal()) < 0)
|
||||
{
|
||||
cutFace = cutFace.reverseFace();
|
||||
}
|
||||
|
||||
cutFaces_[cutFaceI++] = cutFace;
|
||||
}
|
||||
}
|
||||
|
||||
cutFaces_.setSize(cutFaceI);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct without cutting
|
||||
Foam::cuttingPlane::cuttingPlane(const plane& newPlane)
|
||||
:
|
||||
plane(newPlane)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
Foam::cuttingPlane::cuttingPlane
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const plane& newPlane
|
||||
)
|
||||
:
|
||||
plane(newPlane)
|
||||
{
|
||||
reCut(mesh);
|
||||
}
|
||||
|
||||
// Construct from mesh reference and plane, restricted to a list of cells
|
||||
Foam::cuttingPlane::cuttingPlane
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const plane& newPlane,
|
||||
const labelList& cellIdLabels
|
||||
)
|
||||
:
|
||||
plane(newPlane)
|
||||
{
|
||||
reCut(mesh, cellIdLabels);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// reCut mesh with existing planeDesc
|
||||
void Foam::cuttingPlane::reCut
|
||||
(
|
||||
const primitiveMesh& mesh
|
||||
)
|
||||
{
|
||||
cutCells_.clear();
|
||||
cutPoints_.clear();
|
||||
cutFaces_.clear();
|
||||
|
||||
scalarField dotProducts = (mesh.points() - refPoint()) & normal();
|
||||
|
||||
//// Perturb points cuts so edges are cut properly.
|
||||
//const tmp<scalarField> tdotProducts = stabilise(rawDotProducts, SMALL);
|
||||
//const scalarField& dotProducts = tdotProducts();
|
||||
|
||||
// Determine cells that are (probably) cut.
|
||||
calcCutCells(mesh, dotProducts);
|
||||
|
||||
// Determine cutPoints and return list of edge cuts. (per edge -1 or
|
||||
// the label of the intersection point (in cutPoints_)
|
||||
labelList edgePoint(intersectEdges(mesh, dotProducts));
|
||||
|
||||
// Do topological walk around cell to find closed loop.
|
||||
walkCellCuts(mesh, edgePoint);
|
||||
}
|
||||
|
||||
|
||||
// recut mesh with existing planeDesc
|
||||
void Foam::cuttingPlane::reCut
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& cellIdLabels
|
||||
)
|
||||
{
|
||||
cutCells_.clear();
|
||||
cutPoints_.clear();
|
||||
cutFaces_.clear();
|
||||
|
||||
scalarField dotProducts = (mesh.points() - refPoint()) & normal();
|
||||
|
||||
// Determine cells that are (probably) cut.
|
||||
calcCutCells(mesh, dotProducts, cellIdLabels);
|
||||
|
||||
// Determine cutPoints and return list of edge cuts. (per edge -1 or
|
||||
// the label of the intersection point (in cutPoints_)
|
||||
labelList edgePoint(intersectEdges(mesh, dotProducts));
|
||||
|
||||
// Do topological walk around cell to find closed loop.
|
||||
walkCellCuts(mesh, edgePoint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Return plane used
|
||||
const Foam::plane& Foam::cuttingPlane::planeDesc() const
|
||||
{
|
||||
return static_cast<const plane&>(*this);
|
||||
}
|
||||
|
||||
|
||||
// Return vectorField of cutting points
|
||||
const Foam::pointField& Foam::cuttingPlane::points() const
|
||||
{
|
||||
return cutPoints_;
|
||||
}
|
||||
|
||||
|
||||
// Return unallocFaceList of points in cells
|
||||
const Foam::faceList& Foam::cuttingPlane::faces() const
|
||||
{
|
||||
return cutFaces_;
|
||||
}
|
||||
|
||||
|
||||
// Return labelList of cut cells
|
||||
const Foam::labelList& Foam::cuttingPlane::cells() const
|
||||
{
|
||||
return cutCells_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::cuttingPlane::cut()
|
||||
{
|
||||
if (cutCells_.size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::cuttingPlane::operator=(const cuttingPlane& rhs)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorIn ("Foam::cuttingPlane::operator=(const cuttingPlane&)")
|
||||
<< "Attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
static_cast<plane&>(*this) = rhs;
|
||||
|
||||
cutCells_ = rhs.cells();
|
||||
cutPoints_ = rhs.points();
|
||||
cutFaces_ = rhs.faces();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
191
src/sampling/cuttingPlane/cuttingPlane.H
Normal file
191
src/sampling/cuttingPlane/cuttingPlane.H
Normal file
@ -0,0 +1,191 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::cuttingPlane
|
||||
|
||||
Description
|
||||
Constructs plane through mesh.
|
||||
|
||||
No attempt at resolving degenerate cases.
|
||||
|
||||
SourceFiles
|
||||
cuttingPlane.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cuttingPlane_H
|
||||
#define cuttingPlane_H
|
||||
|
||||
#include "plane.H"
|
||||
#include "pointField.H"
|
||||
#include "faceList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class primitiveMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cuttingPlane Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cuttingPlane
|
||||
:
|
||||
public plane
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- List of cells cut by the plane
|
||||
labelList cutCells_;
|
||||
|
||||
//- Intersection points
|
||||
pointField cutPoints_;
|
||||
|
||||
//- Cut faces in terms of intersection points
|
||||
faceList cutFaces_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Determine cut cells, possibly restricted to a list of cells
|
||||
void calcCutCells
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const scalarField& dotProducts,
|
||||
const labelList& cellIdLabels = labelList::null()
|
||||
);
|
||||
|
||||
//- Determine intersection points (cutPoints_).
|
||||
labelList intersectEdges
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const scalarField& dotProducts
|
||||
);
|
||||
|
||||
//- Walk around circumference of cell starting from startEdgeI crossing
|
||||
// only cut edges. Record cutPoint labels in faceVerts.
|
||||
static bool walkCell
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const labelList& edgePoint,
|
||||
const label cellI,
|
||||
const label startEdgeI,
|
||||
DynamicList<label>& faceVerts
|
||||
);
|
||||
|
||||
//- Determine cuts for all cut cells.
|
||||
void walkCellCuts
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& edgePoint
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct plane description without cutting
|
||||
cuttingPlane(const plane&);
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- recut mesh with existing planeDesc
|
||||
void reCut(const primitiveMesh&);
|
||||
|
||||
//- recut mesh with existing planeDesc, restricted to a list of cells
|
||||
void reCut
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const labelList& cellIdLabels
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components: Mesh reference and plane
|
||||
cuttingPlane(const primitiveMesh&, const plane&);
|
||||
|
||||
//- Construct from mesh reference and plane,
|
||||
// restricted to a list of cells
|
||||
cuttingPlane
|
||||
(
|
||||
const primitiveMesh&,
|
||||
const plane&,
|
||||
const labelList& cellIdLabels
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return plane used
|
||||
const plane& planeDesc() const;
|
||||
|
||||
//- Return pointField of cutting points
|
||||
const pointField& points() const;
|
||||
|
||||
//- Return faceList of points in cells
|
||||
const faceList& faces() const;
|
||||
|
||||
//- Return labelList of cut cells
|
||||
const labelList& cells() const;
|
||||
|
||||
//- Return true or false to question: have any cells been cut?
|
||||
bool cut();
|
||||
|
||||
//- Sample the cell field
|
||||
template<class Type>
|
||||
tmp<Field<Type> > sample(const Field<Type>&) const;
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type> > sample(const tmp<Field<Type> >&) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const cuttingPlane&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "cuttingPlaneSample.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
57
src/sampling/cuttingPlane/cuttingPlaneSample.C
Normal file
57
src/sampling/cuttingPlane/cuttingPlaneSample.C
Normal file
@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Cutting plane sampling functionality
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cuttingPlane.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::cuttingPlane::sample
|
||||
(
|
||||
const Field<Type>& sf
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type> >(new Field<Type>(sf, cells()));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::cuttingPlane::sample
|
||||
(
|
||||
const tmp<Field<Type> >& tsf
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type> > tint = sample(tsf());
|
||||
tsf.clear();
|
||||
return tint;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
94
src/sampling/graphField/makeGraph.C
Normal file
94
src/sampling/graphField/makeGraph.C
Normal file
@ -0,0 +1,94 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Global
|
||||
makeGraph
|
||||
|
||||
Description
|
||||
Write a graph file for a field given the data point locations field,
|
||||
the field of interest and the name of the field to be used for the
|
||||
graph file name.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "makeGraph.H"
|
||||
#include "volFields.H"
|
||||
#include "fvMesh.H"
|
||||
#include "graph.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void makeGraph
|
||||
(
|
||||
const scalarField& x,
|
||||
const volScalarField& vsf,
|
||||
const word& graphFormat
|
||||
)
|
||||
{
|
||||
makeGraph(x, vsf, vsf.name(), graphFormat);
|
||||
}
|
||||
|
||||
|
||||
void makeGraph
|
||||
(
|
||||
const scalarField& x,
|
||||
const volScalarField& vsf,
|
||||
const word& name,
|
||||
const word& graphFormat
|
||||
)
|
||||
{
|
||||
makeGraph(x, vsf.internalField(), name, vsf.path(), graphFormat);
|
||||
}
|
||||
|
||||
|
||||
void makeGraph
|
||||
(
|
||||
const scalarField& x,
|
||||
const scalarField& sf,
|
||||
const word& name,
|
||||
const fileName& path,
|
||||
const word& graphFormat
|
||||
)
|
||||
{
|
||||
graph
|
||||
(
|
||||
name,
|
||||
"x",
|
||||
name,
|
||||
x,
|
||||
sf
|
||||
).write(path/name, graphFormat);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
85
src/sampling/graphField/makeGraph.H
Normal file
85
src/sampling/graphField/makeGraph.H
Normal file
@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Global
|
||||
makeGraph
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
makeGraph.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef makeGraph_H
|
||||
#define makeGraph_H
|
||||
|
||||
#include "primitiveFieldsFwd.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class fileName;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void makeGraph
|
||||
(
|
||||
const scalarField& x,
|
||||
const volScalarField& vsf,
|
||||
const word& graphFormat
|
||||
);
|
||||
|
||||
|
||||
void makeGraph
|
||||
(
|
||||
const scalarField& x,
|
||||
const volScalarField& vsf,
|
||||
const word& name,
|
||||
const word& graphFormat
|
||||
);
|
||||
|
||||
|
||||
void makeGraph
|
||||
(
|
||||
const scalarField& x,
|
||||
const scalarField& sf,
|
||||
const word& name,
|
||||
const fileName& path,
|
||||
const word& graphFormat
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
34
src/sampling/graphField/writeCellGraph.C
Normal file
34
src/sampling/graphField/writeCellGraph.C
Normal file
@ -0,0 +1,34 @@
|
||||
#include "writeCellGraph.H"
|
||||
#include "volFields.H"
|
||||
#include "fvMesh.H"
|
||||
#include "graph.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writeCellGraph
|
||||
(
|
||||
const volScalarField& vsf,
|
||||
const word& graphFormat
|
||||
)
|
||||
{
|
||||
graph
|
||||
(
|
||||
vsf.name(),
|
||||
"x",
|
||||
vsf.name(),
|
||||
vsf.mesh().C().internalField().component(vector::X),
|
||||
vsf.internalField()
|
||||
).write(vsf.time().timePath()/vsf.name(), graphFormat);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
61
src/sampling/graphField/writeCellGraph.H
Normal file
61
src/sampling/graphField/writeCellGraph.H
Normal file
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
InNamespace
|
||||
Foam::writeCellGraph
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
writeCellGraph.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeCellGraph_H
|
||||
#define writeCellGraph_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writeCellGraph
|
||||
(
|
||||
const volScalarField& vsf,
|
||||
const word& graphFormat
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
37
src/sampling/graphField/writePatchGraph.C
Normal file
37
src/sampling/graphField/writePatchGraph.C
Normal file
@ -0,0 +1,37 @@
|
||||
#include "writePatchGraph.H"
|
||||
#include "volFields.H"
|
||||
#include "fvMesh.H"
|
||||
#include "graph.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writePatchGraph
|
||||
(
|
||||
const volScalarField& vsf,
|
||||
const label patchLabel,
|
||||
const direction d,
|
||||
const word& graphFormat
|
||||
)
|
||||
{
|
||||
graph
|
||||
(
|
||||
vsf.name(),
|
||||
"position",
|
||||
vsf.name(),
|
||||
vsf.mesh().boundary()[patchLabel].Cf().component(d),
|
||||
vsf.boundaryField()[patchLabel]
|
||||
).write(vsf.time().timePath()/vsf.name(), graphFormat);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
62
src/sampling/graphField/writePatchGraph.H
Normal file
62
src/sampling/graphField/writePatchGraph.H
Normal file
@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::writePatchGraph
|
||||
|
||||
Description
|
||||
|
||||
|
||||
SourceFiles
|
||||
writePatchGraph.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writePatchGraph_H
|
||||
#define writePatchGraph_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
void writePatchGraph
|
||||
(
|
||||
const volScalarField& vsf,
|
||||
const label patchLabel,
|
||||
const direction d,
|
||||
const word& graphFormat
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
82
src/sampling/include/buildPatch.H
Normal file
82
src/sampling/include/buildPatch.H
Normal file
@ -0,0 +1,82 @@
|
||||
|
||||
IOdictionary planeToPatchDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"planeToPatchDict",
|
||||
runTime.system(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
Switch planeMapping
|
||||
(
|
||||
planeToPatchDict.lookup("mappingPlane")
|
||||
);
|
||||
|
||||
Info << "Constructing planePatch" << endl;
|
||||
cuttingPlane cut(mesh, plane(planeToPatchDict));
|
||||
|
||||
primitiveFacePatch planePatch
|
||||
(
|
||||
cut.faces(),
|
||||
cut.points()
|
||||
);
|
||||
|
||||
Info << "Finding target patch" << endl;
|
||||
|
||||
word toPatchName
|
||||
(
|
||||
planeToPatchDict.lookup("targetPatchName")
|
||||
);
|
||||
|
||||
const fvPatchList& patches = mesh.boundary();
|
||||
bool targetPatchNamePresent(false);
|
||||
label targetPatchNumber = -1;
|
||||
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
if(patches[patchI].name() == toPatchName)
|
||||
{
|
||||
targetPatchNamePresent = true;
|
||||
targetPatchNumber = patchI;
|
||||
}
|
||||
}
|
||||
|
||||
const labelList& cutCells(cut.cells());
|
||||
|
||||
if(!targetPatchNamePresent)
|
||||
{
|
||||
targetPatchNumber = 1;
|
||||
Serr << "Target patch not present. " << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serr << "Target patch name: " << patches[targetPatchNumber].name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
patchToPatchInterpolation interPatch
|
||||
(
|
||||
planePatch,
|
||||
patches[targetPatchNumber].patch()
|
||||
);
|
||||
|
||||
|
||||
PrimitivePatchInterpolation
|
||||
<
|
||||
PrimitivePatch<face, List, const pointField&>
|
||||
> planePatchInter
|
||||
(
|
||||
planePatch
|
||||
);
|
||||
|
||||
PrimitivePatchInterpolation
|
||||
<
|
||||
PrimitivePatch<face, List, const pointField&>
|
||||
> toPatchInter
|
||||
(
|
||||
patches[targetPatchNumber].patch()
|
||||
);
|
||||
90
src/sampling/include/mapPatch.H
Normal file
90
src/sampling/include/mapPatch.H
Normal file
@ -0,0 +1,90 @@
|
||||
if(planeMapping && targetPatchNamePresent && cut.cut())
|
||||
{
|
||||
//Map variables U, phi & k
|
||||
//Info << typeInfo("isoLESmodel") << endl;
|
||||
//Info << "SGS model" << sgsModel.type() << endl;
|
||||
|
||||
scalarField planek(cutCells.size());
|
||||
scalarField planeNuTilda(cutCells.size());
|
||||
vectorField planeU(cutCells.size());
|
||||
|
||||
forAll(cutCells, cCellsI)
|
||||
{
|
||||
if(sgsModel.type() == "SpalartAllmaras")
|
||||
{
|
||||
planeNuTilda[cCellsI] = sgsModel.nuTilda()()[cutCells[cCellsI]];
|
||||
}
|
||||
else
|
||||
{
|
||||
planek[cCellsI] = sgsModel.k()()[cutCells[cCellsI]];
|
||||
}
|
||||
planeU[cCellsI] = U[cutCells[cCellsI]];
|
||||
}
|
||||
|
||||
if(sgsModel.type() == "SpalartAllmaras")
|
||||
{
|
||||
Info << "Mapping NuTilda." << endl;
|
||||
sgsModel.nuTilda()().boundaryField()[targetPatchNumber] ==
|
||||
interPatch.faceInterpolate(planeNuTilda)();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info << "Mapping k." << endl;
|
||||
sgsModel.k()().boundaryField()[targetPatchNumber] ==
|
||||
interPatch.faceInterpolate(planek)();
|
||||
}
|
||||
|
||||
U.boundaryField()[targetPatchNumber] ==
|
||||
interPatch.faceInterpolate(planeU)();
|
||||
|
||||
/* sgsModel.k()().boundaryField()[targetPatchNumber] ==
|
||||
toPatchInter.pointToFaceInterpolate
|
||||
(
|
||||
interPatch.pointInterpolate
|
||||
(
|
||||
planePatchInter.faceToPointInterpolate
|
||||
(
|
||||
planek
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
U.boundaryField()[targetPatchNumber] ==
|
||||
toPatchInter.pointToFaceInterpolate
|
||||
(
|
||||
interPatch.pointInterpolate
|
||||
(
|
||||
planePatchInter.faceToPointInterpolate
|
||||
(
|
||||
planeU
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
scalar Q = sum
|
||||
(
|
||||
mesh.Sf().boundaryField()[targetPatchNumber]
|
||||
& U.boundaryField()[targetPatchNumber]
|
||||
);
|
||||
|
||||
scalar Qbar = sum
|
||||
(
|
||||
mesh.Sf().boundaryField()[targetPatchNumber] &
|
||||
Ubar.value()
|
||||
);
|
||||
|
||||
U.boundaryField()[targetPatchNumber] ==
|
||||
U.boundaryField()[targetPatchNumber] * (Qbar/Q);
|
||||
|
||||
Info << "Mass flux correction factor: " << (Qbar/Q) << endl;
|
||||
|
||||
phi.boundaryField()[targetPatchNumber] ==
|
||||
(
|
||||
mesh.Sf().boundaryField()[targetPatchNumber] &
|
||||
U.boundaryField()[targetPatchNumber]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,363 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
private member of meshToMesh.
|
||||
Calculates mesh to mesh addressing pattern (for each cell from one mesh
|
||||
find the closest cell centre in the other mesh).
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshToMesh.H"
|
||||
#include "SubField.H"
|
||||
|
||||
#include "octree.H"
|
||||
#include "octreeDataCell.H"
|
||||
#include "octreeDataFace.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void meshToMesh::calcAddressing()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshToMesh::calculateAddressing() : "
|
||||
<< "calculating mesh-to-mesh cell addressing" << endl;
|
||||
}
|
||||
|
||||
// set reference to cells
|
||||
const cellList& fromCells = fromMesh_.cells();
|
||||
const pointField& fromPoints = fromMesh_.points();
|
||||
|
||||
// In an attempt to preserve the efficiency of linear search and prevent
|
||||
// failure, a RESCUE mechanism will be set up. Here, we shall mark all
|
||||
// cells next to the solid boundaries. If such a cell is found as the
|
||||
// closest, the relationship between the origin and cell will be examined.
|
||||
// If the origin is outside the cell, a global n-squared search is
|
||||
// triggered.
|
||||
|
||||
// SETTING UP RESCUE
|
||||
|
||||
// visit all boundaries and mark the cell next to the boundary.
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshToMesh::calculateAddressing() : "
|
||||
<< "Setting up rescue" << endl;
|
||||
}
|
||||
|
||||
List<bool> boundaryCell(fromCells.size(), false);
|
||||
|
||||
// set reference to boundary
|
||||
const polyPatchList& patchesFrom = fromMesh_.boundaryMesh();
|
||||
|
||||
forAll (patchesFrom, patchI)
|
||||
{
|
||||
// get reference to cells next to the boundary
|
||||
const unallocLabelList& bCells = patchesFrom[patchI].faceCells();
|
||||
|
||||
forAll (bCells, faceI)
|
||||
{
|
||||
boundaryCell[bCells[faceI]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
treeBoundBox meshBb(fromPoints);
|
||||
|
||||
scalar typDim = meshBb.avgDim()/(2.0*cbrt(scalar(fromCells.size())));
|
||||
|
||||
treeBoundBox shiftedBb
|
||||
(
|
||||
meshBb.min(),
|
||||
meshBb.max() + vector(typDim, typDim, typDim)
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "\nMesh" << endl;
|
||||
Info<< " bounding box : " << meshBb << endl;
|
||||
Info<< " bounding box (shifted) : " << shiftedBb << endl;
|
||||
Info<< " typical dimension :" << shiftedBb.typDim() << endl;
|
||||
}
|
||||
|
||||
// Wrap indices and mesh information into helper object
|
||||
octreeDataCell shapes(fromMesh_);
|
||||
|
||||
octree<octreeDataCell> oc
|
||||
(
|
||||
shiftedBb, // overall bounding box
|
||||
shapes, // all information needed to do checks on cells
|
||||
1, // min. levels
|
||||
10.0, // max. size of leaves
|
||||
10.0 // maximum ratio of cubes v.s. cells
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
oc.printStats(Info);
|
||||
}
|
||||
|
||||
cellAddresses
|
||||
(
|
||||
cellAddressing_,
|
||||
toMesh_.cellCentres(),
|
||||
fromMesh_,
|
||||
boundaryCell,
|
||||
oc
|
||||
);
|
||||
|
||||
forAll (toMesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
const polyPatch& toPatch = toMesh_.boundaryMesh()[patchi];
|
||||
|
||||
if (cuttingPatches_.found(toPatch.name()))
|
||||
{
|
||||
boundaryAddressing_[patchi].setSize(toPatch.size());
|
||||
|
||||
cellAddresses
|
||||
(
|
||||
boundaryAddressing_[patchi],
|
||||
toPatch.faceCentres(),
|
||||
fromMesh_,
|
||||
boundaryCell,
|
||||
oc
|
||||
);
|
||||
}
|
||||
else if
|
||||
(
|
||||
patchMap_.found(toPatch.name())
|
||||
&& fromMeshPatches_.found(patchMap_.find(toPatch.name())())
|
||||
)
|
||||
{
|
||||
const polyPatch& fromPatch = fromMesh_.boundaryMesh()
|
||||
[
|
||||
fromMeshPatches_.find(patchMap_.find(toPatch.name())())()
|
||||
];
|
||||
|
||||
if (fromPatch.size() == 0)
|
||||
{
|
||||
WarningIn("meshToMesh::calcAddressing()")
|
||||
<< "Source patch " << fromPatch.name()
|
||||
<< " has no faces. Not performing mapping for it."
|
||||
<< endl;
|
||||
boundaryAddressing_[patchi] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
treeBoundBox wallBb(fromPatch.localPoints());
|
||||
scalar typDim =
|
||||
wallBb.avgDim()/(2.0*sqrt(scalar(fromPatch.size())));
|
||||
|
||||
treeBoundBox shiftedBb
|
||||
(
|
||||
wallBb.min(),
|
||||
wallBb.max() + vector(typDim, typDim, typDim)
|
||||
);
|
||||
|
||||
// Wrap data for octree into container
|
||||
octreeDataFace shapes(fromPatch);
|
||||
|
||||
octree<octreeDataFace> oc
|
||||
(
|
||||
shiftedBb, // overall search domain
|
||||
shapes, // all information needed to do checks on cells
|
||||
1, // min levels
|
||||
20.0, // maximum ratio of cubes v.s. cells
|
||||
2.0
|
||||
);
|
||||
|
||||
|
||||
const vectorField::subField centresToBoundary =
|
||||
toPatch.faceCentres();
|
||||
|
||||
boundaryAddressing_[patchi].setSize(toPatch.size());
|
||||
|
||||
treeBoundBox tightest;
|
||||
scalar tightestDist;
|
||||
|
||||
forAll(toPatch, toi)
|
||||
{
|
||||
tightest = wallBb; // starting search bb
|
||||
tightestDist = Foam::GREAT; // starting max distance
|
||||
|
||||
boundaryAddressing_[patchi][toi] = oc.findNearest
|
||||
(
|
||||
centresToBoundary[toi],
|
||||
tightest,
|
||||
tightestDist
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshToMesh::calculateAddressing() : "
|
||||
<< "finished calculating mesh-to-mesh acell ddressing" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void meshToMesh::cellAddresses
|
||||
(
|
||||
labelList& cellAddressing_,
|
||||
const pointField& points,
|
||||
const fvMesh& fromMesh,
|
||||
const List<bool>& boundaryCell,
|
||||
const octree<octreeDataCell>& oc
|
||||
) const
|
||||
{
|
||||
// the implemented search method is a simple neighbour array search.
|
||||
// It starts from a cell zero, searches its neighbours and finds one
|
||||
// which is nearer to the target point than the current position.
|
||||
// The location of the "current position" is reset to that cell and
|
||||
// search through the neighbours continues. The search is finished
|
||||
// when all the neighbours of the cell are farther from the target
|
||||
// point than the current cell
|
||||
|
||||
// set curCell label to zero (start)
|
||||
register label curCell = 0;
|
||||
|
||||
// set reference to cell to cell addressing
|
||||
const vectorField& centresFrom = fromMesh.cellCentres();
|
||||
const labelListList& cc = fromMesh.cellCells();
|
||||
|
||||
forAll (points, toI)
|
||||
{
|
||||
// pick up target position
|
||||
const vector& p = points[toI];
|
||||
|
||||
// set the sqr-distance
|
||||
scalar distSqr = magSqr(p - centresFrom[curCell]);
|
||||
|
||||
bool closer;
|
||||
|
||||
do
|
||||
{
|
||||
closer = false;
|
||||
|
||||
// set the current list of neighbouring cells
|
||||
const labelList& neighbours = cc[curCell];
|
||||
|
||||
forAll (neighbours, nI)
|
||||
{
|
||||
scalar curDistSqr =
|
||||
magSqr(p - centresFrom[neighbours[nI]]);
|
||||
|
||||
// search through all the neighbours.
|
||||
// If the cell is closer, reset current cell and distance
|
||||
if (curDistSqr < (1 - SMALL)*distSqr)
|
||||
{
|
||||
curCell = neighbours[nI];
|
||||
distSqr = curDistSqr;
|
||||
closer = true; // a closer neighbour has been found
|
||||
}
|
||||
}
|
||||
} while (closer);
|
||||
|
||||
cellAddressing_[toI] = -1;
|
||||
|
||||
// Check point is actually in the nearest cell
|
||||
if (fromMesh.pointInCell(p, curCell))
|
||||
{
|
||||
cellAddressing_[toI] = curCell;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If curCell is a boundary cell then the point maybe either outside
|
||||
// the domain or in an other region of the doamin, either way use
|
||||
// the octree search to find it.
|
||||
if (boundaryCell[curCell])
|
||||
{
|
||||
cellAddressing_[toI] = oc.find(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not on the boundary search the neighbours
|
||||
bool found = false;
|
||||
|
||||
// set the current list of neighbouring cells
|
||||
const labelList& neighbours = cc[curCell];
|
||||
|
||||
forAll (neighbours, nI)
|
||||
{
|
||||
// search through all the neighbours.
|
||||
// If point is in neighbour reset current cell
|
||||
if (fromMesh.pointInCell(p, neighbours[nI]))
|
||||
{
|
||||
cellAddressing_[toI] = neighbours[nI];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
// If still not found search the neighbour-neighbours
|
||||
|
||||
// set the current list of neighbouring cells
|
||||
const labelList& neighbours = cc[curCell];
|
||||
|
||||
forAll (neighbours, nI)
|
||||
{
|
||||
// set the current list of neighbour-neighbouring cells
|
||||
const labelList& nn = cc[neighbours[nI]];
|
||||
|
||||
forAll (nn, nI)
|
||||
{
|
||||
// search through all the neighbours.
|
||||
// If point is in neighbour reset current cell
|
||||
if (fromMesh.pointInCell(p, nn[nI]))
|
||||
{
|
||||
cellAddressing_[toI] = nn[nI];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
// Still not found so us the octree
|
||||
cellAddressing_[toI] = oc.find(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "meshToMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void meshToMesh::calculateInverseDistanceWeights() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "meshToMesh::calculateInverseDistanceWeights() : "
|
||||
<< "calculating inverse distance weighting factors" << endl;
|
||||
}
|
||||
|
||||
if (inverseDistanceWeightsPtr_)
|
||||
{
|
||||
FatalErrorIn("meshToMesh::calculateInverseDistanceWeights()")
|
||||
<< "weighting factors already calculated"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
inverseDistanceWeightsPtr_ = new scalarListList(toMesh_.nCells());
|
||||
scalarListList& invDistCoeffs = *inverseDistanceWeightsPtr_;
|
||||
|
||||
// get reference to source mesh data
|
||||
const labelListList& cc = fromMesh_.cellCells();
|
||||
const vectorField& centreFrom = fromMesh_.C().internalField();
|
||||
const vectorField& centreTo = toMesh_.C().internalField();
|
||||
|
||||
forAll (cellAddressing_, celli)
|
||||
{
|
||||
if (cellAddressing_[celli] != -1)
|
||||
{
|
||||
const vector& target = centreTo[celli];
|
||||
scalar m = mag(target - centreFrom[cellAddressing_[celli]]);
|
||||
|
||||
const labelList& neighbours = cc[cellAddressing_[celli]];
|
||||
|
||||
// if the nearest cell is a boundary cell or there is a direct hit,
|
||||
// pick up the value
|
||||
if
|
||||
(
|
||||
m < directHitTol // Direct hit
|
||||
|| neighbours.size() == 0
|
||||
)
|
||||
{
|
||||
invDistCoeffs[celli].setSize(1);
|
||||
invDistCoeffs[celli][0] = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
invDistCoeffs[celli].setSize(neighbours.size() + 1);
|
||||
|
||||
// The first coefficient corresponds to the centre cell.
|
||||
// The rest is ordered in the same way as the cellCells list.
|
||||
scalar invDist = 1.0/m;
|
||||
invDistCoeffs[celli][0] = invDist;
|
||||
scalar sumInvDist = invDist;
|
||||
|
||||
// now add the neighbours
|
||||
forAll (neighbours, ni)
|
||||
{
|
||||
invDist = 1.0/mag(target - centreFrom[neighbours[ni]]);
|
||||
invDistCoeffs[celli][ni + 1] = invDist;
|
||||
sumInvDist += invDist;
|
||||
}
|
||||
|
||||
// divide by the total inverse-distance
|
||||
forAll (invDistCoeffs[celli], i)
|
||||
{
|
||||
invDistCoeffs[celli][i] /= sumInvDist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const scalarListList& meshToMesh::inverseDistanceWeights() const
|
||||
{
|
||||
if (!inverseDistanceWeightsPtr_)
|
||||
{
|
||||
calculateInverseDistanceWeights();
|
||||
}
|
||||
|
||||
return *inverseDistanceWeightsPtr_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
216
src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.C
Normal file
216
src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.C
Normal file
@ -0,0 +1,216 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "meshToMesh.H"
|
||||
#include "processorFvPatch.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(meshToMesh, 0);
|
||||
|
||||
const scalar meshToMesh::directHitTol = 1e-5;
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
meshToMesh::meshToMesh
|
||||
(
|
||||
const fvMesh& meshFrom,
|
||||
const fvMesh& meshTo,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatchNames
|
||||
)
|
||||
:
|
||||
fromMesh_(meshFrom),
|
||||
toMesh_(meshTo),
|
||||
patchMap_(patchMap),
|
||||
fromPointMesh_(meshFrom),
|
||||
cellAddressing_(toMesh_.nCells()),
|
||||
boundaryAddressing_(toMesh_.boundaryMesh().size()),
|
||||
inverseDistanceWeightsPtr_(NULL)
|
||||
{
|
||||
forAll (fromMesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
fromMeshPatches_.insert
|
||||
(
|
||||
fromMesh_.boundaryMesh()[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
}
|
||||
|
||||
forAll (toMesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
toMeshPatches_.insert
|
||||
(
|
||||
toMesh_.boundaryMesh()[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
}
|
||||
|
||||
forAll (cuttingPatchNames, i)
|
||||
{
|
||||
if (toMeshPatches_.found(cuttingPatchNames[i]))
|
||||
{
|
||||
cuttingPatches_.insert
|
||||
(
|
||||
cuttingPatchNames[i],
|
||||
toMeshPatches_.find(cuttingPatchNames[i])()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"meshToMesh::meshToMesh"
|
||||
"(const fvMesh& meshFrom, const fvMesh& meshTo,"
|
||||
"const HashTable<word>& patchMap,"
|
||||
"const wordList& cuttingPatchNames)"
|
||||
) << "Cannot find cutting-patch " << cuttingPatchNames[i]
|
||||
<< " in destination mesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
forAll (toMesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
// Add the processor patches in the toMesh to the cuttingPatches list
|
||||
if (toMesh_.boundaryMesh()[patchi].type() == processorFvPatch::typeName)
|
||||
{
|
||||
cuttingPatches_.insert
|
||||
(
|
||||
toMesh_.boundaryMesh()[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
calcAddressing();
|
||||
}
|
||||
|
||||
|
||||
meshToMesh::meshToMesh
|
||||
(
|
||||
const fvMesh& meshFrom,
|
||||
const fvMesh& meshTo
|
||||
)
|
||||
:
|
||||
fromMesh_(meshFrom),
|
||||
toMesh_(meshTo),
|
||||
fromPointMesh_(meshFrom),
|
||||
cellAddressing_(toMesh_.nCells()),
|
||||
boundaryAddressing_(toMesh_.boundaryMesh().size()),
|
||||
inverseDistanceWeightsPtr_(NULL)
|
||||
{
|
||||
// check whether both meshes have got the same number
|
||||
// of boundary patches
|
||||
if (fromMesh_.boundary().size() != toMesh_.boundary().size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::meshToMesh"
|
||||
"(const fvMesh& meshFrom, const fvMesh& meshTo)"
|
||||
) << "Incompatible meshes: different number of patches, "
|
||||
<< "fromMesh = " << fromMesh_.boundary().size()
|
||||
<< ", toMesh = " << toMesh_.boundary().size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
forAll (fromMesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
if
|
||||
(
|
||||
fromMesh_.boundaryMesh()[patchi].name()
|
||||
!= toMesh_.boundaryMesh()[patchi].name()
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::meshToMesh"
|
||||
"(const fvMesh& meshFrom, const fvMesh& meshTo)"
|
||||
) << "Incompatible meshes: different patch names for patch "
|
||||
<< patchi
|
||||
<< ", fromMesh = " << fromMesh_.boundary()[patchi].name()
|
||||
<< ", toMesh = " << toMesh_.boundary()[patchi].name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
fromMesh_.boundaryMesh()[patchi].type()
|
||||
!= toMesh_.boundaryMesh()[patchi].type()
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::meshToMesh"
|
||||
"(const fvMesh& meshFrom, const fvMesh& meshTo)"
|
||||
) << "Incompatible meshes: different patch types for patch "
|
||||
<< patchi
|
||||
<< ", fromMesh = " << fromMesh_.boundary()[patchi].type()
|
||||
<< ", toMesh = " << toMesh_.boundary()[patchi].type()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
fromMeshPatches_.insert
|
||||
(
|
||||
fromMesh_.boundaryMesh()[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
|
||||
toMeshPatches_.insert
|
||||
(
|
||||
toMesh_.boundaryMesh()[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
|
||||
patchMap_.insert
|
||||
(
|
||||
toMesh_.boundaryMesh()[patchi].name(),
|
||||
fromMesh_.boundaryMesh()[patchi].name()
|
||||
);
|
||||
}
|
||||
|
||||
calcAddressing();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
meshToMesh::~meshToMesh()
|
||||
{
|
||||
deleteDemandDrivenData(inverseDistanceWeightsPtr_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
325
src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H
Normal file
325
src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H
Normal file
@ -0,0 +1,325 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::meshToMesh
|
||||
|
||||
Description
|
||||
mesh to mesh interpolation class.
|
||||
|
||||
SourceFiles
|
||||
meshToMesh.C
|
||||
calculateMeshToMeshAddressing.C
|
||||
calculateMeshToMeshWeights.C
|
||||
meshToMeshInterpolate.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef meshtoMesh_H
|
||||
#define meshtoMesh_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "pointMesh.H"
|
||||
#include "HashTable.H"
|
||||
#include "fvPatchMapper.H"
|
||||
#include "scalarList.H"
|
||||
#include "className.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
class octree;
|
||||
|
||||
class octreeDataCell;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class meshToMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class meshToMesh
|
||||
{
|
||||
// Private data
|
||||
|
||||
// mesh references
|
||||
|
||||
const fvMesh& fromMesh_;
|
||||
const fvMesh& toMesh_;
|
||||
|
||||
//- fromMesh patch labels
|
||||
HashTable<label> fromMeshPatches_;
|
||||
|
||||
//- toMesh patch labels
|
||||
HashTable<label> toMeshPatches_;
|
||||
|
||||
//- Patch map
|
||||
HashTable<word> patchMap_;
|
||||
|
||||
//- toMesh patch labels which cut the from-mesh
|
||||
HashTable<label> cuttingPatches_;
|
||||
|
||||
//- Point mesh used for interpolation
|
||||
pointMesh fromPointMesh_;
|
||||
|
||||
//- Cell addressing
|
||||
labelList cellAddressing_;
|
||||
|
||||
//- Boundary addressing
|
||||
labelListList boundaryAddressing_;
|
||||
|
||||
//- Inverse-distance interpolation weights
|
||||
mutable scalarListList* inverseDistanceWeightsPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void calcAddressing();
|
||||
|
||||
void cellAddresses
|
||||
(
|
||||
labelList& cells,
|
||||
const pointField& points,
|
||||
const fvMesh& fromMesh,
|
||||
const List<bool>& boundaryCell,
|
||||
const octree<octreeDataCell>& oc
|
||||
) const;
|
||||
|
||||
void calculateInverseDistanceWeights() const;
|
||||
|
||||
const scalarListList& inverseDistanceWeights() const;
|
||||
|
||||
|
||||
// Private static data members
|
||||
|
||||
//- Direct hit tolerance
|
||||
static const scalar directHitTol;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
ClassName("meshToMesh");
|
||||
|
||||
|
||||
//- Enumeration specifying required accuracy
|
||||
enum order
|
||||
{
|
||||
MAP,
|
||||
INTERPOLATE,
|
||||
CELL_POINT_INTERPOLATE
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from the two meshes, the patch name map for the patches
|
||||
// to be interpolated and the names of the toMesh-patches which
|
||||
// cut the fromMesh
|
||||
meshToMesh
|
||||
(
|
||||
const fvMesh& fromMesh,
|
||||
const fvMesh& toMesh,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatchNames
|
||||
);
|
||||
|
||||
//- Construct from the two meshes assuming there is an exact mapping
|
||||
// between the patches
|
||||
meshToMesh
|
||||
(
|
||||
const fvMesh& fromMesh,
|
||||
const fvMesh& toMesh
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~meshToMesh();
|
||||
|
||||
|
||||
//- Patch-field interpolation class
|
||||
class patchFieldInterpolator
|
||||
:
|
||||
public fvPatchFieldMapper
|
||||
{
|
||||
const labelList& directAddressing_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given addressing
|
||||
patchFieldInterpolator(const labelList& addr)
|
||||
:
|
||||
directAddressing_(addr)
|
||||
{}
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~patchFieldInterpolator()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
label size() const
|
||||
{
|
||||
return directAddressing_.size();
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const labelList& directAddressing() const
|
||||
{
|
||||
return directAddressing_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const fvMesh& fromMesh() const
|
||||
{
|
||||
return fromMesh_;
|
||||
}
|
||||
|
||||
const fvMesh& toMesh() const
|
||||
{
|
||||
return toMesh_;
|
||||
}
|
||||
|
||||
//- From toMesh cells to fromMesh cells
|
||||
const labelList& cellAddressing() const
|
||||
{
|
||||
return cellAddressing_;
|
||||
}
|
||||
|
||||
// Interpolation
|
||||
|
||||
//- Map field
|
||||
template<class Type>
|
||||
void mapField
|
||||
(
|
||||
Field<Type>&,
|
||||
const Field<Type>&,
|
||||
const labelList& adr
|
||||
) const;
|
||||
|
||||
//- Interpolate field using inverse-distance weights
|
||||
template<class Type>
|
||||
void interpolateField
|
||||
(
|
||||
Field<Type>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const labelList& adr,
|
||||
const scalarListList& weights
|
||||
) const;
|
||||
|
||||
//- Interpolate field using cell-point interpolation
|
||||
template<class Type>
|
||||
void interpolateField
|
||||
(
|
||||
Field<Type>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const labelList& adr,
|
||||
const vectorField& centres
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate internal volume field
|
||||
template<class Type>
|
||||
void interpolateInternalField
|
||||
(
|
||||
Field<Type>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
order=INTERPOLATE
|
||||
) const;
|
||||
|
||||
template<class Type>
|
||||
void interpolateInternalField
|
||||
(
|
||||
Field<Type>&,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||
order=INTERPOLATE
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field
|
||||
template<class Type>
|
||||
void interpolate
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
order=INTERPOLATE
|
||||
) const;
|
||||
|
||||
template<class Type>
|
||||
void interpolate
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||
order=INTERPOLATE
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
order=INTERPOLATE
|
||||
) const;
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
|
||||
(
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||
order=INTERPOLATE
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "meshToMeshInterpolate.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,415 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "meshToMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
#include "SubField.H"
|
||||
#include "mixedFvPatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::mapField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const Field<Type>& fromVf,
|
||||
const labelList& adr
|
||||
) const
|
||||
{
|
||||
// Direct mapping of nearest-cell values
|
||||
|
||||
forAll(toF, celli)
|
||||
{
|
||||
if (adr[celli] != -1)
|
||||
{
|
||||
toF[celli] = fromVf[adr[celli]];
|
||||
}
|
||||
}
|
||||
|
||||
//toF.map(fromVf, adr);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
const labelList& adr,
|
||||
const scalarListList& weights
|
||||
) const
|
||||
{
|
||||
// Inverse distance weighted interpolation
|
||||
|
||||
// get reference to cellCells
|
||||
const labelListList& cc = fromMesh_.cellCells();
|
||||
|
||||
forAll (toF, celli)
|
||||
{
|
||||
if (adr[celli] != -1)
|
||||
{
|
||||
const labelList& neighbours = cc[adr[celli]];
|
||||
const scalarList& w = weights[celli];
|
||||
|
||||
toF[celli] = fromVf[adr[celli]]*w[0];
|
||||
|
||||
for (label ni = 1; ni < w.size(); ni++)
|
||||
{
|
||||
toF[celli] += fromVf[neighbours[ni - 1]]*w[ni];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
const labelList& adr,
|
||||
const vectorField& centres
|
||||
) const
|
||||
{
|
||||
// Cell-Point interpolation
|
||||
volPointInterpolation vpi(fromMesh_, fromPointMesh_);
|
||||
|
||||
interpolationCellPoint<Type> interpolator
|
||||
(
|
||||
vpi,
|
||||
fromVf
|
||||
);
|
||||
|
||||
forAll (toF, celli)
|
||||
{
|
||||
if (adr[celli] != -1)
|
||||
{
|
||||
toF[celli] = interpolator.interpolate
|
||||
(
|
||||
centres[celli],
|
||||
adr[celli]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateInternalField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
meshToMesh::order ord
|
||||
) const
|
||||
{
|
||||
if (fromVf.mesh() != fromMesh_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::interpolateInternalField(Field<Type>& toF, "
|
||||
"const GeometricField<Type, fvPatchField, volMesh>& fromVf, "
|
||||
"meshToMesh::order ord) const"
|
||||
) << "the argument field does not correspond to the right mesh. "
|
||||
<< "Field size: " << fromVf.size()
|
||||
<< " mesh size: " << fromMesh_.nCells()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (toF.size() != toMesh_.nCells())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::interpolateInternalField(Field<Type>& toF, "
|
||||
"const GeometricField<Type, fvPatchField, volMesh>& fromVf, "
|
||||
"meshToMesh::order ord) const"
|
||||
) << "the argument field does not correspond to the right mesh. "
|
||||
<< "Field size: " << toF.size()
|
||||
<< " mesh size: " << toMesh_.nCells()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
switch(ord)
|
||||
{
|
||||
case MAP:
|
||||
mapField(toF, fromVf, cellAddressing_);
|
||||
break;
|
||||
|
||||
case INTERPOLATE:
|
||||
interpolateField
|
||||
(
|
||||
toF,
|
||||
fromVf,
|
||||
cellAddressing_,
|
||||
inverseDistanceWeights()
|
||||
);
|
||||
break;
|
||||
|
||||
case CELL_POINT_INTERPOLATE:
|
||||
interpolateField
|
||||
(
|
||||
toF,
|
||||
fromVf,
|
||||
cellAddressing_,
|
||||
toMesh_.cellCentres()
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::interpolateInternalField(Field<Type>& toF, "
|
||||
"const GeometricField<Type, fvPatchField, volMesh>& fromVf, "
|
||||
"meshToMesh::order ord) const"
|
||||
) << "unknown interpolation scheme " << ord
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolateInternalField
|
||||
(
|
||||
Field<Type>& toF,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
|
||||
meshToMesh::order ord
|
||||
) const
|
||||
{
|
||||
interpolateInternalField(toF, tfromVf(), ord);
|
||||
tfromVf.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolate
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& toVf,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
meshToMesh::order ord
|
||||
) const
|
||||
{
|
||||
interpolateInternalField(toVf, fromVf, ord);
|
||||
|
||||
forAll (toMesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
const fvPatch& toPatch = toMesh_.boundary()[patchi];
|
||||
|
||||
if (cuttingPatches_.found(toPatch.name()))
|
||||
{
|
||||
switch(ord)
|
||||
{
|
||||
case MAP:
|
||||
mapField
|
||||
(
|
||||
toVf.boundaryField()[patchi],
|
||||
fromVf,
|
||||
boundaryAddressing_[patchi]
|
||||
);
|
||||
break;
|
||||
|
||||
case INTERPOLATE:
|
||||
interpolateField
|
||||
(
|
||||
toVf.boundaryField()[patchi],
|
||||
fromVf,
|
||||
boundaryAddressing_[patchi],
|
||||
toPatch.Cf()
|
||||
);
|
||||
break;
|
||||
|
||||
case CELL_POINT_INTERPOLATE:
|
||||
interpolateField
|
||||
(
|
||||
toVf.boundaryField()[patchi],
|
||||
fromVf,
|
||||
boundaryAddressing_[patchi],
|
||||
toPatch.Cf()
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::interpolate("
|
||||
"GeometricField<Type, fvPatchField, volMesh>& toVf, "
|
||||
"const GeometricField<Type, fvPatchField, volMesh>& "
|
||||
"fromVf, meshToMesh::order ord) const"
|
||||
) << "unknown interpolation scheme " << ord
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (isA<mixedFvPatchField<Type> >(toVf.boundaryField()[patchi]))
|
||||
{
|
||||
refCast<mixedFvPatchField<Type> >
|
||||
(
|
||||
toVf.boundaryField()[patchi]
|
||||
).refValue() = toVf.boundaryField()[patchi];
|
||||
}
|
||||
}
|
||||
else if
|
||||
(
|
||||
patchMap_.found(toPatch.name())
|
||||
&& fromMeshPatches_.found(patchMap_.find(toPatch.name())())
|
||||
)
|
||||
{
|
||||
/*
|
||||
toVf.boundaryField()[patchi].map
|
||||
(
|
||||
fromVf.boundaryField()
|
||||
[
|
||||
fromMeshPatches_.find(patchMap_.find(toPatch.name())())()
|
||||
],
|
||||
boundaryAddressing_[patchi]
|
||||
);
|
||||
*/
|
||||
|
||||
mapField
|
||||
(
|
||||
toVf.boundaryField()[patchi],
|
||||
fromVf.boundaryField()
|
||||
[
|
||||
fromMeshPatches_.find(patchMap_.find(toPatch.name())())()
|
||||
],
|
||||
boundaryAddressing_[patchi]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void meshToMesh::interpolate
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& toVf,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
|
||||
meshToMesh::order ord
|
||||
) const
|
||||
{
|
||||
interpolate(toVf, tfromVf(), ord);
|
||||
tfromVf.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
|
||||
meshToMesh::order ord
|
||||
) const
|
||||
{
|
||||
// Create and map the internal-field values
|
||||
Field<Type> internalField(toMesh_.nCells());
|
||||
interpolateInternalField(internalField, fromVf, ord);
|
||||
|
||||
// check whether both meshes have got the same number
|
||||
// of boundary patches
|
||||
if (fromMesh_.boundary().size() != toMesh_.boundary().size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"meshToMesh::interpolate"
|
||||
"(const GeometricField<Type, fvPatchField, volMesh>& fromVf,"
|
||||
"meshToMesh::order ord) const"
|
||||
) << "Incompatible meshes: different number of boundaries, "
|
||||
"only internal field may be interpolated"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Create and map the patch field values
|
||||
PtrList<fvPatchField<Type> > patchFields
|
||||
(
|
||||
boundaryAddressing_.size()
|
||||
);
|
||||
|
||||
forAll (boundaryAddressing_, patchI)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchI,
|
||||
fvPatchField<Type>::New
|
||||
(
|
||||
fromVf.boundaryField()[patchI],
|
||||
toMesh_.boundary()[patchI],
|
||||
DimensionedField<Type, volMesh>::null(),
|
||||
patchFieldInterpolator
|
||||
(
|
||||
boundaryAddressing_[patchI]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Create the complete field from the pieces
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > ttoF
|
||||
(
|
||||
new GeometricField<Type, fvPatchField, volMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"interpolated(" + fromVf.name() + ')',
|
||||
toMesh_.time().timeName(),
|
||||
toMesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
toMesh_,
|
||||
fromVf.dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
);
|
||||
|
||||
return ttoF;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > meshToMesh::interpolate
|
||||
(
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfromVf,
|
||||
meshToMesh::order ord
|
||||
) const
|
||||
{
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > tint =
|
||||
interpolate(tfromVf(), ord);
|
||||
tfromVf.clear();
|
||||
|
||||
return tint;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
86
src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C
Normal file
86
src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.C
Normal file
@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "IOOutputFilter.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const fileName& dictName,
|
||||
const bool readFromFiles
|
||||
)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dictName,
|
||||
obr.time().system(),
|
||||
obr,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
OutputFilter(name(), obr, *this, readFromFiles)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::IOOutputFilter<OutputFilter>::~IOOutputFilter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::IOOutputFilter<OutputFilter>::read()
|
||||
{
|
||||
if (regIOobject::read())
|
||||
{
|
||||
OutputFilter::read(*this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::IOOutputFilter<OutputFilter>::write()
|
||||
{
|
||||
OutputFilter::write();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
131
src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H
Normal file
131
src/sampling/outputFilters/IOOutputFilter/IOOutputFilter.H
Normal file
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::IOOutputFilter
|
||||
|
||||
Description
|
||||
IOdictionary wrapper around OutputFilter to allow them to read from
|
||||
their associated dictionaries.
|
||||
|
||||
SourceFiles
|
||||
IOOutputFilter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOOutputFilter_H
|
||||
#define IOOutputFilter_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "pointFieldFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class probes Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class OutputFilter>
|
||||
class IOOutputFilter
|
||||
:
|
||||
public IOdictionary,
|
||||
public OutputFilter
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
IOOutputFilter(const IOOutputFilter&);
|
||||
void operator=(const IOOutputFilter&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary
|
||||
// allow the possibility to load fields from files
|
||||
IOOutputFilter
|
||||
(
|
||||
const objectRegistry&,
|
||||
const fileName& dictName = OutputFilter::typeName() + "Dict",
|
||||
const bool loadFromFile = false
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~IOOutputFilter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name
|
||||
virtual const word& name() const
|
||||
{
|
||||
return IOdictionary::name();
|
||||
}
|
||||
|
||||
//- Read the probes
|
||||
virtual bool read();
|
||||
|
||||
//- Sample and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
void updateMesh(const mapPolyMesh& mpm)
|
||||
{
|
||||
read();
|
||||
OutputFilter::updateMesh(mpm);
|
||||
}
|
||||
|
||||
//- Update for changes of mesh
|
||||
void movePoints(const pointField& points)
|
||||
{
|
||||
read();
|
||||
OutputFilter::movePoints(points);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "IOOutputFilter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "OutputFilterFunctionObject.H"
|
||||
#include "IOOutputFilter.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Private Members * * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
|
||||
{
|
||||
if (dict_.found("region"))
|
||||
{
|
||||
dict_.lookup("region") >> regionName_;
|
||||
}
|
||||
|
||||
if (dict_.found("dictionary"))
|
||||
{
|
||||
dict_.lookup("dictionary") >> dictName_;
|
||||
}
|
||||
|
||||
if (dict_.found("interval"))
|
||||
{
|
||||
dict_.lookup("interval") >> interval_;
|
||||
}
|
||||
|
||||
if (dict_.found("enabled"))
|
||||
{
|
||||
dict_.lookup("enabled") >> execution_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& t,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(),
|
||||
name_(name),
|
||||
time_(t),
|
||||
dict_(dict),
|
||||
regionName_(polyMesh::defaultRegion),
|
||||
dictName_(),
|
||||
interval_(0),
|
||||
execution_(true)
|
||||
{
|
||||
readDict();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
|
||||
{
|
||||
readDict();
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
if (dictName_.size())
|
||||
{
|
||||
ptr_.reset
|
||||
(
|
||||
new IOOutputFilter<OutputFilter>
|
||||
(
|
||||
time_.lookupObject<objectRegistry>(regionName_),
|
||||
dictName_
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_.reset
|
||||
(
|
||||
new OutputFilter
|
||||
(
|
||||
name_,
|
||||
time_.lookupObject<objectRegistry>(regionName_),
|
||||
dict_
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::execute()
|
||||
{
|
||||
if (execution_ && (interval_ <= 1 || !(time_.timeIndex() % interval_)) )
|
||||
{
|
||||
ptr_->write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::on()
|
||||
{
|
||||
execution_ = true;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::off()
|
||||
{
|
||||
execution_ = false;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (dict != dict_)
|
||||
{
|
||||
dict_ = dict;
|
||||
return start();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,143 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::OutputFilterFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around OutputFilter to allow them to be created
|
||||
via the functions list within controlDict.
|
||||
|
||||
SourceFiles
|
||||
OutputFilterFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef OutputFilterFunctionObject_H
|
||||
#define OutputFilterFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OutputFilterFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class OutputFilter>
|
||||
class OutputFilterFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
word name_;
|
||||
const Time& time_;
|
||||
dictionary dict_;
|
||||
word regionName_;
|
||||
word dictName_;
|
||||
|
||||
//- 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<OutputFilter> ptr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read relevant dictionary entries
|
||||
void readDict();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OutputFilterFunctionObject(const OutputFilterFunctionObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const OutputFilterFunctionObject&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName(OutputFilter::typeName_());
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
OutputFilterFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- start is called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- execute is called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Switch the function object on
|
||||
virtual void on();
|
||||
|
||||
//- Switch the function object off
|
||||
virtual void off();
|
||||
|
||||
//- Read and set the function object if its data has changed
|
||||
virtual bool read(const dictionary& dict);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "OutputFilterFunctionObject.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
50
src/sampling/probes/IOprobes.H
Normal file
50
src/sampling/probes/IOprobes.H
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
IOprobes
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for probes.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOprobes_H
|
||||
#define IOprobes_H
|
||||
|
||||
#include "probes.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<probes> IOprobes;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
318
src/sampling/probes/probes.C
Normal file
318
src/sampling/probes/probes.C
Normal file
@ -0,0 +1,318 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "probes.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(probes, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::probes::findCells(const fvMesh& mesh)
|
||||
{
|
||||
if (cellList_.size() == 0)
|
||||
{
|
||||
cellList_.setSize(probeLocations_.size());
|
||||
|
||||
forAll(probeLocations_, probeI)
|
||||
{
|
||||
cellList_[probeI] = mesh.findCell(probeLocations_[probeI]);
|
||||
|
||||
if (debug && cellList_[probeI] != -1)
|
||||
{
|
||||
Pout<< "probes : found point " << probeLocations_[probeI]
|
||||
<< " in cell " << cellList_[probeI] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if all probes have been found.
|
||||
forAll(cellList_, probeI)
|
||||
{
|
||||
label cellI = cellList_[probeI];
|
||||
|
||||
// Check at least one processor with cell.
|
||||
reduce(cellI, maxOp<label>());
|
||||
|
||||
if (cellI == -1)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
WarningIn("probes::read()")
|
||||
<< "Did not find location " << probeLocations_[probeI]
|
||||
<< " in any cell. Skipping location." << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure location not on two domains.
|
||||
if (cellList_[probeI] != -1 && cellList_[probeI] != cellI)
|
||||
{
|
||||
WarningIn("probes::read()")
|
||||
<< "Location " << probeLocations_[probeI]
|
||||
<< " seems to be on multiple domains:"
|
||||
<< " cell " << cellList_[probeI]
|
||||
<< " on my domain " << Pstream::myProcNo()
|
||||
<< " and cell " << cellI << " on some other domain."
|
||||
<< endl
|
||||
<< "This might happen if the probe location is on"
|
||||
<< " a processor patch. Change the location slightly"
|
||||
<< " to prevent this." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::probes::checkFieldTypes()
|
||||
{
|
||||
wordList fieldTypes(fieldNames_.size());
|
||||
|
||||
// check files for a particular time
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
forAll(fieldNames_, fieldI)
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
fieldNames_[fieldI],
|
||||
obr_.time().timeName(),
|
||||
refCast<const polyMesh>(obr_),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (io.headerOk())
|
||||
{
|
||||
fieldTypes[fieldI] = io.headerClassName();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldTypes[fieldI] = "(notFound)";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// check objectRegistry
|
||||
forAll(fieldNames_, fieldI)
|
||||
{
|
||||
objectRegistry::const_iterator iter =
|
||||
obr_.find(fieldNames_[fieldI]);
|
||||
|
||||
if (iter != obr_.end())
|
||||
{
|
||||
fieldTypes[fieldI] = iter()->type();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldTypes[fieldI] = "(notFound)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
label nFields = 0;
|
||||
|
||||
// classify fieldTypes
|
||||
nFields += countFields(scalarFields_, fieldTypes);
|
||||
nFields += countFields(vectorFields_, fieldTypes);
|
||||
nFields += countFields(sphericalTensorFields_, fieldTypes);
|
||||
nFields += countFields(symmTensorFields_, fieldTypes);
|
||||
nFields += countFields(tensorFields_, fieldTypes);
|
||||
|
||||
// concatenate all the lists into foundFields
|
||||
wordList foundFields(nFields);
|
||||
|
||||
label fieldI = 0;
|
||||
forAll(scalarFields_, i)
|
||||
{
|
||||
foundFields[fieldI++] = scalarFields_[i];
|
||||
}
|
||||
forAll(vectorFields_, i)
|
||||
{
|
||||
foundFields[fieldI++] = vectorFields_[i];
|
||||
}
|
||||
forAll(sphericalTensorFields_, i)
|
||||
{
|
||||
foundFields[fieldI++] = sphericalTensorFields_[i];
|
||||
}
|
||||
forAll(symmTensorFields_, i)
|
||||
{
|
||||
foundFields[fieldI++] = symmTensorFields_[i];
|
||||
}
|
||||
forAll(tensorFields_, i)
|
||||
{
|
||||
foundFields[fieldI++] = tensorFields_[i];
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName probeDir;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case
|
||||
// (Note: gives problems for distributed data running)
|
||||
probeDir = obr_.time().path()/".."/name_/obr_.time().timeName();
|
||||
}
|
||||
else
|
||||
{
|
||||
probeDir = obr_.time().path()/name_/obr_.time().timeName();
|
||||
}
|
||||
|
||||
// Close the file if any fields have been removed.
|
||||
forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)
|
||||
{
|
||||
if (findIndex(foundFields, iter.key()) == -1)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "close stream: " << iter()->name() << endl;
|
||||
}
|
||||
|
||||
delete probeFilePtrs_.remove(iter);
|
||||
}
|
||||
}
|
||||
|
||||
// Open new files for new fields. Keep existing files.
|
||||
|
||||
probeFilePtrs_.resize(2*foundFields.size());
|
||||
|
||||
forAll(foundFields, fieldI)
|
||||
{
|
||||
const word& fldName = foundFields[fieldI];
|
||||
|
||||
// Check if added field. If so open a stream for it.
|
||||
|
||||
if (!probeFilePtrs_.found(fldName))
|
||||
{
|
||||
// Create directory if does not exist.
|
||||
mkDir(probeDir);
|
||||
|
||||
OFstream* sPtr = new OFstream(probeDir/fldName);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "open stream: " << sPtr->name() << endl;
|
||||
}
|
||||
|
||||
probeFilePtrs_.insert(fldName, sPtr);
|
||||
|
||||
*sPtr<< '#' << setw(IOstream::defaultPrecision() + 6)
|
||||
<< "Time";
|
||||
|
||||
forAll(probeLocations_, probeI)
|
||||
{
|
||||
*sPtr << token::SPACE << probeLocations_[probeI];
|
||||
}
|
||||
*sPtr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Probing fields:" << foundFields << nl
|
||||
<< "Probing locations:" << probeLocations_ << nl
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nFields > 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::probes::probes
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
fieldNames_(0),
|
||||
probeLocations_(0),
|
||||
scalarFields_(),
|
||||
vectorFields_(),
|
||||
sphericalTensorFields_(),
|
||||
symmTensorFields_(),
|
||||
tensorFields_(),
|
||||
cellList_(0),
|
||||
probeFilePtrs_(0)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::probes::~probes()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::probes::write()
|
||||
{
|
||||
if (probeLocations_.size() && checkFieldTypes())
|
||||
{
|
||||
sampleAndWrite(scalarFields_);
|
||||
sampleAndWrite(vectorFields_);
|
||||
sampleAndWrite(sphericalTensorFields_);
|
||||
sampleAndWrite(symmTensorFields_);
|
||||
sampleAndWrite(tensorFields_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::probes::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("fields") >> fieldNames_;
|
||||
dict.lookup("probeLocations") >> probeLocations_;
|
||||
|
||||
// Force all cell locations to be redetermined
|
||||
cellList_.clear();
|
||||
findCells(refCast<const fvMesh>(obr_));
|
||||
checkFieldTypes();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
237
src/sampling/probes/probes.H
Normal file
237
src/sampling/probes/probes.H
Normal file
@ -0,0 +1,237 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::probes
|
||||
|
||||
Description
|
||||
Set of locations to sample.
|
||||
|
||||
Call write() to sample and write files.
|
||||
|
||||
SourceFiles
|
||||
probes.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef probes_H
|
||||
#define probes_H
|
||||
|
||||
#include "HashPtrTable.H"
|
||||
#include "OFstream.H"
|
||||
#include "pointField.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class fvMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class probes Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class probes
|
||||
{
|
||||
// Private classes
|
||||
|
||||
//- Class used for grouping field types
|
||||
template<class Type>
|
||||
class fieldGroup
|
||||
:
|
||||
public wordList
|
||||
{
|
||||
public:
|
||||
//- Construct null
|
||||
fieldGroup()
|
||||
:
|
||||
wordList()
|
||||
{}
|
||||
|
||||
//- Construct for a list of field names
|
||||
fieldGroup(const wordList& fieldNames)
|
||||
:
|
||||
wordList(fieldNames)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
//- Name of this set of probes,
|
||||
// Also used as the name of the probes directory.
|
||||
word name_;
|
||||
|
||||
//- Const reference to objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Load fields from files (not from objectRegistry)
|
||||
bool loadFromFiles_;
|
||||
|
||||
|
||||
// Read from dictonary
|
||||
|
||||
//- Names of fields to probe
|
||||
wordList fieldNames_;
|
||||
|
||||
//- Locations to probe
|
||||
vectorField probeLocations_;
|
||||
|
||||
|
||||
// Calculated
|
||||
|
||||
//- Categorized scalar/vector/tensor fields
|
||||
fieldGroup<scalar> scalarFields_;
|
||||
fieldGroup<vector> vectorFields_;
|
||||
fieldGroup<sphericalTensor> sphericalTensorFields_;
|
||||
fieldGroup<symmTensor> symmTensorFields_;
|
||||
fieldGroup<tensor> tensorFields_;
|
||||
|
||||
// Cells to be probed (obtained from the locations)
|
||||
labelList cellList_;
|
||||
|
||||
//- Current open files
|
||||
HashPtrTable<OFstream> probeFilePtrs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Find cells containing probes
|
||||
void findCells(const fvMesh&);
|
||||
|
||||
//- classify field types, return true if nFields > 0
|
||||
bool checkFieldTypes();
|
||||
|
||||
//- Find the fields in the list of the given type, return count
|
||||
template<class Type>
|
||||
label countFields
|
||||
(
|
||||
fieldGroup<Type>& fieldList,
|
||||
const wordList& fieldTypes
|
||||
) const;
|
||||
|
||||
//- Sample and write a particular volume field
|
||||
template<class Type>
|
||||
void sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
);
|
||||
|
||||
//- Sample and write all the fields of the given type
|
||||
template <class Type>
|
||||
void sampleAndWrite(const fieldGroup<Type>&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
probes(const probes&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const probes&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("probes");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
probes
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~probes();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of probes
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Cells to be probed (obtained from the locations)
|
||||
const labelList& cells() const
|
||||
{
|
||||
return cellList_;
|
||||
}
|
||||
|
||||
//- Sample and write
|
||||
virtual void write();
|
||||
|
||||
//- Read the probes
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const pointField&)
|
||||
{}
|
||||
|
||||
//- Sample a volume field at all locations
|
||||
template<class Type>
|
||||
tmp<Field<Type> > sample
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
) const;
|
||||
|
||||
//- Sample a single field on all sample locations
|
||||
template <class Type>
|
||||
tmp<Field<Type> > sample(const word& fieldName) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "probesTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
38
src/sampling/probes/probesDict
Normal file
38
src/sampling/probes/probesDict
Normal file
@ -0,0 +1,38 @@
|
||||
/*-------------------------------*- C++ -*---------------------------------*\
|
||||
| ========= |
|
||||
| \\ / OpenFOAM 1.4.1 |
|
||||
| \\ / |
|
||||
| \\ / The Open Source CFD Toolbox |
|
||||
| \\/ http://www.OpenFOAM.org |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location system;
|
||||
object probesDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// Fields to be probed. runTime modifiable!
|
||||
fields
|
||||
(
|
||||
p
|
||||
);
|
||||
|
||||
// Locations to be probed. runTime modifiable!
|
||||
probeLocations
|
||||
(
|
||||
(0.0254 0.0253 0.0)
|
||||
(0.0508 0.0253 0.0)
|
||||
(0.0762 0.0253 0.0)
|
||||
(0.1016 0.0253 0.0)
|
||||
(0.1270 0.0253 0.0)
|
||||
(0.1524 0.0253 0.0)
|
||||
(0.1778 0.0253 0.0)
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
43
src/sampling/probes/probesFunctionObject.C
Normal file
43
src/sampling/probes/probesFunctionObject.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "probesFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(probesFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
probesFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
54
src/sampling/probes/probesFunctionObject.H
Normal file
54
src/sampling/probes/probesFunctionObject.H
Normal file
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
probesFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around probes to allow them to be created via the
|
||||
functions list within controlDict.
|
||||
|
||||
SourceFiles
|
||||
probesFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef probesFunctionObject_H
|
||||
#define probesFunctionObject_H
|
||||
|
||||
#include "probes.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<probes> probesFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
218
src/sampling/probes/probesTemplates.C
Normal file
218
src/sampling/probes/probesTemplates.C
Normal file
@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "probes.H"
|
||||
#include "volFields.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- comparison operator for probes class
|
||||
template<class T>
|
||||
class isNotEqOp
|
||||
{
|
||||
public:
|
||||
|
||||
void operator()(T& x, const T& y) const
|
||||
{
|
||||
const T unsetVal(-VGREAT*pTraits<T>::one);
|
||||
|
||||
if (x != unsetVal)
|
||||
{
|
||||
// Keep x.
|
||||
|
||||
// Note:chould check for y != unsetVal but multiple sample cells
|
||||
// already handled in read().
|
||||
}
|
||||
else
|
||||
{
|
||||
// x is not set. y might be.
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::probes::countFields
|
||||
(
|
||||
fieldGroup<Type>& fieldList,
|
||||
const wordList& fieldTypes
|
||||
) const
|
||||
{
|
||||
fieldList.setSize(fieldNames_.size());
|
||||
label nFields = 0;
|
||||
|
||||
forAll(fieldNames_, fieldI)
|
||||
{
|
||||
if
|
||||
(
|
||||
fieldTypes[fieldI]
|
||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
fieldList[nFields] = fieldNames_[fieldI];
|
||||
nFields++;
|
||||
}
|
||||
}
|
||||
|
||||
fieldList.setSize(nFields);
|
||||
|
||||
return nFields;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::probes::sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
)
|
||||
{
|
||||
Field<Type> values = sample(vField);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
unsigned int w = IOstream::defaultPrecision() + 7;
|
||||
OFstream& probeStream = *probeFilePtrs_[vField.name()];
|
||||
|
||||
probeStream << setw(w) << vField.time().value();
|
||||
|
||||
forAll(values, probeI)
|
||||
{
|
||||
probeStream << setw(w) << values[probeI];
|
||||
}
|
||||
probeStream << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
void Foam::probes::sampleAndWrite
|
||||
(
|
||||
const fieldGroup<Type>& fields
|
||||
)
|
||||
{
|
||||
forAll(fields, fieldI)
|
||||
{
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
sampleAndWrite
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fields[fieldI],
|
||||
obr_.time().timeName(),
|
||||
refCast<const polyMesh>(obr_),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
refCast<const fvMesh>(obr_)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
objectRegistry::const_iterator iter = obr_.find(fields[fieldI]);
|
||||
|
||||
if
|
||||
(
|
||||
iter != obr_.end()
|
||||
&& iter()->type()
|
||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
sampleAndWrite
|
||||
(
|
||||
obr_.lookupObject
|
||||
<GeometricField<Type, fvPatchField, volMesh> >
|
||||
(
|
||||
fields[fieldI]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> >
|
||||
Foam::probes::sample
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const
|
||||
{
|
||||
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
||||
|
||||
tmp<Field<Type> > tValues
|
||||
(
|
||||
new Field<Type>(probeLocations_.size(), unsetVal)
|
||||
);
|
||||
|
||||
Field<Type>& values = tValues();
|
||||
|
||||
forAll(probeLocations_, probeI)
|
||||
{
|
||||
if (cellList_[probeI] >= 0)
|
||||
{
|
||||
values[probeI] = vField[cellList_[probeI]];
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(values, isNotEqOp<Type>());
|
||||
Pstream::listCombineScatter(values);
|
||||
|
||||
return tValues;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> >
|
||||
Foam::probes::sample(const word& fieldName) const
|
||||
{
|
||||
return sample
|
||||
(
|
||||
obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
|
||||
(
|
||||
fieldName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
348
src/sampling/sampledSurface/patch/sampledPatch.C
Normal file
348
src/sampling/sampledSurface/patch/sampledPatch.C
Normal file
@ -0,0 +1,348 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sampledPatch.H"
|
||||
#include "dictionary.H"
|
||||
#include "polyMesh.H"
|
||||
#include "polyPatch.H"
|
||||
#include "volFields.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledPatch, 0);
|
||||
// addToRunTimeSelectionTable(sampledSurface, sampledPatch, word);
|
||||
addNamedToRunTimeSelectionTable(sampledSurface, sampledPatch, word, patch);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::sampledPatch::createGeometry()
|
||||
{
|
||||
clearGeom();
|
||||
points_.clear();
|
||||
faces_.clear();
|
||||
patchFaceLabels_.clear();
|
||||
|
||||
if (patchIndex() != -1)
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
|
||||
const faceList& localFaces = patch.localFaces();
|
||||
|
||||
points_ = patch.localPoints();
|
||||
|
||||
if (triangulate())
|
||||
{
|
||||
// Count triangles
|
||||
label nTri = 0;
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
const face& f = localFaces[faceI];
|
||||
|
||||
nTri += f.nTriangles(patch.localPoints());
|
||||
}
|
||||
|
||||
faces_.setSize(nTri);
|
||||
patchFaceLabels_.setSize(nTri);
|
||||
|
||||
// split and fill mesh face references
|
||||
nTri = 0;
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
const face& f = localFaces[faceI];
|
||||
|
||||
label fillIndex = nTri;
|
||||
|
||||
f.triangles(patch.localPoints(), nTri, faces_);
|
||||
while (fillIndex < nTri)
|
||||
{
|
||||
patchFaceLabels_[fillIndex++] = faceI;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
faces_ = localFaces;
|
||||
patchFaceLabels_.setSize(faces_.size());
|
||||
forAll(localFaces, i)
|
||||
{
|
||||
patchFaceLabels_[i] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Pout << *this << endl;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> >
|
||||
Foam::sampledPatch::sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const
|
||||
{
|
||||
// One value per face
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
if (patchIndex() != -1)
|
||||
{
|
||||
const Field<Type>& bField = vField.boundaryField()[patchIndex()];
|
||||
|
||||
forAll(patchFaceLabels_, elemI)
|
||||
{
|
||||
values[elemI] = bField[patchFaceLabels_[elemI]];
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> >
|
||||
Foam::sampledPatch::interpolateField
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
if (patchIndex() != -1)
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
|
||||
const labelList& own = mesh().faceOwner();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
|
||||
forAll(faces(), cutFaceI)
|
||||
{
|
||||
const face& f = faces()[cutFaceI];
|
||||
|
||||
forAll(f, faceVertI)
|
||||
{
|
||||
label pointI = f[faceVertI];
|
||||
|
||||
if (!pointDone[pointI])
|
||||
{
|
||||
label faceI = patchFaceLabels()[cutFaceI] + patch.start();
|
||||
label cellI = own[faceI];
|
||||
|
||||
values[pointI] = interpolator.interpolate
|
||||
(
|
||||
points()[pointI],
|
||||
cellI,
|
||||
faceI
|
||||
);
|
||||
pointDone[pointI] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledPatch::sampledPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const word& patchName,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
sampledSurface(mesh, name, triangulate),
|
||||
patchName_(patchName),
|
||||
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
patchFaceLabels_(0)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
Foam::sampledPatch::sampledPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampledSurface(mesh, dict),
|
||||
patchName_(dict.lookup("patchName")),
|
||||
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
patchFaceLabels_(0)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledPatch::~sampledPatch()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::sampledPatch::correct(const bool meshChanged)
|
||||
{
|
||||
if (meshChanged)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// sample volume field
|
||||
//
|
||||
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::sampledPatch::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField>
|
||||
Foam::sampledPatch::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledPatch::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField>
|
||||
Foam::sampledPatch::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField>
|
||||
Foam::sampledPatch::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// interpolate
|
||||
//
|
||||
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::sampledPatch::interpolate
|
||||
(
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField>
|
||||
Foam::sampledPatch::interpolate
|
||||
(
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledPatch::interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField>
|
||||
Foam::sampledPatch::interpolate
|
||||
(
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField>
|
||||
Foam::sampledPatch::interpolate
|
||||
(
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledPatch::print(Ostream& os) const
|
||||
{
|
||||
os << "sampledPatch: " << name() << " :"
|
||||
<< " patch:" << patchName()
|
||||
<< " faces:" << faces().size()
|
||||
<< " points:" << points().size();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
230
src/sampling/sampledSurface/patch/sampledPatch.H
Normal file
230
src/sampling/sampledSurface/patch/sampledPatch.H
Normal file
@ -0,0 +1,230 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
sampledPatch
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
sampledPatch.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampledPatch_H
|
||||
#define sampledPatch_H
|
||||
|
||||
#include "sampledSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledPatch
|
||||
:
|
||||
public sampledSurface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of patch
|
||||
const word patchName_;
|
||||
|
||||
//- Index of patch in boundaryMesh
|
||||
const label patchIndex_;
|
||||
|
||||
//- Zero size or copy of patch.localPoints()
|
||||
pointField points_;
|
||||
|
||||
//- Triangulated faces
|
||||
faceList faces_;
|
||||
|
||||
//- Local patch face labels
|
||||
labelList patchFaceLabels_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Do all to construct geometry.
|
||||
void createGeometry();
|
||||
|
||||
//- sample field on faces
|
||||
template <class Type>
|
||||
tmp<Field<Type> > sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const;
|
||||
|
||||
|
||||
template <class Type>
|
||||
tmp<Field<Type> >
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sampledPatch");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
sampledPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const word& patchName,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sampledPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~sampledPatch();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const word patchName() const
|
||||
{
|
||||
return patchName_;
|
||||
}
|
||||
|
||||
label patchIndex() const
|
||||
{
|
||||
return patchIndex_;
|
||||
}
|
||||
|
||||
const labelList& patchFaceLabels() const
|
||||
{
|
||||
return patchFaceLabels_;
|
||||
}
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
|
||||
|
||||
//- Correct for mesh movement and/or field changes
|
||||
virtual void correct(const bool meshChanged);
|
||||
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
) const;
|
||||
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
) const;
|
||||
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
) const;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
) const;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
) const;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
380
src/sampling/sampledSurface/plane/sampledPlane.C
Normal file
380
src/sampling/sampledSurface/plane/sampledPlane.C
Normal file
@ -0,0 +1,380 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sampledPlane.H"
|
||||
#include "dictionary.H"
|
||||
#include "polyMesh.H"
|
||||
#include "volFields.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledPlane, 0);
|
||||
addNamedToRunTimeSelectionTable(sampledSurface, sampledPlane, word, plane);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::sampledPlane::createGeometry()
|
||||
{
|
||||
clearGeom();
|
||||
faces_.clear();
|
||||
meshCells_.clear();
|
||||
|
||||
if (triangulate())
|
||||
{
|
||||
// Count triangles
|
||||
label nTri = 0;
|
||||
forAll(cuttingPlane::faces(), faceI)
|
||||
{
|
||||
const face& f = cuttingPlane::faces()[faceI];
|
||||
|
||||
nTri += f.nTriangles(points());
|
||||
}
|
||||
|
||||
faces_.setSize(nTri);
|
||||
meshCells_.setSize(nTri);
|
||||
|
||||
// split and fill mesh cell references
|
||||
nTri = 0;
|
||||
forAll(cuttingPlane::faces(), faceI)
|
||||
{
|
||||
const face& f = cuttingPlane::faces()[faceI];
|
||||
label cellId = cuttingPlane::cells()[faceI];
|
||||
|
||||
label fillIndex = nTri;
|
||||
|
||||
f.triangles(points(), nTri, faces_);
|
||||
while (fillIndex < nTri)
|
||||
{
|
||||
meshCells_[fillIndex++] = cellId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(Pout);
|
||||
Pout << endl;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> >
|
||||
Foam::sampledPlane::sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type> >(new Field<Type>(vField, meshCells()));
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> >
|
||||
Foam::sampledPlane::interpolateField
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per point
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
|
||||
forAll(faces(), cutFaceI)
|
||||
{
|
||||
const face& f = faces()[cutFaceI];
|
||||
|
||||
forAll(f, faceVertI)
|
||||
{
|
||||
label pointI = f[faceVertI];
|
||||
|
||||
if (!pointDone[pointI])
|
||||
{
|
||||
values[pointI] = interpolator.interpolate
|
||||
(
|
||||
points()[pointI],
|
||||
meshCells()[cutFaceI]
|
||||
);
|
||||
pointDone[pointI] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledPlane::sampledPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const plane& planeDesc,
|
||||
const word& zoneName,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
sampledSurface(mesh, name, triangulate),
|
||||
cuttingPlane(planeDesc),
|
||||
zoneName_(zoneName),
|
||||
faces_(0),
|
||||
meshCells_(0)
|
||||
{
|
||||
label zoneId = -1;
|
||||
if (zoneName_.size())
|
||||
{
|
||||
zoneId = mesh.cellZones().findZoneID(zoneName_);
|
||||
if (zoneId < 0)
|
||||
{
|
||||
Info<< "cellZone \"" << zoneName_
|
||||
<< "\" not found - using entire mesh"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
reCut(mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
reCut(mesh, mesh.cellZones()[zoneId]);
|
||||
}
|
||||
|
||||
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
Foam::sampledPlane::sampledPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampledSurface(mesh, dict),
|
||||
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
|
||||
zoneName_(word::null),
|
||||
faces_(0),
|
||||
meshCells_(0)
|
||||
{
|
||||
|
||||
// make plane relative to the coordinateSystem (Cartesian)
|
||||
if (dict.found("coordinateSystem"))
|
||||
{
|
||||
coordinateSystem cs(dict.subDict("coordinateSystem"));
|
||||
|
||||
point base = cs.globalPosition(planeDesc().refPoint());
|
||||
vector norm = cs.globalVector(planeDesc().normal());
|
||||
|
||||
// assign the plane description
|
||||
static_cast<plane&>(*this) = plane(base, norm);
|
||||
}
|
||||
|
||||
|
||||
label zoneId = -1;
|
||||
if (dict.found("zone"))
|
||||
{
|
||||
dict.lookup("zone") >> zoneName_;
|
||||
zoneId = mesh.cellZones().findZoneID(zoneName_);
|
||||
if (zoneId < 0)
|
||||
{
|
||||
Info<< "cellZone \"" << zoneName_
|
||||
<< "\" not found - using entire mesh"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
reCut(mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
reCut(mesh, mesh.cellZones()[zoneId]);
|
||||
}
|
||||
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledPlane::~sampledPlane()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::sampledPlane::correct(const bool meshChanged)
|
||||
{
|
||||
// Only change of mesh changes plane - zone restriction gets lost
|
||||
if (meshChanged)
|
||||
{
|
||||
label zoneId = -1;
|
||||
if (zoneName_.size())
|
||||
{
|
||||
zoneId = mesh().cellZones().findZoneID(zoneName_);
|
||||
}
|
||||
|
||||
if (zoneId < 0)
|
||||
{
|
||||
reCut(mesh());
|
||||
}
|
||||
else
|
||||
{
|
||||
reCut(mesh(), mesh().cellZones()[zoneId]);
|
||||
}
|
||||
|
||||
createGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// sample volume field
|
||||
//
|
||||
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::sampledPlane::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField>
|
||||
Foam::sampledPlane::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledPlane::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField>
|
||||
Foam::sampledPlane::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField>
|
||||
Foam::sampledPlane::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// interpolate
|
||||
//
|
||||
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::sampledPlane::interpolate
|
||||
(
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField>
|
||||
Foam::sampledPlane::interpolate
|
||||
(
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledPlane::interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField>
|
||||
Foam::sampledPlane::interpolate
|
||||
(
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField>
|
||||
Foam::sampledPlane::interpolate
|
||||
(
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledPlane::print(Ostream& os) const
|
||||
{
|
||||
os << "sampledPlane: " << name() << " :"
|
||||
<< " base:" << refPoint()
|
||||
<< " normal:" << normal()
|
||||
<< " faces:" << faces().size()
|
||||
<< " points:" << points().size();
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
233
src/sampling/sampledSurface/plane/sampledPlane.H
Normal file
233
src/sampling/sampledSurface/plane/sampledPlane.H
Normal file
@ -0,0 +1,233 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
sampledPlane
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
sampledPlane.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampledPlane_H
|
||||
#define sampledPlane_H
|
||||
|
||||
#include "sampledSurface.H"
|
||||
#include "cuttingPlane.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledPlane Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledPlane
|
||||
:
|
||||
public sampledSurface,
|
||||
public cuttingPlane
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- zone name (if restricted to zones)
|
||||
word zoneName_;
|
||||
|
||||
//- Triangulated faces in terms of intersection points
|
||||
faceList faces_;
|
||||
|
||||
//- For every triangulated face, the original cell in mesh
|
||||
labelList meshCells_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Do all to create geometry. Triangulate as required
|
||||
void createGeometry();
|
||||
|
||||
//- sample field on faces
|
||||
template <class Type>
|
||||
tmp<Field<Type> > sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const;
|
||||
|
||||
|
||||
template <class Type>
|
||||
tmp<Field<Type> >
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sampledPlane");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
sampledPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const plane& planeDesc,
|
||||
const word& zoneName = word::null,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sampledPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~sampledPlane();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Points of surface
|
||||
const pointField& points() const
|
||||
{
|
||||
return cuttingPlane::points();
|
||||
}
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const
|
||||
{
|
||||
if (triangulate())
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cuttingPlane::faces();
|
||||
}
|
||||
}
|
||||
|
||||
//- For every face original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
if (triangulate())
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cuttingPlane::cells();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Correct for mesh movement and/or field changes
|
||||
virtual void correct(const bool meshChanged);
|
||||
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
) const;
|
||||
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
) const;
|
||||
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
) const;
|
||||
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
) const;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
) const;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
) const;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
322
src/sampling/sampledSurface/surface/sampledSurface.C
Normal file
322
src/sampling/sampledSurface/surface/sampledSurface.C
Normal file
@ -0,0 +1,322 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "sampledSurface.H"
|
||||
#include "polyMesh.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledSurface, 0);
|
||||
defineRunTimeSelectionTable(sampledSurface, word);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
void Foam::sampledSurface::clearGeom() const
|
||||
{
|
||||
deleteDemandDrivenData(SfPtr_);
|
||||
deleteDemandDrivenData(magSfPtr_);
|
||||
deleteDemandDrivenData(CfPtr_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::sampledSurface::makeSf() const
|
||||
{
|
||||
// It is an error to recalculate if the pointer is already set
|
||||
if (SfPtr_)
|
||||
{
|
||||
FatalErrorIn("Foam::sampledSurface::makeSf()")
|
||||
<< "face area vectors already exist"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const faceList& sampleFaces = faces();
|
||||
SfPtr_ = new vectorField(sampleFaces.size());
|
||||
|
||||
vectorField& values = *SfPtr_;
|
||||
|
||||
forAll(sampleFaces, faceI)
|
||||
{
|
||||
values[faceI] = sampleFaces[faceI].normal(points());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurface::makeMagSf() const
|
||||
{
|
||||
// It is an error to recalculate if the pointer is already set
|
||||
if (magSfPtr_)
|
||||
{
|
||||
FatalErrorIn("Foam::sampledSurface::makeMagSf()")
|
||||
<< "mag face areas already exist"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const faceList& sampleFaces = faces();
|
||||
magSfPtr_ = new scalarField(sampleFaces.size());
|
||||
|
||||
scalarField& values = *magSfPtr_;
|
||||
|
||||
forAll(sampleFaces, faceI)
|
||||
{
|
||||
values[faceI] = sampleFaces[faceI].mag(points());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurface::makeCf() const
|
||||
{
|
||||
// It is an error to recalculate if the pointer is already set
|
||||
if (CfPtr_)
|
||||
{
|
||||
FatalErrorIn("Foam::sampledSurface::makeCf()")
|
||||
<< "face centres already exist"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const faceList& sampleFaces = faces();
|
||||
CfPtr_ = new vectorField(sampleFaces.size());
|
||||
|
||||
vectorField& values = *CfPtr_;
|
||||
|
||||
forAll(sampleFaces, faceI)
|
||||
{
|
||||
values[faceI] = sampleFaces[faceI].centre(points());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::sampledSurface>
|
||||
Foam::sampledSurface::New
|
||||
(
|
||||
const word& sampleType,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_
|
||||
->find(sampleType);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampledSurface::New(const word&, "
|
||||
"const polyMesh&, const dictionary&)"
|
||||
) << "Unknown sample type " << sampleType
|
||||
<< endl << endl
|
||||
<< "Valid sample types : " << endl
|
||||
<< wordConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<sampledSurface>
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
mesh,
|
||||
dict
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sampledSurface::getBool
|
||||
(
|
||||
const dictionary& dict,
|
||||
const word& key,
|
||||
const bool defaultVal
|
||||
)
|
||||
{
|
||||
if (dict.found(key))
|
||||
{
|
||||
return readBool(dict.lookup(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from mesh, name
|
||||
Foam::sampledSurface::sampledSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
name_(name),
|
||||
triangulate_(triangulate),
|
||||
interpolate_(false),
|
||||
SfPtr_(NULL),
|
||||
magSfPtr_(NULL),
|
||||
CfPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::sampledSurface::sampledSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
name_(type()),
|
||||
triangulate_(getBool(dict, "triangulate", true)),
|
||||
interpolate_(getBool(dict, "interpolate", false)),
|
||||
SfPtr_(NULL),
|
||||
magSfPtr_(NULL),
|
||||
CfPtr_(NULL)
|
||||
{
|
||||
if (dict.found("name"))
|
||||
{
|
||||
dict.lookup("name") >> name_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledSurface::~sampledSurface()
|
||||
{
|
||||
clearGeom();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::vectorField& Foam::sampledSurface::Sf() const
|
||||
{
|
||||
if (!SfPtr_)
|
||||
{
|
||||
makeSf();
|
||||
}
|
||||
|
||||
return *SfPtr_;
|
||||
}
|
||||
|
||||
const Foam::scalarField& Foam::sampledSurface::magSf() const
|
||||
{
|
||||
if (!magSfPtr_)
|
||||
{
|
||||
makeMagSf();
|
||||
}
|
||||
|
||||
return *magSfPtr_;
|
||||
}
|
||||
|
||||
const Foam::vectorField& Foam::sampledSurface::Cf() const
|
||||
{
|
||||
if (!CfPtr_)
|
||||
{
|
||||
makeCf();
|
||||
}
|
||||
|
||||
return *CfPtr_;
|
||||
}
|
||||
|
||||
|
||||
// do not project scalar - just copy values
|
||||
Foam::tmp<Foam::Field<Foam::scalar> >
|
||||
Foam::sampledSurface::project(const Field<scalar>& field) const
|
||||
{
|
||||
tmp<Field<scalar> > tRes(new Field<scalar>(faces().size()));
|
||||
Field<scalar>& res = tRes();
|
||||
|
||||
forAll(faces(), faceI)
|
||||
{
|
||||
res[faceI] = field[faceI];
|
||||
}
|
||||
|
||||
return tRes;
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::scalar> >
|
||||
Foam::sampledSurface::project(const Field<vector>& field) const
|
||||
{
|
||||
tmp<Field<scalar> > tRes(new Field<scalar>(faces().size()));
|
||||
project(tRes(), field);
|
||||
return tRes;
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector> >
|
||||
Foam::sampledSurface::project(const Field<sphericalTensor>& field) const
|
||||
{
|
||||
tmp<Field<vector> > tRes(new Field<vector>(faces().size()));
|
||||
project(tRes(), field);
|
||||
return tRes;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector> >
|
||||
Foam::sampledSurface::project(const Field<symmTensor>& field) const
|
||||
{
|
||||
tmp<Field<vector> > tRes(new Field<vector>(faces().size()));
|
||||
project(tRes(), field);
|
||||
return tRes;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector> >
|
||||
Foam::sampledSurface::project(const Field<tensor>& field) const
|
||||
{
|
||||
tmp<Field<vector> > tRes(new Field<vector>(faces().size()));
|
||||
project(tRes(), field);
|
||||
return tRes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::sampledSurface::print(Ostream& os) const
|
||||
{
|
||||
os << type();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream &os, const sampledSurface& s)
|
||||
{
|
||||
s.print(os);
|
||||
os.check("Ostream& operator<<(Ostream&, const sampledSurface&");
|
||||
return os;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
396
src/sampling/sampledSurface/surface/sampledSurface.H
Normal file
396
src/sampling/sampledSurface/surface/sampledSurface.H
Normal file
@ -0,0 +1,396 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
sampledSurface
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
sampledSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampledSurface_H
|
||||
#define sampledSurface_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "word.H"
|
||||
#include "labelList.H"
|
||||
#include "faceList.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "polyMesh.H"
|
||||
#include "coordinateSystems.H"
|
||||
#include "interpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledSurface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- Name of sample surface
|
||||
word name_;
|
||||
|
||||
//- Make triangles or keep faces
|
||||
const bool triangulate_;
|
||||
|
||||
//- Do we intend to interpolate the information?
|
||||
bool interpolate_;
|
||||
|
||||
|
||||
// Demand-driven data
|
||||
|
||||
//- Face area vectors
|
||||
mutable vectorField* SfPtr_;
|
||||
|
||||
//- Mag face area vectors
|
||||
mutable scalarField* magSfPtr_;
|
||||
|
||||
//- Face centres
|
||||
mutable vectorField* CfPtr_;
|
||||
|
||||
|
||||
//- Read bool from dictionary. Return provided value if not found
|
||||
static bool getBool(const dictionary&, const word&, const bool);
|
||||
|
||||
//- check field size matches surface size
|
||||
template<class Type>
|
||||
void checkFieldSize(const Field<Type>& field) const;
|
||||
|
||||
// Make geometric data
|
||||
|
||||
void makeSf() const;
|
||||
|
||||
void makeMagSf() const;
|
||||
|
||||
void makeCf() const;
|
||||
|
||||
|
||||
//- project field onto surface
|
||||
template<class ReturnType, class Type>
|
||||
void project
|
||||
(
|
||||
Field<ReturnType>& res,
|
||||
const Field<Type>& field
|
||||
) const;
|
||||
|
||||
//- project field onto surface
|
||||
template<class ReturnType, class Type>
|
||||
void project
|
||||
(
|
||||
Field<ReturnType>& res,
|
||||
const tmp<Field<Type> >& field
|
||||
) const;
|
||||
|
||||
//- project field onto surface
|
||||
template<class ReturnType, class Type>
|
||||
tmp<Field<ReturnType> > project(const tmp<Field<Type> >&) const;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected static functions
|
||||
|
||||
virtual void clearGeom() const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sampledSurface");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
sampledSurface,
|
||||
word,
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
),
|
||||
(mesh, dict)
|
||||
);
|
||||
|
||||
|
||||
//- Class used for the PtrLists read-construction
|
||||
// Has the ability to rewrite coordinate systems as required
|
||||
class iNew
|
||||
:
|
||||
public coordinateSystems
|
||||
{
|
||||
//- Reference to the volume mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
public:
|
||||
|
||||
iNew(const polyMesh& mesh)
|
||||
:
|
||||
coordinateSystems(mesh),
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
iNew
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const coordinateSystems& cs
|
||||
)
|
||||
:
|
||||
coordinateSystems(cs),
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
autoPtr<sampledSurface> operator()(Istream& is) const
|
||||
{
|
||||
word sampleType(is);
|
||||
dictionary dict(is);
|
||||
rewriteDict(dict, true);
|
||||
|
||||
return sampledSurface::New(sampleType, mesh_, dict);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh, name
|
||||
sampledSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const word& name,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sampledSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Clone
|
||||
autoPtr<sampledSurface> clone() const
|
||||
{
|
||||
notImplemented("autoPtr<sampledSurface> clone() const");
|
||||
return autoPtr<sampledSurface>(NULL);
|
||||
}
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected surface
|
||||
static autoPtr<sampledSurface> New
|
||||
(
|
||||
const word& sampleType,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~sampledSurface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const polyMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
//- Name of surface
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
//- interpolation requested for surface
|
||||
bool interpolate() const
|
||||
{
|
||||
return interpolate_;
|
||||
}
|
||||
|
||||
//- triangulation requested for surface
|
||||
bool triangulate() const
|
||||
{
|
||||
return triangulate_;
|
||||
}
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const = 0;
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const = 0;
|
||||
|
||||
//- Correct for mesh movement and/or field changes
|
||||
virtual void correct(const bool meshChanged) = 0;
|
||||
|
||||
//- Return face area vectors
|
||||
virtual const vectorField& Sf() const;
|
||||
|
||||
//- Return face area magnitudes
|
||||
virtual const scalarField& magSf() const;
|
||||
|
||||
//- Return face centres as vectorField
|
||||
virtual const vectorField& Cf() const;
|
||||
|
||||
//- integration of a field across the surface
|
||||
template<class Type>
|
||||
Type integrate(const Field<Type>&) const;
|
||||
|
||||
//- integration of a field across the surface
|
||||
template<class Type>
|
||||
Type integrate(const tmp<Field<Type> >&) const;
|
||||
|
||||
//- area-averaged value of a field across the surface
|
||||
template<class Type>
|
||||
Type average(const Field<Type>&) const;
|
||||
|
||||
//- area-averaged value of a field across the surface
|
||||
template<class Type>
|
||||
Type average(const tmp<Field<Type> >&) const;
|
||||
|
||||
//- project field onto surface
|
||||
tmp<Field<scalar> > project(const Field<scalar>&) const;
|
||||
tmp<Field<scalar> > project(const Field<vector>&) const;
|
||||
tmp<Field<vector> > project(const Field<sphericalTensor>&) const;
|
||||
tmp<Field<vector> > project(const Field<symmTensor>&) const;
|
||||
tmp<Field<vector> > project(const Field<tensor>&) const;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
) const = 0;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
) const = 0;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
) const = 0;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
) const = 0;
|
||||
|
||||
//- sample field on surface
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
) const = 0;
|
||||
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
) const = 0;
|
||||
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
) const = 0;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
) const = 0;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
) const = 0;
|
||||
|
||||
//- interpolate field on surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
) const = 0;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Rename
|
||||
virtual void rename(const word& newName)
|
||||
{
|
||||
name_ = newName;
|
||||
}
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
// IOstream operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const sampledSurface&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "sampledSurfaceTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
128
src/sampling/sampledSurface/surface/sampledSurfaceTemplates.C
Normal file
128
src/sampling/sampledSurface/surface/sampledSurfaceTemplates.C
Normal file
@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "sampledSurface.H"
|
||||
|
||||
template<class Type>
|
||||
void Foam::sampledSurface::checkFieldSize(const Field<Type>& field) const
|
||||
{
|
||||
if (!faces().size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampledSurface::checkFieldSize(const Field<Type>&) const"
|
||||
)
|
||||
<< "empty surface"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else if (field.size() != faces().size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampledSurface::checkFieldSize(const Field<Type>&) const"
|
||||
)
|
||||
<< "size mismatch: "
|
||||
<< "field (" << field.size()
|
||||
<< ") != surface (" << faces().size() << ")"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::integrate(const Field<Type>& field) const
|
||||
{
|
||||
checkFieldSize(field);
|
||||
return sum(field * magSf());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::integrate(const tmp<Field<Type> >& field) const
|
||||
{
|
||||
checkFieldSize(field());
|
||||
return sum(field * magSf());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::average(const Field<Type>& field) const
|
||||
{
|
||||
checkFieldSize(field);
|
||||
return sum(field * magSf()) / sum(magSf());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::average(const tmp<Field<Type> >& field) const
|
||||
{
|
||||
checkFieldSize(field());
|
||||
return sum(field * magSf()) / sum(magSf());
|
||||
}
|
||||
|
||||
|
||||
template<class ReturnType, class Type>
|
||||
void Foam::sampledSurface::project
|
||||
(
|
||||
Field<ReturnType>& res,
|
||||
const Field<Type>& field
|
||||
) const
|
||||
{
|
||||
checkFieldSize(field);
|
||||
|
||||
const faceList& sampleFaces = faces();
|
||||
const vectorField& norm = Sf();
|
||||
|
||||
forAll(sampleFaces, faceI)
|
||||
{
|
||||
res[faceI] = field[faceI] & (norm[faceI] / mag(norm[faceI]));
|
||||
}
|
||||
}
|
||||
|
||||
template<class ReturnType, class Type>
|
||||
void Foam::sampledSurface::project
|
||||
(
|
||||
Field<ReturnType>& res,
|
||||
const tmp<Field<Type> >& field
|
||||
) const
|
||||
{
|
||||
project(res, field());
|
||||
field.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class ReturnType, class Type>
|
||||
Foam::tmp<Foam::Field<ReturnType> >
|
||||
Foam::sampledSurface::project
|
||||
(
|
||||
const tmp<Field<Type> >& field
|
||||
) const
|
||||
{
|
||||
tmp<Field<ReturnType> > tRes(new Field<ReturnType>(faces().size()));
|
||||
project(tRes(), field);
|
||||
return tRes;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "IOsampledSurfaces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOsampledSurfaces::IOsampledSurfaces
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const fileName& dictName,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dictName,
|
||||
obr.time().system(),
|
||||
obr,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
sampledSurfaces(obr, *this, loadFromFiles)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOsampledSurfaces::~IOsampledSurfaces()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::IOsampledSurfaces::read()
|
||||
{
|
||||
if (regIOobject::read())
|
||||
{
|
||||
sampledSurfaces::read(*this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::IOsampledSurfaces::write()
|
||||
{
|
||||
sampledSurfaces::write();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
50
src/sampling/sampledSurface/surfaces/IOsampledSurfaces.H
Normal file
50
src/sampling/sampledSurface/surfaces/IOsampledSurfaces.H
Normal file
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
IOsampledSurfaces
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for sampledSurfaces.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOsampledSurfaces_H
|
||||
#define IOsampledSurfaces_H
|
||||
|
||||
#include "sampledSurfaces.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<sampledSurfaces> IOsampledSurfaces;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
115
src/sampling/sampledSurface/surfaces/IOsampledSurfaces.H.save
Normal file
115
src/sampling/sampledSurface/surfaces/IOsampledSurfaces.H.save
Normal file
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
IOsampledSurfaces
|
||||
|
||||
Description
|
||||
Set of surfaces to sample.
|
||||
Call surfaces.write() to sample and write files.
|
||||
|
||||
SourceFiles
|
||||
surfaces.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOsampledSurfaces_H
|
||||
#define IOsampledSurfaces_H
|
||||
|
||||
#include "sampledSurfaces.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOsampledSurfaces Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IOsampledSurfaces
|
||||
:
|
||||
public IOdictionary,
|
||||
public sampledSurfaces
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
IOsampledSurfaces(const IOsampledSurfaces&);
|
||||
void operator=(const IOsampledSurfaces&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary
|
||||
// allow the possibility to read from files
|
||||
IOsampledSurfaces
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const fileName& dictName = "sampleSurfaceDict",
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~IOsampledSurfaces();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the surfaces
|
||||
virtual bool read();
|
||||
|
||||
//- Write the surfaces
|
||||
virtual void write();
|
||||
|
||||
|
||||
//- Update for changes of mesh
|
||||
void updateMesh(const mapPolyMesh&)
|
||||
{
|
||||
read();
|
||||
sampledSurfaces::correct(true);
|
||||
}
|
||||
|
||||
//- Update for changes of mesh
|
||||
void movePoints(const pointField&)
|
||||
{
|
||||
read();
|
||||
sampledSurfaces::correct(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
390
src/sampling/sampledSurface/surfaces/sampledSurfaces.C
Normal file
390
src/sampling/sampledSurface/surfaces/sampledSurfaces.C
Normal file
@ -0,0 +1,390 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "sampledSurfaces.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "IOmanip.H"
|
||||
#include "ListListOps.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Used to offset faces in Pstream::combineOffset
|
||||
template <>
|
||||
class offsetOp<face>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
face operator()
|
||||
(
|
||||
const face& x,
|
||||
const label offset
|
||||
) const
|
||||
{
|
||||
face result(x.size());
|
||||
|
||||
forAll(x, xI)
|
||||
{
|
||||
result[xI] = x[xI] + offset;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
defineTypeNameAndDebug(sampledSurfaces, 0);
|
||||
}
|
||||
|
||||
bool Foam::sampledSurfaces::verbose_ = false;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sampledSurfaces::checkFieldTypes()
|
||||
{
|
||||
wordList fieldTypes(fieldNames_.size());
|
||||
|
||||
// check files for a particular time
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
forAll(fieldNames_, fieldI)
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
fieldNames_[fieldI],
|
||||
obr_.time().timeName(),
|
||||
refCast<const polyMesh>(obr_),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (io.headerOk())
|
||||
{
|
||||
fieldTypes[fieldI] = io.headerClassName();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldTypes[fieldI] = "(notFound)";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// check objectRegistry
|
||||
forAll(fieldNames_, fieldI)
|
||||
{
|
||||
objectRegistry::const_iterator iter =
|
||||
obr_.find(fieldNames_[fieldI]);
|
||||
|
||||
if (iter != obr_.end())
|
||||
{
|
||||
fieldTypes[fieldI] = iter()->type();
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldTypes[fieldI] = "(notFound)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
label nFields = 0;
|
||||
|
||||
// classify fieldTypes
|
||||
nFields += grep(scalarFields_, fieldTypes);
|
||||
nFields += grep(vectorFields_, fieldTypes);
|
||||
nFields += grep(sphericalTensorFields_, fieldTypes);
|
||||
nFields += grep(symmTensorFields_, fieldTypes);
|
||||
nFields += grep(tensorFields_, fieldTypes);
|
||||
|
||||
if (Pstream::master)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "timeName = " << obr_.time().timeName() << nl
|
||||
<< "scalarFields " << scalarFields_ << nl
|
||||
<< "vectorFields " << vectorFields_ << nl
|
||||
<< "sphTensorFields " << sphericalTensorFields_ << nl
|
||||
<< "symTensorFields " << symmTensorFields_ <<nl
|
||||
<< "tensorFields " << tensorFields_ <<nl;
|
||||
}
|
||||
|
||||
if (nFields > 0)
|
||||
{
|
||||
Pout<< "Creating directory " << outputPath_/obr_.time().timeName()
|
||||
<< nl << endl;
|
||||
|
||||
mkDir(outputPath_/obr_.time().timeName());
|
||||
}
|
||||
}
|
||||
|
||||
return nFields > 0;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::mergeSurfaces()
|
||||
{
|
||||
if (!Pstream::parRun())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Merge close points (1E-10 of mesh bounding box)
|
||||
const scalar mergeTol = 1e-10;
|
||||
|
||||
const polyMesh& mesh = refCast<const polyMesh>(obr_);
|
||||
const boundBox& bb = mesh.globalData().bb();
|
||||
|
||||
scalar mergeDim = mergeTol * mag(bb.max() - bb.min());
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
Pout<< nl << "Merging all points within "
|
||||
<< mergeDim << " meter" << endl;
|
||||
}
|
||||
|
||||
mergeList_.setSize(size());
|
||||
forAll(*this, surfI)
|
||||
{
|
||||
sampledSurface& s = operator[](surfI);
|
||||
|
||||
// Collect points from all processors
|
||||
List<pointField> gatheredPoints(Pstream::nProcs());
|
||||
gatheredPoints[Pstream::myProcNo()] = s.points();
|
||||
Pstream::gatherList(gatheredPoints);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
mergeList_[surfI].points = ListListOps::combine<pointField>
|
||||
(
|
||||
gatheredPoints,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
}
|
||||
|
||||
// Collect faces from all processors and renumber using sizes of
|
||||
// gathered points
|
||||
List<faceList> gatheredFaces(Pstream::nProcs());
|
||||
gatheredFaces[Pstream::myProcNo()] = s.faces();
|
||||
Pstream::gatherList(gatheredFaces);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
mergeList_[surfI].faces = static_cast<const faceList&>
|
||||
(
|
||||
ListListOps::combineOffset<faceList>
|
||||
(
|
||||
gatheredFaces,
|
||||
ListListOps::subSizes
|
||||
(
|
||||
gatheredPoints,
|
||||
accessOp<pointField>()
|
||||
),
|
||||
accessOp<faceList>(),
|
||||
offsetOp<face>()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
pointField newPoints;
|
||||
labelList oldToNew;
|
||||
|
||||
bool hasMerged = mergePoints
|
||||
(
|
||||
mergeList_[surfI].points,
|
||||
mergeDim,
|
||||
false, // verbosity
|
||||
oldToNew,
|
||||
newPoints
|
||||
);
|
||||
|
||||
if (hasMerged)
|
||||
{
|
||||
// Store point mapping
|
||||
mergeList_[surfI].pointsMap.transfer(oldToNew);
|
||||
|
||||
// Copy points
|
||||
mergeList_[surfI].points.transfer(newPoints);
|
||||
|
||||
// Relabel faces
|
||||
faceList& faces = mergeList_[surfI].faces;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
inplaceRenumber(mergeList_[surfI].pointsMap, faces[faceI]);
|
||||
}
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
Pout<< "For surface " << surfI << " merged from "
|
||||
<< mergeList_[surfI].pointsMap.size() << " points down to "
|
||||
<< mergeList_[surfI].points.size() << " points" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledSurfaces::sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
PtrList<sampledSurface>(),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
loadFromFiles_(loadFromFiles_),
|
||||
outputPath_(fileName::null),
|
||||
pMeshPtr_(NULL),
|
||||
pInterpPtr_(NULL),
|
||||
fieldNames_(),
|
||||
interpolationScheme_(word::null),
|
||||
writeFormat_(word::null),
|
||||
mergeList_(),
|
||||
scalarFields_(),
|
||||
vectorFields_(),
|
||||
sphericalTensorFields_(),
|
||||
symmTensorFields_(),
|
||||
tensorFields_()
|
||||
{
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
outputPath_ = obr_.time().path()/".."/name_;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPath_ = obr_.time().path()/name_;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledSurfaces::~sampledSurfaces()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::sampledSurfaces::verbose(const bool verbosity)
|
||||
{
|
||||
verbose_ = verbosity;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::write()
|
||||
{
|
||||
if (size() && checkFieldTypes())
|
||||
{
|
||||
sampleAndWrite(scalarFields_);
|
||||
sampleAndWrite(vectorFields_);
|
||||
sampleAndWrite(sphericalTensorFields_);
|
||||
sampleAndWrite(symmTensorFields_);
|
||||
sampleAndWrite(tensorFields_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
{
|
||||
fieldNames_ = wordList(dict.lookup("fields"));
|
||||
|
||||
interpolationScheme_ = "cell";
|
||||
if (dict.found("interpolationScheme"))
|
||||
{
|
||||
dict.lookup("interpolationScheme") >> interpolationScheme_;
|
||||
}
|
||||
|
||||
writeFormat_ = "null";
|
||||
if (dict.found("surfaceFormat"))
|
||||
{
|
||||
dict.lookup("surfaceFormat") >> writeFormat_;
|
||||
}
|
||||
|
||||
|
||||
PtrList<sampledSurface> newList
|
||||
(
|
||||
dict.lookup("surfaces"),
|
||||
sampledSurface::iNew(refCast<const polyMesh>(obr_))
|
||||
);
|
||||
|
||||
transfer(newList);
|
||||
mergeSurfaces();
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
Pout<< "sample fields:" << fieldNames_ << nl
|
||||
<< "sample surfaces:" << nl << "(" << nl;
|
||||
|
||||
forAll(*this, surfI)
|
||||
{
|
||||
Pout << " " << operator[](surfI) << endl;
|
||||
}
|
||||
Pout << ")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::correct()
|
||||
{
|
||||
forAll(*this, surfI)
|
||||
{
|
||||
operator[](surfI).correct(true);
|
||||
}
|
||||
|
||||
// reset interpolation for later
|
||||
pMeshPtr_.clear();
|
||||
pInterpPtr_.clear();
|
||||
|
||||
mergeSurfaces();
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::updateMesh(const mapPolyMesh&)
|
||||
{
|
||||
correct();
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::movePoints(const pointField&)
|
||||
{
|
||||
correct();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
277
src/sampling/sampledSurface/surfaces/sampledSurfaces.H
Normal file
277
src/sampling/sampledSurface/surfaces/sampledSurfaces.H
Normal file
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
sampledSurfaces
|
||||
|
||||
Description
|
||||
Set of surfaces to sample.
|
||||
Call sampledSurfaces.write() to sample&write files.
|
||||
|
||||
SourceFiles
|
||||
sampledSurfaces.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampledSurfaces_H
|
||||
#define sampledSurfaces_H
|
||||
|
||||
#include "sampledSurface.H"
|
||||
#include "surfaceWriter.H"
|
||||
#include "volFields.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledSurfaces Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledSurfaces
|
||||
:
|
||||
public PtrList<sampledSurface>
|
||||
{
|
||||
// Private classes
|
||||
|
||||
//- Class used for grouping field types
|
||||
template<class Type>
|
||||
class fieldGroup
|
||||
:
|
||||
public wordList
|
||||
{
|
||||
public:
|
||||
//- surface formatter
|
||||
autoPtr<surfaceWriter<Type> > formatter;
|
||||
|
||||
//- Construct null
|
||||
fieldGroup()
|
||||
:
|
||||
wordList(0),
|
||||
formatter(NULL)
|
||||
{}
|
||||
|
||||
//- Construct for a particular surface format
|
||||
fieldGroup(const word& writeFormat)
|
||||
:
|
||||
wordList(0),
|
||||
formatter(surfaceWriter<Type>::New(writeFormat))
|
||||
{}
|
||||
|
||||
//- Construct for a particular surface format
|
||||
// and a list of field names
|
||||
fieldGroup
|
||||
(
|
||||
const word& writeFormat,
|
||||
const wordList& fieldNames
|
||||
)
|
||||
:
|
||||
wordList(fieldNames),
|
||||
formatter(surfaceWriter<Type>::New(writeFormat))
|
||||
{}
|
||||
|
||||
void operator=(const word& writeFormat)
|
||||
{
|
||||
formatter = surfaceWriter<Type>::New(writeFormat);
|
||||
}
|
||||
|
||||
void operator=(const wordList& fieldNames)
|
||||
{
|
||||
wordList::operator=(fieldNames);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//- Class used for surface merging information
|
||||
class mergeInfo
|
||||
{
|
||||
public:
|
||||
pointField points;
|
||||
faceList faces;
|
||||
labelList pointsMap;
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
//- output verbosity
|
||||
static bool verbose_;
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
//- Name of this set of surfaces,
|
||||
// Also used as the name of the sampledSurfaces directory.
|
||||
word name_;
|
||||
|
||||
//- Const reference to objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Load fields from files (not from objectRegistry)
|
||||
bool loadFromFiles_;
|
||||
|
||||
//- output path
|
||||
fileName outputPath_;
|
||||
|
||||
//- pointMesh for interpolation
|
||||
autoPtr<pointMesh> pMeshPtr_;
|
||||
|
||||
//- volPointInterpolation for interpolation
|
||||
autoPtr<volPointInterpolation> pInterpPtr_;
|
||||
|
||||
|
||||
// Read from dictonary
|
||||
|
||||
//- Names of fields to sample
|
||||
wordList fieldNames_;
|
||||
|
||||
//- Interpolation scheme to use
|
||||
word interpolationScheme_;
|
||||
|
||||
//- Output format to use
|
||||
word writeFormat_;
|
||||
|
||||
|
||||
// surfaces
|
||||
|
||||
//- information for merging surfaces
|
||||
List<mergeInfo> mergeList_;
|
||||
|
||||
|
||||
// Calculated
|
||||
|
||||
//- Categorized scalar/vector/tensor fields
|
||||
fieldGroup<scalar> scalarFields_;
|
||||
fieldGroup<vector> vectorFields_;
|
||||
fieldGroup<sphericalTensor> sphericalTensorFields_;
|
||||
fieldGroup<symmTensor> symmTensorFields_;
|
||||
fieldGroup<tensor> tensorFields_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- classify field types, return true if nFields > 0
|
||||
bool checkFieldTypes();
|
||||
|
||||
//- merge points on surfaces
|
||||
void mergeSurfaces();
|
||||
|
||||
//- Correct for mesh changes
|
||||
void correct();
|
||||
|
||||
//- Find the fields in the list of the given type, return count
|
||||
template<class Type>
|
||||
label grep
|
||||
(
|
||||
fieldGroup<Type>& fieldList,
|
||||
const wordList& fieldTypes
|
||||
) const;
|
||||
|
||||
//- set interpolator for the field
|
||||
template<class Type>
|
||||
autoPtr<interpolation<Type> > setInterpolator
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
);
|
||||
|
||||
//- Sample and write a particular volume field
|
||||
template<class Type>
|
||||
void sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const surfaceWriter<Type>& formatter
|
||||
);
|
||||
|
||||
//- Sample and write all the fields of the given type
|
||||
template <class Type>
|
||||
void sampleAndWrite(fieldGroup<Type>&);
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
sampledSurfaces(const sampledSurfaces&);
|
||||
void operator=(const sampledSurfaces&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaces");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary
|
||||
// allow the possibility to load fields from files
|
||||
sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~sampledSurfaces();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- set verbosity level
|
||||
void verbose(const bool verbosity = true);
|
||||
|
||||
//- Sample and write
|
||||
virtual void write();
|
||||
|
||||
//- Read the sampledSurfaces
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
|
||||
//- Update for mesh point-motion
|
||||
virtual void movePoints(const pointField&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "sampledSurfacesTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
252
src/sampling/sampledSurface/surfaces/sampledSurfacesTemplates.C
Normal file
252
src/sampling/sampledSurface/surfaces/sampledSurfacesTemplates.C
Normal file
@ -0,0 +1,252 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "sampledSurfaces.H"
|
||||
#include "volFields.H"
|
||||
#include "ListListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::sampledSurfaces::grep
|
||||
(
|
||||
fieldGroup<Type>& fieldList,
|
||||
const wordList& fieldTypes
|
||||
) const
|
||||
{
|
||||
fieldList.setSize(fieldNames_.size());
|
||||
label nFields = 0;
|
||||
|
||||
forAll(fieldNames_, fieldI)
|
||||
{
|
||||
if
|
||||
(
|
||||
fieldTypes[fieldI]
|
||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
fieldList[nFields] = fieldNames_[fieldI];
|
||||
nFields++;
|
||||
}
|
||||
}
|
||||
|
||||
fieldList.setSize(nFields);
|
||||
|
||||
return nFields;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr<Foam::interpolation<Type> >
|
||||
Foam::sampledSurfaces::setInterpolator
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
)
|
||||
{
|
||||
if (!pMeshPtr_.valid() || !pInterpPtr_.valid())
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
// set up interpolation
|
||||
pMeshPtr_.reset(new pointMesh(mesh));
|
||||
pInterpPtr_.reset(new volPointInterpolation(mesh, pMeshPtr_()));
|
||||
}
|
||||
|
||||
// interpolator for this field
|
||||
return interpolation<Type>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
pInterpPtr_(),
|
||||
vField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::sampledSurfaces::sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField,
|
||||
const surfaceWriter<Type>& formatter
|
||||
)
|
||||
{
|
||||
// interpolator for this field
|
||||
autoPtr<interpolation<Type> > interpolator;
|
||||
|
||||
const word& fieldName = vField.name();
|
||||
const fileName& timeDir = vField.time().timeName();
|
||||
|
||||
forAll(*this, surfI)
|
||||
{
|
||||
const sampledSurface& s = operator[](surfI);
|
||||
|
||||
Field<Type> values;
|
||||
|
||||
if (s.interpolate())
|
||||
{
|
||||
if (!interpolator.valid())
|
||||
{
|
||||
interpolator = setInterpolator(vField);
|
||||
}
|
||||
|
||||
values = s.interpolate(interpolator());
|
||||
}
|
||||
else
|
||||
{
|
||||
values = s.sample(vField);
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Collect values from all processors
|
||||
List<Field<Type> > gatheredValues(Pstream::nProcs());
|
||||
gatheredValues[Pstream::myProcNo()] = values;
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Combine values into single field
|
||||
Field<Type> allValues
|
||||
(
|
||||
ListListOps::combine<Field<Type> >
|
||||
(
|
||||
gatheredValues,
|
||||
accessOp<Field<Type> >()
|
||||
)
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
if (mergeList_[surfI].pointsMap.size() == allValues.size())
|
||||
{
|
||||
inplaceReorder(mergeList_[surfI].pointsMap, allValues);
|
||||
allValues.setSize(mergeList_[surfI].points.size());
|
||||
}
|
||||
|
||||
// Write to time directory under outputPath_
|
||||
formatter.write
|
||||
(
|
||||
outputPath_,
|
||||
timeDir,
|
||||
s.name(),
|
||||
mergeList_[surfI].points,
|
||||
mergeList_[surfI].faces,
|
||||
fieldName,
|
||||
allValues
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write to time directory under outputPath_
|
||||
formatter.write
|
||||
(
|
||||
outputPath_,
|
||||
timeDir,
|
||||
s.name(),
|
||||
s.points(),
|
||||
s.faces(),
|
||||
fieldName,
|
||||
values
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
void Foam::sampledSurfaces::sampleAndWrite
|
||||
(
|
||||
fieldGroup<Type>& fields
|
||||
)
|
||||
{
|
||||
if (fields.size())
|
||||
{
|
||||
// create or use existing surfaceWriter
|
||||
if (!fields.formatter.valid())
|
||||
{
|
||||
fields.formatter = surfaceWriter<Type>::New(writeFormat_);
|
||||
}
|
||||
|
||||
forAll(fields, fieldI)
|
||||
{
|
||||
if (Pstream::master() && verbose_)
|
||||
{
|
||||
Pout<< "sampleAndWrite: " << fields[fieldI] << endl;
|
||||
}
|
||||
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
sampleAndWrite
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fields[fieldI],
|
||||
obr_.time().timeName(),
|
||||
refCast<const polyMesh>(obr_),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
refCast<const fvMesh>(obr_)
|
||||
),
|
||||
fields.formatter()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
objectRegistry::const_iterator iter =
|
||||
obr_.find(fields[fieldI]);
|
||||
|
||||
if
|
||||
(
|
||||
iter != obr_.end()
|
||||
&& iter()->type() == GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
)
|
||||
{
|
||||
sampleAndWrite
|
||||
(
|
||||
obr_.lookupObject<GeometricField<Type, fvPatchField, volMesh> >
|
||||
(
|
||||
fields[fieldI]
|
||||
),
|
||||
fields.formatter()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfacesFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(surfacesFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
surfacesFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfacesFunctionObject.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "IOsampledSurfaces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfacesFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
surfacesFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::surfacesFunctionObject::extractDict()
|
||||
{
|
||||
if (dict_.found("region"))
|
||||
{
|
||||
dict_.lookup("region") >> regionName_;
|
||||
}
|
||||
|
||||
if (dict_.found("dictionary"))
|
||||
{
|
||||
dict_.lookup("dictionary") >> dictName_;
|
||||
}
|
||||
|
||||
if (dict_.found("interval"))
|
||||
{
|
||||
dict_.lookup("interval") >> interval_;
|
||||
}
|
||||
|
||||
if (dict_.found("enabled"))
|
||||
{
|
||||
dict_.lookup("enabled") >> execution_;
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfacesFunctionObject::surfacesFunctionObject
|
||||
(
|
||||
const Time& t,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(),
|
||||
time_(t),
|
||||
dict_(dict),
|
||||
regionName_(polyMesh::defaultRegion),
|
||||
dictName_(),
|
||||
interval_(0),
|
||||
execution_(true)
|
||||
{
|
||||
extractDict();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// any possible side-effects?
|
||||
bool Foam::surfacesFunctionObject::start()
|
||||
{
|
||||
extractDict();
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
if (dictName_.size())
|
||||
{
|
||||
ptr_.reset
|
||||
(
|
||||
new IOsampledSurfaces
|
||||
(
|
||||
time_.lookupObject<objectRegistry>(regionName_),
|
||||
dictName_
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_.reset
|
||||
(
|
||||
new sampledSurfaces
|
||||
(
|
||||
time_.lookupObject<objectRegistry>(regionName_),
|
||||
dict_
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfacesFunctionObject::execute()
|
||||
{
|
||||
if (execution_ && (interval_ <= 1 || !(time_.timeIndex() % interval_)) )
|
||||
{
|
||||
ptr_->write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfacesFunctionObject::on()
|
||||
{
|
||||
execution_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfacesFunctionObject::off()
|
||||
{
|
||||
execution_ = false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfacesFunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
if (dict_ != dict)
|
||||
{
|
||||
dict_ = dict;
|
||||
return start();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
surfacesFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around surfaces to allow them to be created via the
|
||||
functions list within controlDict.
|
||||
|
||||
SourceFiles
|
||||
surfacesFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfacesFunctionObject_H
|
||||
#define surfacesFunctionObject_H
|
||||
|
||||
#include "sampledSurfaces.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<sampledSurfaces> surfacesFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
surfacesFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around surfaces to allow them to be created via the
|
||||
functions list within controlDict.
|
||||
|
||||
SourceFiles
|
||||
surfacesFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfacesFunctionObject_H
|
||||
#define surfacesFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class sampledSurfaces;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfacesFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfacesFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
const Time& time_;
|
||||
dictionary dict_;
|
||||
word regionName_;
|
||||
word dictName_;
|
||||
|
||||
//- 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&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surfacesFunctionObject&);
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaces");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfacesFunctionObject
|
||||
(
|
||||
const Time&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- start is called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- execute is called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Switch the function object on
|
||||
virtual void on();
|
||||
|
||||
//- Switch the function object off
|
||||
virtual void off();
|
||||
|
||||
//- Read and set the function object if its data has changed
|
||||
virtual bool read(const dictionary& dict);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
329
src/sampling/surfaceWriters/dx/dx.C
Normal file
329
src/sampling/surfaceWriters/dx/dx.C
Normal file
@ -0,0 +1,329 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "dx.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write vertex coordinates
|
||||
|
||||
os << "# The irregular positions" << nl
|
||||
<< "object 1 class array type float rank 1 shape 3 items "
|
||||
<< points.size() << " data follows" << nl;
|
||||
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
|
||||
<< nl;
|
||||
}
|
||||
os << nl;
|
||||
|
||||
// Write triangles
|
||||
|
||||
os << "# The irregular connections (triangles)" << nl
|
||||
<< "object 2 class array type int rank 1 shape 3 items "
|
||||
<< faces.size() << " data follows" << nl;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
if (f.size() != 3)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"writeDXGeometry(Ostream&, const pointField&, const faceList&)"
|
||||
) << "Face " << faceI << " vertices " << f
|
||||
<< " is not a triangle."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
os << f[0] << ' ' << f[1] << ' ' << f[2] << nl;
|
||||
}
|
||||
os << "attribute \"element type\" string \"triangles\"" << nl
|
||||
<< "attribute \"ref\" string \"positions\"" << nl << nl;
|
||||
}
|
||||
|
||||
|
||||
// Write scalarField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 0 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI]) << nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write vectorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 1 shape 3 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI].x()) << ' '
|
||||
<< float(values[elemI].y()) << ' '
|
||||
<< float(values[elemI].z()) << nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write sphericalTensorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 0 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI][0]) << nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write symmTensorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 2 shape 3 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const symmTensor& t = values[elemI];
|
||||
|
||||
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
|
||||
<< float(t.xy()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
|
||||
<< float(t.xz()) << ' ' << float(t.yz()) << ' ' << float(t.zz())
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write tensorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 2 shape 3 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const tensor& t = values[elemI];
|
||||
|
||||
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
|
||||
<< float(t.yx()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
|
||||
<< float(t.zx()) << ' ' << float(t.zy()) << ' ' << float(t.zz())
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write trailer in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXTrailer(Ostream& os) const
|
||||
{
|
||||
os << "# the field, with three components: \"positions\","
|
||||
<< " \"connections\", and \"data\"" << nl
|
||||
<< "object \"irregular positions irregular "
|
||||
<< "connections\" class field"
|
||||
<< nl
|
||||
<< "component \"positions\" value 1" << nl
|
||||
<< "component \"connections\" value 2" << nl
|
||||
<< "component \"data\" value 3" << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::dx<Type>::dx()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::dx<Type>::~dx()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".dx");
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
}
|
||||
|
||||
OFstream dxFile(planeFName);
|
||||
|
||||
writeDXGeometry(points, faces, dxFile);
|
||||
|
||||
writeDXData(points, values, dxFile);
|
||||
|
||||
writeDXTrailer(dxFile);
|
||||
|
||||
dxFile << "end" << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
151
src/sampling/surfaceWriters/dx/dx.H
Normal file
151
src/sampling/surfaceWriters/dx/dx.H
Normal file
@ -0,0 +1,151 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
dx
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
dx.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dx_H
|
||||
#define dx_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dx Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class dx
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeDXGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXTrailer(Ostream& os) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("dx");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
dx();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~dx();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "dx.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
43
src/sampling/surfaceWriters/dx/dxWriters.C
Normal file
43
src/sampling/surfaceWriters/dx/dxWriters.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "dxWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(dx);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/sampling/surfaceWriters/dx/dxWriters.H
Normal file
63
src/sampling/surfaceWriters/dx/dxWriters.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
dxWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
dxWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dxWriters_H
|
||||
#define dxWriters_H
|
||||
|
||||
#include "dx.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef dx<scalar> dxScalarWriter;
|
||||
typedef dx<vector> dxVectorWriter;
|
||||
typedef dx<sphericalTensor> dxSphericalTensorWriter;
|
||||
typedef dx<symmTensor> dxSymmTensorWriter;
|
||||
typedef dx<tensor> dxTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
103
src/sampling/surfaceWriters/foamFile/foamFile.C
Normal file
103
src/sampling/surfaceWriters/foamFile/foamFile.C
Normal file
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamFile.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::foamFile<Type>::foamFile()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::foamFile<Type>::~foamFile()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::foamFile<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName planeFName(samplePath/timeDir/surfaceName);
|
||||
|
||||
if (!exists(planeFName))
|
||||
{
|
||||
mkDir(planeFName);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
}
|
||||
|
||||
// Points
|
||||
OFstream pointsFile(planeFName/"points");
|
||||
|
||||
pointsFile << points;
|
||||
|
||||
// Faces
|
||||
OFstream facesFile(planeFName/"faces");
|
||||
|
||||
facesFile << faces;
|
||||
|
||||
// Values to separate directory (e.g. "scalarField/p")
|
||||
|
||||
fileName foamName(pTraits<Type>::typeName);
|
||||
|
||||
fileName valuesDir(planeFName / (foamName + Field<Type>::typeName));
|
||||
|
||||
if (!exists(valuesDir))
|
||||
{
|
||||
mkDir(valuesDir);
|
||||
}
|
||||
|
||||
OFstream valuesFile(valuesDir/fieldName);
|
||||
|
||||
valuesFile << values;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
105
src/sampling/surfaceWriters/foamFile/foamFile.H
Normal file
105
src/sampling/surfaceWriters/foamFile/foamFile.H
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
foamFile
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
foamFile.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamFile_H
|
||||
#define foamFile_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class foamFile
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("foamFile");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
foamFile();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~foamFile();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "foamFile.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
43
src/sampling/surfaceWriters/foamFile/foamFileWriters.C
Normal file
43
src/sampling/surfaceWriters/foamFile/foamFileWriters.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamFileWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(foamFile);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/sampling/surfaceWriters/foamFile/foamFileWriters.H
Normal file
63
src/sampling/surfaceWriters/foamFile/foamFileWriters.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
foamFileWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
foamFileWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamFileWriters_H
|
||||
#define foamFileWriters_H
|
||||
|
||||
#include "foamFile.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef foamFile<scalar> foamFileScalarWriter;
|
||||
typedef foamFile<vector> foamFileVectorWriter;
|
||||
typedef foamFile<sphericalTensor> foamFileSphericalTensorWriter;
|
||||
typedef foamFile<symmTensor> foamFileSymmTensorWriter;
|
||||
typedef foamFile<tensor> foamFileTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
68
src/sampling/surfaceWriters/null/null.C
Normal file
68
src/sampling/surfaceWriters/null/null.C
Normal file
@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "null.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::null<Type>::null()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::null<Type>::~null()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::null<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
105
src/sampling/surfaceWriters/null/null.H
Normal file
105
src/sampling/surfaceWriters/null/null.H
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
null
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
null.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef null_H
|
||||
#define null_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class null Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class null
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("null");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
null();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~null();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "null.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
43
src/sampling/surfaceWriters/null/nullWriters.C
Normal file
43
src/sampling/surfaceWriters/null/nullWriters.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nullWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(null);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/sampling/surfaceWriters/null/nullWriters.H
Normal file
63
src/sampling/surfaceWriters/null/nullWriters.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
nullWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
nullWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef nullWriters_H
|
||||
#define nullWriters_H
|
||||
|
||||
#include "null.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef null<scalar> nullScalarWriter;
|
||||
typedef null<vector> nullVectorWriter;
|
||||
typedef null<sphericalTensor> nullSphericalTensorWriter;
|
||||
typedef null<symmTensor> nullSymmTensorWriter;
|
||||
typedef null<tensor> nullTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
363
src/sampling/surfaceWriters/raw/raw.C
Normal file
363
src/sampling/surfaceWriters/raw/raw.C
Normal file
@ -0,0 +1,363 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const label& pointI,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const label& faceI,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const point& ct = faces[faceI].centre(points);
|
||||
|
||||
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
|
||||
}
|
||||
|
||||
// Write scalarField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# x y z " << fieldName
|
||||
<< endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
os << values[elemI] << endl;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
// Write vectorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# x y z "
|
||||
<< fieldName << "_x "
|
||||
<< fieldName << "_y "
|
||||
<< fieldName << "_z "
|
||||
<< endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const vector& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write sphericalTensorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# ii ";
|
||||
os << fieldName << "_ii" << endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const sphericalTensor& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write symmTensorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# xx xy xz yy yz ";
|
||||
for(int i=0; i<6; i++)
|
||||
{
|
||||
os << fieldName << "_" << i << " ";
|
||||
}
|
||||
os << endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const symmTensor& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << ' ' << v[1] << ' ' << v[2]
|
||||
<< v[3] << ' ' << v[4] << ' ' << v[5]
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write tensorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# xx xy xz yx yy yz zx zy zz";
|
||||
for(int i=0; i<9; i++)
|
||||
{
|
||||
os << fieldName << "_" << i << " ";
|
||||
}
|
||||
os << endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const tensor& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << ' ' << v[1] << ' ' << v[2]
|
||||
<< v[3] << ' ' << v[4] << ' ' << v[5]
|
||||
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::raw<Type>::raw()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::raw<Type>::~raw()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".raw");
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
}
|
||||
|
||||
OFstream rawFile(planeFName);
|
||||
|
||||
writeData(fieldName, points, faces, values, rawFile);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
167
src/sampling/surfaceWriters/raw/raw.H
Normal file
167
src/sampling/surfaceWriters/raw/raw.H
Normal file
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
raw
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
raw.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef raw_H
|
||||
#define raw_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class raw Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class raw
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const label& pointI,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const label& faceI,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("raw");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
raw();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~raw();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "raw.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
43
src/sampling/surfaceWriters/raw/rawWriters.C
Normal file
43
src/sampling/surfaceWriters/raw/rawWriters.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(raw);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/sampling/surfaceWriters/raw/rawWriters.H
Normal file
63
src/sampling/surfaceWriters/raw/rawWriters.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
rawWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
rawWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawWriters_H
|
||||
#define rawWriters_H
|
||||
|
||||
#include "raw.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef raw<scalar> rawScalarWriter;
|
||||
typedef raw<vector> rawVectorWriter;
|
||||
typedef raw<sphericalTensor> rawSphericalTensorWriter;
|
||||
typedef raw<symmTensor> rawSymmTensorWriter;
|
||||
typedef raw<tensor> rawTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
115
src/sampling/surfaceWriters/stl/stl.C
Normal file
115
src/sampling/surfaceWriters/stl/stl.C
Normal file
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "stl.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::stl<Type>::stl()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::stl<Type>::~stl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::stl<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".stl");
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
}
|
||||
|
||||
// Convert faces to triangles.
|
||||
DynamicList<labelledTri> tris(faces.size());
|
||||
|
||||
forAll(faces, i)
|
||||
{
|
||||
const face& f = faces[i];
|
||||
|
||||
faceList triFaces(f.nTriangles(points));
|
||||
label nTris = 0;
|
||||
f.triangles(points, nTris, triFaces);
|
||||
|
||||
forAll(triFaces, triI)
|
||||
{
|
||||
const face& tri = triFaces[triI];
|
||||
tris.append(labelledTri(tri[0], tri[1], tri[2], 0));
|
||||
}
|
||||
}
|
||||
|
||||
triSurface
|
||||
(
|
||||
tris.shrink(),
|
||||
geometricSurfacePatchList
|
||||
(
|
||||
1,
|
||||
geometricSurfacePatch
|
||||
(
|
||||
"patch", // geometricType
|
||||
string::validate<word>(fieldName), // fieldName
|
||||
0 // index
|
||||
)
|
||||
),
|
||||
points
|
||||
).write(planeFName);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
105
src/sampling/surfaceWriters/stl/stl.H
Normal file
105
src/sampling/surfaceWriters/stl/stl.H
Normal file
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
stl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
stl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stl_H
|
||||
#define stl_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class stl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class stl
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("stl");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
stl();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~stl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "stl.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
43
src/sampling/surfaceWriters/stl/stlWriters.C
Normal file
43
src/sampling/surfaceWriters/stl/stlWriters.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "stlWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(stl);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/sampling/surfaceWriters/stl/stlWriters.H
Normal file
63
src/sampling/surfaceWriters/stl/stlWriters.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
stlWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
stlWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stlWriters_H
|
||||
#define stlWriters_H
|
||||
|
||||
#include "stl.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef stl<scalar> stlScalarWriter;
|
||||
typedef stl<vector> stlVectorWriter;
|
||||
typedef stl<sphericalTensor> stlSphericalTensorWriter;
|
||||
typedef stl<symmTensor> stlSymmTensorWriter;
|
||||
typedef stl<tensor> stlTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
78
src/sampling/surfaceWriters/surfaceWriter.C
Normal file
78
src/sampling/surfaceWriters/surfaceWriter.C
Normal file
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "surfaceWriter.H"
|
||||
#include "HashTable.H"
|
||||
#include "word.H"
|
||||
#include "fileName.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
autoPtr<surfaceWriter<Type> > surfaceWriter<Type>::New(const word& writeType)
|
||||
{
|
||||
typename wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_
|
||||
->find(writeType);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"surfaceWriter::New(const word&)"
|
||||
) << "Unknown write type " << writeType
|
||||
<< endl << endl
|
||||
<< "Valid write types : " << endl
|
||||
<< wordConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<surfaceWriter<Type> >(cstrIter()());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
surfaceWriter<Type>::surfaceWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
surfaceWriter<Type>::~surfaceWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
159
src/sampling/surfaceWriters/surfaceWriter.H
Normal file
159
src/sampling/surfaceWriters/surfaceWriter.H
Normal file
@ -0,0 +1,159 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
surfaceWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
surfaceWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceWriter_H
|
||||
#define surfaceWriter_H
|
||||
|
||||
#include "Field.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "pointField.H"
|
||||
#include "faceList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class surfaceWriter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaceWriter");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
surfaceWriter,
|
||||
word,
|
||||
(),
|
||||
()
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected surfaceWriter
|
||||
static autoPtr<surfaceWriter> New(const word& writeFormat);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfaceWriter();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~surfaceWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Writes single surface to file. Either one value per vertex or
|
||||
// one value per face (detected by values.size()==faces.size())
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath, // <root>/<case>/sampleSurfaces
|
||||
const fileName& timeDir, // time directory
|
||||
const fileName& surfaceName, // name of surface
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName, // name of field
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "surfaceWriter.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##SphericalTensorWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##SymmTensorWriter); \
|
||||
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(sphericalTensorWriter, typeWriter##SphericalTensorWriter); \
|
||||
makeWriterTypes(symmTensorWriter, typeWriter##SymmTensorWriter);\
|
||||
makeWriterTypes(tensorWriter, typeWriter##TensorWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
55
src/sampling/surfaceWriters/surfaceWriters.C
Normal file
55
src/sampling/surfaceWriters/surfaceWriters.C
Normal file
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceWriters.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
|
||||
|
||||
// ************************************************************************* //
|
||||
59
src/sampling/surfaceWriters/surfaceWriters.H
Normal file
59
src/sampling/surfaceWriters/surfaceWriters.H
Normal file
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
surfaceWriter
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceWriters_H
|
||||
#define surfaceWriters_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef surfaceWriter<scalar> scalarWriter;
|
||||
typedef surfaceWriter<vector> vectorWriter;
|
||||
typedef surfaceWriter<sphericalTensor> sphericalTensorWriter;
|
||||
typedef surfaceWriter<symmTensor> symmTensorWriter;
|
||||
typedef surfaceWriter<tensor> tensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
334
src/sampling/surfaceWriters/vtk/vtk.C
Normal file
334
src/sampling/surfaceWriters/vtk/vtk.C
Normal file
@ -0,0 +1,334 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "vtk.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write vertex coordinates
|
||||
|
||||
os
|
||||
<< "# vtk DataFile Version 2.0" << nl
|
||||
<< "sampleSurface" << nl
|
||||
<< "ASCII" << nl
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
os << "POINTS " << points.size() << " float" << nl;
|
||||
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
|
||||
<< nl;
|
||||
}
|
||||
os << endl;
|
||||
|
||||
|
||||
// Write triangles
|
||||
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
nFaceVerts += f.size() + 1;
|
||||
}
|
||||
|
||||
os << "POLYGONS " << faces.size() << ' ' << nFaceVerts << nl;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
os << f.size();
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
os << ' ' << f[fp];
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write scalarField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 1 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI]);
|
||||
|
||||
if (elemI > 0 && (elemI%10) == 0)
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
// Write vectorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 3 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const vector& v = values[elemI];
|
||||
|
||||
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2]) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write sphericalTensorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 1 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const sphericalTensor& v = values[elemI];
|
||||
|
||||
os << float(v[0])
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write symmTensorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 6 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const symmTensor& v = values[elemI];
|
||||
|
||||
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
|
||||
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write tensorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 9 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const tensor& v = values[elemI];
|
||||
|
||||
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
|
||||
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
|
||||
<< float(v[6]) << ' ' << float(v[7]) << ' ' << float(v[8])
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
Foam::vtk<Type>::vtk()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::vtk<Type>::~vtk()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".vtk");
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
}
|
||||
|
||||
OFstream vtkFile(planeFName);
|
||||
|
||||
writeGeometry(points, faces, vtkFile);
|
||||
|
||||
writeData(fieldName, points, values, vtkFile);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
154
src/sampling/surfaceWriters/vtk/vtk.H
Normal file
154
src/sampling/surfaceWriters/vtk/vtk.H
Normal file
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
vtk
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
vtk.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtk_H
|
||||
#define vtk_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtk Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class vtk
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("vtk");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
vtk();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~vtk();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "vtk.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
43
src/sampling/surfaceWriters/vtk/vtkWriters.C
Normal file
43
src/sampling/surfaceWriters/vtk/vtkWriters.C
Normal file
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(vtk);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/sampling/surfaceWriters/vtk/vtkWriters.H
Normal file
63
src/sampling/surfaceWriters/vtk/vtkWriters.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
vtkWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
vtkWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkWriters_H
|
||||
#define vtkWriters_H
|
||||
|
||||
#include "vtk.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef vtk<scalar> vtkScalarWriter;
|
||||
typedef vtk<vector> vtkVectorWriter;
|
||||
typedef vtk<sphericalTensor> vtkSphericalTensorWriter;
|
||||
typedef vtk<symmTensor> vtkSymmTensorWriter;
|
||||
typedef vtk<tensor> vtkTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user