Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
c8d4ea0e
Commit
c8d4ea0e
authored
Nov 05, 2008
by
mattijs
Browse files
isosurfaces
parent
593db180
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
src/sampling/Make/files
View file @
c8d4ea0e
...
...
@@ -24,6 +24,7 @@ sampledSurface/patch/sampledPatch.C
sampledSurface/plane/sampledPlane.C
sampledSurface/isoSurface/isoSurface.C
sampledSurface/isoSurface/sampledIsoSurface.C
sampledSurface/distanceSurface/distanceSurface.C
sampledSurface/sampledSurface/sampledSurface.C
sampledSurface/sampledSurfaces/sampledSurfaces.C
sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C
...
...
src/sampling/sampledSurface/distanceSurface/distanceSurface.C
0 → 100644
View file @
c8d4ea0e
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include
"distanceSurface.H"
#include
"dictionary.H"
#include
"volFields.H"
#include
"volPointInterpolation.H"
#include
"addToRunTimeSelectionTable.H"
#include
"fvMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace
Foam
{
defineTypeNameAndDebug
(
distanceSurface
,
0
);
addToRunTimeSelectionTable
(
sampledSurface
,
distanceSurface
,
word
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void
Foam
::
distanceSurface
::
createGeometry
()
const
{
// Clear any stored topo
facesPtr_
.
clear
();
// Distance to cell centres
scalarField
cellDistance
(
mesh
().
nCells
());
{
List
<
pointIndexHit
>
nearest
;
surfPtr_
().
findNearest
(
mesh
().
cellCentres
(),
scalarField
(
mesh
().
nCells
(),
GREAT
),
nearest
);
forAll
(
cellDistance
,
cellI
)
{
cellDistance
[
cellI
]
=
Foam
::
mag
(
nearest
[
cellI
].
hitPoint
()
-
mesh
().
cellCentres
()[
cellI
]
);
}
}
// Distance to points
scalarField
pointDistance
(
mesh
().
nPoints
());
{
List
<
pointIndexHit
>
nearest
;
surfPtr_
().
findNearest
(
mesh
().
points
(),
scalarField
(
mesh
().
nPoints
(),
GREAT
),
nearest
);
forAll
(
pointDistance
,
pointI
)
{
pointDistance
[
pointI
]
=
Foam
::
mag
(
nearest
[
pointI
].
hitPoint
()
-
mesh
().
points
()[
pointI
]
);
}
}
//- Direct from cell field and point field.
const
isoSurface
iso
(
mesh
(),
cellDistance
,
pointDistance
,
distance_
,
regularise_
);
////- From point field and interpolated cell.
//scalarField cellAvg(mesh().nCells(), scalar(0.0));
//labelField nPointCells(mesh().nCells(), 0);
//{
// for (label pointI = 0; pointI < mesh().nPoints(); pointI++)
// {
// const labelList& pCells = mesh().pointCells(pointI);
//
// forAll(pCells, i)
// {
// label cellI = pCells[i];
//
// cellAvg[cellI] += pointDistance[pointI];
// nPointCells[cellI]++;
// }
// }
//}
//forAll(cellAvg, cellI)
//{
// cellAvg[cellI] /= nPointCells[cellI];
//}
//
//const isoSurface iso
//(
// mesh(),
// cellAvg,
// pointDistance,
// distance_,
// regularise_
//);
const_cast
<
distanceSurface
&>
(
*
this
).
triSurface
::
operator
=
(
iso
);
meshCells_
=
iso
.
meshCells
();
if
(
debug
)
{
print
(
Pout
);
}
}
// * * * * * * * * * * * * * * * * 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"
))),
regularise_
(
dict
.
lookupOrDefault
(
"regularise"
,
true
)),
zoneName_
(
word
::
null
),
facesPtr_
(
NULL
),
storedTimeIndex_
(
-
1
),
meshCells_
(
0
)
{
// label zoneId = -1;
// if (dict.readIfPresent("zone", zoneName_))
// {
// zoneId = mesh.cellZones().findZoneID(zoneName_);
// if (debug && zoneId < 0)
// {
// Info<< "cellZone \"" << zoneName_
// << "\" not found - using entire mesh"
// << endl;
// }
// }
correct
(
true
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam
::
distanceSurface
::~
distanceSurface
()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam
::
distanceSurface
::
correct
(
const
bool
meshChanged
)
{
// Only change of mesh changes plane - zone restriction gets lost
if
(
meshChanged
)
{
createGeometry
();
}
}
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
();
}
// ************************************************************************* //
src/sampling/sampledSurface/distanceSurface/distanceSurface.H
0 → 100644
View file @
c8d4ea0e
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::distanceSurface
Description
A sampledSurface defined by a distance to a surface.
SourceFiles
distanceSurface.C
\*---------------------------------------------------------------------------*/
#ifndef distanceSurface_H
#define distanceSurface_H
#include
"sampledSurface.H"
#include
"triSurface.H"
#include
"searchableSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
/*---------------------------------------------------------------------------*\
Class distanceSurface Declaration
\*---------------------------------------------------------------------------*/
class
distanceSurface
:
public
sampledSurface
,
public
triSurface
{
// Private data
//- Surface
const
autoPtr
<
searchableSurface
>
surfPtr_
;
//- distance value
const
scalar
distance_
;
//- Whether to coarsen
const
Switch
regularise_
;
//- zone name (if restricted to zones)
word
zoneName_
;
//- triangles converted to faceList
mutable
autoPtr
<
faceList
>
facesPtr_
;
// Recreated for every isoSurface
//- Time at last call
mutable
label
storedTimeIndex_
;
//- For every triangle the original cell in mesh
mutable
labelList
meshCells_
;
// Private Member Functions
//- Create iso surface (if time has changed)
void
createGeometry
()
const
;
//- sample field on faces
template
<
class
Type
>
tmp
<
Field
<
Type
>
>
sampleField
(
const
GeometricField
<
Type
,
fvPatchField
,
volMesh
>&
vField
)
const
;
template
<
class
Type
>
tmp
<
Field
<
Type
>
>
interpolateField
(
const
interpolation
<
Type
>&
)
const
;
public:
//- Runtime type information
TypeName
(
"distanceSurface"
);
// Constructors
//- Construct from dictionary
distanceSurface
(
const
word
&
name
,
const
polyMesh
&
mesh
,
const
dictionary
&
dict
);
// Destructor
virtual
~
distanceSurface
();
// Member Functions
//- Points of surface
virtual
const
pointField
&
points
()
const
{
return
triSurface
::
points
();
}
//- Faces of surface
virtual
const
faceList
&
faces
()
const
{
if
(
!
facesPtr_
.
valid
())
{
const
triSurface
&
s
=
*
this
;
facesPtr_
.
reset
(
new
faceList
(
s
.
size
()));
forAll
(
s
,
i
)
{
facesPtr_
()[
i
]
=
s
[
i
].
triFaceFace
();
}
}
return
facesPtr_
;
}
//- Correct for mesh movement and/or field changes
virtual
void
correct
(
const
bool
meshChanged
);
//- sample field on surface
virtual
tmp
<
scalarField
>
sample
(
const
volScalarField
&
)
const
;
//- sample field on surface
virtual
tmp
<
vectorField
>
sample
(
const
volVectorField
&
)
const
;
//- sample field on surface
virtual
tmp
<
sphericalTensorField
>
sample
(
const
volSphericalTensorField
&
)
const
;
//- sample field on surface
virtual
tmp
<
symmTensorField
>
sample
(
const
volSymmTensorField
&
)
const
;
//- sample field on surface
virtual
tmp
<
tensorField
>
sample
(
const
volTensorField
&
)
const
;
//- interpolate field on surface
virtual
tmp
<
scalarField
>
interpolate
(
const
interpolation
<
scalar
>&
)
const
;
//- interpolate field on surface
virtual
tmp
<
vectorField
>
interpolate
(
const
interpolation
<
vector
>&
)
const
;
//- interpolate field on surface
virtual
tmp
<
sphericalTensorField
>
interpolate
(
const
interpolation
<
sphericalTensor
>&
)
const
;
//- interpolate field on surface
virtual
tmp
<
symmTensorField
>
interpolate
(
const
interpolation
<
symmTensor
>&
)
const
;
//- interpolate field on surface
virtual
tmp
<
tensorField
>
interpolate
(
const
interpolation
<
tensor
>&
)
const
;
//- Write
virtual
void
print
(
Ostream
&
)
const
;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "distanceSurfaceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
src/sampling/sampledSurface/distanceSurface/distanceSurfaceTemplates.C
0 → 100644
View file @
c8d4ea0e
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include
"distanceSurface.H"
#include
"isoSurface.H"
#include
"volFieldsFwd.H"
#include
"pointFields.H"
#include
"volPointInterpolation.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
distanceSurface
::
sampleField
(
const
GeometricField
<
Type
,
fvPatchField
,
volMesh
>&
vField
)
const
{
return
tmp
<
Field
<
Type
>
>
(
new
Field
<
Type
>
(
vField
,
meshCells_
));
}
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
distanceSurface
::
interpolateField