ENH: propogate face area support into surface-type meshes (issue #266)

* MeshedSurface / surfMesh / triSurface

- use shorter method names similar to those from volume meshes:

      Sf(), magSf(), Cf()

  instead of the longer ones from PrimitivePatch:

      faceAreas(), magFaceAreas(), faceCentres()

- similar names throughout to ease switching between triSurface and
  MeshedSurface storage.
This commit is contained in:
Mark Olesen
2016-10-20 08:36:02 +02:00
parent caba74dcfa
commit fb9f93dd7c
7 changed files with 94 additions and 20 deletions

View File

@ -161,7 +161,8 @@ int main(int argc, char *argv[])
Info<< "Read surface:" << endl; Info<< "Read surface:" << endl;
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
// check: output to ostream, construct from istream // check: output to ostream, construct from istream
{ {
@ -205,7 +206,8 @@ int main(int argc, char *argv[])
Info<< " with scaling " << scaleFactor << endl; Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor); surf.scalePoints(scaleFactor);
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
} }
if (optStdout) if (optStdout)
@ -224,7 +226,8 @@ int main(int argc, char *argv[])
Info<< "Read surface:" << endl; Info<< "Read surface:" << endl;
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
// check: output to ostream, construct from istream // check: output to ostream, construct from istream
{ {
@ -268,7 +271,8 @@ int main(int argc, char *argv[])
Info<< " with scaling " << scaleFactor << endl; Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor); surf.scalePoints(scaleFactor);
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
} }
if (optStdout) if (optStdout)
@ -286,7 +290,8 @@ int main(int argc, char *argv[])
Info<< "Read surface:" << endl; Info<< "Read surface:" << endl;
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
// check: output to ostream, construct from istream // check: output to ostream, construct from istream
{ {
@ -330,7 +335,8 @@ int main(int argc, char *argv[])
Info<< " with scaling " << scaleFactor << endl; Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor); surf.scalePoints(scaleFactor);
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
} }
if (optStdout) if (optStdout)
@ -348,7 +354,8 @@ int main(int argc, char *argv[])
Info<< "Read surface:" << endl; Info<< "Read surface:" << endl;
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
// check: output to ostream, construct from istream // check: output to ostream, construct from istream
{ {
@ -392,7 +399,8 @@ int main(int argc, char *argv[])
Info<< " with scaling " << scaleFactor << endl; Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor); surf.scalePoints(scaleFactor);
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< "Area : " << sum(surf.magSf()) << nl
<< endl;
} }
if (optStdout) if (optStdout)

View File

@ -431,7 +431,9 @@ Foam::MeshedSurface<Face>::MeshedSurface
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::~MeshedSurface() Foam::MeshedSurface<Face>::~MeshedSurface()
{} {
clear();
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -500,6 +502,9 @@ void Foam::MeshedSurface<Face>::clear()
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints) void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints)
{ {
// Changes areas, normals etc.
ParentType::clearGeom();
// Adapt for new point position // Adapt for new point position
ParentType::movePoints(newPoints); ParentType::movePoints(newPoints);
@ -511,9 +516,12 @@ void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints)
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::scalePoints(const scalar scaleFactor) void Foam::MeshedSurface<Face>::scalePoints(const scalar scaleFactor)
{ {
// avoid bad scaling // Avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0) if (scaleFactor > 0 && scaleFactor != 1.0)
{ {
// Changes areas, normals etc.
ParentType::clearGeom();
pointField newPoints(scaleFactor*this->points()); pointField newPoints(scaleFactor*this->points());
// Adapt for new point position // Adapt for new point position
@ -586,7 +594,7 @@ void Foam::MeshedSurface<Face>::reset
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::cleanup(const bool verbose) void Foam::MeshedSurface<Face>::cleanup(const bool verbose)
{ {
// merge points (already done for STL, TRI) // Merge points (already done for STL, TRI)
stitchFaces(SMALL, verbose); stitchFaces(SMALL, verbose);
checkFaces(verbose); checkFaces(verbose);
@ -943,8 +951,6 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
} }
template<class Face> template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
( (

View File

@ -339,6 +339,31 @@ public:
return zones_; return zones_;
} }
//- Face area vectors (normals)
inline const vectorField& Sf() const
{
return ParentType::faceAreas();
}
//- Face area magnitudes
inline const scalarField& magSf() const
{
return ParentType::magFaceAreas();
}
//- Face centres
inline const vectorField& Cf() const
{
return ParentType::faceCentres();
}
// Edit
//- Clear all storage
virtual void clear();
//- Add surface zones //- Add surface zones
virtual void addZones virtual void addZones
( (
@ -365,11 +390,6 @@ public:
virtual void removeZones(); virtual void removeZones();
// Edit
//- Clear all storage
virtual void clear();
//- Move points //- Move points
virtual void movePoints(const pointField&); virtual void movePoints(const pointField&);

View File

@ -233,6 +233,25 @@ public:
//- Check the surface zone definitions //- Check the surface zone definitions
void checkZones(); void checkZones();
//- Return face area vectors (normals)
inline const vectorField& Sf() const
{
return MeshReference::faceAreas();
}
//- Return face area magnitudes
inline const scalarField& magSf() const
{
return MeshReference::magFaceAreas();
}
//- Face centres
inline const vectorField& Cf() const
{
return MeshReference::faceCentres();
}
//- Add surface zones //- Add surface zones
void addZones void addZones
( (

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,6 +69,8 @@ void Foam::surfMesh::clearAddressing()
void Foam::surfMesh::clearOut() void Foam::surfMesh::clearOut()
{ {
MeshReference::clearOut();
clearGeom(); clearGeom();
clearAddressing(); clearAddressing();
} }

View File

@ -168,7 +168,7 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
Info<< "Point motion" << endl; Info<< "Point motion" << endl;
} }
clearGeom(); clearOut();
storedIOPoints().instance() = pointsInst; storedIOPoints().instance() = pointsInst;
storedIOPoints() = pointIOField storedIOPoints() = pointIOField

View File

@ -335,6 +335,25 @@ public:
const labelList& edgeOwner() const; const labelList& edgeOwner() const;
//- Face area vectors (normals)
inline const vectorField& Sf() const
{
return ParentType::faceAreas();
}
//- Face area magnitudes
inline const scalarField& magSf() const
{
return ParentType::magFaceAreas();
}
//- Face centres
inline const vectorField& Cf() const
{
return ParentType::faceCentres();
}
// Edit // Edit
//- Move points //- Move points