Moved contents of src/cfMesh/meshLibrary one level up

This commit is contained in:
Dominik Christ 2015-08-06 11:37:36 +01:00
parent b052860f6f
commit 1dd6f5b45a
873 changed files with 12281 additions and 106708 deletions

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude

View file

@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
EXE_LIBS = \
-lmeshTools \

View file

@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
EXE_LIBS = \
-lmeshTools \

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
EXE_LIBS = \
-lmeshTools \

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude

View file

@ -3,7 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/mesh/cfMesh/meshLibrary/lnInclude
-I$(LIB_SRC)/mesh/cfMesh/lnInclude
EXE_LIBS = \
-lmeshTools \

View file

@ -1,9 +1,22 @@
meshSurfaceEngine = utilities/surfaceTools/meshSurfaceEngine
meshSurfacePartitioner = utilities/surfaceTools/meshSurfacePartitioner
boundaryLayers = utilities/boundaryLayers
bndLayers = utilities/boundaryLayers
boundaryLayers = $(bndLayers)/boundaryLayers
detectBoundaryLayers = $(bndLayers)/detectBoundaryLayers
extrudeLayer = $(bndLayers)/extrudeLayer
refineBoundaryLayers = $(bndLayers)/refineBoundaryLayers
triangulateNonPlanarBaseFaces = $(bndLayers)/triangulateNonPlanarBaseFaces
checkMeshDict = utilities/checkMeshDict
anisotropicMeshing = utilities/anisotropicMeshing
coordinateModification = $(anisotropicMeshing)/coordinateModification
edgeMeshGeometryModification = $(anisotropicMeshing)/edgeMeshGeometryModification
surfaceMeshGeometryModification = $(anisotropicMeshing)/surfaceMeshGeometryModification
polyMeshGenGeometryModification = $(anisotropicMeshing)/polyMeshGenGeometryModification
meshSurfaceCheckInvertedVertices = utilities/surfaceTools/meshSurfaceCheckInvertedVertices
meshSurfaceCheckEdgeTypes = utilities/surfaceTools/meshSurfaceCheckEdgeTypes
meshSurfaceCutter = utilities/surfaceTools/meshSurfaceCutter
@ -14,6 +27,13 @@ edgeExtractor = $(edgeExtraction)/edgeExtractor
meshSurfaceEdgeExtractor = utilities/surfaceTools/meshSurfaceEdgeExtractor
meshSurfaceEdgeExtractorNonTopo = utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo
meshSurfaceEdgeExtractor2D = utilities/surfaceTools/meshSurfaceEdgeExtractor2D
meshSurfaceEdgeExtractorFUN = utilities/surfaceTools/meshSurfaceEdgeExtractorFUN
createFundamentalSheetsBase = utilities/surfaceTools/createFundamentalSheets
createFundamentalSheets = $(createFundamentalSheetsBase)/createFundamentalSheets
createFundamentalSheetsFJ = $(createFundamentalSheetsBase)/createFundamentalSheetsFJ
createFundamentalSheetsJFS = $(createFundamentalSheetsBase)/createFundamentalSheetsJFS
correctEdgesBetweenPatches = utilities/surfaceTools/correctEdgesBetweenPatches
decomposeCellsNearConcaveEdges = utilities/surfaceTools/decomposeCellsNearConcaveEdges
@ -24,9 +44,9 @@ findCellsIntersectingSurface = $(intersectionTools)/findCellsIntersectingSurface
meshOptimizer = utilities/smoothers/geometry/meshOptimizer
tetMeshOptimisation = $(meshOptimizer)/tetMeshOptimisation
boundaryLayerOptimisation = $(meshOptimizer)/boundaryLayerOptimisation
symmetryPlaneOptimisation = $(meshOptimizer)/symmetryPlaneOptimisation
simplexSmoother = $(tetMeshOptimisation)/advancedSmoothers/simplexSmoother
knuppMetric = $(tetMeshOptimisation)/advancedSmoothers/knuppMetric
meshUntangler = $(tetMeshOptimisation)/advancedSmoothers/meshUntangler
@ -67,6 +87,7 @@ checkNonMappableCellConnections = $(topology)/checkNonMappableCellConnections
triSurfaceTools = utilities/triSurfaceTools
triSurface2DCheck = $(triSurfaceTools)/triSurface2DCheck
triSurfaceChecks = $(triSurfaceTools)/triSurfaceChecks
triSurfaceCleanupDuplicates = $(triSurfaceTools)/triSurfaceCleanupDuplicates
triSurfaceCleanupDuplicateTriangles = $(triSurfaceTools)/triSurfaceCleanupDuplicateTriangles
triSurfaceCopyParts = $(triSurfaceTools)/triSurfaceCopyParts
@ -116,6 +137,11 @@ tetMeshExtractor = tetMesh/tetMeshExtractor
tetMeshExtractorOctree = tetMesh/tetMeshExtractorOctree
tetMeshGenerator = tetMesh/tetMeshGenerator
voronoiMeshExtractor = voronoiMesh/voronoiMeshExtractor
voronoiMeshGenerator = voronoiMesh/voronoiMeshGenerator
workflowControls = utilities/workflowControls
$(checkMeshDict)/checkMeshDict.C
$(lists)/pointFieldPMG.C
@ -136,6 +162,17 @@ $(polyMeshGen)/polyMeshGenCells.C
$(polyMeshGen2DEngine)/polyMeshGen2DEngine.C
$(coordinateModification)/coordinateModification.C
$(coordinateModification)/newCoordinateModification.C
$(coordinateModification)/planeScaling.C
$(coordinateModification)/boxScaling.C
$(edgeMeshGeometryModification)/edgeMeshGeometryModification.C
$(surfaceMeshGeometryModification)/surfaceMeshGeometryModification.C
$(polyMeshGenGeometryModification)/polyMeshGenGeometryModification.C
$(coordinateModification)/coordinateModifier.C
$(boundaryPatch)/boundaryPatchBase.C
$(boundaryPatch)/boundaryPatch.C
$(boundaryPatch)/processorBoundaryPatch.C
@ -231,11 +268,15 @@ $(boundaryLayers)/boundaryLayersFacesAndCells.C
$(boundaryLayers)/boundaryLayerCells.C
$(boundaryLayers)/boundaryLayersCheckTopologyOfBndFaces.C
$(boundaryLayers)/boundaryLayersWrapperLayer.C
$(boundaryLayers)/extrudeLayer.C
$(boundaryLayers)/refineBoundaryLayers.C
$(boundaryLayers)/refineBoundaryLayersFunctions.C
$(boundaryLayers)/refineBoundaryLayersFaces.C
$(boundaryLayers)/refineBoundaryLayersCells.C
$(extrudeLayer)/extrudeLayer.C
$(detectBoundaryLayers)/detectBoundaryLayers.C
$(detectBoundaryLayers)/detectBoundaryLayersFunctions.C
$(refineBoundaryLayers)/refineBoundaryLayers.C
$(refineBoundaryLayers)/refineBoundaryLayersFunctions.C
$(refineBoundaryLayers)/refineBoundaryLayersFaces.C
$(refineBoundaryLayers)/refineBoundaryLayersCells.C
$(triangulateNonPlanarBaseFaces)/triangulateNonPlanarBaseFaces.C
$(triangulateNonPlanarBaseFaces)/triangulateNonPlanarBaseFacesFunctions.C
$(meshSurfaceEngine)/meshSurfaceEngine.C
$(meshSurfaceEngine)/meshSurfaceEngineCalculateBoundaryNodesAndFaces.C
@ -267,6 +308,13 @@ $(meshSurfaceEdgeExtractorNonTopo)/meshSurfaceEdgeExtractorNonTopoDistributeFace
$(meshSurfaceEdgeExtractor2D)/meshSurfaceEdgeExtractor2D.C
$(meshSurfaceEdgeExtractor2D)/meshSurfaceEdgeExtractor2DDistributeFaces.C
$(meshSurfaceEdgeExtractorFUN)/meshSurfaceEdgeExtractorFUN.C
$(meshSurfaceEdgeExtractorFUN)/meshSurfaceEdgeExtractorFUNDistributeFaces.C
$(createFundamentalSheets)/createFundamentalSheets.C
$(createFundamentalSheetsFJ)/createFundamentalSheetsFJ.C
$(createFundamentalSheetsJFS)/createFundamentalSheetsJFS.C
$(correctEdgesBetweenPatches)/correctEdgesBetweenPatches.C
$(correctEdgesBetweenPatches)/correctEdgesBetweenPatchesDistributeFaces.C
@ -283,6 +331,11 @@ $(tetMeshOptimisation)/tetMeshOptimisationParallel.C
$(symmetryPlaneOptimisation)/symmetryPlaneOptimisation.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisation.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisationFunctions.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisationNormals.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisationThickness.C
$(simplexSmoother)/simplexSmoother.C
$(knuppMetric)/knuppMetric.C
@ -353,9 +406,12 @@ $(objectRefinement)/sphereRefinement.C
$(objectRefinement)/lineRefinement.C
$(objectRefinement)/coneRefinement.C
$(objectRefinement)/boxRefinement.C
$(objectRefinement)/hollowConeRefinement.C
$(triSurface2DCheck)/triSurface2DCheck.C
$(triSurfaceChecks)/triSurfaceChecks.C
$(triSurfaceCleanupDuplicates)/triSurfaceCleanupDuplicates.C
$(triSurfaceCleanupDuplicates)/triSurfaceCleanupDuplicatesFunctions.C
@ -401,7 +457,15 @@ $(tetMeshExtractorOctree)/tetMeshExtractorOctree.C
$(tetMeshGenerator)/tetMeshGenerator.C
$(voronoiMeshExtractor)/voronoiMeshExtractor.C
$(voronoiMeshExtractor)/voronoiMeshExtractorAddressing.C
$(voronoiMeshExtractor)/voronoiMeshExtractorCreateMesh.C
$(voronoiMeshGenerator)/voronoiMeshGenerator.C
$(writeAsFPMA)/writeMeshFPMA.C
$(writeAsFPMA)/fpmaMesh.C
LIB = $(FOAM_LIBBIN)/libcfMesh
$(workflowControls)/workflowControls.C
LIB = $(FOAM_LIBBIN)/libmeshLibrary

View file

@ -11,4 +11,5 @@
EXE_INC = \
$(OMP_FLAGS) \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
@ -49,6 +49,8 @@ Description
#include "checkNonMappableCellConnections.H"
#include "checkBoundaryFacesSharingTwoEdges.H"
#include "triSurfaceMetaData.H"
#include "polyMeshGenGeometryModification.H"
#include "surfaceMeshGeometryModification.H"
//#define DEBUG
@ -71,11 +73,6 @@ void cartesian2DMeshGenerator::createCartesianMesh()
}
cme.createMesh();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_FAILURE);
# endif
}
void cartesian2DMeshGenerator::surfacePreparation()
@ -101,11 +98,6 @@ void cartesian2DMeshGenerator::surfacePreparation()
} while( changed );
checkBoundaryFacesSharingTwoEdges(mesh_).improveTopology();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_FAILURE);
# endif
}
void cartesian2DMeshGenerator::mapMeshToSurface()
@ -120,30 +112,20 @@ void cartesian2DMeshGenerator::mapMeshToSurface()
mapper.preMapVertices();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_FAILURE);
# endif
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
deleteDemandDrivenData(msePtr);
}
void cartesian2DMeshGenerator::extractPatches()
{
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_).distributeBoundaryFaces();
}
void cartesian2DMeshGenerator::mapEdgesAndCorners()
{
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_);
# ifdef DEBUG
mesh_.write();
//::exit(0);
# endif
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_).remapBoundaryPoints();
}
void cartesian2DMeshGenerator::optimiseMeshSurface()
@ -152,11 +134,6 @@ void cartesian2DMeshGenerator::optimiseMeshSurface()
meshSurfaceOptimizer optimizer(mse, *octreePtr_);
optimizer.optimizeSurface2D();
optimizer.untangleSurface2D();
# ifdef DEBUG
mesh_.write();
//::exit(0);
# endif
}
void cartesian2DMeshGenerator::generateBoundaryLayers()
@ -167,10 +144,27 @@ void cartesian2DMeshGenerator::generateBoundaryLayers()
bl.addLayerForAllPatches();
# ifdef DEBUG
mesh_.write();
//::exit(0);
# endif
if( modSurfacePtr_ )
{
polyMeshGenGeometryModification meshMod(mesh_, meshDict_);
//- revert the mesh into the original space
meshMod.revertGeometryModification();
//- delete modified surface mesh
deleteDemandDrivenData(modSurfacePtr_);
//- delete the octree
deleteDemandDrivenData(octreePtr_);
//- contruct a new octree from the input surface
octreePtr_ = new meshOctree(*surfacePtr_, true);
meshOctreeCreator(*octreePtr_).createOctreeWithRefinedBoundary(20);
mapEdgesAndCorners();
optimiseMeshSurface();
}
}
void cartesian2DMeshGenerator::refBoundaryLayers()
@ -195,46 +189,68 @@ void cartesian2DMeshGenerator::refBoundaryLayers()
void cartesian2DMeshGenerator::replaceBoundaries()
{
renameBoundaryPatches rbp(mesh_, meshDict_);
# ifdef DEBUG
mesh_.write();
//::exit(0);
# endif
}
void cartesian2DMeshGenerator::renumberMesh()
{
polyMeshGenModifier(mesh_).renumberMesh();
# ifdef DEBUG
mesh_.write();
//::exit(0);
# endif
}
void cartesian2DMeshGenerator::generateMesh()
{
try
{
createCartesianMesh();
if( controller_.runCurrentStep("templateGeneration") )
{
createCartesianMesh();
}
surfacePreparation();
if( controller_.runCurrentStep("surfaceTopology") )
{
surfacePreparation();
}
mapMeshToSurface();
if( controller_.runCurrentStep("surfaceProjection") )
{
mapMeshToSurface();
}
mapEdgesAndCorners();
if( controller_.runCurrentStep("patchAssignment") )
{
extractPatches();
}
optimiseMeshSurface();
if( controller_.runCurrentStep("edgeExtraction") )
{
mapEdgesAndCorners();
generateBoundaryLayers();
optimiseMeshSurface();
}
optimiseMeshSurface();
if( controller_.runCurrentStep("boundaryLayerGeneration") )
{
generateBoundaryLayers();
}
refBoundaryLayers();
if( controller_.runCurrentStep("meshOptimisation") )
{
optimiseMeshSurface();
}
if( controller_.runCurrentStep("boundaryLayerRefinement") )
{
refBoundaryLayers();
}
renumberMesh();
replaceBoundaries();
controller_.workflowCompleted();
}
catch(const std::string& message)
{
Info << message << endl;
}
catch(...)
{
@ -247,11 +263,11 @@ void cartesian2DMeshGenerator::generateMesh()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from objectRegistry
cartesian2DMeshGenerator::cartesian2DMeshGenerator(const Time& time)
:
db_(time),
surfacePtr_(NULL),
modSurfacePtr_(NULL),
meshDict_
(
IOobject
@ -264,7 +280,8 @@ cartesian2DMeshGenerator::cartesian2DMeshGenerator(const Time& time)
)
),
octreePtr_(NULL),
mesh_(time)
mesh_(time),
controller_(mesh_)
{
if( true )
{
@ -283,8 +300,8 @@ cartesian2DMeshGenerator::cartesian2DMeshGenerator(const Time& time)
triSurfaceMetaData sMetaData(*surfacePtr_);
const dictionary& surfMetaDict = sMetaData.metaData();
mesh_.metaData().add("surfaceFile", surfaceFile);
mesh_.metaData().add("surfaceMeta", surfMetaDict);
mesh_.metaData().add("surfaceFile", surfaceFile, true);
mesh_.metaData().add("surfaceMeta", surfMetaDict, true);
triSurface2DCheck surfCheck(*surfacePtr_);
if( !surfCheck.is2DSurface() )
@ -314,7 +331,18 @@ cartesian2DMeshGenerator::cartesian2DMeshGenerator(const Time& time)
surfacePtr_ = surfaceWithPatches;
}
octreePtr_ = new meshOctree(*surfacePtr_, true);
if( meshDict_.found("anisotropicSources") )
{
surfaceMeshGeometryModification surfMod(*surfacePtr_, meshDict_);
modSurfacePtr_ = surfMod.modifyGeometry();
octreePtr_ = new meshOctree(*modSurfacePtr_, true);
}
else
{
octreePtr_ = new meshOctree(*surfacePtr_, true);
}
meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes();
@ -326,6 +354,7 @@ cartesian2DMeshGenerator::cartesian2DMeshGenerator(const Time& time)
cartesian2DMeshGenerator::~cartesian2DMeshGenerator()
{
deleteDemandDrivenData(surfacePtr_);
deleteDemandDrivenData(modSurfacePtr_);
deleteDemandDrivenData(octreePtr_);
}

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cartesian2DMeshGenerator
@ -37,6 +37,7 @@ SourceFiles
#include "polyMeshGen.H"
#include "IOdictionary.H"
#include "workflowControls.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,6 +62,9 @@ class cartesian2DMeshGenerator
//- pointer to the surface
const triSurf* surfacePtr_;
//- pointer to the modified surface mesh
const triSurf* modSurfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
@ -70,6 +74,9 @@ class cartesian2DMeshGenerator
//- mesh
polyMeshGen mesh_;
//- workflow controller
workflowControls controller_;
// Private member functions
//- create cartesian mesh
void createCartesianMesh();
@ -80,6 +87,9 @@ class cartesian2DMeshGenerator
//- map mesh to the surface and untangle surface
void mapMeshToSurface();
//- capture edges and corners
void extractPatches();
//- capture edges and corners
void mapEdgesAndCorners();

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
@ -76,24 +76,24 @@ void cartesianMeshExtractor::decomposeSplitHexes()
void cartesianMeshExtractor::createMesh()
{
Info << "Extracting polyMesh" << endl;
//- create points and pointLeaves addressing
createPointsAndAddressing();
//- create the mesh
createPolyMesh();
//- decompose split-hex cells into tetrahedra and pyramids
decomposeSplitHexesIntoTetsAndPyramids();
//- remove unused vertices
polyMeshGenModifier(mesh_).removeUnusedVertices();
Info << "Mesh has :" << nl
<< mesh_.points().size() << " vertices " << nl
<< mesh_.faces().size() << " faces" << nl
<< mesh_.cells().size() << " cells" << endl;
if( Pstream::parRun() )
{
label nCells = mesh_.cells().size();
@ -112,7 +112,7 @@ void cartesianMeshExtractor::createMesh()
<< " This can be reolved by reducing the maxCellSize by a fraction."
<< "i.e. 2.49999 instead of 2.5." << exit(FatalError);
}
Info << "Finished extracting polyMesh" << endl;
}

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cartesianMeshExtractor
@ -42,7 +42,7 @@ SourceFiles
namespace Foam
{
class IOdictionary;
/*---------------------------------------------------------------------------*\
@ -54,13 +54,13 @@ class cartesianMeshExtractor
// Private data
//- reference to the octree addressing
meshOctreeAddressing octreeCheck_;
//- reference to the mesh
polyMeshGen& mesh_;
//- decompose split hex cells
bool decomposeSplitHexes_;
//- cell label for a given leaf
labelList* leafCellLabelPtr_;
@ -73,7 +73,7 @@ class cartesianMeshExtractor
//- create mesh data
void createPolyMesh();
//- decompose split hexes into pyramids and tets
void decomposeSplitHexesIntoTetsAndPyramids();
@ -105,7 +105,7 @@ public:
//- decompose split hexes into standard cells
void decomposeSplitHexes();
//- create the mesh with the above options
void createMesh();
};

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
@ -45,39 +45,39 @@ void cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids()
if( !decomposeSplitHexes_ ) return;
Info << "Decomposing split-hex cells" << endl;
const faceListPMG& faces = mesh_.faces();
//- decompose faces which have more than 4 vertices
boolList decompose(faces.size(), false);
label nDecomposed(0);
forAll(faces, faceI)
{
if( faces[faceI].size() > 4 )
{
++nDecomposed;
decompose[faceI] = true;
}
}
reduce(nDecomposed, sumOp<label>());
Info << "Decomposing " << nDecomposed
<< " faces with more than 4 vertices" << endl;
if( nDecomposed != 0 )
{
//- decompose marked faces into triangles
decomposeFaces(mesh_).decomposeMeshFaces(decompose);
}
//- decompose cells with 24 faces
const cellListPMG& cells = mesh_.cells();
decompose.setSize(cells.size());
decompose = false;
hexMatcher hex;
forAll(cells, cellI)
{
@ -87,19 +87,19 @@ void cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids()
decompose[cellI] = true;
}
}
reduce(nDecomposed, sumOp<label>());
Info << "Decomposing " << nDecomposed
<< " cells into tetrahedra and pyramids" << endl;
if( nDecomposed )
{
//- decompose marked cells into tets and pyramids
decomposeCells dc(mesh_);
dc.decomposeMesh(decompose);
}
Info << "Finished decomposing split-hex cells" << endl;
}

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
@ -34,6 +34,7 @@ Description
#include "cartesianMeshExtractor.H"
#include "meshSurfaceEngine.H"
#include "meshSurfaceMapper.H"
#include "edgeExtractor.H"
#include "meshSurfaceEdgeExtractorNonTopo.H"
#include "meshOptimizer.H"
#include "meshSurfaceOptimizer.H"
@ -47,6 +48,8 @@ Description
#include "checkNonMappableCellConnections.H"
#include "checkBoundaryFacesSharingTwoEdges.H"
#include "triSurfaceMetaData.H"
#include "polyMeshGenGeometryModification.H"
#include "surfaceMeshGeometryModification.H"
//#define DEBUG
@ -69,11 +72,6 @@ void cartesianMeshGenerator::createCartesianMesh()
}
cme.createMesh();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::surfacePreparation()
@ -99,67 +97,43 @@ void cartesianMeshGenerator::surfacePreparation()
} while( changed );
checkBoundaryFacesSharingTwoEdges(mesh_).improveTopology();
# ifdef DEBUG
mesh_.write();
returnReduce(1, sumOp<label>());
::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::mapMeshToSurface()
{
//- calculate mesh surface
meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_);
meshSurfaceEngine mse(mesh_);
//- pre-map mesh surface
meshSurfaceMapper mapper(*msePtr, *octreePtr_);
meshSurfaceMapper mapper(mse, *octreePtr_);
mapper.preMapVertices();
# ifdef DEBUG
mesh_.write();
returnReduce(1, sumOp<label>());
//::exit(EXIT_SUCCESS);
# endif
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
//- untangle surface faces
meshSurfaceOptimizer(*msePtr, *octreePtr_).untangleSurface();
meshSurfaceOptimizer(mse, *octreePtr_).untangleSurface();
}
# ifdef DEBUG
mesh_.write();
::exit(EXIT_SUCCESS);
# endif
void cartesianMeshGenerator::extractPatches()
{
edgeExtractor extractor(mesh_, *octreePtr_);
deleteDemandDrivenData(msePtr);
Info << "Extracting edges" << endl;
extractor.extractEdges();
extractor.updateMeshPatches();
}
void cartesianMeshGenerator::mapEdgesAndCorners()
{
meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_);
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::optimiseMeshSurface()
{
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::generateBoundaryLayers()
@ -167,11 +141,6 @@ void cartesianMeshGenerator::generateBoundaryLayers()
//- add boundary layers
boundaryLayers bl(mesh_);
bl.addLayerForAllPatches();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::refBoundaryLayers()
@ -184,8 +153,12 @@ void cartesianMeshGenerator::refBoundaryLayers()
refLayers.refineLayers();
meshOptimizer optimizer(mesh_);
optimizer.untangleMeshFV();
labelLongList pointsInLayer;
refLayers.pointsInBndLayer(pointsInLayer);
meshOptimizer mOpt(mesh_);
mOpt.lockPoints(pointsInLayer);
mOpt.untangleBoundaryLayer();
}
}
@ -216,59 +189,119 @@ void cartesianMeshGenerator::optimiseFinalMesh()
meshOptimizer optimizer(mesh_);
if( enforceConstraints )
optimizer.enforceConstraints();
optimizer.optimizeMeshFV();
optimizer.optimizeLowQualityFaces();
optimizer.optimizeBoundaryLayer(modSurfacePtr_==NULL);
optimizer.untangleMeshFV();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
mesh_.clearAddressingData();
if( modSurfacePtr_ )
{
polyMeshGenGeometryModification meshMod(mesh_, meshDict_);
//- revert the mesh into the original space
meshMod.revertGeometryModification();
//- delete modified surface mesh
deleteDemandDrivenData(modSurfacePtr_);
}
}
void cartesianMeshGenerator::projectSurfaceAfterBackScaling()
{
if( !meshDict_.found("anisotropicSources") )
return;
deleteDemandDrivenData(octreePtr_);
octreePtr_ = new meshOctree(*surfacePtr_);
meshOctreeCreator
(
*octreePtr_,
meshDict_
).createOctreeWithRefinedBoundary(20, 30);
//- calculate mesh surface
meshSurfaceEngine mse(mesh_);
//- pre-map mesh surface
meshSurfaceMapper mapper(mse, *octreePtr_);
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
optimiseFinalMesh();
}
void cartesianMeshGenerator::replaceBoundaries()
{
renameBoundaryPatches rbp(mesh_, meshDict_);
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::renumberMesh()
{
polyMeshGenModifier(mesh_).renumberMesh();
# ifdef DEBUG
mesh_.write();
//::exit(EXIT_SUCCESS);
# endif
}
void cartesianMeshGenerator::generateMesh()
{
try
{
createCartesianMesh();
if( controller_.runCurrentStep("templateGeneration") )
{
createCartesianMesh();
}
surfacePreparation();
if( controller_.runCurrentStep("surfaceTopology") )
{
surfacePreparation();
}
mapMeshToSurface();
if( controller_.runCurrentStep("surfaceProjection") )
{
mapMeshToSurface();
}
mapEdgesAndCorners();
if( controller_.runCurrentStep("patchAssignment") )
{
extractPatches();
}
optimiseMeshSurface();
if( controller_.runCurrentStep("edgeExtraction") )
{
mapEdgesAndCorners();
generateBoundaryLayers();
optimiseMeshSurface();
}
optimiseFinalMesh();
if( controller_.runCurrentStep("boundaryLayerGeneration") )
{
generateBoundaryLayers();
}
refBoundaryLayers();
if( controller_.runCurrentStep("meshOptimisation") )
{
optimiseFinalMesh();
projectSurfaceAfterBackScaling();
}
if( controller_.runCurrentStep("boundaryLayerRefinement") )
{
refBoundaryLayers();
}
renumberMesh();
replaceBoundaries();
controller_.workflowCompleted();
}
catch(const std::string& message)
{
Info << message << endl;
}
catch(...)
{
@ -281,11 +314,11 @@ void cartesianMeshGenerator::generateMesh()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from objectRegistry
cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
:
db_(time),
surfacePtr_(NULL),
modSurfacePtr_(NULL),
meshDict_
(
IOobject
@ -298,7 +331,8 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
)
),
octreePtr_(NULL),
mesh_(time)
mesh_(time),
controller_(mesh_)
{
if( true )
{
@ -317,8 +351,8 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
triSurfaceMetaData sMetaData(*surfacePtr_);
const dictionary& surfMetaDict = sMetaData.metaData();
mesh_.metaData().add("surfaceFile", surfaceFile);
mesh_.metaData().add("surfaceMeta", surfMetaDict);
mesh_.metaData().add("surfaceFile", surfaceFile, true);
mesh_.metaData().add("surfaceMeta", surfMetaDict, true);
}
if( surfacePtr_->featureEdges().size() != 0 )
@ -335,7 +369,18 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
surfacePtr_ = surfaceWithPatches;
}
octreePtr_ = new meshOctree(*surfacePtr_);
if( meshDict_.found("anisotropicSources") )
{
surfaceMeshGeometryModification surfMod(*surfacePtr_, meshDict_);
modSurfacePtr_ = surfMod.modifyGeometry();
octreePtr_ = new meshOctree(*modSurfacePtr_);
}
else
{
octreePtr_ = new meshOctree(*surfacePtr_);
}
meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes();
@ -347,6 +392,7 @@ cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
cartesianMeshGenerator::~cartesianMeshGenerator()
{
deleteDemandDrivenData(surfacePtr_);
deleteDemandDrivenData(modSurfacePtr_);
deleteDemandDrivenData(octreePtr_);
}

View file

@ -1,25 +1,25 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
This file is part of cfMesh.
foam-extend is free software: you can redistribute it and/or modify it
cfMesh 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
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
foam-extend 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.
cfMesh 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cartesianMeshGenerator
@ -37,6 +37,7 @@ SourceFiles
#include "polyMeshGen.H"
#include "IOdictionary.H"
#include "workflowControls.H"
//#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,6 +63,9 @@ class cartesianMeshGenerator
//- pointer to the surface
const triSurf* surfacePtr_;
//- pointer to the modified surface
const triSurf* modSurfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
@ -71,6 +75,9 @@ class cartesianMeshGenerator
//- mesh
polyMeshGen mesh_;
//- workflow controller
workflowControls controller_;
// Private member functions
//- create cartesian mesh
void createCartesianMesh();
@ -82,6 +89,9 @@ class cartesianMeshGenerator
void mapMeshToSurface();
//- capture edges and corners
void extractPatches();
//- map points at feature edges and corners
void mapEdgesAndCorners();
//- optimise surface mesh
@ -96,6 +106,9 @@ class cartesianMeshGenerator
//- mesh optimisation
void optimiseFinalMesh();
//- re-project points back on the surface mesh after back-scaling
void projectSurfaceAfterBackScaling();
//- replace boundaries
void replaceBoundaries();

View file

@ -1,471 +0,0 @@
meshSurfaceEngine = utilities/surfaceTools/meshSurfaceEngine
meshSurfacePartitioner = utilities/surfaceTools/meshSurfacePartitioner
bndLayers = utilities/boundaryLayers
boundaryLayers = $(bndLayers)/boundaryLayers
detectBoundaryLayers = $(bndLayers)/detectBoundaryLayers
extrudeLayer = $(bndLayers)/extrudeLayer
refineBoundaryLayers = $(bndLayers)/refineBoundaryLayers
triangulateNonPlanarBaseFaces = $(bndLayers)/triangulateNonPlanarBaseFaces
checkMeshDict = utilities/checkMeshDict
anisotropicMeshing = utilities/anisotropicMeshing
coordinateModification = $(anisotropicMeshing)/coordinateModification
edgeMeshGeometryModification = $(anisotropicMeshing)/edgeMeshGeometryModification
surfaceMeshGeometryModification = $(anisotropicMeshing)/surfaceMeshGeometryModification
polyMeshGenGeometryModification = $(anisotropicMeshing)/polyMeshGenGeometryModification
meshSurfaceCheckInvertedVertices = utilities/surfaceTools/meshSurfaceCheckInvertedVertices
meshSurfaceCheckEdgeTypes = utilities/surfaceTools/meshSurfaceCheckEdgeTypes
meshSurfaceCutter = utilities/surfaceTools/meshSurfaceCutter
meshSurfaceMapper = utilities/surfaceTools/meshSurfaceMapper
meshSurfaceMapper2D = utilities/surfaceTools/meshSurfaceMapper2D
edgeExtraction = utilities/surfaceTools/edgeExtraction
edgeExtractor = $(edgeExtraction)/edgeExtractor
meshSurfaceEdgeExtractor = utilities/surfaceTools/meshSurfaceEdgeExtractor
meshSurfaceEdgeExtractorNonTopo = utilities/surfaceTools/meshSurfaceEdgeExtractorNonTopo
meshSurfaceEdgeExtractor2D = utilities/surfaceTools/meshSurfaceEdgeExtractor2D
meshSurfaceEdgeExtractorFUN = utilities/surfaceTools/meshSurfaceEdgeExtractorFUN
createFundamentalSheetsBase = utilities/surfaceTools/createFundamentalSheets
createFundamentalSheets = $(createFundamentalSheetsBase)/createFundamentalSheets
createFundamentalSheetsFJ = $(createFundamentalSheetsBase)/createFundamentalSheetsFJ
createFundamentalSheetsJFS = $(createFundamentalSheetsBase)/createFundamentalSheetsJFS
correctEdgesBetweenPatches = utilities/surfaceTools/correctEdgesBetweenPatches
decomposeCellsNearConcaveEdges = utilities/surfaceTools/decomposeCellsNearConcaveEdges
renameBoundaryPatches = utilities/surfaceTools/renameBoundaryPatches
intersectionTools = utilities/intersectionTools
findCellsIntersectingSurface = $(intersectionTools)/findCellsIntersectingSurface
meshOptimizer = utilities/smoothers/geometry/meshOptimizer
tetMeshOptimisation = $(meshOptimizer)/tetMeshOptimisation
boundaryLayerOptimisation = $(meshOptimizer)/boundaryLayerOptimisation
symmetryPlaneOptimisation = $(meshOptimizer)/symmetryPlaneOptimisation
simplexSmoother = $(tetMeshOptimisation)/advancedSmoothers/simplexSmoother
knuppMetric = $(tetMeshOptimisation)/advancedSmoothers/knuppMetric
meshUntangler = $(tetMeshOptimisation)/advancedSmoothers/meshUntangler
quadricMetric = $(tetMeshOptimisation)/advancedSmoothers/quadricMetric
volumeOptimizer = $(tetMeshOptimisation)/advancedSmoothers/volumeOptimizer
meshSurfaceOptimizer = utilities/smoothers/geometry/meshSurfaceOptimizer
surfaceOptimizer = $(meshSurfaceOptimizer)/advancedSurfaceSmoothers/surfaceOptimizer
surfaceMorpherCells = utilities/surfaceTools/surfaceMorpherCells
utilitiesOctrees = utilities/octrees
meshOctree = utilities/octrees/meshOctree
meshOctreeCube = utilities/octrees/meshOctree/meshOctreeCube
meshOctreeInsideOutside = utilities/octrees/meshOctree/meshOctreeInsideOutside
meshOctreeCreator = utilities/octrees/meshOctree/meshOctreeCreator
meshOctreeAddressing = utilities/octrees/meshOctree/meshOctreeAddressing
meshOctreeModifier = utilities/octrees/meshOctree/meshOctreeModifier
meshOctreeAutoRef = utilities/octrees/meshOctree/meshOctreeAutomaticRefinement
patchRefinement = utilities/octrees/meshOctree/refinementControls/patchRefinement
objectRefinement = utilities/octrees/meshOctree/refinementControls/objectRefinement
helperFunctions = utilities/helperFunctions
createFacesFromChain = utilities/helperClasses/createFacesFromChain
sortEdgesIntoChains = utilities/helperClasses/sortEdgesIntoChains
trianglePlaneIntersections = utilities/helperClasses/trianglePlaneIntersections
tetCreatorOctree = utilities/tetrahedra/tetCreatorOctree
faceDecomposition = utilities/faceDecomposition
decomposeCells = utilities/decomposeCells
topology = utilities/smoothers/topology
topologicalCleaner = $(topology)/topologicalCleaner
checkBoundaryFacesSharingTwoEdges = $(topology)/checkBoundaryFacesSharingTwoEdges
checkCellConnectionsOverFaces = $(topology)/checkCellConnectionsOverFaces
checkIrregularSurfaceConnections = $(topology)/checkIrregularSurfaceConnections
checkNonMappableCellConnections = $(topology)/checkNonMappableCellConnections
triSurfaceTools = utilities/triSurfaceTools
triSurface2DCheck = $(triSurfaceTools)/triSurface2DCheck
triSurfaceChecks = $(triSurfaceTools)/triSurfaceChecks
triSurfaceCleanupDuplicates = $(triSurfaceTools)/triSurfaceCleanupDuplicates
triSurfaceCleanupDuplicateTriangles = $(triSurfaceTools)/triSurfaceCleanupDuplicateTriangles
triSurfaceCopyParts = $(triSurfaceTools)/triSurfaceCopyParts
triSurfaceCurvatureEstimator = $(triSurfaceTools)/triSurfaceCurvatureEstimator
triSurfacePartitioner = $(triSurfaceTools)/triSurfacePartitioner
triSurfaceDetectFeatureEdges = $(triSurfaceTools)/triSurfaceDetectFeatureEdges
triSurfaceClassifyEdges = $(triSurfaceTools)/triSurfaceClassifyEdges
triSurfaceImportSurfaceAsSubset = $(triSurfaceTools)/triSurfaceImportSurfaceAsSubset
triSurfacePatchManipulator = $(triSurfaceTools)/triSurfacePatchManipulator
triSurfaceRemoveFacets = $(triSurfaceTools)/triSurfaceRemoveFacets
triSurfaceExtrude2DEdges = $(triSurfaceTools)/triSurfaceExtrude2DEdges
triSurfaceMetaData = $(triSurfaceTools)/triSurfaceMetaData
polyMeshGen = utilities/meshes/polyMeshGen
boundaryPatch = utilities/meshes/polyMeshGen/boundaryPatch
polyMeshGen2DEngine = utilities/meshes/polyMeshGen2DEngine
polyMeshGenModifier = utilities/meshes/polyMeshGenModifier
polyMeshGenAddressing = utilities/meshes/polyMeshGenAddressing
polyMeshGenChecks = utilities/meshes/polyMeshGenChecks
partTetMesh = utilities/meshes/partTetMesh
partTriMesh = utilities/meshes/partTriMesh
primitiveMesh = utilities/meshes/primitiveMesh
triSurf = utilities/meshes/triSurf
cell = utilities/meshes/primitives/cell
edge = utilities/meshes/primitives/edge
face = utilities/meshes/primitives/face
containers = utilities/containers
VRWGraph = $(containers)/VRWGraph
VRWGraphList = $(containers)/VRWGraphList
graphs = $(containers)/Graphs
lists = $(containers)/Lists
meshZipper = utilities/meshZipper
writeAsFPMA = utilities/dataConversion/foamToFPMA
polyMeshExtractor = pMeshLibrary/polyMeshExtractor
polyMeshGenerator = pMeshLibrary/polyMeshGenerator
cartesianMeshExtractor = cartesianMesh/cartesianMeshExtractor
cartesianMeshGenerator = cartesianMesh/cartesianMeshGenerator
cartesian2DMeshGenerator = cartesian2DMesh/cartesian2DMeshGenerator
tetMeshExtractor = tetMesh/tetMeshExtractor
tetMeshExtractorOctree = tetMesh/tetMeshExtractorOctree
tetMeshGenerator = tetMesh/tetMeshGenerator
voronoiMeshExtractor = voronoiMesh/voronoiMeshExtractor
voronoiMeshGenerator = voronoiMesh/voronoiMeshGenerator
workflowControls = utilities/workflowControls
$(checkMeshDict)/checkMeshDict.C
$(lists)/pointFieldPMG.C
$(lists)/faceListPMG.C
$(VRWGraph)/VRWGraph.C
$(VRWGraph)/VRWGraphSMPModifier.C
$(VRWGraphList)/VRWGraphList.C
$(graphs)/cellIOGraph.C
$(graphs)/faceIOGraph.C
$(polyMeshGen)/polyMeshGen.C
$(polyMeshGen)/polyMeshGenPoints.C
$(polyMeshGen)/polyMeshGenFaces.C
$(polyMeshGen)/polyMeshGenCells.C
$(polyMeshGen2DEngine)/polyMeshGen2DEngine.C
$(coordinateModification)/coordinateModification.C
$(coordinateModification)/newCoordinateModification.C
$(coordinateModification)/planeScaling.C
$(coordinateModification)/boxScaling.C
$(edgeMeshGeometryModification)/edgeMeshGeometryModification.C
$(surfaceMeshGeometryModification)/surfaceMeshGeometryModification.C
$(polyMeshGenGeometryModification)/polyMeshGenGeometryModification.C
$(coordinateModification)/coordinateModifier.C
$(boundaryPatch)/boundaryPatchBase.C
$(boundaryPatch)/boundaryPatch.C
$(boundaryPatch)/processorBoundaryPatch.C
$(polyMeshGenModifier)/polyMeshGenModifierRemoveUnusedVertices.C
$(polyMeshGenModifier)/polyMeshGenModifierRemoveFaces.C
$(polyMeshGenModifier)/polyMeshGenModifierRemoveCells.C
$(polyMeshGenModifier)/polyMeshGenModifierReorderBoundaryFaces.C
$(polyMeshGenModifier)/polyMeshGenModifierAddCells.C
$(polyMeshGenModifier)/polyMeshGenModifierAddProcessorFaces.C
$(polyMeshGenModifier)/polyMeshGenModifierAddBufferCells.C
$(polyMeshGenModifier)/polyMeshGenModifierReplaceBoundary.C
$(polyMeshGenModifier)/polyMeshGenModifierZipUpCells.C
$(polyMeshGenModifier)/polyMeshGenModifierRenumberMesh.C
$(polyMeshGenModifier)/polyMeshGenModifierAddCellByCell.C
$(polyMeshGenAddressing)/polyMeshGenAddressing.C
$(polyMeshGenAddressing)/polyMeshGenAddressingCellCells.C
$(polyMeshGenAddressing)/polyMeshGenAddressingCellEdges.C
$(polyMeshGenAddressing)/polyMeshGenAddressingCellPoints.C
$(polyMeshGenAddressing)/polyMeshGenAddressingCentresAndAreas.C
$(polyMeshGenAddressing)/polyMeshGenAddressingCentresAndVols.C
$(polyMeshGenAddressing)/polyMeshGenAddressingClear.C
$(polyMeshGenAddressing)/polyMeshGenAddressingUpdateGeometry.C
$(polyMeshGenAddressing)/polyMeshGenAddressingEdgeCells.C
$(polyMeshGenAddressing)/polyMeshGenAddressingEdgeFaces.C
$(polyMeshGenAddressing)/polyMeshGenAddressingFaceEdges.C
$(polyMeshGenAddressing)/polyMeshGenAddressingEdges.C
$(polyMeshGenAddressing)/polyMeshGenAddressingPointCells.C
$(polyMeshGenAddressing)/polyMeshGenAddressingPointEdges.C
$(polyMeshGenAddressing)/polyMeshGenAddressingPointFaces.C
$(polyMeshGenAddressing)/polyMeshGenAddressingPointPoints.C
$(polyMeshGenAddressing)/polyMeshGenAddressingParallelAddressing.C
$(polyMeshGenChecks)/polyMeshGenChecks.C
$(polyMeshGenChecks)/polyMeshGenChecksGeometry.C
$(polyMeshGenChecks)/polyMeshGenChecksTopology.C
$(partTetMesh)/partTetMesh.C
$(partTetMesh)/partTetMeshAddressing.C
$(partTetMesh)/partTetMeshParallelAddressing.C
$(partTetMesh)/partTetMeshSimplex.C
$(partTriMesh)/partTriMesh.C
$(partTriMesh)/partTriMeshAddressing.C
$(partTriMesh)/partTriMeshParallelAddressing.C
$(partTriMesh)/partTriMeshSimplex.C
$(triSurf)/triSurf.C
$(triSurf)/triSurfPoints.C
$(triSurf)/triSurfFacets.C
$(triSurf)/triSurfFeatureEdges.C
$(triSurf)/triSurfAddressing.C
$(triSurf)/triSurfModifier.C
$(findCellsIntersectingSurface)/findCellsIntersectingSurface.C
$(tetCreatorOctree)/tetCreatorOctree.C
$(tetCreatorOctree)/tetCreatorOctreePointsAndAddressing.C
$(tetCreatorOctree)/tetCreatorOctreeFromFacesWithCentreNode.C
$(tetCreatorOctree)/tetCreatorOctreeTetsAroundEdges.C
$(tetCreatorOctree)/tetCreatorOctreeTetsAroundSplitEdges.C
$(tetCreatorOctree)/tetCreatorOctreeTetsFromSplitFaces.C
$(faceDecomposition)/faceDecomposition.C
$(faceDecomposition)/decomposeFaces.C
$(helperFunctions)/helperFunctionsStringConversion.C
$(sortEdgesIntoChains)/sortEdgesIntoChains.C
$(surfaceMorpherCells)/surfaceMorpherCells.C
$(surfaceMorpherCells)/surfaceMorpherCellsMorphInternalFaces.C
$(surfaceMorpherCells)/surfaceMorpherCellsCreateBoundaryFaces.C
$(decomposeCells)/decomposeCells.C
$(decomposeCells)/decomposeCellsPyramids.C
$(decomposeCells)/decomposeCellsDecomposition.C
$(topologicalCleaner)/topologicalCleaner.C
$(topologicalCleaner)/topologyCleanerNonConsecutiveBoundaryVertices.C
$(topologicalCleaner)/topologicalCleanerInvalidVertices.C
$(topologicalCleaner)/topologyCleanerNonMappableCells.C
$(checkCellConnectionsOverFaces)/checkCellConnectionsOverFaces.C
$(checkIrregularSurfaceConnections)/checkIrregularSurfaceConnections.C
$(checkIrregularSurfaceConnections)/checkIrregularSurfaceConnectionsFunctions.C
$(checkNonMappableCellConnections)/checkNonMappableCellConnections.C
$(checkBoundaryFacesSharingTwoEdges)/checkBoundaryFacesSharingTwoEdges.C
$(boundaryLayers)/boundaryLayers.C
$(boundaryLayers)/boundaryLayersCreateVertices.C
$(boundaryLayers)/boundaryLayersFacesAndCells.C
$(boundaryLayers)/boundaryLayerCells.C
$(boundaryLayers)/boundaryLayersCheckTopologyOfBndFaces.C
$(boundaryLayers)/boundaryLayersWrapperLayer.C
$(extrudeLayer)/extrudeLayer.C
$(detectBoundaryLayers)/detectBoundaryLayers.C
$(detectBoundaryLayers)/detectBoundaryLayersFunctions.C
$(refineBoundaryLayers)/refineBoundaryLayers.C
$(refineBoundaryLayers)/refineBoundaryLayersFunctions.C
$(refineBoundaryLayers)/refineBoundaryLayersFaces.C
$(refineBoundaryLayers)/refineBoundaryLayersCells.C
$(triangulateNonPlanarBaseFaces)/triangulateNonPlanarBaseFaces.C
$(triangulateNonPlanarBaseFaces)/triangulateNonPlanarBaseFacesFunctions.C
$(meshSurfaceEngine)/meshSurfaceEngine.C
$(meshSurfaceEngine)/meshSurfaceEngineCalculateBoundaryNodesAndFaces.C
$(meshSurfaceEngine)/meshSurfaceEngineParallelAddressing.C
$(meshSurfaceEngine)/meshSurfaceEngineModifier.C
$(meshSurfacePartitioner)/meshSurfacePartitioner.C
$(meshSurfacePartitioner)/meshSurfacePartitionerFunctions.C
$(meshSurfaceCheckInvertedVertices)/meshSurfaceCheckInvertedVertices.C
$(meshSurfaceCheckEdgeTypes)/meshSurfaceCheckEdgeTypes.C
$(meshSurfaceMapper)/meshSurfaceMapper.C
$(meshSurfaceMapper)/meshSurfaceMapperMapVertices.C
$(meshSurfaceMapper)/meshSurfaceMapperCornersAndEdges.C
$(meshSurfaceMapper)/meshSurfaceMapperPremapVertices.C
$(meshSurfaceMapper2D)/meshSurfaceMapper2D.C
$(meshSurfaceMapper2D)/meshSurfaceMapper2DMapVertices.C
$(meshSurfaceMapper2D)/meshSurfaceMapper2DPremapVertices.C
$(edgeExtractor)/edgeExtractor.C
$(edgeExtractor)/edgeExtractorCorners.C
$(meshSurfaceEdgeExtractorNonTopo)/meshSurfaceEdgeExtractorNonTopo.C
$(meshSurfaceEdgeExtractorNonTopo)/meshSurfaceEdgeExtractorNonTopoDistributeFaces.C
$(meshSurfaceEdgeExtractor2D)/meshSurfaceEdgeExtractor2D.C
$(meshSurfaceEdgeExtractor2D)/meshSurfaceEdgeExtractor2DDistributeFaces.C
$(meshSurfaceEdgeExtractorFUN)/meshSurfaceEdgeExtractorFUN.C
$(meshSurfaceEdgeExtractorFUN)/meshSurfaceEdgeExtractorFUNDistributeFaces.C
$(createFundamentalSheets)/createFundamentalSheets.C
$(createFundamentalSheetsFJ)/createFundamentalSheetsFJ.C
$(createFundamentalSheetsJFS)/createFundamentalSheetsJFS.C
$(correctEdgesBetweenPatches)/correctEdgesBetweenPatches.C
$(correctEdgesBetweenPatches)/correctEdgesBetweenPatchesDistributeFaces.C
$(renameBoundaryPatches)/renameBoundaryPatches.C
$(meshOptimizer)/meshOptimizer.C
$(meshOptimizer)/meshOptimizerOptimizePoint.C
$(meshOptimizer)/meshOptimizerOptimizePointParallel.C
$(meshOptimizer)/meshOptimizerOptimizeSurface.C
$(meshOptimizer)/optimizeMeshFV.C
$(tetMeshOptimisation)/tetMeshOptimisation.C
$(tetMeshOptimisation)/tetMeshOptimisationParallel.C
$(symmetryPlaneOptimisation)/symmetryPlaneOptimisation.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisation.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisationFunctions.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisationNormals.C
$(boundaryLayerOptimisation)/boundaryLayerOptimisationThickness.C
$(simplexSmoother)/simplexSmoother.C
$(knuppMetric)/knuppMetric.C
$(meshUntangler)/meshUntangler.C
$(meshUntangler)/meshUntanglerCutRegion.C
$(meshUntangler)/meshUntanglerCutRegionPoints.C
$(meshUntangler)/meshUntanglerCutRegionEdges.C
$(meshUntangler)/meshUntanglerCutRegionFaces.C
$(meshUntangler)/meshUntanglerCutRegionTieBreak.C
$(quadricMetric)/quadricMetric.C
$(volumeOptimizer)/volumeOptimizer.C
$(volumeOptimizer)/volumeOptimizerEvaluateGradients.C
$(meshSurfaceOptimizer)/meshSurfaceOptimizer.C
$(meshSurfaceOptimizer)/meshSurfaceOptimizerCalculateTrianglesAndAddressing.C
$(meshSurfaceOptimizer)/meshSurfaceOptimizerOptimizePoint.C
$(meshSurfaceOptimizer)/meshSurfaceOptimizerOptimizeSurface.C
$(meshSurfaceOptimizer)/meshSurfaceOptimizerOptimizePointParallel.C
$(surfaceOptimizer)/surfaceOptimizer.C
$(meshOctreeCube)/meshOctreeCube.C
$(meshOctreeCube)/meshOctreeCubeIntersections.C
$(meshOctreeCube)/meshOctreeCubeRecursiveFunctions.C
$(meshOctreeCube)/meshOctreeCubeRefine.C
$(meshOctreeCube)/meshOctreeCubeCoordinatesIntersections.C
$(meshOctreeModifier)/meshOctreeModifier.C
$(meshOctreeModifier)/meshOctreeModifierRefineSelectedBoxes.C
$(meshOctreeModifier)/meshOctreeModifierEnsureCorrectRegularity.C
$(meshOctreeModifier)/meshOctreeModifierParallelRefinement.C
$(meshOctreeModifier)/meshOctreeModifierDistributeLeavesToProcessors.C
$(meshOctreeModifier)/meshOctreeModifierLoadDistribution.C
$(meshOctreeModifier)/meshOctreeModifierReduceMemoryConsumption.C
$(meshOctreeModifier)/meshOctreeModifierUpdateCommunicationPattern.C
$(meshOctreeInsideOutside)/meshOctreeInsideOutside.C
$(meshOctreeCreator)/meshOctreeCreator.C
$(meshOctreeCreator)/meshOctreeCreatorAdjustOctreeToSurface.C
$(meshOctreeCreator)/meshOctreeCreatorCreateOctreeBoxes.C
$(meshOctreeCreator)/meshOctreeCreatorFrontalMarking.C
$(meshOctreeCreator)/meshOctreeCreatorLoadDistribution.C
$(meshOctreeAddressing)/meshOctreeAddressing.C
$(meshOctreeAddressing)/meshOctreeAddressingCreation.C
$(meshOctreeAddressing)/meshOctreeAddressingGluedMesh.C
$(meshOctreeAddressing)/meshOctreeAddressingIrregularConnections.C
$(meshOctreeAddressing)/meshOctreeAddressingParallelAddressing.C
$(meshOctreeAutoRef)/meshOctreeAutomaticRefinement.C
$(meshOctreeAutoRef)/meshOctreeAutomaticRefinementRef.C
$(meshOctree)/meshOctree.C
$(meshOctree)/meshOctreeCubePatches.C
$(meshOctree)/meshOctreeNeighbourSearches.C
$(meshOctree)/meshOctreeFindNearestSurfacePoint.C
$(meshOctree)/meshOctreeInsideCalculations.C
$(meshOctree)/meshOctreeParallelCommunication.C
$(patchRefinement)/patchRefinement.C
$(objectRefinement)/objectRefinement.C
$(objectRefinement)/newObjectRefinement.C
$(objectRefinement)/sphereRefinement.C
$(objectRefinement)/lineRefinement.C
$(objectRefinement)/coneRefinement.C
$(objectRefinement)/boxRefinement.C
$(objectRefinement)/hollowConeRefinement.C
$(triSurface2DCheck)/triSurface2DCheck.C
$(triSurfaceChecks)/triSurfaceChecks.C
$(triSurfaceCleanupDuplicates)/triSurfaceCleanupDuplicates.C
$(triSurfaceCleanupDuplicates)/triSurfaceCleanupDuplicatesFunctions.C
$(triSurfaceCleanupDuplicateTriangles)/triSurfaceCleanupDuplicateTriangles.C
$(triSurfaceCleanupDuplicateTriangles)/triSurfaceCleanupDuplicateTrianglesFunctions.C
$(triSurfaceCopyParts)/triSurfaceCopyParts.C
$(triSurfacePartitioner)/triSurfacePartitioner.C
$(triSurfacePartitioner)/triSurfacePartitionerCreateAddressing.C
$(triSurfaceCurvatureEstimator)/triSurfaceCurvatureEstimator.C
$(triSurfaceCurvatureEstimator)/triSurfaceCurvatureEstimatorCalculate.C
$(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdges.C
$(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdgesFunctions.C
$(triSurfaceClassifyEdges)/triSurfaceClassifyEdges.C
$(triSurfaceClassifyEdges)/triSurfaceClassifyEdgesFunctions.C
$(triSurfaceImportSurfaceAsSubset)/triSurfaceImportSurfaceAsSubset.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulator.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulatorFunctions.C
$(triSurfaceRemoveFacets)/triSurfaceRemoveFacets.C
$(triSurfaceRemoveFacets)/triSurfaceRemoveFacetsFunctions.C
$(triSurfaceExtrude2DEdges)/triSurfaceExtrude2DEdges.C
$(triSurfaceMetaData)/triSurfaceMetaData.C
$(cartesianMeshExtractor)/cartesianMeshExtractor.C
$(cartesianMeshExtractor)/cartesianMeshExtractorPointsAndAddressing.C
$(cartesianMeshExtractor)/cartesianMeshExtractorPolyMesh.C
$(cartesianMeshExtractor)/cartesianMeshExtractorDecomposeSplitHexes.C
$(cartesianMeshGenerator)/cartesianMeshGenerator.C
$(cartesian2DMeshGenerator)/cartesian2DMeshGenerator.C
$(tetMeshExtractorOctree)/tetMeshExtractorOctree.C
$(tetMeshGenerator)/tetMeshGenerator.C
$(voronoiMeshExtractor)/voronoiMeshExtractor.C
$(voronoiMeshExtractor)/voronoiMeshExtractorAddressing.C
$(voronoiMeshExtractor)/voronoiMeshExtractorCreateMesh.C
$(voronoiMeshGenerator)/voronoiMeshGenerator.C
$(writeAsFPMA)/writeMeshFPMA.C
$(writeAsFPMA)/fpmaMesh.C
$(workflowControls)/workflowControls.C
LIB = $(FOAM_LIBBIN)/libmeshLibrary

View file

@ -1,15 +0,0 @@
#if defined(__GNUC__)
# if defined(darwinIntel64)
OMP_FLAGS =
# else
OMP_FLAGS = -DUSE_OMP -fopenmp
# endif
#else
OMP_FLAGS =
#endif
EXE_INC = \
$(OMP_FLAGS) \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude

View file

@ -1,372 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "cartesian2DMeshGenerator.H"
#include "triSurface2DCheck.H"
#include "polyMeshGen2DEngine.H"
#include "triSurf.H"
#include "triSurfacePatchManipulator.H"
#include "triSurfaceCleanupDuplicateTriangles.H"
#include "demandDrivenData.H"
#include "Time.H"
#include "meshOctreeCreator.H"
#include "cartesianMeshExtractor.H"
#include "meshSurfaceEngine.H"
#include "meshSurfaceMapper2D.H"
#include "meshSurfaceEdgeExtractor2D.H"
#include "meshSurfaceOptimizer.H"
#include "topologicalCleaner.H"
#include "boundaryLayers.H"
#include "refineBoundaryLayers.H"
#include "renameBoundaryPatches.H"
#include "checkMeshDict.H"
#include "checkCellConnectionsOverFaces.H"
#include "checkIrregularSurfaceConnections.H"
#include "checkNonMappableCellConnections.H"
#include "checkBoundaryFacesSharingTwoEdges.H"
#include "triSurfaceMetaData.H"
#include "polyMeshGenGeometryModification.H"
#include "surfaceMeshGeometryModification.H"
//#define DEBUG
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * * //
void cartesian2DMeshGenerator::createCartesianMesh()
{
//- create polyMesh from octree boxes
cartesianMeshExtractor cme(*octreePtr_, meshDict_, mesh_);
if( meshDict_.found("decomposePolyhedraIntoTetsAndPyrs") )
{
if( readBool(meshDict_.lookup("decomposePolyhedraIntoTetsAndPyrs")) )
cme.decomposeSplitHexes();
}
cme.createMesh();
}
void cartesian2DMeshGenerator::surfacePreparation()
{
//- removes unnecessary cells and morph the boundary
//- such that there is only one boundary face per cell
//- It also checks topology of cells after morphing is performed
bool changed;
do
{
changed = false;
checkIrregularSurfaceConnections checkConnections(mesh_);
if( checkConnections.checkAndFixIrregularConnections() )
changed = true;
if( checkNonMappableCellConnections(mesh_).removeCells() )
changed = true;
if( checkCellConnectionsOverFaces(mesh_).checkCellGroups() )
changed = true;
} while( changed );
checkBoundaryFacesSharingTwoEdges(mesh_).improveTopology();
}
void cartesian2DMeshGenerator::mapMeshToSurface()
{
//- calculate mesh surface
meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_);
//- pre-map mesh surface
meshSurfaceMapper2D mapper(*msePtr, *octreePtr_);
mapper.adjustZCoordinates();
mapper.preMapVertices();
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
deleteDemandDrivenData(msePtr);
}
void cartesian2DMeshGenerator::extractPatches()
{
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_).distributeBoundaryFaces();
}
void cartesian2DMeshGenerator::mapEdgesAndCorners()
{
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_).remapBoundaryPoints();
}
void cartesian2DMeshGenerator::optimiseMeshSurface()
{
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer optimizer(mse, *octreePtr_);
optimizer.optimizeSurface2D();
optimizer.untangleSurface2D();
}
void cartesian2DMeshGenerator::generateBoundaryLayers()
{
boundaryLayers bl(mesh_);
bl.activate2DMode();
bl.addLayerForAllPatches();
if( modSurfacePtr_ )
{
polyMeshGenGeometryModification meshMod(mesh_, meshDict_);
//- revert the mesh into the original space
meshMod.revertGeometryModification();
//- delete modified surface mesh
deleteDemandDrivenData(modSurfacePtr_);
//- delete the octree
deleteDemandDrivenData(octreePtr_);
//- contruct a new octree from the input surface
octreePtr_ = new meshOctree(*surfacePtr_, true);
meshOctreeCreator(*octreePtr_).createOctreeWithRefinedBoundary(20);
mapEdgesAndCorners();
optimiseMeshSurface();
}
}
void cartesian2DMeshGenerator::refBoundaryLayers()
{
if( meshDict_.isDict("boundaryLayers") )
{
refineBoundaryLayers refLayers(mesh_);
refineBoundaryLayers::readSettings(meshDict_, refLayers);
refLayers.activate2DMode();
refLayers.refineLayers();
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer optimizer(mse, *octreePtr_);
optimizer.untangleSurface2D();
}
}
void cartesian2DMeshGenerator::replaceBoundaries()
{
renameBoundaryPatches rbp(mesh_, meshDict_);
}
void cartesian2DMeshGenerator::renumberMesh()
{
polyMeshGenModifier(mesh_).renumberMesh();
}
void cartesian2DMeshGenerator::generateMesh()
{
try
{
if( controller_.runCurrentStep("templateGeneration") )
{
createCartesianMesh();
}
if( controller_.runCurrentStep("surfaceTopology") )
{
surfacePreparation();
}
if( controller_.runCurrentStep("surfaceProjection") )
{
mapMeshToSurface();
}
if( controller_.runCurrentStep("patchAssignment") )
{
extractPatches();
}
if( controller_.runCurrentStep("edgeExtraction") )
{
mapEdgesAndCorners();
optimiseMeshSurface();
}
if( controller_.runCurrentStep("boundaryLayerGeneration") )
{
generateBoundaryLayers();
}
if( controller_.runCurrentStep("meshOptimisation") )
{
optimiseMeshSurface();
}
if( controller_.runCurrentStep("boundaryLayerRefinement") )
{
refBoundaryLayers();
}
renumberMesh();
replaceBoundaries();
controller_.workflowCompleted();
}
catch(const std::string& message)
{
Info << message << endl;
}
catch(...)
{
WarningIn
(
"void cartesian2DMeshGenerator::generateMesh()"
) << "Meshing process terminated!" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cartesian2DMeshGenerator::cartesian2DMeshGenerator(const Time& time)
:
db_(time),
surfacePtr_(NULL),
modSurfacePtr_(NULL),
meshDict_
(
IOobject
(
"meshDict",
db_.system(),
db_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
octreePtr_(NULL),
mesh_(time),
controller_(mesh_)
{
if( true )
{
checkMeshDict cmd(meshDict_);
}
fileName surfaceFile = meshDict_.lookup("surfaceFile");
if( Pstream::parRun() )
surfaceFile = ".."/surfaceFile;
surfacePtr_ = new triSurf(db_.path()/surfaceFile);
if( true )
{
//- save meta data with the mesh (surface mesh + its topology info)
triSurfaceMetaData sMetaData(*surfacePtr_);
const dictionary& surfMetaDict = sMetaData.metaData();
mesh_.metaData().add("surfaceFile", surfaceFile, true);
mesh_.metaData().add("surfaceMeta", surfMetaDict, true);
triSurface2DCheck surfCheck(*surfacePtr_);
if( !surfCheck.is2DSurface() )
{
surfCheck.createSubsets();
Info << "Writting surface with subsets to file "
<< "badSurfaceWithSubsets.fms" << endl;
surfacePtr_->writeSurface("badSurfaceWithSubsets.fms");
}
}
if( surfacePtr_->featureEdges().size() != 0 )
{
//- get rid of duplicate triangles as they cause strange problems
triSurfaceCleanupDuplicateTriangles(const_cast<triSurf&>(*surfacePtr_));
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr_);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict_);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr_);
surfacePtr_ = surfaceWithPatches;
}
if( meshDict_.found("anisotropicSources") )
{
surfaceMeshGeometryModification surfMod(*surfacePtr_, meshDict_);
modSurfacePtr_ = surfMod.modifyGeometry();
octreePtr_ = new meshOctree(*modSurfacePtr_, true);
}
else
{
octreePtr_ = new meshOctree(*surfacePtr_, true);
}
meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes();
generateMesh();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
cartesian2DMeshGenerator::~cartesian2DMeshGenerator()
{
deleteDemandDrivenData(surfacePtr_);
deleteDemandDrivenData(modSurfacePtr_);
deleteDemandDrivenData(octreePtr_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void cartesian2DMeshGenerator::writeMesh() const
{
mesh_.write();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,147 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cartesian2DMeshGenerator
Description
Creates a 2D cartesian mesh from the quadtree
SourceFiles
cartesian2DMeshGenerator.C
\*---------------------------------------------------------------------------*/
#ifndef cartesian2DMeshGenerator_H
#define cartesian2DMeshGenerator_H
#include "polyMeshGen.H"
#include "IOdictionary.H"
#include "workflowControls.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class triSurf;
class meshOctree;
class Time;
/*---------------------------------------------------------------------------*\
Class cartesian2DMeshGenerator Declaration
\*---------------------------------------------------------------------------*/
class cartesian2DMeshGenerator
{
// Private data
//- reference to Time
const Time& db_;
//- pointer to the surface
const triSurf* surfacePtr_;
//- pointer to the modified surface mesh
const triSurf* modSurfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
//- pointer to the octree
meshOctree* octreePtr_;
//- mesh
polyMeshGen mesh_;
//- workflow controller
workflowControls controller_;
// Private member functions
//- create cartesian mesh
void createCartesianMesh();
//- prepare mesh surface
void surfacePreparation();
//- map mesh to the surface and untangle surface
void mapMeshToSurface();
//- capture edges and corners
void extractPatches();
//- capture edges and corners
void mapEdgesAndCorners();
//- optimise surface mesh
void optimiseMeshSurface();
//- add boundary layers
void generateBoundaryLayers();
//- refine boundary layers
void refBoundaryLayers();
//- replace boundaries
void replaceBoundaries();
//- renumber the mesh
void renumberMesh();
//- generate mesh
void generateMesh();
//- Disallow default bitwise copy construct
cartesian2DMeshGenerator(const cartesian2DMeshGenerator&);
//- Disallow default bitwise assignment
void operator=(const cartesian2DMeshGenerator&);
public:
// Constructors
//- Construct from time
cartesian2DMeshGenerator(const Time&);
// Destructor
~cartesian2DMeshGenerator();
// Member Functions
//- write the mesh
void writeMesh() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,123 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "cartesianMeshExtractor.H"
#include "meshOctree.H"
// #define DEBUGSearch
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void cartesianMeshExtractor::clearOut()
{
deleteDemandDrivenData(leafCellLabelPtr_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from octree and mesh data
cartesianMeshExtractor::cartesianMeshExtractor
(
meshOctree& octree,
const IOdictionary& meshDict,
polyMeshGen& mesh
)
:
octreeCheck_(octree, meshDict, false),
mesh_(mesh),
decomposeSplitHexes_(false),
leafCellLabelPtr_(new labelList(octree.numberOfLeaves(), -1))
{
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
cartesianMeshExtractor::~cartesianMeshExtractor()
{
clearOut();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void cartesianMeshExtractor::decomposeSplitHexes()
{
decomposeSplitHexes_ = true;
}
void cartesianMeshExtractor::createMesh()
{
Info << "Extracting polyMesh" << endl;
//- create points and pointLeaves addressing
createPointsAndAddressing();
//- create the mesh
createPolyMesh();
//- decompose split-hex cells into tetrahedra and pyramids
decomposeSplitHexesIntoTetsAndPyramids();
//- remove unused vertices
polyMeshGenModifier(mesh_).removeUnusedVertices();
Info << "Mesh has :" << nl
<< mesh_.points().size() << " vertices " << nl
<< mesh_.faces().size() << " faces" << nl
<< mesh_.cells().size() << " cells" << endl;
if( Pstream::parRun() )
{
label nCells = mesh_.cells().size();
reduce(nCells, sumOp<label>());
Info << "Total number of cells " << nCells << endl;
}
if( mesh_.cells().size() == 0 )
{
FatalErrorIn
(
"void cartesianMeshExtractor::createMesh()"
) << "There are no cells in the mesh!"
<< nl << "The reasons for this can be fwofold:"
<< nl << "1. Inadequate mesh resolution."
<< nl << "2. You maxCellSize is a multiplier of the domain length."
<< " This can be reolved by reducing the maxCellSize by a fraction."
<< "i.e. 2.49999 instead of 2.5." << exit(FatalError);
}
Info << "Finished extracting polyMesh" << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,122 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cartesianMeshExtractor
Description
Generates the cartesian mesh template from the octree
SourceFiles
cartesianMeshExtractor.C
\*---------------------------------------------------------------------------*/
#ifndef cartesianMeshExtractor_H
#define cartesianMeshExtractor_H
#include "polyMeshGenModifier.H"
#include "meshOctreeAddressing.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class IOdictionary;
/*---------------------------------------------------------------------------*\
Class cartesianMeshExtractor Declaration
\*---------------------------------------------------------------------------*/
class cartesianMeshExtractor
{
// Private data
//- reference to the octree addressing
meshOctreeAddressing octreeCheck_;
//- reference to the mesh
polyMeshGen& mesh_;
//- decompose split hex cells
bool decomposeSplitHexes_;
//- cell label for a given leaf
labelList* leafCellLabelPtr_;
// Private member functions
//- delete all freestore data
void clearOut();
//- create vertices and pointLeaves addressing
void createPointsAndAddressing();
//- create mesh data
void createPolyMesh();
//- decompose split hexes into pyramids and tets
void decomposeSplitHexesIntoTetsAndPyramids();
// Private copy constructor
//- Disallow default bitwise copy construct
cartesianMeshExtractor(const cartesianMeshExtractor&);
//- Disallow default bitwise assignment
void operator=(const cartesianMeshExtractor&);
public:
// Constructors
//- Construct from octree and mesh data
cartesianMeshExtractor
(
meshOctree& octree,
const IOdictionary& meshDict,
polyMeshGen& mesh
);
// Destructor
~cartesianMeshExtractor();
// Member Functions
//- decompose split hexes into standard cells
void decomposeSplitHexes();
//- create the mesh with the above options
void createMesh();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,110 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "cartesianMeshExtractor.H"
#include "demandDrivenData.H"
#include "decomposeFaces.H"
#include "decomposeCells.H"
#include "hexMatcher.H"
//#define DEBUGMesh
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids()
{
if( !decomposeSplitHexes_ ) return;
Info << "Decomposing split-hex cells" << endl;
const faceListPMG& faces = mesh_.faces();
//- decompose faces which have more than 4 vertices
boolList decompose(faces.size(), false);
label nDecomposed(0);
forAll(faces, faceI)
{
if( faces[faceI].size() > 4 )
{
++nDecomposed;
decompose[faceI] = true;
}
}
reduce(nDecomposed, sumOp<label>());
Info << "Decomposing " << nDecomposed
<< " faces with more than 4 vertices" << endl;
if( nDecomposed != 0 )
{
//- decompose marked faces into triangles
decomposeFaces(mesh_).decomposeMeshFaces(decompose);
}
//- decompose cells with 24 faces
const cellListPMG& cells = mesh_.cells();
decompose.setSize(cells.size());
decompose = false;
hexMatcher hex;
forAll(cells, cellI)
{
if( !hex.matchShape(true, faces, mesh_.owner(), cellI, cells[cellI]) )
{
++nDecomposed;
decompose[cellI] = true;
}
}
reduce(nDecomposed, sumOp<label>());
Info << "Decomposing " << nDecomposed
<< " cells into tetrahedra and pyramids" << endl;
if( nDecomposed )
{
//- decompose marked cells into tets and pyramids
decomposeCells dc(mesh_);
dc.decomposeMesh(decompose);
}
Info << "Finished decomposing split-hex cells" << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,62 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "cartesianMeshExtractor.H"
#include "meshOctree.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Private member functions
void cartesianMeshExtractor::createPointsAndAddressing()
{
Info << "Creating octree vertices" << endl;
Info << "Octree nodes " << octreeCheck_.numberOfNodes() << endl;
//- set the size of the point field
pointFieldPMG& points = mesh_.points();
points.setSize(octreeCheck_.numberOfNodes());
//- store vertices into the pointField
const pointField& octreePoints = octreeCheck_.octreePoints();
forAll(points, pointI)
points[pointI] = octreePoints[pointI];
Info << "Finished creating octree vertices" << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,432 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "cartesianMeshExtractor.H"
#include "demandDrivenData.H"
#include "meshOctree.H"
#include "labelledPair.H"
#include "meshSurfaceEngine.H"
#include "helperFunctions.H"
#include "helperFunctionsPar.H"
#include "decomposeFaces.H"
#include "decomposeCells.H"
#include <map>
#include <sstream>
//#define DEBUGMesh
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void cartesianMeshExtractor::createPolyMesh()
{
Info << "Creating polyMesh from octree" << endl;
const meshOctree& octree = octreeCheck_.octree();
//- give labels to cubes which will be used as mesh cells
const List<direction>& cType = octreeCheck_.boxType();
labelList& leafCellLabel = *leafCellLabelPtr_;
label nCells(0);
forAll(cType, leafI)
{
if(
Pstream::parRun() &&
(octree.returnLeaf(leafI).procNo() != Pstream::myProcNo())
)
continue;
if( cType[leafI] & meshOctreeAddressing::MESHCELL )
{
leafCellLabel[leafI] = nCells++;
}
}
//- access to mesh data
polyMeshGenModifier meshModifier(mesh_);
faceListPMG& faces = meshModifier.facesAccess();
cellListPMG& cells = meshModifier.cellsAccess();
//- start creating octree mesh
cells.setSize(nCells);
List<direction> nFacesInCell(nCells, direction(0));
label nFaces(0);
const VRWGraph& octreeFaces = octreeCheck_.octreeFaces();
const labelLongList& owner = octreeCheck_.octreeFaceOwner();
const labelLongList& neighbour = octreeCheck_.octreeFaceNeighbour();
//- map storing box label and a direction for each processor face
//- The map stores data in the same order on both sides of processor
//- boundaries. This is a consequence of Morton ordering of
//- leaf boxes in the octree.
std::map<label, labelLongList> procFaces;
forAll(octreeFaces, faceI)
{
const label own = owner[faceI];
const label nei = neighbour[faceI];
const label ownLabel = leafCellLabel[own];
label neiLabel(-1);
if( nei != -1 )
neiLabel = leafCellLabel[nei];
if( (ownLabel != -1) && (neiLabel != -1) )
{
++nFaces;
++nFacesInCell[ownLabel];
++nFacesInCell[neiLabel];
}
else if( ownLabel != -1 )
{
++nFaces;
++nFacesInCell[ownLabel];
if( (nei != -1) && (cType[nei] & meshOctreeAddressing::MESHCELL) )
{
const label procNo = octree.returnLeaf(nei).procNo();
procFaces[procNo].append(faceI);
}
}
else if( neiLabel != -1 )
{
++nFaces;
++nFacesInCell[neiLabel];
if( (own != -1) && (cType[own] & meshOctreeAddressing::MESHCELL) )
{
const label procNo = octree.returnLeaf(own).procNo();
procFaces[procNo].append(faceI);
}
}
}
//- case is a serial run
faces.setSize(nFaces);
forAll(cells, cI)
cells[cI].setSize(nFacesInCell[cI]);
nFacesInCell = 0;
//- calculate faces in processor patches
if( Pstream::parRun() )
{
PtrList<processorBoundaryPatch>& procBoundaries =
meshModifier.procBoundariesAccess();
//- set the number of procBoundaries
procBoundaries.setSize(procFaces.size());
std::ostringstream ss;
ss << Pstream::myProcNo();
const word name("processor"+ss.str()+"to");
label nProcBoundaries(nFaces), patchI(0);
//- allocate memory for processor patches
std::map<label, labelLongList>::const_iterator iter;
for(iter=procFaces.begin();iter!=procFaces.end();++iter)
{
const label procI = iter->first;
std::ostringstream ssNei;
ssNei << procI;
procBoundaries.set
(
patchI,
new processorBoundaryPatch
(
name+ssNei.str(),
"processor",
iter->second.size(),
0,
Pstream::myProcNo(),
procI
)
);
nProcBoundaries -= iter->second.size();
++patchI;
}
//- create processor faces
//- they need to be created here because of the correct ordering
patchI = 0;
for(iter=procFaces.begin();iter!=procFaces.end();++iter)
{
procBoundaries[patchI].patchStart() = nProcBoundaries;
const labelLongList& patchFaces = iter->second;
forAll(patchFaces, pfI)
{
const label fLabel = patchFaces[pfI];
const label own = owner[fLabel];
const label nei = neighbour[fLabel];
const label curCell = leafCellLabel[own];
label neiCell(-1);
if( nei != -1 )
neiCell = leafCellLabel[nei];
//- create a processor face
if( neiCell == -1 )
{
//- add a face
faces[nProcBoundaries].setSize(octreeFaces[fLabel].size());
forAllRow(octreeFaces, fLabel, pI)
faces[nProcBoundaries][pI] = octreeFaces(fLabel, pI);
cells[curCell][nFacesInCell[curCell]++] = nProcBoundaries++;
}
else if( curCell == -1 )
{
//- add a reversed face
faces[nProcBoundaries].setSize(octreeFaces[fLabel].size());
label i(0);
faces[nProcBoundaries][i++] = octreeFaces(fLabel, 0);
for(label pI=octreeFaces.sizeOfRow(fLabel)-1;pI>0;--pI)
faces[nProcBoundaries][i++] = octreeFaces(fLabel, pI);
cells[neiCell][nFacesInCell[neiCell]++] = nProcBoundaries++;
}
else
{
FatalErrorIn
(
"void cartesianMeshExtractor::createPolyMesh()"
) << "Face " << octreeFaces[fLabel] << " causes problems!"
<< abort(FatalError);
}
}
if( procBoundaries[patchI].patchSize() !=
(nProcBoundaries - procBoundaries[patchI].patchStart())
)
FatalErrorIn
(
"cartesianMeshExtractor::createPolyMesh()"
) << "Invalid patch size!" << Pstream::myProcNo()
<< abort(FatalError);
++patchI;
}
}
nFaces = 0;
forAll(octreeFaces, faceI)
{
const label own = owner[faceI];
const label nei = neighbour[faceI];
const label ownLabel = leafCellLabel[own];
label neiLabel(-1);
if( nei != -1 )
neiLabel = leafCellLabel[nei];
if( (ownLabel != -1) && (neiLabel != -1) )
{
//- internal face
faces[nFaces].setSize(octreeFaces.sizeOfRow(faceI));
forAllRow(octreeFaces, faceI, pI)
faces[nFaces][pI] = octreeFaces(faceI, pI);
cells[ownLabel][nFacesInCell[ownLabel]++] = nFaces;
cells[neiLabel][nFacesInCell[neiLabel]++] = nFaces;
++nFaces;
}
else if( ownLabel != -1 )
{
if( (nei != -1) && (cType[nei] & meshOctreeAddressing::MESHCELL) )
{
//- face at a parallel boundary
continue;
}
//- boundary face
faces[nFaces].setSize(octreeFaces.sizeOfRow(faceI));
forAllRow(octreeFaces, faceI, pI)
faces[nFaces][pI] = octreeFaces(faceI, pI);
cells[ownLabel][nFacesInCell[ownLabel]++] = nFaces;
++nFaces;
}
else if( neiLabel != -1 )
{
if( (own != -1) && (cType[own] & meshOctreeAddressing::MESHCELL) )
{
//- face at a parallel boundary
continue;
}
//- boundary face
faces[nFaces].setSize(octreeFaces.sizeOfRow(faceI));
faces[nFaces][0] = octreeFaces(faceI, 0);
for(label pI=octreeFaces.sizeOfRow(faceI)-1;pI>0;--pI)
faces[nFaces][octreeFaces.sizeOfRow(faceI)-pI] =
octreeFaces(faceI, pI);
cells[neiLabel][nFacesInCell[neiLabel]++] = nFaces;
++nFaces;
}
}
# ifdef DEBUGMesh
label nProcBoundaries(0);
forAll(procBoundaries, patchI)
nProcBoundaries += procBoundaries[patchI].patchSize();
if( faces.size() != (nProcBoundaries + nFaces) )
{
Serr << "Number of faces " << faces.size() << endl;
Serr << "Number of processor boundaries " << nProcBoundaries << endl;
Serr << "Number of domain faces " << nFaces << endl;
FatalErrorIn
(
"void cartesianMeshExtractor::createPolyMesh()"
) << Pstream::myProcNo() << "This mesh is invalid!"
<< abort(FatalError);
}
vectorField closedness(cells.size(), vector::zero);
const labelList& owner = mesh_.owner();
const labelList& neighbour = mesh_.neighbour();
forAll(owner, faceI)
if( owner[faceI] == -1 )
{
Info << "faces " << faces << endl;
FatalErrorIn
(
"void cartesianMeshExtractor::createPolyMesh"
"("
"pointFieldPMG& points,"
"faceListPMG& faces,"
"cellListPMG& cells"
")"
) << "Face " << faceI
<< " has no owner and neighbour!!" << abort(FatalError);
}
forAll(faces, faceI)
{
const vector area = faces[faceI].normal(mesh_.points());
closedness[owner[faceI]] += area;
if( neighbour[faceI] != -1 )
closedness[neighbour[faceI]] -= area;
}
forAll(closedness, cellI)
if( mag(closedness[cellI]) > 1e-10 )
Info << "Cell " << cellI << " is not closed by "
<< closedness[cellI] << endl;
# endif
meshModifier.reorderBoundaryFaces();
if( octree.isQuadtree() )
{
//- generate empty patches
//- search for faces with a dominant z coordinate and store them
//- into an empty patch
meshSurfaceEngine mse(mesh_);
const vectorField& fNormals = mse.faceNormals();
const faceList::subList& bFaces = mse.boundaryFaces();
const labelList& fOwner = mse.faceOwners();
const vectorField& fCentres = mse.faceCentres();
const boundBox& bb = octree.rootBox();
const scalar tZ = 0.05 * (bb.max().z() - bb.min().z());
wordList patchNames(3);
patchNames[0] = "defaultFaces";
patchNames[1] = "unusedFacesBottom";
patchNames[2] = "unusedFacesTop";
VRWGraph boundaryFaces;
labelLongList newFaceOwner;
labelLongList newFacePatch;
forAll(fNormals, bfI)
{
//- store the face and its owner
boundaryFaces.appendList(bFaces[bfI]);
newFaceOwner.append(fOwner[bfI]);
const vector& fNormal = fNormals[bfI];
if( Foam::mag(fNormal.z()) > Foam::mag(fNormal.x() + fNormal.y()) )
{
if( Foam::mag(fCentres[bfI].z() - bb.min().z()) < tZ )
{
newFacePatch.append(1);
}
else if( Foam::mag(fCentres[bfI].z() - bb.max().z()) < tZ )
{
newFacePatch.append(2);
}
else
{
FatalErrorIn
(
"void cartesianMeshExtractor::createPolyMesh()"
) << "Cannot distribute the face!!" << exit(FatalError);
}
}
else
{
newFacePatch.append(0);
}
}
//- replace the boundary with faces in correct patches
meshModifier.replaceBoundary
(
patchNames,
boundaryFaces,
newFaceOwner,
newFacePatch
);
meshModifier.boundariesAccess()[1].patchType() = "empty";
meshModifier.boundariesAccess()[2].patchType() = "empty";
}
Info << "Finished creating polyMesh" << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,410 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "cartesianMeshGenerator.H"
#include "triSurf.H"
#include "triSurfacePatchManipulator.H"
#include "demandDrivenData.H"
#include "Time.H"
#include "meshOctreeCreator.H"
#include "cartesianMeshExtractor.H"
#include "meshSurfaceEngine.H"
#include "meshSurfaceMapper.H"
#include "edgeExtractor.H"
#include "meshSurfaceEdgeExtractorNonTopo.H"
#include "meshOptimizer.H"
#include "meshSurfaceOptimizer.H"
#include "topologicalCleaner.H"
#include "boundaryLayers.H"
#include "refineBoundaryLayers.H"
#include "renameBoundaryPatches.H"
#include "checkMeshDict.H"
#include "checkCellConnectionsOverFaces.H"
#include "checkIrregularSurfaceConnections.H"
#include "checkNonMappableCellConnections.H"
#include "checkBoundaryFacesSharingTwoEdges.H"
#include "triSurfaceMetaData.H"
#include "polyMeshGenGeometryModification.H"
#include "surfaceMeshGeometryModification.H"
//#define DEBUG
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * * //
void cartesianMeshGenerator::createCartesianMesh()
{
//- create polyMesh from octree boxes
cartesianMeshExtractor cme(*octreePtr_, meshDict_, mesh_);
if( meshDict_.found("decomposePolyhedraIntoTetsAndPyrs") )
{
if( readBool(meshDict_.lookup("decomposePolyhedraIntoTetsAndPyrs")) )
cme.decomposeSplitHexes();
}
cme.createMesh();
}
void cartesianMeshGenerator::surfacePreparation()
{
//- removes unnecessary cells and morph the boundary
//- such that there is only one boundary face per cell
//- It also checks topology of cells after morphing is performed
bool changed;
do
{
changed = false;
checkIrregularSurfaceConnections checkConnections(mesh_);
if( checkConnections.checkAndFixIrregularConnections() )
changed = true;
if( checkNonMappableCellConnections(mesh_).removeCells() )
changed = true;
if( checkCellConnectionsOverFaces(mesh_).checkCellGroups() )
changed = true;
} while( changed );
checkBoundaryFacesSharingTwoEdges(mesh_).improveTopology();
}
void cartesianMeshGenerator::mapMeshToSurface()
{
//- calculate mesh surface
meshSurfaceEngine mse(mesh_);
//- pre-map mesh surface
meshSurfaceMapper mapper(mse, *octreePtr_);
mapper.preMapVertices();
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
//- untangle surface faces
meshSurfaceOptimizer(mse, *octreePtr_).untangleSurface();
}
void cartesianMeshGenerator::extractPatches()
{
edgeExtractor extractor(mesh_, *octreePtr_);
Info << "Extracting edges" << endl;
extractor.extractEdges();
extractor.updateMeshPatches();
}
void cartesianMeshGenerator::mapEdgesAndCorners()
{
meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_);
}
void cartesianMeshGenerator::optimiseMeshSurface()
{
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface();
}
void cartesianMeshGenerator::generateBoundaryLayers()
{
//- add boundary layers
boundaryLayers bl(mesh_);
bl.addLayerForAllPatches();
}
void cartesianMeshGenerator::refBoundaryLayers()
{
if( meshDict_.isDict("boundaryLayers") )
{
refineBoundaryLayers refLayers(mesh_);
refineBoundaryLayers::readSettings(meshDict_, refLayers);
refLayers.refineLayers();
labelLongList pointsInLayer;
refLayers.pointsInBndLayer(pointsInLayer);
meshOptimizer mOpt(mesh_);
mOpt.lockPoints(pointsInLayer);
mOpt.untangleBoundaryLayer();
}
}
void cartesianMeshGenerator::optimiseFinalMesh()
{
//- untangle the surface if needed
bool enforceConstraints(false);
if( meshDict_.found("enforceGeometryConstraints") )
{
enforceConstraints =
readBool(meshDict_.lookup("enforceGeometryConstraints"));
}
if( true )
{
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer surfOpt(mse, *octreePtr_);
if( enforceConstraints )
surfOpt.enforceConstraints();
surfOpt.optimizeSurface();
}
deleteDemandDrivenData(octreePtr_);
//- final optimisation
meshOptimizer optimizer(mesh_);
if( enforceConstraints )
optimizer.enforceConstraints();
optimizer.optimizeMeshFV();
optimizer.optimizeLowQualityFaces();
optimizer.optimizeBoundaryLayer(modSurfacePtr_==NULL);
optimizer.untangleMeshFV();
mesh_.clearAddressingData();
if( modSurfacePtr_ )
{
polyMeshGenGeometryModification meshMod(mesh_, meshDict_);
//- revert the mesh into the original space
meshMod.revertGeometryModification();
//- delete modified surface mesh
deleteDemandDrivenData(modSurfacePtr_);
}
}
void cartesianMeshGenerator::projectSurfaceAfterBackScaling()
{
if( !meshDict_.found("anisotropicSources") )
return;
deleteDemandDrivenData(octreePtr_);
octreePtr_ = new meshOctree(*surfacePtr_);
meshOctreeCreator
(
*octreePtr_,
meshDict_
).createOctreeWithRefinedBoundary(20, 30);
//- calculate mesh surface
meshSurfaceEngine mse(mesh_);
//- pre-map mesh surface
meshSurfaceMapper mapper(mse, *octreePtr_);
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
optimiseFinalMesh();
}
void cartesianMeshGenerator::replaceBoundaries()
{
renameBoundaryPatches rbp(mesh_, meshDict_);
}
void cartesianMeshGenerator::renumberMesh()
{
polyMeshGenModifier(mesh_).renumberMesh();
}
void cartesianMeshGenerator::generateMesh()
{
try
{
if( controller_.runCurrentStep("templateGeneration") )
{
createCartesianMesh();
}
if( controller_.runCurrentStep("surfaceTopology") )
{
surfacePreparation();
}
if( controller_.runCurrentStep("surfaceProjection") )
{
mapMeshToSurface();
}
if( controller_.runCurrentStep("patchAssignment") )
{
extractPatches();
}
if( controller_.runCurrentStep("edgeExtraction") )
{
mapEdgesAndCorners();
optimiseMeshSurface();
}
if( controller_.runCurrentStep("boundaryLayerGeneration") )
{
generateBoundaryLayers();
}
if( controller_.runCurrentStep("meshOptimisation") )
{
optimiseFinalMesh();
projectSurfaceAfterBackScaling();
}
if( controller_.runCurrentStep("boundaryLayerRefinement") )
{
refBoundaryLayers();
}
renumberMesh();
replaceBoundaries();
controller_.workflowCompleted();
}
catch(const std::string& message)
{
Info << message << endl;
}
catch(...)
{
WarningIn
(
"void cartesianMeshGenerator::generateMesh()"
) << "Meshing process terminated!" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cartesianMeshGenerator::cartesianMeshGenerator(const Time& time)
:
db_(time),
surfacePtr_(NULL),
modSurfacePtr_(NULL),
meshDict_
(
IOobject
(
"meshDict",
db_.system(),
db_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
octreePtr_(NULL),
mesh_(time),
controller_(mesh_)
{
if( true )
{
checkMeshDict cmd(meshDict_);
}
fileName surfaceFile = meshDict_.lookup("surfaceFile");
if( Pstream::parRun() )
surfaceFile = ".."/surfaceFile;
surfacePtr_ = new triSurf(db_.path()/surfaceFile);
if( true )
{
//- save meta data with the mesh (surface mesh + its topology info)
triSurfaceMetaData sMetaData(*surfacePtr_);
const dictionary& surfMetaDict = sMetaData.metaData();
mesh_.metaData().add("surfaceFile", surfaceFile, true);
mesh_.metaData().add("surfaceMeta", surfMetaDict, true);
}
if( surfacePtr_->featureEdges().size() != 0 )
{
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr_);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict_);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr_);
surfacePtr_ = surfaceWithPatches;
}
if( meshDict_.found("anisotropicSources") )
{
surfaceMeshGeometryModification surfMod(*surfacePtr_, meshDict_);
modSurfacePtr_ = surfMod.modifyGeometry();
octreePtr_ = new meshOctree(*modSurfacePtr_);
}
else
{
octreePtr_ = new meshOctree(*surfacePtr_);
}
meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes();
generateMesh();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
cartesianMeshGenerator::~cartesianMeshGenerator()
{
deleteDemandDrivenData(surfacePtr_);
deleteDemandDrivenData(modSurfacePtr_);
deleteDemandDrivenData(octreePtr_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void cartesianMeshGenerator::writeMesh() const
{
mesh_.write();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,154 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cartesianMeshGenerator
Description
Creates cartesian mesh from the octree
SourceFiles
cartesianMeshGenerator.C
\*---------------------------------------------------------------------------*/
#ifndef cartesianMeshGenerator_H
#define cartesianMeshGenerator_H
#include "polyMeshGen.H"
#include "IOdictionary.H"
#include "workflowControls.H"
//#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class triSurf;
class meshOctree;
class Time;
/*---------------------------------------------------------------------------*\
Class cartesianMeshGenerator Declaration
\*---------------------------------------------------------------------------*/
class cartesianMeshGenerator
{
// Private data
//- reference to Time
const Time& db_;
//- pointer to the surface
const triSurf* surfacePtr_;
//- pointer to the modified surface
const triSurf* modSurfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
//- pointer to the octree
meshOctree* octreePtr_;
//- mesh
polyMeshGen mesh_;
//- workflow controller
workflowControls controller_;
// Private member functions
//- create cartesian mesh
void createCartesianMesh();
//- prepare mesh surface
void surfacePreparation();
//- map mesh to the surface and untangle surface
void mapMeshToSurface();
//- capture edges and corners
void extractPatches();
//- map points at feature edges and corners
void mapEdgesAndCorners();
//- optimise surface mesh
void optimiseMeshSurface();
//- add boundary layers
void generateBoundaryLayers();
//- refine boundary layers
void refBoundaryLayers();
//- mesh optimisation
void optimiseFinalMesh();
//- re-project points back on the surface mesh after back-scaling
void projectSurfaceAfterBackScaling();
//- replace boundaries
void replaceBoundaries();
//- renumber the mesh
void renumberMesh();
//- generate mesh
void generateMesh();
//- Disallow default bitwise copy construct
cartesianMeshGenerator(const cartesianMeshGenerator&);
//- Disallow default bitwise assignment
void operator=(const cartesianMeshGenerator&);
public:
// Constructors
//- Construct from time
cartesianMeshGenerator(const Time&);
// Destructor
~cartesianMeshGenerator();
// Member Functions
//- write the mesh
void writeMesh() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,287 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "tetMeshExtractorOctree.H"
#include "meshOctree.H"
#include "triSurface.H"
#include "polyMeshGenModifierAddCellByCell.H"
#include "demandDrivenData.H"
# ifdef USE_OMP
#include <omp.h>
# endif
// #define DEBUGTets
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void tetMeshExtractorOctree::createPoints()
{
polyMeshGenModifier meshModifier ( mesh_ );
pointFieldPMG& points = meshModifier.pointsAccess();
const LongList<point>& tetPoints = tetCreator_.tetPoints();
points.setSize(tetPoints.size());
# ifdef USE_OMP
# pragma omp parallel for
# endif
forAll(tetPoints, pointI)
points[pointI] = tetPoints[pointI];
}
void tetMeshExtractorOctree::createPolyMesh()
{
polyMeshGenModifier meshModifier ( mesh_ );
faceListPMG& faces = meshModifier.facesAccess();
cellListPMG& cells = meshModifier.cellsAccess();
meshModifier.boundariesAccess().setSize ( 0 );
meshModifier.procBoundariesAccess().setSize ( 0 );
const LongList<partTet>& tets = tetCreator_.tets();
VRWGraph pTets;
pTets.reverseAddressing(mesh_.points().size(), tets);
//- set the number of cells
cells.setSize(tets.size());
//- all faces of tetrahedral cells
faces.setSize(4*tets.size());
boolList removeFace(faces.size());
# ifdef USE_OMP
# pragma omp parallel if( tets.size() > 1000 )
# endif
{
//- set face labels
# ifdef USE_OMP
# pragma omp for
# endif
forAll(removeFace, faceI)
removeFace[faceI] = false;
//- set sizes of cells and create all faces
# ifdef USE_OMP
# pragma omp for schedule(dynamic, 20)
# endif
forAll(tets, elmtI)
{
cells[elmtI].setSize(4);
const partTet& elmt = tets[elmtI];
label faceI = 4 * elmtI;
//- first face
cells[elmtI][0] = faceI;
face& f0 = faces[faceI];
f0.setSize(3);
f0[0] = elmt.a();
f0[1] = elmt.c();
f0[2] = elmt.b();
++faceI;
//- second face
cells[elmtI][1] = faceI;
face& f1 = faces[faceI];
f1.setSize(3);
f1[0] = elmt.a();
f1[1] = elmt.b();
f1[2] = elmt.d();
++faceI;
//- third face
cells[elmtI][2] = faceI;
face& f2 = faces[faceI];
f2.setSize ( 3 );
f2[0] = elmt.b();
f2[1] = elmt.c();
f2[2] = elmt.d();
++faceI;
//- fourth face
cells[elmtI][3] = faceI;
face& f3 = faces[faceI];
f3.setSize ( 3 );
f3[0] = elmt.c();
f3[1] = elmt.a();
f3[2] = elmt.d();
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- find duplicate faces
# ifdef USE_OMP
# pragma omp for schedule(dynamic, 20)
# endif
forAll(cells, cellI)
{
cell& c = cells[cellI];
forAll(c, fI)
{
const face& f = faces[c[fI]];
const label pointI = f[0];
forAllRow(pTets, pointI, ptI)
{
//- do not check cells with greater labels
//- they cannot be face owners
if( pTets(pointI, ptI) >= cellI )
continue;
const cell& otherTet = cells[pTets(pointI, ptI)];
//- check faces created from a tet
forAll(otherTet, ofI)
{
//- do not compare faces with greater labels
//- they shall not be removed here
if( otherTet[ofI] >= c[fI] )
continue;
//- check if the faces are equal
if( f == faces[otherTet[ofI]] )
{
removeFace[c[fI]] = true;
c[fI] = otherTet[ofI];
}
}
}
}
}
}
//- remove duplicate faces
label nFaces(0);
labelLongList newFaceLabel(faces.size(), -1);
forAll(faces, faceI)
{
if( !removeFace[faceI] )
{
if( nFaces < faceI )
faces[nFaces].transfer(faces[faceI]);
newFaceLabel[faceI] = nFaces;
++nFaces;
}
}
//- set the size of faces
faces.setSize(nFaces);
//- change cells
# ifdef USE_OMP
# pragma omp for schedule(dynamic, 40)
# endif
forAll(cells, cellI)
{
cell& c = cells[cellI];
DynList<label> newC;
forAll(c, fI)
{
if( newFaceLabel[c[fI]] != -1 )
newC.append(newFaceLabel[c[fI]]);
}
c.setSize(newC.size());
forAll(c, fI)
c[fI] = newC[fI];
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from octree and mesh data
tetMeshExtractorOctree::tetMeshExtractorOctree
(
const meshOctree& octree,
const IOdictionary& meshDict,
polyMeshGen& mesh
)
:
tetCreator_(octree, meshDict),
mesh_(mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
tetMeshExtractorOctree::~tetMeshExtractorOctree()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void tetMeshExtractorOctree::createMesh()
{
Info << "Extracting tetMesh" << endl;
//- copy tet points into the mesh
createPoints();
//- create the mesh
createPolyMesh();
polyMeshGenModifier(mesh_).reorderBoundaryFaces();
polyMeshGenModifier(mesh_).removeUnusedVertices();
Info << "Mesh has :" << nl
<< mesh_.points().size() << " vertices " << nl
<< mesh_.faces().size() << " faces" << nl
<< mesh_.cells().size() << " cells" << endl;
Info << "Finished extracting tetMesh" << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
tetMeshExtractorOctree
Description
A class which extracts tet mesh out of an octree structure
SourceFiles
tetMeshExtractorOctree.C
\*---------------------------------------------------------------------------*/
#ifndef tetMeshExtractorOctree_H
#define tetMeshExtractorOctree_H
#include "polyMeshGenModifier.H"
#include "partTet.H"
#include "tetCreatorOctree.H"
#include "VRWGraph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tetMeshExtractorOctree Declaration
\*---------------------------------------------------------------------------*/
class tetMeshExtractorOctree
{
// Private data
//- create tets
tetCreatorOctree tetCreator_;
//- reference to the mesh
polyMeshGen& mesh_;
// Private member functions
//- copy tetPoints_ into mesh
void createPoints();
//- create mesh data
void createPolyMesh();
// Private copy constructor
//- Disallow default bitwise copy construct
tetMeshExtractorOctree ( const tetMeshExtractorOctree& );
//- Disallow default bitwise assignment
void operator= ( const tetMeshExtractorOctree& );
public:
// Constructors
//- Construct from octree and mesh data
tetMeshExtractorOctree
(
const meshOctree& octree,
const IOdictionary& meshDict,
polyMeshGen& mesh
);
// Destructor
~tetMeshExtractorOctree();
// Member Functions
void createMesh();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,397 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "tetMeshGenerator.H"
#include "triSurf.H"
#include "demandDrivenData.H"
#include "Time.H"
#include "meshOctreeCreator.H"
#include "tetMeshExtractorOctree.H"
#include "meshSurfaceEngine.H"
#include "meshSurfaceMapper.H"
#include "edgeExtractor.H"
#include "meshSurfaceEdgeExtractorNonTopo.H"
#include "surfaceMorpherCells.H"
#include "meshOptimizer.H"
#include "meshSurfaceOptimizer.H"
#include "topologicalCleaner.H"
#include "boundaryLayers.H"
#include "renameBoundaryPatches.H"
#include "checkMeshDict.H"
#include "triSurfacePatchManipulator.H"
#include "refineBoundaryLayers.H"
#include "triSurfaceMetaData.H"
#include "polyMeshGenGeometryModification.H"
#include "surfaceMeshGeometryModification.H"
//#define DEBUG
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * * //
void tetMeshGenerator::createTetMesh()
{
//- create tet Mesh from octree and Delaunay tets
tetMeshExtractorOctree tme(*octreePtr_, meshDict_, mesh_);
tme.createMesh();
}
void tetMeshGenerator::surfacePreparation()
{
//- removes unnecessary cells and morph the boundary
//- such that there is only one boundary face per cell
//- It also checks topology of cells after morphing is performed
do
{
surfaceMorpherCells* cmPtr = new surfaceMorpherCells(mesh_);
cmPtr->morphMesh();
deleteDemandDrivenData(cmPtr);
}
while( topologicalCleaner(mesh_).cleanTopology() );
}
void tetMeshGenerator::mapMeshToSurface()
{
//- calculate mesh surface
meshSurfaceEngine* msePtr = new meshSurfaceEngine(mesh_);
//- map mesh surface on the geometry surface
meshSurfaceMapper(*msePtr, *octreePtr_).mapVerticesOntoSurface();
//- untangle surface faces
meshSurfaceOptimizer(*msePtr, *octreePtr_).untangleSurface();
deleteDemandDrivenData(msePtr);
}
void tetMeshGenerator::extractPatches()
{
edgeExtractor extractor(mesh_, *octreePtr_);
Info << "Extracting edges" << endl;
extractor.extractEdges();
extractor.updateMeshPatches();
}
void tetMeshGenerator::mapEdgesAndCorners()
{
meshSurfaceEdgeExtractorNonTopo(mesh_, *octreePtr_);
}
void tetMeshGenerator::optimiseMeshSurface()
{
meshSurfaceEngine mse(mesh_);
meshSurfaceOptimizer(mse, *octreePtr_).optimizeSurface();
}
void tetMeshGenerator::generateBoundaryLayers()
{
if( meshDict_.found("boundaryLayers") )
{
boundaryLayers bl(mesh_);
const dictionary& bndLayers = meshDict_.subDict("boundaryLayers");
if( bndLayers.found("nLayers") )
{
const label nLayers = readLabel(bndLayers.lookup("nLayers"));
if( nLayers > 0 )
bl.addLayerForAllPatches();
}
else if( bndLayers.found("patchBoundaryLayers") )
{
const dictionary& patchLayers =
bndLayers.subDict("patchBoundaryLayers");
const wordList createLayers = patchLayers.toc();
forAll(createLayers, patchI)
bl.addLayerForPatch(createLayers[patchI]);
}
}
}
void tetMeshGenerator::optimiseFinalMesh()
{
//- final optimisation
bool enforceConstraints(false);
if( meshDict_.found("enforceGeometryConstraints") )
{
enforceConstraints =
readBool(meshDict_.lookup("enforceGeometryConstraints"));
}
meshOptimizer optimizer(mesh_);
if( enforceConstraints )
optimizer.enforceConstraints();
optimizer.optimizeSurface(*octreePtr_);
optimizer.optimizeMeshFV();
optimizer.optimizeLowQualityFaces();
optimizer.optimizeBoundaryLayer(false);
optimizer.untangleMeshFV();
deleteDemandDrivenData(octreePtr_);
mesh_.clearAddressingData();
if( modSurfacePtr_ )
{
polyMeshGenGeometryModification meshMod(mesh_, meshDict_);
//- revert the mesh into the original space
meshMod.revertGeometryModification();
//- delete modified surface mesh
deleteDemandDrivenData(modSurfacePtr_);
}
}
void tetMeshGenerator::projectSurfaceAfterBackScaling()
{
if( !meshDict_.found("anisotropicSources") )
return;
deleteDemandDrivenData(octreePtr_);
octreePtr_ = new meshOctree(*surfacePtr_);
meshOctreeCreator
(
*octreePtr_,
meshDict_
).createOctreeWithRefinedBoundary(20, 30);
//- calculate mesh surface
meshSurfaceEngine mse(mesh_);
//- pre-map mesh surface
meshSurfaceMapper mapper(mse, *octreePtr_);
//- map mesh surface on the geometry surface
mapper.mapVerticesOntoSurface();
optimiseFinalMesh();
}
void tetMeshGenerator::refBoundaryLayers()
{
if( meshDict_.isDict("boundaryLayers") )
{
refineBoundaryLayers refLayers(mesh_);
refineBoundaryLayers::readSettings(meshDict_, refLayers);
refLayers.refineLayers();
labelLongList pointsInLayer;
refLayers.pointsInBndLayer(pointsInLayer);
meshOptimizer opt(mesh_);
opt.lockPoints(pointsInLayer);
opt.untangleBoundaryLayer();
}
}
void tetMeshGenerator::replaceBoundaries()
{
renameBoundaryPatches rbp(mesh_, meshDict_);
}
void tetMeshGenerator::renumberMesh()
{
polyMeshGenModifier(mesh_).renumberMesh();
}
void tetMeshGenerator::generateMesh()
{
try
{
if( controller_.runCurrentStep("templateGeneration") )
{
createTetMesh();
}
if( controller_.runCurrentStep("surfaceTopology") )
{
surfacePreparation();
}
if( controller_.runCurrentStep("surfaceProjection") )
{
mapMeshToSurface();
}
if( controller_.runCurrentStep("patchAssignment") )
{
extractPatches();
}
if( controller_.runCurrentStep("edgeExtraction") )
{
mapEdgesAndCorners();
optimiseMeshSurface();
}
if( controller_.runCurrentStep("boundaryLayerGeneration") )
{
generateBoundaryLayers();
}
if( controller_.runCurrentStep("meshOptimisation") )
{
optimiseFinalMesh();
projectSurfaceAfterBackScaling();
}
if( controller_.runCurrentStep("boundaryLayerRefinement") )
{
refBoundaryLayers();
}
renumberMesh();
replaceBoundaries();
controller_.workflowCompleted();
}
catch(const std::string& message)
{
Info << message << endl;
}
catch(...)
{
WarningIn
(
"void tetMeshGenerator::generateMesh()"
) << "Meshing process terminated!" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from Time
tetMeshGenerator::tetMeshGenerator(const Time& time)
:
runTime_(time),
surfacePtr_(NULL),
modSurfacePtr_(NULL),
meshDict_
(
IOobject
(
"meshDict",
runTime_.system(),
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
octreePtr_(NULL),
mesh_(time),
controller_(mesh_)
{
if( true )
{
checkMeshDict cmd(meshDict_);
}
const fileName surfaceFile = meshDict_.lookup("surfaceFile");
surfacePtr_ = new triSurf(runTime_.path()/surfaceFile);
if( true )
{
//- save meta data with the mesh (surface mesh + its topology info)
triSurfaceMetaData sMetaData(*surfacePtr_);
const dictionary& surfMetaDict = sMetaData.metaData();
mesh_.metaData().add("surfaceFile", surfaceFile, true);
mesh_.metaData().add("surfaceMeta", surfMetaDict, true);
}
if( surfacePtr_->featureEdges().size() != 0 )
{
//- create surface patches based on the feature edges
//- and update the meshDict based on the given data
triSurfacePatchManipulator manipulator(*surfacePtr_);
const triSurf* surfaceWithPatches =
manipulator.surfaceWithPatches(&meshDict_);
//- delete the old surface and assign the new one
deleteDemandDrivenData(surfacePtr_);
surfacePtr_ = surfaceWithPatches;
}
if( meshDict_.found("anisotropicSources") )
{
surfaceMeshGeometryModification surfMod(*surfacePtr_, meshDict_);
modSurfacePtr_ = surfMod.modifyGeometry();
octreePtr_ = new meshOctree(*modSurfacePtr_);
}
else
{
octreePtr_ = new meshOctree(*surfacePtr_);
}
meshOctreeCreator(*octreePtr_, meshDict_).createOctreeBoxes();
generateMesh();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
tetMeshGenerator::~tetMeshGenerator()
{
deleteDemandDrivenData(surfacePtr_);
deleteDemandDrivenData(octreePtr_);
deleteDemandDrivenData(modSurfacePtr_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void tetMeshGenerator::writeMesh() const
{
mesh_.write();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,154 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
tetMeshGenerator
Description
Creates cartesian mesh from the octree
SourceFiles
tetMeshGenerator.C
\*---------------------------------------------------------------------------*/
#ifndef tetMeshGenerator_H
#define tetMeshGenerator_H
#include "polyMeshGen.H"
#include "IOdictionary.H"
#include "workflowControls.H"
//#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class triSurf;
class meshOctree;
class Time;
/*---------------------------------------------------------------------------*\
Class tetMeshGenerator Declaration
\*---------------------------------------------------------------------------*/
class tetMeshGenerator
{
// Private data
//- reference to Time
const Time& runTime_;
//- pointer to the surface
const triSurf* surfacePtr_;
//- pointer to the modified surface mesh
const triSurf* modSurfacePtr_;
//- IOdictionary containing information about cell sizes, etc..
IOdictionary meshDict_;
//- pointer to the octree
meshOctree* octreePtr_;
//- mesh
polyMeshGen mesh_;
//- workflow controller
workflowControls controller_;
// Private member functions
//- create cartesian mesh
void createTetMesh();
//- prepare mesh surface
void surfacePreparation();
//- map mesh to the surface and untangle surface
void mapMeshToSurface();
//- capture edges and corners
void extractPatches();
//- capture edges and corners
void mapEdgesAndCorners();
//- optimise surface mesh
void optimiseMeshSurface();
//- add boundary layers
void generateBoundaryLayers();
//- mesh optimisation
void optimiseFinalMesh();
//- re-project points back on the surface mesh after back-scaling
void projectSurfaceAfterBackScaling();
//- refine boundary layers
void refBoundaryLayers();
//- replace boundaries
void replaceBoundaries();
//- renumber the mesh
void renumberMesh();
//- generate mesh
void generateMesh();
//- Disallow default bitwise copy construct
tetMeshGenerator(const tetMeshGenerator&);
//- Disallow default bitwise assignment
void operator=(const tetMeshGenerator&);
public:
// Constructors
//- Construct from time
tetMeshGenerator(const Time&);
// Destructor
~tetMeshGenerator();
// Member Functions
//- write the mesh
void writeMesh() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,162 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
checkMeshDict
Description
Check whether the meshDict file is set correctly
SourceFiles
checkMeshDict.C
\*---------------------------------------------------------------------------*/
#ifndef checkMeshDict_H
#define checkMeshDict_H
#include "objectRegistry.H"
#include "Time.H"
#include "IOdictionary.H"
#include <map>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class checkMeshDict Declaration
\*---------------------------------------------------------------------------*/
class checkMeshDict
{
//- Reference to the mesh
IOdictionary& meshDict_;
// Private member functions
//- check settings for cell size in meshDict
void checkBasicSettings() const;
//- check patchCellSize entry
void checkPatchCellSize() const;
//- check subsetCellSize entry
void checkSubsetCellSize() const;
//- check local refinement level
void checkLocalRefinementLevel() const;
//- check keepCellsIntersectingPatches entry
void checkKeepCellsIntersectingPatches() const;
//- check removeCellsIntersectingPatches entry
void checkRemoveCellsIntersectingPatches() const;
//- check objectRefinements entry
void checkObjectRefinements() const;
//- check anisotropic sources
void checkAnisotropicSources() const;
//- check surfaceRefinements entry
void checkSurfaceRefinements() const;
//- check edgeMeshRefinements entry
void checkEdgeMeshRefinements() const;
//- check entry for boundary layers
void checkBoundaryLayers() const;
//- check renameBoundary entry
void checkRenameBoundary() const;
//- perform all checks
void checkEntries() const;
//- update patchCellSize entry
void updatePatchCellSize(const std::map<word, wordList>&);
//- update subsetCellSize entry
void updateSubsetCellSize(const std::map<word, wordList>&);
//- update local refinement
void updateLocalRefinement(const std::map<word, wordList>&);
//- check keepCellsIntersectingPatches entry
void updateKeepCellsIntersectingPatches
(
const std::map<word, wordList>&
);
//- check removeCellsIntersectingPatches entry
void updateRemoveCellsIntersectingPatches
(
const std::map<word, wordList>&
);
//- check objectRefinements entry
void updateObjectRefinements(const std::map<word, wordList>&);
//- check entry for boundary layers
void updateBoundaryLayers(const std::map<word, wordList>&);
//- check renameBoundary entry
void updateRenameBoundary
(
const std::map<word, wordList>&,
const std::map<word, word>&
);
public:
// Constructors
//- Construct from IOdictionary
checkMeshDict(IOdictionary& meshDict);
// Destructor
~checkMeshDict();
// Public member functions
//- update meshDict based on modification of patches in the surface
void updateDictionaries
(
const std::map<word, wordList>& patchesForPatch,
const std::map<word, word>& patchTypes,
const bool renamePatches = true
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,85 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "DynList.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// Construct from Istream
template<class T, Foam::label staticSize>
Foam::DynList<T, staticSize>::DynList(Istream& is)
:
UList<T>(),
nextFree_(0)
{
FatalErrorIn
(
"template<class T, Foam::label staticSize>"
"\nFoam::DynList<T, staticSize>::DynList(Istream& is)"
) << "Not implemented" << exit(FatalError);
List<T> helper(is);
nextFree_ = helper.size();
UList<T>::swap(helper);
}
template<class T, Foam::label staticSize>
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::DynList<T, staticSize>& DL
)
{
UList<T> helper(const_cast<T*>(DL.begin()), DL.nextFree_);
os << helper;
return os;
}
template<class T, Foam::label staticSize>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::DynList<T, staticSize>& DL
)
{
FatalErrorIn
(
"template<class T, Foam::label staticSize>"
"\nFoam::Istream& Foam::operator>>"
"(Foam::Istream& is, Foam::DynList<T, staticSize>& DL)"
) << "Not implemented" << exit(FatalError);
is >> static_cast<List<T>&>(DL);
DL.nextFree_ = DL.List<T>::size();
return is;
}
// ************************************************************************* //

View file

@ -1,245 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
DynList
Description
A dynamic list is a 1-D vector of objects of type T which resizes
itself as necessary to accept the new objects. Internal storage
is a compact array and the list can be shrunk to compact storage.
The increase of list size is controlled by three template parameters,
which allows the list storage to either increase by the given increment
or the given multiplier and divider (allowing non-integer multiples).
SourceFiles
DynListI.H
DynList.C
\*---------------------------------------------------------------------------*/
#ifndef DynList_H
#define DynList_H
#include "UList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
template<class T, label staticSize>
class DynList;
template<class T, label staticSize>
Ostream& operator<<
(
Ostream&,
const DynList<T, staticSize>&
);
template<class T, label staticSize>
Istream& operator>>
(
Istream&,
DynList<T, staticSize>&
);
/*---------------------------------------------------------------------------*\
Class DynList Declaration
\*---------------------------------------------------------------------------*/
template<class T, label staticSize = 16>
class DynList
:
public UList<T>
{
// Private data
//- statically allocated data (used for short lists)
T staticData_[staticSize];
//- Number of next free element
label nextFree_;
// Private member functions
//- allocate list size
inline void allocateSize(const label);
//- check if index is inside the scope (used for debugging only)
inline void checkIndex(const label) const;
public:
// Constructors
//- Construct null
inline DynList();
//- Construct given size
explicit inline DynList(const label);
//- Construct from given size and defualt value
explicit inline DynList(const label, const T&);
//- Construct from UList. nextFree_ set to size().
explicit inline DynList(const UList<T>&);
//- Construct from other ListType
template<class ListType>
inline DynList(const ListType&);
//- Copy constructor
inline DynList(const DynList<T, staticSize>&);
//- Construct from Istream. nextFree_ set to size().
explicit DynList(Istream&);
// Destructor
inline ~DynList();
// Member Functions
// Access
//- Size of the active part of the list.
//- Direct over-ride of list size member function
inline label size() const;
//- Number of bytes used by the active part of the list
//- Direct over-ride of list byteSize member function
inline label byteSize() const;
// Edit
//- Reset size of List.
void setSize(const label);
//- Clear the list, i.e. set next free to zero.
// Allocated size does not change
void clear();
//- Shrink the List<T> to the number of elements used
void shrink();
// Member Operators
//- Append an element at the end of the list
inline void append(const T& e);
//- Append an element at the end of the list if it is not yet
//- present in the list (takes linear time)
inline void appendIfNotIn(const T& e);
//- check if the element is in the list (takes linear time)
inline bool contains(const T& e) const;
inline label containsAtPosition(const T& e) const;
//- return a const reference to the last element
inline const T& lastElement() const;
//- Return and remove the last element
inline T removeLastElement();
inline T removeElement(const label i);
//- return a refence to the element. Resize the list if necessary
inline T& newElmt(const label);
//- Return non-const access to an element,
//- resizing the list if necessary
inline T& operator()(const label);
//- return access to an element
inline const T& operator[](const label) const;
inline T& operator[](const label);
//- return forward and reverse circular indices
inline label fcIndex(const label index, const label offset = 1) const;
inline label rcIndex(const label index, const label offset = 1) const;
//- return forward and reverse circular elements
inline const T& fcElement
(
const label index,
const label offset = 1
) const;
inline const T& rcElement
(
const label index,
const label offset = 1
) const;
//- Assignment of all entries to the given value
inline void operator=(const T&);
//- Copy of another list
inline void operator=(const DynList<T, staticSize>&);
//- Copy of another list type
template<class ListType>
inline void operator=(const ListType&);
// IOstream operators
// Write DynList to Ostream.
friend Ostream& operator<< <T, staticSize>
(
Ostream&,
const DynList<T, staticSize>&
);
//- Read from Istream, discarding contents of existing DynList.
friend Istream& operator>> <T, staticSize>
(
Istream&,
DynList<T, staticSize>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DynListI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "DynList.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,405 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::allocateSize(const label s)
{
if( s > UList<T>::size() )
{
T* newData = new T[s];
for(label i=0;i<nextFree_;++i)
newData[i] = this->operator[](i);
T* data = UList<T>::begin();
if( data && (data != staticData_) )
delete [] data;
//UList<T>::reset(newData, s);
this->UList<T>::operator=(UList<T>(newData, s));
}
else if( (s > staticSize) && (s < UList<T>::size()) )
{
T* newData = new T[s];
for(label i=0;i<s;++i)
newData[i] = this->operator[](i);
T* data = UList<T>::begin();
delete [] data;
//UList<T>::reset(newData, s);
this->UList<T>::operator=(UList<T>(newData, s));
}
else if( (s <= staticSize) && (UList<T>::size() > staticSize) )
{
for(label i=0;i<s;++i)
staticData_[i] = UList<T>::operator[](i);
T* data = UList<T>::begin();
if( data && (data != staticData_) )
delete [] data;
//UList<T>::reset(staticData_, staticSize);
this->UList<T>::operator=(UList<T>(staticData_, staticSize));
}
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::checkIndex(const label i) const
{
if( (i < 0) || (i >= nextFree_) )
{
FatalErrorIn
(
"void Foam::DynList<T, label, Offset>::"
"checkIndex(const label i) const"
) << "Index " << i << " is not in range " << 0
<< " and " << nextFree_ << abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
template<class T, Foam::label staticSize>
inline Foam::DynList<T, staticSize>::DynList()
:
UList<T>(staticData_, staticSize),
nextFree_(0)
{}
template<class T, Foam::label staticSize>
inline Foam::DynList<T, staticSize>::DynList(const label s)
:
UList<T>(staticData_, staticSize),
nextFree_(0)
{
setSize(s);
}
template<class T, Foam::label staticSize>
inline Foam::DynList<T, staticSize>::DynList(const label s, const T& val)
:
UList<T>(staticData_, staticSize),
nextFree_(0)
{
setSize(s);
for(label i=0;i<s;++i)
this->operator[](i) = val;
}
template<class T, Foam::label staticSize>
inline Foam::DynList<T, staticSize>::DynList(const UList<T>& ul)
:
UList<T>(staticData_, staticSize),
nextFree_(0)
{
setSize(ul.size());
forAll(ul, i)
this->operator[](i) = ul[i];
}
template<class T, Foam::label staticSize>
template<class ListType>
inline Foam::DynList<T, staticSize>::DynList(const ListType& l)
:
UList<T>(staticData_, staticSize),
nextFree_(0)
{
setSize(l.size());
for(label i=0;i<nextFree_;++i)
this->operator[](i) = l[i];
}
//- Copy construct
template<class T, Foam::label staticSize>
inline Foam::DynList<T, staticSize>::DynList
(
const DynList<T, staticSize>& dl
)
:
UList<T>(staticData_, staticSize),
nextFree_(0)
{
setSize(dl.size());
for(label i=0;i<nextFree_;++i)
this->operator[](i) = dl[i];
}
template<class T, Foam::label staticSize>
inline Foam::DynList<T, staticSize>::~DynList()
{
allocateSize(0);
//UList<T>::reset(NULL, 0);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::size() const
{
return nextFree_;
}
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::byteSize() const
{
if( !contiguous<T>() )
{
FatalErrorIn("DynList<T>::byteSize()")
<< "Cannot return the binary size of a list of "
"non-primitive elements"
<< abort(FatalError);
}
return nextFree_*sizeof(T);
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::setSize(const label s)
{
allocateSize(s);
nextFree_ = s;
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::clear()
{
nextFree_ = 0;
}
template<class T, Foam::label staticSize>
void Foam::DynList<T, staticSize>::shrink()
{
allocateSize(nextFree_);
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::append(const T& e)
{
if( nextFree_ >= UList<T>::size() )
{
const label newSize = 2*UList<T>::size()+2;
allocateSize(newSize);
}
UList<T>::operator[](nextFree_++) = e;
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::appendIfNotIn(const T& e)
{
if( !contains(e) )
append(e);
}
template<class T, Foam::label staticSize>
inline bool Foam::DynList<T, staticSize>::contains(const T& e) const
{
for(label i=0;i<nextFree_;++i)
{
if( UList<T>::operator[](i) == e )
return true;
}
return false;
}
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::containsAtPosition
(
const T& e
) const
{
for(label i=0;i<nextFree_;++i)
{
if( UList<T>::operator[](i) == e )
return i;
}
return -1;
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::lastElement() const
{
return this->operator[](nextFree_-1);
}
template<class T, Foam::label staticSize>
inline T Foam::DynList<T, staticSize>::removeLastElement()
{
if( nextFree_ == 0 )
{
FatalErrorIn
(
"void Foam::DynList<T, staticSize>::remove()"
) << "List is empty" << abort(FatalError);
}
T el = UList<T>::operator[](--nextFree_);
return el;
}
template<class T, Foam::label staticSize>
inline T Foam::DynList<T, staticSize>::removeElement(const label i)
{
if( nextFree_ == 0 )
{
FatalErrorIn
(
"void Foam::DynList<T, staticSize>::remove()"
) << "List is empty" << abort(FatalError);
}
T el = this->operator[](i);
this->operator[](i) = this->operator[](nextFree_-1);
--nextFree_;
return el;
}
template<class T, Foam::label staticSize>
inline T& Foam::DynList<T, staticSize>::newElmt(const label i)
{
return this->operator()(i);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, Foam::label staticSize>
inline T& Foam::DynList<T, staticSize>::operator()(const label i)
{
nextFree_ = Foam::max(nextFree_, i + 1);
if( nextFree_ >= UList<T>::size() )
{
allocateSize(2 * nextFree_+1);
}
return this->operator[](i);
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::operator[](const label i) const
{
# ifdef FULLDEBUG
checkIndex(i);
# endif
return UList<T>::operator[](i);
}
template<class T, Foam::label staticSize>
inline T& Foam::DynList<T, staticSize>::operator[](const label i)
{
# ifdef FULLDEBUG
checkIndex(i);
# endif
return UList<T>::operator[](i);
}
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::fcIndex
(
const label index,
const label offset
) const
{
return (index + offset) % nextFree_;
}
template<class T, Foam::label staticSize>
inline Foam::label Foam::DynList<T, staticSize>::rcIndex
(
const label index,
const label offset
) const
{
return (index + nextFree_ - offset) % nextFree_;
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::fcElement
(
const label index,
const label offset
) const
{
return operator[](fcIndex(index, offset));
}
template<class T, Foam::label staticSize>
inline const T& Foam::DynList<T, staticSize>::rcElement
(
const label index,
const label offset
) const
{
return operator[](rcIndex(index, offset));
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::operator=(const T& t)
{
UList<T>::operator=(t);
}
template<class T, Foam::label staticSize>
inline void Foam::DynList<T, staticSize>::operator=
(
const DynList<T, staticSize>& dl
)
{
allocateSize(dl.size());
nextFree_ = dl.size();
for(label i=0;i<nextFree_;++i)
this->operator[](i) = dl[i];
}
template<class T, Foam::label staticSize>
template<class ListType>
inline void Foam::DynList<T, staticSize>::operator=(const ListType& l)
{
allocateSize(l.size());
nextFree_ = l.size();
for(label i=0;i<nextFree_;++i)
this->operator[](i) = l[i];
}
// ************************************************************************* //

View file

@ -1,71 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "FRWGraph.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, Foam::label width>
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::FRWGraph<T, width>& DL
)
{
os << DL.size() << "(" << endl;
for(register label i=0;i<DL.size();++i)
{
os << width << "(";
for(label j=0;j<width;++j)
os << DL(i, j) << " " << endl;
os << ")" << endl;
}
os << ")";
return os;
}
/*
template<class T, Foam::label width>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::FRWGraph<T, width>& DL
)
{
label size;
T e;
is >> size;
DL.setSize(size);
for(IndexType i=0;i<size;++i)
{
is >> e;
DL[i] = e;
}
return is;
}
*/
// ************************************************************************* //

View file

@ -1,183 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
FRWGraph
Description
This class is an implementation of a graph with the fixed row width.
The implementation is memory efficient.
SourceFiles
FRWGraphI.H
FRWGraph.C
\*---------------------------------------------------------------------------*/
#ifndef FRWGraph_H
#define FRWGraph_H
#include "label.H"
#include "LongList.H"
#include "FixedList.H"
#include "bool.H"
#include "error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
template<class T, label width>
class FRWGraph;
template<class T, label width>
Ostream& operator<<
(
Ostream&,
const FRWGraph<T, width>&
);
template<class T, label width>
Istream& operator>>
(
Istream&,
FRWGraph<T, width>&
);
/*---------------------------------------------------------------------------*\
Class FRWGraph Declaration
\*---------------------------------------------------------------------------*/
template<class T, label width>
class FRWGraph
{
// Private data
//- list containing the data
LongList<T> data_;
//- number of rows
label nRows_;
// Private member functions
//- check index
void checkIndex(const label i, const label j) const;
public:
// Constructors
//- Construct null
inline FRWGraph();
//- Construct given size
explicit inline FRWGraph(const label size);
//- Construct to given size and initialize
explicit inline FRWGraph(const label size, const T& t);
//- Copy contructor
inline FRWGraph(const FRWGraph<T, width>&);
// Destructor
inline ~FRWGraph();
// Member Functions
// Access
//- Returns the number of rows
inline label size() const;
//- Returns the size of a given row (obsolete)
inline label sizeOfRow(const label rowI) const;
// Edit
//- Reset the number of rows
void setSize(const label);
//- Clear the graph
// Allocated size does not change
void clear();
// Member Operators
//- Append a row at the end of the graph
inline void appendFixedList(const FixedList<T, width>& l);
//- Set row with the list
inline void setRow(const label rowI, const FixedList<T, width>& l);
//- check if the element is in the given row (takes linear time)
inline bool contains(const label rowI, const T& e) const;
inline label containsAtPosition(const label rowI, const T& e) const;
//- get and set operators
inline const T& operator()(const label i, const label j) const;
inline T& operator()(const label i, const label j);
//- Assignment operator
inline void operator=(const FRWGraph<T, width>&);
// IOstream operators
// Write FRWGraph to Ostream.
friend Ostream& operator<< <T, width>
(
Ostream&,
const FRWGraph<T, width>&
);
//- Read from Istream, discarding contents of existing FRWGraph.
/* friend Istream& operator>> <T, width>
(
Istream&,
FRWGraph<T, width>&
);
*/
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FRWGraphI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "FRWGraph.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,219 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
template<class T, Foam::label width>
void Foam::FRWGraph<T, width>::checkIndex(const label i, const label j) const
{
if( (i < 0) || (i >= nRows_) )
{
FatalErrorIn
(
"void Foam::FRWGraph<T,width>::"
"checkIndex(const label i, const label j) const"
) << "Row index " << i
<< " is not in range " << 0
<< " and " << nRows_ << abort(FatalError);
}
if( (j < 0) || (j >= width) )
FatalErrorIn
(
"void Foam::FRWGraph<T,width>::"
"checkIndex(const label i, const label j) const"
) << "Column index " << j
<< " is not in range " << 0
<< " and " << width << abort(FatalError);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::FRWGraph()
:
data_(),
nRows_(0)
{}
//- Construct given size
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::FRWGraph
(
const label s
)
:
data_(s * width),
nRows_(s)
{}
//- Construct given size
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::FRWGraph
(
const label s,
const T& t
)
:
data_(s * width, t),
nRows_(s)
{}
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::FRWGraph
(
const FRWGraph<T,width>& ol
)
:
data_(ol.data_),
nRows_(ol.nRows_)
{}
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::~FRWGraph()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label width>
inline Foam::label Foam::FRWGraph<T,width>::size() const
{
return nRows_;
}
template<class T, Foam::label width>
inline Foam::label Foam::FRWGraph<T,width>::sizeOfRow(const label rowI) const
{
return width;
}
template<class T, Foam::label width>
inline void Foam::FRWGraph<T,width>::setSize(const label i)
{
data_.setSize(i * width);
nRows_ = i;
}
template<class T, Foam::label width>
inline void Foam::FRWGraph<T,width>::clear()
{
data_.clear();
nRows_ = 0;
}
template<class T, Foam::label width>
inline void Foam::FRWGraph<T,width>::appendFixedList
(
const FixedList<T, width>& l
)
{
forAll(l, elI)
data_.append(l[elI]);
++nRows_;
}
template<class T, Foam::label width>
inline void Foam::FRWGraph<T,width>::setRow
(
const label rowI,
const FixedList<T, width>& l
)
{
const label start = rowI * width;
forAll(l, elI)
data_[start+elI] = l[elI];
}
template<class T, Foam::label width>
inline bool Foam::FRWGraph<T,width>::contains
(
const label rowI,
const T& e
) const
{
const label start = rowI * width;
for(register label i=0;i<width;++i)
if( data_[start+i] == e )
return true;
return false;
}
template<class T, Foam::label width>
inline Foam::label Foam::FRWGraph<T,width>::containsAtPosition
(
const label rowI,
const T& e
) const
{
const label start = rowI * width;
for(register label i=0;i<width;++i)
if( data_[start+i] == e )
return i;
return -1;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, Foam::label width>
inline const T& Foam::FRWGraph<T,width>::operator()
(
const label i,
const label j
) const
{
#ifdef FULLDEBUG
checkIndex(i, j);
#endif
return data_[i * width + j];
}
template<class T, Foam::label width>
inline T& Foam::FRWGraph<T,width>::operator()
(
const label i, const label j
)
{
#ifdef FULLDEBUG
checkIndex(i, j);
#endif
return data_[i * width + j];
}
template<class T, Foam::label width>
inline void Foam::FRWGraph<T,width>::operator=
(
const FRWGraph<T, width>& l
)
{
data_ = l.data_;
nRows_ = l.nRows_;
}
// ************************************************************************* //

View file

@ -1,87 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
An graph of faces which supports automated output.
\*---------------------------------------------------------------------------*/
#include "cellIOGraph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
cellIOGraph::cellIOGraph(const IOobject& io)
:
regIOobject(io),
VRWGraph()
{}
cellIOGraph::cellIOGraph
(
const IOobject& io,
const label size
)
:
regIOobject(io),
VRWGraph(size)
{}
cellIOGraph::cellIOGraph
(
const IOobject& io,
const VRWGraph& g
)
:
regIOobject(io),
VRWGraph(g)
{}
void cellIOGraph::operator=(const cellIOGraph& rhs)
{
VRWGraph::operator=(rhs);
}
void cellIOGraph::operator=(const VRWGraph& rhs)
{
VRWGraph::operator=(rhs);
}
bool cellIOGraph::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameWithName(cellIOGraph, "cellList");
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,93 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cellIOGraph
Description
A graph of cells which support automated output
SourceFiles
cellIOGraph.C
\*---------------------------------------------------------------------------*/
#ifndef cellIOGraph_H
#define cellIOGraph_H
#include "VRWGraph.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cellIOGraph Declaration
\*---------------------------------------------------------------------------*/
class cellIOGraph
:
public regIOobject,
public VRWGraph
{
public:
//- Runtime type information
TypeName("cellIOGraph");
// Constructors
//- Construct from IOobject
cellIOGraph(const IOobject&);
//- Construct from IOobject and size of cellIOGraph
cellIOGraph(const IOobject&, const label);
//- Construct from IOobject and a VRWGraph
cellIOGraph(const IOobject&, const VRWGraph&);
// Member functions
bool writeData(Ostream&) const;
// Member operators
void operator=(const cellIOGraph&);
void operator=(const VRWGraph&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,87 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
An graph of faces which supports automated output.
\*---------------------------------------------------------------------------*/
#include "faceIOGraph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
faceIOGraph::faceIOGraph(const IOobject& io)
:
regIOobject(io),
VRWGraph()
{}
faceIOGraph::faceIOGraph
(
const IOobject& io,
const label size
)
:
regIOobject(io),
VRWGraph(size)
{}
faceIOGraph::faceIOGraph
(
const IOobject& io,
const VRWGraph& g
)
:
regIOobject(io),
VRWGraph(g)
{}
void faceIOGraph::operator=(const faceIOGraph& rhs)
{
VRWGraph::operator=(rhs);
}
void faceIOGraph::operator=(const VRWGraph& rhs)
{
VRWGraph::operator=(rhs);
}
bool faceIOGraph::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameWithName(faceIOGraph, "faceList");
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,93 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
faceIOGraph
Description
A graph of faces which support automated output
SourceFiles
faceIOGraph.C
\*---------------------------------------------------------------------------*/
#ifndef faceIOGraph_H
#define faceIOGraph_H
#include "VRWGraph.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceIOGraph Declaration
\*---------------------------------------------------------------------------*/
class faceIOGraph
:
public regIOobject,
public VRWGraph
{
public:
//- Runtime type information
TypeName("faceIOGraph");
// Constructors
//- Construct from IOobject
faceIOGraph(const IOobject&);
//- Construct from IOobject and size of faceIOGraph
faceIOGraph(const IOobject&, const label);
//- Construct from IOobject and a VRWGraph
faceIOGraph(const IOobject&, const VRWGraph&);
// Member functions
bool writeData(Ostream&) const;
// Member operators
void operator=(const faceIOGraph&);
void operator=(const VRWGraph&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,120 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
An IODynList of a given type is a List of that type which supports automated
input and output.
\*---------------------------------------------------------------------------*/
#include "IODynList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T, class IndexType>
IODynList<T, IndexType>::IODynList(const IOobject& io)
:
regIOobject(io),
DynList<T, IndexType>()
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
template<class T, class IndexType>
IODynList<T, IndexType>::IODynList
(
const IOobject& io,
const IndexType size
)
:
regIOobject(io),
DynList<T, IndexType>(size)
{}
template<class T, class IndexType>
IODynList<T, IndexType>::IODynList
(
const IOobject& io,
const DynList<T, IndexType>& list
)
:
regIOobject(io),
DynList<T, IndexType>()
{
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
{
readStream(typeName) >> *this;
close();
}
DynList<T, IndexType>::operator=(list);
}
template<class T, class IndexType>
void IODynList<T, IndexType>::operator=
(
const IODynList<T, IndexType>& rhs
)
{
DynList<T, IndexType>::operator=(rhs);
}
template<class T, class IndexType>
void IODynList<T, IndexType>::operator=
(
const DynList<T, IndexType>& rhs
)
{
DynList<T, IndexType>::operator=(rhs);
}
template<class T, class IndexType>
bool IODynList<T, IndexType>::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
IODynList
Description
An IODynList of a given type is a DynList of that type which supports
automated input and output.
SourceFiles
IODynList.C
\*---------------------------------------------------------------------------*/
#ifndef IODynList_H
#define IODynList_H
#include "DynList.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class IODynList Declaration
\*---------------------------------------------------------------------------*/
template<class T, class IndexType=label>
class IODynList
:
public regIOobject,
public DynList<T, IndexType>
{
public:
//- Runtime type information
TypeName("DynList");
// Constructors
//- Construct from IOobject
IODynList(const IOobject&);
//- Construct from IOobject and size of IODynList
IODynList(const IOobject&, const IndexType);
//- Construct from IOobject and a List
IODynList(const IOobject&, const DynList<T, IndexType>&);
// Member functions
bool writeData(Ostream&) const;
// Member operators
void operator=(const IODynList<T, IndexType>&);
void operator=(const DynList<T, IndexType>&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IODynList.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,120 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
An IOLongList of a given type is a list which supports automated
input and output.
\*---------------------------------------------------------------------------*/
#include "IOLongList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T, label Offset>
IOLongList<T, Offset>::IOLongList(const IOobject& io)
:
regIOobject(io),
LongList<T, Offset>()
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
template<class T, label Offset>
IOLongList<T, Offset>::IOLongList
(
const IOobject& io,
const label size
)
:
regIOobject(io),
LongList<T, Offset>(size)
{}
template<class T, label Offset>
IOLongList<T, Offset>::IOLongList
(
const IOobject& io,
const LongList<T, Offset>& list
)
:
regIOobject(io),
LongList<T, Offset>()
{
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
{
readStream(typeName) >> *this;
close();
}
LongList<T, Offset>::operator=(list);
}
template<class T, label Offset>
void IOLongList<T, Offset>::operator=
(
const IOLongList<T, Offset>& rhs
)
{
LongList<T, Offset>::operator=(rhs);
}
template<class T, label Offset>
void IOLongList<T, Offset>::operator=
(
const LongList<T, Offset>& rhs
)
{
LongList<T, Offset>::operator=(rhs);
}
template<class T, label Offset>
bool IOLongList<T, Offset>::writeData(Ostream& os) const
{
return (os << *this).good();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
IOLongList
Description
An IOLongList of a given type is a List of that type which supports
automated input and output.
SourceFiles
IOLongList.C
\*---------------------------------------------------------------------------*/
#ifndef IOLongList_H
#define IOLongList_H
#include "LongList.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class IOLongList Declaration
\*---------------------------------------------------------------------------*/
template<class T, label Offset = 19>
class IOLongList
:
public regIOobject,
public LongList<T, Offset>
{
public:
//- Runtime type information
TypeName("LongList");
// Constructors
//- Construct from IOobject
IOLongList(const IOobject&);
//- Construct from IOobject and size of IOLongList
IOLongList(const IOobject&, const label);
//- Construct from IOobject and a List
IOLongList(const IOobject&, const LongList<T, Offset>&);
// Member functions
bool writeData(Ostream&) const;
// Member operators
void operator=(const IOLongList<T, Offset>&);
void operator=(const LongList<T, Offset>&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IOLongList.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,48 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Declaration of IOLongList ClassNames for IOLists that do not have .C files.
\*---------------------------------------------------------------------------*/
#include "IOLongListInstances.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineCompoundTypeName(IOLongList<label>, labelIOListPMG);
defineCompoundTypeName(IOLongList<point>, pointIOFieldPMG);
//defineCompoundTypeName(IOLongList<face>, faceIOListPMG);
//defineCompoundTypeName(IOLongList<cell>, cellIOListPMG);
//addCompoundToRunTimeSelectionTable(IOLongList<label>, labelIOLongList);
defineTemplateTypeNameAndDebugWithName(labelIOListPMG, "labelList", 0);
defineTemplateTypeNameAndDebugWithName(pointIOFieldPMG, "vectorField", 0);
//defineTemplateTypeNameAndDebugWithName(faceIOListPMG, "faceList", 0);
//defineTemplateTypeNameAndDebugWithName(cellIOListPMG, "cellList", 0);
}
// ************************************************************************* //

View file

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Type
IOLongList
Description
Definitions of output classes for mesh data
\*---------------------------------------------------------------------------*/
#ifndef IOLongListInstances_H
#define IOLongListInstances_H
#include "face.H"
#include "cell.H"
#include "point.H"
#include "IOLongList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOLongList<point> pointIOFieldPMG;
typedef IOLongList<face> faceIOListPMG;
typedef IOLongList<cell> cellIOListPMG;
typedef IOLongList<label> labelIOListPMG;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,110 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
cellListPMG
Description
This is a container with additional size to prevent re-allocation
every time it is resized
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cellListPMG_H
#define cellListPMG_H
#include "cellList.H"
#include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class cellListPMG
: public cellList
{
// Private data
//- number of used elements
label nElmts_;
// Disallow bitwise assignment
void operator=(const cellListPMG&);
cellListPMG(const cellListPMG&);
// Disallow transfer from cellList
void transfer(cellList&);
public:
// Constructors
//- null construct
inline cellListPMG();
// Destructor
inline ~cellListPMG();
// Member functions
//- return the number of used elements
inline label size() const;
//- set the number of used elements
inline void setSize(const label nElmts);
//- set the size to zero
inline void clear();
//- add a cell at the end of the list
inline void append(const cell&);
//- return an element with bound checking
inline cell& newElmt(const label);
// Member operators
inline void operator=(const cellList&);
friend inline Ostream& operator<<(Ostream&, const cellListPMG&);
friend inline Istream& operator>>(Istream&, cellListPMG&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "cellListPMGI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,131 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "SubList.H"
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Constructors
inline cellListPMG::cellListPMG()
:
cellList(),
nElmts_(0)
{
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Destructor
inline cellListPMG::~cellListPMG()
{
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline label cellListPMG::size() const
{
return nElmts_;
}
inline void cellListPMG::setSize(const label nElmts)
{
if( nElmts >= cellList::size() )
{
if( cellList::size() != 0 )
{
Info << "Resizing cells!" << endl;
cellList copy(label(1.5*nElmts));
for(label i=0;i<nElmts_;++i)
copy[i].transfer(this->operator[](i));
cellList::transfer(copy);
}
else
{
cellList::setSize(label(1.5*nElmts));
}
}
nElmts_ = nElmts;
}
inline void cellListPMG::clear()
{
nElmts_ = 0;
}
inline void cellListPMG::append(const cell& c)
{
const label i = nElmts_;
setSize(i+1);
this->operator[](i) = c;
}
inline cell& cellListPMG::newElmt(const label cI)
{
setSize(cI+1);
return this->operator[](cI);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void cellListPMG::operator=(const cellList& cls)
{
setSize(cls.size());
forAll(cls, cI)
this->operator[](cI) = cls[cI];
}
inline Ostream& operator<<(Ostream& os, const cellListPMG& cls)
{
SubList<cell> c(cls, cls.nElmts_, 0);
os << c;
return os;
}
inline Istream& operator>>(Istream& is, cellListPMG& cls)
{
cellList& cells = static_cast<cellList&>(cls);
is >> cells;
cls.nElmts_ = cells.size();
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,57 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
edgeLongList
Description
This is a typedef for LongList<edge>
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef edgeLongList_H
#define edgeLongList_H
#include "edge.H"
#include "LongList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef LongList<edge> edgeLongList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,39 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Declaration of IODynListHP ClassNames for IOLists that do not have .C files.
\*---------------------------------------------------------------------------*/
#include "faceListPMG.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameWithName(faceListPMG, "faceList");
}
// ************************************************************************* //

View file

@ -1,123 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
faceListPMG
Description
This is a container with additional size to prevent re-allocation
every time it is resized
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faceListPMG_H
#define faceListPMG_H
#include "regIOobject.H"
#include "faceList.H"
#include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class faceListPMG
: public regIOobject,
public faceList
{
// Private data
//- number of used elements
label nElmts_;
// Disallow bitwise assignment
void operator=(const faceListPMG&);
faceListPMG(const faceListPMG&);
// Disallow transfer from faceList
void transfer(faceList&);
public:
TypeName("faceList");
// Constructors
//- construct from IOobject
inline faceListPMG(const IOobject&);
//- construct from IOobject and size
inline faceListPMG(const IOobject&, const label);
//- construct from IOobject and faceList
inline faceListPMG(const IOobject&, const faceList&);
// Destructor
inline ~faceListPMG();
// Member functions
//- return the number of used elements
inline label size() const;
//- set the number of used elements
inline void setSize(const label nElmts);
//- set the size to zero
inline void clear();
//- add a face at the end of the list
inline void append(const face&);
//- return an element with bound checking
inline face& newElmt(const label);
//- read/write the list onto disk
inline bool writeData(Ostream&) const;
// Member operators
inline void operator=(const faceList&);
friend inline Ostream& operator<<(Ostream&, const faceListPMG&);
friend inline Istream& operator>>(Istream&, faceListPMG&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "faceListPMGI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,153 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "SubList.H"
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Constructors
inline faceListPMG::faceListPMG(const IOobject& io)
:
regIOobject(io),
faceList(readStream(typeName)),
nElmts_(faceList::size())
{
}
inline faceListPMG::faceListPMG(const IOobject& io, const label s)
:
regIOobject(io),
faceList(s),
nElmts_(s)
{
}
inline faceListPMG::faceListPMG(const IOobject& io, const faceList& fcs)
:
regIOobject(io),
faceList(fcs),
nElmts_(fcs.size())
{
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Destructor
inline faceListPMG::~faceListPMG()
{
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline label faceListPMG::size() const
{
return nElmts_;
}
inline void faceListPMG::setSize(const label nElmts)
{
if( nElmts >= faceList::size() )
{
if( faceList::size() != 0 )
{
Info << "Resizing faces!" << endl;
faceList copy(label(1.5*nElmts));
for(label i=0;i<nElmts_;++i)
copy[i].transfer(this->operator[](i));
faceList::transfer(copy);
}
else
{
faceList::setSize(label(1.5*nElmts));
}
}
nElmts_ = nElmts;
}
inline void faceListPMG::clear()
{
nElmts_ = 0;
}
inline void faceListPMG::append(const face& f)
{
const label i = nElmts_;
setSize(i+1);
this->operator[](i) = f;
}
inline face& faceListPMG::newElmt(const label fI)
{
setSize(fI+1);
return this->operator[](fI);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline bool faceListPMG::writeData(Ostream& os) const
{
return (os << *this).good();
}
inline void faceListPMG::operator=(const faceList& fcs)
{
setSize(fcs.size());
forAll(fcs, fI)
this->operator[](fI) = fcs[fI];
}
inline Ostream& operator<<(Ostream& os, const faceListPMG& fcs)
{
SubList<face> f(fcs, fcs.nElmts_, 0);
os << f;
return os;
}
inline Istream& operator>>(Istream& is, faceListPMG& fcs)
{
faceList& faces = static_cast<faceList&>(fcs);
is >> faces;
fcs.nElmts_ = faces.size();
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,57 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
labelLongList
Description
This is a typedef for LongList<label>
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef labelLongList_H
#define labelLongList_H
#include "label.H"
#include "LongList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef LongList<label> labelLongList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,39 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Declaration of IODynListHP ClassNames for IOLists that do not have .C files.
\*---------------------------------------------------------------------------*/
#include "pointFieldPMG.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameWithName(pointFieldPMG, "vectorField");
}
// ************************************************************************* //

View file

@ -1,130 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
pointFieldPMG
Description
This is a container with additional size to prevent re-allocation
every time it is resized
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef pointFieldPMG_H
#define pointFieldPMG_H
#include "regIOobject.H"
#include "pointField.H"
#include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class pointFieldPMG
: public regIOobject,
public pointField
{
// Private data
//- number of used elements
label nElmts_;
// Disallow bitwise assignment
void operator=(const pointFieldPMG&);
pointFieldPMG(const pointFieldPMG&);
// Disallow transfer from pointField
void transfer(pointField&);
public:
// Declare type name
TypeName("vectorField");
// Constructors
//- construct from IOobject
inline pointFieldPMG(const IOobject&);
//- construct from IOobject and size
inline pointFieldPMG(const IOobject&, const label);
//- construct from IOobject and pointField
inline pointFieldPMG(const IOobject&, const pointField&);
// Destructor
inline ~pointFieldPMG();
// Member functions
//- return the number of used elements
inline label size() const;
//- set the number of used elements
inline void setSize(const label nElmts);
//- reserve the memory for the specified number of elements
//- the request is ignored if the specified value is smaller than
//- the current number of elements
//- does not change the size
inline void reserve(const label capacity);
//- set the size to zero
inline void clear();
//- add a point at the end of the list
inline void append(const point&);
//- return an element with bound checking
inline point& newElmt(const label);
//- read/write the list onto disk
inline bool writeData(Ostream&) const;
// Member operators
inline void operator=(const pointField&);
friend inline Ostream& operator<<(Ostream&, const pointFieldPMG&);
friend inline Istream& operator>>(Istream&, pointFieldPMG&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointFieldPMGI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,146 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "SubList.H"
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Constructors
inline pointFieldPMG::pointFieldPMG(const IOobject& io)
:
regIOobject(io),
pointField(readStream(typeName)),
nElmts_(pointField::size())
{
close();
}
inline pointFieldPMG::pointFieldPMG(const IOobject& io, const label s)
:
regIOobject(io),
pointField(s),
nElmts_(s)
{}
inline pointFieldPMG::pointFieldPMG(const IOobject& io, const pointField& pts)
:
regIOobject(io),
pointField(pts),
nElmts_(pts.size())
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Destructor
inline pointFieldPMG::~pointFieldPMG()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline label pointFieldPMG::size() const
{
return nElmts_;
}
inline void pointFieldPMG::setSize(const label nElmts)
{
if( nElmts >= pointField::size() )
{
Info << "Resizing points!" << endl;
pointField::setSize(label(1.5*nElmts)+1);
}
nElmts_ = nElmts;
}
inline void pointFieldPMG::reserve(const label capacity)
{
if( capacity > size() )
this->setSize(capacity);
}
inline void pointFieldPMG::clear()
{
nElmts_ = 0;
}
inline void pointFieldPMG::append(const point& p)
{
const label i = nElmts_;
setSize(i+1);
this->operator[](i) = p;
}
inline point& pointFieldPMG::newElmt(const label pI)
{
setSize(pI+1);
return this->operator[](pI);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline bool pointFieldPMG::writeData(Ostream& os) const
{
return (os << *this).good();
}
inline void pointFieldPMG::operator=(const pointField& pts)
{
setSize(pts.size());
forAll(pts, pI)
this->operator[](pI) = pts[pI];
}
inline Ostream& operator<<(Ostream& os, const pointFieldPMG& pts)
{
SubList<point> p(pts, pts.nElmts_, 0);
os << p;
return os;
}
inline Istream& operator>>(Istream& is, pointFieldPMG& pts)
{
pointField& points = static_cast<pointField&>(pts);
is >> points;
pts.nElmts_ = points.size();
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,391 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "LongList.H"
#include "Ostream.H"
#include "token.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::writeEntry(Ostream& os) const
{
if
(
size() &&
token::compound::isCompound
(
"LongList<" + word(pTraits<T>::typeName) + '>'
)
)
{
os << word("LongList<" + word(pTraits<T>::typeName) + '>') << " ";
}
os << *this;
}
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::writeEntry
(
const word& keyword,
Ostream& os
) const
{
os.writeKeyword(keyword);
writeEntry(os);
os << token::END_STATEMENT << endl;
}
template<class T, Foam::label Offset>
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::LongList<T, Offset>& DL
)
{
if( (os.format() == IOstream::ASCII) || !contiguous<T>() )
{
if( DL.size() < 15 )
{
// Write size of list and start contents delimiter
os << DL.size() << token::BEGIN_LIST;
// Write list contents
forAll(DL, i)
{
if( i != 0 ) os << token::SPACE;
os << DL[i];
}
// Write end of contents delimiter
os << token::END_LIST;
}
else
{
// Write size of list and start contents delimiter
os << nl << DL.size() << nl << token::BEGIN_LIST;
// Write list contents
forAll(DL, i)
{
os << nl << DL[i];
}
// Write end of contents delimiter
os << nl << token::END_LIST << nl;
}
}
else
{
os << nl << DL.nextFree_ << nl;
if( DL.nextFree_ )
{
const label blockSize = 1<<DL.shift_;
label currBlock(0);
label currPos(0);
while( currPos < DL.nextFree_ )
{
const label bs =
Foam::min(DL.nextFree_ - currPos, blockSize);
os.write
(
reinterpret_cast<const char*>(DL.dataPtr_[currBlock]),
bs * sizeof(T)
);
currPos += bs;
++currBlock;
}
}
}
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const LongList&)");
return os;
}
template<class T, Foam::label Offset>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::LongList<T, Offset>& DL
)
{
// Anull list
DL.setSize(0);
is.fatalCheck("operator>>(Istream&, LongList<T, Offset>&)");
token firstToken(is);
is.fatalCheck
(
"operator>>(Istream&, LongList<T, Offset>&) : reading first token"
);
if( firstToken.isLabel() )
{
const label size = firstToken.labelToken();
// Set list length to that read
DL.setSize(size);
// Read list contents depending on data format
if( (is.format() == IOstream::ASCII) || !contiguous<T>() )
{
// Read beginning of contents
char listDelimiter = is.readBeginList("List");
if( size == 0 )
{
if( listDelimiter != token::BEGIN_LIST )
{
WarningIn
(
"template<class T, Foam::label Offset>"
"Foam::Istream& Foam::operator>>"
"("
"Foam::Istream& ,"
"Foam::LongList<T, Offset>& DL"
")"
) << "Missing ( after 0" << endl;
return is;
}
listDelimiter = is.readEndList("List");
if( listDelimiter != token::END_LIST )
{
WarningIn
(
"template<class T, Foam::label Offset>"
"Foam::Istream& Foam::operator>>"
"("
"Foam::Istream& ,"
"Foam::LongList<T, Offset>& DL"
")"
) << "Missing ) after 0(" << endl;
}
return is;
}
if( listDelimiter == token::BEGIN_LIST )
{
for(register label i=0;i<size;++i)
{
is >> DL[i];
is.fatalCheck
(
"operator>>(Istream&, List<T>&) : reading entry"
);
}
}
else
{
T element;
is >> element;
is.fatalCheck
(
"operator>>(Istream&, List<T>&) : "
"reading the single entry"
);
for(register label i=0;i<size;++i)
{
DL[i] = element;
}
}
// Read end of contents
is.readEndList("List");
}
else
{
const label blockSize = (1<<DL.shift_);
label currBlock(0);
label currPos(0);
while( currPos < size )
{
const label bs = Foam::min(size - currPos, blockSize);
is.read
(
reinterpret_cast<char*>(DL.dataPtr_[currBlock]),
bs * sizeof(T)
);
currPos += bs;
++currBlock;
}
is.fatalCheck
(
"operator>>(Istream&, LongList<T, Offset>&)"
": reading the binary block"
);
}
}
else
{
FatalIOErrorIn("operator>>(Istream&, LongList<T, Offset>&)", is)
<< "incorrect first token, expected <int>, found "
<< firstToken.info()
<< exit(FatalIOError);
}
return is;
}
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
{
is.fatalCheck("appendFromStream(Istream& is)");
token firstToken(is);
is.fatalCheck
(
"appendFromStream(Istream& is) : reading first token"
);
if( firstToken.isLabel() )
{
const label size = firstToken.labelToken();
if( size == 0 )
{
Pout << "Appending empty stream" << endl;
return;
}
label origSize(this->size());
// Set list length to that read
setSize(origSize+size);
// Read list contents depending on data format
if( (is.format() == IOstream::ASCII) || !contiguous<T>() )
{
// Read beginning of contents
char listDelimiter = is.readBeginList("List");
if( listDelimiter == token::BEGIN_LIST )
{
for(register label i=0;i<size;++i)
{
is >> this->operator[](origSize);
++origSize;
is.fatalCheck
(
"appendFromStream(Istream& is) : reading entry"
);
}
}
else
{
T element;
is >> element;
is.fatalCheck
(
"appendFromStream(Istream& is) : "
"reading the single entry"
);
for(register label i=0;i<size;++i)
{
this->operator[](origSize) = element;
++origSize;
}
}
// Read end of contents
is.readEndList("List");
}
else
{
List<T> buf(size);
is.read(reinterpret_cast<char*>(buf.begin()), size * sizeof(T));
forAll(buf, i)
this->operator[](origSize++) = buf[i];
/*const label blockSize = 1<<shift_;
Info << "nextFree_ " << nextFree_ << endl;
//- append elements by reading binary block
while( origSize < nextFree_ )
{
const label currBlock = origSize >> shift_;
const label currPos = origSize & mask_;
Info << "Orig size " << origSize
<< nl << "currBlock " << currBlock
<< nl << "currPos " << currPos << endl;
T* data = &dataPtr_[currBlock][currPos];
label bs = Foam::min(nextFree_-origSize, blockSize);
bs = Foam::min(blockSize - currPos, bs);
Info << "bs " << bs << endl;
is.read(reinterpret_cast<char*>(data), bs * sizeof(T));
origSize += bs;
} */
is.fatalCheck
(
"appendFromStream(Istream& is)"
": reading the binary block"
);
}
}
else
{
FatalIOErrorIn("appendFromStream(Istream& is)", is)
<< "incorrect first token, expected <int>, found "
<< firstToken.info()
<< exit(FatalIOError);
}
}
// ************************************************************************* //

View file

@ -1,242 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
LongList
Description
A dynamic list is a 1-D vector of objects of type T which resizes
itself as necessary to accept the new objects. Internal storage
is a 2-D graph with a fixed size of the chunks used to store the data.
This way the data does not get copied every time array is resized, but
only the pointers to the chunks of data.
SourceFiles
LongListI.H
LongList.C
\*---------------------------------------------------------------------------*/
#ifndef LongList_H
#define LongList_H
#include "label.H"
#include "bool.H"
#include "IOstreams.H"
#include "error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * Forward declaration of template friend fuctions * * * * * * * //
template<class T, label Offset>
class LongList;
template<class T, label Offset>
Ostream& operator<<
(
Ostream&,
const LongList<T, Offset>&
);
template<class T, label Offset>
Istream& operator>>
(
Istream&,
LongList<T, Offset>&
);
/*---------------------------------------------------------------------------*\
Class LongList Declaration
\*---------------------------------------------------------------------------*/
template<class T, label Offset = 19>
class LongList
{
// Private data
//- number of allocated elements
label N_;
//- number of elements in the list
label nextFree_;
//- number of used blocks of data
label numBlocks_;
//- maximum number of blocks that can be allocated
//- without reallocating the list containing pointers
//- to the chunks of data
label numAllocatedBlocks_;
//- size of blocks is calculated by powers of 2
//- and therefore the access can be done using shift and mask
label shift_;
label mask_;
//- array of pointers to the blocks of data, each of the size WIDTH
T** dataPtr_;
// Private member functions
//- check index
void checkIndex(const label i) const;
//- initialize width and mask
void initializeParameters();
//- Allocate memory for the list
void allocateSize(const label);
//- delete all elements
void clearOut();
public:
// Constructors
//- Construct null
inline LongList();
//- Construct given size
explicit inline LongList(const label size);
//- Construct to given size and initialize
explicit inline LongList(const label size, const T& t);
//- Copy contructor
inline LongList(const LongList<T, Offset>&);
// Destructor
inline ~LongList();
// Member Functions
// Access
//- Size of the active part of the list.
inline label size() const;
//- Return the binary size in number of characters of the UList
// if the element is a primitive type
// i.e. contiguous<T>() == true
inline label byteSize() const;
// Edit
//- Reset size of List.
void setSize(const label);
//- Clear the list, i.e. set next free to zero.
// Allocated size does not change
void clear();
//- Shrink the list to the number of elements used
inline LongList<T, Offset>& shrink();
//- transfer the list from another one without allocating it
inline void transfer(LongList<T, Offset>&);
// Member Operators
//- Append an element at the end of the list
inline void append(const T& e);
//- Append an element at the end of the list if it is not yet
//- present in the list (takes linear time)
inline void appendIfNotIn(const T& e);
//- check if the element is in the list (takes linear time)
inline bool contains(const T& e) const;
inline label containsAtPosition(const T& e) const;
//- Return and remove the element
inline T remove(const label i);
inline T removeLastElement();
//- get and set operators
inline const T& operator[](const label i) const;
inline T& operator[](const label i);
//- Return non-const access to an element,
// resizing the list if necessary
inline T& operator()(const label);
//- return a non-const access to an element,
// resize the list if necessary
inline T& newElmt(const label);
//- Assignment of all entries to the given value
inline void operator=(const T&);
//- Assignment operator
inline void operator=(const LongList<T, Offset>&);
// IOstream operators
//- Read from stream and append to the current content
void appendFromStream(Istream&);
//- Write as a dictionary entry.
void writeEntry(Ostream& os) const;
//- Write as a dictionary entry with keyword.
void writeEntry(const word& keyword, Ostream& os) const;
// Write LongList to Ostream.
friend Ostream& operator<< <T, Offset>
(
Ostream&,
const LongList<T, Offset>&
);
//- Read from Istream, discarding contents of existing LongList.
friend Istream& operator>> <T, Offset>
(
Istream&,
LongList<T, Offset>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "LongListI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "LongList.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,392 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "contiguous.H"
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::checkIndex(const label i) const
{
if( (i < 0) || (i >= nextFree_) )
{
FatalErrorIn
(
"void Foam::LongList<T, label>::"
"checkIndex(const label i) const"
) << "Index " << i << " is not in range " << 0
<< " and " << nextFree_ << abort(FatalError);
}
}
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::initializeParameters()
{
unsigned int t = sizeof(T);
label it(0);
while( t > 1 )
{
t >>= 1;
++it;
}
shift_ = Foam::max(10, Offset - it);
mask_ = 1<<shift_;
mask_ -= 1;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::allocateSize(const label s)
{
if( s == 0 )
{
clearOut();
return;
}
else if( s < 0 )
{
FatalErrorIn
(
"template<class T, Foam::label Offset>\n"
"inline void Foam::LongList<T, Offset>::allocateSize(const label)"
) << "Negative size requested." << abort(FatalError);
}
const label numblock1 = ((s-1)>>shift_) + 1;
const label blockSize = 1<<shift_;
if( numblock1 < numBlocks_ )
{
for(register label i=numblock1;i<numBlocks_;++i)
delete [] dataPtr_[i];
}
else if( numblock1 > numBlocks_ )
{
if( numblock1 >= numAllocatedBlocks_ )
{
do
{
numAllocatedBlocks_ += 64;
} while( numblock1 > numAllocatedBlocks_ );
T** dataptr1 = new T*[numAllocatedBlocks_];
for(register label i=0;i<numBlocks_;++i)
dataptr1[i] = dataPtr_[i];
if( dataPtr_ )
delete [] dataPtr_;
dataPtr_ = dataptr1;
}
for(register label i=numBlocks_;i<numblock1;++i)
dataPtr_[i] = new T[blockSize];
}
numBlocks_ = numblock1;
N_ = numBlocks_ * blockSize;
}
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::clearOut()
{
for(register label i=0;i<numBlocks_;++i)
delete [] dataPtr_[i];
if( dataPtr_ )
{
delete [] dataPtr_;
dataPtr_ = NULL;
}
N_ = 0;
numBlocks_ = 0;
numAllocatedBlocks_ = 0;
nextFree_ = 0;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList()
:
N_(0),
nextFree_(0),
numBlocks_(0),
numAllocatedBlocks_(0),
shift_(),
mask_(),
dataPtr_(NULL)
{
initializeParameters();
}
//- Construct given size
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const label s)
:
N_(0),
nextFree_(0),
numBlocks_(0),
numAllocatedBlocks_(0),
shift_(),
mask_(),
dataPtr_(NULL)
{
initializeParameters();
setSize(s);
}
//- Construct given size
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const label s, const T& t)
:
N_(0),
nextFree_(0),
numBlocks_(0),
numAllocatedBlocks_(0),
shift_(),
mask_(),
dataPtr_(NULL)
{
initializeParameters();
setSize(s);
*this = t;
}
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const LongList<T, Offset>& ol)
:
N_(0),
nextFree_(0),
numBlocks_(0),
numAllocatedBlocks_(0),
shift_(ol.shift_),
mask_(ol.mask_),
dataPtr_(NULL)
{
*this = ol;
}
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::~LongList()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label Offset>
inline Foam::label Foam::LongList<T, Offset>::size() const
{
return nextFree_;
}
template<class T, Foam::label Offset>
inline Foam::label Foam::LongList<T, Offset>::byteSize() const
{
if( !contiguous<T>() )
{
FatalErrorIn("LongList<T, Offset>::byteSize()")
<< "Cannot return the binary size of a list of "
"non-primitive elements"
<< abort(FatalError);
}
return nextFree_*sizeof(T);
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::setSize(const label i)
{
allocateSize(i);
nextFree_ = i;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::clear()
{
nextFree_ = 0;
}
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>&
Foam::LongList<T, Offset>::shrink()
{
setSize(nextFree_);
return *this;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::transfer(LongList<T, Offset>& ol)
{
clearOut();
dataPtr_ = ol.dataPtr_;
N_ = ol.N_;
nextFree_ = ol.nextFree_;
numBlocks_ = ol.numBlocks_;
numAllocatedBlocks_ = ol.numAllocatedBlocks_;
shift_ = ol.shift_;
mask_ = ol.mask_;
ol.dataPtr_ = NULL;
ol.N_ = 0;
ol.nextFree_ = 0;
ol.numBlocks_ = 0;
ol.numAllocatedBlocks_ = 0;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::append(const T& e)
{
if( nextFree_ >= N_ )
{
allocateSize(nextFree_+1);
}
operator[](nextFree_++) = e;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::appendIfNotIn(const T& e)
{
if( !contains(e) )
append(e);
}
template<class T, Foam::label Offset>
inline bool Foam::LongList<T, Offset>::contains(const T& e) const
{
for(register label i=0;i<nextFree_;++i)
if( (*this)[i] == e )
return true;
return false;
}
template<class T, Foam::label Offset>
inline Foam::label Foam::LongList<T, Offset>::containsAtPosition
(
const T& e
) const
{
for(register label i=0;i<nextFree_;++i)
if( (*this)[i] == e )
return i;
return -1;
}
template<class T, Foam::label Offset>
inline T Foam::LongList<T, Offset>::remove(const label i)
{
if( nextFree_ == 0 )
{
FatalErrorIn
(
"void Foam::LongList<T, Offset>::remove()"
) << "List is empty" << abort(FatalError);
}
T el = operator[](i);
operator[](i) = operator[](nextFree_-1);
--nextFree_;
return el;
}
template<class T, Foam::label Offset>
inline T Foam::LongList<T, Offset>::removeLastElement()
{
if( nextFree_ == 0 )
{
FatalErrorIn
(
"void Foam::LongList<T, Offset>::remove()"
) << "List is empty" << abort(FatalError);
}
T lastEl = operator[](nextFree_-1);
--nextFree_;
return lastEl;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, Foam::label Offset>
inline const T& Foam::LongList<T, Offset>::operator[](const label i) const
{
#ifdef FULLDEBUG
checkIndex(i);
#endif
return dataPtr_[i>>shift_][i&mask_];
}
template<class T, Foam::label Offset>
inline T& Foam::LongList<T, Offset>::operator[](const label i)
{
#ifdef FULLDEBUG
checkIndex(i);
#endif
return dataPtr_[i>>shift_][i&mask_];
}
template<class T, Foam::label Offset>
inline T& Foam::LongList<T, Offset>::operator()(const label i)
{
if( i >= nextFree_ )
setSize(i+1);
return operator[](i);
}
template<class T, Foam::label Offset>
inline T& Foam::LongList<T, Offset>::newElmt(const label i)
{
return operator()(i);
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::operator=(const T& t)
{
for(register label i=0;i<nextFree_;++i)
operator[](i) = t;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::operator=(const LongList<T, Offset>& l)
{
setSize(l.size());
for(register label i=0;i<l.nextFree_;++i)
operator[](i) = l[i];
}
// ************************************************************************* //

View file

@ -1,108 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VRWGraph.H"
#include "token.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::VRWGraph& DL
)
{
os << DL.size() << nl << token::BEGIN_LIST;
for(register label i=0;i<DL.size();++i)
{
os << nl << DL.sizeOfRow(i) << token::BEGIN_LIST;
for(label j=0;j<DL.sizeOfRow(i);++j)
{
if( j > 0 ) os << token::SPACE;
os << DL(i, j);
}
os << token::END_LIST;
}
os << nl << token::END_LIST;
return os;
}
/*
template<class T, Foam::label width>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::VRWGraph<T, width>& DL
)
{
label size;
T e;
is >> size;
DL.setSize(size);
for(IndexType i=0;i<size;++i)
{
is >> e;
DL[i] = e;
}
return is;
}
*/
void Foam::VRWGraph::optimizeMemoryUsage()
{
labelLongList newPosForNode(data_.size());
label pos(0), nElements;
nElements = data_.size();
for(label elI=0;elI<nElements;++elI)
if( data_[elI] != FREEENTRY )
{
newPosForNode[elI] = pos++;
}
else
{
newPosForNode[elI] = -1;
}
//- create new data
for(label elI=0;elI<nElements;++elI)
if( (newPosForNode[elI] != -1) && (newPosForNode[elI] < elI) )
data_[newPosForNode[elI]] = data_[elI];
data_.setSize(pos);
//- renumber rows
nElements = rows_.size();
for(label rowI=0;rowI<nElements;++rowI)
if( rows_[rowI].start() != INVALIDROW )
rows_[rowI].start() = newPosForNode[rows_[rowI].start()];
}
// ************************************************************************* //

View file

@ -1,285 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
VRWGraph
Description
This class is an implementation of a graph with variable column width.
The imoplementation is memory efficient.
SourceFiles
VRWGraphI.H
VRWGraph.C
\*---------------------------------------------------------------------------*/
#ifndef VRWGraph_H
#define VRWGraph_H
#include "labelLongList.H"
#include "graphRow.H"
#include "DynList.H"
#include "bool.H"
#include "error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class VRWGraphModifier;
class rowElement
{
// Private data
//- starting element of the row
label start_;
//- number of elements in the row
label size_;
public:
inline rowElement()
:
start_(),
size_()
{}
inline rowElement(const label i, const label j)
:
start_(i),
size_(j)
{}
inline ~rowElement()
{}
inline label start() const
{
return start_;
}
inline label& start()
{
return start_;
}
inline label size() const
{
return size_;
}
inline label& size()
{
return size_;
}
};
/*---------------------------------------------------------------------------*\
Class VRWGraph Declaration
\*---------------------------------------------------------------------------*/
class VRWGraph
{
// Private data
//- list containing data
labelLongList data_;
//- number of rows
LongList<rowElement> rows_;
// Private member functions
//- check index
inline void checkIndex(const label i, const label j) const;
// Enumerators
enum typeOfEntries
{
NONE = 0,
INVALIDROW=-10,
FREEENTRY=-11,
FREESTART=-12
};
public:
// Friend classes
friend class VRWGraphSMPModifier;
// Constructors
//- Construct null
inline VRWGraph();
//- Construct given number of rows
explicit inline VRWGraph(const label size);
//- Construct given number of rows and row size
explicit inline VRWGraph
(
const label nRows,
const label nColumnsInRow
);
//- Construct to given number of rows, row size and initialize
explicit inline VRWGraph
(
const label nRows,
const label nColumnsInRow,
const label t
);
//- Copy contructor
inline VRWGraph(const VRWGraph&);
// Destructor
inline ~VRWGraph();
// Member Functions
// Access
//- Returns the number of rows
inline label size() const;
//- Returns the number of elements in the given row
inline label sizeOfRow(const label rowI) const;
// Edit
//- Reset the number of rows
inline void setSize(const label);
//- Reset the number of rows. The second argument specifies
//- the reserved column width
inline void setSizeAndColumnWidth
(
const label newNumRows,
const label rcWidth
);
//- Set the number of rows and the size of each row
template<class ListType>
inline void setSizeAndRowSize(const ListType&);
//- Reset the size of the given row
inline void setRowSize(const label rowI, const label newSize);
//- Clear the graph
inline void clear();
// Member Operators
//- Append a list as a row at the end of the graph
template<class ListType>
inline void appendList(const ListType& l);
//- Append an element to the given row
inline void append(const label rowI, const label);
//- Append an element to the given row if it does not exist there
inline void appendIfNotIn(const label rowI, const label);
//- Set row with the list
template<class ListType>
inline void setRow(const label rowI, const ListType& l);
//- merge graphs with the identical number of rows
//- into a single one. Use for SMP parallelisation
inline void mergeGraphs(const List<VRWGraph>& graphParts);
//- set the graph to the reverse of the original graph.
//- the rows of such graph store the rows which contain the elements
//- of the original graph
template<class GraphType>
inline void reverseAddressing
(
const label nRows,
const GraphType& origGraph
);
template<class GraphType>
inline void reverseAddressing(const GraphType& origGraph);
inline void reverseAddressing
(
const label nRows,
const VRWGraph& origGraph
);
inline void reverseAddressing(const VRWGraph& origGraph);
//- optimize memory usage
// this should be used once the graph will not be resized any more
void optimizeMemoryUsage();
//- check if the element is in the given row (takes linear time)
inline bool contains(const label rowI, const label e) const;
inline label containsAtPosition(const label rowI, const label e) const;
//- get and set operators
inline label operator()(const label i, const label j) const;
inline label& operator()(const label i, const label j);
inline constRow operator[](const label i) const;
inline row operator[](const label i);
//- Assignment operator
inline void operator=(const VRWGraph&);
// IOstream operators
// Write VRWGraph to Ostream.
friend Ostream& operator<<(Ostream&, const VRWGraph&);
//- Read from Istream, discarding contents of existing VRWGraph.
/* friend Istream& operator>> <T, width>
(
Istream&,
VRWGraph<T, width>&
);
*/
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "VRWGraphI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define forAllRow(graph, rowI, index) \
for(Foam::label index=0;index<(graph).sizeOfRow(rowI);++index)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,594 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
inline void Foam::VRWGraph::checkIndex(const label i, const label j) const
{
if( (i < 0) || (i >= rows_.size()) )
{
FatalErrorIn
(
"void Foam::VRWGraph<T,width>::"
"checkIndex(const label i, const label j) const"
) << "Row index " << i
<< " is not in range " << 0
<< " and " << rows_.size() << abort(FatalError);
}
if( (j < 0) || (j >= rows_[i].size()) )
FatalErrorIn
(
"void Foam::VRWGraph<T,width>::"
"checkIndex(label const, const label) const"
) << "Column index " << j
<< " is not in range " << 0
<< " and " << rows_[i].size() << abort(FatalError);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
inline Foam::VRWGraph::VRWGraph()
:
data_(),
rows_()
{}
//- Construct given size
inline Foam::VRWGraph::VRWGraph
(
const label size
)
:
data_(),
rows_(size)
{
for(label rowI=0;rowI<size;++rowI)
{
rows_[rowI].start() = INVALIDROW;
rows_[rowI].size() = NONE;
}
}
inline Foam::VRWGraph::VRWGraph
(
const label nRows,
const label nColumnsInRow
)
:
data_(nRows * nColumnsInRow),
rows_(nRows)
{
for(label rowI=0;rowI<nRows;++rowI)
{
rows_[rowI].start() = rowI * nColumnsInRow;
rows_[rowI].size() = nColumnsInRow;
}
}
inline Foam::VRWGraph::VRWGraph
(
const label nRows,
const label nColumnsInRow,
const label t
)
:
data_(nRows * nColumnsInRow, t),
rows_(nRows)
{
for(label rowI=0;rowI<nRows;++rowI)
{
rows_[rowI].start() = rowI * nColumnsInRow;
rows_[rowI].size() = nColumnsInRow;
}
}
inline Foam::VRWGraph::VRWGraph
(
const VRWGraph& ol
)
:
data_(ol.data_),
rows_(ol.rows_)
{}
inline Foam::VRWGraph::~VRWGraph()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::VRWGraph::size() const
{
return rows_.size();
}
inline Foam::label Foam::VRWGraph::sizeOfRow(const label rowI) const
{
return rows_[rowI].size();
}
inline void Foam::VRWGraph::setSize(const label size)
{
if( size > rows_.size() )
{
rowElement rowInfo(INVALIDROW, NONE);
for(label i=rows_.size();i<size;++i)
rows_.append(rowInfo);
}
else
{
rows_.setSize(size);
}
}
void Foam::VRWGraph::setSizeAndColumnWidth
(
const label newNumRows,
const label rcWidth
)
{
if( rows_.size() != 0 )
FatalErrorIn
(
"void Foam::VRWGraph::setSizeAndColumnWidth"
"(const label size, const label rcWidth)"
) << "This function should be used for empty graphs, only!"
<< exit(FatalError);
data_.setSize(newNumRows * rcWidth);
data_ = FREEENTRY;
rows_.setSize(newNumRows);
label start(0);
for(label i=0;i<newNumRows;++i)
{
rows_[i].start() = start;
rows_[i].size() = 0;
data_[start] = FREESTART;
start += rcWidth;
}
}
template<class ListType>
inline void Foam::VRWGraph::setSizeAndRowSize(const ListType& l)
{
//- set the size of graph rows
const label nRows = l.size();
rows_.setSize(nRows);
label start(0);
for(label rowI=0;rowI<nRows;++rowI)
{
rows_[rowI].size() = l[rowI];
if( rows_[rowI].size() != NONE )
{
rows_[rowI].start() = start;
}
else
{
rows_[rowI].start() = INVALIDROW;
}
start += rows_[rowI].size();
}
data_.setSize(start);
}
inline void Foam::VRWGraph::setRowSize(const label rowI, const label newSize)
{
# ifdef FULLDEBUG
if( (rowI < 0) || (rowI >= rows_.size()) )
FatalErrorIn
(
"void Foam::VRWGraph<T,width>::"
"checkIndex(const label rowI, const label size) const"
) << "Row index " << Foam::label(rowI)
<< " is not in range " << Foam::label(0)
<< " and " << rows_.size() << abort(FatalError);
# endif
const label start = rows_[rowI].start();
if( start == INVALIDROW )
{
if( newSize > 0 )
{
rows_[rowI].start() = data_.size();
for(label i=0;i<newSize;++i)
data_.append(NONE);
rows_[rowI].size() = newSize;
}
}
else if( newSize > rows_[rowI].size() )
{
//- check if there is some unused space after the last element
bool foundUnused(true);
for(label i=rows_[rowI].size();i<newSize;++i)
{
const label j = start + i;
if(
(j >= data_.size()) ||
(data_[j] != FREEENTRY) ||
(data_[j] == FREESTART)
)
{
foundUnused = false;
break;
}
}
if( foundUnused )
{
//- row can be extended without copying
for(label i=rows_[rowI].size();i<newSize;++i)
data_[start+i] = NONE;
}
else
{
//- row is copied at the end of the data list
rows_[rowI].start() = data_.size();
for(label i=0;i<rows_[rowI].size();++i)
{
data_.append(data_[start+i]);
data_[start+i] = FREEENTRY;
}
for(label i=rows_[rowI].size();i<newSize;++i)
data_.append(NONE);
}
rows_[rowI].size() = newSize;
}
else if( newSize < rows_[rowI].size() )
{
for(label i=newSize;i<rows_[rowI].size();++i)
data_[start+i] = FREEENTRY;
rows_[rowI].size() = newSize;
if( newSize == 0 )
rows_[rowI].start() = INVALIDROW;
}
}
inline void Foam::VRWGraph::clear()
{
data_.setSize(0);
rows_.setSize(0);
}
template<class ListType>
inline void Foam::VRWGraph::appendList
(
const ListType& l
)
{
if( l.size() == 0 )
{
rows_.append(rowElement(INVALIDROW, 0));
return;
}
rowElement rowInfo(data_.size(), l.size());
const label size = l.size();
for(label elI=0;elI<size;++elI)
data_.append(l[elI]);
rows_.append(rowInfo);
}
inline void Foam::VRWGraph::append(const label rowI, const label el)
{
rowElement& re = rows_[rowI];
if( re.start() == INVALIDROW )
{
re.start() = data_.size();
re.size() = 1;
data_.append(el);
}
else
{
const label oldStart = re.start();
const label oldSize = re.size();
++re.size();
if( oldStart + oldSize < data_.size() )
{
if(
(data_[oldStart+oldSize] == FREEENTRY) ||
(data_[oldStart+oldSize] == FREESTART)
)
{
data_[oldStart + oldSize] = el;
}
else
{
re.start() = data_.size();
for(label i=0;i<oldSize;++i)
{
data_.append(data_[oldStart+i]);
data_[oldStart+i] = FREEENTRY;
}
data_.append(el);
}
}
else
{
data_.append(el);
}
}
}
inline void Foam::VRWGraph::appendIfNotIn(const label rowI, const label el)
{
if( !contains(rowI, el) )
append(rowI, el);
}
template<class ListType>
inline void Foam::VRWGraph::setRow
(
const label rowI,
const ListType& l
)
{
this->setRowSize(rowI, l.size());
const label start = rows_[rowI].start();
const label size = l.size();
for(label elI=0;elI<size;++elI)
data_[start+elI] = l[elI];
}
inline void Foam::VRWGraph::mergeGraphs(const List<VRWGraph>& graphParts)
{
const label nGraphs = graphParts.size();
const label nRows = graphParts[0].size();
forAll(graphParts, i)
{
if( nRows != graphParts[i].size() )
FatalErrorIn
(
"inline void Foam::VRWGraph::mergeGraphs(const List<VRWGraph>&)"
) << "Cannot merge graphs" << abort(FatalError);
}
//- find the number of elements in each row
labelLongList nElmtsInRow(nRows);
for(label rowI=0;rowI<nRows;++rowI)
{
label sum(0);
for(label i=0;i<nGraphs;++i)
sum += graphParts[i].sizeOfRow(rowI);
nElmtsInRow[rowI] = sum;
}
setSizeAndRowSize(nElmtsInRow);
//- Finally, assemble the merged graph
for(label rowI=0;rowI<nRows;++rowI)
{
forAll(graphParts, i)
{
const VRWGraph& gp = graphParts[i];
for(label j=0;j<gp.sizeOfRow(rowI);++j)
this->operator()(rowI, --nElmtsInRow[rowI]) = gp(rowI, j);
}
}
}
template<class GraphType>
inline void Foam::VRWGraph::reverseAddressing
(
const label nRows,
const GraphType& origGraph
)
{
const label origSize = origGraph.size();
labelLongList nElmtsInRow(nRows);
for(label rowI=0;rowI<nRows;++rowI)
nElmtsInRow[rowI] = 0;
for(label rowI=0;rowI<origSize;++rowI)
{
const label rowSize = origGraph[rowI].size();
for(label i=0;i<rowSize;++i)
++nElmtsInRow[origGraph[rowI][i]];
}
setSizeAndRowSize(nElmtsInRow);
nElmtsInRow = 0;
//- finally fill in the data
for(label rowI=0;rowI<origSize;++rowI)
{
const label rowSize = origGraph[rowI].size();
for(label i=0;i<rowSize;++i)
{
const label el = origGraph[rowI][i];
this->operator()(el, nElmtsInRow[el]++) = rowI;
}
}
}
template<class GraphType>
inline void Foam::VRWGraph::reverseAddressing(const GraphType& origGraph)
{
const label size = origGraph.size();
label maxValue(-1);
for(label rowI=0;rowI<size;++rowI)
{
const label rowSize = origGraph[rowI].size();
for(label i=0;i<rowSize;++i)
maxValue = Foam::max(maxValue, origGraph[rowI][i]);
}
++maxValue;
reverseAddressing(maxValue, origGraph);
}
inline void Foam::VRWGraph::reverseAddressing
(
const label nRows,
const VRWGraph& origGraph
)
{
const label origSize = origGraph.size();
labelLongList nElmtsInRow(nRows);
for(label rowI=0;rowI<nRows;++rowI)
nElmtsInRow[rowI] = 0;
for(label rowI=0;rowI<origSize;++rowI)
{
const label rowSize = origGraph.sizeOfRow(rowI);
for(label i=0;i<rowSize;++i)
++nElmtsInRow[origGraph(rowI, i)];
}
setSizeAndRowSize(nElmtsInRow);
nElmtsInRow = 0;
//- finally fill in the data
for(label rowI=0;rowI<origSize;++rowI)
{
const label rowSize = origGraph.sizeOfRow(rowI);
for(label i=0;i<rowSize;++i)
{
const label el = origGraph(rowI, i);
this->operator()(el, nElmtsInRow[el]++) = rowI;
}
}
}
inline void Foam::VRWGraph::reverseAddressing(const VRWGraph& origGraph)
{
const label size = origGraph.size();
label maxValue(-1);
for(label rowI=0;rowI<size;++rowI)
{
const label rowSize = origGraph.sizeOfRow(rowI);
for(label i=0;i<rowSize;++i)
maxValue = Foam::max(maxValue, origGraph(rowI, i));
}
++maxValue;
reverseAddressing(maxValue, origGraph);
}
inline bool Foam::VRWGraph::contains
(
const label rowI,
const label e
) const
{
const label start = rows_[rowI].start();
if( start == INVALIDROW )
return false;
const label size = rows_[rowI].size();
for(register label i=0;i<size;++i)
if( data_[start+i] == e )
return true;
return false;
}
inline Foam::label Foam::VRWGraph::containsAtPosition
(
const label rowI,
const label e
) const
{
const label start = rows_[rowI].start();
if( start == INVALIDROW )
return -1;
const label size = rows_[rowI].size();
for(register label i=0;i<size;++i)
if( data_[start+i] == e )
return i;
return -1;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline Foam::label Foam::VRWGraph::operator()
(
const label i,
const label j
) const
{
#ifdef FULLDEBUG
checkIndex(i, j);
#endif
return data_[rows_[i].start() + j];
}
inline Foam::label& Foam::VRWGraph::operator()
(
const label i, const label j
)
{
#ifdef FULLDEBUG
checkIndex(i, j);
#endif
return data_[rows_[i].start() + j];
}
inline Foam::constRow Foam::VRWGraph::operator[](const label i) const
{
return constRow(*this, i);
}
inline Foam::row Foam::VRWGraph::operator[](const label i)
{
return row(*this, i);
}
inline void Foam::VRWGraph::operator=
(
const VRWGraph& l
)
{
data_ = l.data_;
rows_ = l.rows_;
}
// ************************************************************************* //

View file

@ -1,397 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VRWGraphSMPModifier.H"
#include "labelPair.H"
# ifdef USE_OMP
#include <omp.h>
# endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
VRWGraphSMPModifier::VRWGraphSMPModifier(VRWGraph& graph)
:
graph_(graph)
{}
VRWGraphSMPModifier::~VRWGraphSMPModifier()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void VRWGraphSMPModifier::mergeGraphs(const List<VRWGraph>& graphParts)
{
const label nGraphs = graphParts.size();
const label nRows = graphParts[0].size();
forAll(graphParts, i)
{
if( nRows != graphParts[i].size() )
FatalErrorIn
(
"inline void Foam::VRWGraph::mergeGraphs(const List<VRWGraph>&)"
) << "Cannot merge graphs" << abort(FatalError);
}
//- find the number of elements in each row
labelLongList nElmtsInRow(nRows);
# ifdef USE_OMP
# pragma omp parallel for schedule(static, 1)
# endif
for(label rowI=0;rowI<nRows;++rowI)
{
label sum(0);
for(label i=0;i<nGraphs;++i)
sum += graphParts[i].sizeOfRow(rowI);
nElmtsInRow[rowI] = sum;
}
//- set the size of graph
setSizeAndRowSize(nElmtsInRow);
//- Finally, assemble the merged graph
# ifdef USE_OMP
# pragma omp parallel for schedule(static, 1)
# endif
for(label rowI=0;rowI<nRows;++rowI)
{
forAll(graphParts, i)
{
const VRWGraph& gp = graphParts[i];
for(label j=0;j<gp.sizeOfRow(rowI);++j)
graph_(rowI, --nElmtsInRow[rowI]) = gp(rowI, j);
}
}
}
void VRWGraphSMPModifier::reverseAddressing(const VRWGraph& origGraph)
{
graph_.setSize(0);
labelLongList nAppearances;
# ifdef USE_OMP
label nThreads = 3 * omp_get_num_procs();
if( origGraph.size() < 1000 )
nThreads = 1;
# else
const label nThreads(1);
# endif
label minRow(INT_MAX), maxRow(-1);
List<List<LongList<labelPair> > > dataForOtherThreads(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
const label threadI = omp_get_thread_num();
# else
const label threadI(0);
# endif
List<LongList<labelPair> >& dot = dataForOtherThreads[threadI];
dot.setSize(nThreads);
//- find min and max entry in the graph
//- they are used for assigning ranges of values local for each process
label localMinRow(INT_MAX), localMaxRow(-1);
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAllRow(origGraph, rowI, i)
{
const label entryI = origGraph(rowI, i);
localMaxRow = Foam::max(localMaxRow, entryI);
localMinRow = Foam::min(localMinRow, entryI);
}
}
++localMaxRow;
# ifdef USE_OMP
# pragma omp critical
# endif
{
minRow = Foam::min(minRow, localMinRow);
maxRow = Foam::max(maxRow, localMaxRow);
nAppearances.setSize(maxRow);
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- initialise appearances
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
for(label i=0;i<maxRow;++i)
nAppearances[i] = 0;
# ifdef USE_OMP
# pragma omp barrier
# endif
const label range = (maxRow - minRow) / nThreads + 1;
const label localMin = minRow + threadI * range;
const label localMax = Foam::min(localMin + range, maxRow);
//- find the number of appearances of each element in the original graph
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAllRow(origGraph, rowI, j)
{
const label entryI = origGraph(rowI, j);
const label threadNo = (entryI - minRow) / range;
if( threadNo == threadI )
{
++nAppearances[entryI];
}
else
{
dot[threadNo].append(labelPair(entryI, rowI));
}
}
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- count the appearances which are not local to the processor
for(label i=0;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
++nAppearances[data[j].first()];
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- allocate graph
# ifdef USE_OMP
# pragma omp master
# endif
setSizeAndRowSize(nAppearances);
# ifdef USE_OMP
# pragma omp barrier
# endif
for(label i=localMin;i<localMax;++i)
{
nAppearances[i] = 0;
}
//- start filling reverse addressing graph
//- update data from processors with smaller labels
for(label i=0;i<threadI;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
//- update data local to the processor
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAllRow(origGraph, rowI, j)
{
const label entryI = origGraph(rowI, j);
if( (entryI >= localMin) && (entryI < localMax) )
graph_(entryI, nAppearances[entryI]++) = rowI;
}
}
//- update data from the processors with higher labels
for(label i=threadI+1;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
}
}
void VRWGraphSMPModifier::optimizeMemoryUsage()
{
# ifdef USE_OMP
label nThreads = 3 * omp_get_num_procs();
if( graph_.size() < 1000 )
nThreads = 1;
# else
const label nThreads(1);
# endif
DynList<label> nRows, nEntries;
nRows.setSize(nThreads);
nEntries.setSize(nThreads);
LongList<rowElement> newRows;
labelLongList newData;
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
const label threadI = omp_get_thread_num();
# else
const label threadI(0);
# endif
nRows[threadI] = 0;
nEntries[threadI] = 0;
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(graph_.rows_, rowI)
{
if( graph_.rows_[rowI].start() == VRWGraph::INVALIDROW )
continue;
++nRows[threadI];
nEntries[threadI] += graph_.rows_[rowI].size();
}
# ifdef USE_OMP
# pragma omp barrier
# pragma omp master
# endif
{
//- find the number of rows
label counter(0);
forAll(nRows, i)
counter += nRows[i];
newRows.setSize(counter);
//- find the number of data entries
counter = 0;
forAll(nEntries, i)
counter += nEntries[i];
newData.setSize(counter);
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- find the starting position for each thread
label rowStart(0), entryStart(0);
for(label i=0;i<threadI;++i)
{
rowStart += nRows[i];
entryStart += nEntries[i];
}
//- copy the data into the location
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(graph_, rowI)
{
rowElement& el = newRows[rowStart];
el.start() += entryStart;
++rowStart;
el.size() = graph_.sizeOfRow(rowI);
forAllRow(graph_, rowI, i)
{
newData[entryStart] = graph_(rowI, i);
++entryStart;
}
}
}
//- replace the original data with the compressed data
graph_.rows_.transfer(newRows);
graph_.data_.transfer(newData);
}
void VRWGraphSMPModifier::operator=(const VRWGraph& og)
{
graph_.data_.setSize(og.data_.size());
graph_.rows_.setSize(og.rows_.size());
# ifdef USE_OMP
# pragma omp parallel
# endif
{
# ifdef USE_OMP
# pragma omp for schedule(static, 1)
# endif
forAll(graph_.data_, i)
graph_.data_[i] = og.data_[i];
# ifdef USE_OMP
# pragma omp for schedule(static, 1)
# endif
forAll(graph_.rows_, rowI)
graph_.rows_[rowI] = og.rows_[rowI];
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,128 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
VRWGraphModifier
Description
This class is a modifier for VRWGraph which allows for multi-threaded
execution of most time-consuimg functions
SourceFiles
VRWGraphSMPModifier.H
VRWGraphSMPModifier.C
\*---------------------------------------------------------------------------*/
#ifndef VRWGraphSMPModifier_H
#define VRWGraphSMPModifier_H
#include "VRWGraph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class VRWGraphSMPModifier Declaration
\*---------------------------------------------------------------------------*/
class VRWGraphSMPModifier
{
// Private data
//- list containing the data
VRWGraph& graph_;
// Private member functions
//- Disallow default construct
VRWGraphSMPModifier();
//- Disallow bitwise copy construct
VRWGraphSMPModifier(const VRWGraphSMPModifier&);
//- Disallow bitwise assignment
void operator=(const VRWGraphSMPModifier&);
public:
// Constructor
//- Construct from reference to VRWGraph
VRWGraphSMPModifier(VRWGraph&);
// Destructor
~VRWGraphSMPModifier();
// Member Functions
//- set the size and row sizes
template<class ListType>
void setSizeAndRowSize(const ListType&);
//- merge graphs with the identical number of rows
//- into a single one. Use for SMP parallelisation
void mergeGraphs(const List<VRWGraph>& graphParts);
//- set the graph to the reverse of the original graph.
//- the rows of such graph store the rows which contain the elements
//- of the original graph
template<class GraphType>
void reverseAddressing(const GraphType& origGraph);
void reverseAddressing(const VRWGraph& origGraph);
//- set the graph to the reverse of the original graph and mapped
//- to another space.
template<class ListType, class GraphType>
void reverseAddressing(const ListType&, const GraphType&);
template<class ListType>
void reverseAddressing(const ListType&, const VRWGraph&);
//- optimize memory usage
// this should be used once the graph will not be resized any more
void optimizeMemoryUsage();
//- Assignment operator
void operator=(const VRWGraph&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "VRWGraphSMPModifierTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,638 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VRWGraphSMPModifier.H"
#include "labelPair.H"
# ifdef USE_OMP
#include <omp.h>
# endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class ListType>
void VRWGraphSMPModifier::setSizeAndRowSize(const ListType& s)
{
graph_.rows_.setSize(s.size());
# ifdef USE_OMP
label nThreads = 3 * omp_get_num_procs();
if( s.size() < 1000 )
nThreads = 1;
# else
const label nThreads(1);
# endif
label nEntries(0);
DynList<label> procEntries;
procEntries.setSize(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
label& nLocalEntries = procEntries[omp_get_thread_num()];
# else
label& nLocalEntries = procEntries[0];
# endif
nLocalEntries = 0;
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(s, i)
nLocalEntries += s[i];
# ifdef USE_OMP
# pragma omp critical
# endif
nEntries += nLocalEntries;
# ifdef USE_OMP
# pragma omp barrier
# pragma omp master
# endif
{
graph_.data_.setSize(nEntries);
}
# ifdef USE_OMP
# pragma omp barrier
# endif
label start(0);
# ifdef USE_OMP
for(label i=0;i<omp_get_thread_num();++i)
start += procEntries[i];
# endif
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(s, i)
{
graph_.rows_[i].start() = start;
graph_.rows_[i].size() = s[i];
start += s[i];
}
}
}
template<class GraphType>
void VRWGraphSMPModifier::reverseAddressing(const GraphType& origGraph)
{
graph_.setSize(0);
labelLongList nAppearances;
# ifdef USE_OMP
label nThreads = 3 * omp_get_num_procs();
if( origGraph.size() < 1000 )
nThreads = 1;
# else
const label nThreads(1);
# endif
label minRow(INT_MAX), maxRow(-1);
List<List<LongList<labelPair> > > dataForOtherThreads(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
const label threadI = omp_get_thread_num();
# else
const label threadI(0);
# endif
List<LongList<labelPair> >& dot = dataForOtherThreads[threadI];
dot.setSize(nThreads);
//- find min and max entry in the graph
//- they are used for assigning ranges of values local for each process
label localMinRow(INT_MAX), localMaxRow(-1);
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAll(origGraph[rowI], i)
{
const label entryI = origGraph[rowI][i];
localMaxRow = Foam::max(localMaxRow, entryI);
localMinRow = Foam::min(localMinRow, entryI);
}
}
++localMaxRow;
# ifdef USE_OMP
# pragma omp critical
# endif
{
minRow = Foam::min(minRow, localMinRow);
maxRow = Foam::max(maxRow, localMaxRow);
nAppearances.setSize(maxRow);
}
# ifdef USE_OMP
# pragma omp barrier
//- initialise appearances
# pragma omp for schedule(static)
# endif
for(label i=0;i<maxRow;++i)
nAppearances[i] = 0;
# ifdef USE_OMP
# pragma omp barrier
# endif
const label range = (maxRow - minRow) / nThreads + 1;
const label localMin = minRow + threadI * range;
const label localMax = Foam::min(localMin + range, maxRow);
//- find the number of appearances of each element in the original graph
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAll(origGraph[rowI], j)
{
const label entryI = origGraph[rowI][j];
const label threadNo = (entryI - minRow) / range;
if( threadNo == threadI )
{
++nAppearances[entryI];
}
else
{
dot[threadNo].append(labelPair(entryI, rowI));
}
}
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- count the appearances which are not local to the processor
for(label i=0;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
++nAppearances[data[j].first()];
}
# ifdef USE_OMP
# pragma omp barrier
//- allocate graph
# pragma omp master
# endif
setSizeAndRowSize(nAppearances);
# ifdef USE_OMP
# pragma omp barrier
# endif
for(label i=localMin;i<localMax;++i)
{
nAppearances[i] = 0;
}
//- start filling reverse addressing graph
//- update data from processors with smaller labels
for(label i=0;i<threadI;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
//- update data local to the processor
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAll(origGraph[rowI], j)
{
const label entryI = origGraph[rowI][j];
if( (entryI >= localMin) && (entryI < localMax) )
graph_(entryI, nAppearances[entryI]++) = rowI;
}
}
//- update data from the processors with higher labels
for(label i=threadI+1;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
}
}
template<class ListType, class GraphType>
void VRWGraphSMPModifier::reverseAddressing
(
const ListType& mapper,
const GraphType& origGraph
)
{
ListType nAppearances;
# ifdef USE_OMP
label nThreads = 3 * omp_get_num_procs();
if( origGraph.size() < 1000 )
nThreads = 1;
# else
const label nThreads(1);
# endif
label minRow(INT_MAX), maxRow(-1);
List<List<LongList<labelPair> > > dataForOtherThreads(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
const label threadI = omp_get_thread_num();
# else
const label threadI(0);
# endif
List<LongList<labelPair> >& dot = dataForOtherThreads[threadI];
dot.setSize(nThreads);
//- find min and max entry in the graph
//- they are used for assigning ranges of values local for each process
label localMinRow(INT_MAX), localMaxRow(-1);
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAll(origGraph[rowI], i)
{
const label entryI = mapper[origGraph[rowI][i]];
localMaxRow = Foam::max(localMaxRow, entryI);
localMinRow = Foam::min(localMinRow, entryI);
}
}
++localMaxRow;
# ifdef USE_OMP
# pragma omp critical
# endif
{
minRow = Foam::min(minRow, localMinRow);
maxRow = Foam::max(maxRow, localMaxRow);
nAppearances.setSize(maxRow);
}
# ifdef USE_OMP
# pragma omp barrier
//- initialise appearances
# pragma omp for schedule(static)
# endif
for(label i=0;i<maxRow;++i)
nAppearances[i] = 0;
# ifdef USE_OMP
# pragma omp barrier
# endif
const label range = (maxRow - minRow) / nThreads + 1;
const label localMin = minRow + threadI * range;
const label localMax = Foam::min(localMin + range, maxRow);
//- find the number of appearances of each element in the original graph
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAll(origGraph[rowI], i)
{
const label entryI = mapper[origGraph[rowI][i]];
const label threadNo = (entryI - minRow) / range;
if( threadNo == threadI )
{
++nAppearances[entryI];
}
else
{
dot[threadNo].append(labelPair(entryI, rowI));
}
}
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- count the appearances which are not local to the processor
for(label i=0;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
++nAppearances[data[j].first()];
}
# ifdef USE_OMP
# pragma omp barrier
//- allocate graph
# pragma omp master
# endif
{
setSizeAndRowSize(nAppearances);
}
# ifdef USE_OMP
# pragma omp barrier
# endif
for(label i=localMin;i<localMax;++i)
{
nAppearances[i] = 0;
}
//- start filling reverse addressing graph
//- update data from processors with smaller labels
for(label i=0;i<threadI;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
//- update data local to the processor
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAll(origGraph[rowI], j)
{
const label entryI = mapper[origGraph[rowI][j]];
if( (entryI >= localMin) && (entryI < localMax) )
graph_(entryI, nAppearances[entryI]++) = rowI;
}
}
//- update data from the processors with higher labels
for(label i=threadI+1;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
}
}
template<class ListType>
void VRWGraphSMPModifier::reverseAddressing
(
const ListType& mapper,
const VRWGraph& origGraph
)
{
ListType nAppearances;
# ifdef USE_OMP
label nThreads = 3 * omp_get_num_procs();
if( origGraph.size() < 1000 )
nThreads = 1;
# else
const label nThreads(1);
# endif
label minRow(INT_MAX), maxRow(-1);
List<List<LongList<labelPair> > > dataForOtherThreads(nThreads);
# ifdef USE_OMP
# pragma omp parallel num_threads(nThreads)
# endif
{
# ifdef USE_OMP
const label threadI = omp_get_thread_num();
# else
const label threadI(0);
# endif
List<LongList<labelPair> >& dot = dataForOtherThreads[threadI];
dot.setSize(nThreads);
//- find min and max entry in the graph
//- they are used for assigning ranges of values local for each process
label localMinRow(INT_MAX), localMaxRow(-1);
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAllRow(origGraph, rowI, i)
{
const label entryI = mapper[origGraph(rowI, i)];
localMaxRow = Foam::max(localMaxRow, entryI);
localMinRow = Foam::min(localMinRow, entryI);
}
}
++localMaxRow;
# ifdef USE_OMP
# pragma omp critical
# endif
{
minRow = Foam::min(minRow, localMinRow);
maxRow = Foam::max(maxRow, localMaxRow);
nAppearances.setSize(maxRow);
}
# ifdef USE_OMP
# pragma omp barrier
//- initialise appearances
# pragma omp for schedule(static)
# endif
for(label i=0;i<maxRow;++i)
nAppearances[i] = 0;
# ifdef USE_OMP
# pragma omp barrier
# endif
const label range = (maxRow - minRow) / nThreads + 1;
const label localMin = minRow + threadI * range;
const label localMax = Foam::min(localMin + range, maxRow);
//- find the number of appearances of each element in the original graph
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAllRow(origGraph, rowI, i)
{
const label entryI = mapper[origGraph(rowI, i)];
const label threadNo = (entryI - minRow) / range;
if( threadNo == threadI )
{
++nAppearances[entryI];
}
else
{
dot[threadNo].append(labelPair(entryI, rowI));
}
}
}
# ifdef USE_OMP
# pragma omp barrier
# endif
//- count the appearances which are not local to the processor
for(label i=0;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
++nAppearances[data[j].first()];
}
# ifdef USE_OMP
# pragma omp barrier
//- allocate graph
# pragma omp master
# endif
{
setSizeAndRowSize(nAppearances);
}
# ifdef USE_OMP
# pragma omp barrier
# endif
for(label i=localMin;i<localMax;++i)
nAppearances[i] = 0;
//- start filling reverse addressing graph
//- update data from processors with smaller labels
for(label i=0;i<threadI;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
//- update data local to the processor
# ifdef USE_OMP
# pragma omp for schedule(static)
# endif
forAll(origGraph, rowI)
{
forAllRow(origGraph, rowI, j)
{
const label entryI = mapper[origGraph(rowI, j)];
if( (entryI >= localMin) && (entryI < localMax) )
graph_(entryI, nAppearances[entryI]++) = rowI;
}
}
//- update data from the processors with higher labels
for(label i=threadI+1;i<nThreads;++i)
{
const LongList<labelPair>& data =
dataForOtherThreads[i][threadI];
forAll(data, j)
{
const label entryI = data[j].first();
graph_(entryI, nAppearances[entryI]++) = data[j].second();
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,71 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VRWGraphList.H"
#include "token.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::VRWGraphList& DL
)
{
os << DL.size() << nl << token::BEGIN_LIST;
for(register label i=0;i<DL.size();++i)
{
os << nl << DL[i];
}
os << nl << token::END_LIST;
return os;
}
/*
template<class T, Foam::label width>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::VRWGraphList<T, width>& DL
)
{
label size;
T e;
is >> size;
DL.setSize(size);
for(IndexType i=0;i<size;++i)
{
is >> e;
DL[i] = e;
}
return is;
}
*/
// ************************************************************************* //

View file

@ -1,150 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
VRWGraphList
Description
This class is an implementation of a list of graphs
with variable column width. The implementation is memory efficient.
SourceFiles
VRWGraphListI.H
VRWGraphList.C
\*---------------------------------------------------------------------------*/
#ifndef VRWGraphList_H
#define VRWGraphList_H
#include "VRWGraph.H"
#include "subGraph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class VRWGraphList Declaration
\*---------------------------------------------------------------------------*/
class VRWGraphList
{
// Private data
//- graph containing the data
VRWGraph data_;
//- number of rows
LongList<rowElement> rows_;
// Private member functions
//- check index
inline void checkIndex
(
const label i,
const label j,
const label k
) const;
public:
// Constructors
//- Construct null
inline VRWGraphList();
//- Copy contructor
inline VRWGraphList(const VRWGraphList&);
// Destructor
inline ~VRWGraphList();
// Member Functions
// Access
//- Returns the number of graphs
inline label size() const;
//- Returns the number of rows in the graph at that position
inline label sizeOfGraph(const label posI) const;
//- Return the number of element in the row at the given position
inline label sizeOfRow(const label posI, const label rowI) const;
//- Clear the graph
inline void clear();
// Member Operators
//- Append a graph at the end of the graphList
template<class GraphType>
inline void appendGraph(const GraphType& l);
//- get and set operators
inline label operator()
(
const label i,
const label j,
const label k
) const;
inline label& operator()(const label i, const label j, const label k);
inline const subGraph<const VRWGraph> operator[](const label i) const;
//- Assignment operator
inline void operator=(const VRWGraphList&);
// IOstream operators
// Write VRWGraphList to Ostream.
friend Ostream& operator<<(Ostream&, const VRWGraphList&);
//- Read from Istream, discarding contents of existing VRWGraphList.
/* friend Istream& operator>> <T, width>
(
Istream&,
VRWGraphList<T, width>&
);
*/
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "VRWGraphListI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,182 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline void Foam::VRWGraphList::checkIndex
(
const label i,
const label j,
const label k
) const
{
if( (i < 0) || (i >= rows_.size()) )
{
FatalErrorIn
(
"void Foam::VRWGraphList<T,width>::"
"checkIndex(const label i, const label j, const label k) const"
) << "Position index " << Foam::label(i)
<< " is not in range " << Foam::label(0)
<< " and " << rows_.size() << abort(FatalError);
}
if( (j < 0) || (j >= rows_[i].size()) )
FatalErrorIn
(
"void Foam::VRWGraphList<T,width>::"
"checkIndex(label const i, const label j, const label k) const"
) << "Row index " << Foam::label(j)
<< " is not in range " << Foam::label(0)
<< " and " << rows_[i].size() << abort(FatalError);
if( (k < 0) || (k >= data_.sizeOfRow(rows_[i].start()+j)) )
FatalErrorIn
(
"void Foam::VRWGraphList<T,width>::"
"checkIndex(label const i, const label j, const label k) const"
) << "Data index " << Foam::label(k)
<< " is not in range " << Foam::label(0)
<< " and " << data_.sizeOfRow(rows_[i].start()+j)
<< abort(FatalError);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
inline Foam::VRWGraphList::VRWGraphList()
:
data_(),
rows_()
{
}
inline Foam::VRWGraphList::VRWGraphList
(
const VRWGraphList& ol
)
:
data_(ol.data_),
rows_(ol.rows_)
{
}
inline Foam::VRWGraphList::~VRWGraphList()
{
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::VRWGraphList::size() const
{
return rows_.size();
}
inline Foam::label Foam::VRWGraphList::sizeOfGraph(const label posI) const
{
return rows_[posI].size();
}
inline Foam::label Foam::VRWGraphList::sizeOfRow
(
const label posI,
const label rowI
) const
{
return data_.sizeOfRow(rows_[posI].start()+rowI);
}
inline void Foam::VRWGraphList::clear()
{
data_.setSize(0);
rows_.setSize(0);
}
template<class GraphType>
inline void Foam::VRWGraphList::appendGraph
(
const GraphType& l
)
{
rowElement re(data_.size(), l.size());
for(label i=0;i<l.size();++i)
data_.appendList(l[i]);
rows_.append(re);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline Foam::label Foam::VRWGraphList::operator()
(
const label i,
const label j,
const label k
) const
{
#ifdef FULLDEBUG
checkIndex(i, j, k);
#endif
return data_(rows_[i].start() + j, k);
}
inline Foam::label& Foam::VRWGraphList::operator()
(
const label i, const label j, const label k
)
{
#ifdef FULLDEBUG
checkIndex(i, j, k);
#endif
return data_(rows_[i].start() + j, k);
}
inline const Foam::subGraph<const VRWGraph> Foam::VRWGraphList::operator[]
(
const label i
) const
{
return Foam::subGraph<const VRWGraph>(data_, i, rows_[i].size());
}
inline void Foam::VRWGraphList::operator=(const VRWGraphList& l)
{
data_ = l.data_;
rows_ = l.rows_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,151 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
graphRow
Description
This class provides access to a row of a graph
SourceFiles
graphRowI.H
\*---------------------------------------------------------------------------*/
#ifndef graphRow_H
#define graphRow_H
#include "bool.H"
#include "Ostream.H"
#include "error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class VRWGraph;
template<class graphType> class graphRow;
template<class graphType>
Ostream& operator<<(Ostream&, const graphRow<graphType>&);
/*---------------------------------------------------------------------------*\
Class graphRow Declaration
\*---------------------------------------------------------------------------*/
template<class graphType>
class graphRow
{
// Private data
//- reference to the graph
graphType& data_;
//- row number
const label rowI_;
// Private member functions
//- check index
inline void checkIndex(const label i) const;
public:
// Constructors
//- Construct from graph and row number
inline graphRow(graphType&, const label);
//- Copy contructor
inline graphRow(const graphRow<graphType>&);
// Destructor
inline ~graphRow();
// Member Functions
//- Returns the number of rows
inline label size() const;
//- Reset the number of rows
inline void setSize(const label size);
//- Clear the graph
inline void clear();
// Member Operators
//- Append an element to the given row
inline void append(const label);
//- Append an element to the given row if it does not exist there
inline void appendIfNotIn(const label);
//- check if the element is in the given row (takes linear time)
inline bool contains(const label e) const;
inline label containsAtPosition(const label e) const;
//- set and get operators
inline label operator[](const label) const;
inline label& operator[](const label);
//- Assignment operator
inline void operator=(const graphRow<graphType>&);
template<class listType>
inline void operator=(const listType&);
// IOstream operators
// Write graphRow to Ostream.
friend Ostream& operator<< <graphType>
(
Ostream&,
const graphRow<graphType>&
);
//- Read from Istream, discarding contents of existing graphRow.
/* friend Istream& operator>> <T, width>
(
Istream&,
graphRow<T, width>&
);
*/
};
typedef const graphRow<const VRWGraph> constRow;
typedef graphRow<VRWGraph> row;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "graphRowI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
namespace Foam
{
template<class graphType>
inline void Foam::graphRow<graphType>::checkIndex(const label i) const
{
if( (i < 0) || (i >=data_.sizeOfRow(rowI_)) )
{
FatalErrorIn
(
"void Foam::graphRow<graphType>::"
"checkIndex(const label i) const"
) << "Row index " << rowI_
<< " is not in range " << Foam::label(0)
<< " and " << data_.sizeOfRow(rowI_) << abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class graphType>
inline Foam::graphRow<graphType>::graphRow(graphType& g, const label i)
:
data_(g),
rowI_(i)
{
}
template<class graphType>
inline Foam::graphRow<graphType>::graphRow
(
const graphRow<graphType>& ol
)
:
data_(ol.data_),
rowI_(ol.rowI_)
{
}
template<class graphType>
inline Foam::graphRow<graphType>::~graphRow()
{
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class graphType>
inline Foam::label Foam::graphRow<graphType>::size() const
{
return data_.sizeOfRow(rowI_);
}
template<class graphType>
inline void Foam::graphRow<graphType>::setSize(const label s)
{
data_.setRowSize(rowI_, s);
}
template<class graphType>
inline void Foam::graphRow<graphType>::clear()
{
data_.setRowSize(rowI_, 0);
}
template<class graphType>
inline void Foam::graphRow<graphType>::append(const label el)
{
data_.append(rowI_, el);
}
template<class graphType>
inline void Foam::graphRow<graphType>::appendIfNotIn(const label el)
{
data_.appendIfNotIn(rowI_, el);
}
template<class graphType>
inline bool Foam::graphRow<graphType>::contains(const label e) const
{
return data_.contains(rowI_, e);
}
template<class graphType>
inline Foam::label Foam::graphRow<graphType>::containsAtPosition
(
const label e
) const
{
return data_.containsAtPosition(rowI_, e);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class graphType>
inline Foam::label Foam::graphRow<graphType>::operator[](const label i) const
{
return data_(rowI_, i);
}
template<class graphType>
inline Foam::label& Foam::graphRow<graphType>::operator[](const label i)
{
return data_(rowI_, i);
}
template<class graphType>
inline void Foam::graphRow<graphType>::operator=
(
const graphRow<graphType>& l
)
{
data_.setRowSize(rowI_, l.size());
for(label i=0;i<l.size();++i)
data_(rowI_, i) = l[i];
}
template<class graphType>
template<class listType>
inline void Foam::graphRow<graphType>::operator=(const listType& l)
{
data_.setRowSize(rowI_, l.size());
for(label i=0;i<l.size();++i)
data_(rowI_, i) = l[i];
}
template<class graphType>
inline Foam::Ostream& operator<<
(
Foam::Ostream& os,
const Foam::graphRow<graphType>& r
)
{
os << r.size() << "(";
for(Foam::label i=0;i<r.size();++i)
os << r[i] << " ";
os << ")";
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,135 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
subGraph
Description
This class provides access to a row of a graph
SourceFiles
subGraphI.H
\*---------------------------------------------------------------------------*/
#ifndef subGraph_H
#define subGraph_H
#include "bool.H"
#include "Ostream.H"
#include "error.H"
#include "graphRow.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class graphType> class subGraph;
template<class graphType>
Ostream& operator<<(Ostream&, const subGraph<graphType>&);
/*---------------------------------------------------------------------------*\
Class subGraph Declaration
\*---------------------------------------------------------------------------*/
template<class graphType>
class subGraph
{
// Private data
//- reference to the graph
graphType& data_;
//- starts at row
const label start_;
//- number of rows in the subGraph
const label size_;
// Private member functions
//- check index
inline void checkIndex(const label i) const;
public:
// Constructors
//- Construct from graph and start row and size
inline subGraph(graphType&, const label, const label);
//- Copy contructor
inline subGraph(const subGraph<graphType>&);
// Destructor
inline ~subGraph();
// Member Functions
//- Returns the number of rows
inline label size() const;
//- Returns the size of a given row
inline label sizeOfRow(const label rowI) const;
// Member Operators
//- Append an element to the given row
inline void append(const label rowI, const label);
//- Append an element to the given row if it does not exist there
inline void appendIfNotIn(const label rowI, const label);
//- check if the element is in the given row (takes linear time)
inline bool contains(const label rowI, const label e) const;
inline label containsAtPosition(const label rowI, const label e) const;
//- set and get operators
inline label operator()(const label i, const label j) const;
inline label& operator()(const label i, const label j);
inline const graphRow<const graphType> operator[](const label) const;
inline graphRow<graphType> operator[](const label);
// IOstream operators
// Write subGraph to Ostream.
friend Ostream& operator<< <graphType>
(
Ostream&,
const subGraph<graphType>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "subGraphI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,202 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
namespace Foam
{
template<class graphType>
inline void Foam::subGraph<graphType>::checkIndex(const label i) const
{
if( (i < 0) || (i >= size_) )
{
FatalErrorIn
(
"void Foam::subGraph<graphType>::"
"checkIndex(const label i) const"
) << "Row index " << i
<< " is not in range " << Foam::label(0)
<< " and " << size_ << abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class graphType>
inline Foam::subGraph<graphType>::subGraph
(
graphType& g,
const label start,
const label size
)
:
data_(g),
start_(start),
size_(size)
{
}
template<class graphType>
inline Foam::subGraph<graphType>::subGraph
(
const subGraph<graphType>& ol
)
:
data_(ol.data_),
start_(ol.start_),
size_(ol.size_)
{
}
template<class graphType>
inline Foam::subGraph<graphType>::~subGraph()
{
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class graphType>
inline Foam::label Foam::subGraph<graphType>::size() const
{
return size_;
}
template<class graphType>
inline Foam::label Foam::subGraph<graphType>::sizeOfRow(const label rowI) const
{
return data_.sizeOfRow(start_+rowI);
}
template<class graphType>
inline void Foam::subGraph<graphType>::append(const label rowI, const label el)
{
data_.append(start_+rowI, el);
}
template<class graphType>
inline void Foam::subGraph<graphType>::appendIfNotIn
(
const label rowI,
const label el
)
{
data_.appendIfNotIn(start_+rowI, el);
}
template<class graphType>
inline bool Foam::subGraph<graphType>::contains
(
const label rowI,
const label e
) const
{
return data_.contains(start_+rowI, e);
}
template<class graphType>
inline Foam::label Foam::subGraph<graphType>::containsAtPosition
(
const label rowI,
const label e
) const
{
return data_.containsAtPosition(start_+rowI, e);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class graphType>
inline Foam::label Foam::subGraph<graphType>::operator()
(
const label i,
const label j
) const
{
# ifdef FULLDEBUG
checkIndex(i);
# endif
return data_(start_+i, j);
}
template<class graphType>
inline Foam::label& Foam::subGraph<graphType>::operator()
(
const label i,
const label j
)
{
return data_(start_+i, j);
}
template<class graphType>
inline const Foam::graphRow<const graphType>
Foam::subGraph<graphType>::operator[]
(
const label i
) const
{
return data_[start_+i];
}
template<class graphType>
inline Foam::graphRow<graphType>
Foam::subGraph<graphType>::operator[](const label i)
{
return data_[start_+i];
}
template<class graphType>
inline Foam::Ostream& operator<<
(
Foam::Ostream& os,
const Foam::subGraph<graphType>& sg
)
{
os << sg.size() << "\n" << "(";
for(Foam::label i=0;i<sg.size();++i)
{
os << "\n" << sg.sizeOfRow(i) << "(";
for(Foam::label j=0;j<sg.sizeOfRow(i);++j)
{
if( j > 0 ) os << " ";
os << sg(i, j);
}
os << ")";
}
os << "\n" << ")";
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,192 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fpmaMesh.H"
#include "IOmanip.H"
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from polyMeshGen
Foam::fpmaMesh::fpmaMesh(const polyMeshGen& mesh)
:
mesh_(mesh)
{
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fpmaMesh::~fpmaMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fpmaMesh::writePoints(Foam::OFstream& fpmaGeometryFile) const
{
fpmaGeometryFile << mesh_.points().size() << nl;
const pointFieldPMG& points = mesh_.points();
forAll(points, pointI)
{
const point& p = points[pointI];
fpmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' ';
}
fpmaGeometryFile << nl;
}
void fpmaMesh::writeCells(OFstream& fpmaGeometryFile) const
{
const cellListPMG& cells = mesh_.cells();
fpmaGeometryFile << cells.size() << nl;
forAll(cells, cellI)
{
const cell& c = cells[cellI];
fpmaGeometryFile << c.size();
forAll(c, fI)
fpmaGeometryFile << ' ' << c[fI];
fpmaGeometryFile << nl;
}
}
void Foam::fpmaMesh::writeFaces(OFstream& fpmaGeometryFile) const
{
const faceListPMG& faces = mesh_.faces();
fpmaGeometryFile << faces.size() << nl;
forAll(faces, faceI)
{
const face& f = faces[faceI];
fpmaGeometryFile << f.size();
forAllReverse(f, pI)
fpmaGeometryFile << ' ' << f[pI];
fpmaGeometryFile << nl;
}
}
void Foam::fpmaMesh::writeSubsets(Foam::OFstream& fpmaGeometryFile) const
{
//- write patches as face selections
const PtrList<boundaryPatch>& patches = mesh_.boundaries();
label nSubsets(0);
nSubsets += patches.size();
DynList<label> indices;
mesh_.pointSubsetIndices(indices);
nSubsets += indices.size();
Info << "Mesh has " << indices.size() << " point subsets" << endl;
mesh_.faceSubsetIndices(indices);
nSubsets += indices.size();
Info << "Mesh has " << indices.size() << " face subsets" << endl;
mesh_.cellSubsetIndices(indices);
nSubsets += indices.size();
Info << "Mesh has " << indices.size() << " cell subsets" << endl;
fpmaGeometryFile << nSubsets << nl;
//- write patches as face selections
forAll(patches, patchI)
{
label start = patches[patchI].patchStart();
const label size = patches[patchI].patchSize();
fpmaGeometryFile << patches[patchI].patchName() << nl;
fpmaGeometryFile << 3 << nl;
fpmaGeometryFile << size << nl;
for(label i=0;i<size;++i)
fpmaGeometryFile << start++ << ' ';
fpmaGeometryFile << nl;
}
//- write node selections
mesh_.pointSubsetIndices(indices);
forAll(indices, indexI)
{
labelLongList nodesInSubset;
mesh_.pointsInSubset(indices[indexI], nodesInSubset);
fpmaGeometryFile << mesh_.pointSubsetName(indices[indexI]) << nl;
fpmaGeometryFile << 1 << nl;
fpmaGeometryFile << nodesInSubset.size() << nl;
forAll(nodesInSubset, i)
fpmaGeometryFile << nodesInSubset[i] << ' ';
fpmaGeometryFile << nl;
}
//- write face selections
mesh_.faceSubsetIndices(indices);
forAll(indices, indexI)
{
labelLongList facesInSubset;
mesh_.facesInSubset(indices[indexI], facesInSubset);
fpmaGeometryFile << mesh_.faceSubsetName(indices[indexI]) << nl;
fpmaGeometryFile << 3 << nl;
fpmaGeometryFile << facesInSubset.size() << nl;
forAll(facesInSubset, i)
fpmaGeometryFile << facesInSubset[i] << ' ';
fpmaGeometryFile << nl;
}
//- write cell selections
mesh_.cellSubsetIndices(indices);
forAll(indices, indexI)
{
labelLongList cellsInSubset;
mesh_.cellsInSubset(indices[indexI], cellsInSubset);
fpmaGeometryFile << mesh_.cellSubsetName(indices[indexI]) << nl;
fpmaGeometryFile << 2 << nl;
fpmaGeometryFile << cellsInSubset.size() << nl;
forAll(cellsInSubset, i)
fpmaGeometryFile << cellsInSubset[i] << ' ';
fpmaGeometryFile << nl;
}
}
void fpmaMesh::write(OFstream& fpmaGeometryFile) const
{
writePoints(fpmaGeometryFile);
writeFaces(fpmaGeometryFile);
writeCells(fpmaGeometryFile);
writeSubsets(fpmaGeometryFile);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
fpmaMesh
Description
SourceFiles
fpmaMesh.C
\*---------------------------------------------------------------------------*/
#ifndef fpmaMesh_H
#define fpmaMesh_H
#include "polyMeshGen.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fpmaMesh Declaration
\*---------------------------------------------------------------------------*/
class fpmaMesh
{
// Private data
// Private Member Functions
//- Disallow default bitwise copy construct
fpmaMesh(const fpmaMesh&);
//- Disallow default bitwise assignment
void operator=(const fpmaMesh&);
void writePoints(OFstream& fpmaGeometryFile) const;
void writeFaces(OFstream& fpmaGeometryFile) const;
void writeCells(OFstream& fpmaGeometryFile) const;
void writeSubsets(OFstream& fpmaGeometryFile) const;
public:
// Public data
const polyMeshGen& mesh_;
// Constructors
//- Construct from polyMeshGen
fpmaMesh(const polyMeshGen& mesh);
// Destructor
~fpmaMesh();
// Member Functions
// Access
// Check
// Edit
// Write
void write(OFstream& fpmaGeometryFile) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,159 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Translates FOAM mesh to AVL's FPMA format
\*---------------------------------------------------------------------------*/
#include "objectRegistry.H"
#include "Time.H"
#include "polyMeshGen.H"
#include "meshSurfaceEngine.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "fileName.H"
#include "fpmaMesh.H"
#include "writeMeshFPMA.H"
#include "helperFunctions.H"
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void writeMeshFPMA(const polyMeshGen& mesh, const word& fName)
{
const Time& time = mesh.returnTime();
const word postProcDir = "FPMA";
fileName postProcPath = time.path()/postProcDir;
if( !Foam::isDir(postProcPath) )
{
mkDir(postProcPath);
}
// Open the Case file
const fileName fpmaFileName = fName + ".fpma";
Info << "Writting mesh into " << fpmaFileName << endl;
/* OFstream fpmaGeometryFile
(
postProcPath/fpmaFileName,
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
*/
OFstream fpmaGeometryFile(postProcPath/fpmaFileName);
// Construct the FIRE mesh
fpmaMesh Mesh(mesh);
Mesh.write(fpmaGeometryFile);
}
void createFIRESelections(polyMeshGen& mesh)
{
if( !Pstream::parRun() )
return;
const faceListPMG& faces = mesh.faces();
const PtrList<processorBoundaryPatch>& procBoundaries =
mesh.procBoundaries();
//- create face selections from proc patches
forAll(procBoundaries, patchI)
{
word sName = "InterFacesToProc";
sName += help::scalarToText(procBoundaries[patchI].neiProcNo());
const label sID = mesh.addFaceSubset(sName);
label faceI = procBoundaries[patchI].patchStart();
const label end = faceI + procBoundaries[patchI].patchSize();
for(;faceI<end;++faceI)
mesh.addFaceToSubset(sID, faceI);
}
//- create cell selections
DynList<label> subsets;
mesh.faceSubsetIndices(subsets);
forAll(subsets, subsetI)
{
const word sName = mesh.faceSubsetName(subsets[subsetI]);
if( sName.substr(0, 10) == "processor_" )
{
const word newName = "Proc" + sName.substr(10, sName.size()-10);
labelLongList cellsInSubset;
mesh.cellsInSubset(subsets[subsetI], cellsInSubset);
const label subsetID = mesh.addCellSubset(newName);
forAll(cellsInSubset, i)
mesh.addCellToSubset(subsetID, cellsInSubset[i]);
}
}
//- creating node selections
boolList bndVertex(mesh.points().size(), false);
forAll(mesh.boundaries(), patchI)
{
label faceI = mesh.boundaries()[patchI].patchStart();
const label end = faceI + mesh.boundaries()[patchI].patchSize();
for(;faceI<end;++faceI)
{
const face& f = mesh.faces()[faceI];
forAll(f, pI)
bndVertex[f[pI]] = true;
}
}
forAll(procBoundaries, patchI)
{
word sName = "InterSurfaceEdgesToProc";
sName += help::scalarToText(procBoundaries[patchI].neiProcNo());
const label subsetID = mesh.addPointSubset(sName);
label faceI = procBoundaries[patchI].patchStart();
const label end = faceI + procBoundaries[patchI].patchSize();
for(;faceI<end;++faceI)
{
const face& f = faces[faceI];
forAll(f, pI)
{
if( bndVertex[f[pI]] )
mesh.addPointToSubset(subsetID, f[pI]);
}
}
}
}
}
// ************************************************************************* //

View file

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
writeMeshFPMA
Description
Write mesh into fpma format
SourceFiles
writeMeshFPMA.C
\*---------------------------------------------------------------------------*/
#ifndef writeMeshFPMA_H
#define writeMeshFPMA_H
#include "OFstream.H"
#include "word.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMeshGen;
void writeMeshFPMA(const polyMeshGen& mesh, const word& fName);
void createFIRESelections(polyMeshGen& mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "decomposeCells.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
decomposeCells::decomposeCells(polyMeshGen& mesh)
:
mesh_(mesh),
patchNames_(mesh.boundaries().size()),
patchTypes_(mesh.boundaries().size()),
newBoundaryFaces_(),
newBoundaryPatches_(),
facesOfNewCells_()
{
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
forAll(boundaries, patchI)
{
patchNames_[patchI] = boundaries[patchI].patchName();
patchTypes_[patchI] = boundaries[patchI].patchType();
}
}
//- Destructor
decomposeCells::~decomposeCells()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
} // End namespace Foam
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show more