Commit b6304d25 authored by franjo_j@hotmail.com's avatar franjo_j@hotmail.com
Browse files

Bug fixes in fms IO + classification of edges in the surface mesh


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@17 fdcce57e-7e00-11e2-b579-49867b4cea03
parent d73212d8
......@@ -9,6 +9,8 @@ meshSurfaceCheckInvertedVertices = utilities/surfaceTools/meshSurfaceCheckInvert
meshSurfaceCheckEdgeTypes = utilities/surfaceTools/meshSurfaceCheckEdgeTypes
meshSurfaceCutter = utilities/surfaceTools/meshSurfaceCutter
meshSurfaceMapper = utilities/surfaceTools/meshSurfaceMapper
edgeExtraction = utilities/surfaceTools/edgeExtraction
edgeExtractionFunctions = $(edgeExtraction)/edgeExtractionFunctions
meshSurfaceEdgeExtractor = utilities/surfaceTools/meshSurfaceEdgeExtractor
meshSurfaceEdgeExtractorNonTopo = utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo
meshSurfaceEdgeExtractorFUN = utilities/surfaceTools/meshSurfaceEdgeExtractorFUN
......@@ -75,6 +77,7 @@ triSurfacePartitioner = utilities/triSurfaceTools/triSurfacePartitioner
triSurfaceDetectMaterials = utilities/triSurfaceTools/triSurfaceDetectMaterials
triSurfaceDetectPlanarRegions = utilities/triSurfaceTools/triSurfaceDetectPlanarRegions
triSurfaceDetectFeatureEdges = utilities/triSurfaceTools/triSurfaceDetectFeatureEdges
triSurfaceClassifyEdges = utilities/triSurfaceTools/triSurfaceClassifyEdges
triSurfacePatchManipulator = utilities/triSurfaceTools/triSurfacePatchManipulator
polyMeshGen = utilities/meshes/polyMeshGen
......@@ -287,6 +290,8 @@ $(meshSurfaceMapper)/meshSurfaceMapperMapVertices.C
$(meshSurfaceMapper)/meshSurfaceMapperCornersAndEdges.C
$(meshSurfaceMapper)/meshSurfaceMapperPremapVertices.C
$(edgeExtractionFunctions)/edgeExtractionFunctions.C
$(meshSurfaceEdgeExtractor)/meshSurfaceEdgeExtractor.C
$(meshSurfaceEdgeExtractor)/meshSurfaceEdgeCreateEdgeVertices.C
$(meshSurfaceEdgeExtractor)/meshSurfaceEdgeCreateBoundaryFaces.C
......@@ -414,6 +419,9 @@ $(triSurfaceDetectPlanarRegions)/triSurfaceDetectPlanarRegions.C
$(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdges.C
$(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdgesFunctions.C
$(triSurfaceClassifyEdges)/triSurfaceClassifyEdges.C
$(triSurfaceClassifyEdges)/triSurfaceClassifyEdgesFunctions.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulator.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulatorFunctions.C
......
......@@ -49,8 +49,9 @@ Description
#include "checkNonMappableCellConnections.H"
#include "checkBoundaryFacesSharingTwoEdges.H"
//#define DEBUG
#define DEBUG
//#define DEBUGfpma
//#define DEBUGEnsight
# ifdef DEBUG
#include "writeMeshEnsight.H"
......@@ -81,7 +82,7 @@ void cartesianMeshGenerator::createCartesianMesh()
mesh_.write();
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "cartesianMesh");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "cartesianMesh");
# endif
//::exit(EXIT_FAILURE);
......@@ -123,7 +124,7 @@ void cartesianMeshGenerator::surfacePreparation()
mesh_.write();
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "afterTopoCleaning");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "afterTopoCleaning");
# endif
//::exit(EXIT_FAILURE);
......@@ -142,7 +143,7 @@ void cartesianMeshGenerator::mapMeshToSurface()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "preMappedMesh");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "preMappedMesh");
# endif
mesh_.write();
......@@ -155,7 +156,7 @@ void cartesianMeshGenerator::mapMeshToSurface()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "afterMapping");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "afterMapping");
# endif
mesh_.write();
......@@ -168,7 +169,7 @@ void cartesianMeshGenerator::mapMeshToSurface()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "afterSurfaceSmoothing");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "afterSurfaceSmoothing");
# endif
mesh_.write();
......@@ -183,11 +184,13 @@ void cartesianMeshGenerator::mapEdgesAndCorners()
meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_);
# ifdef DEBUG
//mesh_.write();
meshOptimizer(mesh_).optimizeSurface(*octreePtr_);
mesh_.write();
//meshOptimizer(*octreePtr_, mesh_).preOptimize();
::exit(EXIT_FAILURE);
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "withEdges");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "withEdges");
#endif
//::exit(EXIT_FAILURE);
......@@ -203,7 +206,7 @@ void cartesianMeshGenerator::optimiseMeshSurface()
mesh_.write();
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "optSurfaceWithEdges");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "optSurfaceWithEdges");
#endif
//::exit(EXIT_FAILURE);
......@@ -241,7 +244,7 @@ void cartesianMeshGenerator::generateBoudaryLayers()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_, "meshWithBndLayer");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "meshWithBndLayer");
# endif
mesh_.write();
......@@ -263,7 +266,7 @@ void cartesianMeshGenerator::optimiseFinalMesh()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_,"optimisedMesh");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "optimisedMesh");
#endif
# endif
......@@ -276,7 +279,7 @@ void cartesianMeshGenerator::replaceBoundaries()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_,"renamedPatchesMesh");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "renamedPatchesMesh");
#endif
# endif
......@@ -289,7 +292,7 @@ void cartesianMeshGenerator::renumberMesh()
# ifdef DEBUG
# ifdef DEBUGfpma
writeMeshFPMA(mesh_,"renumberedMesh");
# else
# elif DEBUGEnsight
writeMeshEnsight(mesh_, "renumberedMesh");
#endif
# endif
......
......@@ -139,6 +139,8 @@ public:
// operators
inline void operator=(const meshSubset&);
inline bool operator==(const meshSubset&) const;
inline bool operator!=(const meshSubset&) const;
// IOstream operators
......
......@@ -157,6 +157,25 @@ inline void meshSubset::operator=(const meshSubset& ms)
data_ = ms.data_;
}
inline bool meshSubset::operator==(const meshSubset& ms) const
{
if( ms.name_ != name_ )
return false;
if( ms.type_ != ms.type_ )
return false;
forAllConstIter(HashSet<label>, data_, it)
if( !ms.data_.found(it.key()) )
return false;
return true;
}
inline bool meshSubset::operator!=(const meshSubset& ms) const
{
return !operator==(ms);
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
inline Ostream& operator<<(Ostream& os, const meshSubset& sel)
......
......@@ -114,31 +114,56 @@ void triSurf::writeToFMS(const fileName& fName) const
{
OFstream fStream(fName);
//- write patches
fStream << triSurfFacets::patches_;
fStream << nl;
//- write points
fStream << triSurfPoints::points_;
fStream << nl;
//- write triangles
fStream << triSurfFacets::triangles_;
fStream << nl;
//- write feature edges
fStream << triSurfFeatureEdges::featureEdges_;
fStream << nl;
fStream << triSurfPoints::pointSubsets_;
//- write point subsets
List<meshSubset> subsets;
label i(0);
subsets.setSize(pointSubsets_.size());
forAllConstIter(Map<meshSubset>, pointSubsets_, it)
subsets[i++] = it();
fStream << subsets;
fStream << nl;
fStream << triSurfFacets::facetSubsets_;
//- write subsets of facets
subsets.setSize(triSurfFacets::facetSubsets_.size());
i = 0;
forAllConstIter(Map<meshSubset>, triSurfFacets::facetSubsets_, it)
subsets[i++] = it();
fStream << subsets;
fStream << nl;
fStream << triSurfFeatureEdges::featureEdgeSubsets_;
//- write subets of feature edges
subsets.setSize(triSurfFeatureEdges::featureEdgeSubsets_.size());
i = 0;
forAllConstIter
(
Map<meshSubset>,
triSurfFeatureEdges::featureEdgeSubsets_,
it
)
subsets[i++] = it();
fStream << subsets;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -27,6 +27,9 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "meshSurfaceEngine.H"
#include "meshOctree.H"
#include "triSurf.H"
#include "helperFunctionsPar.H"
#include "DynList.H"
#include "labelPair.H"
......@@ -53,7 +56,45 @@ void distributeBoundaryFaces
labelListPMG& facePatch
)
{
const faceList::subList& bFaces = surfaceEngine.boundaryFaces();
const pointFieldPMG& points = surfaceEngine.points();
//- set the size of the facePatch list
facePatch.setSize(bFaces.size());
//- set size of patchNames, newBoundaryFaces_ and newBoundaryOwners_
const triSurf& surface = octree.surface();
const label nPatches = surface.patches().size();
//- find the region for face by finding the patch nearest
//- to the face centre
# ifdef USE_OMP
# pragma omp parallel for if( bFaces.size() > 100 ) schedule(dynamic, 40)
# endif
forAll(bFaces, bfI)
{
const point c = bFaces[bfI].centre(points);
label fPatch;
point p;
scalar distSq;
octree.findNearestSurfacePoint(p, distSq, fPatch, c);
if( (fPatch > -1) && (fPatch < nPatches) )
{
facePatch[bfI] = fPatch;
}
else
{
FatalErrorIn
(
"void meshSurfaceEdgeExtractorNonTopo::"
"distributeBoundaryFaces()"
) << "Cannot distribute a face " << bFaces[bfI] << " into any "
<< "surface patch!. Exiting.." << exit(FatalError);
}
}
}
void findCornerCandidates
......
......@@ -59,7 +59,7 @@ namespace EdgeExtraction
);
//- find the nearest points on the surface of the volume mesh
//- to the corners on the triangulated surface
//- to the corners on the surface mesh
void findCornerCandidates
(
const meshSurfaceEngine&,
......@@ -67,8 +67,6 @@ namespace EdgeExtraction
LongList<labelPair>&
);
} // End namespace EdgeExtraction
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -49,11 +49,15 @@ meshSurfaceEdgeExtractorNonTopo::meshSurfaceEdgeExtractorNonTopo
:
mesh_(mesh),
meshOctree_(octree)
{
{
distributeBoundaryFaces();
Info << "Writting mesh with boundary faces distributed into patches" << endl;
mesh_.write();
::exit(1);
correctEdgesBetweenPatches featureEdges(mesh);
remapBoundaryPoints();
}
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2005-2007 Franjo Juretic
\\/ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "triSurfaceClassifyEdges.H"
#include "helperFunctions.H"
#include "demandDrivenData.H"
#include "triSurfModifier.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
triSurfaceClassifyEdges::triSurfaceClassifyEdges
(
const meshOctree& octree
)
:
octree_(octree),
edgeTypes_(),
facetOrientation_()
{
checkOrientation();
classifyEdgesTypes();
}
triSurfaceClassifyEdges::~triSurfaceClassifyEdges()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const List<direction>& triSurfaceClassifyEdges::edgeTypes() const
{
return edgeTypes_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2005-2007 Franjo Juretic
\\/ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Class
triSurfaceClassifyEdges
Description
Divides the surface mesh into regions bounded by feature edges
SourceFiles
triSurfaceClassifyEdges.C
triSurfaceClassifyEdgesFunctions.C
\*---------------------------------------------------------------------------*/
#ifndef triSurfaceClassifyEdges_H
#define triSurfaceClassifyEdges_H
#include "triSurf.H"
#include "VRWGraph.H"
#include "boolList.H"
#include "direction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Forward declarations
class meshOctree;
/*---------------------------------------------------------------------------*\
Class triSurfaceClassifyEdges Declaration
\*---------------------------------------------------------------------------*/
class triSurfaceClassifyEdges
{
// Private data
//- reference to meshOctree
const meshOctree& octree_;
//- flags for surface edges
List<direction> edgeTypes_;
//- orientation of facet's normal (0 - unknown, 1- outward, 2- inward)
List<direction> facetOrientation_;
// Private member functions
//- check the orientation of the patches in the triangulated surface
void checkOrientation();
//- classify edges based on the orientation of the surface facets
void classifyEdgesTypes();
//- Disallow default bitwise copy construct
triSurfaceClassifyEdges(const triSurfaceClassifyEdges&);
//- Disallow default bitwise assignment
void operator=(const triSurfaceClassifyEdges&);
public:
// Enumerators
enum edgeType_
{
NONE = 0,
CONVEXEDGE = 1,
CONCAVEEDGE = 2,
FLATSURFACEEDGE = 4,
FEATUREEDGE = 8
};
// Constructors
//- Construct from octree
triSurfaceClassifyEdges(const meshOctree& octree);
// Destructor
~triSurfaceClassifyEdges();
// Member Functions
//- return the edge type according to the above enumerator
inline direction edgeType(const label edgeI) const
{
return edgeTypes_[edgeI];
}
//- return the list of edge classification
const List<direction>& edgeTypes() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2005-2007 Franjo Juretic
\\/ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Description
\*---------------------------------------------------------------------------*/
#include "triSurfaceClassifyEdges.H"
#include "demandDrivenData.H"
#include "helperFunctions.H"
#include "triSurf.H"
#include "meshOctree.H"
#include "labelPair.H"
#ifdef USE_OMP
#include <omp.h>
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void triSurfaceClassifyEdges::checkOrientation()
{
const triSurf& surf = octree_.surface();
const boundBox& rootBox = octree_.rootBox();
const pointField& points = surf.points();
const VRWGraph& facetEdges = surf.facetEdges();
const VRWGraph& edgeFacets = surf.edgeFacets();
facetOrientation_.setSize(surf.size());
//- sort all surface facets into groups consisting of facets with consistent
//- orientation. Do not cross non-manifold edges
labelListPMG orientationGroup(surf.size(), -1);