OpenFOAM: v1912 released! - For more information see https://www.openfoam.com/releases/openfoam-v1912

Commit bbb5defd authored by Franjo's avatar Franjo

Merge branch 'release' for version 1.1

parents fb22fdba c50d952d
# -*- mode: org; -*-
#
#+TITLE: *cfMesh README for version 1.0*
#+TITLE: *cfMesh README*
#+AUTHOR: Franjo Juretic.
#+DATE: May 2014
#+DATE: May 2015
#+LINK: http://www.c-fields.com
#+OPTIONS:
......@@ -18,11 +18,11 @@ cfMesh is a library for mesh generation built on OpenFOAM.
cfMesh is developed and tested on Linux and MS Windows.
* Installation
The binaries can be downloaded from www.c-fields.com
Binaries and the source code can be downloaded from http://sourceforge.net/projects/cfmesh/
* Building from Sources (Optional)
cfMesh can be built with recent versions of OpenFOAM and foam-extend. In order to build the library, a working OpenFOAM environment is needed. The build started by the Allwmake script located in this folder. It can be built with gcc and mingw compilers which support OpenMP (gcc-4.2.4 and above). Other compilers are not tested.
cfMesh can be built with recent versions of OpenFOAM and foam-extend. In order to build the library, a working OpenFOAM environment is needed. The build started by the Allwmake script located in this folder. It can be built with gcc and mingw compilers which support OpenMP (gcc-4.2.4 and above). Other compilers are not tested. This instructions are valid for Linux, only. We encourage Windows users to download the binary package.
* Getting Started
......@@ -37,5 +37,18 @@ cfMesh is a library for mesh generation built on OpenFOAM.
+ cd $FOAM_RUN/tutorials/asmoOctree
+ cartesianMesh
All cases have Allrun and Allclean scripts guiding you through the meshing process.
* Documentation
http://www.c-fields.com
\ No newline at end of file
http://www.c-fields.com and in the userGuide folder.
* List of contributors
Franjo Juretic
Philippose Rajan
Ivor Clifford
* How to contribute
It you are interested in contributing to cfMesh please send an e-mail at: info@c-fields.com
We gladly accept contributions, whether they are the code, validation data, documentation, promotional material, etc.
cfMesh development process follows the git-flow branching model, described in http://nvie.com/posts/a-successful-git-branching-model/.
......@@ -2,11 +2,13 @@ EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary
......@@ -2,11 +2,13 @@ EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary
pMesh.C
EXE = $(FOAM_USER_APPBIN)/pMesh
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Application
Generates polyhedral mesh
Description
- takes a triangulated surface and generates a body-fitted polyhedral mesh
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "voronoiMeshGenerator.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
//- polyhedral mesher cannot be run in parallel yet
argList::noParallel();
voronoiMeshGenerator pmg(runTime);
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n"
<< "ClockTime = " << runTime.elapsedClockTime() << endl;
pmg.writeMesh();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
......@@ -2,11 +2,13 @@ EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I../../meshLibrary/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface \
-lfiniteVolume \
-ledgeMesh \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary
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
$(workflowControls)/workflowControls.C
LIB = $(FOAM_USER_LIBBIN)/libmeshLibrary
......@@ -11,4 +11,5 @@
EXE_INC = \
$(OMP_FLAGS) \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
......@@ -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::mapEdgesAndCorners()
void cartesian2DMeshGenerator::extractPatches()
{
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_);
meshSurfaceEdgeExtractor2D(mesh_, *octreePtr_).distributeBoundaryFaces();
}
# ifdef DEBUG
mesh_.write();
//::exit(0);
# endif
void cartesian2DMeshGenerator::mapEdgesAndCorners()
{
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_);
}
......
......@@ -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();