From 86385c6e25f864470be8f8729f8cc007bf2cc9b3 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:06:04 +0100 Subject: [PATCH 01/36] ENH: IOobject: construct as copy with different name --- src/OpenFOAM/db/IOobject/IOobject.C | 21 ++++++++++++++++++++- src/OpenFOAM/db/IOobject/IOobject.H | 9 ++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index 090aea0a01..2126ee1216 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -234,6 +234,25 @@ Foam::IOobject::IOobject } +Foam::IOobject::IOobject +( + const IOobject& io, + const word& name +) +: + name_(name), + headerClassName_(io.headerClassName_), + note_(io.note_), + instance_(io.instance_), + local_(io.local_), + db_(io.db_), + rOpt_(io.rOpt_), + wOpt_(io.wOpt_), + registerObject_(io.registerObject_), + objState_(io.objState_) +{} + + // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // Foam::IOobject::~IOobject() diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index da8f443447..15f4465e9f 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -236,6 +236,13 @@ public: bool registerObject=true ); + //- Construct as copy resetting name + IOobject + ( + const IOobject& io, + const word& name + ); + //- Clone Foam::autoPtr clone() const { From 40a8318b1acace2d5e66101c4236d9ee3211a5dd Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:06:04 +0100 Subject: [PATCH 02/36] ENH: IOobject: construct as copy with different name --- src/OpenFOAM/db/IOobject/IOobject.C | 21 ++++++++++++++++++++- src/OpenFOAM/db/IOobject/IOobject.H | 9 ++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index 090aea0a01..2126ee1216 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -234,6 +234,25 @@ Foam::IOobject::IOobject } +Foam::IOobject::IOobject +( + const IOobject& io, + const word& name +) +: + name_(name), + headerClassName_(io.headerClassName_), + note_(io.note_), + instance_(io.instance_), + local_(io.local_), + db_(io.db_), + rOpt_(io.rOpt_), + wOpt_(io.wOpt_), + registerObject_(io.registerObject_), + objState_(io.objState_) +{} + + // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // Foam::IOobject::~IOobject() diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index da8f443447..15f4465e9f 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -236,6 +236,13 @@ public: bool registerObject=true ); + //- Construct as copy resetting name + IOobject + ( + const IOobject& io, + const word& name + ); + //- Clone Foam::autoPtr clone() const { From 4e9bfba3f9eb10005316d0c5909b29d2855b9dfd Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:06:56 +0100 Subject: [PATCH 03/36] ENH: syncTools: have local synchronisation (e.g. cyclics) only --- src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H | 8 +++++--- .../meshes/polyMesh/syncTools/syncToolsTemplates.C | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H index cb1484b3b0..286bfb9a50 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -164,7 +164,8 @@ public: const polyMesh&, UList&, const CombineOp& cop, - const TransformOp& top + const TransformOp& top, + const bool parRun = Pstream::parRun() ); @@ -556,7 +557,8 @@ public: ( const polyMesh& mesh, PackedList& faceValues, - const CombineOp& cop + const CombineOp& cop, + const bool parRun = Pstream::parRun() ); template diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index f9b90ae0a1..e729520288 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1316,7 +1316,8 @@ void Foam::syncTools::syncBoundaryFaceList const polyMesh& mesh, UList& faceValues, const CombineOp& cop, - const TransformOp& top + const TransformOp& top, + const bool parRun ) { const label nBFaces = mesh.nFaces() - mesh.nInternalFaces(); @@ -1327,7 +1328,7 @@ void Foam::syncTools::syncBoundaryFaceList ( "syncTools::syncBoundaryFaceList" "(const polyMesh&, UList&, const CombineOp&" - ", const bool)" + ", const TransformOp&, const bool)" ) << "Number of values " << faceValues.size() << " is not equal to the number of boundary faces in the mesh " << nBFaces << abort(FatalError); @@ -1335,7 +1336,7 @@ void Foam::syncTools::syncBoundaryFaceList const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (Pstream::parRun()) + if (parRun) { PstreamBuffers pBufs(Pstream::nonBlocking); @@ -1441,7 +1442,8 @@ void Foam::syncTools::syncFaceList ( const polyMesh& mesh, PackedList& faceValues, - const CombineOp& cop + const CombineOp& cop, + const bool parRun ) { if (faceValues.size() != mesh.nFaces()) @@ -1457,7 +1459,7 @@ void Foam::syncTools::syncFaceList const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (Pstream::parRun()) + if (parRun) { PstreamBuffers pBufs(Pstream::nonBlocking); From 42822327b59e467edba5bc42d7a5e55164abde5e Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:06:56 +0100 Subject: [PATCH 04/36] ENH: syncTools: have local synchronisation (e.g. cyclics) only --- src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H | 8 +++++--- .../meshes/polyMesh/syncTools/syncToolsTemplates.C | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H index cb1484b3b0..286bfb9a50 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -164,7 +164,8 @@ public: const polyMesh&, UList&, const CombineOp& cop, - const TransformOp& top + const TransformOp& top, + const bool parRun = Pstream::parRun() ); @@ -556,7 +557,8 @@ public: ( const polyMesh& mesh, PackedList& faceValues, - const CombineOp& cop + const CombineOp& cop, + const bool parRun = Pstream::parRun() ); template diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index f9b90ae0a1..e729520288 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1316,7 +1316,8 @@ void Foam::syncTools::syncBoundaryFaceList const polyMesh& mesh, UList& faceValues, const CombineOp& cop, - const TransformOp& top + const TransformOp& top, + const bool parRun ) { const label nBFaces = mesh.nFaces() - mesh.nInternalFaces(); @@ -1327,7 +1328,7 @@ void Foam::syncTools::syncBoundaryFaceList ( "syncTools::syncBoundaryFaceList" "(const polyMesh&, UList&, const CombineOp&" - ", const bool)" + ", const TransformOp&, const bool)" ) << "Number of values " << faceValues.size() << " is not equal to the number of boundary faces in the mesh " << nBFaces << abort(FatalError); @@ -1335,7 +1336,7 @@ void Foam::syncTools::syncBoundaryFaceList const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (Pstream::parRun()) + if (parRun) { PstreamBuffers pBufs(Pstream::nonBlocking); @@ -1441,7 +1442,8 @@ void Foam::syncTools::syncFaceList ( const polyMesh& mesh, PackedList& faceValues, - const CombineOp& cop + const CombineOp& cop, + const bool parRun ) { if (faceValues.size() != mesh.nFaces()) @@ -1457,7 +1459,7 @@ void Foam::syncTools::syncFaceList const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (Pstream::parRun()) + if (parRun) { PstreamBuffers pBufs(Pstream::nonBlocking); From e5186e0275e3862532dc3485ab14354c341c77a6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:09:08 +0100 Subject: [PATCH 05/36] ENH: pointList: simple typedef --- .../meshes/primitiveShapes/point/pointList.H | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/OpenFOAM/meshes/primitiveShapes/point/pointList.H diff --git a/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H new file mode 100644 index 0000000000..abd7f4ada0 --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Typedef + Foam::pointList + +Description + A List of points + +Typedef + Foam::pointListList + +Description + A List of labelList + +\*---------------------------------------------------------------------------*/ + +#ifndef pointList_H +#define pointList_H + +#include "point.H" +#include "List.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + // Note: frequently used UList version is located in container itself + + typedef List pointList; + typedef List pointListList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 64d066a4f037799db37bd0d755ca83ca0d86aa1b Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:09:08 +0100 Subject: [PATCH 06/36] ENH: pointList: simple typedef --- .../meshes/primitiveShapes/point/pointList.H | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/OpenFOAM/meshes/primitiveShapes/point/pointList.H diff --git a/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H new file mode 100644 index 0000000000..abd7f4ada0 --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveShapes/point/pointList.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Typedef + Foam::pointList + +Description + A List of points + +Typedef + Foam::pointListList + +Description + A List of labelList + +\*---------------------------------------------------------------------------*/ + +#ifndef pointList_H +#define pointList_H + +#include "point.H" +#include "List.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + // Note: frequently used UList version is located in container itself + + typedef List pointList; + typedef List pointListList; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From d292a909aa327f6d8625f9198f37c9c9be72aa26 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:20:40 +0100 Subject: [PATCH 07/36] ENH: fvMeshAdd: support dimensionedFields --- src/dynamicMesh/fvMeshAdder/fvMeshAdder.C | 18 ++- src/dynamicMesh/fvMeshAdder/fvMeshAdder.H | 28 ++++- .../fvMeshAdder/fvMeshAdderTemplates.C | 105 +++++++++++++++++- 3 files changed, 144 insertions(+), 7 deletions(-) diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C index 915173a142..6e1febbcd9 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,14 @@ License #include "faceCoupleInfo.H" #include "fvMesh.H" +/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ + +namespace Foam +{ +defineTypeNameAndDebug(fvMeshAdder, 0); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // //- Calculate map from new patch faces to old patch faces. -1 where @@ -108,6 +116,12 @@ Foam::autoPtr Foam::fvMeshAdder::add fvMeshAdder::MapSurfaceFields(mapPtr, mesh0, mesh1); fvMeshAdder::MapSurfaceFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + return mapPtr; } diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H index cc4240c77e..ccd869296c 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +26,7 @@ Class Description Adds two fvMeshes without using any polyMesh morphing. - Uses fvMeshAdder. + Uses polyMeshAdder. SourceFiles fvMeshAdder.C @@ -42,6 +42,7 @@ SourceFiles #include "fvPatchFieldsFwd.H" #include "fvsPatchFieldsFwd.H" #include "fvPatchFieldMapper.H" +#include "DimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -101,8 +102,22 @@ private: const GeometricField& fldToAdd ); + //- Update single dimensionedField. + template + static void MapDimField + ( + const mapAddedPolyMesh& meshMap, + + DimensionedField& fld, + const DimensionedField& fldToAdd + ); + public: + // Declare name of the class and its debug switch + ClassName("fvMeshAdder"); + + // Member Functions //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map. @@ -131,6 +146,15 @@ public: const fvMesh& mesh, const fvMesh& meshToAdd ); + + //- Map all DimensionedFields of Type + template + static void MapDimFields + ( + const mapAddedPolyMesh&, + const fvMesh& mesh, + const fvMesh& meshToAdd + ); }; diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C index 296bb3c513..41ae1918cb 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -280,6 +280,12 @@ void Foam::fvMeshAdder::MapVolFields ++fieldIter ) { + if (debug) + { + Pout<< "MapVolFields : Storing old time for " << fieldIter()->name() + << endl; + } + const_cast*>(fieldIter()) ->storeOldTimes(); } @@ -304,6 +310,12 @@ void Foam::fvMeshAdder::MapVolFields const GeometricField& fldToAdd = *fieldsToAdd[fld.name()]; + if (debug) + { + Pout<< "MapVolFields : mapping " << fld.name() + << " and " << fldToAdd.name() << endl; + } + MapVolField(meshMap, fld, fldToAdd); } else @@ -585,8 +597,13 @@ void Foam::fvMeshAdder::MapSurfaceFields ++fieldIter ) { - const_cast(fieldIter()) - ->storeOldTimes(); + if (debug) + { + Pout<< "MapSurfaceFields : Storing old time for " + << fieldIter()->name() << endl; + } + + const_cast(fieldIter())->storeOldTimes(); } @@ -604,6 +621,12 @@ void Foam::fvMeshAdder::MapSurfaceFields { const fldType& fldToAdd = *fieldsToAdd[fld.name()]; + if (debug) + { + Pout<< "MapSurfaceFields : mapping " << fld.name() + << " and " << fldToAdd.name() << endl; + } + MapSurfaceField(meshMap, fld, fldToAdd); } else @@ -617,4 +640,80 @@ void Foam::fvMeshAdder::MapSurfaceFields } +template +void Foam::fvMeshAdder::MapDimField +( + const mapAddedPolyMesh& meshMap, + + DimensionedField& fld, + const DimensionedField& fldToAdd +) +{ + const fvMesh& mesh = fld.mesh(); + + // Store old field + Field oldField(fld); + + fld.setSize(mesh.nCells()); + + fld.rmap(oldField, meshMap.oldCellMap()); + fld.rmap(fldToAdd, meshMap.addedCellMap()); +} + + +template +void Foam::fvMeshAdder::MapDimFields +( + const mapAddedPolyMesh& meshMap, + const fvMesh& mesh, + const fvMesh& meshToAdd +) +{ + typedef DimensionedField fldType; + + // Note: use strict flag on lookupClass to avoid picking up + // volFields + HashTable fields + ( + mesh.objectRegistry::lookupClass(true) + ); + + HashTable fieldsToAdd + ( + meshToAdd.objectRegistry::lookupClass(true) + ); + + for + ( + typename HashTable:: + iterator fieldIter = fields.begin(); + fieldIter != fields.end(); + ++fieldIter + ) + { + fldType& fld = const_cast(*fieldIter()); + + if (fieldsToAdd.found(fld.name())) + { + const fldType& fldToAdd = *fieldsToAdd[fld.name()]; + + if (debug) + { + Pout<< "MapDimFields : mapping " << fld.name() + << " and " << fldToAdd.name() << endl; + } + + MapDimField(meshMap, fld, fldToAdd); + } + else + { + WarningIn("fvMeshAdder::MapDimFields(..)") + << "Not mapping field " << fld.name() + << " since not present on mesh to add" + << endl; + } + } +} + + // ************************************************************************* // From b4f78778d2c2786d38915f29c6e4642205a8644c Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:20:40 +0100 Subject: [PATCH 08/36] ENH: fvMeshAdd: support dimensionedFields --- src/dynamicMesh/fvMeshAdder/fvMeshAdder.C | 18 ++- src/dynamicMesh/fvMeshAdder/fvMeshAdder.H | 28 ++++- .../fvMeshAdder/fvMeshAdderTemplates.C | 105 +++++++++++++++++- 3 files changed, 144 insertions(+), 7 deletions(-) diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C index 915173a142..6e1febbcd9 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,6 +28,14 @@ License #include "faceCoupleInfo.H" #include "fvMesh.H" +/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ + +namespace Foam +{ +defineTypeNameAndDebug(fvMeshAdder, 0); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // //- Calculate map from new patch faces to old patch faces. -1 where @@ -108,6 +116,12 @@ Foam::autoPtr Foam::fvMeshAdder::add fvMeshAdder::MapSurfaceFields(mapPtr, mesh0, mesh1); fvMeshAdder::MapSurfaceFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + fvMeshAdder::MapDimFields(mapPtr, mesh0, mesh1); + return mapPtr; } diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H index cc4240c77e..ccd869296c 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,7 +26,7 @@ Class Description Adds two fvMeshes without using any polyMesh morphing. - Uses fvMeshAdder. + Uses polyMeshAdder. SourceFiles fvMeshAdder.C @@ -42,6 +42,7 @@ SourceFiles #include "fvPatchFieldsFwd.H" #include "fvsPatchFieldsFwd.H" #include "fvPatchFieldMapper.H" +#include "DimensionedField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -101,8 +102,22 @@ private: const GeometricField& fldToAdd ); + //- Update single dimensionedField. + template + static void MapDimField + ( + const mapAddedPolyMesh& meshMap, + + DimensionedField& fld, + const DimensionedField& fldToAdd + ); + public: + // Declare name of the class and its debug switch + ClassName("fvMeshAdder"); + + // Member Functions //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map. @@ -131,6 +146,15 @@ public: const fvMesh& mesh, const fvMesh& meshToAdd ); + + //- Map all DimensionedFields of Type + template + static void MapDimFields + ( + const mapAddedPolyMesh&, + const fvMesh& mesh, + const fvMesh& meshToAdd + ); }; diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C index 296bb3c513..41ae1918cb 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -280,6 +280,12 @@ void Foam::fvMeshAdder::MapVolFields ++fieldIter ) { + if (debug) + { + Pout<< "MapVolFields : Storing old time for " << fieldIter()->name() + << endl; + } + const_cast*>(fieldIter()) ->storeOldTimes(); } @@ -304,6 +310,12 @@ void Foam::fvMeshAdder::MapVolFields const GeometricField& fldToAdd = *fieldsToAdd[fld.name()]; + if (debug) + { + Pout<< "MapVolFields : mapping " << fld.name() + << " and " << fldToAdd.name() << endl; + } + MapVolField(meshMap, fld, fldToAdd); } else @@ -585,8 +597,13 @@ void Foam::fvMeshAdder::MapSurfaceFields ++fieldIter ) { - const_cast(fieldIter()) - ->storeOldTimes(); + if (debug) + { + Pout<< "MapSurfaceFields : Storing old time for " + << fieldIter()->name() << endl; + } + + const_cast(fieldIter())->storeOldTimes(); } @@ -604,6 +621,12 @@ void Foam::fvMeshAdder::MapSurfaceFields { const fldType& fldToAdd = *fieldsToAdd[fld.name()]; + if (debug) + { + Pout<< "MapSurfaceFields : mapping " << fld.name() + << " and " << fldToAdd.name() << endl; + } + MapSurfaceField(meshMap, fld, fldToAdd); } else @@ -617,4 +640,80 @@ void Foam::fvMeshAdder::MapSurfaceFields } +template +void Foam::fvMeshAdder::MapDimField +( + const mapAddedPolyMesh& meshMap, + + DimensionedField& fld, + const DimensionedField& fldToAdd +) +{ + const fvMesh& mesh = fld.mesh(); + + // Store old field + Field oldField(fld); + + fld.setSize(mesh.nCells()); + + fld.rmap(oldField, meshMap.oldCellMap()); + fld.rmap(fldToAdd, meshMap.addedCellMap()); +} + + +template +void Foam::fvMeshAdder::MapDimFields +( + const mapAddedPolyMesh& meshMap, + const fvMesh& mesh, + const fvMesh& meshToAdd +) +{ + typedef DimensionedField fldType; + + // Note: use strict flag on lookupClass to avoid picking up + // volFields + HashTable fields + ( + mesh.objectRegistry::lookupClass(true) + ); + + HashTable fieldsToAdd + ( + meshToAdd.objectRegistry::lookupClass(true) + ); + + for + ( + typename HashTable:: + iterator fieldIter = fields.begin(); + fieldIter != fields.end(); + ++fieldIter + ) + { + fldType& fld = const_cast(*fieldIter()); + + if (fieldsToAdd.found(fld.name())) + { + const fldType& fldToAdd = *fieldsToAdd[fld.name()]; + + if (debug) + { + Pout<< "MapDimFields : mapping " << fld.name() + << " and " << fldToAdd.name() << endl; + } + + MapDimField(meshMap, fld, fldToAdd); + } + else + { + WarningIn("fvMeshAdder::MapDimFields(..)") + << "Not mapping field " << fld.name() + << " since not present on mesh to add" + << endl; + } + } +} + + // ************************************************************************* // From 431042dc232f8f0eff5af80b71d8ad5be55b8915 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Oct 2015 16:22:03 +0100 Subject: [PATCH 09/36] BUG: polyMeshGeometry: fixed updating of local geometric properties --- .../motionSmoother/motionSmootherAlgo.H | 16 ++- .../motionSmoother/motionSmootherAlgoCheck.C | 100 +++++++------- .../polyMeshGeometry/polyMeshGeometry.C | 122 +++++++++--------- 3 files changed, 128 insertions(+), 110 deletions(-) diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H index d4c1054860..724658012e 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -332,6 +332,17 @@ public: const dictionary& paramDict() const; + //- Return reference to the point motion displacement field + pointVectorField& pointDisplacement() + { + return displacement_; + } + + //- Return const reference to the point motion displacement field + const pointVectorField& pointDisplacement() const + { + return displacement_; + } // Edit @@ -339,7 +350,6 @@ public: //- Take over existing mesh position. void correct(); - //- Set patch fields on patchIDs to be consistent with // all other boundary conditions static void setDisplacementPatchFields @@ -471,6 +481,7 @@ public: const bool report, const dictionary& dict, const polyMeshGeometry&, + const pointField&, const labelList& checkFaces, labelHashSet& wrongFaces ); @@ -483,6 +494,7 @@ public: const bool report, const dictionary& dict, const polyMeshGeometry&, + const pointField&, const labelList& checkFaces, const List& baffles, labelHashSet& wrongFaces diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C index 07859539a5..8928dc29bb 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgoCheck.C @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -434,6 +434,7 @@ bool Foam::motionSmootherAlgo::checkMesh const bool report, const dictionary& dict, const polyMeshGeometry& meshGeom, + const pointField& points, const labelList& checkFaces, labelHashSet& wrongFaces ) @@ -445,6 +446,7 @@ bool Foam::motionSmootherAlgo::checkMesh report, dict, meshGeom, + points, checkFaces, emptyBaffles, wrongFaces @@ -457,6 +459,7 @@ bool Foam::motionSmootherAlgo::checkMesh const bool report, const dictionary& dict, const polyMeshGeometry& meshGeom, + const pointField& points, const labelList& checkFaces, const List& baffles, labelHashSet& wrongFaces @@ -482,14 +485,14 @@ bool Foam::motionSmootherAlgo::checkMesh ( readScalar(dict.lookup("minArea", true)) ); - //const scalar maxIntSkew - //( - // readScalar(dict.lookup("maxInternalSkewness", true)) - //); - //const scalar maxBounSkew - //( - // readScalar(dict.lookup("maxBoundarySkewness", true)) - //); + const scalar maxIntSkew + ( + readScalar(dict.lookup("maxInternalSkewness", true)) + ); + const scalar maxBounSkew + ( + readScalar(dict.lookup("maxBoundarySkewness", true)) + ); const scalar minWeight ( readScalar(dict.lookup("minFaceWeight", true)) @@ -512,7 +515,6 @@ bool Foam::motionSmootherAlgo::checkMesh ( readScalar(dict.lookup("minDeterminant", true)) ); - label nWrongFaces = 0; Info<< "Checking faces in error :" << endl; @@ -544,8 +546,8 @@ bool Foam::motionSmootherAlgo::checkMesh meshGeom.checkFacePyramids ( report, - minVol, - meshGeom.mesh().points(), + minTetQuality, + points, checkFaces, baffles, &wrongFaces @@ -566,7 +568,7 @@ bool Foam::motionSmootherAlgo::checkMesh ( report, minTetQuality, - meshGeom.mesh().points(), + points, checkFaces, baffles, &wrongFaces @@ -575,7 +577,7 @@ bool Foam::motionSmootherAlgo::checkMesh label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp