Commit 4a845f5c authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: newly structured surface 'sources' for sampling.

- extend the sampling concept to include surfMeshes and surfFields
  for storage.

- Note the createOnRead switch in surfMeshSamplers can be desirable in
  some situations to force creation of the surface faces within the
  constructor.
parent 5d7f8f11
......@@ -21,6 +21,12 @@ surface/cuttingPlane/cuttingPlane.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
sampledSurface/sampledPatch/sampledPatch.C
sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C
......@@ -35,6 +41,10 @@ sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
/* Proof-of-concept: */
/* sampledSurface/triSurfaceMesh/sampledDiscreteSurface.C */
surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriter.C
......
......@@ -64,6 +64,9 @@ Description
}
\endverbatim
See also
Foam::surfMeshSamplers
SourceFiles
sampledSurfaces.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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.
-------------------------------------------------------------------------------
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 "sampledDiscreteSurface.H"
#include "meshSearch.H"
#include "Tuple2.H"
#include "globalIndex.H"
#include "treeDataCell.H"
#include "treeDataFace.H"
#include "meshTools.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sampledDiscreteSurface, 0);
addToRunTimeSelectionTable
(
sampledSurface,
sampledDiscreteSurface,
word
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledDiscreteSurface::sampledDiscreteSurface
(
const word& name,
const polyMesh& mesh,
const word& surfaceName,
const discreteSurface::samplingSource sampleSource
)
:
sampledSurface(name, mesh),
SurfaceSource(mesh, surfaceName, sampleSource)
{}
Foam::sampledDiscreteSurface::sampledDiscreteSurface
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
)
:
sampledSurface(name, mesh, dict),
SurfaceSource(mesh, dict)
{}
Foam::sampledDiscreteSurface::sampledDiscreteSurface
(
const word& name,
const polyMesh& mesh,
const triSurface& surface,
const word& sampleSourceName
)
:
sampledSurface(name, mesh),
SurfaceSource(name, mesh, surface, sampleSourceName)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledDiscreteSurface::~sampledDiscreteSurface()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sampledDiscreteSurface::needsUpdate() const
{
return SurfaceSource::needsUpdate();
}
bool Foam::sampledDiscreteSurface::expire()
{
if (SurfaceSource::expire())
{
// merged information etc
sampledSurface::clearGeom();
return true;
}
return false;
}
bool Foam::sampledDiscreteSurface::update()
{
return SurfaceSource::update();
}
bool Foam::sampledDiscreteSurface::update(const treeBoundBox& bb)
{
return SurfaceSource::update(bb);
}
bool Foam::sampledDiscreteSurface::sampleAndStore
(
const objectRegistry& store,
const word& fieldName
) const
{
return SurfaceSource::sampleAndStore(store, fieldName);
}
Foam::tmp<Foam::scalarField> Foam::sampledDiscreteSurface::sample
(
const volScalarField& vField
) const
{
return SurfaceSource::sampleField(vField);
}
Foam::tmp<Foam::vectorField> Foam::sampledDiscreteSurface::sample
(
const volVectorField& vField
) const
{
return SurfaceSource::sampleField(vField);
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledDiscreteSurface::sample
(
const volSphericalTensorField& vField
) const
{
return SurfaceSource::sampleField(vField);
}
Foam::tmp<Foam::symmTensorField> Foam::sampledDiscreteSurface::sample
(
const volSymmTensorField& vField
) const
{
return SurfaceSource::sampleField(vField);
}
Foam::tmp<Foam::tensorField> Foam::sampledDiscreteSurface::sample
(
const volTensorField& vField
) const
{
return SurfaceSource::sampleField(vField);
}
Foam::tmp<Foam::scalarField> Foam::sampledDiscreteSurface::interpolate
(
const interpolation<scalar>& interpolator
) const
{
return SurfaceSource::interpolateField(interpolator);
}
Foam::tmp<Foam::vectorField> Foam::sampledDiscreteSurface::interpolate
(
const interpolation<vector>& interpolator
) const
{
return SurfaceSource::interpolateField(interpolator);
}
Foam::tmp<Foam::sphericalTensorField> Foam::sampledDiscreteSurface::interpolate
(
const interpolation<sphericalTensor>& interpolator
) const
{
return SurfaceSource::interpolateField(interpolator);
}
Foam::tmp<Foam::symmTensorField> Foam::sampledDiscreteSurface::interpolate
(
const interpolation<symmTensor>& interpolator
) const
{
return SurfaceSource::interpolateField(interpolator);
}
Foam::tmp<Foam::tensorField> Foam::sampledDiscreteSurface::interpolate
(
const interpolation<tensor>& interpolator
) const
{
return SurfaceSource::interpolateField(interpolator);
}
void Foam::sampledDiscreteSurface::print(Ostream& os) const
{
os << "sampledDiscreteSurface: " << name() << " :";
SurfaceSource::print(os);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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.
-------------------------------------------------------------------------------
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::sampledDiscreteSurface
Description
A sampledSurface from a triSurfaceMesh.
It samples on the points/triangles of a triSurfaceMesh.
See Also
discreteSurface, sampledSurface
SourceFiles
sampledDiscreteSurface.C
sampledDiscreteSurfaceTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef sampledDiscreteSurface_H
#define sampledDiscreteSurface_H
#include "sampledSurface.H"
#include "discreteSurface.H"
#include "triSurfaceMesh.H"
#include "MeshedSurface.H"
#include "MeshedSurfacesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class sampledDiscreteSurface;
/*---------------------------------------------------------------------------*\
Class sampledDiscreteSurface Declaration
\*---------------------------------------------------------------------------*/
class sampledDiscreteSurface
:
public sampledSurface,
public discreteSurface
{
//- Private typedefs for convenience
typedef discreteSurface MeshStorage;
typedef discreteSurface SurfaceSource;
// Private Member Functions
//- Sample field on faces
template<class Type>
tmp<Field<Type>> sampleField
(
const GeometricField<Type, fvPatchField, volMesh>& vField
) const;
template<class Type>
tmp<Field<Type>>
interpolateField(const interpolation<Type>&) const;
public:
//- Runtime type information
TypeName("sampledDiscreteSurface");
// Constructors
//- Construct from components
sampledDiscreteSurface
(
const word& name,
const polyMesh& mesh,
const word& surfaceName,
const discreteSurface::samplingSource sampleSource
);
//- Construct from dictionary
sampledDiscreteSurface
(
const word& name,
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from triSurface
sampledDiscreteSurface
(
const word& name,
const polyMesh& mesh,
const triSurface& surface,
const word& sampleSourceName
);
//- Destructor
virtual ~sampledDiscreteSurface();
// Member Functions
//- Does the surface need an update?
virtual bool needsUpdate() const;
//- Mark the surface as needing an update.
// May also free up unneeded data.
// Return false if surface was already marked as expired.
virtual bool expire();
//- Update the surface as required.
// Do nothing (and return false) if no update was needed
virtual bool update();
//- 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&);
//- Points of surface
virtual const pointField& points() const
{
return MeshStorage::points();
}
//- Faces of surface
virtual const faceList& faces() const
{
return MeshStorage::surfFaces();
}
//- Const access to per-face zone/region information
virtual const labelList& zoneIds() const
{
return MeshStorage::zoneIds();
}
//- Face area vectors
virtual const vectorField& Sf() const
{
return MeshStorage::Sf();
}
//- Face area magnitudes
virtual const scalarField& magSf() const
{
return MeshStorage::magSf();
}
//- Face centres
virtual const vectorField& Cf() const
{
return MeshStorage::Cf();
}
//- If element ids/order of the original surface are kept
bool keepIds() const
{
return MeshStorage::keepIds();
}
//- List of element ids/order of the original surface,
// when keepIds is active.
const labelList& originalIds() const
{
return MeshStorage::originalIds();
}
//- Sample the volume field onto surface,
// store it (temporarily) onto the given registry
virtual bool sampleAndStore
(
const objectRegistry& store,
const word& fieldName
) const;
//- 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 information
virtual void print(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// #ifdef NoRepository
// #include "sampledDiscreteSurfaceTemplates.C"
// #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 "sampledDiscreteSurface.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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