ENH: distanceSurface: use either cell (default) or cross-cell isosurface

This commit is contained in:
mattijs
2012-02-29 11:51:42 +00:00
parent 644dfbbffd
commit 003e62fadc
3 changed files with 149 additions and 35 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,6 +49,8 @@ void Foam::distanceSurface::createGeometry()
// Clear any stored topologies // Clear any stored topologies
facesPtr_.clear(); facesPtr_.clear();
isoSurfCellPtr_.clear();
isoSurfPtr_.clear();
// Clear derived data // Clear derived data
clearGeom(); clearGeom();
@ -265,6 +267,22 @@ void Foam::distanceSurface::createGeometry()
//- Direct from cell field and point field. //- Direct from cell field and point field.
if (cell_)
{
isoSurfCellPtr_.reset
(
new isoSurfaceCell
(
fvm,
cellDistance,
pointDistance_,
distance_,
regularise_
)
);
}
else
{
isoSurfPtr_.reset isoSurfPtr_.reset
( (
new isoSurface new isoSurface
@ -274,15 +292,8 @@ void Foam::distanceSurface::createGeometry()
distance_, distance_,
regularise_ regularise_
) )
//new isoSurfaceCell
//(
// fvm,
// cellDistance,
// pointDistance_,
// distance_,
// regularise_
//)
); );
}
if (debug) if (debug)
{ {
@ -321,10 +332,12 @@ Foam::distanceSurface::distanceSurface
), ),
distance_(readScalar(dict.lookup("distance"))), distance_(readScalar(dict.lookup("distance"))),
signed_(readBool(dict.lookup("signed"))), signed_(readBool(dict.lookup("signed"))),
cell_(dict.lookupOrDefault("cell", true)),
regularise_(dict.lookupOrDefault("regularise", true)), regularise_(dict.lookupOrDefault("regularise", true)),
average_(dict.lookupOrDefault("average", false)), average_(dict.lookupOrDefault("average", false)),
zoneKey_(keyType::null), zoneKey_(keyType::null),
needsUpdate_(true), needsUpdate_(true),
isoSurfCellPtr_(NULL),
isoSurfPtr_(NULL), isoSurfPtr_(NULL),
facesPtr_(NULL) facesPtr_(NULL)
{ {
@ -338,6 +351,52 @@ Foam::distanceSurface::distanceSurface
} }
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
)
:
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),
zoneKey_(keyType::null),
needsUpdate_(true),
isoSurfCellPtr_(NULL),
isoSurfPtr_(NULL),
facesPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::distanceSurface::~distanceSurface() Foam::distanceSurface::~distanceSurface()

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,6 +27,8 @@ Class
Description Description
A sampledSurface defined by a distance to a surface. A sampledSurface defined by a distance to a surface.
Uses either isoSurfaceCell or isoSurface.
SourceFiles SourceFiles
distanceSurface.C distanceSurface.C
@ -37,7 +39,7 @@ SourceFiles
#include "sampledSurface.H" #include "sampledSurface.H"
#include "searchableSurface.H" #include "searchableSurface.H"
//#include "isoSurfaceCell.H" #include "isoSurfaceCell.H"
#include "isoSurface.H" #include "isoSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -64,6 +66,9 @@ class distanceSurface
//- signed distance //- signed distance
const bool signed_; const bool signed_;
//- Whether to use isoSurfaceCell or isoSurface
const bool cell_;
//- Whether to coarsen //- Whether to coarsen
const Switch regularise_; const Switch regularise_;
@ -84,7 +89,9 @@ class distanceSurface
scalarField pointDistance_; scalarField pointDistance_;
//- Constructed iso surface //- Constructed iso surface
//autoPtr<isoSurfaceCell> isoSurfPtr_; autoPtr<isoSurfaceCell> isoSurfCellPtr_;
//- Constructed iso surface
autoPtr<isoSurface> isoSurfPtr_; autoPtr<isoSurface> isoSurfPtr_;
//- triangles converted to faceList //- triangles converted to faceList
@ -125,6 +132,21 @@ public:
const dictionary& dict 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
);
//- Destructor //- Destructor
virtual ~distanceSurface(); virtual ~distanceSurface();
@ -167,12 +189,17 @@ public:
return facesPtr_; return facesPtr_;
} }
const triSurface& surface() const
//const isoSurfaceCell& surface() const {
const isoSurface& surface() const if (cell_)
{
return isoSurfCellPtr_();
}
else
{ {
return isoSurfPtr_(); return isoSurfPtr_();
} }
}
//- sample field on surface //- sample field on surface
virtual tmp<scalarField> sample virtual tmp<scalarField> sample

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,7 +37,20 @@ Foam::distanceSurface::sampleField
const GeometricField<Type, fvPatchField, volMesh>& vField const GeometricField<Type, fvPatchField, volMesh>& vField
) const ) const
{ {
return tmp<Field<Type> >(new Field<Type>(vField, surface().meshCells())); if (cell_)
{
return tmp<Field<Type> >
(
new Field<Type>(vField, isoSurfCellPtr_().meshCells())
);
}
else
{
return tmp<Field<Type> >
(
new Field<Type>(vField, isoSurfPtr_().meshCells())
);
}
} }
@ -60,7 +73,9 @@ Foam::distanceSurface::interpolateField
); );
// Sample. // Sample.
return surface().interpolate if (cell_)
{
return isoSurfCellPtr_().interpolate
( (
( (
average_ average_
@ -69,6 +84,19 @@ Foam::distanceSurface::interpolateField
), ),
pointFld() pointFld()
); );
}
else
{
return isoSurfPtr_().interpolate
(
(
average_
? pointAverage(pointFld())()
: volFld
),
pointFld()
);
}
} }