mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improvements in the surface sampling infrastructure
- improvement documentation for surface sampling.
- can now specify alternative sampling scheme for obtaining the
face values instead of just using the "cell" value. For example,
sampleScheme cellPoint;
This can be useful for cases when the surface is close to a boundary
cell and there are large gradients in the sampled field.
- distanceSurface now handles non-closed surfaces more robustly.
Unknown regions (not inside or outside) are marked internally and
excluded from consideration. This allows use of 'signed' surfaces
where not previously possible.
This commit is contained in:
@ -35,9 +35,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(pointMesh, 0);
|
||||
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -88,18 +86,6 @@ Foam::pointMesh::pointMesh(const polyMesh& pMesh)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointMesh::~pointMesh()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "~pointMesh::pointMesh()"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::pointMesh::movePoints()
|
||||
@ -121,8 +107,7 @@ void Foam::pointMesh::updateMesh(const mapPolyMesh& mpm)
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "pointMesh::updateMesh(const mapPolyMesh&): "
|
||||
<< "Updating for topology changes." << endl;
|
||||
Pout<< endl;
|
||||
<< "Updating for topology changes." << nl << endl;
|
||||
}
|
||||
boundary_.updateMesh();
|
||||
|
||||
|
||||
@ -60,13 +60,13 @@ class pointMesh
|
||||
// Private Member Functions
|
||||
|
||||
//- Map all fields
|
||||
void mapFields(const mapPolyMesh&);
|
||||
void mapFields(const mapPolyMesh& mpm);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pointMesh(const pointMesh&);
|
||||
//- No copy construct
|
||||
pointMesh(const pointMesh&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pointMesh&);
|
||||
//- No copy assignment
|
||||
void operator=(const pointMesh&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -86,7 +86,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
~pointMesh();
|
||||
~pointMesh() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -34,15 +34,11 @@ void Foam::plane::calcPntAndVec(const scalarList& C)
|
||||
{
|
||||
point_ = vector((-C[3]/C[0]), 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mag(C[1]) > VSMALL)
|
||||
else if (mag(C[1]) > VSMALL)
|
||||
{
|
||||
point_ = vector(0, (-C[3]/C[1]), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mag(C[2]) > VSMALL)
|
||||
else if (mag(C[2]) > VSMALL)
|
||||
{
|
||||
point_ = vector(0, 0, (-C[3]/C[2]));
|
||||
}
|
||||
@ -52,8 +48,6 @@ void Foam::plane::calcPntAndVec(const scalarList& C)
|
||||
<< "At least one plane coefficient must have a value"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
normal_ = vector(C[0], C[1], C[2]);
|
||||
scalar magUnitVector(mag(normal_));
|
||||
@ -127,7 +121,7 @@ Foam::plane::plane(const vector& normalVector)
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "plane normal has zero length. basePoint:" << point_
|
||||
<< "plane normal has zero length. base point:" << point_
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -148,7 +142,7 @@ Foam::plane::plane
|
||||
if (magSqrNormalVector < VSMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "plane normal has zero length. basePoint:" << point_
|
||||
<< "plane normal has zero length. base point:" << point_
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
@ -247,7 +241,7 @@ Foam::plane::plane(Istream& is)
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "plane normal has zero length. basePoint:" << point_
|
||||
<< "plane normal has zero length. base point:" << point_
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,40 @@ Description
|
||||
Geometric class that creates a 3D plane and can return the intersection
|
||||
point between a line and the plane.
|
||||
|
||||
Construction from a dictionary is driven by the \c planeType
|
||||
|
||||
For \c planeType as \c pointAndNormal :
|
||||
\verbatim
|
||||
pointAndNormalDict
|
||||
{
|
||||
point <point>; // or basePoint
|
||||
normal <vector>; // or normalVector
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
For \c planeType as \c embeddedPoints :
|
||||
\verbatim
|
||||
embeddedPointsDict
|
||||
{
|
||||
point1 <point>;
|
||||
point2 <point>;
|
||||
point3 <point>;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
For \c planeType with \c planeEquation coefficients
|
||||
\f$ ax + by + cz + d = 0 \f$ :
|
||||
|
||||
\verbatim
|
||||
planeEquationDict
|
||||
{
|
||||
a <scalar>;
|
||||
b <scalar>;
|
||||
c <scalar>;
|
||||
d <scalar>;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
plane.C
|
||||
|
||||
@ -63,10 +97,11 @@ public:
|
||||
//- Side of the plane
|
||||
enum side
|
||||
{
|
||||
NORMAL,
|
||||
FLIP
|
||||
NORMAL = 1, //!< The front (or normal) side of the plane
|
||||
FLIP = -1 //!< The back (or flip) side of the plane
|
||||
};
|
||||
|
||||
|
||||
//- A direction and a reference point
|
||||
class ray
|
||||
{
|
||||
@ -126,10 +161,12 @@ public:
|
||||
//- Construct null. Does not set normal and point.
|
||||
plane();
|
||||
|
||||
//- Construct from normal vector through the origin
|
||||
//- Construct from normal vector through the origin.
|
||||
// The vector is normalised to a unit vector on input.
|
||||
explicit plane(const vector& normalVector);
|
||||
|
||||
//- Construct from normal vector and point in plane
|
||||
//- Construct from normal vector and point in plane.
|
||||
// By default, the vector is normalised to a unit vector on input.
|
||||
explicit plane
|
||||
(
|
||||
const point& basePoint,
|
||||
@ -150,7 +187,7 @@ public:
|
||||
explicit plane(const scalarList& C);
|
||||
|
||||
//- Construct from dictionary
|
||||
explicit plane(const dictionary& planeDict);
|
||||
explicit plane(const dictionary& dict);
|
||||
|
||||
//- Construct from Istream. Assumes the base + normal notation.
|
||||
explicit plane(Istream& is);
|
||||
|
||||
@ -45,7 +45,7 @@ Description
|
||||
\endtable
|
||||
|
||||
The values are assigned according to the phase-fraction field:
|
||||
- 1: apply \$fp_{hyd}\$f
|
||||
- 1: apply \f$p_{hyd}\f$
|
||||
- 0: apply a zero-gradient condition
|
||||
|
||||
Usage
|
||||
|
||||
@ -113,11 +113,11 @@ class volPointInterpolation
|
||||
GeometricField<Type, pointPatchField, pointMesh>&
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
volPointInterpolation(const volPointInterpolation&);
|
||||
//- No copy construct
|
||||
volPointInterpolation(const volPointInterpolation&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const volPointInterpolation&);
|
||||
//- No copy assignment
|
||||
void operator=(const volPointInterpolation&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -147,10 +147,10 @@ public:
|
||||
bool movePoints();
|
||||
|
||||
|
||||
// Interpolation functions
|
||||
// Interpolation Functions
|
||||
|
||||
//- Interpolate volField using inverse distance weighting
|
||||
// returning pointField
|
||||
// \return pointField
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> interpolate
|
||||
(
|
||||
@ -158,7 +158,7 @@ public:
|
||||
) const;
|
||||
|
||||
//- Interpolate tmp<volField> using inverse distance weighting
|
||||
// returning pointField
|
||||
// \return pointField
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> interpolate
|
||||
(
|
||||
@ -188,7 +188,7 @@ public:
|
||||
) const;
|
||||
|
||||
//- Interpolate dimensionedField using inverse distance weighting
|
||||
// returning pointField
|
||||
// \return pointField
|
||||
template<class Type>
|
||||
tmp<DimensionedField<Type, pointMesh>> interpolate
|
||||
(
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,7 @@ License
|
||||
#include "volFields.H"
|
||||
#include "sampledSurface.H"
|
||||
#include "surfaceWriter.H"
|
||||
#include "interpolationCell.H"
|
||||
#include "interpolationCellPoint.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
@ -100,18 +101,15 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
|
||||
// Average
|
||||
const faceList& faces = surfacePtr_().faces();
|
||||
tmp<Field<Type>> tavg
|
||||
(
|
||||
new Field<Type>(faces.size(), Zero)
|
||||
);
|
||||
Field<Type>& avg = tavg.ref();
|
||||
auto tavg = tmp<Field<Type>>::New(faces.size(), Zero);
|
||||
auto& avg = tavg.ref();
|
||||
|
||||
forAll(faces, facei)
|
||||
{
|
||||
const face& f = faces[facei];
|
||||
forAll(f, fp)
|
||||
for (const label labi : f)
|
||||
{
|
||||
avg[facei] += intFld[f[fp]];
|
||||
avg[facei] += intFld[labi];
|
||||
}
|
||||
avg[facei] /= f.size();
|
||||
}
|
||||
@ -120,7 +118,9 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
|
||||
}
|
||||
else
|
||||
{
|
||||
return surfacePtr_().sample(fld);
|
||||
const interpolationCell<Type> interp(fld);
|
||||
|
||||
return surfacePtr_().sample(interp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -19,22 +19,24 @@ sampledSet/array/arraySet.C
|
||||
sampledSet/shortestPath/shortestPathSet.C
|
||||
|
||||
surface/cuttingPlane/cuttingPlane.C
|
||||
surface/distanceSurface/distanceSurface.C
|
||||
surface/isoSurface/isoSurface.C
|
||||
surface/isoSurface/isoSurfaceCell.C
|
||||
surface/thresholdCellFaces/thresholdCellFaces.C
|
||||
surface/triSurfaceMesh/discreteSurface.C
|
||||
|
||||
surfMeshSampler/surfMeshSampler/surfMeshSampler.C
|
||||
surfMeshSampler/surfMeshSamplers/surfMeshSamplers.C
|
||||
surfMeshSampler/plane/surfMeshPlaneSampler.C
|
||||
surfMeshSampler/triSurfaceMesh/surfMeshDiscreteSampler.C
|
||||
surfMeshSample/surfMeshSample/surfMeshSample.C
|
||||
surfMeshSample/surfMeshSamplers/surfMeshSamplers.C
|
||||
surfMeshSample/distanceSurface/surfMeshSampleDistanceSurface.C
|
||||
surfMeshSample/plane/surfMeshSamplePlane.C
|
||||
surfMeshSample/triSurfaceMesh/surfMeshSampleDiscrete.C
|
||||
|
||||
sampledSurface/sampledPatch/sampledPatch.C
|
||||
sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C
|
||||
sampledSurface/sampledPlane/sampledPlane.C
|
||||
sampledSurface/isoSurface/sampledIsoSurface.C
|
||||
sampledSurface/isoSurface/sampledIsoSurfaceCell.C
|
||||
sampledSurface/distanceSurface/distanceSurface.C
|
||||
sampledSurface/distanceSurface/sampledDistanceSurface.C
|
||||
sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C
|
||||
sampledSurface/sampledSurface/sampledSurface.C
|
||||
sampledSurface/sampledSurfaces/sampledSurfaces.C
|
||||
|
||||
@ -214,8 +214,7 @@ Foam::label Foam::probes::prepare()
|
||||
{
|
||||
probeDir = mesh_.time().path()/probeSubDir;
|
||||
}
|
||||
// Remove ".."
|
||||
probeDir.clean();
|
||||
probeDir.clean(); // Remove unneeded ".."
|
||||
|
||||
// ignore known fields, close streams for fields that no longer exist
|
||||
forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)
|
||||
|
||||
@ -109,8 +109,7 @@ Foam::sampledSets::sampledSets
|
||||
{
|
||||
outputPath_ = outputPath_/mesh_.name();
|
||||
}
|
||||
// Remove ".."
|
||||
outputPath_.clean();
|
||||
outputPath_.clean(); // Remove unneeded ".."
|
||||
|
||||
read(dict);
|
||||
}
|
||||
@ -145,8 +144,7 @@ Foam::sampledSets::sampledSets
|
||||
{
|
||||
outputPath_ = outputPath_/mesh_.name();
|
||||
}
|
||||
// Remove ".."
|
||||
outputPath_.clean();
|
||||
outputPath_.clean(); // Remove unneeded ".."
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -0,0 +1,211 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sampledDistanceSurface.H"
|
||||
#include "dictionary.H"
|
||||
#include "volFields.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volumeType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledDistanceSurface, 0);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
sampledSurface,
|
||||
sampledDistanceSurface,
|
||||
word,
|
||||
distanceSurface
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledDistanceSurface::sampledDistanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampledSurface(name, mesh, dict),
|
||||
distanceSurface(name, mesh, dict),
|
||||
average_(dict.lookupOrDefault("average", false)),
|
||||
needsUpdate_(true)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sampledDistanceSurface::needsUpdate() const
|
||||
{
|
||||
return needsUpdate_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sampledDistanceSurface::expire()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "sampledDistanceSurface::expire :"
|
||||
<< " needsUpdate:" << needsUpdate_ << endl;
|
||||
}
|
||||
|
||||
// Clear derived data
|
||||
clearGeom();
|
||||
|
||||
// already marked as expired
|
||||
if (needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
needsUpdate_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sampledDistanceSurface::update()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "sampledDistanceSurface::update :"
|
||||
<< " needsUpdate:" << needsUpdate_ << endl;
|
||||
}
|
||||
|
||||
if (!needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
distanceSurface::createGeometry();
|
||||
|
||||
needsUpdate_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledDistanceSurface::sample
|
||||
(
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledDistanceSurface::sample
|
||||
(
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledDistanceSurface::sample
|
||||
(
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledDistanceSurface::sample
|
||||
(
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledDistanceSurface::sample
|
||||
(
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledDistanceSurface::interpolate
|
||||
(
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledDistanceSurface::interpolate
|
||||
(
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledDistanceSurface::interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledDistanceSurface::interpolate
|
||||
(
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledDistanceSurface::interpolate
|
||||
(
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledDistanceSurface::print(Ostream& os) const
|
||||
{
|
||||
os << "distanceSurface: " << name() << " :";
|
||||
distanceSurface::print(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -22,25 +22,51 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::distanceSurface
|
||||
Foam::sampledDistanceSurface
|
||||
|
||||
Description
|
||||
A sampledSurface defined by a distance to a surface.
|
||||
A sampledSurface defined by a distance to a surface - using either
|
||||
an isoSurfaceCell or an isoSurface.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type dDistanceSurface;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | distanceSurface | yes |
|
||||
distance | distance from surface | yes |
|
||||
signed | apply sign for +ve/-ve distance | yes |
|
||||
cell | use isoSurfaceCell algorithm | no | true
|
||||
regularise | point snapping | yes |
|
||||
average | cell values from averaged point values | no | false
|
||||
bounds | limit with bounding box | no |
|
||||
surfaceType | type of surface | yes |
|
||||
surfaceName | name of surface in triSurface/ | no | dict name
|
||||
\endtable
|
||||
|
||||
Uses either isoSurfaceCell or isoSurface.
|
||||
|
||||
SourceFiles
|
||||
distanceSurface.C
|
||||
sampledDistanceSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef distanceSurface_H
|
||||
#define distanceSurface_H
|
||||
#ifndef sampledDistanceSurface_H
|
||||
#define sampledDistanceSurface_H
|
||||
|
||||
#include "sampledSurface.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "isoSurfaceCell.H"
|
||||
#include "isoSurface.H"
|
||||
#include "distanceSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -48,109 +74,59 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class distanceSurface Declaration
|
||||
Class sampledDistanceSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class distanceSurface
|
||||
class sampledDistanceSurface
|
||||
:
|
||||
public sampledSurface
|
||||
public sampledSurface,
|
||||
public distanceSurface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Surface
|
||||
const autoPtr<searchableSurface> surfPtr_;
|
||||
|
||||
//- Distance value
|
||||
const scalar distance_;
|
||||
|
||||
//- Signed distance
|
||||
const bool signed_;
|
||||
|
||||
//- Whether to use isoSurfaceCell or isoSurface
|
||||
const bool cell_;
|
||||
|
||||
//- Whether to coarsen
|
||||
const Switch regularise_;
|
||||
|
||||
//- Whether to recalculate cell values as average of point values
|
||||
const Switch average_;
|
||||
|
||||
//- Optional bounding box to trim triangles against
|
||||
const boundBox bounds_;
|
||||
|
||||
//- If restricted to zones, name of this zone or a regular expression
|
||||
keyType zoneKey_;
|
||||
|
||||
//- Track if the surface needs an update
|
||||
mutable bool needsUpdate_;
|
||||
|
||||
|
||||
//- Distance to cell centres
|
||||
autoPtr<volScalarField> cellDistancePtr_;
|
||||
|
||||
//- Distance to points
|
||||
scalarField pointDistance_;
|
||||
|
||||
//- Constructed iso surface
|
||||
autoPtr<isoSurfaceCell> isoSurfCellPtr_;
|
||||
|
||||
//- Constructed iso surface
|
||||
autoPtr<isoSurface> isoSurfPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Create iso surface
|
||||
void createGeometry();
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolation
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("distanceSurface");
|
||||
TypeName("sampledDistanceSurface");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
distanceSurface
|
||||
sampledDistanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
distanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const bool interpolate,
|
||||
const word& surfaceType,
|
||||
const word& surfaceName,
|
||||
const scalar distance,
|
||||
const bool signedDistance,
|
||||
const bool cell,
|
||||
const Switch regularise,
|
||||
const Switch average,
|
||||
const boundBox& bounds = boundBox::invertedBox
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~distanceSurface();
|
||||
virtual ~sampledDistanceSurface() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -204,81 +180,76 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- The underlying surface
|
||||
const meshedSurface& surface() const
|
||||
{
|
||||
if (cell_)
|
||||
{
|
||||
return *isoSurfCellPtr_;
|
||||
}
|
||||
// Sample
|
||||
|
||||
return *isoSurfPtr_;
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
// Output
|
||||
|
||||
//- Print information
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
@ -289,7 +260,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "distanceSurfaceTemplates.C"
|
||||
#include "sampledDistanceSurfaceTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,7 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "distanceSurface.H"
|
||||
#include "sampledDistanceSurface.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFields.H"
|
||||
#include "volPointInterpolation.H"
|
||||
@ -32,71 +32,39 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::distanceSurface::sampleField
|
||||
Foam::sampledDistanceSurface::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
if (cell_)
|
||||
{
|
||||
return tmp<Field<Type>>
|
||||
return sampledSurface::sampleOnFaces
|
||||
(
|
||||
new Field<Type>(vField, isoSurfCellPtr_().meshCells())
|
||||
sampler,
|
||||
meshCells(),
|
||||
faces(),
|
||||
points()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return tmp<Field<Type>>
|
||||
(
|
||||
new Field<Type>(vField, isoSurfPtr_().meshCells())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::distanceSurface::interpolateField
|
||||
Foam::sampledDistanceSurface::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
|
||||
// Assume volPointInterpolation for the point field!
|
||||
const auto& volFld = interpolator.psi();
|
||||
|
||||
// Get fields to sample. Assume volPointInterpolation!
|
||||
const GeometricField<Type, fvPatchField, volMesh>& volFld =
|
||||
interpolator.psi();
|
||||
auto tpointFld =
|
||||
volPointInterpolation::New(volFld.mesh()).interpolate(volFld);
|
||||
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> pointFld
|
||||
return distanceSurface::interpolate
|
||||
(
|
||||
volPointInterpolation::New(fvm).interpolate(volFld)
|
||||
(average_ ? pointAverage(tpointFld())() : volFld),
|
||||
tpointFld()
|
||||
);
|
||||
|
||||
// Sample.
|
||||
if (cell_)
|
||||
{
|
||||
return isoSurfCellPtr_().interpolate
|
||||
(
|
||||
(
|
||||
average_
|
||||
? pointAverage(pointFld())()
|
||||
: volFld
|
||||
),
|
||||
pointFld()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return isoSurfPtr_().interpolate
|
||||
(
|
||||
(
|
||||
average_
|
||||
? pointAverage(pointFld())()
|
||||
: volFld
|
||||
),
|
||||
pointFld()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -538,13 +538,13 @@ bool Foam::sampledIsoSurface::expire()
|
||||
// Clear derived data
|
||||
clearGeom();
|
||||
|
||||
// already marked as expired
|
||||
// Already marked as expired
|
||||
if (prevTimeIndex_ == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// force update
|
||||
// Force update
|
||||
prevTimeIndex_ = -1;
|
||||
return true;
|
||||
}
|
||||
@ -558,46 +558,46 @@ bool Foam::sampledIsoSurface::update()
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledIsoSurface::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledIsoSurface::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledIsoSurface::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledIsoSurface::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledIsoSurface::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -606,7 +606,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledIsoSurface::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -615,7 +615,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledIsoSurface::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledIsoSurface::interpolate
|
||||
@ -623,7 +623,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledIsoSurface::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -632,7 +632,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledIsoSurface::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -641,7 +641,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledIsoSurface::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,6 +29,35 @@ Description
|
||||
To be used in sampleSurfaces / functionObjects. Recalculates iso surface
|
||||
only if time changes.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type sampledIsoSurface;
|
||||
cell false;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | sampledIsoSurface | yes |
|
||||
isoField | field name for obtaining iso-surface | yes |
|
||||
isoValue | value of iso-surface | yes |
|
||||
mergeTol | tolerance for merging points | no | 1e-6
|
||||
regularise | point snapping | yes |
|
||||
average | cell values from averaged point values | no | false
|
||||
bounds | limit with bounding box | no |
|
||||
zone | limit to specified zone | no |
|
||||
exposedPatchName | name for zone subset | partly |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
sampledIsoSurface.C
|
||||
|
||||
@ -109,7 +138,6 @@ class sampledIsoSurface
|
||||
mutable const pointScalarField* pointSubFieldPtr_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get fields needed to recreate iso surface.
|
||||
@ -119,17 +147,19 @@ class sampledIsoSurface
|
||||
// Do nothing (and return false) if no update was needed
|
||||
bool updateGeometry() const;
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -217,67 +247,67 @@ public:
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -51,7 +51,7 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
|
||||
{
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
|
||||
|
||||
// no update needed
|
||||
// No update needed
|
||||
if (fvm.time().timeIndex() == prevTimeIndex_)
|
||||
{
|
||||
return false;
|
||||
@ -62,36 +62,33 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
|
||||
// Clear derived data
|
||||
sampledSurface::clearGeom();
|
||||
|
||||
// Optionally read volScalarField
|
||||
autoPtr<volScalarField> readFieldPtr_;
|
||||
// Use field from database, or try to read it in
|
||||
|
||||
const auto* cellFldPtr = fvm.lookupObjectPtr<volScalarField>(isoField_);
|
||||
|
||||
// 1. see if field in database
|
||||
// 2. see if field can be read
|
||||
const volScalarField* cellFldPtr = nullptr;
|
||||
if (fvm.foundObject<volScalarField>(isoField_))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
if (cellFldPtr)
|
||||
{
|
||||
InfoInFunction << "Lookup " << isoField_ << endl;
|
||||
}
|
||||
|
||||
cellFldPtr = &fvm.lookupObject<volScalarField>(isoField_);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bit of a hack. Read field and store.
|
||||
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Reading " << isoField_
|
||||
<< " from time " <<fvm.time().timeName()
|
||||
<< " from time " << fvm.time().timeName()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
readFieldPtr_.reset
|
||||
(
|
||||
new volScalarField
|
||||
// For holding the volScalarField read in.
|
||||
autoPtr<volScalarField> fieldReadPtr;
|
||||
|
||||
if (!cellFldPtr)
|
||||
{
|
||||
// Bit of a hack. Read field and store.
|
||||
|
||||
fieldReadPtr = autoPtr<volScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -103,35 +100,29 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
|
||||
false
|
||||
),
|
||||
fvm
|
||||
)
|
||||
);
|
||||
|
||||
cellFldPtr = readFieldPtr_.operator->();
|
||||
}
|
||||
const volScalarField& cellFld = *cellFldPtr;
|
||||
|
||||
tmp<pointScalarField> pointFld
|
||||
(
|
||||
volPointInterpolation::New(fvm).interpolate(cellFld)
|
||||
);
|
||||
const volScalarField& cellFld =
|
||||
(fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr);
|
||||
|
||||
auto tpointFld = volPointInterpolation::New(fvm).interpolate(cellFld);
|
||||
|
||||
if (average_)
|
||||
{
|
||||
//- From point field and interpolated cell.
|
||||
scalarField cellAvg(fvm.nCells(), scalar(0.0));
|
||||
labelField nPointCells(fvm.nCells(), 0);
|
||||
{
|
||||
for (label pointi = 0; pointi < fvm.nPoints(); pointi++)
|
||||
scalarField cellAvg(fvm.nCells(), Zero);
|
||||
labelField nPointCells(fvm.nCells(), Zero);
|
||||
|
||||
for (label pointi = 0; pointi < fvm.nPoints(); ++pointi)
|
||||
{
|
||||
const scalar& val = tpointFld().primitiveField()[pointi];
|
||||
const labelList& pCells = fvm.pointCells(pointi);
|
||||
|
||||
forAll(pCells, i)
|
||||
for (const label celli : pCells)
|
||||
{
|
||||
label celli = pCells[i];
|
||||
|
||||
cellAvg[celli] += pointFld().primitiveField()[pointi];
|
||||
nPointCells[celli]++;
|
||||
}
|
||||
cellAvg[celli] += val;
|
||||
++nPointCells[celli];
|
||||
}
|
||||
}
|
||||
forAll(cellAvg, celli)
|
||||
@ -139,11 +130,11 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
|
||||
cellAvg[celli] /= nPointCells[celli];
|
||||
}
|
||||
|
||||
isoSurfaceCell iso
|
||||
isoSurfaceCell surf
|
||||
(
|
||||
fvm,
|
||||
cellAvg,
|
||||
pointFld().primitiveField(),
|
||||
tpointFld().primitiveField(),
|
||||
isoVal_,
|
||||
regularise_,
|
||||
bounds_
|
||||
@ -152,17 +143,17 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
|
||||
const_cast<sampledIsoSurfaceCell&>
|
||||
(
|
||||
*this
|
||||
).transfer(static_cast<meshedSurface&>(iso));
|
||||
meshCells_ = iso.meshCells();
|
||||
).transfer(static_cast<meshedSurface&>(surf));
|
||||
meshCells_.transfer(surf.meshCells());
|
||||
}
|
||||
else
|
||||
{
|
||||
//- Direct from cell field and point field. Gives bad continuity.
|
||||
isoSurfaceCell iso
|
||||
isoSurfaceCell surf
|
||||
(
|
||||
fvm,
|
||||
cellFld.primitiveField(),
|
||||
pointFld().primitiveField(),
|
||||
tpointFld().primitiveField(),
|
||||
isoVal_,
|
||||
regularise_,
|
||||
bounds_
|
||||
@ -171,8 +162,8 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const
|
||||
const_cast<sampledIsoSurfaceCell&>
|
||||
(
|
||||
*this
|
||||
).transfer(static_cast<meshedSurface&>(iso));
|
||||
meshCells_ = iso.meshCells();
|
||||
).transfer(static_cast<meshedSurface&>(surf));
|
||||
meshCells_.transfer(surf.meshCells());
|
||||
}
|
||||
|
||||
|
||||
@ -212,7 +203,7 @@ Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
|
||||
average_(dict.lookupOrDefault("average", true)),
|
||||
zoneKey_(keyType::null),
|
||||
prevTimeIndex_(-1),
|
||||
meshCells_(0)
|
||||
meshCells_()
|
||||
{}
|
||||
|
||||
|
||||
@ -237,13 +228,13 @@ bool Foam::sampledIsoSurfaceCell::expire()
|
||||
// Clear derived data
|
||||
sampledSurface::clearGeom();
|
||||
|
||||
// already marked as expired
|
||||
// Already marked as expired
|
||||
if (prevTimeIndex_ == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// force update
|
||||
// Force update
|
||||
prevTimeIndex_ = -1;
|
||||
return true;
|
||||
}
|
||||
@ -258,50 +249,50 @@ bool Foam::sampledIsoSurfaceCell::update()
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::sampledIsoSurfaceCell::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField>
|
||||
Foam::sampledIsoSurfaceCell::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledIsoSurfaceCell::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField>
|
||||
Foam::sampledIsoSurfaceCell::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField>
|
||||
Foam::sampledIsoSurfaceCell::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +302,7 @@ Foam::sampledIsoSurfaceCell::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -321,7 +312,7 @@ Foam::sampledIsoSurfaceCell::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
@ -330,7 +321,7 @@ Foam::sampledIsoSurfaceCell::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +331,7 @@ Foam::sampledIsoSurfaceCell::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -350,7 +341,7 @@ Foam::sampledIsoSurfaceCell::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -29,6 +29,33 @@ Description
|
||||
To be used in sampleSurfaces / functionObjects. Recalculates iso surface
|
||||
only if time changes.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type sampledIsoSurfaceCell;
|
||||
cell true;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | sampledIsoSurfaceCell | yes |
|
||||
isoField | field name for obtaining iso-surface | yes |
|
||||
isoValue | value of iso-surface | yes |
|
||||
mergeTol | tolerance for merging points | no | 1e-6
|
||||
regularise | point snapping | yes |
|
||||
average | cell values from averaged point values | no | false
|
||||
bounds | limit with bounding box | no |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
sampledIsoSurfaceCell.C
|
||||
|
||||
@ -94,17 +121,19 @@ class sampledIsoSurfaceCell
|
||||
// Do nothing (and return false) if no update was needed
|
||||
bool updateGeometry() const;
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -180,65 +209,69 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
// Sample
|
||||
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,50 +33,57 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledIsoSurfaceCell::sampleField
|
||||
Foam::sampledIsoSurfaceCell::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
// Recreate geometry if time has changed
|
||||
updateGeometry();
|
||||
updateGeometry(); // Recreate geometry if time has changed
|
||||
|
||||
return tmp<Field<Type>>::New(vField, meshCells_);
|
||||
return sampledSurface::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
meshCells_,
|
||||
faces(),
|
||||
points()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledIsoSurfaceCell::interpolateField
|
||||
Foam::sampledIsoSurfaceCell::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// Recreate geometry if time has changed
|
||||
updateGeometry();
|
||||
updateGeometry(); // Recreate geometry if time has changed
|
||||
|
||||
const labelList& elements = meshCells_;
|
||||
|
||||
// One value per point
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(points().size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(points().size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
const faceList& fcs = faces();
|
||||
const pointField& pts = points();
|
||||
|
||||
bitSet pointDone(points().size());
|
||||
|
||||
forAll(faces(), cutFacei)
|
||||
{
|
||||
const face& f = faces()[cutFacei];
|
||||
const face& f = fcs[cutFacei];
|
||||
const label celli = elements[cutFacei];
|
||||
|
||||
forAll(f, faceVertI)
|
||||
for (const label pointi : f)
|
||||
{
|
||||
label pointi = f[faceVertI];
|
||||
|
||||
if (!pointDone[pointi])
|
||||
if (pointDone.set(pointi))
|
||||
{
|
||||
values[pointi] = interpolator.interpolate
|
||||
(
|
||||
points()[pointi],
|
||||
meshCells_[cutFacei]
|
||||
pts[pointi],
|
||||
celli
|
||||
);
|
||||
pointDone[pointi] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,70 +32,59 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledIsoSurface::sampleField
|
||||
Foam::sampledIsoSurface::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
// Recreate geometry if time has changed
|
||||
updateGeometry();
|
||||
updateGeometry(); // Recreate geometry if time has changed
|
||||
|
||||
return tmp<Field<Type>>::New(vField, surface().meshCells());
|
||||
return sampledSurface::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
surface().meshCells(),
|
||||
surface(),
|
||||
points()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledIsoSurface::interpolateField
|
||||
Foam::sampledIsoSurface::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// Get fields to sample. Assume volPointInterpolation!
|
||||
const GeometricField<Type, fvPatchField, volMesh>& volFld =
|
||||
interpolator.psi();
|
||||
updateGeometry(); // Recreate geometry if time has changed
|
||||
|
||||
// Recreate geometry if time has changed
|
||||
updateGeometry();
|
||||
// Assume volPointInterpolation for the point field!
|
||||
const auto& volFld = interpolator.psi();
|
||||
|
||||
if (subMeshPtr_.valid())
|
||||
{
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tvolSubFld =
|
||||
subMeshPtr_().interpolate(volFld);
|
||||
auto tvolSubFld = subMeshPtr_().interpolate(volFld);
|
||||
const auto& volSubFld = tvolSubFld();
|
||||
|
||||
const GeometricField<Type, fvPatchField, volMesh>& volSubFld =
|
||||
tvolSubFld();
|
||||
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> tpointSubFld =
|
||||
auto tpointFld =
|
||||
volPointInterpolation::New(volSubFld.mesh()).interpolate(volSubFld);
|
||||
|
||||
// Sample.
|
||||
return surface().interpolate
|
||||
(
|
||||
(
|
||||
average_
|
||||
? pointAverage(tpointSubFld())()
|
||||
: volSubFld
|
||||
),
|
||||
tpointSubFld()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> tpointFld =
|
||||
volPointInterpolation::New(volFld.mesh()).interpolate(volFld);
|
||||
|
||||
// Sample.
|
||||
return surface().interpolate
|
||||
(
|
||||
(
|
||||
average_
|
||||
? pointAverage(tpointFld())()
|
||||
: volFld
|
||||
),
|
||||
(average_ ? pointAverage(tpointFld())() : volSubFld),
|
||||
tpointFld()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
auto tpointFld =
|
||||
volPointInterpolation::New(volFld.mesh()).interpolate(volFld);
|
||||
|
||||
return surface().interpolate
|
||||
(
|
||||
(average_ ? pointAverage(tpointFld())() : volFld),
|
||||
tpointFld()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -164,21 +164,16 @@ Foam::tmp<Foam::Field<Type>> Foam::ensightSurfaceReader::readField
|
||||
}
|
||||
}
|
||||
|
||||
tmp<Field<Type>> tField(new Field<Type>(n, pTraits<Type>::zero));
|
||||
Field<Type>& field = tField.ref();
|
||||
auto tfield = tmp<Field<Type>>::New(n, Zero);
|
||||
auto& field = tfield.ref();
|
||||
|
||||
for
|
||||
(
|
||||
direction cmptI=0;
|
||||
cmptI < pTraits<Type>::nComponents;
|
||||
++cmptI
|
||||
)
|
||||
for (direction cmpti=0; cmpti < pTraits<Type>::nComponents; ++cmpti)
|
||||
{
|
||||
field.replace(cmptI, values[cmptI]);
|
||||
values[cmptI].clear();
|
||||
field.replace(cmpti, values[cmpti]);
|
||||
values[cmpti].clear();
|
||||
}
|
||||
|
||||
return tField;
|
||||
return tfield;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -386,50 +386,50 @@ bool Foam::sampledCuttingPlane::update()
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::sampledCuttingPlane::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField>
|
||||
Foam::sampledCuttingPlane::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledCuttingPlane::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField>
|
||||
Foam::sampledCuttingPlane::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField>
|
||||
Foam::sampledCuttingPlane::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -439,7 +439,7 @@ Foam::sampledCuttingPlane::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -449,16 +449,17 @@ Foam::sampledCuttingPlane::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
Foam::sampledCuttingPlane::interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -468,7 +469,7 @@ Foam::sampledCuttingPlane::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -478,7 +479,7 @@ Foam::sampledCuttingPlane::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,7 +26,41 @@ Class
|
||||
|
||||
Description
|
||||
A sampledSurface defined by a plane using the iso-surface algorithm
|
||||
to 'cut' the mesh.
|
||||
to \a cut the mesh.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type cuttingPlane;
|
||||
planeType pointAndNormal;
|
||||
pointAndNormalDict
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | cuttingPlane | yes |
|
||||
planeType | plane description (pointAndNormal etc) | yes |
|
||||
mergeTol | tolerance for merging points | no | 1e-6
|
||||
regularise | point snapping | no | true
|
||||
bounds | limit with bounding box | no |
|
||||
zone | limit to specified zone | no |
|
||||
exposedPatchName | name for zone subset | partly |
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::plane
|
||||
|
||||
SourceFiles
|
||||
sampledCuttingPlane.C
|
||||
@ -93,7 +127,7 @@ class sampledCuttingPlane
|
||||
scalarField pointDistance_;
|
||||
|
||||
//- Constructed iso surface
|
||||
//autoPtr<isoSurfaceCell> isoSurfPtr_;
|
||||
//autoPtr<isoSurfaceCell> isoSurfCellPtr_;
|
||||
autoPtr<isoSurface> isoSurfPtr_;
|
||||
|
||||
|
||||
@ -102,17 +136,19 @@ class sampledCuttingPlane
|
||||
//- Create iso surface
|
||||
void createGeometry();
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -193,76 +229,95 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- The underlying surface
|
||||
meshedSurface& surface()
|
||||
{
|
||||
return *isoSurfPtr_;
|
||||
}
|
||||
|
||||
//- For each face, the original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return isoSurfPtr_->meshCells();
|
||||
}
|
||||
|
||||
//- For each face, the original cell in mesh
|
||||
labelList& meshCells()
|
||||
{
|
||||
return isoSurfPtr_->meshCells();
|
||||
}
|
||||
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
//- Print information
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,66 +32,55 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledCuttingPlane::sampleField
|
||||
Foam::sampledCuttingPlane::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>::New(vField, surface().meshCells());
|
||||
return sampledSurface::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
meshCells(),
|
||||
faces(),
|
||||
points()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledCuttingPlane::interpolateField
|
||||
Foam::sampledCuttingPlane::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// Get fields to sample. Assume volPointInterpolation!
|
||||
const GeometricField<Type, fvPatchField, volMesh>& volFld =
|
||||
interpolator.psi();
|
||||
// Assume volPointInterpolation for the point field!
|
||||
const auto& volFld = interpolator.psi();
|
||||
|
||||
if (subMeshPtr_.valid())
|
||||
{
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tvolSubFld =
|
||||
subMeshPtr_().interpolate(volFld);
|
||||
auto tvolSubFld = subMeshPtr_().interpolate(volFld);
|
||||
const auto& volSubFld = tvolSubFld();
|
||||
|
||||
const GeometricField<Type, fvPatchField, volMesh>& volSubFld =
|
||||
tvolSubFld();
|
||||
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> tpointSubFld =
|
||||
auto tpointFld =
|
||||
volPointInterpolation::New(volSubFld.mesh()).interpolate(volSubFld);
|
||||
|
||||
// Sample.
|
||||
return surface().interpolate
|
||||
(
|
||||
(
|
||||
average_
|
||||
? pointAverage(tpointSubFld())()
|
||||
: volSubFld
|
||||
),
|
||||
tpointSubFld()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>> tpointFld
|
||||
(
|
||||
volPointInterpolation::New(volFld.mesh()).interpolate(volFld)
|
||||
);
|
||||
|
||||
// Sample.
|
||||
return surface().interpolate
|
||||
(
|
||||
(
|
||||
average_
|
||||
? pointAverage(tpointFld())()
|
||||
: volFld
|
||||
),
|
||||
(average_ ? pointAverage(tpointFld())() : volSubFld),
|
||||
tpointFld()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
auto tpointFld =
|
||||
volPointInterpolation::New(volFld.mesh()).interpolate(volFld);
|
||||
|
||||
return surface().interpolate
|
||||
(
|
||||
(average_ ? pointAverage(tpointFld())() : volFld),
|
||||
tpointFld()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -118,10 +118,8 @@ bool Foam::sampledPatch::update()
|
||||
}
|
||||
|
||||
label sz = 0;
|
||||
forAll(patchIDs(), i)
|
||||
for (const label patchi : patchIDs())
|
||||
{
|
||||
const label patchi = patchIDs()[i];
|
||||
|
||||
const polyPatch& pp = mesh().boundaryMesh()[patchi];
|
||||
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
@ -156,7 +154,7 @@ bool Foam::sampledPatch::update()
|
||||
patchIndex_[sz] = i;
|
||||
patchFaceLabels_[sz] = j;
|
||||
meshFaceLabels[sz] = pp.start()+j;
|
||||
sz++;
|
||||
++sz;
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,46 +222,46 @@ void Foam::sampledPatch::remapFaces(const labelUList& faceMap)
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledPatch::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledPatch::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledPatch::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -272,7 +270,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledPatch::sample
|
||||
const surfaceScalarField& sField
|
||||
) const
|
||||
{
|
||||
return sampleField(sField);
|
||||
return sampleOnFaces(sField);
|
||||
}
|
||||
|
||||
|
||||
@ -281,7 +279,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledPatch::sample
|
||||
const surfaceVectorField& sField
|
||||
) const
|
||||
{
|
||||
return sampleField(sField);
|
||||
return sampleOnFaces(sField);
|
||||
}
|
||||
|
||||
|
||||
@ -290,7 +288,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::sample
|
||||
const surfaceSphericalTensorField& sField
|
||||
) const
|
||||
{
|
||||
return sampleField(sField);
|
||||
return sampleOnFaces(sField);
|
||||
}
|
||||
|
||||
|
||||
@ -299,7 +297,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::sample
|
||||
const surfaceSymmTensorField& sField
|
||||
) const
|
||||
{
|
||||
return sampleField(sField);
|
||||
return sampleOnFaces(sField);
|
||||
}
|
||||
|
||||
|
||||
@ -308,7 +306,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledPatch::sample
|
||||
const surfaceTensorField& sField
|
||||
) const
|
||||
{
|
||||
return sampleField(sField);
|
||||
return sampleOnFaces(sField);
|
||||
}
|
||||
|
||||
|
||||
@ -317,7 +315,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledPatch::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -326,7 +324,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledPatch::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +333,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatch::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -344,7 +342,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledPatch::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -353,7 +351,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledPatch::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,6 +27,29 @@ Class
|
||||
Description
|
||||
A sampledSurface on patches. Non-triangulated by default.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type patch;
|
||||
patches (inlet "outlet.*");
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | patch | yes |
|
||||
patches | patch selection as word/regex list | yes |
|
||||
triangulate | triangulate faces | no | false
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
sampledPatch.C
|
||||
|
||||
@ -83,22 +106,27 @@ class sampledPatch
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample boundary field (from volume field) onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample surface field on faces
|
||||
//- Sample boundary field (from surface field) onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||
) const;
|
||||
|
||||
//- Interpolate boundary field (from volume field) onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
//- Re-map action on triangulation or cleanup
|
||||
virtual void remapFaces(const labelUList& faceMap);
|
||||
@ -208,61 +236,62 @@ public:
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
|
||||
//- Sample boundary of surface field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const surfaceScalarField&
|
||||
) const;
|
||||
|
||||
//- Surface Sample field on surface
|
||||
//- Sample boundary of surface field on surface
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const surfaceVectorField&
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
//- Sample boundary of surface field on surface
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const surfaceSphericalTensorField&
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
//- Sample boundary of surface field on surface
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const surfaceSymmTensorField&
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
//- Sample boundary of surface field on surface
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const surfaceTensorField&
|
||||
@ -271,36 +300,39 @@ public:
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,19 +29,23 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPatch::sampleField
|
||||
Foam::sampledPatch::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
const auto& vField = sampler.psi();
|
||||
|
||||
// One value per face
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(patchFaceLabels_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(patchFaceLabels_.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
forAll(patchFaceLabels_, i)
|
||||
{
|
||||
label patchi = patchIDs_[patchIndex_[i]];
|
||||
const Field<Type>& bField = vField.boundaryField()[patchi];
|
||||
values[i] = bField[patchFaceLabels_[i]];
|
||||
const label patchi = patchIDs_[patchIndex_[i]];
|
||||
const label patchFacei = patchFaceLabels_[i];
|
||||
|
||||
values[i] = vField.boundaryField()[patchi][patchFacei];
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
@ -50,19 +54,21 @@ Foam::sampledPatch::sampleField
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPatch::sampleField
|
||||
Foam::sampledPatch::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||
) const
|
||||
{
|
||||
// One value per face
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(patchFaceLabels_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(patchFaceLabels_.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
forAll(patchFaceLabels_, i)
|
||||
{
|
||||
label patchi = patchIDs_[patchIndex_[i]];
|
||||
values[i] = sField.boundaryField()[patchi][patchFaceLabels_[i]];
|
||||
const label patchi = patchIDs_[patchIndex_[i]];
|
||||
const label patchFacei = patchFaceLabels_[i];
|
||||
|
||||
values[i] = sField.boundaryField()[patchi][patchFacei];
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
@ -71,34 +77,32 @@ Foam::sampledPatch::sampleField
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPatch::interpolateField
|
||||
Foam::sampledPatch::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(points().size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(points().size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
const labelList& own = mesh().faceOwner();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
bitSet pointDone(points().size());
|
||||
|
||||
forAll(faces(), cutFacei)
|
||||
{
|
||||
label patchi = patchIDs_[patchIndex_[cutFacei]];
|
||||
const label patchi = patchIDs_[patchIndex_[cutFacei]];
|
||||
const polyPatch& pp = mesh().boundaryMesh()[patchi];
|
||||
label patchFacei = patchFaceLabels()[cutFacei];
|
||||
const label patchFacei = patchFaceLabels()[cutFacei];
|
||||
const face& f = faces()[cutFacei];
|
||||
|
||||
forAll(f, faceVertI)
|
||||
for (const label pointi : f)
|
||||
{
|
||||
label pointi = f[faceVertI];
|
||||
|
||||
if (!pointDone[pointi])
|
||||
if (pointDone.set(pointi))
|
||||
{
|
||||
label facei = patchFacei + pp.start();
|
||||
label celli = own[facei];
|
||||
const label facei = patchFacei + pp.start();
|
||||
const label celli = own[facei];
|
||||
|
||||
values[pointi] = interpolator.interpolate
|
||||
(
|
||||
@ -106,7 +110,6 @@ Foam::sampledPatch::interpolateField
|
||||
celli,
|
||||
facei
|
||||
);
|
||||
pointDone[pointi] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -135,55 +135,50 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledPatchInternalField::~sampledPatchInternalField()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledPatchInternalField::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledPatchInternalField::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPatchInternalField::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledPatchInternalField::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledPatchInternalField::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -192,7 +187,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledPatchInternalField::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -201,7 +196,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledPatchInternalField::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -211,7 +206,7 @@ Foam::sampledPatchInternalField::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -220,7 +215,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledPatchInternalField::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +224,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledPatchInternalField::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,6 +32,34 @@ Description
|
||||
- interpolate=true : interpolate inside cell and interpolate to points
|
||||
There is no option to get interpolated value inside the cell on the faces.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type patchInternalField;
|
||||
patches (inlet "outlet.*");
|
||||
offsetMode normal;
|
||||
distance 0.05;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | patchInternalField | yes |
|
||||
patches | patch selection as word/regex list | yes |
|
||||
offsetMode | normal/uniform/nonuniform | no | normal
|
||||
distance | distance for normal offset | partly |
|
||||
offset | point offset for uniform offset | partly |
|
||||
offsets | point offsets for nonuniform offset | partly |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
sampledPatchInternalField.C
|
||||
|
||||
@ -64,15 +92,19 @@ class sampledPatchInternalField
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>> interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -93,79 +125,81 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sampledPatchInternalField();
|
||||
virtual ~sampledPatchInternalField() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample boundary of volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate boundary of volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
// Output
|
||||
|
||||
//- Print information
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,14 +31,16 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPatchInternalField::sampleField
|
||||
Foam::sampledPatchInternalField::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
const auto& vField = sampler.psi();
|
||||
|
||||
// One value per face
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(patchFaceLabels().size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(patchFaceLabels().size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
forAll(patchStart(), i)
|
||||
{
|
||||
@ -66,7 +68,7 @@ Foam::sampledPatchInternalField::sampleField
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPatchInternalField::interpolateField
|
||||
Foam::sampledPatchInternalField::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
@ -118,9 +120,9 @@ Foam::sampledPatchInternalField::interpolateField
|
||||
|
||||
labelList meshFaceLabels(allPatchVals.size());
|
||||
sz = 0;
|
||||
forAll(patchIDs(), i)
|
||||
for (const label patchId : patchIDs())
|
||||
{
|
||||
const polyPatch& pp = mesh().boundaryMesh()[patchIDs()[i]];
|
||||
const polyPatch& pp = mesh().boundaryMesh()[patchId];
|
||||
forAll(pp, i)
|
||||
{
|
||||
meshFaceLabels[sz++] = pp.start()+i;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,7 +35,13 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledPlane, 0);
|
||||
addNamedToRunTimeSelectionTable(sampledSurface, sampledPlane, word, plane);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
sampledSurface,
|
||||
sampledPlane,
|
||||
word,
|
||||
plane
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -170,6 +176,7 @@ bool Foam::sampledPlane::update()
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
|
||||
labelList selectedCells(mesh().cellZones().findMatching(zoneKey_).toc());
|
||||
|
||||
bool fullMesh = returnReduce(selectedCells.empty(), andOp<bool>());
|
||||
@ -234,46 +241,46 @@ bool Foam::sampledPlane::update()
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledPlane::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledPlane::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPlane::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledPlane::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledPlane::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -282,7 +289,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledPlane::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -291,7 +298,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledPlane::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledPlane::interpolate
|
||||
@ -299,7 +306,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledPlane::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -308,7 +315,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledPlane::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -317,7 +324,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledPlane::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,8 +25,43 @@ Class
|
||||
Foam::sampledPlane
|
||||
|
||||
Description
|
||||
A sampledSurface defined by a plane which 'cuts' the mesh using the
|
||||
cuttingPlane alorithm. The plane is triangulated by default.
|
||||
A sampledSurface defined by a plane which \a cuts the mesh using the
|
||||
cuttingPlane alorithm. The surface is triangulated by default.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type plane;
|
||||
planeType pointAndNormal;
|
||||
pointAndNormalDict
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | plane | yes |
|
||||
planeType | plane description (pointAndNormal etc) | yes |
|
||||
triangulate | triangulate faces | no | true
|
||||
bounds | limit with bounding box | no |
|
||||
zone | limit to specified zone | no |
|
||||
coordinateSystem | plane relative to given coordinate system | no |
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::coordinateSystem
|
||||
Foam::cuttingPlane
|
||||
Foam::plane
|
||||
|
||||
Note
|
||||
Does not actually cut until update() called.
|
||||
@ -70,19 +105,22 @@ class sampledPlane
|
||||
//- Track if the surface needs an update
|
||||
mutable bool needsUpdate_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -168,78 +206,80 @@ public:
|
||||
return cuttingPlane::Cf();
|
||||
}
|
||||
|
||||
//- For each face, the original cell in mesh
|
||||
using cuttingPlane::meshCells;
|
||||
|
||||
//- For every face original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return cuttingPlane::meshCells();
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
// Sample
|
||||
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
// Output
|
||||
|
||||
//- Print information
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -29,40 +29,50 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPlane::sampleField
|
||||
Foam::sampledPlane::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>::New(vField, meshCells());
|
||||
return sampledSurface::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
meshCells(),
|
||||
faces(),
|
||||
points()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledPlane::interpolateField
|
||||
Foam::sampledPlane::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// elements to sample
|
||||
const labelList& elements = meshCells();
|
||||
|
||||
// One value per point.
|
||||
// Initialize with Zero to handle missed/degenerate faces
|
||||
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(points().size(), Zero));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(points().size(), Zero);
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
bitSet pointDone(points().size());
|
||||
|
||||
forAll(faces(), cutFacei)
|
||||
const faceList& fcs = faces();
|
||||
|
||||
forAll(fcs, facei)
|
||||
{
|
||||
const face& f = faces()[cutFacei];
|
||||
const label celli = meshCells()[cutFacei];
|
||||
const face& f = fcs[facei];
|
||||
const label celli = elements[facei];
|
||||
|
||||
for (const label pointi : f)
|
||||
{
|
||||
if (!pointDone[pointi])
|
||||
if (pointDone.set(pointi))
|
||||
{
|
||||
pointDone[pointi] = true;
|
||||
values[pointi] = interpolator.interpolate
|
||||
(
|
||||
points()[pointi],
|
||||
|
||||
@ -181,57 +181,6 @@ Foam::tmp<Foam::tensorField> Foam::sampledSurface::sample
|
||||
}
|
||||
|
||||
|
||||
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.ref();
|
||||
|
||||
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.ref(), 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.ref(), 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.ref(), 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.ref(), field);
|
||||
return tRes;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurface::print(Ostream& os) const
|
||||
{
|
||||
os << type();
|
||||
@ -240,7 +189,7 @@ void Foam::sampledSurface::print(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream &os, const sampledSurface& s)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const sampledSurface& s)
|
||||
{
|
||||
s.print(os);
|
||||
os.check(FUNCTION_NAME);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -70,11 +70,10 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
// Forward declarations
|
||||
|
||||
class sampledSurface;
|
||||
|
||||
Ostream& operator<<(Ostream&, const sampledSurface&);
|
||||
Ostream& operator<<(Ostream& os, const sampledSurface& s);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -103,36 +102,28 @@ class sampledSurface
|
||||
mutable scalar area_;
|
||||
|
||||
|
||||
// Service methods
|
||||
|
||||
//- Check field size matches surface size
|
||||
template<class Type>
|
||||
bool checkFieldSize(const Field<Type>&) const;
|
||||
|
||||
//- Project field onto surface
|
||||
template<class ReturnType, class Type>
|
||||
void project
|
||||
(
|
||||
Field<ReturnType>&,
|
||||
const Field<Type>&
|
||||
) const;
|
||||
|
||||
//- Project field onto surface
|
||||
template<class ReturnType, class Type>
|
||||
void project
|
||||
(
|
||||
Field<ReturnType>&,
|
||||
const tmp<Field<Type>>&
|
||||
) const;
|
||||
|
||||
//- Project field onto surface
|
||||
template<class ReturnType, class Type>
|
||||
tmp<Field<ReturnType>> project(const tmp<Field<Type>>&) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member functions
|
||||
// Protected Member Functions
|
||||
|
||||
//- General loop for sampling elements to faces
|
||||
template<class Type>
|
||||
static tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler,
|
||||
const labelUList& elements,
|
||||
const faceList& fcs,
|
||||
const pointField& pts
|
||||
);
|
||||
|
||||
|
||||
//- Create cell values by averaging the point values
|
||||
template<class Type>
|
||||
static tmp<GeometricField<Type, fvPatchField, volMesh>> pointAverage
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld
|
||||
);
|
||||
|
||||
|
||||
virtual void clearGeom() const;
|
||||
|
||||
@ -277,133 +268,96 @@ public:
|
||||
scalar area() 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;
|
||||
|
||||
//- Project field onto surface
|
||||
tmp<Field<scalar>> project(const Field<vector>&) const;
|
||||
|
||||
//- Project field onto surface
|
||||
tmp<Field<vector>> project(const Field<sphericalTensor>&) const;
|
||||
|
||||
//- Project field onto surface
|
||||
tmp<Field<vector>> project(const Field<symmTensor>&) const;
|
||||
|
||||
//- Project field onto surface
|
||||
tmp<Field<vector>> project(const Field<tensor>&) const;
|
||||
|
||||
//- Interpolate from points to cell centre
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> pointAverage
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const = 0;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const = 0;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const = 0;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const = 0;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const = 0;
|
||||
|
||||
//- Surface sample field on surface
|
||||
|
||||
//- Sample surface field onto surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const surfaceScalarField&
|
||||
const surfaceScalarField& sField
|
||||
) const;
|
||||
|
||||
//- Surface Sample field on surface
|
||||
//- Sample surface field onto surface
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const surfaceVectorField&
|
||||
const surfaceVectorField& sField
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
//- Sample surface field onto surface
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const surfaceSphericalTensorField&
|
||||
const surfaceSphericalTensorField& sField
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
//- Sample surface field onto surface
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const surfaceSymmTensorField&
|
||||
const surfaceSymmTensorField& sField
|
||||
) const;
|
||||
|
||||
//- Surface sample field on surface
|
||||
//- Sample surface field onto surface
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const surfaceTensorField&
|
||||
const surfaceTensorField& sField
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const = 0;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const = 0;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const = 0;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const = 0;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const = 0;
|
||||
|
||||
|
||||
@ -418,11 +372,11 @@ public:
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
//- Print information
|
||||
virtual void print(Ostream& os) const;
|
||||
|
||||
//- Ostream operator
|
||||
friend Ostream& operator<<(Ostream&, const sampledSurface&);
|
||||
friend Ostream& operator<<(Ostream& os, const sampledSurface& s);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,129 +25,41 @@ License
|
||||
|
||||
#include "sampledSurface.H"
|
||||
|
||||
template<class Type>
|
||||
bool Foam::sampledSurface::checkFieldSize(const Field<Type>& field) const
|
||||
{
|
||||
if (faces().empty() || field.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
if (field.size() != faces().size())
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledSurface::sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler,
|
||||
const labelUList& elements,
|
||||
const faceList& fcs,
|
||||
const pointField& pts
|
||||
)
|
||||
{
|
||||
const label len = elements.size();
|
||||
|
||||
if (len != fcs.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "size mismatch: "
|
||||
<< "field (" << field.size()
|
||||
<< ") != surface (" << faces().size() << ")"
|
||||
<< "sampled elements (" << len
|
||||
<< ") != faces (" << fcs.size() << ')'
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
auto tvalues = tmp<Field<Type>>::New(len);
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::integrate(const Field<Type>& field) const
|
||||
{
|
||||
Type value = Zero;
|
||||
|
||||
if (checkFieldSize(field))
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
value = sum(field*magSf());
|
||||
const label celli = elements[i];
|
||||
const point pt = fcs[i].centre(pts);
|
||||
|
||||
values[i] = sampler.interpolate(pt, celli);
|
||||
}
|
||||
|
||||
reduce(value, sumOp<Type>());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::integrate(const tmp<Field<Type>>& field) const
|
||||
{
|
||||
Type value = integrate(field());
|
||||
field.clear();
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::average(const Field<Type>& field) const
|
||||
{
|
||||
Type value = Zero;
|
||||
|
||||
if (checkFieldSize(field))
|
||||
{
|
||||
value = sum(field*magSf());
|
||||
}
|
||||
|
||||
reduce(value, sumOp<Type>());
|
||||
|
||||
// avoid divide-by-zero
|
||||
if (area())
|
||||
{
|
||||
return value/area();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::sampledSurface::average(const tmp<Field<Type>>& field) const
|
||||
{
|
||||
Type value = average(field());
|
||||
field.clear();
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<class ReturnType, class Type>
|
||||
void Foam::sampledSurface::project
|
||||
(
|
||||
Field<ReturnType>& res,
|
||||
const Field<Type>& field
|
||||
) const
|
||||
{
|
||||
if (checkFieldSize(field))
|
||||
{
|
||||
const vectorField& norm = Sf();
|
||||
|
||||
forAll(norm, facei)
|
||||
{
|
||||
res[facei] = field[facei] & (norm[facei]/mag(norm[facei]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
@ -156,13 +68,11 @@ Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
|
||||
Foam::sampledSurface::pointAverage
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld
|
||||
) const
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = dynamic_cast<const fvMesh&>(pfld.mesh()());
|
||||
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>> tcellAvg
|
||||
(
|
||||
new GeometricField<Type, fvPatchField, volMesh>
|
||||
auto tcellAvg = tmp<GeometricField<Type, fvPatchField, volMesh>>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -175,29 +85,28 @@ Foam::sampledSurface::pointAverage
|
||||
),
|
||||
mesh,
|
||||
dimensioned<Type>(dimless, Zero)
|
||||
)
|
||||
);
|
||||
GeometricField<Type, fvPatchField, volMesh>& cellAvg = tcellAvg.ref();
|
||||
auto& cellAvg = tcellAvg.ref();
|
||||
|
||||
labelField nPointCells(mesh.nCells(), 0);
|
||||
{
|
||||
for (label pointi = 0; pointi < mesh.nPoints(); pointi++)
|
||||
labelField nPointCells(mesh.nCells(), Zero);
|
||||
|
||||
for (label pointi = 0; pointi < mesh.nPoints(); ++pointi)
|
||||
{
|
||||
const Type& val = pfld[pointi];
|
||||
const labelList& pCells = mesh.pointCells(pointi);
|
||||
|
||||
forAll(pCells, i)
|
||||
for (const label celli : pCells)
|
||||
{
|
||||
label celli = pCells[i];
|
||||
cellAvg[celli] += val;
|
||||
++nPointCells[celli];
|
||||
}
|
||||
}
|
||||
|
||||
cellAvg[celli] += pfld[pointi];
|
||||
nPointCells[celli]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
forAll(cellAvg, celli)
|
||||
{
|
||||
cellAvg[celli] /= nPointCells[celli];
|
||||
}
|
||||
|
||||
// Give value to calculatedFvPatchFields
|
||||
cellAvg.correctBoundaryConditions();
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "IOmanip.H"
|
||||
#include "interpolationCell.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "PatchTools.H"
|
||||
#include "mapPolyMesh.H"
|
||||
@ -61,19 +62,19 @@ void Foam::sampledSurfaces::writeGeometry() const
|
||||
|
||||
const fileName outputDir = outputPath_/time_.timeName();
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
const sampledSurface& s = operator[](surfI);
|
||||
const sampledSurface& s = operator[](surfi);
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
if (Pstream::master() && mergedList_[surfI].size())
|
||||
if (Pstream::master() && mergedList_[surfi].size())
|
||||
{
|
||||
formatter_->write
|
||||
(
|
||||
outputDir,
|
||||
s.name(),
|
||||
mergedList_[surfI]
|
||||
mergedList_[surfi]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -90,9 +91,9 @@ void Foam::sampledSurfaces::writeOriginalIds()
|
||||
const word fieldName = "Ids";
|
||||
const fileName outputDir = outputPath_/time_.timeName();
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
const sampledSurface& s = operator[](surfI);
|
||||
const sampledSurface& s = operator[](surfi);
|
||||
|
||||
if (isA<sampledTriSurfaceMesh>(s))
|
||||
{
|
||||
@ -109,7 +110,7 @@ void Foam::sampledSurfaces::writeOriginalIds()
|
||||
ids[i] = idLst[i];
|
||||
}
|
||||
|
||||
writeSurface(ids, surfI, fieldName, outputDir);
|
||||
writeSurface(ids, surfi, fieldName, outputDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +132,8 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
loadFromFiles_(false),
|
||||
outputPath_(fileName::null),
|
||||
fieldSelection_(),
|
||||
interpolationScheme_(word::null),
|
||||
sampleFaceScheme_(word::null),
|
||||
sampleNodeScheme_(word::null),
|
||||
mergedList_(),
|
||||
formatter_(nullptr)
|
||||
{
|
||||
@ -143,8 +145,7 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
{
|
||||
outputPath_ = mesh_.time().path()/"postProcessing"/name;
|
||||
}
|
||||
// Remove ".."
|
||||
outputPath_.clean();
|
||||
outputPath_.clean(); // Remove unneeded ".."
|
||||
|
||||
read(dict);
|
||||
}
|
||||
@ -164,7 +165,8 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
loadFromFiles_(loadFromFiles),
|
||||
outputPath_(fileName::null),
|
||||
fieldSelection_(),
|
||||
interpolationScheme_(word::null),
|
||||
sampleFaceScheme_(word::null),
|
||||
sampleNodeScheme_(word::null),
|
||||
mergedList_(),
|
||||
formatter_(nullptr)
|
||||
{
|
||||
@ -178,8 +180,7 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
{
|
||||
outputPath_ = time_.path()/"postProcessing"/name;
|
||||
}
|
||||
// Remove ".."
|
||||
outputPath_.clean();
|
||||
outputPath_.clean(); // Remove unneeded ".."
|
||||
|
||||
read(dict);
|
||||
}
|
||||
@ -207,8 +208,12 @@ bool Foam::sampledSurfaces::execute()
|
||||
|
||||
bool Foam::sampledSurfaces::write()
|
||||
{
|
||||
if (size())
|
||||
if (empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Finalize surfaces, merge points etc.
|
||||
update();
|
||||
|
||||
@ -234,7 +239,6 @@ bool Foam::sampledSurfaces::write()
|
||||
sampleAndWrite<surfaceSphericalTensorField>(objects);
|
||||
sampleAndWrite<surfaceSymmTensorField>(objects);
|
||||
sampleAndWrite<surfaceTensorField>(objects);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -246,9 +250,12 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
|
||||
if (surfacesFound)
|
||||
{
|
||||
sampleFaceScheme_ = dict.lookupOrDefault<word>("sampleScheme", "cell");
|
||||
|
||||
dict.lookup("interpolationScheme") >> sampleNodeScheme_;
|
||||
|
||||
dict.lookup("fields") >> fieldSelection_;
|
||||
|
||||
dict.lookup("interpolationScheme") >> interpolationScheme_;
|
||||
const word writeType(dict.lookup("surfaceFormat"));
|
||||
|
||||
// Define the surface formatter
|
||||
@ -277,9 +284,9 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
if (this->size())
|
||||
{
|
||||
Info<< "Reading surface description:" << nl;
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
Info<< " " << operator[](surfI).name() << nl;
|
||||
Info<< " " << operator[](surfi).name() << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
@ -290,9 +297,9 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
Pout<< "sample fields:" << fieldSelection_ << nl
|
||||
<< "sample surfaces:" << nl << "(" << nl;
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
Pout<< " " << operator[](surfI) << endl;
|
||||
Pout<< " " << operator[](surfi) << nl;
|
||||
}
|
||||
Pout<< ")" << endl;
|
||||
}
|
||||
@ -332,9 +339,9 @@ void Foam::sampledSurfaces::readUpdate(const polyMesh::readUpdateState state)
|
||||
|
||||
bool Foam::sampledSurfaces::needsUpdate() const
|
||||
{
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
if (operator[](surfI).needsUpdate())
|
||||
if (operator[](surfi).needsUpdate())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -348,9 +355,9 @@ bool Foam::sampledSurfaces::expire()
|
||||
{
|
||||
bool justExpired = false;
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
if (operator[](surfI).expire())
|
||||
if (operator[](surfi).expire())
|
||||
{
|
||||
justExpired = true;
|
||||
}
|
||||
@ -358,7 +365,7 @@ bool Foam::sampledSurfaces::expire()
|
||||
// Clear merge information
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
mergedList_[surfI].clear();
|
||||
mergedList_[surfi].clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,9 +386,9 @@ bool Foam::sampledSurfaces::update()
|
||||
// Serial: quick and easy, no merging required
|
||||
if (!Pstream::parRun())
|
||||
{
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
if (operator[](surfI).update())
|
||||
if (operator[](surfi).update())
|
||||
{
|
||||
updated = true;
|
||||
}
|
||||
@ -390,8 +397,9 @@ bool Foam::sampledSurfaces::update()
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
// Dimension as fraction of mesh bounding box
|
||||
scalar mergeDim = mergeTol_*mesh_.bounds().mag();
|
||||
const scalar mergeDim = mergeTol_*mesh_.bounds().mag();
|
||||
|
||||
if (Pstream::master() && debug)
|
||||
{
|
||||
@ -399,14 +407,14 @@ bool Foam::sampledSurfaces::update()
|
||||
<< mergeDim << " metre" << endl;
|
||||
}
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
sampledSurface& s = operator[](surfI);
|
||||
sampledSurface& s = operator[](surfi);
|
||||
|
||||
if (s.update())
|
||||
{
|
||||
updated = true;
|
||||
mergedList_[surfI].merge(s, mergeDim);
|
||||
mergedList_[surfi].merge(s, mergeDim);
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,9 +430,9 @@ Foam::scalar Foam::sampledSurfaces::mergeTol()
|
||||
|
||||
Foam::scalar Foam::sampledSurfaces::mergeTol(const scalar tol)
|
||||
{
|
||||
scalar oldTol = mergeTol_;
|
||||
const scalar prev(mergeTol_);
|
||||
mergeTol_ = tol;
|
||||
return oldTol;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,8 +44,12 @@ Description
|
||||
// Fields to be sampled
|
||||
fields (p U);
|
||||
|
||||
// Interpolation scheme to use (only used if interpolate=true for
|
||||
// the surfaces below)
|
||||
// Scheme to obtain face centre value
|
||||
sampleScheme cell;
|
||||
|
||||
// Scheme to obtain node values
|
||||
// (only used if interpolate=true for the surfaces below)
|
||||
|
||||
interpolationScheme cell;
|
||||
|
||||
// Output surface format
|
||||
@ -95,7 +99,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// Forward declarations
|
||||
class Time;
|
||||
class fvMesh;
|
||||
class dictionary;
|
||||
@ -135,11 +139,14 @@ class sampledSurfaces
|
||||
//- Names of fields to sample
|
||||
wordRes fieldSelection_;
|
||||
|
||||
//- Interpolation scheme to use
|
||||
word interpolationScheme_;
|
||||
//- Interpolation/sample scheme to obtain face values
|
||||
word sampleFaceScheme_;
|
||||
|
||||
//- Interpolation/sample scheme to obtain node values
|
||||
word sampleNodeScheme_;
|
||||
|
||||
|
||||
// surfaces
|
||||
// Surfaces
|
||||
|
||||
//- Merged meshed surfaces (parallel only)
|
||||
List<mergedSurf> mergedList_;
|
||||
@ -168,7 +175,7 @@ class sampledSurfaces
|
||||
void writeSurface
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const label surfI,
|
||||
const label surfi,
|
||||
const word& fieldName,
|
||||
const fileName& outputDir
|
||||
);
|
||||
@ -177,22 +184,25 @@ class sampledSurfaces
|
||||
template<class Type>
|
||||
void sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
);
|
||||
|
||||
//- Sample and write a particular surface field
|
||||
template<class Type>
|
||||
void sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>&
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||
);
|
||||
|
||||
//- Sample and write all sampled fields
|
||||
template<class Type> void sampleAndWrite(const IOobjectList& objects);
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
sampledSurfaces(const sampledSurfaces&);
|
||||
void operator=(const sampledSurfaces&);
|
||||
|
||||
//- No copy construct
|
||||
sampledSurfaces(const sampledSurfaces&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const sampledSurfaces&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -207,7 +217,7 @@ public:
|
||||
sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
@ -216,8 +226,8 @@ public:
|
||||
sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
@ -265,7 +275,7 @@ public:
|
||||
static scalar mergeTol();
|
||||
|
||||
//- Set tolerance (and return old tolerance)
|
||||
static scalar mergeTol(const scalar);
|
||||
static scalar mergeTol(const scalar tol);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -35,12 +35,12 @@ template<class Type>
|
||||
void Foam::sampledSurfaces::writeSurface
|
||||
(
|
||||
const Field<Type>& values,
|
||||
const label surfI,
|
||||
const label surfi,
|
||||
const word& fieldName,
|
||||
const fileName& outputDir
|
||||
)
|
||||
{
|
||||
const sampledSurface& s = operator[](surfI);
|
||||
const sampledSurface& s = operator[](surfi);
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
@ -63,21 +63,21 @@ void Foam::sampledSurfaces::writeSurface
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
if (mergedList_[surfI].pointsMap().size() == allValues.size())
|
||||
if (mergedList_[surfi].pointsMap().size() == allValues.size())
|
||||
{
|
||||
inplaceReorder(mergedList_[surfI].pointsMap(), allValues);
|
||||
allValues.setSize(mergedList_[surfI].points().size());
|
||||
inplaceReorder(mergedList_[surfi].pointsMap(), allValues);
|
||||
allValues.setSize(mergedList_[surfi].points().size());
|
||||
}
|
||||
|
||||
// Write to time directory under outputPath_
|
||||
// skip surface without faces (eg, a failed cut-plane)
|
||||
if (mergedList_[surfI].size())
|
||||
if (mergedList_[surfi].size())
|
||||
{
|
||||
sampleFile = formatter_->write
|
||||
(
|
||||
outputDir,
|
||||
s.name(),
|
||||
mergedList_[surfI],
|
||||
mergedList_[surfi],
|
||||
fieldName,
|
||||
allValues,
|
||||
s.interpolate()
|
||||
@ -123,37 +123,46 @@ void Foam::sampledSurfaces::sampleAndWrite
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
)
|
||||
{
|
||||
// interpolator for this field
|
||||
autoPtr<interpolation<Type>> interpolatorPtr;
|
||||
// sampler/interpolator for this field
|
||||
autoPtr<interpolation<Type>> interpPtr;
|
||||
|
||||
const word& fieldName = vField.name();
|
||||
const fileName outputDir = outputPath_/vField.time().timeName();
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
const sampledSurface& s = operator[](surfI);
|
||||
const sampledSurface& s = operator[](surfi);
|
||||
|
||||
Field<Type> values;
|
||||
|
||||
if (s.interpolate())
|
||||
{
|
||||
if (interpolatorPtr.empty())
|
||||
if (interpPtr.empty())
|
||||
{
|
||||
interpolatorPtr = interpolation<Type>::New
|
||||
interpPtr = interpolation<Type>::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
sampleNodeScheme_,
|
||||
vField
|
||||
);
|
||||
}
|
||||
|
||||
values = s.interpolate(interpolatorPtr());
|
||||
values = s.interpolate(*interpPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
values = s.sample(vField);
|
||||
if (interpPtr.empty())
|
||||
{
|
||||
interpPtr = interpolation<Type>::New
|
||||
(
|
||||
sampleFaceScheme_,
|
||||
vField
|
||||
);
|
||||
}
|
||||
|
||||
writeSurface<Type>(values, surfI, fieldName, outputDir);
|
||||
values = s.sample(*interpPtr);
|
||||
}
|
||||
|
||||
writeSurface<Type>(values, surfi, fieldName, outputDir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,11 +176,11 @@ void Foam::sampledSurfaces::sampleAndWrite
|
||||
const word& fieldName = sField.name();
|
||||
const fileName outputDir = outputPath_/sField.time().timeName();
|
||||
|
||||
forAll(*this, surfI)
|
||||
forAll(*this, surfi)
|
||||
{
|
||||
const sampledSurface& s = operator[](surfI);
|
||||
const sampledSurface& s = operator[](surfi);
|
||||
Field<Type> values(s.sample(sField));
|
||||
writeSurface<Type>(values, surfI, fieldName, outputDir);
|
||||
writeSurface<Type>(values, surfi, fieldName, outputDir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,13 +200,11 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
|
||||
writeOriginalIds();
|
||||
}
|
||||
|
||||
forAll(fieldNames, fieldi)
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldi];
|
||||
|
||||
if ((Pstream::master()) && verbose_)
|
||||
if (verbose_)
|
||||
{
|
||||
Pout<< "sampleAndWrite: " << fieldName << endl;
|
||||
Info<< "sampleAndWrite: " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (loadFromFiles_)
|
||||
|
||||
@ -87,9 +87,8 @@ void Foam::sampledTriSurfaceMesh::setZoneMap
|
||||
)
|
||||
{
|
||||
label sz = 0;
|
||||
forAll(zoneLst, zonei)
|
||||
for (const surfZone& zn : zoneLst)
|
||||
{
|
||||
const surfZone& zn = zoneLst[zonei];
|
||||
sz += zn.size();
|
||||
}
|
||||
|
||||
@ -119,9 +118,8 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
|
||||
|
||||
labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces());
|
||||
label bndI = 0;
|
||||
forAll(patches, patchi)
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
if (!pp.coupled())
|
||||
{
|
||||
forAll(pp, i)
|
||||
@ -174,10 +172,10 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
// elements
|
||||
globalIndex globalCells(onBoundary() ? mesh().nFaces() : mesh().nCells());
|
||||
|
||||
forAll(nearest, i)
|
||||
for (nearInfo& near : nearest)
|
||||
{
|
||||
nearest[i].first() = GREAT;
|
||||
nearest[i].second() = labelMax;
|
||||
near.first() = GREAT;
|
||||
near.second() = labelMax;
|
||||
}
|
||||
|
||||
if (sampleSource_ == cells)
|
||||
@ -333,20 +331,16 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
const triSurface::FaceType& f = s[facei];
|
||||
const label regionid = f.region();
|
||||
|
||||
Map<label>::iterator fnd = zoneSizes.find(regionid);
|
||||
if (fnd != zoneSizes.end())
|
||||
auto fnd = zoneSizes.find(regionid);
|
||||
if (fnd.found())
|
||||
{
|
||||
fnd()++;
|
||||
++(*fnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This shouldn't happen
|
||||
zoneSizes.insert(regionid, 1);
|
||||
zoneNames.set
|
||||
(
|
||||
regionid,
|
||||
word::printf("patch%d", regionid)
|
||||
);
|
||||
zoneNames.set(regionid, word::printf("patch%d", regionid));
|
||||
}
|
||||
|
||||
// Store new faces compact
|
||||
@ -355,14 +349,12 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
++newFacei;
|
||||
|
||||
// Renumber face points
|
||||
forAll(f, fp)
|
||||
for (const label labi : f)
|
||||
{
|
||||
const label labI = f[fp];
|
||||
|
||||
if (reversePointMap[labI] == -1)
|
||||
if (reversePointMap[labi] == -1)
|
||||
{
|
||||
pointMap[newPointi] = labI;
|
||||
reversePointMap[labI] = newPointi++;
|
||||
pointMap[newPointi] = labi;
|
||||
reversePointMap[labi] = newPointi++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -380,16 +372,16 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
surfZoneList zoneLst(zoneSizes.size());
|
||||
label start = 0;
|
||||
label zoneI = 0;
|
||||
forAllIter(Map<label>, zoneSizes, iter)
|
||||
forAllIters(zoneSizes, iter)
|
||||
{
|
||||
// No negative regionids, so Map<label> sorts properly
|
||||
// No negative regionids, so Map<label> usually sorts properly
|
||||
const label regionid = iter.key();
|
||||
|
||||
word name;
|
||||
Map<word>::const_iterator fnd = zoneNames.find(regionid);
|
||||
if (fnd != zoneNames.end())
|
||||
auto fnd = zoneNames.cfind(regionid);
|
||||
if (fnd.found())
|
||||
{
|
||||
name = fnd();
|
||||
name = *fnd;
|
||||
}
|
||||
if (name.empty())
|
||||
{
|
||||
@ -420,7 +412,7 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
|
||||
forAll(zoneIds_, facei)
|
||||
{
|
||||
label zonei = zoneIds_[facei];
|
||||
const label zonei = zoneIds_[facei];
|
||||
label sortedFacei = zoneLst[zonei].start() + zoneLst[zonei].size()++;
|
||||
sortedFaceMap[sortedFacei] = faceMap[facei];
|
||||
}
|
||||
@ -460,9 +452,9 @@ bool Foam::sampledTriSurfaceMesh::update(const meshSearch& meshSearcher)
|
||||
reversePointMap[origF[2]]
|
||||
);
|
||||
|
||||
forAll(f, fp)
|
||||
for (const label labi : f)
|
||||
{
|
||||
pointToFace[f[fp]] = facei;
|
||||
pointToFace[labi] = facei;
|
||||
}
|
||||
}
|
||||
|
||||
@ -658,8 +650,8 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
||||
keepIds_(false),
|
||||
originalIds_(),
|
||||
zoneIds_(),
|
||||
sampleElements_(0),
|
||||
samplePoints_(0)
|
||||
sampleElements_(),
|
||||
samplePoints_()
|
||||
{}
|
||||
|
||||
|
||||
@ -691,8 +683,8 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
||||
keepIds_(dict.lookupOrDefault("keepIds", false)),
|
||||
originalIds_(),
|
||||
zoneIds_(),
|
||||
sampleElements_(0),
|
||||
samplePoints_(0)
|
||||
sampleElements_(),
|
||||
samplePoints_()
|
||||
{}
|
||||
|
||||
|
||||
@ -725,8 +717,8 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
|
||||
keepIds_(false),
|
||||
originalIds_(),
|
||||
zoneIds_(),
|
||||
sampleElements_(0),
|
||||
samplePoints_(0)
|
||||
sampleElements_(),
|
||||
samplePoints_()
|
||||
{}
|
||||
|
||||
|
||||
@ -832,45 +824,46 @@ bool Foam::sampledTriSurfaceMesh::update(const treeBoundBox& bb)
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledTriSurfaceMesh::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -879,7 +872,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledTriSurfaceMesh::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -888,7 +881,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledTriSurfaceMesh::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::interpolate
|
||||
@ -896,7 +889,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledTriSurfaceMesh::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -905,7 +898,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledTriSurfaceMesh::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -914,7 +907,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledTriSurfaceMesh::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -60,6 +60,31 @@ Description
|
||||
to be on one processor only. So after stitching (by sampledSurfaces)
|
||||
the original surface should be complete.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type sampledTriSurfaceMesh;
|
||||
surface something.obj;
|
||||
source cells;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | sampledTriSurfaceMesh | yes |
|
||||
surface | surface name in triSurface/ | yes |
|
||||
source | cells/insideCells/boundaryFaces | yes |
|
||||
keepIds | pass through id numbering | no | false
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
sampledTriSurfaceMesh.C
|
||||
sampledTriSurfaceMeshTemplates.C
|
||||
@ -144,17 +169,19 @@ private:
|
||||
//- Get tree of all non-coupled boundary faces
|
||||
const indexedOctree<treeDataFace>& nonCoupledboundaryTree() const;
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
bool update(const meshSearch& meshSearcher);
|
||||
|
||||
@ -200,7 +227,11 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Set new zoneIds list based on the surfZoneList information
|
||||
static void setZoneMap(const surfZoneList&, labelList& zoneIds);
|
||||
static void setZoneMap
|
||||
(
|
||||
const surfZoneList& zoneLst,
|
||||
labelList& zoneIds
|
||||
);
|
||||
|
||||
|
||||
//- Does the surface need an update?
|
||||
@ -218,7 +249,7 @@ public:
|
||||
//- Update the surface using a bound box to limit the searching.
|
||||
// For direct use, i.e. not through sample.
|
||||
// Do nothing (and return false) if no update was needed
|
||||
bool update(const treeBoundBox&);
|
||||
bool update(const treeBoundBox& bb);
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
@ -276,70 +307,76 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
// Sample
|
||||
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Write information
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
// Output
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -77,28 +77,24 @@ Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledTriSurfaceMeshNormal::~sampledTriSurfaceMeshNormal()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector>>
|
||||
Foam::sampledTriSurfaceMeshNormal::sample
|
||||
(
|
||||
const GeometricField<vector, fvPatchField, volMesh>& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
tmp<Field<vector>> tfld(new Field<vector>(size(), vector::zero));
|
||||
tfld.ref().replace
|
||||
auto tvalues = tmp<Field<vector>>::New(size(), Zero);
|
||||
|
||||
tvalues.ref().replace
|
||||
(
|
||||
0,
|
||||
meshedSurface::faceNormals()
|
||||
&sampledTriSurfaceMesh::sample(vField)
|
||||
&sampledTriSurfaceMesh::sample(sampler)
|
||||
);
|
||||
return tfld;
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
@ -108,26 +104,19 @@ Foam::sampledTriSurfaceMeshNormal::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<vectorField> tn
|
||||
(
|
||||
new vectorField
|
||||
(
|
||||
points().size(),
|
||||
vector::zero
|
||||
)
|
||||
);
|
||||
auto tvalues = tmp<Field<vector>>::New(points().size(), Zero);
|
||||
|
||||
pointField allNormals(tn().size(), vector::zero);
|
||||
pointField allNormals(points().size(), Zero);
|
||||
UIndirectList<vector>(allNormals, meshPoints()) = pointNormals();
|
||||
|
||||
tn.ref().replace
|
||||
tvalues.ref().replace
|
||||
(
|
||||
0,
|
||||
allNormals
|
||||
&sampledTriSurfaceMesh::interpolate(interpolator)
|
||||
);
|
||||
return tn;
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,6 +31,34 @@ Description
|
||||
Returns a vector field with the value in the first component and sets
|
||||
the other two to zero.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type sampledTriSurfaceMeshNormal;
|
||||
surface something.obj;
|
||||
source cells;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | sampledTriSurfaceMeshNormal | yes |
|
||||
surface | surface name in triSurface/ | yes |
|
||||
source | cells/insideCells/boundaryFaces | yes |
|
||||
keepIds | pass through id numbering | no | false
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::sampledTriSurfaceMesh
|
||||
|
||||
SourceFiles
|
||||
sampledTriSurfaceMeshNormal.C
|
||||
sampledTriSurfaceMeshNormalTemplates.C
|
||||
@ -91,97 +119,102 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sampledTriSurfaceMeshNormal();
|
||||
virtual ~sampledTriSurfaceMeshNormal() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Sample field on surface
|
||||
// Sample
|
||||
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,54 +29,61 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledTriSurfaceMesh::sampleField
|
||||
Foam::sampledTriSurfaceMesh::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
// One value per face
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(sampleElements_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
const labelList& elements = sampleElements_;
|
||||
|
||||
if (!onBoundary())
|
||||
{
|
||||
// Sample cells
|
||||
|
||||
forAll(sampleElements_, triI)
|
||||
{
|
||||
values[triI] = vField[sampleElements_[triI]];
|
||||
return sampledSurface::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
elements,
|
||||
faces(),
|
||||
points()
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
// Sample boundary faces
|
||||
//
|
||||
|
||||
auto tvalues = tmp<Field<Type>>::New(elements.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh().boundaryMesh();
|
||||
const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
|
||||
|
||||
|
||||
// Create flat boundary field
|
||||
const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
|
||||
|
||||
Field<Type> bVals(nBnd, Zero);
|
||||
|
||||
forAll(vField.boundaryField(), patchi)
|
||||
const auto& bField = sampler.psi().boundaryField();
|
||||
forAll(bField, patchi)
|
||||
{
|
||||
label bFacei = pbm[patchi].start() - mesh().nInternalFaces();
|
||||
const label bFacei = (pbm[patchi].start() - mesh().nInternalFaces());
|
||||
|
||||
SubList<Type>
|
||||
(
|
||||
bVals,
|
||||
vField.boundaryField()[patchi].size(),
|
||||
bField[patchi].size(),
|
||||
bFacei
|
||||
) = vField.boundaryField()[patchi];
|
||||
) = bField[patchi];
|
||||
}
|
||||
|
||||
// Sample in flat boundary field
|
||||
|
||||
forAll(sampleElements_, triI)
|
||||
forAll(elements, i)
|
||||
{
|
||||
label facei = sampleElements_[triI];
|
||||
values[triI] = bVals[facei-mesh().nInternalFaces()];
|
||||
}
|
||||
const label bFacei = (elements[i] - mesh().nInternalFaces());
|
||||
values[i] = bVals[bFacei];
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
@ -85,18 +92,18 @@ Foam::sampledTriSurfaceMesh::sampleField
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledTriSurfaceMesh::interpolateField
|
||||
Foam::sampledTriSurfaceMesh::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(sampleElements_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(sampleElements_.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
if (!onBoundary())
|
||||
{
|
||||
// Sample cells.
|
||||
// Sample cells
|
||||
|
||||
forAll(sampleElements_, pointi)
|
||||
{
|
||||
@ -109,11 +116,11 @@ Foam::sampledTriSurfaceMesh::interpolateField
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sample boundary faces.
|
||||
// Sample boundary faces
|
||||
|
||||
forAll(samplePoints_, pointi)
|
||||
{
|
||||
label facei = sampleElements_[pointi];
|
||||
const label facei = sampleElements_[pointi];
|
||||
|
||||
values[pointi] = interpolator.interpolate
|
||||
(
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,36 +59,33 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const
|
||||
|
||||
prevTimeIndex_ = fvm.time().timeIndex();
|
||||
|
||||
// Optionally read volScalarField
|
||||
autoPtr<volScalarField> readFieldPtr_;
|
||||
// Use volField from database, or try to read it in
|
||||
|
||||
const auto* cellFldPtr = fvm.lookupObjectPtr<volScalarField>(fieldName_);
|
||||
|
||||
// 1. see if field in database
|
||||
// 2. see if field can be read
|
||||
const volScalarField* cellFldPtr = nullptr;
|
||||
if (fvm.foundObject<volScalarField>(fieldName_))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction<< "Lookup " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
cellFldPtr = &fvm.lookupObject<volScalarField>(fieldName_);
|
||||
if (cellFldPtr)
|
||||
{
|
||||
InfoInFunction << "Lookup " << fieldName_ << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bit of a hack. Read field and store.
|
||||
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction
|
||||
<< "Reading " << fieldName_
|
||||
<< " from time " << fvm.time().timeName()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
readFieldPtr_.reset
|
||||
(
|
||||
new volScalarField
|
||||
// For holding the volScalarField read in.
|
||||
autoPtr<volScalarField> fieldReadPtr;
|
||||
|
||||
if (!cellFldPtr)
|
||||
{
|
||||
// Bit of a hack. Read field and store.
|
||||
|
||||
fieldReadPtr = autoPtr<volScalarField>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -100,12 +97,10 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const
|
||||
false
|
||||
),
|
||||
fvm
|
||||
)
|
||||
);
|
||||
|
||||
cellFldPtr = readFieldPtr_.operator->();
|
||||
}
|
||||
const volScalarField& cellFld = *cellFldPtr;
|
||||
const volScalarField& cellFld =
|
||||
(fieldReadPtr.valid() ? *fieldReadPtr : *cellFldPtr);
|
||||
|
||||
|
||||
thresholdCellFaces surf
|
||||
@ -123,7 +118,7 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const
|
||||
).MeshedSurface<face>::transfer(surf);
|
||||
meshCells_.transfer(surf.meshCells());
|
||||
|
||||
// clear derived data
|
||||
// Clear derived data
|
||||
sampledSurface::clearGeom();
|
||||
|
||||
if (debug)
|
||||
@ -169,12 +164,6 @@ Foam::sampledThresholdCellFaces::sampledThresholdCellFaces
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledThresholdCellFaces::~sampledThresholdCellFaces()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sampledThresholdCellFaces::needsUpdate() const
|
||||
@ -207,46 +196,46 @@ bool Foam::sampledThresholdCellFaces::update()
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledThresholdCellFaces::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledThresholdCellFaces::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledThresholdCellFaces::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledThresholdCellFaces::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledThresholdCellFaces::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
return sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +244,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledThresholdCellFaces::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -264,7 +253,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledThresholdCellFaces::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField>
|
||||
@ -273,7 +262,7 @@ Foam::sampledThresholdCellFaces::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -282,7 +271,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledThresholdCellFaces::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -291,7 +280,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledThresholdCellFaces::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
return sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,38 @@ Description
|
||||
A sampledSurface defined by the cell faces corresponding to a threshold
|
||||
value.
|
||||
|
||||
This is often embedded as part of a sampled surfaces function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type thresholdCellFaces;
|
||||
field rho;
|
||||
lowerLimit 0.1;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | thresholdCellFaces | yes |
|
||||
field | field name for threshold | yes |
|
||||
lowerLimit | lower limit for threshold | partly | -Inf
|
||||
upperLimit | upper limit for threshold | partly | +Inf
|
||||
triangulate | triangulate faces | no | false
|
||||
\endtable
|
||||
|
||||
Note
|
||||
Must specify at least one or both of \c lowerLimit or \c upperLimit
|
||||
|
||||
SeeAlso
|
||||
Foam::thresholdCellFaces
|
||||
|
||||
SourceFiles
|
||||
sampledThresholdCellFaces.C
|
||||
|
||||
@ -88,17 +120,19 @@ class sampledThresholdCellFaces
|
||||
// Do nothing (and return false) if no update was needed
|
||||
bool updateGeometry() const;
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -119,7 +153,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sampledThresholdCellFaces();
|
||||
virtual ~sampledThresholdCellFaces() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -173,59 +207,76 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample(const volScalarField&) const;
|
||||
// Sample
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<vectorField> sample( const volVectorField&) const;
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<symmTensorField> sample(const volSymmTensorField&) const;
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
// Output
|
||||
|
||||
//- Print information
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,50 +34,69 @@ License
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledThresholdCellFaces::sampleField
|
||||
Foam::sampledThresholdCellFaces::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
// Recreate geometry if time has changed
|
||||
updateGeometry();
|
||||
updateGeometry(); // Recreate geometry if time has changed
|
||||
|
||||
return tmp<Field<Type>>::New(vField, meshCells_);
|
||||
const labelList& elements = meshCells_;
|
||||
|
||||
const label len = faces().size();
|
||||
|
||||
auto tvalues = tmp<Field<Type>>::New(len);
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
const faceList& fcs = faces();
|
||||
const pointField& pts = points();
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
const label celli = elements[i];
|
||||
const point pt = fcs[i].centre(pts);
|
||||
|
||||
values[i] = sampler.interpolate(pt, celli);
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::sampledThresholdCellFaces::interpolateField
|
||||
Foam::sampledThresholdCellFaces::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// Recreate geometry if time has changed
|
||||
updateGeometry();
|
||||
updateGeometry(); // Recreate geometry if time has changed
|
||||
|
||||
const labelList& elements = meshCells_;
|
||||
|
||||
// One value per point
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(points().size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(points().size(), Zero);
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
bitSet pointDone(points().size());
|
||||
|
||||
forAll(faces(), cutFacei)
|
||||
const faceList& fcs = faces();
|
||||
const pointField& pts = points();
|
||||
|
||||
forAll(fcs, i)
|
||||
{
|
||||
const face& f = faces()[cutFacei];
|
||||
const face& f = fcs[i];
|
||||
const label celli = elements[i];
|
||||
|
||||
forAll(f, faceVertI)
|
||||
for (const label pointi : f)
|
||||
{
|
||||
label pointi = f[faceVertI];
|
||||
|
||||
if (!pointDone[pointi])
|
||||
if (pointDone.set(pointi))
|
||||
{
|
||||
values[pointi] = interpolator.interpolate
|
||||
(
|
||||
points()[pointi],
|
||||
meshCells_[cutFacei]
|
||||
pts[pointi],
|
||||
celli
|
||||
);
|
||||
pointDone[pointi] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,7 +30,6 @@ License
|
||||
#include "treeDataCell.H"
|
||||
#include "treeDataFace.H"
|
||||
#include "meshTools.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -138,45 +137,45 @@ bool Foam::sampledDiscreteSurface::sampleAndStore
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::sampledDiscreteSurface::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
const interpolation<scalar>& sampler
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::sampleField(vField);
|
||||
return SurfaceSource::sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::sampledDiscreteSurface::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
const interpolation<vector>& sampler
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::sampleField(vField);
|
||||
return SurfaceSource::sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledDiscreteSurface::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::sampleField(vField);
|
||||
return SurfaceSource::sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::sampledDiscreteSurface::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::sampleField(vField);
|
||||
return SurfaceSource::sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::sampledDiscreteSurface::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
const interpolation<tensor>& sampler
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::sampleField(vField);
|
||||
return SurfaceSource::sampleOnFaces(sampler);
|
||||
}
|
||||
|
||||
|
||||
@ -185,7 +184,7 @@ Foam::tmp<Foam::scalarField> Foam::sampledDiscreteSurface::interpolate
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::interpolateField(interpolator);
|
||||
return SurfaceSource::sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +193,7 @@ Foam::tmp<Foam::vectorField> Foam::sampledDiscreteSurface::interpolate
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::interpolateField(interpolator);
|
||||
return SurfaceSource::sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::sampledDiscreteSurface::interpolate
|
||||
@ -202,7 +201,7 @@ Foam::tmp<Foam::sphericalTensorField> Foam::sampledDiscreteSurface::interpolate
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::interpolateField(interpolator);
|
||||
return SurfaceSource::sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -211,7 +210,7 @@ Foam::tmp<Foam::symmTensorField> Foam::sampledDiscreteSurface::interpolate
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::interpolateField(interpolator);
|
||||
return SurfaceSource::sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
@ -220,7 +219,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledDiscreteSurface::interpolate
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::interpolateField(interpolator);
|
||||
return SurfaceSource::sampleOnPoints(interpolator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -70,17 +70,19 @@ class sampledDiscreteSurface
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample field on faces
|
||||
//- Sample volume field onto surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>>
|
||||
interpolateField(const interpolation<Type>&) const;
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -199,70 +201,76 @@ public:
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
// Sample
|
||||
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
const interpolation<scalar>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
const interpolation<vector>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
const interpolation<sphericalTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
const interpolation<symmTensor>& sampler
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
//- Sample volume field onto surface faces
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
const interpolation<tensor>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
const interpolation<scalar>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
const interpolation<vector>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
//- Interpolate volume field onto surface points
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
const interpolation<tensor>& interpolator
|
||||
) const;
|
||||
|
||||
//- Write information
|
||||
virtual void print(Ostream&) const;
|
||||
|
||||
// Output
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -28,5 +28,4 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -130,7 +130,7 @@ Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
}
|
||||
|
||||
|
||||
// create write methods
|
||||
// Create all write methods
|
||||
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
|
||||
|
||||
|
||||
|
||||
@ -27,6 +27,24 @@ Class
|
||||
Description
|
||||
A surfaceWriter for Ensight format.
|
||||
|
||||
\verbatim
|
||||
formatOptions
|
||||
{
|
||||
ensight
|
||||
{
|
||||
format ascii;
|
||||
collateTimes true;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Format options:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
format | ascii/binary | no | ascii
|
||||
collateTimes | use common geometry for times | no | true
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
ensightSurfaceWriter.C
|
||||
|
||||
@ -55,7 +73,7 @@ class ensightSurfaceWriter
|
||||
//- Write option (default: IOstream::ASCII)
|
||||
IOstream::streamFormat writeFormat_;
|
||||
|
||||
//- Collate times (default: ASCII)
|
||||
//- Collate times (default: true)
|
||||
bool collateTimes_;
|
||||
|
||||
|
||||
|
||||
@ -306,11 +306,11 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
<< "time values:" << nl;
|
||||
|
||||
label count = 0;
|
||||
forAll(times, timeI)
|
||||
forAll(times, timei)
|
||||
{
|
||||
osCase << ' ' << setw(12) << times[timeI];
|
||||
osCase << ' ' << setw(12) << times[timei];
|
||||
|
||||
if (++count % 6 == 0)
|
||||
if (!(++count % 6))
|
||||
{
|
||||
osCase << nl;
|
||||
}
|
||||
@ -335,7 +335,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
{
|
||||
Info<< "Writing mesh file to " << meshFile.name() << endl;
|
||||
}
|
||||
// use two-argument form for path-name to avoid validating the base-dir
|
||||
// Use two-argument form for path-name to avoid validating the base-dir
|
||||
ensightGeoFile osGeom(meshFile.path(), meshFile.name(), writeFormat_);
|
||||
osGeom << ensPart;
|
||||
}
|
||||
@ -352,7 +352,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
|
||||
fileName dataDir = baseDir/"data"/timeString;
|
||||
|
||||
// as per mkdir -p "data/000000"
|
||||
// As per mkdir -p "data/000000"
|
||||
mkDir(dataDir);
|
||||
|
||||
// Write field
|
||||
@ -378,7 +378,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
isNodeValues
|
||||
);
|
||||
|
||||
// place a timestamp in the directory for future reference
|
||||
// Place a timestamp in the directory for future reference
|
||||
{
|
||||
OFstream timeStamp(dataDir/"time");
|
||||
timeStamp
|
||||
|
||||
@ -43,7 +43,7 @@ Description
|
||||
// Optional format
|
||||
format free; // short, long, free
|
||||
}
|
||||
};
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
|
||||
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshSampleDistanceSurface.H"
|
||||
#include "dictionary.H"
|
||||
#include "polyMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfMeshSampleDistanceSurface, 0);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
surfMeshSample,
|
||||
surfMeshSampleDistanceSurface,
|
||||
word,
|
||||
distanceSurface
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfMeshSampleDistanceSurface::surfMeshSampleDistanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surfMeshSample(name, mesh, dict),
|
||||
SurfaceSource(name, mesh, dict),
|
||||
needsUpdate_(true)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::surfMeshSampleDistanceSurface::needsUpdate() const
|
||||
{
|
||||
return needsUpdate_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshSampleDistanceSurface::expire()
|
||||
{
|
||||
// Already marked as expired
|
||||
if (needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
needsUpdate_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshSampleDistanceSurface::update()
|
||||
{
|
||||
if (!needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SurfaceSource::createGeometry();
|
||||
|
||||
// Transfer content
|
||||
getOrCreateSurfMesh().transfer
|
||||
(
|
||||
SurfaceSource::surface()
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
print(Pout);
|
||||
Pout<< endl;
|
||||
}
|
||||
|
||||
needsUpdate_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshSampleDistanceSurface::sample
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
return
|
||||
(
|
||||
sampleType<scalar>(fieldName, sampleScheme)
|
||||
|| sampleType<vector>(fieldName, sampleScheme)
|
||||
|| sampleType<sphericalTensor>(fieldName, sampleScheme)
|
||||
|| sampleType<symmTensor>(fieldName, sampleScheme)
|
||||
|| sampleType<tensor>(fieldName, sampleScheme)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfMeshSampleDistanceSurface::print(Ostream& os) const
|
||||
{
|
||||
os << "distanceSurface: " << name() << " :"
|
||||
<< " surface:" << surfaceName()
|
||||
<< " distance:" << distance()
|
||||
<< " faces:" << surface().faces().size()
|
||||
<< " points:" << surface().points().size();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::surfMeshSampleDistanceSurface
|
||||
|
||||
Description
|
||||
Sampling surfFields onto a surfMesh based on a plane.
|
||||
The cuttingPlane algorithm 'cuts' the mesh.
|
||||
The plane is triangulated by default.
|
||||
|
||||
Note
|
||||
Does not actually cut until update() called.
|
||||
|
||||
SourceFiles
|
||||
surfMeshSampleDistanceSurface.C
|
||||
surfMeshSampleDistanceSurfaceTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfMeshSampleDistanceSurface_H
|
||||
#define surfMeshSampleDistanceSurface_H
|
||||
|
||||
#include "surfMeshSample.H"
|
||||
#include "distanceSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfMeshSampleDistanceSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfMeshSampleDistanceSurface
|
||||
:
|
||||
public surfMeshSample,
|
||||
private distanceSurface
|
||||
{
|
||||
// Private typedefs for convenience
|
||||
typedef distanceSurface SurfaceSource;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Track if the surface needs an update
|
||||
mutable bool needsUpdate_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample field on surface
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface.
|
||||
template<class Type>
|
||||
bool sampleType
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfMeshSampleDistanceSurface");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
surfMeshSampleDistanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfMeshSampleDistanceSurface() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The surface is from surfMesh
|
||||
using surfMeshSample::surface;
|
||||
|
||||
//- 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();
|
||||
|
||||
//- Sample the volume field onto surface
|
||||
virtual bool sample
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme = "cell"
|
||||
) const;
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "surfMeshSampleDistanceSurfaceTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshSampleDistanceSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::surfMeshSampleDistanceSurface::sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
return surfMeshSample::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
SurfaceSource::meshCells(),
|
||||
surface().faces(),
|
||||
surface().points()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::surfMeshSampleDistanceSurface::sampleType
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
const auto* volFldPtr = mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
||||
|
||||
if (!volFldPtr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
||||
|
||||
getOrCreateSurfField<Type>(*volFldPtr).field() =
|
||||
sampleOnFaces(*samplerPtr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,7 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshPlaneSampler.H"
|
||||
#include "surfMeshSamplePlane.H"
|
||||
#include "dictionary.H"
|
||||
#include "polyMesh.H"
|
||||
#include "volFields.H"
|
||||
@ -34,31 +34,20 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfMeshPlaneSampler, 0);
|
||||
defineTypeNameAndDebug(surfMeshSamplePlane, 0);
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
surfMeshSampler,
|
||||
surfMeshPlaneSampler,
|
||||
surfMeshSample,
|
||||
surfMeshSamplePlane,
|
||||
word,
|
||||
plane
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::surfMeshPlaneSampler::transferContent()
|
||||
{
|
||||
SurfaceSource& src = static_cast<SurfaceSource&>(*this);
|
||||
surfMesh& dst = getOrCreateSurfMesh();
|
||||
|
||||
dst.transfer(src);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
|
||||
Foam::surfMeshSamplePlane::surfMeshSamplePlane
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -67,7 +56,7 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
surfMeshSampler(name, mesh),
|
||||
surfMeshSample(name, mesh),
|
||||
SurfaceSource(planeDesc),
|
||||
zoneKey_(zoneKey),
|
||||
bounds_(),
|
||||
@ -82,14 +71,14 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
|
||||
}
|
||||
|
||||
|
||||
Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
|
||||
Foam::surfMeshSamplePlane::surfMeshSamplePlane
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surfMeshSampler(name, mesh, dict),
|
||||
surfMeshSample(name, mesh, dict),
|
||||
SurfaceSource(plane(dict)),
|
||||
zoneKey_(dict.lookupOrDefault<keyType>("zone", keyType::null)),
|
||||
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
|
||||
@ -119,13 +108,13 @@ Foam::surfMeshPlaneSampler::surfMeshPlaneSampler
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::surfMeshPlaneSampler::needsUpdate() const
|
||||
bool Foam::surfMeshSamplePlane::needsUpdate() const
|
||||
{
|
||||
return needsUpdate_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshPlaneSampler::expire()
|
||||
bool Foam::surfMeshSamplePlane::expire()
|
||||
{
|
||||
// Already marked as expired
|
||||
if (needsUpdate_)
|
||||
@ -138,7 +127,7 @@ bool Foam::surfMeshPlaneSampler::expire()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshPlaneSampler::update()
|
||||
bool Foam::surfMeshSamplePlane::update()
|
||||
{
|
||||
if (!needsUpdate_)
|
||||
{
|
||||
@ -243,32 +232,37 @@ bool Foam::surfMeshPlaneSampler::update()
|
||||
Pout<< endl;
|
||||
}
|
||||
|
||||
transferContent();
|
||||
// Transfer content
|
||||
getOrCreateSurfMesh().transfer
|
||||
(
|
||||
static_cast<SurfaceSource&>(*this)
|
||||
);
|
||||
|
||||
needsUpdate_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshPlaneSampler::sample
|
||||
bool Foam::surfMeshSamplePlane::sample
|
||||
(
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
return
|
||||
(
|
||||
sampleType<scalar>(fieldName)
|
||||
|| sampleType<vector>(fieldName)
|
||||
|| sampleType<sphericalTensor>(fieldName)
|
||||
|| sampleType<symmTensor>(fieldName)
|
||||
|| sampleType<tensor>(fieldName)
|
||||
sampleType<scalar>(fieldName, sampleScheme)
|
||||
|| sampleType<vector>(fieldName, sampleScheme)
|
||||
|| sampleType<sphericalTensor>(fieldName, sampleScheme)
|
||||
|| sampleType<symmTensor>(fieldName, sampleScheme)
|
||||
|| sampleType<tensor>(fieldName, sampleScheme)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfMeshPlaneSampler::print(Ostream& os) const
|
||||
void Foam::surfMeshSamplePlane::print(Ostream& os) const
|
||||
{
|
||||
os << "surfMeshPlaneSampler: " << name() << " :"
|
||||
os << "surfMeshSamplePlane: " << name() << " :"
|
||||
<< " base:" << cuttingPlane::refPoint()
|
||||
<< " normal:" << cuttingPlane::normal()
|
||||
<< " triangulate:" << triangulate_
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::surfMeshPlaneSampler
|
||||
Foam::surfMeshSamplePlane
|
||||
|
||||
Description
|
||||
Sampling surfFields onto a surfMesh based on a plane.
|
||||
@ -33,15 +33,15 @@ Note
|
||||
Does not actually cut until update() called.
|
||||
|
||||
SourceFiles
|
||||
surfMeshPlaneSampler.C
|
||||
surfMeshPlaneSamplerTemplates.C
|
||||
surfMeshSamplePlane.C
|
||||
surfMeshSamplePlaneTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfMeshPlaneSampler_H
|
||||
#define surfMeshPlaneSampler_H
|
||||
#ifndef surfMeshSamplePlane_H
|
||||
#define surfMeshSamplePlane_H
|
||||
|
||||
#include "surfMeshSampler.H"
|
||||
#include "surfMeshSample.H"
|
||||
#include "cuttingPlane.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -50,12 +50,12 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfMeshPlaneSampler Declaration
|
||||
Class surfMeshSamplePlane Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfMeshPlaneSampler
|
||||
class surfMeshSamplePlane
|
||||
:
|
||||
public surfMeshSampler,
|
||||
public surfMeshSample,
|
||||
private cuttingPlane
|
||||
{
|
||||
// Private typedefs for convenience
|
||||
@ -78,36 +78,33 @@ class surfMeshPlaneSampler
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Transfer mesh content from SurfaceSource to surfMesh
|
||||
void transferContent();
|
||||
//- Sample field on surface
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface.
|
||||
template<class Type>
|
||||
bool sampleType
|
||||
(
|
||||
const word& fieldName
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfMeshPlaneSampler");
|
||||
TypeName("surfMeshSamplePlane");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfMeshPlaneSampler
|
||||
surfMeshSamplePlane
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -117,7 +114,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfMeshPlaneSampler
|
||||
surfMeshSamplePlane
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -126,7 +123,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfMeshPlaneSampler() = default;
|
||||
virtual ~surfMeshSamplePlane() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -144,11 +141,15 @@ public:
|
||||
virtual bool update();
|
||||
|
||||
//- Sample the volume field onto surface
|
||||
virtual bool sample(const word& fieldName) const;
|
||||
virtual bool sample
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme = "cell"
|
||||
) const;
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
@ -159,7 +160,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "surfMeshPlaneSamplerTemplates.C"
|
||||
#include "surfMeshSamplePlaneTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,41 +23,50 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshPlaneSampler.H"
|
||||
#include "surfMeshSamplePlane.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::surfMeshPlaneSampler::sampleType
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::surfMeshSamplePlane::sampleOnFaces
|
||||
(
|
||||
const word& fieldName
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
return surfMeshSample::sampleOnFaces
|
||||
(
|
||||
sampler,
|
||||
SurfaceSource::meshCells(),
|
||||
surface().faces(),
|
||||
surface().points()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::surfMeshSamplePlane::sampleType
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
if (!mesh().foundObject<VolFieldType>(fieldName))
|
||||
const auto* volFldPtr = mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
||||
|
||||
if (!volFldPtr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const VolFieldType& fld = mesh().lookupObject<VolFieldType>(fieldName);
|
||||
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
||||
|
||||
getOrCreateSurfField<Type>(fld).field()
|
||||
= SurfaceSource::sample<Type>(fld);
|
||||
getOrCreateSurfField<Type>(*volFldPtr).field() =
|
||||
sampleOnFaces(*samplerPtr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::surfMeshPlaneSampler::sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const
|
||||
{
|
||||
return SurfaceSource::sample<Type>(vField);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,7 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshSampler.H"
|
||||
#include "surfMeshSample.H"
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -31,15 +31,15 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfMeshSampler, 0);
|
||||
defineRunTimeSelectionTable(surfMeshSampler, word);
|
||||
defineTypeNameAndDebug(surfMeshSample, 0);
|
||||
defineRunTimeSelectionTable(surfMeshSample, word);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::surfMesh&
|
||||
Foam::surfMeshSampler::getOrCreateSurfMesh() const
|
||||
Foam::surfMeshSample::getOrCreateSurfMesh() const
|
||||
{
|
||||
if (!mesh().foundObject<surfMesh>(name()))
|
||||
{
|
||||
@ -67,8 +67,8 @@ Foam::surfMeshSampler::getOrCreateSurfMesh() const
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::surfMeshSampler>
|
||||
Foam::surfMeshSampler::New
|
||||
Foam::autoPtr<Foam::surfMeshSample>
|
||||
Foam::surfMeshSample::New
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -89,13 +89,13 @@ Foam::surfMeshSampler::New
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<surfMeshSampler>(cstrIter()(name, mesh, dict));
|
||||
return autoPtr<surfMeshSample>(cstrIter()(name, mesh, dict));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfMeshSampler::surfMeshSampler
|
||||
Foam::surfMeshSample::surfMeshSample
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh
|
||||
@ -106,7 +106,7 @@ Foam::surfMeshSampler::surfMeshSampler
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfMeshSampler::surfMeshSampler
|
||||
Foam::surfMeshSample::surfMeshSample
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -122,20 +122,21 @@ Foam::surfMeshSampler::surfMeshSampler
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::surfMeshSampler::create() const
|
||||
void Foam::surfMeshSample::create() const
|
||||
{
|
||||
getOrCreateSurfMesh();
|
||||
}
|
||||
|
||||
|
||||
const Foam::surfMesh& Foam::surfMeshSampler::surface() const
|
||||
const Foam::surfMesh& Foam::surfMeshSample::surface() const
|
||||
{
|
||||
return mesh().lookupObject<surfMesh>(name());
|
||||
}
|
||||
|
||||
|
||||
// Demonstration of using separate tmp registry
|
||||
// Foam::label Foam::surfMeshSampler::sample
|
||||
//
|
||||
// Foam::label Foam::surfMeshSample::sample
|
||||
// (
|
||||
// const objectRegistry& store,
|
||||
// const UList<word>& fields
|
||||
@ -168,15 +169,16 @@ const Foam::surfMesh& Foam::surfMeshSampler::surface() const
|
||||
// }
|
||||
|
||||
|
||||
Foam::label Foam::surfMeshSampler::sample
|
||||
Foam::label Foam::surfMeshSample::sample
|
||||
(
|
||||
const UList<word>& fieldNames
|
||||
const UList<word>& fieldNames,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
label count = 0;
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
if (sample(fieldName))
|
||||
if (sample(fieldName, sampleScheme))
|
||||
{
|
||||
++count;
|
||||
}
|
||||
@ -186,7 +188,7 @@ Foam::label Foam::surfMeshSampler::sample
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::surfMeshSampler::write(const wordRes& select) const
|
||||
Foam::label Foam::surfMeshSample::write(const wordRes& select) const
|
||||
{
|
||||
label count =
|
||||
(
|
||||
@ -207,7 +209,7 @@ Foam::label Foam::surfMeshSampler::write(const wordRes& select) const
|
||||
|
||||
|
||||
|
||||
void Foam::surfMeshSampler::print(Ostream& os) const
|
||||
void Foam::surfMeshSample::print(Ostream& os) const
|
||||
{
|
||||
os << type();
|
||||
}
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::surfMeshSampler
|
||||
Foam::surfMeshSample
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
@ -31,13 +31,13 @@ Description
|
||||
An abstract class for surfMesh with sampling.
|
||||
|
||||
SourceFiles
|
||||
surfMeshSampler.C
|
||||
surfMeshSamplerTemplates.C
|
||||
surfMeshSample.C
|
||||
surfMeshSampleTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfMeshSampler_H
|
||||
#define surfMeshSampler_H
|
||||
#ifndef surfMeshSample_H
|
||||
#define surfMeshSample_H
|
||||
|
||||
#include "surfMesh.H"
|
||||
#include "surfFields.H"
|
||||
@ -61,13 +61,13 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class surfMeshSampler;
|
||||
class surfMeshSample;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfMeshSampler Declaration
|
||||
Class surfMeshSample Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfMeshSampler
|
||||
class surfMeshSample
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -78,15 +78,21 @@ class surfMeshSampler
|
||||
const polyMesh& mesh_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Service methods
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- General loop for sampling elements to faces
|
||||
template<class Type>
|
||||
static tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler,
|
||||
const labelUList& elements,
|
||||
const faceList& fcs,
|
||||
const pointField& pts
|
||||
);
|
||||
|
||||
|
||||
//- Get existing or create new surfMesh
|
||||
surfMesh& getOrCreateSurfMesh() const;
|
||||
|
||||
@ -116,14 +122,14 @@ protected:
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfMeshSampler");
|
||||
TypeName("surfMeshSample");
|
||||
|
||||
|
||||
//- Declare run-time constructor selection table
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
surfMeshSampler,
|
||||
surfMeshSample,
|
||||
word,
|
||||
(
|
||||
const word& name,
|
||||
@ -149,12 +155,12 @@ public:
|
||||
mesh_(mesh)
|
||||
{}
|
||||
|
||||
autoPtr<surfMeshSampler> operator()(Istream& is) const
|
||||
autoPtr<surfMeshSample> operator()(Istream& is) const
|
||||
{
|
||||
word name(is);
|
||||
dictionary dict(is);
|
||||
|
||||
return surfMeshSampler::New(name, mesh_, dict);
|
||||
return surfMeshSample::New(name, mesh_, dict);
|
||||
}
|
||||
};
|
||||
|
||||
@ -162,14 +168,14 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from name, mesh
|
||||
surfMeshSampler
|
||||
surfMeshSample
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfMeshSampler
|
||||
surfMeshSample
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -178,7 +184,7 @@ public:
|
||||
|
||||
|
||||
//- Clone
|
||||
autoPtr<surfMeshSampler> clone() const
|
||||
autoPtr<surfMeshSample> clone() const
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
@ -189,7 +195,7 @@ public:
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected surface
|
||||
static autoPtr<surfMeshSampler> New
|
||||
static autoPtr<surfMeshSample> New
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -198,7 +204,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfMeshSampler() = default;
|
||||
virtual ~surfMeshSample() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -249,11 +255,19 @@ public:
|
||||
|
||||
// Execute
|
||||
|
||||
//- Sample from specified volume field to surface
|
||||
virtual bool sample(const word& fieldName) const = 0;
|
||||
//- Sample from specified volume field to obtain surface field.
|
||||
virtual bool sample
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme = "cell"
|
||||
) const = 0;
|
||||
|
||||
//- Sample from volume fields to specified surface fields.
|
||||
virtual label sample(const UList<word>& fieldNames) const;
|
||||
//- Sample from specified volume fields to obtain surface fields.
|
||||
virtual label sample
|
||||
(
|
||||
const UList<word>& fieldNames,
|
||||
const word& sampleScheme = "cell"
|
||||
) const;
|
||||
|
||||
|
||||
// Write
|
||||
@ -274,7 +288,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "surfMeshSamplerTemplates.C"
|
||||
# include "surfMeshSampleTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -23,14 +23,50 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshSampler.H"
|
||||
#include "surfMeshSample.H"
|
||||
#include "dimensionedType.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::surfMeshSample::sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler,
|
||||
const labelUList& elements,
|
||||
const faceList& fcs,
|
||||
const pointField& pts
|
||||
)
|
||||
{
|
||||
const label len = elements.size();
|
||||
|
||||
if (len != fcs.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "size mismatch: "
|
||||
<< "sampled elements (" << len
|
||||
<< ") != faces (" << fcs.size() << ')'
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
auto tvalues = tmp<Field<Type>>::New(len);
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
const label celli = elements[i];
|
||||
const point pt = fcs[i].centre(pts);
|
||||
|
||||
values[i] = sampler.interpolate(pt, celli);
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::DimensionedField<Type, Foam::surfGeoMesh>&
|
||||
Foam::surfMeshSampler::getOrCreateSurfField
|
||||
Foam::surfMeshSample::getOrCreateSurfField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
) const
|
||||
@ -68,7 +104,7 @@ Foam::surfMeshSampler::getOrCreateSurfField
|
||||
// // Older code for transferring an IOField to a surfField between
|
||||
// // different registries
|
||||
// template<class Type>
|
||||
// bool Foam::surfMeshSampler::transferField
|
||||
// bool Foam::surfMeshSample::transferField
|
||||
// (
|
||||
// const objectRegistry& store,
|
||||
// const word& fieldName
|
||||
@ -104,7 +140,7 @@ Foam::surfMeshSampler::getOrCreateSurfField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::surfMeshSampler::writeFields
|
||||
Foam::label Foam::surfMeshSample::writeFields
|
||||
(
|
||||
const wordRes& select
|
||||
) const
|
||||
@ -112,7 +148,8 @@ Foam::label Foam::surfMeshSampler::writeFields
|
||||
typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
|
||||
const surfMesh& s = surface();
|
||||
|
||||
const wordList fieldNames = s.sortedNames<SurfFieldType>(select);
|
||||
const wordList fieldNames(s.sortedNames<SurfFieldType>(select));
|
||||
|
||||
for (const word& fieldName : fieldNames)
|
||||
{
|
||||
s.lookupObject<SurfFieldType>(fieldName).write();
|
||||
@ -44,7 +44,7 @@ namespace Foam
|
||||
surfMeshSamplers,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
bool Foam::surfMeshSamplers::verbose_ = false;
|
||||
@ -106,9 +106,11 @@ Foam::surfMeshSamplers::surfMeshSamplers
|
||||
)
|
||||
:
|
||||
functionObjects::regionFunctionObject(name, runTime, dict),
|
||||
PtrList<surfMeshSampler>(),
|
||||
PtrList<surfMeshSample>(),
|
||||
mesh_(refCast<const fvMesh>(obr_)),
|
||||
fieldSelection_()
|
||||
fieldSelection_(),
|
||||
derivedNames_(),
|
||||
sampleScheme_(word::null)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -122,10 +124,11 @@ Foam::surfMeshSamplers::surfMeshSamplers
|
||||
)
|
||||
:
|
||||
functionObjects::regionFunctionObject(name, obr, dict),
|
||||
PtrList<surfMeshSampler>(),
|
||||
PtrList<surfMeshSample>(),
|
||||
mesh_(refCast<const fvMesh>(obr)),
|
||||
fieldSelection_(),
|
||||
derivedNames_()
|
||||
derivedNames_(),
|
||||
sampleScheme_(word::null)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -141,8 +144,11 @@ void Foam::surfMeshSamplers::verbose(const bool verbosity)
|
||||
|
||||
bool Foam::surfMeshSamplers::execute()
|
||||
{
|
||||
if (size())
|
||||
if (empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const objectRegistry& db = mesh_.thisDb();
|
||||
|
||||
// Manage derived names
|
||||
@ -234,6 +240,7 @@ bool Foam::surfMeshSamplers::execute()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The acceptable fields
|
||||
wordHashSet acceptable(added);
|
||||
acceptable.insertMany(acceptType<scalar>());
|
||||
@ -245,7 +252,7 @@ bool Foam::surfMeshSamplers::execute()
|
||||
const wordList fields = acceptable.sortedToc();
|
||||
if (!fields.empty())
|
||||
{
|
||||
for (surfMeshSampler& s : surfaces())
|
||||
for (surfMeshSample& s : surfaces())
|
||||
{
|
||||
// Potentially monitor the update for writing geometry?
|
||||
if (s.needsUpdate())
|
||||
@ -253,12 +260,11 @@ bool Foam::surfMeshSamplers::execute()
|
||||
s.update();
|
||||
}
|
||||
|
||||
s.sample(fields);
|
||||
s.sample(fields, sampleScheme_);
|
||||
}
|
||||
}
|
||||
|
||||
checkOutNames(db, cleanup);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -287,7 +293,7 @@ bool Foam::surfMeshSamplers::write()
|
||||
// Avoid duplicate entries
|
||||
select.uniq();
|
||||
|
||||
for (const surfMeshSampler& s : surfaces())
|
||||
for (const surfMeshSample& s : surfaces())
|
||||
{
|
||||
s.write(select);
|
||||
}
|
||||
@ -305,6 +311,8 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
|
||||
|
||||
if (dict.found("surfaces"))
|
||||
{
|
||||
sampleScheme_ = dict.lookupOrDefault<word>("sampleScheme", "cell");
|
||||
|
||||
dict.lookup("fields") >> fieldSelection_;
|
||||
fieldSelection_.uniq();
|
||||
|
||||
@ -316,10 +324,10 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
|
||||
}
|
||||
Info<< nl;
|
||||
|
||||
PtrList<surfMeshSampler> newList
|
||||
PtrList<surfMeshSample> newList
|
||||
(
|
||||
dict.lookup("surfaces"),
|
||||
surfMeshSampler::iNew(mesh_)
|
||||
surfMeshSample::iNew(mesh_)
|
||||
);
|
||||
transfer(newList);
|
||||
|
||||
@ -332,7 +340,7 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
|
||||
if (this->size())
|
||||
{
|
||||
Info<< "Reading surface description:" << nl;
|
||||
for (surfMeshSampler& s : surfaces())
|
||||
for (surfMeshSample& s : surfaces())
|
||||
{
|
||||
Info<< " " << s.name() << nl;
|
||||
if (createOnRead)
|
||||
@ -383,7 +391,7 @@ void Foam::surfMeshSamplers::readUpdate(const polyMesh::readUpdateState state)
|
||||
|
||||
bool Foam::surfMeshSamplers::needsUpdate() const
|
||||
{
|
||||
for (const surfMeshSampler& s : surfaces())
|
||||
for (const surfMeshSample& s : surfaces())
|
||||
{
|
||||
if (s.needsUpdate())
|
||||
{
|
||||
@ -399,7 +407,7 @@ bool Foam::surfMeshSamplers::expire()
|
||||
{
|
||||
bool justExpired = false;
|
||||
|
||||
for (surfMeshSampler& s : surfaces())
|
||||
for (surfMeshSample& s : surfaces())
|
||||
{
|
||||
if (s.expire())
|
||||
{
|
||||
@ -420,7 +428,7 @@ bool Foam::surfMeshSamplers::update()
|
||||
}
|
||||
|
||||
bool updated = false;
|
||||
for (surfMeshSampler& s : surfaces())
|
||||
for (surfMeshSample& s : surfaces())
|
||||
{
|
||||
if (s.update())
|
||||
{
|
||||
@ -47,6 +47,9 @@ Description
|
||||
// Fields to be sampled
|
||||
fields (p U);
|
||||
|
||||
// Scheme to obtain face centre value
|
||||
sampleScheme cell;
|
||||
|
||||
// Optional: pre-defined derived fields to be sampled
|
||||
derived (rhoU pTotal);
|
||||
|
||||
@ -79,7 +82,7 @@ SourceFiles
|
||||
#define surfMeshSamplers_H
|
||||
|
||||
#include "regionFunctionObject.H"
|
||||
#include "surfMeshSampler.H"
|
||||
#include "surfMeshSample.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "wordRes.H"
|
||||
@ -102,7 +105,7 @@ class dictionary;
|
||||
class surfMeshSamplers
|
||||
:
|
||||
public functionObjects::regionFunctionObject,
|
||||
public PtrList<surfMeshSampler>
|
||||
public PtrList<surfMeshSample>
|
||||
{
|
||||
// Static data members
|
||||
|
||||
@ -124,6 +127,9 @@ class surfMeshSamplers
|
||||
//- Names of derived fields to create and sample
|
||||
wordList derivedNames_;
|
||||
|
||||
//- Sample scheme to obtain face values
|
||||
word sampleScheme_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -135,15 +141,15 @@ class surfMeshSamplers
|
||||
);
|
||||
|
||||
//- Access the sampling surfaces
|
||||
inline const PtrList<surfMeshSampler>& surfaces() const
|
||||
inline const PtrList<surfMeshSample>& surfaces() const
|
||||
{
|
||||
return static_cast<const PtrList<surfMeshSampler>&>(*this);
|
||||
return static_cast<const PtrList<surfMeshSample>&>(*this);
|
||||
}
|
||||
|
||||
//- Access the sampling surfaces
|
||||
inline PtrList<surfMeshSampler>& surfaces()
|
||||
inline PtrList<surfMeshSample>& surfaces()
|
||||
{
|
||||
return static_cast<PtrList<surfMeshSampler>&>(*this);
|
||||
return static_cast<PtrList<surfMeshSample>&>(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -152,8 +158,10 @@ class surfMeshSamplers
|
||||
wordList acceptType() const;
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
//- No copy construct
|
||||
surfMeshSamplers(const surfMeshSamplers&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const surfMeshSamplers&) = delete;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,6 +37,7 @@ Foam::surfMeshSamplers::acceptType() const
|
||||
return mesh_.names<VolFieldType>(fieldSelection_);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
template<class Type>
|
||||
Foam::wordList
|
||||
@ -55,10 +56,8 @@ Foam::surfMeshSamplers::acceptType
|
||||
|
||||
return objects.names(VolFieldType::typeName, fieldSelection_);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return mesh_.names<VolFieldType>(fieldSelection_);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -23,7 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshDiscreteSampler.H"
|
||||
#include "surfMeshSampleDiscrete.H"
|
||||
#include "MeshedSurfaces.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -32,14 +32,14 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(surfMeshDiscreteSampler, 0);
|
||||
defineTypeNameAndDebug(surfMeshSampleDiscrete, 0);
|
||||
|
||||
// Add under name "sampledTriSurfaceMesh"
|
||||
// for symmetry with normal sampledSurface
|
||||
// for symmetry with regular sampledSurface
|
||||
addNamedToRunTimeSelectionTable
|
||||
(
|
||||
surfMeshSampler,
|
||||
surfMeshDiscreteSampler,
|
||||
surfMeshSample,
|
||||
surfMeshSampleDiscrete,
|
||||
word,
|
||||
sampledTriSurfaceMesh
|
||||
);
|
||||
@ -48,18 +48,18 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::surfMeshDiscreteSampler::transferContent()
|
||||
void Foam::surfMeshSampleDiscrete::transferContent()
|
||||
{
|
||||
SurfaceSource& src = static_cast<SurfaceSource&>(*this);
|
||||
surfMesh& dst = getOrCreateSurfMesh();
|
||||
|
||||
dst.transfer(src);
|
||||
getOrCreateSurfMesh().transfer
|
||||
(
|
||||
static_cast<SurfaceSource&>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfMeshDiscreteSampler::surfMeshDiscreteSampler
|
||||
Foam::surfMeshSampleDiscrete::surfMeshSampleDiscrete
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -67,24 +67,24 @@ Foam::surfMeshDiscreteSampler::surfMeshDiscreteSampler
|
||||
const discreteSurface::samplingSource sampleSource
|
||||
)
|
||||
:
|
||||
surfMeshSampler(name, mesh),
|
||||
surfMeshSample(name, mesh),
|
||||
SurfaceSource(mesh, surfaceName, sampleSource, false) // no interpolate
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfMeshDiscreteSampler::surfMeshDiscreteSampler
|
||||
Foam::surfMeshSampleDiscrete::surfMeshSampleDiscrete
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surfMeshSampler(name, mesh),
|
||||
surfMeshSample(name, mesh),
|
||||
SurfaceSource(mesh, dict, false) // no interpolate
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfMeshDiscreteSampler::surfMeshDiscreteSampler
|
||||
Foam::surfMeshSampleDiscrete::surfMeshSampleDiscrete
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -92,32 +92,26 @@ Foam::surfMeshDiscreteSampler::surfMeshDiscreteSampler
|
||||
const word& sampleSourceName
|
||||
)
|
||||
:
|
||||
surfMeshSampler(name, mesh),
|
||||
surfMeshSample(name, mesh),
|
||||
SurfaceSource(name, mesh, surface, sampleSourceName, false)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfMeshDiscreteSampler::~surfMeshDiscreteSampler()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::surfMeshDiscreteSampler::needsUpdate() const
|
||||
bool Foam::surfMeshSampleDiscrete::needsUpdate() const
|
||||
{
|
||||
return SurfaceSource::needsUpdate();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshDiscreteSampler::expire()
|
||||
bool Foam::surfMeshSampleDiscrete::expire()
|
||||
{
|
||||
return SurfaceSource::expire();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshDiscreteSampler::update()
|
||||
bool Foam::surfMeshSampleDiscrete::update()
|
||||
{
|
||||
if (SurfaceSource::update())
|
||||
{
|
||||
@ -129,7 +123,7 @@ bool Foam::surfMeshDiscreteSampler::update()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshDiscreteSampler::update(const treeBoundBox& bb)
|
||||
bool Foam::surfMeshSampleDiscrete::update(const treeBoundBox& bb)
|
||||
{
|
||||
if (SurfaceSource::update(bb))
|
||||
{
|
||||
@ -141,18 +135,19 @@ bool Foam::surfMeshDiscreteSampler::update(const treeBoundBox& bb)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::surfMeshDiscreteSampler::sample
|
||||
bool Foam::surfMeshSampleDiscrete::sample
|
||||
(
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
return
|
||||
(
|
||||
sampleType<scalar>(fieldName)
|
||||
|| sampleType<vector>(fieldName)
|
||||
|| sampleType<sphericalTensor>(fieldName)
|
||||
|| sampleType<symmTensor>(fieldName)
|
||||
|| sampleType<tensor>(fieldName)
|
||||
sampleType<scalar>(fieldName, sampleScheme)
|
||||
|| sampleType<vector>(fieldName, sampleScheme)
|
||||
|| sampleType<sphericalTensor>(fieldName, sampleScheme)
|
||||
|| sampleType<symmTensor>(fieldName, sampleScheme)
|
||||
|| sampleType<tensor>(fieldName, sampleScheme)
|
||||
);
|
||||
}
|
||||
|
||||
@ -22,23 +22,47 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::surfMeshDiscreteSampler
|
||||
Foam::surfMeshSampleDiscrete
|
||||
|
||||
Description
|
||||
Sampling surfFields onto a surfMesh based on a triSurfaceMesh.
|
||||
|
||||
This is often embedded as part of a surfMeshSamplers function object.
|
||||
|
||||
Usage
|
||||
Example of function object partial specification:
|
||||
\verbatim
|
||||
surfaces
|
||||
(
|
||||
surface1
|
||||
{
|
||||
type sampledTriSurfaceMesh;
|
||||
surface something.obj;
|
||||
source cells;
|
||||
}
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
Where the sub-entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | sampledTriSurfaceMesh | yes |
|
||||
surface | surface name in triSurface/ | yes |
|
||||
source | cells/insideCells/boundaryFaces | yes |
|
||||
\endtable
|
||||
|
||||
See Also
|
||||
discreteSurface, surfMeshSampler
|
||||
discreteSurface, surfMeshSample
|
||||
|
||||
SourceFiles
|
||||
surfMeshDiscreteSampler.C
|
||||
surfMeshSampleDiscrete.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfMeshDiscreteSampler_H
|
||||
#define surfMeshDiscreteSampler_H
|
||||
#ifndef surfMeshSampleDiscrete_H
|
||||
#define surfMeshSampleDiscrete_H
|
||||
|
||||
#include "surfMeshSampler.H"
|
||||
#include "surfMeshSample.H"
|
||||
#include "discreteSurface.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
|
||||
@ -47,15 +71,15 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class surfMeshDiscreteSampler;
|
||||
class surfMeshSampleDiscrete;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfMeshDiscreteSampler Declaration
|
||||
Class surfMeshSampleDiscrete Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfMeshDiscreteSampler
|
||||
class surfMeshSampleDiscrete
|
||||
:
|
||||
public surfMeshSampler,
|
||||
public surfMeshSample,
|
||||
private discreteSurface
|
||||
{
|
||||
// Private typedefs for convenience
|
||||
@ -67,16 +91,25 @@ class surfMeshDiscreteSampler
|
||||
//- Transfer mesh content from SurfaceSource to surfMesh
|
||||
void transferContent();
|
||||
|
||||
//- Sample field on surface.
|
||||
template<class Type>
|
||||
bool sampleType
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfMeshDiscreteSampler");
|
||||
TypeName("surfMeshSampleDiscrete");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfMeshDiscreteSampler
|
||||
surfMeshSampleDiscrete
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -85,7 +118,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfMeshDiscreteSampler
|
||||
surfMeshSampleDiscrete
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -93,7 +126,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from triSurface
|
||||
surfMeshDiscreteSampler
|
||||
surfMeshSampleDiscrete
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
@ -103,7 +136,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surfMeshDiscreteSampler();
|
||||
virtual ~surfMeshSampleDiscrete() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -123,15 +156,14 @@ public:
|
||||
//- Update the surface using a bound box to limit the searching.
|
||||
// For direct use, i.e. not through sample.
|
||||
// Do nothing (and return false) if no update was needed
|
||||
bool update(const treeBoundBox&);
|
||||
|
||||
bool update(const treeBoundBox& bb);
|
||||
|
||||
//- Sample the volume field onto surface
|
||||
virtual bool sample(const word& fieldName) const;
|
||||
|
||||
//- Sample field on surface.
|
||||
template<class Type>
|
||||
bool sampleType(const word& fieldName) const;
|
||||
virtual bool sample
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& sampleScheme = "cell"
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
@ -143,7 +175,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "surfMeshDiscreteSamplerTemplates.C"
|
||||
#include "surfMeshSampleDiscreteTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -23,31 +23,33 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfMeshDiscreteSampler.H"
|
||||
#include "surfMeshSampleDiscrete.H"
|
||||
#include "dimensionedType.H"
|
||||
#include "error.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::surfMeshDiscreteSampler::sampleType
|
||||
bool Foam::surfMeshSampleDiscrete::sampleType
|
||||
(
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
const polyMesh& mesh = SurfaceSource::mesh();
|
||||
const auto volFldPtr =
|
||||
SurfaceSource::mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
||||
|
||||
if (!mesh.foundObject<VolFieldType>(fieldName))
|
||||
if (!volFldPtr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const VolFieldType& fld = mesh.lookupObject<VolFieldType>(fieldName);
|
||||
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
||||
|
||||
getOrCreateSurfField<Type>(fld).field()
|
||||
= SurfaceSource::sampleField(fld);
|
||||
getOrCreateSurfField<Type>(*volFldPtr).field()
|
||||
= SurfaceSource::sampleOnFaces(*samplerPtr);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -55,14 +57,14 @@ bool Foam::surfMeshDiscreteSampler::sampleType
|
||||
|
||||
// template<class Type>
|
||||
// Foam::tmp<Foam::DimensionedField<Type, Foam::surfGeoMesh>>
|
||||
// Foam::surfMeshDiscreteSampler::sampleField
|
||||
// Foam::surfMeshSampleDiscrete::sampleOnFaces
|
||||
// (
|
||||
// const GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
// ) const
|
||||
// {
|
||||
// typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
|
||||
//
|
||||
// tmp<Field<Type>> tfield = SurfaceSource::sampleField(fld);
|
||||
// tmp<Field<Type>> tfield = SurfaceSource::sampleOnFaces(fld);
|
||||
// SurfFieldType& result = getOrCreateSurfField<Type>(fld);
|
||||
//
|
||||
// // need to verify if this will be needed (in the future)
|
||||
@ -72,7 +74,7 @@ bool Foam::surfMeshDiscreteSampler::sampleType
|
||||
// // maybe resampling changed the surfMesh,
|
||||
// // but the existing surfField wasn't updated
|
||||
//
|
||||
// result.setSize(s.size(), Zero);
|
||||
// result.resize(s.size(), Zero);
|
||||
// }
|
||||
//
|
||||
// if (result.size() != sampleElements().size())
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,6 +37,7 @@ static const Foam::scalar zeroish = Foam::SMALL;
|
||||
static const Foam::scalar positive = Foam::SMALL * 1E3;
|
||||
//! \endcond
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::cuttingPlane::calcCutCells
|
||||
@ -105,9 +106,9 @@ void Foam::cuttingPlane::intersectEdges
|
||||
|
||||
DynamicList<point> dynCuttingPoints(4*meshCells_.size());
|
||||
|
||||
forAll(edges, edgeI)
|
||||
forAll(edges, edgei)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
const edge& e = edges[edgei];
|
||||
|
||||
if
|
||||
(
|
||||
@ -116,7 +117,7 @@ void Foam::cuttingPlane::intersectEdges
|
||||
)
|
||||
{
|
||||
// Edge is cut
|
||||
edgePoint[edgeI] = dynCuttingPoints.size();
|
||||
edgePoint[edgei] = dynCuttingPoints.size();
|
||||
|
||||
const point& p0 = points[e[0]];
|
||||
const point& p1 = points[e[1]];
|
||||
@ -138,7 +139,7 @@ void Foam::cuttingPlane::intersectEdges
|
||||
}
|
||||
else
|
||||
{
|
||||
edgePoint[edgeI] = -1;
|
||||
edgePoint[edgei] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,48 +152,48 @@ bool Foam::cuttingPlane::walkCell
|
||||
const primitiveMesh& mesh,
|
||||
const labelUList& edgePoint,
|
||||
const label celli,
|
||||
const label startEdgeI,
|
||||
const label startEdgei,
|
||||
DynamicList<label>& faceVerts
|
||||
)
|
||||
{
|
||||
label facei = -1;
|
||||
label edgeI = startEdgeI;
|
||||
label edgei = startEdgei;
|
||||
|
||||
label nIter = 0;
|
||||
|
||||
faceVerts.clear();
|
||||
do
|
||||
{
|
||||
faceVerts.append(edgePoint[edgeI]);
|
||||
faceVerts.append(edgePoint[edgei]);
|
||||
|
||||
// Cross edge to other face
|
||||
facei = meshTools::otherFace(mesh, celli, facei, edgeI);
|
||||
facei = meshTools::otherFace(mesh, celli, facei, edgei);
|
||||
|
||||
// Find next cut edge on face.
|
||||
const labelList& fEdges = mesh.faceEdges()[facei];
|
||||
|
||||
label nextEdgeI = -1;
|
||||
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.
|
||||
|
||||
for (const label edge2I : fEdges)
|
||||
for (const label edge2i : fEdges)
|
||||
{
|
||||
if (edge2I != edgeI && edgePoint[edge2I] != -1)
|
||||
if (edge2i != edgei && edgePoint[edge2i] != -1)
|
||||
{
|
||||
nextEdgeI = edge2I;
|
||||
nextEdgei = edge2i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextEdgeI == -1)
|
||||
if (nextEdgei == -1)
|
||||
{
|
||||
// Did not find another cut edge on facei. Do what?
|
||||
WarningInFunction
|
||||
<< "Did not find closed walk along surface of cell " << celli
|
||||
<< " starting from edge " << startEdgeI
|
||||
<< " starting from edge " << startEdgei
|
||||
<< " in " << nIter << " iterations." << nl
|
||||
<< "Collected cutPoints so far:" << faceVerts
|
||||
<< endl;
|
||||
@ -200,7 +201,7 @@ bool Foam::cuttingPlane::walkCell
|
||||
return false;
|
||||
}
|
||||
|
||||
edgeI = nextEdgeI;
|
||||
edgei = nextEdgei;
|
||||
|
||||
++nIter;
|
||||
|
||||
@ -209,13 +210,13 @@ bool Foam::cuttingPlane::walkCell
|
||||
WarningInFunction
|
||||
<< "Did not find closed walk along surface of cell " << celli
|
||||
<< " at " << mesh.cellCentres()[celli]
|
||||
<< " starting from edge " << startEdgeI
|
||||
<< " starting from edge " << startEdgei
|
||||
<< " in " << nIter << " iterations."
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
} while (edgeI != startEdgeI);
|
||||
} while (edgei != startEdgei);
|
||||
|
||||
|
||||
if (faceVerts.size() >= 3)
|
||||
@ -225,7 +226,7 @@ bool Foam::cuttingPlane::walkCell
|
||||
|
||||
WarningInFunction
|
||||
<< "Did not find closed walk along surface of cell " << celli
|
||||
<< " starting from edge " << startEdgeI << nl
|
||||
<< " starting from edge " << startEdgei << nl
|
||||
<< "Collected cutPoints so far:" << faceVerts
|
||||
<< endl;
|
||||
|
||||
@ -254,19 +255,19 @@ void Foam::cuttingPlane::walkCellCuts
|
||||
// Find the starting edge to walk from.
|
||||
const labelList& cEdges = mesh.cellEdges()[celli];
|
||||
|
||||
label startEdgeI = -1;
|
||||
label startEdgei = -1;
|
||||
|
||||
for (const label edgeI : cEdges)
|
||||
for (const label edgei : cEdges)
|
||||
{
|
||||
if (edgePoint[edgeI] != -1)
|
||||
if (edgePoint[edgei] != -1)
|
||||
{
|
||||
startEdgeI = edgeI;
|
||||
startEdgei = edgei;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for the unexpected ...
|
||||
if (startEdgeI == -1)
|
||||
if (startEdgei == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot find cut edge for cut cell " << celli
|
||||
@ -279,7 +280,7 @@ void Foam::cuttingPlane::walkCellCuts
|
||||
mesh,
|
||||
edgePoint,
|
||||
celli,
|
||||
startEdgeI,
|
||||
startEdgei,
|
||||
faceVerts
|
||||
);
|
||||
|
||||
@ -379,7 +380,6 @@ void Foam::cuttingPlane::remapFaces
|
||||
const labelUList& faceMap
|
||||
)
|
||||
{
|
||||
// Recalculate the cells cut
|
||||
if (notNull(faceMap) && faceMap.size())
|
||||
{
|
||||
MeshStorage::remapFaces(faceMap);
|
||||
|
||||
@ -98,7 +98,7 @@ class cuttingPlane
|
||||
const primitiveMesh&,
|
||||
const labelUList& edgePoint,
|
||||
const label celli,
|
||||
const label startEdgeI,
|
||||
const label startEdgei,
|
||||
DynamicList<label>& faceVerts
|
||||
);
|
||||
|
||||
@ -138,7 +138,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from plane and mesh reference,
|
||||
// possibly restricted to a list of cells
|
||||
//- possibly restricted to a list of cells
|
||||
cuttingPlane
|
||||
(
|
||||
const plane& pln,
|
||||
@ -150,31 +150,30 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return plane used
|
||||
//- Return the plane used
|
||||
const plane& planeDesc() const
|
||||
{
|
||||
return static_cast<const plane&>(*this);
|
||||
}
|
||||
|
||||
//- Return List of cells cut by the plane
|
||||
//- The mesh cells cut by the plane
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
//- Return true or false to question: have any cells been cut?
|
||||
//- The mesh cells cut by the plane
|
||||
labelList& meshCells()
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
//- Have any cells been cut?
|
||||
bool cut() const
|
||||
{
|
||||
return meshCells_.size();
|
||||
}
|
||||
|
||||
//- 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
|
||||
|
||||
@ -189,12 +188,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "cuttingPlaneTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,26 +36,105 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(distanceSurface, 0);
|
||||
addToRunTimeSelectionTable(sampledSurface, distanceSurface, word);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::distanceSurface::distanceSurface
|
||||
(
|
||||
const word& defaultSurfaceName,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
surfPtr_
|
||||
(
|
||||
searchableSurface::New
|
||||
(
|
||||
dict.lookup("surfaceType"),
|
||||
IOobject
|
||||
(
|
||||
dict.lookupOrDefault("surfaceName", defaultSurfaceName),
|
||||
mesh.time().constant(), // directory
|
||||
"triSurface", // instance
|
||||
mesh.time(), // registry
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dict
|
||||
)
|
||||
),
|
||||
distance_(readScalar(dict.lookup("distance"))),
|
||||
signed_(readBool(dict.lookup("signed"))),
|
||||
cell_(dict.lookupOrDefault("cell", true)),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
|
||||
zoneKey_(keyType::null),
|
||||
isoSurfCellPtr_(nullptr),
|
||||
isoSurfPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
Foam::distanceSurface::distanceSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const bool interpolate,
|
||||
const word& surfaceType,
|
||||
const word& surfaceName,
|
||||
const scalar distance,
|
||||
const bool signedDistance,
|
||||
const bool cell,
|
||||
const Switch regularise,
|
||||
const boundBox& bounds
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
surfPtr_
|
||||
(
|
||||
searchableSurface::New
|
||||
(
|
||||
surfaceType,
|
||||
IOobject
|
||||
(
|
||||
surfaceName, // name
|
||||
mesh.time().constant(), // directory
|
||||
"triSurface", // instance
|
||||
mesh.time(), // registry
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dictionary()
|
||||
)
|
||||
),
|
||||
distance_(distance),
|
||||
signed_(signedDistance),
|
||||
cell_(cell),
|
||||
regularise_(regularise),
|
||||
bounds_(bounds),
|
||||
zoneKey_(keyType::null),
|
||||
isoSurfCellPtr_(nullptr),
|
||||
isoSurfPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::distanceSurface::createGeometry()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "distanceSurface::createGeometry :updating geometry." << endl;
|
||||
Pout<< "distanceSurface::createGeometry updating geometry." << endl;
|
||||
}
|
||||
|
||||
// Clear any stored topologies
|
||||
isoSurfCellPtr_.clear();
|
||||
isoSurfPtr_.clear();
|
||||
|
||||
// Clear derived data
|
||||
clearGeom();
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh_);
|
||||
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
|
||||
const labelList& own = fvm.faceOwner();
|
||||
|
||||
// Distance to cell centres
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -77,7 +156,7 @@ void Foam::distanceSurface::createGeometry()
|
||||
dimensionedScalar(dimLength, Zero)
|
||||
)
|
||||
);
|
||||
volScalarField& cellDistance = cellDistancePtr_();
|
||||
volScalarField& cellDistance = *cellDistancePtr_;
|
||||
|
||||
// Internal field
|
||||
{
|
||||
@ -110,10 +189,17 @@ void Foam::distanceSurface::createGeometry()
|
||||
{
|
||||
fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint());
|
||||
}
|
||||
else if (vT == volumeType::UNKNOWN)
|
||||
{
|
||||
// Treat as very far outside
|
||||
fld[i] = GREAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "getVolumeType failure, neither INSIDE or OUTSIDE"
|
||||
<< "getVolumeType failure:"
|
||||
<< " neither INSIDE or OUTSIDE but "
|
||||
<< volumeType::names[vT]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -137,6 +223,9 @@ void Foam::distanceSurface::createGeometry()
|
||||
const pointField& cc = fvm.C().boundaryField()[patchi];
|
||||
fvPatchScalarField& fld = cellDistanceBf[patchi];
|
||||
|
||||
const label patchStarti = fvm.boundaryMesh()[patchi].start();
|
||||
|
||||
|
||||
List<pointIndexHit> nearest;
|
||||
surfPtr_().findNearest
|
||||
(
|
||||
@ -163,11 +252,23 @@ void Foam::distanceSurface::createGeometry()
|
||||
{
|
||||
fld[i] = -Foam::mag(cc[i] - nearest[i].hitPoint());
|
||||
}
|
||||
else if (vT == volumeType::UNKNOWN)
|
||||
{
|
||||
// Nothing known, so use the cell value.
|
||||
// - this avoids spurious changes on the boundary
|
||||
|
||||
// The cell value
|
||||
const label meshFacei = i+patchStarti;
|
||||
const scalar& cellVal = cellDistance[own[meshFacei]];
|
||||
|
||||
fld[i] = cellVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "getVolumeType failure, "
|
||||
<< "neither INSIDE or OUTSIDE"
|
||||
<< "getVolumeType failure:"
|
||||
<< " neither INSIDE or OUTSIDE but "
|
||||
<< volumeType::names[vT]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -220,10 +321,17 @@ void Foam::distanceSurface::createGeometry()
|
||||
pointDistance_[i] =
|
||||
-Foam::mag(pts[i] - nearest[i].hitPoint());
|
||||
}
|
||||
else if (vT == volumeType::UNKNOWN)
|
||||
{
|
||||
// Treat as very far outside
|
||||
pointDistance_[i] = GREAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "getVolumeType failure, neither INSIDE or OUTSIDE"
|
||||
<< "getVolumeType failure:"
|
||||
<< " neither INSIDE or OUTSIDE but "
|
||||
<< volumeType::names[vT]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -263,7 +371,7 @@ void Foam::distanceSurface::createGeometry()
|
||||
}
|
||||
|
||||
|
||||
//- Direct from cell field and point field.
|
||||
// Direct from cell field and point field.
|
||||
if (cell_)
|
||||
{
|
||||
isoSurfCellPtr_.reset
|
||||
@ -302,253 +410,12 @@ void Foam::distanceSurface::createGeometry()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::distanceSurface::distanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampledSurface(name, mesh, dict),
|
||||
surfPtr_
|
||||
(
|
||||
searchableSurface::New
|
||||
(
|
||||
dict.lookup("surfaceType"),
|
||||
IOobject
|
||||
(
|
||||
dict.lookupOrDefault("surfaceName", name), // name
|
||||
mesh.time().constant(), // directory
|
||||
"triSurface", // instance
|
||||
mesh.time(), // registry
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dict
|
||||
)
|
||||
),
|
||||
distance_(readScalar(dict.lookup("distance"))),
|
||||
signed_(readBool(dict.lookup("signed"))),
|
||||
cell_(dict.lookupOrDefault("cell", true)),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
average_(dict.lookupOrDefault("average", false)),
|
||||
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
|
||||
zoneKey_(keyType::null),
|
||||
needsUpdate_(true),
|
||||
isoSurfCellPtr_(nullptr),
|
||||
isoSurfPtr_(nullptr)
|
||||
{
|
||||
// dict.readIfPresent("zone", zoneKey_);
|
||||
//
|
||||
// if (debug && zoneKey_.size() && mesh.cellZones().findZoneID(zoneKey_) < 0)
|
||||
// {
|
||||
// Info<< "cellZone " << zoneKey_
|
||||
// << " not found - using entire mesh" << endl;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Foam::distanceSurface::distanceSurface
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const bool interpolate,
|
||||
const word& surfaceType,
|
||||
const word& surfaceName,
|
||||
const scalar distance,
|
||||
const bool signedDistance,
|
||||
const bool cell,
|
||||
const Switch regularise,
|
||||
const Switch average,
|
||||
const boundBox& bounds
|
||||
)
|
||||
:
|
||||
sampledSurface(name, mesh, interpolate),
|
||||
surfPtr_
|
||||
(
|
||||
searchableSurface::New
|
||||
(
|
||||
surfaceType,
|
||||
IOobject
|
||||
(
|
||||
surfaceName, // name
|
||||
mesh.time().constant(), // directory
|
||||
"triSurface", // instance
|
||||
mesh.time(), // registry
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dictionary()
|
||||
)
|
||||
),
|
||||
distance_(distance),
|
||||
signed_(signedDistance),
|
||||
cell_(cell),
|
||||
regularise_(regularise),
|
||||
average_(average),
|
||||
bounds_(bounds),
|
||||
zoneKey_(keyType::null),
|
||||
needsUpdate_(true),
|
||||
isoSurfCellPtr_(nullptr),
|
||||
isoSurfPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::distanceSurface::~distanceSurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::distanceSurface::needsUpdate() const
|
||||
{
|
||||
return needsUpdate_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::distanceSurface::expire()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "distanceSurface::expire :"
|
||||
<< " needsUpdate:" << needsUpdate_ << endl;
|
||||
}
|
||||
|
||||
// Clear derived data
|
||||
clearGeom();
|
||||
|
||||
// already marked as expired
|
||||
if (needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
needsUpdate_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::distanceSurface::update()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "distanceSurface::update :"
|
||||
<< " needsUpdate:" << needsUpdate_ << endl;
|
||||
}
|
||||
|
||||
if (!needsUpdate_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
createGeometry();
|
||||
|
||||
needsUpdate_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::distanceSurface::sample
|
||||
(
|
||||
const volScalarField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::distanceSurface::sample
|
||||
(
|
||||
const volVectorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::distanceSurface::sample
|
||||
(
|
||||
const volSphericalTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::distanceSurface::sample
|
||||
(
|
||||
const volSymmTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::distanceSurface::sample
|
||||
(
|
||||
const volTensorField& vField
|
||||
) const
|
||||
{
|
||||
return sampleField(vField);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::distanceSurface::interpolate
|
||||
(
|
||||
const interpolation<scalar>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::distanceSurface::interpolate
|
||||
(
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::distanceSurface::interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::distanceSurface::interpolate
|
||||
(
|
||||
const interpolation<symmTensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::distanceSurface::interpolate
|
||||
(
|
||||
const interpolation<tensor>& interpolator
|
||||
) const
|
||||
{
|
||||
return interpolateField(interpolator);
|
||||
}
|
||||
|
||||
|
||||
void Foam::distanceSurface::print(Ostream& os) const
|
||||
{
|
||||
os << "distanceSurface: " << name() << " :"
|
||||
<< " surface:" << surfPtr_().name()
|
||||
<< " distance:" << distance_
|
||||
<< " faces:" << faces().size()
|
||||
<< " points:" << points().size();
|
||||
os << " surface:" << surfaceName()
|
||||
<< " distance:" << distance()
|
||||
<< " faces:" << surface().surfFaces().size()
|
||||
<< " points:" << surface().points().size();
|
||||
}
|
||||
|
||||
|
||||
236
src/sampling/surface/distanceSurface/distanceSurface.H
Normal file
236
src/sampling/surface/distanceSurface/distanceSurface.H
Normal file
@ -0,0 +1,236 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::distanceSurface
|
||||
|
||||
Description
|
||||
A surface defined by distance to an input surface - using either
|
||||
an isoSurfaceCell or an isoSurface.
|
||||
|
||||
Usage
|
||||
Dictionary controls:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
distance | distance from surface | yes |
|
||||
signed | apply sign for +ve/-ve distance | yes |
|
||||
cell | use isoSurfaceCell algorithm | no | true
|
||||
regularise | point snapping | yes |
|
||||
bounds | limit with bounding box | no |
|
||||
surfaceType | type of surface | yes |
|
||||
surfaceName | name of surface in triSurface/ | no | dict name
|
||||
\endtable
|
||||
|
||||
|
||||
SourceFiles
|
||||
distanceSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef distanceSurface_H
|
||||
#define distanceSurface_H
|
||||
|
||||
#include "sampledSurface.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "isoSurfaceCell.H"
|
||||
#include "isoSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class distanceSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class distanceSurface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- Surface
|
||||
const autoPtr<searchableSurface> surfPtr_;
|
||||
|
||||
//- Distance value
|
||||
const scalar distance_;
|
||||
|
||||
//- Signed distance
|
||||
const bool signed_;
|
||||
|
||||
//- Whether to use isoSurfaceCell or isoSurface
|
||||
const bool cell_;
|
||||
|
||||
//- Whether to coarsen
|
||||
const Switch regularise_;
|
||||
|
||||
//- Optional bounding box to trim triangles against
|
||||
const boundBox bounds_;
|
||||
|
||||
//- If restricted to zones, name of this zone or a regular expression
|
||||
keyType zoneKey_;
|
||||
|
||||
//- Distance to cell centres
|
||||
autoPtr<volScalarField> cellDistancePtr_;
|
||||
|
||||
//- Distance to points
|
||||
scalarField pointDistance_;
|
||||
|
||||
//- Constructed iso surface
|
||||
autoPtr<isoSurfaceCell> isoSurfCellPtr_;
|
||||
|
||||
//- Constructed iso surface
|
||||
autoPtr<isoSurface> isoSurfPtr_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("distanceSurface");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
distanceSurface
|
||||
(
|
||||
const word& defaultSurfaceName,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
distanceSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const bool interpolate,
|
||||
const word& surfaceType,
|
||||
const word& surfaceName,
|
||||
const scalar distance,
|
||||
const bool signedDistance,
|
||||
const bool cell,
|
||||
const Switch regularise,
|
||||
const boundBox& bounds = boundBox::invertedBox
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~distanceSurface() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Create/recreate the distance surface
|
||||
void createGeometry();
|
||||
|
||||
//- The name of the underlying searchableSurface
|
||||
const word& surfaceName() const
|
||||
{
|
||||
return surfPtr_->name();
|
||||
}
|
||||
|
||||
//- The distance to the underlying searchableSurface
|
||||
scalar distance() const
|
||||
{
|
||||
return distance_;
|
||||
}
|
||||
|
||||
|
||||
//- The underlying surface
|
||||
const meshedSurface& surface() const
|
||||
{
|
||||
if (cell_)
|
||||
{
|
||||
return *isoSurfCellPtr_;
|
||||
}
|
||||
return *isoSurfPtr_;
|
||||
}
|
||||
|
||||
|
||||
//- The underlying surface
|
||||
meshedSurface& surface()
|
||||
{
|
||||
if (cell_)
|
||||
{
|
||||
return *isoSurfCellPtr_;
|
||||
}
|
||||
return *isoSurfPtr_;
|
||||
}
|
||||
|
||||
//- For each face, the original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
if (cell_)
|
||||
{
|
||||
return isoSurfCellPtr_->meshCells();
|
||||
}
|
||||
return isoSurfPtr_->meshCells();
|
||||
}
|
||||
|
||||
//- For each face, the original cell in mesh
|
||||
labelList& meshCells()
|
||||
{
|
||||
if (cell_)
|
||||
{
|
||||
return isoSurfCellPtr_->meshCells();
|
||||
}
|
||||
return isoSurfPtr_->meshCells();
|
||||
}
|
||||
|
||||
|
||||
// Interpolate
|
||||
|
||||
//- Interpolate volume field onto surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>> interpolate
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& cellValues,
|
||||
const Field<Type>& pointValues
|
||||
) const;
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
//- Print information
|
||||
void print(Ostream& os) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "distanceSurfaceTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -21,34 +21,29 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Cutting plane sampling functionality
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cuttingPlane.H"
|
||||
#include "distanceSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::cuttingPlane::sample
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::distanceSurface::interpolate
|
||||
(
|
||||
const Field<Type>& fld
|
||||
const GeometricField<Type, fvPatchField, volMesh>& cellValues,
|
||||
const Field<Type>& pointValues
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>::New(fld, meshCells());
|
||||
if (cell_)
|
||||
{
|
||||
return isoSurfCellPtr_().interpolate(cellValues, pointValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
return isoSurfPtr_().interpolate(cellValues, pointValues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::cuttingPlane::sample
|
||||
(
|
||||
const tmp<Field<Type>>& tfld
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tsf = sample(tfld());
|
||||
tfld.clear();
|
||||
return tsf;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -36,7 +36,13 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(isoSurface, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Helper class for slicing triangles
|
||||
class storeOp
|
||||
{
|
||||
@ -53,7 +59,16 @@ namespace Foam
|
||||
tris_.append(tri);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Avoid detecting change if the cells have been marked as GREAT
|
||||
// (ie, ignore them)
|
||||
static inline constexpr bool ignoreValue(const scalar val)
|
||||
{
|
||||
return (val >= 0.5*Foam::GREAT);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
@ -254,7 +269,7 @@ void Foam::isoSurface::syncUnseparatedPoints
|
||||
|
||||
forAll(pd.sharedPointLabels(), i)
|
||||
{
|
||||
label meshPointi = pd.sharedPointLabels()[i];
|
||||
const label meshPointi = pd.sharedPointLabels()[i];
|
||||
// Fill my entries in the shared points
|
||||
sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointi];
|
||||
}
|
||||
@ -267,7 +282,7 @@ void Foam::isoSurface::syncUnseparatedPoints
|
||||
// my local information.
|
||||
forAll(pd.sharedPointLabels(), i)
|
||||
{
|
||||
label meshPointi = pd.sharedPointLabels()[i];
|
||||
const label meshPointi = pd.sharedPointLabels()[i];
|
||||
pointValues[meshPointi] = sharedPts[pd.sharedPointAddr()[i]];
|
||||
}
|
||||
}
|
||||
@ -280,16 +295,14 @@ Foam::scalar Foam::isoSurface::isoFraction
|
||||
const scalar s1
|
||||
) const
|
||||
{
|
||||
scalar d = s1-s0;
|
||||
const scalar d = s1-s0;
|
||||
|
||||
if (mag(d) > VSMALL)
|
||||
{
|
||||
return (iso_-s0)/d;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -301,19 +314,41 @@ bool Foam::isoSurface::isEdgeOfFaceCut
|
||||
const bool neiLower
|
||||
) const
|
||||
{
|
||||
// Could also count number of edges cut and return when they are > 1
|
||||
// but doesn't appear to improve anything
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
bool fpLower = (pVals[f[fp]] < iso_);
|
||||
if
|
||||
(
|
||||
(fpLower != ownLower)
|
||||
|| (fpLower != neiLower)
|
||||
|| (fpLower != (pVals[f[f.fcIndex(fp)]] < iso_))
|
||||
)
|
||||
const scalar& pt0Value = pVals[f[fp]];
|
||||
|
||||
if (ignoreValue(pt0Value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool fpLower = (pt0Value < iso_);
|
||||
|
||||
if (fpLower != ownLower || fpLower != neiLower)
|
||||
{
|
||||
// ++ncut;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const scalar& pt1Value = pVals[f[f.fcIndex(fp)]];
|
||||
|
||||
if (!ignoreValue(pt1Value) && (fpLower != (pt1Value < iso_)))
|
||||
{
|
||||
// ++ncut;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// if (ncut > 1)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -334,16 +369,16 @@ void Foam::isoSurface::getNeighbour
|
||||
|
||||
if (mesh_.isInternalFace(facei))
|
||||
{
|
||||
label nbr = (own[facei] == celli ? nei[facei] : own[facei]);
|
||||
const label nbr = (own[facei] == celli ? nei[facei] : own[facei]);
|
||||
nbrValue = cVals[nbr];
|
||||
nbrPoint = meshC[nbr];
|
||||
}
|
||||
else
|
||||
{
|
||||
label bFacei = facei-mesh_.nInternalFaces();
|
||||
label patchi = boundaryRegion[bFacei];
|
||||
const label bFacei = facei-mesh_.nInternalFaces();
|
||||
const label patchi = boundaryRegion[bFacei];
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
|
||||
label patchFacei = facei-pp.start();
|
||||
const label patchFacei = facei-pp.start();
|
||||
|
||||
nbrValue = cVals.boundaryField()[patchi][patchFacei];
|
||||
nbrPoint = meshC.boundaryField()[patchi][patchFacei];
|
||||
@ -366,10 +401,18 @@ void Foam::isoSurface::calcCutTypes
|
||||
faceCutType_.setSize(mesh_.nFaces());
|
||||
faceCutType_ = NOTCUT;
|
||||
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
|
||||
// Avoid detecting change if the cells have been marked as GREAT
|
||||
// (ie, ignore them)
|
||||
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
|
||||
{
|
||||
// CC edge.
|
||||
bool ownLower = (cVals[own[facei]] < iso_);
|
||||
const scalar& ownValue = cVals[own[facei]];
|
||||
if (ignoreValue(ownValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool ownLower = (ownValue < iso_);
|
||||
|
||||
scalar nbrValue;
|
||||
point nbrPoint;
|
||||
@ -384,7 +427,12 @@ void Foam::isoSurface::calcCutTypes
|
||||
nbrPoint
|
||||
);
|
||||
|
||||
bool neiLower = (nbrValue < iso_);
|
||||
if (ignoreValue(nbrValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool neiLower = (nbrValue < iso_);
|
||||
|
||||
if (ownLower != neiLower)
|
||||
{
|
||||
@ -392,8 +440,8 @@ void Foam::isoSurface::calcCutTypes
|
||||
}
|
||||
else
|
||||
{
|
||||
// See if any mesh edge is cut by looping over all the edges of the
|
||||
// face.
|
||||
// Is mesh edge cut?
|
||||
// - by looping over all the edges of the face.
|
||||
const face f = mesh_.faces()[facei];
|
||||
|
||||
if (isEdgeOfFaceCut(pVals, f, ownLower, neiLower))
|
||||
@ -411,7 +459,8 @@ void Foam::isoSurface::calcCutTypes
|
||||
|
||||
forAll(pp, i)
|
||||
{
|
||||
bool ownLower = (cVals[own[facei]] < iso_);
|
||||
const scalar& ownValue = cVals[own[facei]];
|
||||
const bool ownLower = (ownValue < iso_);
|
||||
|
||||
scalar nbrValue;
|
||||
point nbrPoint;
|
||||
@ -426,7 +475,7 @@ void Foam::isoSurface::calcCutTypes
|
||||
nbrPoint
|
||||
);
|
||||
|
||||
bool neiLower = (nbrValue < iso_);
|
||||
const bool neiLower = (nbrValue < iso_);
|
||||
|
||||
if (ownLower != neiLower)
|
||||
{
|
||||
@ -434,7 +483,8 @@ void Foam::isoSurface::calcCutTypes
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mesh edge.
|
||||
// Is mesh edge cut?
|
||||
// - by looping over all the edges of the face.
|
||||
const face f = mesh_.faces()[facei];
|
||||
|
||||
if (isEdgeOfFaceCut(pVals, f, ownLower, neiLower))
|
||||
@ -443,49 +493,73 @@ void Foam::isoSurface::calcCutTypes
|
||||
}
|
||||
}
|
||||
|
||||
facei++;
|
||||
++facei;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
nCutCells_ = 0;
|
||||
cellCutType_.setSize(mesh_.nCells());
|
||||
cellCutType_ = NOTCUT;
|
||||
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
|
||||
|
||||
// Propagate internal face cuts into the cells.
|
||||
// For cells marked as ignore (eg, GREAT) - skip this.
|
||||
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
|
||||
{
|
||||
if (faceCutType_[facei] != NOTCUT)
|
||||
if (faceCutType_[facei] == NOTCUT)
|
||||
{
|
||||
if (cellCutType_[own[facei]] == NOTCUT)
|
||||
continue;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
cellCutType_[own[facei]] == NOTCUT
|
||||
&& !ignoreValue(cVals[own[facei]])
|
||||
)
|
||||
{
|
||||
cellCutType_[own[facei]] = CUT;
|
||||
nCutCells_++;
|
||||
++nCutCells_;
|
||||
}
|
||||
if (cellCutType_[nei[facei]] == NOTCUT)
|
||||
if
|
||||
(
|
||||
cellCutType_[nei[facei]] == NOTCUT
|
||||
&& !ignoreValue(cVals[nei[facei]])
|
||||
)
|
||||
{
|
||||
cellCutType_[nei[facei]] = CUT;
|
||||
nCutCells_++;
|
||||
++nCutCells_;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
|
||||
|
||||
|
||||
// Propagate boundary face cuts into the cells.
|
||||
// For cells marked as ignore (eg, GREAT) - skip this and
|
||||
// also suppress the boundary face cut to prevent dangling face cuts.
|
||||
|
||||
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); ++facei)
|
||||
{
|
||||
if (faceCutType_[facei] != NOTCUT)
|
||||
if (faceCutType_[facei] == NOTCUT)
|
||||
{
|
||||
if (cellCutType_[own[facei]] == NOTCUT)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignoreValue(cVals[own[facei]]))
|
||||
{
|
||||
// Suppress dangling boundary face cut
|
||||
faceCutType_[facei] = NOTCUT;
|
||||
}
|
||||
else if (cellCutType_[own[facei]] == NOTCUT)
|
||||
{
|
||||
cellCutType_[own[facei]] = CUT;
|
||||
nCutCells_++;
|
||||
}
|
||||
++nCutCells_;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "isoSurface : detected " << nCutCells_
|
||||
<< " candidate cut cells (out of " << mesh_.nCells()
|
||||
<< ")." << endl;
|
||||
Pout<< "isoSurface : candidate cut cells "
|
||||
<< nCutCells_ << " / " << mesh_.nCells() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -597,7 +671,7 @@ void Foam::isoSurface::calcSnappedCc
|
||||
if (s[i] >= 0.0 && s[i] <= 0.5)
|
||||
{
|
||||
otherPointSum += pt[i];
|
||||
nOther++;
|
||||
++nOther;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -792,7 +866,7 @@ void Foam::isoSurface::calcSnappedPoint
|
||||
if (s[i] >= 0.0 && s[i] <= 0.5)
|
||||
{
|
||||
otherPointSum += pt[i];
|
||||
nOther++;
|
||||
++nOther;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1455,7 +1529,7 @@ Foam::isoSurface::isoSurface
|
||||
forAll(pp, i)
|
||||
{
|
||||
boundaryRegion[facei-mesh_.nInternalFaces()] = patchi;
|
||||
facei++;
|
||||
++facei;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1464,6 +1538,38 @@ Foam::isoSurface::isoSurface
|
||||
// Determine if any cut through face/cell
|
||||
calcCutTypes(boundaryRegion, meshC, cValsPtr_(), pVals_);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
const fvMesh& fvm = mesh_;
|
||||
|
||||
volScalarField debugField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cutType",
|
||||
fvm.time().timeName(),
|
||||
fvm.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
fvm,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
);
|
||||
|
||||
auto& debugFld = debugField.primitiveFieldRef();
|
||||
|
||||
forAll(cellCutType_, celli)
|
||||
{
|
||||
debugFld[celli] = cellCutType_[celli];
|
||||
}
|
||||
|
||||
Pout<< "Writing cut types:"
|
||||
<< debugField.objectPath() << endl;
|
||||
|
||||
debugField.write();
|
||||
}
|
||||
|
||||
|
||||
DynamicList<point> snappedPoints(nCutCells_);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,7 +54,6 @@ Description
|
||||
can use the neighbouring value. Any separated processor face or cyclic
|
||||
face gets handled just like any boundary face.
|
||||
|
||||
|
||||
SourceFiles
|
||||
isoSurface.C
|
||||
isoSurfaceTemplates.C
|
||||
@ -75,6 +74,8 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
|
||||
class fvMesh;
|
||||
class plane;
|
||||
class treeBoundBox;
|
||||
@ -162,7 +163,7 @@ class isoSurface
|
||||
bool noTransform(const tensor& tt) const;
|
||||
|
||||
//- Is patch a collocated (i.e. non-separated) coupled patch?
|
||||
static bool collocatedPatch(const polyPatch&);
|
||||
static bool collocatedPatch(const polyPatch& pp);
|
||||
|
||||
//- Per face whether is collocated
|
||||
bitSet collocatedFaces(const coupledPolyPatch&) const;
|
||||
@ -291,7 +292,7 @@ class isoSurface
|
||||
const bool hasSnap3,
|
||||
const Type& snapP3,
|
||||
|
||||
DynamicList<Type>& points
|
||||
DynamicList<Type>& pts
|
||||
) const;
|
||||
|
||||
template<class Type>
|
||||
@ -402,9 +403,9 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from cell values and point values. Uses boundaryField
|
||||
// for boundary values. Holds reference to cellIsoVals and
|
||||
// pointIsoVals.
|
||||
//- Construct from cell values and point values.
|
||||
// Uses boundaryField for boundary values.
|
||||
// Holds reference to cellIsoVals and pointIsoVals.
|
||||
isoSurface
|
||||
(
|
||||
const volScalarField& cellIsoVals,
|
||||
@ -418,14 +419,22 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- For every face, the original cell in mesh
|
||||
//- For each face, the original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
//- Interpolates cCoords,pCoords. Uses the references to the original
|
||||
// fields used to create the iso surface.
|
||||
//- For each face, the original cell in mesh
|
||||
labelList& meshCells()
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
|
||||
//- Interpolates cCoords, pCoords.
|
||||
// Uses the references to the original fields used to create the
|
||||
// iso surface.
|
||||
template<class Type>
|
||||
tmp<Field<Type>> interpolate
|
||||
(
|
||||
|
||||
@ -44,6 +44,20 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Avoid detecting change if the cells have been marked as GREAT
|
||||
// (ie, ignore them)
|
||||
static inline constexpr bool ignoreValue(const scalar val)
|
||||
{
|
||||
return (val >= 0.5*Foam::GREAT);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::isoSurfaceCell::isoFraction
|
||||
@ -52,16 +66,14 @@ Foam::scalar Foam::isoSurfaceCell::isoFraction
|
||||
const scalar s1
|
||||
) const
|
||||
{
|
||||
scalar d = s1-s0;
|
||||
const scalar d = s1-s0;
|
||||
|
||||
if (mag(d) > VSMALL)
|
||||
{
|
||||
return (iso_-s0)/d;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,9 +83,9 @@ bool Foam::isoSurfaceCell::isTriCut
|
||||
const scalarField& pointValues
|
||||
) const
|
||||
{
|
||||
bool aLower = (pointValues[tri[0]] < iso_);
|
||||
bool bLower = (pointValues[tri[1]] < iso_);
|
||||
bool cLower = (pointValues[tri[2]] < iso_);
|
||||
const bool aLower = (pointValues[tri[0]] < iso_);
|
||||
const bool bLower = (pointValues[tri[1]] < iso_);
|
||||
const bool cLower = (pointValues[tri[2]] < iso_);
|
||||
|
||||
return !(aLower == bLower && aLower == cLower);
|
||||
}
|
||||
@ -87,15 +99,20 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
|
||||
const label celli
|
||||
) const
|
||||
{
|
||||
if (ignoreValue(cellValues[celli]))
|
||||
{
|
||||
return NOTCUT;
|
||||
}
|
||||
|
||||
const cell& cFaces = mesh_.cells()[celli];
|
||||
|
||||
if (isTet.test(celli))
|
||||
{
|
||||
forAll(cFaces, cFacei)
|
||||
for (const label facei : cFaces)
|
||||
{
|
||||
const face& f = mesh_.faces()[cFaces[cFacei]];
|
||||
const face& f = mesh_.faces()[facei];
|
||||
|
||||
for (label fp = 1; fp < f.size() - 1; fp++)
|
||||
for (label fp = 1; fp < f.size() - 1; ++fp)
|
||||
{
|
||||
triFace tri(f[0], f[fp], f[f.fcIndex(fp)]);
|
||||
|
||||
@ -107,22 +124,24 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
|
||||
}
|
||||
return NOTCUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool cellLower = (cellValues[celli] < iso_);
|
||||
|
||||
const bool cellLower = (cellValues[celli] < iso_);
|
||||
|
||||
// First check if there is any cut in cell
|
||||
bool edgeCut = false;
|
||||
|
||||
forAll(cFaces, cFacei)
|
||||
for (const label facei : cFaces)
|
||||
{
|
||||
label facei = cFaces[cFacei];
|
||||
const face& f = mesh_.faces()[facei];
|
||||
|
||||
// Check pyramids cut
|
||||
forAll(f, fp)
|
||||
for (const label labi : f)
|
||||
{
|
||||
if ((pointValues[f[fp]] < iso_) != cellLower)
|
||||
if
|
||||
(
|
||||
!ignoreValue(pointValues[labi])
|
||||
&& cellLower != (pointValues[labi] < iso_)
|
||||
)
|
||||
{
|
||||
edgeCut = true;
|
||||
break;
|
||||
@ -138,7 +157,7 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
|
||||
label fp = f.fcIndex(fp0);
|
||||
for (label i = 2; i < f.size(); i++)
|
||||
{
|
||||
label nextFp = f.fcIndex(fp);
|
||||
const label nextFp = f.fcIndex(fp);
|
||||
|
||||
if (isTriCut(triFace(f[fp0], f[fp], f[nextFp]), pointValues))
|
||||
{
|
||||
@ -155,6 +174,7 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (edgeCut)
|
||||
{
|
||||
// Count actual cuts (expensive since addressing needed)
|
||||
@ -163,30 +183,31 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType
|
||||
|
||||
const labelList& cPoints = mesh_.cellPoints(celli);
|
||||
|
||||
label nPyrCuts = 0;
|
||||
label nCuts = 0;
|
||||
|
||||
forAll(cPoints, i)
|
||||
for (const label pointi : cPoints)
|
||||
{
|
||||
if ((pointValues[cPoints[i]] < iso_) != cellLower)
|
||||
if
|
||||
(
|
||||
!ignoreValue(pointValues[pointi])
|
||||
&& cellLower != (pointValues[pointi] < iso_)
|
||||
)
|
||||
{
|
||||
nPyrCuts++;
|
||||
++nCuts;
|
||||
}
|
||||
}
|
||||
|
||||
if (nPyrCuts == cPoints.size())
|
||||
if (nCuts == cPoints.size())
|
||||
{
|
||||
return SPHERE;
|
||||
}
|
||||
else
|
||||
else if (nCuts > 1)
|
||||
{
|
||||
return CUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return NOTCUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -205,14 +226,14 @@ void Foam::isoSurfaceCell::calcCutTypes
|
||||
|
||||
if (cellCutType_[celli] == CUT)
|
||||
{
|
||||
nCutCells_++;
|
||||
++nCutCells_;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "isoSurfaceCell : detected " << nCutCells_
|
||||
<< " candidate cut cells." << endl;
|
||||
Pout<< "isoSurfaceCell : candidate cut cells "
|
||||
<< nCutCells_ << " / " << mesh_.nCells() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,7 +404,7 @@ void Foam::isoSurfaceCell::calcSnappedCc
|
||||
{
|
||||
if (cellCutType_[celli] == CUT && !isTet.test(celli))
|
||||
{
|
||||
scalar cVal = cVals[celli];
|
||||
const scalar cVal = cVals[celli];
|
||||
|
||||
const cell& cFaces = mesh_.cells()[celli];
|
||||
|
||||
@ -394,14 +415,12 @@ void Foam::isoSurfaceCell::calcSnappedCc
|
||||
// Create points for all intersections close to cell centre
|
||||
// (i.e. from pyramid edges)
|
||||
|
||||
forAll(cFaces, cFacei)
|
||||
for (const label facei : cFaces)
|
||||
{
|
||||
const face& f = mesh_.faces()[cFaces[cFacei]];
|
||||
const face& f = mesh_.faces()[facei];
|
||||
|
||||
forAll(f, fp)
|
||||
for (const label pointi : f)
|
||||
{
|
||||
label pointi = f[fp];
|
||||
|
||||
scalar s = isoFraction(cVal, pVals[pointi]);
|
||||
|
||||
if (s >= 0.0 && s <= 0.5)
|
||||
@ -441,9 +460,8 @@ void Foam::isoSurfaceCell::calcSnappedCc
|
||||
else if (localPoints.size())
|
||||
{
|
||||
// Need to analyse
|
||||
forAll(cFaces, cFacei)
|
||||
for (const label facei : cFaces)
|
||||
{
|
||||
label facei = cFaces[cFacei];
|
||||
const face& f = mesh_.faces()[facei];
|
||||
|
||||
// Do a tetrahedralisation. Each face to cc becomes pyr.
|
||||
@ -622,13 +640,11 @@ void Foam::isoSurfaceCell::genPointTris
|
||||
|
||||
// Find 4th point
|
||||
label ccPointi = -1;
|
||||
forAll(cFaces, cFacei)
|
||||
for (const label cfacei : cFaces)
|
||||
{
|
||||
const face& f1 = mesh_.faces()[cFaces[cFacei]];
|
||||
forAll(f1, fp)
|
||||
const face& f1 = mesh_.faces()[cfacei];
|
||||
for (const label p1 : f1)
|
||||
{
|
||||
label p1 = f1[fp];
|
||||
|
||||
if (!f.found(p1))
|
||||
{
|
||||
ccPointi = p1;
|
||||
@ -697,10 +713,8 @@ void Foam::isoSurfaceCell::calcSnappedPoint
|
||||
// snapped. Coupled boundaries are handled explicitly so not marked here.
|
||||
bitSet isBoundaryPoint(mesh_.nPoints());
|
||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||
forAll(patches, patchi)
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
if (!pp.coupled())
|
||||
{
|
||||
label facei = pp.start();
|
||||
@ -708,10 +722,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint
|
||||
{
|
||||
const face& f = mesh_.faces()[facei++];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
isBoundaryPoint.set(f[fp], 1);
|
||||
}
|
||||
isBoundaryPoint.setMany(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -728,7 +739,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint
|
||||
|
||||
forAll(mesh_.pointFaces(), pointi)
|
||||
{
|
||||
if (isBoundaryPoint.get(pointi) == 1)
|
||||
if (isBoundaryPoint.test(pointi))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -737,10 +748,8 @@ void Foam::isoSurfaceCell::calcSnappedPoint
|
||||
|
||||
bool anyCut = false;
|
||||
|
||||
forAll(pFaces, i)
|
||||
for (const label facei : pFaces)
|
||||
{
|
||||
label facei = pFaces[i];
|
||||
|
||||
if
|
||||
(
|
||||
cellCutType_[mesh_.faceOwner()[facei]] == CUT
|
||||
@ -766,10 +775,9 @@ void Foam::isoSurfaceCell::calcSnappedPoint
|
||||
localPointCells.clear();
|
||||
localTriPoints.clear();
|
||||
|
||||
forAll(pFaces, pFacei)
|
||||
for (const label facei : pFaces)
|
||||
{
|
||||
label facei = pFaces[pFacei];
|
||||
label own = mesh_.faceOwner()[facei];
|
||||
const label own = mesh_.faceOwner()[facei];
|
||||
|
||||
if (isTet.test(own))
|
||||
{
|
||||
@ -795,7 +803,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint
|
||||
|
||||
if (mesh_.isInternalFace(facei))
|
||||
{
|
||||
label nei = mesh_.faceNeighbour()[facei];
|
||||
const label nei = mesh_.faceNeighbour()[facei];
|
||||
|
||||
if (isTet.test(nei))
|
||||
{
|
||||
@ -1157,22 +1165,15 @@ bool Foam::isoSurfaceCell::danglingTriangle
|
||||
)
|
||||
{
|
||||
label nOpen = 0;
|
||||
forAll(fEdges, i)
|
||||
for (const label edgei : fEdges)
|
||||
{
|
||||
if (edgeFace1[fEdges[i]] == -1)
|
||||
if (edgeFace1[edgei] == -1)
|
||||
{
|
||||
nOpen++;
|
||||
++nOpen;
|
||||
}
|
||||
}
|
||||
|
||||
if (nOpen == 1 || nOpen == 2 || nOpen == 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (nOpen == 1 || nOpen == 2 || nOpen == 3);
|
||||
}
|
||||
|
||||
|
||||
@ -1191,32 +1192,31 @@ Foam::label Foam::isoSurfaceCell::markDanglingTriangles
|
||||
label nDangling = 0;
|
||||
|
||||
// Remove any dangling triangles
|
||||
forAllConstIter(Map<labelList>, edgeFacesRest, iter)
|
||||
forAllConstIters(edgeFacesRest, iter)
|
||||
{
|
||||
// These are all the non-manifold edges. Filter out all triangles
|
||||
// with only one connected edge (= this edge)
|
||||
|
||||
label edgeI = iter.key();
|
||||
const labelList& otherEdgeFaces = iter();
|
||||
const label edgeI = iter.key();
|
||||
const labelList& otherEdgeFaces = iter.object();
|
||||
|
||||
// Remove all dangling triangles
|
||||
if (danglingTriangle(faceEdges[edgeFace0[edgeI]], edgeFace1))
|
||||
{
|
||||
keepTriangles[edgeFace0[edgeI]] = false;
|
||||
nDangling++;
|
||||
++nDangling;
|
||||
}
|
||||
if (danglingTriangle(faceEdges[edgeFace1[edgeI]], edgeFace1))
|
||||
{
|
||||
keepTriangles[edgeFace1[edgeI]] = false;
|
||||
nDangling++;
|
||||
++nDangling;
|
||||
}
|
||||
forAll(otherEdgeFaces, i)
|
||||
for (const label triI : otherEdgeFaces)
|
||||
{
|
||||
label triI = otherEdgeFaces[i];
|
||||
if (danglingTriangle(faceEdges[triI], edgeFace1))
|
||||
{
|
||||
keepTriangles[triI] = false;
|
||||
nDangling++;
|
||||
++nDangling;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1250,10 +1250,8 @@ Foam::triSurface Foam::isoSurfaceCell::subsetMesh
|
||||
// Renumber labels for face
|
||||
const triSurface::FaceType& f = s[oldFacei];
|
||||
|
||||
forAll(f, fp)
|
||||
for (const label oldPointi : f)
|
||||
{
|
||||
label oldPointi = f[fp];
|
||||
|
||||
if (oldToNewPoints[oldPointi] == -1)
|
||||
{
|
||||
oldToNewPoints[oldPointi] = pointi;
|
||||
@ -1313,9 +1311,19 @@ Foam::isoSurfaceCell::isoSurfaceCell
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "isoSurfaceCell : mergeTol:" << mergeTol
|
||||
<< " mesh span:" << mesh.bounds().mag()
|
||||
<< " mergeDistance:" << mergeDistance_ << endl;
|
||||
Pout<< "isoSurfaceCell::"
|
||||
<< " cell min/max : "
|
||||
<< min(cVals_) << " / "
|
||||
<< max(cVals_) << nl
|
||||
<< " point min/max : "
|
||||
<< min(pVals_) << " / "
|
||||
<< max(pVals_) << nl
|
||||
<< " isoValue : " << iso << nl
|
||||
<< " regularise : " << regularise << nl
|
||||
<< " mergeTol : " << mergeTol << nl
|
||||
<< " mesh span : " << mesh.bounds().mag() << nl
|
||||
<< " mergeDistance : " << mergeDistance_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Determine if cell is tet
|
||||
@ -1336,6 +1344,39 @@ Foam::isoSurfaceCell::isoSurfaceCell
|
||||
// Determine if any cut through cell
|
||||
calcCutTypes(isTet, cVals, pVals);
|
||||
|
||||
if (debug && isA<fvMesh>(mesh))
|
||||
{
|
||||
const fvMesh& fvm = dynamicCast<const fvMesh&>(mesh);
|
||||
|
||||
volScalarField debugField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cutType",
|
||||
fvm.time().timeName(),
|
||||
fvm.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
fvm,
|
||||
dimensionedScalar(dimless, Zero)
|
||||
);
|
||||
|
||||
auto& debugFld = debugField.primitiveFieldRef();
|
||||
|
||||
forAll(cellCutType_, celli)
|
||||
{
|
||||
debugFld[celli] = cellCutType_[celli];
|
||||
}
|
||||
|
||||
Pout<< "Writing cut types:"
|
||||
<< debugField.objectPath() << endl;
|
||||
|
||||
debugField.write();
|
||||
}
|
||||
|
||||
|
||||
DynamicList<point> snappedPoints(nCutCells_);
|
||||
|
||||
// Per cc -1 or a point inside snappedPoints.
|
||||
|
||||
@ -57,6 +57,8 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
|
||||
class polyMesh;
|
||||
class triSurface;
|
||||
|
||||
@ -337,13 +339,20 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- For every face, the original cell in mesh
|
||||
//- For each face, the original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
//- Interpolates cCoords,pCoords.
|
||||
//- For each face, the original cell in mesh
|
||||
labelList& meshCells()
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
|
||||
//- Interpolates cCoords, pCoords.
|
||||
template<class Type>
|
||||
tmp<Field<Type>> interpolate
|
||||
(
|
||||
|
||||
@ -44,11 +44,11 @@ Type Foam::isoSurfaceCell::generatePoint
|
||||
const label p1Index
|
||||
) const
|
||||
{
|
||||
scalar d = s1-s0;
|
||||
const scalar d = s1-s0;
|
||||
|
||||
if (mag(d) > VSMALL)
|
||||
{
|
||||
scalar s = (iso_-s0)/d;
|
||||
const scalar s = (iso_-s0)/d;
|
||||
|
||||
if (s >= 0.5 && s <= 1 && p1Index != -1)
|
||||
{
|
||||
@ -124,22 +124,13 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x01:
|
||||
case 0x0E:
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s0,p0,p0Index,s1,p1,p1Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s0,p0,p0Index,s2,p2,p2Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s0,p0,p0Index,s3,p3,p3Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s0,p0,p0Index,s1,p1,p1Index));
|
||||
pts.append(generatePoint(snapped,s0,p0,p0Index,s2,p2,p2Index));
|
||||
pts.append(generatePoint(snapped,s0,p0,p0Index,s3,p3,p3Index));
|
||||
if (triIndex == 0x0E)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = pts.size();
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
@ -148,23 +139,14 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x02:
|
||||
case 0x0D:
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s1,p1,p1Index,s0,p0,p0Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s1,p1,p1Index,s3,p3,p3Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s1,p1,p1Index,s2,p2,p2Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s1,p1,p1Index,s0,p0,p0Index));
|
||||
pts.append(generatePoint(snapped,s1,p1,p1Index,s3,p3,p3Index));
|
||||
pts.append(generatePoint(snapped,s1,p1,p1Index,s2,p2,p2Index));
|
||||
|
||||
if (triIndex == 0x0D)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = pts.size();
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
@ -173,15 +155,10 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x03:
|
||||
case 0x0C:
|
||||
{
|
||||
Type p0p2 =
|
||||
generatePoint(snapped,s0,p0,p0Index,s2,p2,p2Index);
|
||||
Type p1p3 =
|
||||
generatePoint(snapped,s1,p1,p1Index,s3,p3,p3Index);
|
||||
Type p0p2 = generatePoint(snapped,s0,p0,p0Index,s2,p2,p2Index);
|
||||
Type p1p3 = generatePoint(snapped,s1,p1,p1Index,s3,p3,p3Index);
|
||||
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s0,p0,p0Index,s3,p3,p3Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s0,p0,p0Index,s3,p3,p3Index));
|
||||
pts.append(p1p3);
|
||||
pts.append(p0p2);
|
||||
|
||||
@ -205,23 +182,14 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x04:
|
||||
case 0x0B:
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s2,p2,p2Index,s0,p0,p0Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s2,p2,p2Index,s1,p1,p1Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s2,p2,p2Index,s3,p3,p3Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s2,p2,p2Index,s0,p0,p0Index));
|
||||
pts.append(generatePoint(snapped,s2,p2,p2Index,s1,p1,p1Index));
|
||||
pts.append(generatePoint(snapped,s2,p2,p2Index,s3,p3,p3Index));
|
||||
|
||||
if (triIndex == 0x0B)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = pts.size();
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
@ -230,29 +198,21 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x05:
|
||||
case 0x0A:
|
||||
{
|
||||
Type p0p1 =
|
||||
generatePoint(snapped,s0,p0,p0Index,s1,p1,p1Index);
|
||||
Type p2p3 =
|
||||
generatePoint(snapped,s2,p2,p2Index,s3,p3,p3Index);
|
||||
Type p0p1 = generatePoint(snapped,s0,p0,p0Index,s1,p1,p1Index);
|
||||
Type p2p3 = generatePoint(snapped,s2,p2,p2Index,s3,p3,p3Index);
|
||||
|
||||
pts.append(p0p1);
|
||||
pts.append(p2p3);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s0,p0,p0Index,s3,p3,p3Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s0,p0,p0Index,s3,p3,p3Index));
|
||||
|
||||
pts.append(p0p1);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s1,p1,p1Index,s2,p2,p2Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s1,p1,p1Index,s2,p2,p2Index));
|
||||
pts.append(p2p3);
|
||||
|
||||
if (triIndex == 0x0A)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = pts.size();
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-5], pts[sz-4]);
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
@ -262,29 +222,21 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x06:
|
||||
case 0x09:
|
||||
{
|
||||
Type p0p1 =
|
||||
generatePoint(snapped,s0,p0,p0Index,s1,p1,p1Index);
|
||||
Type p2p3 =
|
||||
generatePoint(snapped,s2,p2,p2Index,s3,p3,p3Index);
|
||||
Type p0p1 = generatePoint(snapped,s0,p0,p0Index,s1,p1,p1Index);
|
||||
Type p2p3 = generatePoint(snapped,s2,p2,p2Index,s3,p3,p3Index);
|
||||
|
||||
pts.append(p0p1);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s1,p1,p1Index,s3,p3,p3Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s1,p1,p1Index,s3,p3,p3Index));
|
||||
pts.append(p2p3);
|
||||
|
||||
pts.append(p0p1);
|
||||
pts.append(p2p3);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s0,p0,p0Index,s2,p2,p2Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s0,p0,p0Index,s2,p2,p2Index));
|
||||
|
||||
if (triIndex == 0x09)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = pts.size();
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-5], pts[sz-4]);
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
@ -294,22 +246,13 @@ void Foam::isoSurfaceCell::generateTriPoints
|
||||
case 0x08:
|
||||
case 0x07:
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s3,p3,p3Index,s0,p0,p0Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s3,p3,p3Index,s2,p2,p2Index)
|
||||
);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(snapped,s3,p3,p3Index,s1,p1,p1Index)
|
||||
);
|
||||
pts.append(generatePoint(snapped,s3,p3,p3Index,s0,p0,p0Index));
|
||||
pts.append(generatePoint(snapped,s3,p3,p3Index,s2,p2,p2Index));
|
||||
pts.append(generatePoint(snapped,s3,p3,p3Index,s1,p1,p1Index));
|
||||
if (triIndex == 0x07)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = pts.size();
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,9 +53,7 @@ Foam::isoSurface::adaptPatchFields
|
||||
volMesh
|
||||
> FieldType;
|
||||
|
||||
tmp<FieldType> tsliceFld
|
||||
(
|
||||
new FieldType
|
||||
auto tslice = tmp<FieldType>::New
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -68,16 +66,14 @@ Foam::isoSurface::adaptPatchFields
|
||||
),
|
||||
fld, // internal field
|
||||
true // preserveCouples
|
||||
)
|
||||
);
|
||||
FieldType& sliceFld = tsliceFld.ref();
|
||||
auto& sliceFld = tslice.ref();
|
||||
|
||||
const fvMesh& mesh = fld.mesh();
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
typename FieldType::Boundary& sliceFldBf =
|
||||
sliceFld.boundaryFieldRef();
|
||||
auto& sliceFldBf = sliceFld.boundaryFieldRef();
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
@ -146,7 +142,7 @@ Foam::isoSurface::adaptPatchFields
|
||||
}
|
||||
}
|
||||
}
|
||||
return tsliceFld;
|
||||
return tslice;
|
||||
}
|
||||
|
||||
|
||||
@ -164,11 +160,11 @@ Type Foam::isoSurface::generatePoint
|
||||
const Type& snapP1
|
||||
) const
|
||||
{
|
||||
scalar d = s1-s0;
|
||||
const scalar d = s1-s0;
|
||||
|
||||
if (mag(d) > VSMALL)
|
||||
{
|
||||
scalar s = (iso_-s0)/d;
|
||||
const scalar s = (iso_-s0)/d;
|
||||
|
||||
if (hasSnap1 && s >= 0.5 && s <= 1)
|
||||
{
|
||||
@ -215,7 +211,7 @@ void Foam::isoSurface::generateTriPoints
|
||||
const bool hasSnap3,
|
||||
const Type& snapP3,
|
||||
|
||||
DynamicList<Type>& points
|
||||
DynamicList<Type>& pts
|
||||
) const
|
||||
{
|
||||
// Note: cannot use simpler isoSurfaceCell::generateTriPoints since
|
||||
@ -248,45 +244,49 @@ void Foam::isoSurface::generateTriPoints
|
||||
|
||||
case 0x01:
|
||||
case 0x0E:
|
||||
points.append
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s0,p0,hasSnap0,snapP0,s1,p1,hasSnap1,snapP1)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s0,p0,hasSnap0,snapP0,s2,p2,hasSnap2,snapP2)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s0,p0,hasSnap0,snapP0,s3,p3,hasSnap3,snapP3)
|
||||
);
|
||||
if (triIndex == 0x0E)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x02:
|
||||
case 0x0D:
|
||||
points.append
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s0,p0,hasSnap0,snapP0)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s3,p3,hasSnap3,snapP3)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s2,p2,hasSnap2,snapP2)
|
||||
);
|
||||
if (triIndex == 0x0D)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -298,50 +298,52 @@ void Foam::isoSurface::generateTriPoints
|
||||
Type p1p3 =
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s3,p3,hasSnap3,snapP3);
|
||||
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s0,p0,hasSnap0,snapP0,s3,p3,hasSnap3,snapP3)
|
||||
);
|
||||
points.append(p1p3);
|
||||
points.append(p0p2);
|
||||
pts.append(p1p3);
|
||||
pts.append(p0p2);
|
||||
|
||||
points.append(p1p3);
|
||||
points.append
|
||||
pts.append(p1p3);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s2,p2,hasSnap2,snapP2)
|
||||
);
|
||||
points.append(p0p2);
|
||||
}
|
||||
pts.append(p0p2);
|
||||
|
||||
if (triIndex == 0x0C)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-5], points[sz-4]);
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-5], pts[sz-4]);
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
case 0x0B:
|
||||
{
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s2,p2,hasSnap2,snapP2,s0,p0,hasSnap0,snapP0)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s2,p2,hasSnap2,snapP2,s1,p1,hasSnap1,snapP1)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s2,p2,hasSnap2,snapP2,s3,p3,hasSnap3,snapP3)
|
||||
);
|
||||
}
|
||||
|
||||
if (triIndex == 0x0B)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -353,26 +355,27 @@ void Foam::isoSurface::generateTriPoints
|
||||
Type p2p3 =
|
||||
generatePoint(s2,p2,hasSnap2,snapP2,s3,p3,hasSnap3,snapP3);
|
||||
|
||||
points.append(p0p1);
|
||||
points.append(p2p3);
|
||||
points.append
|
||||
pts.append(p0p1);
|
||||
pts.append(p2p3);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s0,p0,hasSnap0,snapP0,s3,p3,hasSnap3,snapP3)
|
||||
);
|
||||
|
||||
points.append(p0p1);
|
||||
points.append
|
||||
pts.append(p0p1);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s2,p2,hasSnap2,snapP2)
|
||||
);
|
||||
points.append(p2p3);
|
||||
}
|
||||
pts.append(p2p3);
|
||||
|
||||
if (triIndex == 0x0A)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-5], points[sz-4]);
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
const label sz = pts.size();
|
||||
Swap(pts[sz-5], pts[sz-4]);
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -384,48 +387,52 @@ void Foam::isoSurface::generateTriPoints
|
||||
Type p2p3 =
|
||||
generatePoint(s2,p2,hasSnap2,snapP2,s3,p3,hasSnap3,snapP3);
|
||||
|
||||
points.append(p0p1);
|
||||
points.append
|
||||
pts.append(p0p1);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s1,p1,hasSnap1,snapP1,s3,p3,hasSnap3,snapP3)
|
||||
);
|
||||
points.append(p2p3);
|
||||
pts.append(p2p3);
|
||||
|
||||
points.append(p0p1);
|
||||
points.append(p2p3);
|
||||
points.append
|
||||
pts.append(p0p1);
|
||||
pts.append(p2p3);
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s0,p0,hasSnap0,snapP0,s2,p2,hasSnap2,snapP2)
|
||||
);
|
||||
}
|
||||
|
||||
if (triIndex == 0x09)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-5], points[sz-4]);
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
label sz = pts.size();
|
||||
Swap(pts[sz-5], pts[sz-4]);
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x08:
|
||||
case 0x07:
|
||||
points.append
|
||||
{
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s3,p3,hasSnap3,snapP3,s0,p0,hasSnap0,snapP0)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s3,p3,hasSnap3,snapP3,s2,p2,hasSnap2,snapP2)
|
||||
);
|
||||
points.append
|
||||
pts.append
|
||||
(
|
||||
generatePoint(s3,p3,hasSnap3,snapP3,s1,p1,hasSnap1,snapP1)
|
||||
);
|
||||
|
||||
if (triIndex == 0x07)
|
||||
{
|
||||
// Flip normals
|
||||
label sz = points.size();
|
||||
Swap(points[sz-2], points[sz-1]);
|
||||
label sz = pts.size();
|
||||
Swap(pts[sz-2], pts[sz-1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -565,7 +572,7 @@ void Foam::isoSurface::generateTriPoints
|
||||
triPoints.clear();
|
||||
triMeshCells.clear();
|
||||
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
|
||||
for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
|
||||
{
|
||||
if (faceCutType_[facei] != NOTCUT)
|
||||
{
|
||||
@ -601,10 +608,8 @@ void Foam::isoSurface::generateTriPoints
|
||||
// Determine neighbouring snap status
|
||||
boolList neiSnapped(mesh_.nFaces()-mesh_.nInternalFaces(), false);
|
||||
List<Type> neiSnappedPoint(neiSnapped.size(), Type(Zero));
|
||||
forAll(patches, patchi)
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
if (pp.coupled())
|
||||
{
|
||||
label facei = pp.start();
|
||||
@ -626,7 +631,6 @@ void Foam::isoSurface::generateTriPoints
|
||||
syncTools::swapBoundaryFaceList(mesh_, neiSnappedPoint);
|
||||
|
||||
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
@ -748,8 +752,8 @@ Foam::isoSurface::interpolate
|
||||
)
|
||||
{
|
||||
// One value per point
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(nPoints, Type(Zero)));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(nPoints, Type(Zero));
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
|
||||
// Pass1: unweighted average of merged point values
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -84,7 +84,6 @@ void Foam::thresholdCellFaces::calculate
|
||||
label nFaces = 0;
|
||||
label nPoints = 0;
|
||||
|
||||
|
||||
meshCells_.clear();
|
||||
|
||||
DynamicList<face> surfFaces(0.5 * mesh_.nFaces());
|
||||
@ -98,7 +97,7 @@ void Foam::thresholdCellFaces::calculate
|
||||
{
|
||||
int side = 0;
|
||||
|
||||
// check lowerThreshold
|
||||
// Check lowerThreshold
|
||||
if (field[own[facei]] > lowerThreshold)
|
||||
{
|
||||
if (field[nei[facei]] < lowerThreshold)
|
||||
@ -111,7 +110,7 @@ void Foam::thresholdCellFaces::calculate
|
||||
side = -1;
|
||||
}
|
||||
|
||||
// check upperThreshold
|
||||
// Check upperThreshold
|
||||
if (field[own[facei]] < upperThreshold)
|
||||
{
|
||||
if (field[nei[facei]] > upperThreshold)
|
||||
@ -129,11 +128,11 @@ void Foam::thresholdCellFaces::calculate
|
||||
{
|
||||
const face& f = origFaces[facei];
|
||||
|
||||
forAll(f, fp)
|
||||
for (const label pointi : f)
|
||||
{
|
||||
if (oldToNewPoints[f[fp]] == -1)
|
||||
if (oldToNewPoints[pointi] == -1)
|
||||
{
|
||||
oldToNewPoints[f[fp]] = nPoints++;
|
||||
oldToNewPoints[pointi] = nPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,11 +200,11 @@ void Foam::thresholdCellFaces::calculate
|
||||
)
|
||||
{
|
||||
const face& f = origFaces[facei];
|
||||
forAll(f, fp)
|
||||
for (const label pointi : f)
|
||||
{
|
||||
if (oldToNewPoints[f[fp]] == -1)
|
||||
if (oldToNewPoints[pointi] == -1)
|
||||
{
|
||||
oldToNewPoints[f[fp]] = nPoints++;
|
||||
oldToNewPoints[pointi] = nPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,9 +236,9 @@ void Foam::thresholdCellFaces::calculate
|
||||
surfCells.shrink();
|
||||
|
||||
// renumber
|
||||
forAll(surfFaces, facei)
|
||||
for (face& f : surfFaces)
|
||||
{
|
||||
inplaceRenumber(oldToNewPoints, surfFaces[facei]);
|
||||
inplaceRenumber(oldToNewPoints, f);
|
||||
}
|
||||
|
||||
|
||||
@ -250,7 +249,7 @@ void Foam::thresholdCellFaces::calculate
|
||||
if (oldToNewPoints[pointi] >= 0)
|
||||
{
|
||||
surfPoints[oldToNewPoints[pointi]] = origPoints[pointi];
|
||||
nPoints++;
|
||||
++nPoints;
|
||||
}
|
||||
}
|
||||
surfPoints.setSize(nPoints);
|
||||
@ -276,7 +275,6 @@ Foam::thresholdCellFaces::thresholdCellFaces
|
||||
:
|
||||
mesh_(mesh)
|
||||
{
|
||||
|
||||
if (lowerThreshold > upperThreshold)
|
||||
{
|
||||
WarningInFunction
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,14 +59,15 @@ class thresholdCellFaces
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- For every face the original cell in mesh
|
||||
//- For each face, the original cell in mesh
|
||||
labelList meshCells_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void calculate
|
||||
(
|
||||
const scalarField&,
|
||||
const scalarField& field,
|
||||
const scalar lowerThreshold,
|
||||
const scalar upperThreshold,
|
||||
const bool triangulate
|
||||
@ -80,11 +81,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh, field and threshold value
|
||||
//- Construct from mesh, field and threshold values
|
||||
thresholdCellFaces
|
||||
(
|
||||
const polyMesh&,
|
||||
const scalarField&,
|
||||
const polyMesh& mesh,
|
||||
const scalarField& field,
|
||||
const scalar lowerThreshold,
|
||||
const scalar upperThreshold,
|
||||
const bool triangulate = false
|
||||
@ -93,14 +94,14 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- For every face original cell in mesh
|
||||
labelList& meshCells()
|
||||
//- For each face, the original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
//- For every face original cell in mesh
|
||||
const labelList& meshCells() const
|
||||
//- For each face, the original cell in mesh
|
||||
labelList& meshCells()
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
@ -81,9 +81,8 @@ void Foam::discreteSurface::setZoneMap
|
||||
)
|
||||
{
|
||||
label sz = 0;
|
||||
forAll(zoneLst, zonei)
|
||||
for (const surfZone& zn : zoneLst)
|
||||
{
|
||||
const surfZone& zn = zoneLst[zonei];
|
||||
sz += zn.size();
|
||||
}
|
||||
|
||||
@ -113,9 +112,8 @@ Foam::discreteSurface::nonCoupledboundaryTree() const
|
||||
|
||||
labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces());
|
||||
label bndI = 0;
|
||||
forAll(patches, patchi)
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
if (!pp.coupled())
|
||||
{
|
||||
forAll(pp, i)
|
||||
@ -841,23 +839,24 @@ bool Foam::discreteSurface::update(const treeBoundBox& bb)
|
||||
bool Foam::discreteSurface::sampleAndStore
|
||||
(
|
||||
const objectRegistry& store,
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
return
|
||||
(
|
||||
sampleType<scalar>(store, fieldName)
|
||||
|| sampleType<vector>(store, fieldName)
|
||||
|| sampleType<sphericalTensor>(store, fieldName)
|
||||
|| sampleType<symmTensor>(store, fieldName)
|
||||
|| sampleType<tensor>(store, fieldName)
|
||||
sampleType<scalar>(store, fieldName, sampleScheme)
|
||||
|| sampleType<vector>(store, fieldName, sampleScheme)
|
||||
|| sampleType<sphericalTensor>(store, fieldName, sampleScheme)
|
||||
|| sampleType<symmTensor>(store, fieldName, sampleScheme)
|
||||
|| sampleType<tensor>(store, fieldName, sampleScheme)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::discreteSurface::print(Ostream& os) const
|
||||
{
|
||||
os << "discreteSurface: "
|
||||
os << "discreteSurface:"
|
||||
<< " surface:" << surface_.objectRegistry::name()
|
||||
<< " faces:" << this->surfFaces().size()
|
||||
<< " points:" << this->points().size()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -155,13 +155,35 @@ private:
|
||||
bool update(const meshSearch& meshSearcher);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Sample the volume field onto surface,
|
||||
// store it (temporarily) onto the given registry
|
||||
template<class Type>
|
||||
bool sampleType
|
||||
(
|
||||
const objectRegistry& store,
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface faces
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleOnFaces
|
||||
(
|
||||
const interpolation<Type>& sampler
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface points
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const;
|
||||
|
||||
|
||||
@ -291,7 +313,8 @@ public:
|
||||
virtual bool sampleAndStore
|
||||
(
|
||||
const objectRegistry& store,
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const;
|
||||
|
||||
|
||||
@ -299,28 +322,13 @@ public:
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleType
|
||||
(
|
||||
const word& fieldName
|
||||
) const;
|
||||
|
||||
|
||||
//- Sample field on surface
|
||||
template<class Type>
|
||||
tmp<Field<Type>> sampleField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
) const;
|
||||
|
||||
|
||||
//- Interpolate field on surface
|
||||
template<class Type>
|
||||
tmp<Field<Type>> interpolateField
|
||||
(
|
||||
const interpolation<Type>&
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const;
|
||||
|
||||
|
||||
//- Write information
|
||||
virtual void print(Ostream&) const;
|
||||
virtual void print(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,20 +32,25 @@ template<class Type>
|
||||
bool Foam::discreteSurface::sampleType
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
|
||||
typedef IOField<Type> TmpFieldType;
|
||||
|
||||
if (!mesh().foundObject<VolFieldType>(fieldName))
|
||||
const auto* volFldPtr = mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
||||
|
||||
if (!volFldPtr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const VolFieldType& fld = mesh().lookupObject<VolFieldType>(fieldName);
|
||||
tmp<Field<Type>> tfield = sampleField(fld);
|
||||
const auto& volFld = *volFldPtr;
|
||||
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
||||
|
||||
tmp<Field<Type>> tfield = sampleOnFaces(*samplerPtr);
|
||||
|
||||
// The rest could be moved into a separate helper
|
||||
if (isA<surfMesh>(obr))
|
||||
@ -67,7 +72,7 @@ bool Foam::discreteSurface::sampleType
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
surf,
|
||||
dimensioned<Type>(fld.dimensions(), Zero)
|
||||
dimensioned<Type>(volFld.dimensions(), Zero)
|
||||
);
|
||||
ptr->writeOpt() = IOobject::NO_WRITE;
|
||||
|
||||
@ -110,15 +115,18 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::discreteSurface::sampleType
|
||||
(
|
||||
const word& fieldName
|
||||
const word& fieldName,
|
||||
const word& sampleScheme
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
|
||||
if (mesh().foundObject<VolFieldType>(fieldName))
|
||||
const auto* volFldPtr = mesh().lookupObjectPtr<VolFieldType>(fieldName);
|
||||
|
||||
if (volFldPtr)
|
||||
{
|
||||
const VolFieldType& fld = mesh().lookupObject<VolFieldType>(fieldName);
|
||||
return sampleField(fld);
|
||||
auto samplerPtr = interpolation<Type>::New(sampleScheme, *volFldPtr);
|
||||
return sampleOnFaces(*samplerPtr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -127,22 +135,33 @@ Foam::discreteSurface::sampleType
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::discreteSurface::sampleField
|
||||
Foam::discreteSurface::sampleOnFaces
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const interpolation<Type>& sampler
|
||||
) const
|
||||
{
|
||||
const labelList& elements = sampleElements_;
|
||||
|
||||
const auto& vField = sampler.psi();
|
||||
const label len = elements.size();
|
||||
|
||||
// One value per face
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(sampleElements_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(len);
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
if (!onBoundary())
|
||||
{
|
||||
// Sample cells
|
||||
|
||||
forAll(sampleElements_, triI)
|
||||
const faceList& fcs = this->surfFaces();
|
||||
const pointField& pts = points();
|
||||
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
values[triI] = vField[sampleElements_[triI]];
|
||||
const label celli = elements[i];
|
||||
const point pt = fcs[i].centre(pts);
|
||||
|
||||
values[i] = sampler.interpolate(pt, celli);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -170,10 +189,10 @@ Foam::discreteSurface::sampleField
|
||||
|
||||
// Sample in flat boundary field
|
||||
|
||||
forAll(sampleElements_, triI)
|
||||
for (label i=0; i < len; ++i)
|
||||
{
|
||||
label facei = sampleElements_[triI];
|
||||
values[triI] = bVals[facei-mesh().nInternalFaces()];
|
||||
label facei = elements[i];
|
||||
values[i] = bVals[facei-mesh().nInternalFaces()];
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,14 +202,14 @@ Foam::discreteSurface::sampleField
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::discreteSurface::interpolateField
|
||||
Foam::discreteSurface::sampleOnPoints
|
||||
(
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<Field<Type>> tvalues(new Field<Type>(sampleElements_.size()));
|
||||
Field<Type>& values = tvalues.ref();
|
||||
auto tvalues = tmp<Field<Type>>::New(sampleElements_.size());
|
||||
auto& values = tvalues.ref();
|
||||
|
||||
if (!onBoundary())
|
||||
{
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
Foam::Detail::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
(
|
||||
const IOobject& ioPoints,
|
||||
const IOobject& ioFaces,
|
||||
@ -40,7 +40,7 @@ Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
{}
|
||||
|
||||
|
||||
Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
Foam::Detail::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
(
|
||||
const IOobject& ioPoints, const pointField& points,
|
||||
const IOobject& ioFaces, const faceList& faces,
|
||||
@ -53,7 +53,7 @@ Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
{}
|
||||
|
||||
|
||||
Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
Foam::Detail::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
(
|
||||
const IOobject& ioPoints, pointField&& points,
|
||||
const IOobject& ioFaces, faceList&& faces,
|
||||
@ -68,7 +68,7 @@ Foam::MeshedSurfaceIOAllocator::MeshedSurfaceIOAllocator
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::MeshedSurfaceIOAllocator::~MeshedSurfaceIOAllocator()
|
||||
Foam::Detail::MeshedSurfaceIOAllocator::~MeshedSurfaceIOAllocator()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
@ -76,7 +76,10 @@ Foam::MeshedSurfaceIOAllocator::~MeshedSurfaceIOAllocator()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::MeshedSurfaceIOAllocator::setInstance(const fileName& inst)
|
||||
void Foam::Detail::MeshedSurfaceIOAllocator::setInstance
|
||||
(
|
||||
const fileName& inst
|
||||
)
|
||||
{
|
||||
points_.instance() = inst;
|
||||
faces_.instance() = inst;
|
||||
@ -84,7 +87,10 @@ void Foam::MeshedSurfaceIOAllocator::setInstance(const fileName& inst)
|
||||
}
|
||||
|
||||
|
||||
void Foam::MeshedSurfaceIOAllocator::setWriteOption(IOobject::writeOption wOpt)
|
||||
void Foam::Detail::MeshedSurfaceIOAllocator::setWriteOption
|
||||
(
|
||||
IOobject::writeOption wOpt
|
||||
)
|
||||
{
|
||||
points_.writeOpt() = wOpt;
|
||||
faces_.writeOpt() = wOpt;
|
||||
@ -92,7 +98,7 @@ void Foam::MeshedSurfaceIOAllocator::setWriteOption(IOobject::writeOption wOpt)
|
||||
}
|
||||
|
||||
|
||||
void Foam::MeshedSurfaceIOAllocator::clear()
|
||||
void Foam::Detail::MeshedSurfaceIOAllocator::clear()
|
||||
{
|
||||
points_.clear();
|
||||
faces_.clear();
|
||||
@ -100,7 +106,7 @@ void Foam::MeshedSurfaceIOAllocator::clear()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::MeshedSurfaceIOAllocator::writeObject
|
||||
bool Foam::Detail::MeshedSurfaceIOAllocator::writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::MeshedSurfaceIOAllocator
|
||||
Foam::Detail::MeshedSurfaceIOAllocator
|
||||
|
||||
Description
|
||||
A helper class for storing points, faces and zones with IO capabilities.
|
||||
@ -43,9 +43,11 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class MeshedSurfaceIOAllocator Declaration
|
||||
Class Detail::MeshedSurfaceIOAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class MeshedSurfaceIOAllocator
|
||||
@ -64,10 +66,10 @@ class MeshedSurfaceIOAllocator
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow copy construct
|
||||
//- No copy construct
|
||||
MeshedSurfaceIOAllocator(const MeshedSurfaceIOAllocator&) = delete;
|
||||
|
||||
//- Disallow copy assignment
|
||||
//- No copy assignment
|
||||
void operator=(const MeshedSurfaceIOAllocator&) = delete;
|
||||
|
||||
|
||||
@ -176,6 +178,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Detail
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,10 +54,10 @@ class ModifiableMeshedSurface
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow copy construct
|
||||
//- No copy construct
|
||||
ModifiableMeshedSurface(const ModifiableMeshedSurface<Face>&) = delete;
|
||||
|
||||
//- Disallow copy assignment
|
||||
//- No copy assignment
|
||||
void operator=(const ModifiableMeshedSurface<Face>&) = delete;
|
||||
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ template<class Face> class MeshedSurface;
|
||||
class surfMesh
|
||||
:
|
||||
public surfaceRegistry,
|
||||
private MeshedSurfaceIOAllocator,
|
||||
private Detail::MeshedSurfaceIOAllocator,
|
||||
public PrimitivePatch<face, ::Foam::UList, ::Foam::SubField<point>, point>
|
||||
{
|
||||
public:
|
||||
@ -80,7 +80,7 @@ private:
|
||||
|
||||
// Private Typedefs
|
||||
|
||||
typedef MeshedSurfaceIOAllocator Allocator;
|
||||
typedef Detail::MeshedSurfaceIOAllocator Allocator;
|
||||
|
||||
typedef PrimitivePatch
|
||||
<
|
||||
@ -94,10 +94,10 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow copy construct
|
||||
//- No copy construct
|
||||
surfMesh(const surfMesh&) = delete;
|
||||
|
||||
//- Disallow copy assignment
|
||||
//- No copy assignment
|
||||
void operator=(const surfMesh&) = delete;
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
# An angled plane that extends beyond the geometry
|
||||
o angledPlane
|
||||
|
||||
v -0.03 -0.08 -0.03
|
||||
v -0.03 -0.08 0.03
|
||||
v -0.07 -0.02 0.03
|
||||
v -0.07 -0.02 -0.03
|
||||
|
||||
f 1 2 4
|
||||
f 2 3 4
|
||||
# EOF
|
||||
@ -45,7 +45,19 @@ fieldTransfer
|
||||
${_plane}
|
||||
bounds (-1 -1 -1) (0 0 1);
|
||||
}
|
||||
|
||||
// Angled plane - for general testing
|
||||
plane3
|
||||
{
|
||||
type distanceSurface;
|
||||
distance 0;
|
||||
signed true;
|
||||
|
||||
surfaceType triSurfaceMesh;
|
||||
surfaceName angledPlane.obj;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -54,6 +54,19 @@ UI2
|
||||
}
|
||||
|
||||
|
||||
// Uniformity on sampled surface
|
||||
UI3
|
||||
{
|
||||
${__surfaceFieldValue}
|
||||
|
||||
regionType surface;
|
||||
name plane3;
|
||||
|
||||
operation uniformity;
|
||||
fields ( U T );
|
||||
}
|
||||
|
||||
|
||||
// Inflow uniformity, but use a scalar field for weighting
|
||||
// Since this field is quite uniform, there should be no difference
|
||||
T_UI1
|
||||
@ -96,4 +109,5 @@ rhoU_UI2
|
||||
fields ( p rho U rhoU );
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
debug
|
||||
{
|
||||
type surfaces;
|
||||
libs ("libsampling.so");
|
||||
log true;
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
|
||||
fields (rho U);
|
||||
|
||||
sampleScheme cellPoint;
|
||||
interpolationScheme cellPoint;
|
||||
surfaceFormat ensight;
|
||||
|
||||
formatOptions
|
||||
{
|
||||
ensight
|
||||
{
|
||||
collateTimes true;
|
||||
}
|
||||
}
|
||||
|
||||
surfaces
|
||||
(
|
||||
angledPlane
|
||||
{
|
||||
type distanceSurface;
|
||||
distance 0;
|
||||
signed true;
|
||||
regularise true;
|
||||
surfaceType triSurfaceMesh;
|
||||
surfaceName angledPlane.obj;
|
||||
}
|
||||
|
||||
iso
|
||||
{
|
||||
type isoSurface;
|
||||
isoField p;
|
||||
isoValue 1e5;
|
||||
regularise true;
|
||||
interpolate true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,5 +1,5 @@
|
||||
#-------------------------------*- makefile -*---------------------------------
|
||||
WM_VERSION = OPENFOAM=1804
|
||||
WM_VERSION = OPENFOAM=1805
|
||||
|
||||
AR = ar
|
||||
ARFLAGS = cr
|
||||
|
||||
Reference in New Issue
Block a user