From 8e8eb32cc4253165011f5f2efdd4cd64ca196343 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 25 Mar 2019 15:42:29 +0000 Subject: [PATCH 01/15] ENH: limitedSnGrad: added debug writing --- .../limitedSnGrad/limitedSnGrad.C | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C index 4c6a014c25..d58c649626 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/limitedSnGrad/limitedSnGrad.C @@ -30,6 +30,7 @@ License #include "volFields.H" #include "surfaceFields.H" #include "localMax.H" +#include "fvcCellReduce.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -82,6 +83,40 @@ limitedSnGrad::correction << "limiter min: " << min(limiter.primitiveField()) << " max: "<< max(limiter.primitiveField()) << " avg: " << average(limiter.primitiveField()) << endl; + + + if (fv::debug & 2) + { + static scalar oldTime = -1; + static label subIter = 0; + if (vf.mesh().time().value() != oldTime) + { + oldTime = vf.mesh().time().value(); + subIter = 0; + } + else + { + ++subIter; + } + word fieldName("limiter_" + Foam::name(subIter)); + + GeometricField volLimiter + ( + IOobject + ( + fieldName, + vf.mesh().time().timeName(), + vf.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + fvc::cellReduce(limiter, minEqOp(), scalar(1.0)) + ); + Info<< "Writing limiter field to " << volLimiter.objectPath() + << endl; + volLimiter.write(); + } } return limiter*corr; From 40d771b3995d369ffeceaf7f8731709f7ce226f1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 27 Mar 2019 10:39:35 +0000 Subject: [PATCH 02/15] ENH: extrudeMesh: -dict. See #1253 --- .../extrude/extrudeMesh/extrudeMesh.C | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 4313846826..a247fdb059 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -217,6 +217,7 @@ int main(int argc, char *argv[]) ); #include "addRegionOption.H" + argList::addOption("dict", "file", "Use alternative extrudeMeshDict"); #include "setRootCase.H" #include "createTimeExtruded.H" @@ -236,15 +237,19 @@ int main(int argc, char *argv[]) << runTimeExtruded.timeName() << nl << endl; } - - IOdictionary dict + const IOdictionary dict ( - IOobject + IOobject::selectIO ( - "extrudeMeshDict", - runTimeExtruded.system(), - runTimeExtruded, - IOobject::MUST_READ_IF_MODIFIED + IOobject + ( + "extrudeMeshDict", + runTimeExtruded.system(), + runTimeExtruded, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ), + args.opt("dict", "") ) ); From 311581371f65998062d9a99c3e3039fed6800b7a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 27 Mar 2019 08:24:03 +0100 Subject: [PATCH 03/15] ENH: changed definition of complex::one (#1247) - was historically defined as (1 1), but it is more consistent with the concept of one to have a real component only. Now defined as (1 0): 1+0i STYLE: remove obscure '!' operator for complex conjugate - either use the member function or the '~' operator --- applications/test/complex/Test-complex.C | 5 ++--- .../Vector/complexVector/complexVector.H | 5 +++-- .../Vector/complexVector/complexVectorI.H | 15 ++++---------- src/OpenFOAM/primitives/complex/complex.C | 2 +- src/OpenFOAM/primitives/complex/complex.H | 14 ++++++------- src/OpenFOAM/primitives/complex/complexI.H | 20 ++++++++----------- 6 files changed, 25 insertions(+), 36 deletions(-) diff --git a/applications/test/complex/Test-complex.C b/applications/test/complex/Test-complex.C index 0cf31f9c85..7ee36a7d4a 100644 --- a/applications/test/complex/Test-complex.C +++ b/applications/test/complex/Test-complex.C @@ -56,11 +56,10 @@ int main(int argc, char *argv[]) << "complexVector::one : " << complexVector::one << nl << nl; - // Comparison - - for (complex c : { complex{1, 0}, complex{1, 2}} ) + for (complex c : { complex{1, 0}, complex{1, 2}} ) { print1(c); + // TDB: allow implicit construct from scalar? // // if (c == 1.0) diff --git a/src/OpenFOAM/primitives/Vector/complexVector/complexVector.H b/src/OpenFOAM/primitives/Vector/complexVector/complexVector.H index 0fa238575e..fb36af3ad8 100644 --- a/src/OpenFOAM/primitives/Vector/complexVector/complexVector.H +++ b/src/OpenFOAM/primitives/Vector/complexVector/complexVector.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011 OpenFOAM Foundation @@ -27,7 +27,7 @@ Typedef Foam::complexVector Description - complexVector obtained from generic Vector. + A Vector of complex values with 'scalar' precision. SourceFiles complexVectorI.H @@ -48,6 +48,7 @@ namespace Foam typedef Vector complexVector; } +// Functions #include "complexVectorI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H b/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H index 7e181669d1..175900b723 100644 --- a/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H +++ b/src/OpenFOAM/primitives/Vector/complexVector/complexVectorI.H @@ -23,10 +23,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - complexVector specific part of 3D complexVector obtained from - generic Vector. - \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -34,7 +30,7 @@ Description namespace Foam { -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // inline complexVector operator*(const complex& v1, const complexVector& v2) { @@ -80,8 +76,7 @@ inline complexVector operator/(const complex& v1, const complexVector& v2) } -// complexVector dot product - +//- Dot product for complexVector inline complex operator&(const complexVector& v1, const complexVector& v2) { return complex @@ -93,8 +88,7 @@ inline complex operator&(const complexVector& v1, const complexVector& v2) } -// complexVector cross product - +//- Cross product for complexVector inline complexVector operator^(const complexVector& v1, const complexVector& v2) { return complexVector @@ -106,8 +100,7 @@ inline complexVector operator^(const complexVector& v1, const complexVector& v2) } -// complexVector cross product - +//- Cross product for complexVector inline complexVector operator^(const vector& v1, const complexVector& v2) { return complexVector diff --git a/src/OpenFOAM/primitives/complex/complex.C b/src/OpenFOAM/primitives/complex/complex.C index e53a04fe52..51bd1142fb 100644 --- a/src/OpenFOAM/primitives/complex/complex.C +++ b/src/OpenFOAM/primitives/complex/complex.C @@ -32,7 +32,7 @@ License const char* const Foam::complex::typeName = "complex"; const Foam::complex Foam::complex::zero(0, 0); -const Foam::complex Foam::complex::one(1, 1); +const Foam::complex Foam::complex::one(1, 0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/complex/complex.H b/src/OpenFOAM/primitives/complex/complex.H index 8c67134d80..7e9419af48 100644 --- a/src/OpenFOAM/primitives/complex/complex.H +++ b/src/OpenFOAM/primitives/complex/complex.H @@ -98,7 +98,7 @@ public: //- A complex zero (0,0) static const complex zero; - //- A complex one (1,1) + //- A complex one (1,0) static const complex one; @@ -189,12 +189,6 @@ public: inline void operator*=(const scalar s); inline void operator/=(const scalar s); - //- Conjugate - inline complex operator~() const; - - //- Conjugate - inline complex operator!() const; - inline bool operator==(const complex& c) const; inline bool operator!=(const complex& c) const; @@ -244,6 +238,12 @@ template<> inline bool contiguous() {return true;} +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +//- Complex conjugate +inline complex operator~(const complex& c); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/complex/complexI.H b/src/OpenFOAM/primitives/complex/complexI.H index 41bfa6befd..587eb6a0bd 100644 --- a/src/OpenFOAM/primitives/complex/complexI.H +++ b/src/OpenFOAM/primitives/complex/complexI.H @@ -174,18 +174,6 @@ inline void Foam::complex::operator/=(const scalar s) } -inline Foam::complex Foam::complex::operator~() const -{ - return conjugate(); -} - - -inline Foam::complex Foam::complex::operator!() const -{ - return conjugate(); -} - - inline bool Foam::complex::operator==(const complex& c) const { return (equal(re, c.re) && equal(im, c.im)); @@ -198,6 +186,14 @@ inline bool Foam::complex::operator!=(const complex& c) const } +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +inline Foam::complex Foam::operator~(const complex& c) +{ + return c.conjugate(); +} + + // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // From 626c97cbeae364506d96aacff49fd7cd0f6aedaa Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 27 Mar 2019 08:46:10 +0100 Subject: [PATCH 04/15] STYLE: move bitSet '~' member operator to be a global operator instead --- src/OpenFOAM/containers/Bits/bitSet/bitSet.H | 7 +++---- src/OpenFOAM/containers/Bits/bitSet/bitSetI.H | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/OpenFOAM/containers/Bits/bitSet/bitSet.H b/src/OpenFOAM/containers/Bits/bitSet/bitSet.H index 2c5c283136..59429e7d70 100644 --- a/src/OpenFOAM/containers/Bits/bitSet/bitSet.H +++ b/src/OpenFOAM/containers/Bits/bitSet/bitSet.H @@ -513,10 +513,6 @@ public: //- Move assignment inline bitSet& operator=(bitSet&& bitset); - //- Complement operator. - // Return a copy of the existing set with all its bits flipped. - inline bitSet operator~() const; - //- Bitwise-AND all the bits in other with the bits in this bitset. // The operands may have dissimilar sizes without affecting the size // of the set. @@ -576,6 +572,9 @@ Ostream& operator<<(Ostream& os, const bitSet& bitset); Ostream& operator<<(Ostream& os, const InfoProxy& info); +//- Bitset complement, returns a copy of the bitset with all its bits flipped +inline bitSet operator~(const bitSet& bitset); + //- Bitwise-AND of two bitsets. // See bitSet::operator&= for more details. inline bitSet operator&(const bitSet& a, const bitSet& b); diff --git a/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H b/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H index afc7d93f97..5312caa3d1 100644 --- a/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H +++ b/src/OpenFOAM/containers/Bits/bitSet/bitSetI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -663,14 +663,6 @@ inline Foam::bitSet& Foam::bitSet::operator=(bitSet&& bitset) } -inline Foam::bitSet Foam::bitSet::operator~() const -{ - bitSet result(*this); - result.flip(); - return result; -} - - inline Foam::bitSet& Foam::bitSet::operator&=(const bitSet& other) { return andEq(other); @@ -697,6 +689,14 @@ inline Foam::bitSet& Foam::bitSet::operator-=(const bitSet& other) // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // +inline Foam::bitSet Foam::operator~(const bitSet& bitset) +{ + bitSet result(bitset); + result.flip(); + return result; +} + + inline Foam::bitSet Foam::operator&(const bitSet& a, const bitSet& b) { bitSet result(a); From 77076e5302272cc8b4dcd4e53512d4fdc4367f01 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 27 Mar 2019 09:04:13 +0100 Subject: [PATCH 05/15] STYLE: remove deprecated bitSet::used() method - The 'used()' method was for transitional compatibility with the now defunct PackedBoolList. The canonical method name for returning a labelList of 'on' bits is toc(). --- src/OpenFOAM/containers/Bits/bitSet/bitSet.H | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/OpenFOAM/containers/Bits/bitSet/bitSet.H b/src/OpenFOAM/containers/Bits/bitSet/bitSet.H index 59429e7d70..00d9430596 100644 --- a/src/OpenFOAM/containers/Bits/bitSet/bitSet.H +++ b/src/OpenFOAM/containers/Bits/bitSet/bitSet.H @@ -551,14 +551,6 @@ public: { return *this; } - - - // Housekeeping - - //- Deprecated(2018-04) compatibility name for PackedBoolList - // \deprecated(2018-04) - use toc() method - inline labelList used() const { return toc(); } - }; From 729d8e41b73d9574ef9e551125577ae26e21617c Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 27 Mar 2019 15:04:48 +0000 Subject: [PATCH 06/15] ENH: snappyHexMesh: allow cross-patch merging of patch faces. Fixes #1255. --- .../generation/snappyHexMesh/snappyHexMesh.C | 48 ++++++++---- .../polyTopoChange/combineFaces.C | 77 ++++++++++++++++--- .../polyTopoChange/combineFaces.H | 21 +++-- .../meshRefinement/meshRefinement.H | 18 ++++- .../meshRefinement/meshRefinementMerge.C | 14 ++-- .../snappyHexMeshDriver/snappyLayerDriver.C | 16 ++-- .../snappyHexMeshDriver/snappyLayerDriver.H | 6 +- .../snappyHexMeshDriver/snappyRefineDriver.C | 18 +++-- .../snappyHexMeshDriver/snappyRefineDriver.H | 6 +- .../snappyHexMeshDriver/snappySnapDriver.C | 11 ++- .../snappyHexMeshDriver/snappySnapDriver.H | 3 +- 11 files changed, 179 insertions(+), 59 deletions(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 5ac2aeb11d..d5381bc241 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011, 2015-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011, 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -1691,19 +1691,41 @@ int main(int argc, char *argv[]) } - const bool mergePatchFaces - ( - meshDict.lookupOrDefault("mergePatchFaces", true) - ); - - if (!mergePatchFaces) + // How to treat co-planar faces + meshRefinement::FaceMergeType mergeType = + meshRefinement::FaceMergeType::GEOMETRIC; { - Info<< "Not merging patch-faces of cell to preserve" - << " (split)hex cell shape." - << nl << endl; + const bool mergePatchFaces + ( + meshDict.lookupOrDefault("mergePatchFaces", true) + ); + + if (!mergePatchFaces) + { + Info<< "Not merging patch-faces of cell to preserve" + << " (split)hex cell shape." + << nl << endl; + mergeType = meshRefinement::FaceMergeType::NONE; + } + else + { + const bool mergeAcrossPatches + ( + meshDict.lookupOrDefault("mergeAcrossPatches", false) + ); + + if (mergeAcrossPatches) + { + Info<< "Merging co-planar patch-faces of cells" + << ", regardless of patch assignment" + << nl << endl; + mergeType = meshRefinement::FaceMergeType::IGNOREPATCH; + } + } } + if (wantRefine) { cpuTime timer; @@ -1732,7 +1754,7 @@ int main(int argc, char *argv[]) refineParams, snapParams, refineParams.handleSnapProblems(), - mergePatchFaces, // merge co-planar faces + mergeType, motionDict ); @@ -1784,7 +1806,7 @@ int main(int argc, char *argv[]) ( snapDict, motionDict, - mergePatchFaces, + mergeType, curvature, planarAngle, snapParams @@ -1851,7 +1873,7 @@ int main(int argc, char *argv[]) layerDict, motionDict, layerParams, - mergePatchFaces, + mergeType, preBalance, decomposer, distributor diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C index 9c47866bd4..8078b9ccfc 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C @@ -129,6 +129,7 @@ bool Foam::combineFaces::validFace void Foam::combineFaces::regioniseFaces ( const scalar minCos, + const bool mergeAcrossPatches, const label celli, const labelList& cEdges, Map