From e40207b6b506d12113e87d982ac509ba0a79be99 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 11:59:39 +0100 Subject: [PATCH 01/56] Windows scotch decomposition build fix --- ThirdParty/mingwBuild/build.sh | 5 +++-- .../mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ThirdParty/mingwBuild/build.sh b/ThirdParty/mingwBuild/build.sh index a10de7bf9..d095c5443 100644 --- a/ThirdParty/mingwBuild/build.sh +++ b/ThirdParty/mingwBuild/build.sh @@ -151,13 +151,14 @@ build_library() { system) cd $INSTALL_DIR - patch system + patch $PACKAGE ;; pthreads-w32-2-9-1-release) download $PACKAGE.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip > $LOG_FILE 2>&1 unzip_dir $PACKAGE >> $LOG_FILE 2>&1 patch $PACKAGE + mv $PACKAGE $INSTALL_DIR ;; metis-5.1.0) @@ -222,7 +223,7 @@ build_library() { ;; scotch_6.0.4) - export PTHREADS_HOME=$BUILD_DIR/pthreads-w32-2-9-1-release + export PTHREADS_HOME=$INSTALL_DIR/pthreads-w32-2-9-1-release download $PACKAGE.tar.gz https://gforge.inria.fr/frs/download.php/34618 > $LOG_FILE 2>&1 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1 patch $PACKAGE diff --git a/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc b/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc index 69c4c02c0..bfb7e1ca4 100644 --- a/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc +++ b/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc @@ -46,7 +46,7 @@ LDFLAGS += -L$(MPI_ROOTDIR)/bin -lm -lmpi -lmpid #PTHREAD_ROOTDIR = $(PGMFILES)/pthread-win32 #CFLAGS_INC += -I$(PTHREAD_ROOTDIR)/include #CLIBFLAGS = -LDFLAGS += -L$(PTHREADS_HOME)/Pre-built.2/lib/x64 -lpthread +LDFLAGS += -L$(PTHREADS_HOME)/Pre-built.2/lib/x64 -lpthreadGC2 #--- zlib: Uncomment for compressed files #ZLIB_ROOTDIR = $(PGMFILES)/zlib-1.2.3 From 09c8c55ed2a1f999dc2d967c5aad0e743ee5aa49 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 12:03:07 +0100 Subject: [PATCH 02/56] Bugfix: Fixed corrupted point field on stitch --- .../triSurface/triSurface/stitchTriangles.C | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/meshTools/triSurface/triSurface/stitchTriangles.C b/src/meshTools/triSurface/triSurface/stitchTriangles.C index b5c329b45..65f0fea28 100644 --- a/src/meshTools/triSurface/triSurface/stitchTriangles.C +++ b/src/meshTools/triSurface/triSurface/stitchTriangles.C @@ -46,17 +46,12 @@ bool triSurface::stitchTriangles pointField newPoints; bool hasMerged = mergePoints(rawPoints, tol, verbose, pointMap, newPoints); - pointField& ps = storedPoints(); - - // Set the coordinates to the merged ones - ps.transfer(newPoints); - if (hasMerged) { if (verbose) { Pout<< "stitchTriangles : Merged from " << rawPoints.size() - << " points down to " << ps.size() << endl; + << " points down to " << newPoints.size() << endl; } // Reset the triangle point labels to the unique points array @@ -72,7 +67,12 @@ bool triSurface::stitchTriangles tri.region() ); - if ((newTri[0] != newTri[1]) && (newTri[0] != newTri[2]) && (newTri[1] != newTri[2])) + if + ( + (newTri[0] != newTri[1]) + && (newTri[0] != newTri[2]) + && (newTri[1] != newTri[2]) + ) { operator[](newTriangleI++) = newTri; } @@ -82,11 +82,12 @@ bool triSurface::stitchTriangles << "Removing triangle " << i << " with non-unique vertices." << endl << " vertices :" << newTri << endl - << " coordinates:" << newTri.points(ps) + << " coordinates:" << newTri.points(newPoints) << endl; } } + // If empty triangles are detected, remove them from the list if (newTriangleI != size()) { if (verbose) @@ -97,12 +98,12 @@ bool triSurface::stitchTriangles } setSize(newTriangleI); - // And possibly compact out any unused points (since used only + // Possibly compact out any unused points (since used only // by triangles that have just been deleted) // Done in two passes to save memory (pointField) // 1. Detect only - PackedBoolList pointIsUsed(ps.size()); + PackedBoolList pointIsUsed(newPoints.size()); label nPoints = 0; @@ -120,20 +121,20 @@ bool triSurface::stitchTriangles } } - if (nPoints != ps.size()) + if (nPoints != newPoints.size()) { // 2. Compact. - pointMap.setSize(ps.size()); + pointMap.setSize(newPoints.size()); label newPointI = 0; forAll(pointIsUsed, pointI) { if (pointIsUsed[pointI]) { - ps[newPointI] = ps[pointI]; + newPoints[newPointI] = newPoints[pointI]; pointMap[pointI] = newPointI++; } } - ps.setSize(newPointI); + newPoints.setSize(newPointI); newTriangleI = 0; forAll(*this, i) @@ -149,6 +150,9 @@ bool triSurface::stitchTriangles } } } + + // Set the coordinates to the merged ones + storedPoints().transfer(newPoints); } return hasMerged; From 67bc2639e1ab7f7354a2da98de3b6bd6b35c1be2 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 12:04:47 +0100 Subject: [PATCH 03/56] Clean-up and formatting --- src/meshTools/searchableSurface/triSurfaceMesh.H | 4 +++- .../booleanOps/booleanSurface/booleanSurface.H | 3 ++- .../triSurface/orientedSurface/orientedSurface.H | 10 +++++++--- .../triSurface/treeDataTriSurface/treeDataTriSurface.C | 4 ++-- .../triSurface/treeDataTriSurface/treeDataTriSurface.H | 3 ++- .../triSurface/triSurfaceSearch/triSurfaceSearch.C | 7 +++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.H b/src/meshTools/searchableSurface/triSurfaceMesh.H index a9825900e..e81d30a25 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.H +++ b/src/meshTools/searchableSurface/triSurfaceMesh.H @@ -249,6 +249,7 @@ public: List& ) const; + // Other //- Set bounds of surface. Bounds currently set as list of @@ -271,7 +272,8 @@ public: // indices) get the specified field. Misses do not get set. virtual void getField ( - const List&, labelList& + const List&, + labelList& ) const; diff --git a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H index fb46a2979..4d8463f6c 100644 --- a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H +++ b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H @@ -25,7 +25,8 @@ Class Foam::booleanSurface Description - Surface-surface intersection. Given two surfaces construct combined surface. + Surface-surface intersection. + Given two surfaces construct a combined surface. Called 'boolean' since the volume of resulting surface will encompass the volumes of the original surface according to some boolean operation: diff --git a/src/meshTools/triSurface/orientedSurface/orientedSurface.H b/src/meshTools/triSurface/orientedSurface/orientedSurface.H index d685fa3bb..3e39b30d7 100644 --- a/src/meshTools/triSurface/orientedSurface/orientedSurface.H +++ b/src/meshTools/triSurface/orientedSurface/orientedSurface.H @@ -46,7 +46,7 @@ namespace Foam // Forward declaration of classes /*---------------------------------------------------------------------------*\ - Class orientedSurface Declaration + Class orientedSurface Declaration \*---------------------------------------------------------------------------*/ class orientedSurface @@ -148,8 +148,12 @@ public: //- Flip faces such that normals are consistent with point: // orientOutside=true : point outside surface // orientOutside=false : point inside surface - static bool orient(triSurface&, const point&, const bool orientOutside); - + static bool orient + ( + triSurface&, + const point&, + const bool orientOutside + ); }; diff --git a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C index 709918323..218dd5cb0 100644 --- a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C +++ b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C @@ -216,8 +216,8 @@ Foam::label Foam::treeDataTriSurface::getVolumeType sample, max ( - Foam::sqr(GREAT), - Foam::magSqr(treeBb.span()) + sqr(GREAT), + magSqr(treeBb.span()) ) ); diff --git a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H index beb41ddbf..610c5950f 100644 --- a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H +++ b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H @@ -108,7 +108,8 @@ public: // Search - //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. + //- Get type (inside, outside, mixed, unknown) of point + // with respect to a surface. // Only makes sense for closed surfaces. label getVolumeType ( diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index bf6d8dd33..092bdb7af 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -174,8 +174,11 @@ tmp triSurfaceSearch::calcNearest } -pointIndexHit triSurfaceSearch::nearest(const point& pt, const vector& span) - const +pointIndexHit triSurfaceSearch::nearest +( + const point& pt, + const vector& span +) const { const scalar nearestDistSqr = 0.25*magSqr(span); From e22b7afdfe887197afee9b3f51cbec204bd4fc4e Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 12:19:45 +0100 Subject: [PATCH 04/56] Bugfix: Windows scotch compilation --- etc/prefs.sh.mingw | 2 +- src/decompositionMethods/scotchDecomp/Make/options | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/prefs.sh.mingw b/etc/prefs.sh.mingw index acafa9304..2190e1933 100644 --- a/etc/prefs.sh.mingw +++ b/etc/prefs.sh.mingw @@ -105,7 +105,7 @@ export PARMGRIDGEN_INCLUDE_DIR=$PARMGRIDGEN_DIR/include # System installed Scotch #export SCOTCH_SYSTEM=1 -export SCOTCH_DIR=$WM_THIRD_PARTY_DIR/packages/scotch_6.0.0 +export SCOTCH_DIR=$WM_THIRD_PARTY_DIR/packages/scotch_6.0.4 export SCOTCH_BIN_DIR=$SCOTCH_DIR/bin export SCOTCH_LIB_DIR=$SCOTCH_DIR/lib export SCOTCH_INCLUDE_DIR=$SCOTCH_DIR/include diff --git a/src/decompositionMethods/scotchDecomp/Make/options b/src/decompositionMethods/scotchDecomp/Make/options index 3ac7982b4..5092e51cb 100644 --- a/src/decompositionMethods/scotchDecomp/Make/options +++ b/src/decompositionMethods/scotchDecomp/Make/options @@ -17,6 +17,7 @@ LIB_LIBS = \ -ldecompositionMethods \ -L$(SCOTCH_LIB_DIR) -lscotch \ -L$(SCOTCH_LIB_DIR) -lscotcherrexit \ + -L$(WM_THIRD_PARTY_DIR)/packages/pthreads-w32-2-9-1-release/Pre-built.2/lib/x64 -lpthreadGC2 \ -L$(OPENMPI_DIR)/lib -lmpi #else From e1b0c3361176737b9332e9c4bc5e6be8ddad9f93 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 11:59:39 +0100 Subject: [PATCH 05/56] Windows scotch decomposition build fix --- ThirdParty/mingwBuild/build.sh | 5 +++-- .../mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ThirdParty/mingwBuild/build.sh b/ThirdParty/mingwBuild/build.sh index a10de7bf9..d095c5443 100644 --- a/ThirdParty/mingwBuild/build.sh +++ b/ThirdParty/mingwBuild/build.sh @@ -151,13 +151,14 @@ build_library() { system) cd $INSTALL_DIR - patch system + patch $PACKAGE ;; pthreads-w32-2-9-1-release) download $PACKAGE.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip > $LOG_FILE 2>&1 unzip_dir $PACKAGE >> $LOG_FILE 2>&1 patch $PACKAGE + mv $PACKAGE $INSTALL_DIR ;; metis-5.1.0) @@ -222,7 +223,7 @@ build_library() { ;; scotch_6.0.4) - export PTHREADS_HOME=$BUILD_DIR/pthreads-w32-2-9-1-release + export PTHREADS_HOME=$INSTALL_DIR/pthreads-w32-2-9-1-release download $PACKAGE.tar.gz https://gforge.inria.fr/frs/download.php/34618 > $LOG_FILE 2>&1 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1 patch $PACKAGE diff --git a/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc b/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc index 69c4c02c0..bfb7e1ca4 100644 --- a/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc +++ b/ThirdParty/mingwBuild/x64/patches/scotch_6.0.4/src/Makefile.inc @@ -46,7 +46,7 @@ LDFLAGS += -L$(MPI_ROOTDIR)/bin -lm -lmpi -lmpid #PTHREAD_ROOTDIR = $(PGMFILES)/pthread-win32 #CFLAGS_INC += -I$(PTHREAD_ROOTDIR)/include #CLIBFLAGS = -LDFLAGS += -L$(PTHREADS_HOME)/Pre-built.2/lib/x64 -lpthread +LDFLAGS += -L$(PTHREADS_HOME)/Pre-built.2/lib/x64 -lpthreadGC2 #--- zlib: Uncomment for compressed files #ZLIB_ROOTDIR = $(PGMFILES)/zlib-1.2.3 From 9e29f21409202d99d857b3f3ff3ea387d8457e12 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 12:03:07 +0100 Subject: [PATCH 06/56] Bugfix: Fixed corrupted point field on stitch --- .../triSurface/triSurface/stitchTriangles.C | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/meshTools/triSurface/triSurface/stitchTriangles.C b/src/meshTools/triSurface/triSurface/stitchTriangles.C index b5c329b45..65f0fea28 100644 --- a/src/meshTools/triSurface/triSurface/stitchTriangles.C +++ b/src/meshTools/triSurface/triSurface/stitchTriangles.C @@ -46,17 +46,12 @@ bool triSurface::stitchTriangles pointField newPoints; bool hasMerged = mergePoints(rawPoints, tol, verbose, pointMap, newPoints); - pointField& ps = storedPoints(); - - // Set the coordinates to the merged ones - ps.transfer(newPoints); - if (hasMerged) { if (verbose) { Pout<< "stitchTriangles : Merged from " << rawPoints.size() - << " points down to " << ps.size() << endl; + << " points down to " << newPoints.size() << endl; } // Reset the triangle point labels to the unique points array @@ -72,7 +67,12 @@ bool triSurface::stitchTriangles tri.region() ); - if ((newTri[0] != newTri[1]) && (newTri[0] != newTri[2]) && (newTri[1] != newTri[2])) + if + ( + (newTri[0] != newTri[1]) + && (newTri[0] != newTri[2]) + && (newTri[1] != newTri[2]) + ) { operator[](newTriangleI++) = newTri; } @@ -82,11 +82,12 @@ bool triSurface::stitchTriangles << "Removing triangle " << i << " with non-unique vertices." << endl << " vertices :" << newTri << endl - << " coordinates:" << newTri.points(ps) + << " coordinates:" << newTri.points(newPoints) << endl; } } + // If empty triangles are detected, remove them from the list if (newTriangleI != size()) { if (verbose) @@ -97,12 +98,12 @@ bool triSurface::stitchTriangles } setSize(newTriangleI); - // And possibly compact out any unused points (since used only + // Possibly compact out any unused points (since used only // by triangles that have just been deleted) // Done in two passes to save memory (pointField) // 1. Detect only - PackedBoolList pointIsUsed(ps.size()); + PackedBoolList pointIsUsed(newPoints.size()); label nPoints = 0; @@ -120,20 +121,20 @@ bool triSurface::stitchTriangles } } - if (nPoints != ps.size()) + if (nPoints != newPoints.size()) { // 2. Compact. - pointMap.setSize(ps.size()); + pointMap.setSize(newPoints.size()); label newPointI = 0; forAll(pointIsUsed, pointI) { if (pointIsUsed[pointI]) { - ps[newPointI] = ps[pointI]; + newPoints[newPointI] = newPoints[pointI]; pointMap[pointI] = newPointI++; } } - ps.setSize(newPointI); + newPoints.setSize(newPointI); newTriangleI = 0; forAll(*this, i) @@ -149,6 +150,9 @@ bool triSurface::stitchTriangles } } } + + // Set the coordinates to the merged ones + storedPoints().transfer(newPoints); } return hasMerged; From f6cbf149e749ce56fba6853a931265196d10c287 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 12:04:47 +0100 Subject: [PATCH 07/56] Clean-up and formatting --- src/meshTools/searchableSurface/triSurfaceMesh.H | 4 +++- .../booleanOps/booleanSurface/booleanSurface.H | 3 ++- .../triSurface/orientedSurface/orientedSurface.H | 10 +++++++--- .../triSurface/treeDataTriSurface/treeDataTriSurface.C | 4 ++-- .../triSurface/treeDataTriSurface/treeDataTriSurface.H | 3 ++- .../triSurface/triSurfaceSearch/triSurfaceSearch.C | 7 +++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.H b/src/meshTools/searchableSurface/triSurfaceMesh.H index a9825900e..e81d30a25 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.H +++ b/src/meshTools/searchableSurface/triSurfaceMesh.H @@ -249,6 +249,7 @@ public: List& ) const; + // Other //- Set bounds of surface. Bounds currently set as list of @@ -271,7 +272,8 @@ public: // indices) get the specified field. Misses do not get set. virtual void getField ( - const List&, labelList& + const List&, + labelList& ) const; diff --git a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H index fb46a2979..4d8463f6c 100644 --- a/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H +++ b/src/meshTools/triSurface/booleanOps/booleanSurface/booleanSurface.H @@ -25,7 +25,8 @@ Class Foam::booleanSurface Description - Surface-surface intersection. Given two surfaces construct combined surface. + Surface-surface intersection. + Given two surfaces construct a combined surface. Called 'boolean' since the volume of resulting surface will encompass the volumes of the original surface according to some boolean operation: diff --git a/src/meshTools/triSurface/orientedSurface/orientedSurface.H b/src/meshTools/triSurface/orientedSurface/orientedSurface.H index d685fa3bb..3e39b30d7 100644 --- a/src/meshTools/triSurface/orientedSurface/orientedSurface.H +++ b/src/meshTools/triSurface/orientedSurface/orientedSurface.H @@ -46,7 +46,7 @@ namespace Foam // Forward declaration of classes /*---------------------------------------------------------------------------*\ - Class orientedSurface Declaration + Class orientedSurface Declaration \*---------------------------------------------------------------------------*/ class orientedSurface @@ -148,8 +148,12 @@ public: //- Flip faces such that normals are consistent with point: // orientOutside=true : point outside surface // orientOutside=false : point inside surface - static bool orient(triSurface&, const point&, const bool orientOutside); - + static bool orient + ( + triSurface&, + const point&, + const bool orientOutside + ); }; diff --git a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C index 709918323..218dd5cb0 100644 --- a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C +++ b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.C @@ -216,8 +216,8 @@ Foam::label Foam::treeDataTriSurface::getVolumeType sample, max ( - Foam::sqr(GREAT), - Foam::magSqr(treeBb.span()) + sqr(GREAT), + magSqr(treeBb.span()) ) ); diff --git a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H index beb41ddbf..610c5950f 100644 --- a/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H +++ b/src/meshTools/triSurface/triSurface/treeDataTriSurface/treeDataTriSurface.H @@ -108,7 +108,8 @@ public: // Search - //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. + //- Get type (inside, outside, mixed, unknown) of point + // with respect to a surface. // Only makes sense for closed surfaces. label getVolumeType ( diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index bf6d8dd33..092bdb7af 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -174,8 +174,11 @@ tmp triSurfaceSearch::calcNearest } -pointIndexHit triSurfaceSearch::nearest(const point& pt, const vector& span) - const +pointIndexHit triSurfaceSearch::nearest +( + const point& pt, + const vector& span +) const { const scalar nearestDistSqr = 0.25*magSqr(span); From 6e02cac360b068947bcecb3d7172ee6121cc9717 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 18 Sep 2015 12:19:45 +0100 Subject: [PATCH 08/56] Bugfix: Windows scotch compilation --- etc/prefs.sh.mingw | 2 +- src/decompositionMethods/scotchDecomp/Make/options | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/prefs.sh.mingw b/etc/prefs.sh.mingw index acafa9304..2190e1933 100644 --- a/etc/prefs.sh.mingw +++ b/etc/prefs.sh.mingw @@ -105,7 +105,7 @@ export PARMGRIDGEN_INCLUDE_DIR=$PARMGRIDGEN_DIR/include # System installed Scotch #export SCOTCH_SYSTEM=1 -export SCOTCH_DIR=$WM_THIRD_PARTY_DIR/packages/scotch_6.0.0 +export SCOTCH_DIR=$WM_THIRD_PARTY_DIR/packages/scotch_6.0.4 export SCOTCH_BIN_DIR=$SCOTCH_DIR/bin export SCOTCH_LIB_DIR=$SCOTCH_DIR/lib export SCOTCH_INCLUDE_DIR=$SCOTCH_DIR/include diff --git a/src/decompositionMethods/scotchDecomp/Make/options b/src/decompositionMethods/scotchDecomp/Make/options index 3ac7982b4..5092e51cb 100644 --- a/src/decompositionMethods/scotchDecomp/Make/options +++ b/src/decompositionMethods/scotchDecomp/Make/options @@ -17,6 +17,7 @@ LIB_LIBS = \ -ldecompositionMethods \ -L$(SCOTCH_LIB_DIR) -lscotch \ -L$(SCOTCH_LIB_DIR) -lscotcherrexit \ + -L$(WM_THIRD_PARTY_DIR)/packages/pthreads-w32-2-9-1-release/Pre-built.2/lib/x64 -lpthreadGC2 \ -L$(OPENMPI_DIR)/lib -lmpi #else From 807f31fa518df3693851cc9033438b2c4bd81c5c Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 23 Sep 2015 09:43:39 +0100 Subject: [PATCH 09/56] Added Vuko Vukcevic --- ListOfContributors | 1 + 1 file changed, 1 insertion(+) diff --git a/ListOfContributors b/ListOfContributors index 67af9073d..e8a42c1b1 100644 --- a/ListOfContributors +++ b/ListOfContributors @@ -85,3 +85,4 @@ Contents: Alexander Vakhrushev Inno Gatin Alexey Matveichev + Vuko Vukcevic From 8a6332d6316ca2cadd3935a854b7d728c661c777 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 23 Sep 2015 09:43:57 +0100 Subject: [PATCH 10/56] Silent clean-up --- tutorials/mesh/cfMesh/pMesh/multipleOrifices/Allclean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/mesh/cfMesh/pMesh/multipleOrifices/Allclean b/tutorials/mesh/cfMesh/pMesh/multipleOrifices/Allclean index 9c7a965cc..4edd8413a 100755 --- a/tutorials/mesh/cfMesh/pMesh/multipleOrifices/Allclean +++ b/tutorials/mesh/cfMesh/pMesh/multipleOrifices/Allclean @@ -4,4 +4,4 @@ . $WM_PROJECT_DIR/bin/tools/CleanFunctions cleanCase -rm -r constant/polyMesh +\rm -rf constant/polyMesh From 57d8f598c424225c6d93c4811f9335abc0326c0a Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 19 Jun 2014 19:54:41 +0100 Subject: [PATCH 11/56] Draft for next release notes --- DraftReleaseNotes-nextRelease | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 DraftReleaseNotes-nextRelease diff --git a/DraftReleaseNotes-nextRelease b/DraftReleaseNotes-nextRelease new file mode 100644 index 000000000..ec6de9652 --- /dev/null +++ b/DraftReleaseNotes-nextRelease @@ -0,0 +1,7 @@ +New features: +- merged cfMesh contribution: Franjo Juretic + + +Bug fixes: +- fixed precunfigured mixing plane boundary files +- added 0 directories to cfMesh tutorials From 5c260e911501c475d286000523c17d3027a6474a Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 27 Jan 2015 12:12:53 +0000 Subject: [PATCH 12/56] Formatting Conflicts: applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C --- applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C index cf821dbc4..5f4bf526e 100644 --- a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) # include "setDeltaT.H" runTime++; - + Info<< "deltaT = " << runTime.deltaT().value() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl; bool meshChanged = mesh.update(); From 239cb5d376bb1420de3fbd816eb89e8c3f8be568 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Wed, 20 May 2015 12:26:21 +0200 Subject: [PATCH 13/56] Removed bPrime update on reverseSweep in symGaussSeidel preconditioner --- .../symGaussSeidelPrecon/symGaussSeidelPrecon.C | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/lduSolvers/lduPrecon/symGaussSeidelPrecon/symGaussSeidelPrecon.C b/src/lduSolvers/lduPrecon/symGaussSeidelPrecon/symGaussSeidelPrecon.C index 4f77a8e27..5b58b998c 100644 --- a/src/lduSolvers/lduPrecon/symGaussSeidelPrecon/symGaussSeidelPrecon.C +++ b/src/lduSolvers/lduPrecon/symGaussSeidelPrecon/symGaussSeidelPrecon.C @@ -203,11 +203,7 @@ void Foam::symGaussSeidelPrecon::precondition // Finish current x curX /= diagPtr[rowI]; - // Distribute the neighbour side using current x - for (register label curCoeff = fStart; curCoeff < fEnd; curCoeff++) - { - bPrimePtr[uPtr[curCoeff]] -= lowerPtr[curCoeff]*curX; - } + // No need to update bPrime on reverse sweep. VV, 20/May/2015. } } } @@ -325,12 +321,7 @@ void Foam::symGaussSeidelPrecon::preconditionT // Finish current x curX /= diagPtr[rowI]; - // Distribute the neighbour side using current x - for (register label curCoeff = fStart; curCoeff < fEnd; curCoeff++) - { - // Transpose multiplication. HJ, 10/Jul/2007 - bPrimePtr[uPtr[curCoeff]] -= upperPtr[curCoeff]*curX; - } + // No need to update bPrime on reverse sweep. VV, 20/May/2015. } } } From 2fef5659ceef2938db7d39dde7bc58018e408f7b Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Fri, 12 Jun 2015 08:28:07 +0200 Subject: [PATCH 14/56] Crout ILU0 algorithm: preparation for ILU1 --- src/lduSolvers/Make/files | 2 + src/lduSolvers/lduPrecon/ILUC0/ILUC0.C | 423 +++++++++++++++++++++++++ src/lduSolvers/lduPrecon/ILUC0/ILUC0.H | 154 +++++++++ 3 files changed, 579 insertions(+) create mode 100644 src/lduSolvers/lduPrecon/ILUC0/ILUC0.C create mode 100644 src/lduSolvers/lduPrecon/ILUC0/ILUC0.H diff --git a/src/lduSolvers/Make/files b/src/lduSolvers/Make/files index 7d891ced3..ecc549233 100644 --- a/src/lduSolvers/Make/files +++ b/src/lduSolvers/Make/files @@ -4,6 +4,7 @@ crMatrix/crMatrix.C lduPrecon = lduPrecon $(lduPrecon)/CholeskyPrecon/CholeskyPrecon.C $(lduPrecon)/ILU0/ILU0.C +$(lduPrecon)/ILUC0/ILUC0.C $(lduPrecon)/symGaussSeidelPrecon/symGaussSeidelPrecon.C $(lduPrecon)/amgPrecon/amgPrecon.C @@ -30,5 +31,6 @@ $(amg)/coarseAmgLevel.C amgPolicy = $(amg)/amgPolicy $(amgPolicy)/amgPolicy.C $(amgPolicy)/pamgPolicy.C +$(amgPolicy)/aamgPolicy.C LIB = $(FOAM_LIBBIN)/liblduSolvers diff --git a/src/lduSolvers/lduPrecon/ILUC0/ILUC0.C b/src/lduSolvers/lduPrecon/ILUC0/ILUC0.C new file mode 100644 index 000000000..b8ced45e7 --- /dev/null +++ b/src/lduSolvers/lduPrecon/ILUC0/ILUC0.C @@ -0,0 +1,423 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + 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. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +Class + ILUC0 + +Description + ILU preconditioning without fill in based on Crout algorithm. L and U are + calculated and stored. + + Reference: Saad, Y.: Iterative Methods for Sparse Linear Systems (2nd + Edition), SIAM, 2003. + +Author + Vuko Vukcevic, FMENA Zagreb. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "ILUC0.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(ILUC0, 0); + + lduPreconditioner:: + addasymMatrixConstructorToTable + addILUC0ditionerAsymMatrixConstructorToTable_; +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + +void Foam::ILUC0::calcFactorization() +{ + if (!matrix_.diagonal()) + { + // Get necessary const access to matrix addressing + const lduAddressing& addr = matrix_.lduAddr(); + + // Get upper/lower addressing + const label* const __restrict__ uPtr = addr.upperAddr().begin(); + const label* const __restrict__ lPtr = addr.lowerAddr().begin(); + + // Get owner start addressing + const label* const __restrict__ ownStartPtr = + addr.ownerStartAddr().begin(); + + // Get losort and losort start addressing + const label* const __restrict__ lsrPtr = addr.losortAddr().begin(); + const label* const __restrict__ lsrStartPtr = + addr.losortStartAddr().begin(); + + // Get access to factored matrix entries + scalar* __restrict__ diagPtr = preconDiag_.begin(); + scalar* __restrict__ upperPtr = preconUpper_.begin(); + scalar* __restrict__ lowerPtr = preconLower_.begin(); + + // Get access to working fields + scalar* __restrict__ zPtr = z_.begin(); + scalar* __restrict__ wPtr = w_.begin(); + + // Get number of rows + const label nRows = preconDiag_.size(); + + // Define start and end face of this row/column, and number of nonzero + // off diagonal entries + register label fStart, fEnd, fLsrStart, fLsrEnd; + + // Crout LU factorization + + // Row by row loop (k - loop). + for (register label rowI = 0; rowI < nRows; ++rowI) + { + // Start and end of k-th row (upper) and k-th column (lower) + fStart = ownStartPtr[rowI]; + fEnd = ownStartPtr[rowI + 1]; + + // Initialize temporary working diagonal + zDiag_ = diagPtr[rowI]; + + // Initialize temporary working row field + for (register label faceI = fStart; faceI < fEnd; ++faceI) + { + // Note: z addressed by neighbour of face (column index for + // upper) + zPtr[uPtr[faceI]] = upperPtr[faceI]; + } + + // Start and end of k-th row (lower) and k-th column (upper) + fLsrStart = lsrStartPtr[rowI]; + fLsrEnd = lsrStartPtr[rowI + 1]; + + // Lower coeff loop (first i - loop) + for + ( + register label faceLsrI = fLsrStart; + faceLsrI < fLsrEnd; + ++faceLsrI + ) + { + // Get losort coefficient for this face + const register label losortCoeff = lsrPtr[faceLsrI]; + + // Get corresponding row index for upper (i label) + const label i = lPtr[losortCoeff]; + + // Update diagonal + zDiag_ -= lowerPtr[losortCoeff]*upperPtr[losortCoeff]; + + // Get end of row for cell i + const register label fEndRowi = ownStartPtr[i + 1]; + + // Upper coeff loop (additional loop to avoid checking the + // existence of certain upper coeffs) + for + ( + // Diagonal is already updated (losortCoeff + 1 = start) + register label faceI = losortCoeff + 1; + faceI < fEndRowi; + ++faceI + ) + { + // Note: z addressed by neighbour of face (column index for + // upper) + zPtr[uPtr[faceI]] -= lowerPtr[losortCoeff]*upperPtr[faceI]; + } + } + + for (register label faceI = fStart; faceI < fEnd; ++faceI) + { + // Note: w addressed by neighbour of face (row index for lower) + wPtr[uPtr[faceI]] = lowerPtr[faceI]; + } + + // Upper coeff loop (second i - loop) + for + ( + register label faceLsrI = fLsrStart; + faceLsrI < fLsrEnd; + ++faceLsrI + ) + { + // Get losort coefficient for this face + const register label losortCoeff = lsrPtr[faceLsrI]; + + // Get corresponding column index for lower (i label) + const label i = lPtr[losortCoeff]; + + // Get end of column for cell i + const register label fEndColumni = ownStartPtr[i + 1]; + + // Lower coeff loop (additional loop to avoid checking the + // existance of certain lower coeffs) + for + ( + register label faceI = losortCoeff + 1; + faceI < fEndColumni; + ++faceI + ) + { + // Note: w addressed by neighbour of face (row index for + // lower) + wPtr[uPtr[faceI]] -= upperPtr[losortCoeff]*lowerPtr[faceI]; + } + } + + // Update diagonal entry, inverting it for future use + scalar& diagRowI = diagPtr[rowI]; + diagRowI = 1.0/zDiag_; + + // Index for updating L and U + register label zwIndex; + + // Update upper and lower coeffs + for (register label faceI = fStart; faceI < fEnd; ++faceI) + { + // Get index for current face + zwIndex = uPtr[faceI]; + + // Update L and U decomposition for this row (column) + upperPtr[faceI] = zPtr[zwIndex]; + lowerPtr[faceI] = wPtr[zwIndex]*diagRowI; + } + + // Reset temporary working fields + // NOTE: RESET ONLY COEFFS THAT HAVE BEEN TEMPERED WITH + zDiag_ = 0; + for (register label i = 0; i < nRows; ++i) + { + zPtr[i] = wPtr[i] = 0; + } + } + } + else + { + forAll (preconDiag_, i) + { + preconDiag_[i] = 1.0/preconDiag_[i]; + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::ILUC0::ILUC0 +( + const lduMatrix& matrix, + const FieldField& coupleBouCoeffs, + const FieldField& coupleIntCoeffs, + const lduInterfaceFieldPtrsList& interfaces, + const dictionary& dict +) +: + lduPreconditioner + ( + matrix, + coupleBouCoeffs, + coupleIntCoeffs, + interfaces + ), + preconDiag_(matrix_.diag()), + preconLower_(matrix.lower()), + preconUpper_(matrix.upper()), + zDiag_(0), + z_(preconDiag_.size(), 0), + w_(preconDiag_.size(), 0) +{ + calcFactorization(); +} + + +Foam::ILUC0::ILUC0 +( + const lduMatrix& matrix, + const FieldField& coupleBouCoeffs, + const FieldField& coupleIntCoeffs, + const lduInterfaceFieldPtrsList& interfaces +) +: + lduPreconditioner + ( + matrix, + coupleBouCoeffs, + coupleIntCoeffs, + interfaces + ), + preconDiag_(matrix_.diag()), + preconLower_(matrix.lower()), + preconUpper_(matrix.upper()), + zDiag_(0), + z_(preconDiag_.size(), 0), + w_(preconDiag_.size(), 0) +{ + calcFactorization(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::ILUC0::~ILUC0() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::ILUC0::precondition +( + scalarField& x, + const scalarField& b, + const direction +) const +{ + if (!matrix_.diagonal()) + { + // Get matrix addressing + const lduAddressing& addr = matrix_.lduAddr(); + const unallocLabelList& upperAddr = addr.upperAddr(); + const unallocLabelList& lowerAddr = addr.lowerAddr(); + const unallocLabelList& losortAddr = addr.losortAddr(); + + // Get upper matrix coefficients + const scalarField& upper = matrix_.upper(); + + // Solve Lz = b with forward substitution. preconLower_ is chosen to + // be unit triangular. z does not need to be stored + + // Initialize x field + x = b; + + label losortCoeffI; + + // Forward substitution loop + forAll (preconLower_, coeffI) + { + // Get current losortCoeff to ensure row by row access + losortCoeffI = losortAddr[coeffI]; + + // Subtract already updated lower part from the solution + x[upperAddr[losortCoeffI]] -= + preconLower_[losortCoeffI]*x[lowerAddr[losortCoeffI]]; + } + + // Solve Ux = b with back substitution. U is chosen to be upper + // triangular with diagonal entries corresponding to preconDiag_ + + // Multiply with inverse diagonal + x *= preconDiag_; + + label rowI; + + // Back substitution loop + forAllReverse (upper, coeffI) + { + // Get row index + rowI = lowerAddr[coeffI]; + + // Subtract already updated upper part from the solution + x[rowI] -= upper[coeffI]*x[upperAddr[coeffI]]*preconDiag_[rowI]; + } + } + else + { + // Diagonal preconditioning + forAll(x, i) + { + x[i] = b[i]*preconDiag_[i]; + } + } +} + + +void Foam::ILUC0::preconditionT +( + scalarField& x, + const scalarField& b, + const direction cmpt +) const +{ + if (!matrix_.diagonal()) + { + // Get matrix addressing + const lduAddressing& addr = matrix_.lduAddr(); + const unallocLabelList& upperAddr = addr.upperAddr(); + const unallocLabelList& lowerAddr = addr.lowerAddr(); + const unallocLabelList& losortAddr = addr.losortAddr(); + + // Get upper matrix coefficients + const scalarField& upper = matrix_.upper(); + + // Solve U^T z = b with forward substitution. preconLower_ is chosen to + // be unit triangular - U^T (transpose U) "contains" diagonal entries. z + // does not need to be stored. + + // Initialize x field + forAll(x, i) + { + x[i] = b[i]*preconDiag_[i]; + } + + label losortCoeffI; + label rowI; + + // Forward substitution loop + forAll (upper, coeffI) + { + // Get current losortCoeff to ensure row by row access + losortCoeffI = losortAddr[coeffI]; + + // Get row index + rowI = upperAddr[losortCoeffI]; + + // Subtract already updated lower (upper transpose) part from the + // solution + x[rowI] -= upper[losortCoeffI]*x[lowerAddr[losortCoeffI]]* + preconDiag_[rowI]; + } + + // Solve L^T x = z with back substitution. L^T is unit upper triangular + + // Back substitution loop + forAllReverse (preconLower_, coeffI) + { + // Subtract already updated upper part from the solution + x[lowerAddr[coeffI]] -= preconLower_[coeffI]*x[upperAddr[coeffI]]; + } + } + else + { + // Diagonal preconditioning + forAll(x, i) + { + x[i] = b[i]*preconDiag_[i]; + } + } +} + + +// ************************************************************************* // diff --git a/src/lduSolvers/lduPrecon/ILUC0/ILUC0.H b/src/lduSolvers/lduPrecon/ILUC0/ILUC0.H new file mode 100644 index 000000000..a24ecee1f --- /dev/null +++ b/src/lduSolvers/lduPrecon/ILUC0/ILUC0.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + 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. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +Class + ILUC0 + +Description + ILU preconditioning without fill in based on Crout algorithm. L and U are + calculated and stored. + + Reference: Saad, Y.: Iterative Methods for Sparse Linear Systems (2nd + Edition), SIAM, 2003. + +Author + Vuko Vukcevic, FMENA Zagreb. All rights reserved + +SourceFiles + ILUC0.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ILUC0_H +#define ILUC0_H + +#include "lduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ILUC0 Declaration +\*---------------------------------------------------------------------------*/ + +class ILUC0 +: + public lduPreconditioner +{ + // Private Data + + //- Preconditioned diagonal + scalarField preconDiag_; + + //- Strictly lower part + scalarField preconLower_; + + //- Strictly upper part + scalarField preconUpper_; + + //- Temporary working diagonal + scalar zDiag_; + + //- Temporary working row field + scalarField z_; + + //- Temporary Working column field + scalarField w_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + ILUC0(const ILUC0&); + + //- Disallow default bitwise assignment + void operator=(const ILUC0&); + + //- Calculate LU factorization + void calcFactorization(); + + +public: + + //- Runtime type information + TypeName("ILUC0"); + + + // Constructors + + //- Construct from matrix and dictionary + ILUC0 + ( + const lduMatrix& matrix, + const FieldField& coupleBouCoeffs, + const FieldField& coupleIntCoeffs, + const lduInterfaceFieldPtrsList& interfaces, + const dictionary& dict + ); + + //- Construct from matrix as a smoother + ILUC0 + ( + const lduMatrix& matrix, + const FieldField& coupleBouCoeffs, + const FieldField& coupleIntCoeffs, + const lduInterfaceFieldPtrsList& interfaces + ); + + + // Destructor + + virtual ~ILUC0(); + + + // Member Functions + + //- Execute preconditioning + virtual void precondition + ( + scalarField& x, + const scalarField& b, + const direction cmpt = 0 + ) const; + + //- Execute preconditioning with matrix transpose + virtual void preconditionT + ( + scalarField& x, + const scalarField& b, + const direction cmpt = 0 + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 6c27c17d007336ace45d0788fab0fcd138e2d2fd Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Fri, 26 Jun 2015 09:45:31 +0200 Subject: [PATCH 15/56] extendedLduAddressing with arbitrary extension level and extendedLduMatrix classes --- src/foam/Make/files | 2 + .../extendedLduAddressing.C | 573 ++++++++++++++++++ .../extendedLduAddressing.H | 245 ++++++++ .../extendedLduMatrix/extendedLduMatrix.C | 255 ++++++++ .../extendedLduMatrix/extendedLduMatrix.H | 137 +++++ 5 files changed, 1212 insertions(+) create mode 100644 src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C create mode 100644 src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.H create mode 100644 src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.C create mode 100644 src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.H diff --git a/src/foam/Make/files b/src/foam/Make/files index ec2283a43..5989ae249 100644 --- a/src/foam/Make/files +++ b/src/foam/Make/files @@ -246,6 +246,7 @@ $(lduMatrix)/lduMatrix/lduMatrixUpdateMatrixInterfaces.C $(lduMatrix)/lduMatrix/lduMatrixSolver.C $(lduMatrix)/lduMatrix/lduMatrixSmoother.C $(lduMatrix)/lduMatrix/lduMatrixPreconditioner.C +$(lduMatrix)/lduMatrix/extendedLduMatrix/extendedLduMatrix.C $(lduMatrix)/solvers/diagonalSolver/diagonalSolver.C $(lduMatrix)/solvers/smoothSolver/smoothSolver.C @@ -269,6 +270,7 @@ $(lduMatrix)/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C lduAddressing = $(lduMatrix)/lduAddressing $(lduAddressing)/lduAddressing.C +$(lduAddressing)/extendedLduAddressing/extendedLduAddressing.C $(lduAddressing)/lduInterface/lduInterface.C $(lduAddressing)/lduInterface/processorLduInterface.C $(lduAddressing)/lduInterface/cyclicLduInterface.C diff --git a/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C b/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C new file mode 100644 index 000000000..fbf984c66 --- /dev/null +++ b/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C @@ -0,0 +1,573 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | + \\ / A nd | For copyright notice see file Copyright + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + 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. + + You should have received a copy of the GNU General Public License + along with foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "extendedLduAddressing.H" +#include "mapPolyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(extendedLduAddressing, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedLduAddressing::extendedLduAddressing +( + const polyMesh& mesh, + const lduAddressing& lduAddr, + const label extensionLevel +) +: + MeshObject(mesh), + lowerAddr_ + ( + labelList::subList + ( + mesh.faceOwner(), + mesh.nInternalFaces() + ) + ), + upperAddr_(mesh.faceNeighbour()), + lduAddr_(lduAddr), + p_(extensionLevel), + extendedLowerPtr_(NULL), + extendedUpperPtr_(NULL), + faceMapPtr_(NULL), + extendedLosortPtr_(NULL), + extendedOwnerStartPtr_(NULL), + extendedLosortStartPtr_(NULL) +{ + // Issue an error if a negative extension level is selected + if (p_ < 0) + { + FatalErrorIn + ( + "extendedLduAddressing::extendedLduAddressing" + ) + << "Negative extension level not allowed." + << abort(FatalError); + } + // Disallow extension level 0 as it is the same as ordinary lduAddressing + else if (p_ == 0) + { + FatalErrorIn + ( + "extendedLduAddressing::extendedLduAddressing" + ) + << "Extension level 0 not allowed as it is the same as ordinary " + << " lduAddressing." + << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * / + +Foam::extendedLduAddressing::~extendedLduAddressing() +{ + clearAllDemandDrivenData(); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::extendedLduAddressing::clearAllDemandDrivenData() const +{ + deleteDemandDrivenData(extendedLowerPtr_); + deleteDemandDrivenData(extendedUpperPtr_); + deleteDemandDrivenData(faceMapPtr_); + deleteDemandDrivenData(extendedLosortPtr_); + deleteDemandDrivenData(extendedOwnerStartPtr_); + deleteDemandDrivenData(extendedLosortStartPtr_); +} + + +void Foam::extendedLduAddressing::markNeighbours +( + const label& masterCellI, + const labelList& nbrCells, + const labelListList& cellCells, + HashSet