mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: sampling on triSurfaceMesh
sampledTriSurfaceMesh adds sampling on points/triangles of a triSurface(mesh). All values outside mesh are set to 0.
This commit is contained in:
@ -118,9 +118,7 @@ sets
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Surface sampling definition: choice of
|
// Surface sampling definition
|
||||||
// plane : values on plane defined by point, normal.
|
|
||||||
// patch : values on patch.
|
|
||||||
//
|
//
|
||||||
// 1] patches are not triangulated by default
|
// 1] patches are not triangulated by default
|
||||||
// 2] planes are always triangulated
|
// 2] planes are always triangulated
|
||||||
@ -209,6 +207,28 @@ surfaces
|
|||||||
// regularise false; // Optional: do not simplify
|
// regularise false; // Optional: do not simplify
|
||||||
}
|
}
|
||||||
|
|
||||||
|
distance
|
||||||
|
{
|
||||||
|
// Isosurface from signed/unsigned distance to surface
|
||||||
|
type distanceSurface;
|
||||||
|
signed true;
|
||||||
|
|
||||||
|
// Definition of surface
|
||||||
|
surfaceType triSurfaceMesh;
|
||||||
|
surfaceName integrationPlane.stl;
|
||||||
|
// Distance to surface
|
||||||
|
distance 0.0;
|
||||||
|
|
||||||
|
interpolate false;
|
||||||
|
}
|
||||||
|
|
||||||
|
triSurfaceSampling
|
||||||
|
{
|
||||||
|
// Sampling on triSurface
|
||||||
|
type sampledTriSurfaceMesh;
|
||||||
|
surface integrationPlane.stl;
|
||||||
|
interpolate true;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ sampledSurface/sampledSurface/sampledSurface.C
|
|||||||
sampledSurface/sampledSurfaces/sampledSurfaces.C
|
sampledSurface/sampledSurfaces/sampledSurfaces.C
|
||||||
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
|
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
|
||||||
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
|
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
|
||||||
|
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
|
||||||
sampledSurface/thresholdCellFaces/thresholdCellFaces.C
|
sampledSurface/thresholdCellFaces/thresholdCellFaces.C
|
||||||
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
|
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,353 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 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 "sampledTriSurfaceMesh.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "polyPatch.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "meshSearch.H"
|
||||||
|
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(sampledTriSurfaceMesh, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
sampledSurface,
|
||||||
|
sampledTriSurfaceMesh,
|
||||||
|
word
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& surfaceName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
sampledSurface(name, mesh),
|
||||||
|
surface_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
mesh.time().constant(), // instance
|
||||||
|
"triSurface", // local
|
||||||
|
mesh, // registry
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
needsUpdate_(true),
|
||||||
|
cellLabels_(0),
|
||||||
|
pointMap_(0),
|
||||||
|
faceMap_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
sampledSurface(name, mesh, dict),
|
||||||
|
surface_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
dict.lookup("surface"),
|
||||||
|
mesh.time().constant(), // instance
|
||||||
|
"triSurface", // local
|
||||||
|
mesh, // registry
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
),
|
||||||
|
needsUpdate_(true),
|
||||||
|
cellLabels_(0),
|
||||||
|
pointMap_(0),
|
||||||
|
faceMap_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::sampledTriSurfaceMesh::~sampledTriSurfaceMesh()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::sampledTriSurfaceMesh::needsUpdate() const
|
||||||
|
{
|
||||||
|
return needsUpdate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::sampledTriSurfaceMesh::expire()
|
||||||
|
{
|
||||||
|
// already marked as expired
|
||||||
|
if (needsUpdate_)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sampledSurface::clearGeom();
|
||||||
|
MeshStorage::clear();
|
||||||
|
cellLabels_.clear();
|
||||||
|
pointMap_.clear();
|
||||||
|
faceMap_.clear();
|
||||||
|
|
||||||
|
needsUpdate_ = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::sampledTriSurfaceMesh::update()
|
||||||
|
{
|
||||||
|
if (!needsUpdate_)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Find the cells the triangles of the surface are in.
|
||||||
|
// Does approximation by looking at the face centres only
|
||||||
|
const pointField fc = surface_.faceCentres();
|
||||||
|
|
||||||
|
cellLabels_.setSize(fc.size());
|
||||||
|
|
||||||
|
meshSearch meshSearcher(mesh(), false);
|
||||||
|
|
||||||
|
forAll(fc, triI)
|
||||||
|
{
|
||||||
|
cellLabels_[triI] = meshSearcher.findCell
|
||||||
|
(
|
||||||
|
fc[triI],
|
||||||
|
-1, // seed
|
||||||
|
true // use tree
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boolList include(surface_.size(), true);
|
||||||
|
|
||||||
|
label nNotFound = 0;
|
||||||
|
|
||||||
|
forAll(cellLabels_, triI)
|
||||||
|
{
|
||||||
|
if (cellLabels_[triI] == -1)
|
||||||
|
{
|
||||||
|
include[triI] = false;
|
||||||
|
nNotFound++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
label nTotalNotFound = returnReduce(nNotFound, sumOp<label>());
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "surface:" << surface_.size()
|
||||||
|
<< " included:" << surface_.size()-nNotFound
|
||||||
|
<< " total not found" << nTotalNotFound << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add to master all triangles are outside all meshes.
|
||||||
|
{
|
||||||
|
boolList onAnyProc(surface_.size(), false);
|
||||||
|
Pstream::listCombineGather(onAnyProc, orEqOp<bool>());
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
label nAdded = 0;
|
||||||
|
forAll(onAnyProc, triI)
|
||||||
|
{
|
||||||
|
if (!onAnyProc[triI])
|
||||||
|
{
|
||||||
|
include[triI] = true;
|
||||||
|
nAdded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "nAdded to master:" << nAdded << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Now subset the surface
|
||||||
|
triSurface localSurface
|
||||||
|
(
|
||||||
|
surface_.subsetMesh
|
||||||
|
(
|
||||||
|
include,
|
||||||
|
pointMap_,
|
||||||
|
faceMap_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// And convert into faces.
|
||||||
|
faceList& faces = this->storedFaces();
|
||||||
|
faces.setSize(localSurface.size());
|
||||||
|
forAll(localSurface, i)
|
||||||
|
{
|
||||||
|
faces[i] = localSurface[i].triFaceFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
this->storedPoints() = localSurface.points();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
print(Pout);
|
||||||
|
Pout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
needsUpdate_ = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::scalarField>
|
||||||
|
Foam::sampledTriSurfaceMesh::sample
|
||||||
|
(
|
||||||
|
const volScalarField& vField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(vField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::vectorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::sample
|
||||||
|
(
|
||||||
|
const volVectorField& vField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(vField);
|
||||||
|
}
|
||||||
|
|
||||||
|
Foam::tmp<Foam::sphericalTensorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::sample
|
||||||
|
(
|
||||||
|
const volSphericalTensorField& vField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(vField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::symmTensorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::sample
|
||||||
|
(
|
||||||
|
const volSymmTensorField& vField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(vField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::tensorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::sample
|
||||||
|
(
|
||||||
|
const volTensorField& vField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return sampleField(vField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::scalarField>
|
||||||
|
Foam::sampledTriSurfaceMesh::interpolate
|
||||||
|
(
|
||||||
|
const interpolation<scalar>& interpolator
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return interpolateField(interpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::vectorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::interpolate
|
||||||
|
(
|
||||||
|
const interpolation<vector>& interpolator
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return interpolateField(interpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
Foam::tmp<Foam::sphericalTensorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::interpolate
|
||||||
|
(
|
||||||
|
const interpolation<sphericalTensor>& interpolator
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return interpolateField(interpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::symmTensorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::interpolate
|
||||||
|
(
|
||||||
|
const interpolation<symmTensor>& interpolator
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return interpolateField(interpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::tensorField>
|
||||||
|
Foam::sampledTriSurfaceMesh::interpolate
|
||||||
|
(
|
||||||
|
const interpolation<tensor>& interpolator
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return interpolateField(interpolator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sampledTriSurfaceMesh::print(Ostream& os) const
|
||||||
|
{
|
||||||
|
os << "sampledTriSurfaceMesh: " << name() << " :"
|
||||||
|
<< " surface:" << surface_.objectRegistry::name()
|
||||||
|
<< " faces:" << faces().size()
|
||||||
|
<< " points:" << points().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,241 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 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::sampledTriSurfaceMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
A sampledSurface from a triSurfaceMesh. It samples on the points/triangles
|
||||||
|
of the triSurface.
|
||||||
|
|
||||||
|
In parallel every processor just operates on the part of the surface
|
||||||
|
where the face centres are inside the mesh. It is then up to the
|
||||||
|
caller to stitch the partial surfaces together.
|
||||||
|
|
||||||
|
No check is done for triangle centres being on multiple processors
|
||||||
|
(should never happen but truncation errors ...)
|
||||||
|
|
||||||
|
Any value on a triangle outside the mesh will be set to 0.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sampledTriSurfaceMesh.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sampledTriSurfaceMesh_H
|
||||||
|
#define sampledTriSurfaceMesh_H
|
||||||
|
|
||||||
|
#include "sampledSurface.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
#include "MeshedSurface.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sampledTriSurfaceMesh Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sampledTriSurfaceMesh
|
||||||
|
:
|
||||||
|
public sampledSurface,
|
||||||
|
public MeshedSurface<face>
|
||||||
|
{
|
||||||
|
//- Private typedefs for convenience
|
||||||
|
typedef MeshedSurface<face> MeshStorage;
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Surface to sample on
|
||||||
|
const triSurfaceMesh surface_;
|
||||||
|
|
||||||
|
//- Track if the surface needs an update
|
||||||
|
mutable bool needsUpdate_;
|
||||||
|
|
||||||
|
//- Local cell labels
|
||||||
|
labelList cellLabels_;
|
||||||
|
|
||||||
|
//- From local surface back to surface_
|
||||||
|
labelList pointMap_;
|
||||||
|
|
||||||
|
//- From local surface back to surface_
|
||||||
|
labelList faceMap_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- 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("sampledTriSurfaceMesh");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
sampledTriSurfaceMesh
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const word& surfaceName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
sampledTriSurfaceMesh
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~sampledTriSurfaceMesh();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Does the surface need an update?
|
||||||
|
virtual bool needsUpdate() const;
|
||||||
|
|
||||||
|
//- Mark the surface as needing an update.
|
||||||
|
// May also free up unneeded data.
|
||||||
|
// Return false if surface was already marked as expired.
|
||||||
|
virtual bool expire();
|
||||||
|
|
||||||
|
//- Update the surface as required.
|
||||||
|
// Do nothing (and return false) if no update was needed
|
||||||
|
virtual bool update();
|
||||||
|
|
||||||
|
|
||||||
|
//- Points of surface
|
||||||
|
virtual const pointField& points() const
|
||||||
|
{
|
||||||
|
return MeshStorage::points();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Faces of surface
|
||||||
|
virtual const faceList& faces() const
|
||||||
|
{
|
||||||
|
return MeshStorage::faces();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- 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
|
||||||
|
virtual void print(Ostream&) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "sampledTriSurfaceMeshTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 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 "sampledTriSurfaceMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type> >
|
||||||
|
Foam::sampledTriSurfaceMesh::sampleField
|
||||||
|
(
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// One value per face
|
||||||
|
tmp<Field<Type> > tvalues(new Field<Type>(faceMap_.size()));
|
||||||
|
Field<Type>& values = tvalues();
|
||||||
|
|
||||||
|
forAll(faceMap_, i)
|
||||||
|
{
|
||||||
|
label cellI = cellLabels_[faceMap_[i]];
|
||||||
|
if (cellI != -1)
|
||||||
|
{
|
||||||
|
values[i] = vField[cellI];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values[i] = pTraits<Type>::zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tvalues;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type> >
|
||||||
|
Foam::sampledTriSurfaceMesh::interpolateField
|
||||||
|
(
|
||||||
|
const interpolation<Type>& interpolator
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// One value per vertex
|
||||||
|
tmp<Field<Type> > tvalues(new Field<Type>(pointMap_.size()));
|
||||||
|
Field<Type>& values = tvalues();
|
||||||
|
|
||||||
|
forAll(pointMap_, i)
|
||||||
|
{
|
||||||
|
label origPointI = pointMap_[i];
|
||||||
|
label origTriI = surface_.pointFaces()[origPointI][0];
|
||||||
|
|
||||||
|
label cellI = cellLabels_[origTriI];
|
||||||
|
|
||||||
|
if (cellI != -1)
|
||||||
|
{
|
||||||
|
values[i] = interpolator.interpolate(points()[i], cellI);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values[i] = pTraits<Type>::zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tvalues;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user