ENH: sampledTriSurfaceMeshNormal: variant of sampledTriSurfaceMesh. Fixes #500.
This commit is contained in:
parent
7e6faf049c
commit
acdeb308be
@ -39,6 +39,7 @@ sampledSurface/sampledSurface/sampledSurface.C
|
||||
sampledSurface/sampledSurfaces/sampledSurfaces.C
|
||||
sampledSurface/sampledSurfaces/sampledSurfacesGrouping.C
|
||||
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
|
||||
sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshNormal.C
|
||||
sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
|
||||
|
||||
/* Proof-of-concept: */
|
||||
|
@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 "sampledTriSurfaceMeshNormal.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledTriSurfaceMeshNormal, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sampledSurface,
|
||||
sampledTriSurfaceMeshNormal,
|
||||
word
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const word& surfaceName,
|
||||
const samplingSource sampleSource
|
||||
)
|
||||
:
|
||||
sampledTriSurfaceMesh(name, mesh, surfaceName, sampleSource)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampledTriSurfaceMesh(name, mesh, dict)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sampledTriSurfaceMeshNormal::sampledTriSurfaceMeshNormal
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const triSurface& surface,
|
||||
const word& sampleSourceName
|
||||
)
|
||||
:
|
||||
sampledTriSurfaceMesh(name, mesh, surface, sampleSourceName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledTriSurfaceMeshNormal::~sampledTriSurfaceMeshNormal()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector>>
|
||||
Foam::sampledTriSurfaceMeshNormal::sample
|
||||
(
|
||||
const GeometricField<vector, fvPatchField, volMesh>& vField
|
||||
) const
|
||||
{
|
||||
tmp<Field<vector>> tfld(new Field<vector>(size(), vector::zero));
|
||||
tfld.ref().replace
|
||||
(
|
||||
0,
|
||||
meshedSurface::faceNormals()
|
||||
&sampledTriSurfaceMesh::sample(vField)
|
||||
);
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::Field<Foam::vector>>
|
||||
Foam::sampledTriSurfaceMeshNormal::interpolate
|
||||
(
|
||||
const interpolation<vector>& interpolator
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<vectorField> tn
|
||||
(
|
||||
new vectorField
|
||||
(
|
||||
points().size(),
|
||||
vector::zero
|
||||
)
|
||||
);
|
||||
|
||||
pointField allNormals(tn().size(), vector::zero);
|
||||
UIndirectList<vector>(allNormals, meshPoints()) = pointNormals();
|
||||
|
||||
tn.ref().replace
|
||||
(
|
||||
0,
|
||||
allNormals
|
||||
&sampledTriSurfaceMesh::interpolate(interpolator)
|
||||
);
|
||||
return tn;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,201 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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::sampledTriSurfaceMeshNormal
|
||||
|
||||
Description
|
||||
Variant of sampledTriSurfaceMesh that samples the surface-normal component
|
||||
of a vector field.
|
||||
|
||||
Returns a vector field with the value in the first component and sets
|
||||
the other two to zero.
|
||||
|
||||
SourceFiles
|
||||
sampledTriSurfaceMeshNormal.C
|
||||
sampledTriSurfaceMeshNormalTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampledTriSurfaceMeshNormal_H
|
||||
#define sampledTriSurfaceMeshNormal_H
|
||||
|
||||
#include "sampledTriSurfaceMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampledTriSurfaceMeshNormal Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampledTriSurfaceMeshNormal
|
||||
:
|
||||
public sampledTriSurfaceMesh
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sampledTriSurfaceMeshNormal");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
sampledTriSurfaceMeshNormal
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const word& surfaceName,
|
||||
const samplingSource sampleSource
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sampledTriSurfaceMeshNormal
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from triSurface
|
||||
sampledTriSurfaceMeshNormal
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const triSurface& surface,
|
||||
const word& sampleSourceName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sampledTriSurfaceMeshNormal();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<scalarField> sample
|
||||
(
|
||||
const volScalarField&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<scalarField>();
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<vectorField> sample
|
||||
(
|
||||
const volVectorField&
|
||||
) const;
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<sphericalTensorField> sample
|
||||
(
|
||||
const volSphericalTensorField&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<sphericalTensorField>();
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<symmTensorField> sample
|
||||
(
|
||||
const volSymmTensorField&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<symmTensorField>();
|
||||
}
|
||||
|
||||
//- Sample field on surface
|
||||
virtual tmp<tensorField> sample
|
||||
(
|
||||
const volTensorField&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<tensorField>();
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const interpolation<scalar>&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<scalarField>();
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const interpolation<vector>&
|
||||
) const;
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const interpolation<sphericalTensor>&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<sphericalTensorField>();
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const interpolation<symmTensor>&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<symmTensorField>();
|
||||
}
|
||||
|
||||
//- Interpolate field on surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const interpolation<tensor>&
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<tensorField>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
Loading…
Reference in New Issue
Block a user