From 71c6af8fe97a6782b4bcce540d6eab11cc81ac95 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 26 May 2015 11:32:46 +0100 Subject: [PATCH] mapFields: Reinstated mapFields from OpenFOAM-2.2.x and renamed the current mapFields -> mapFieldsPar This required the addition of the meshToMesh class in the sampling library from OpenFOAM-2.2.x which is now named meshToMesh0. --- .../mapFields/MapConsistentVolFields.H | 130 ++++ .../mapFields/MapLagrangianFields.H | 22 +- .../preProcessing/mapFields/MapMeshes.H | 188 +++++- .../preProcessing/mapFields/MapVolFields.H | 81 +-- .../preProcessing/mapFields/UnMapped.H | 2 +- .../preProcessing/mapFields/createTimes.H | 20 +- .../preProcessing/mapFields/mapFields.C | 563 ++++++++++++++---- .../preProcessing/mapFields/mapFieldsDict | 8 +- .../preProcessing/mapFields/mapLagrangian.C | 66 +- .../preProcessing/mapFields/mapLagrangian.H | 6 +- .../preProcessing/mapFields/setTimeIndex.H | 2 - .../preProcessing/mapFieldsPar/Make/files | 4 + .../preProcessing/mapFieldsPar/Make/options | 12 + .../mapFieldsPar/MapLagrangianFields.H | 184 ++++++ .../preProcessing/mapFieldsPar/MapMeshes.H | 131 ++++ .../preProcessing/mapFieldsPar/MapVolFields.H | 104 ++++ .../preProcessing/mapFieldsPar/UnMapped.H | 57 ++ .../preProcessing/mapFieldsPar/createTimes.H | 11 + .../preProcessing/mapFieldsPar/mapFieldsDict | 36 ++ .../preProcessing/mapFieldsPar/mapFieldsPar.C | 343 +++++++++++ .../mapFieldsPar/mapLagrangian.C | 303 ++++++++++ .../mapFieldsPar/mapLagrangian.H | 56 ++ .../preProcessing/mapFieldsPar/setTimeIndex.H | 33 + src/sampling/Make/files | 11 +- .../cellVolumeWeight/cellVolumeWeightMethod.C | 2 +- .../cellVolumeWeight/cellVolumeWeightMethod.H | 2 +- .../calcMethod/direct/directMethod.C | 0 .../calcMethod/direct/directMethod.H | 2 +- .../calcMethod/mapNearest/mapNearestMethod.C | 2 +- .../calcMethod/mapNearest/mapNearestMethod.H | 2 +- .../meshToMeshMethod/meshToMeshMethod.C | 2 +- .../meshToMeshMethod/meshToMeshMethod.H | 2 +- .../meshToMeshMethod/meshToMeshMethodI.H | 2 +- .../meshToMeshMethod/meshToMeshMethodNew.C | 2 +- .../meshToMesh/meshToMesh.C | 2 +- .../meshToMesh/meshToMesh.H | 2 +- .../meshToMesh/meshToMeshI.H | 2 +- .../meshToMesh/meshToMeshParallelOps.C | 2 +- .../meshToMesh/meshToMeshTemplates.C | 0 .../meshToMesh/weightedFvPatchFieldMapper.H | 0 .../calculateMeshToMesh0Addressing.C | 343 +++++++++++ .../meshToMesh0/calculateMeshToMesh0Weights.C | 274 +++++++++ src/sampling/meshToMesh0/meshToMesh0.C | 216 +++++++ src/sampling/meshToMesh0/meshToMesh0.H | 373 ++++++++++++ .../meshToMesh0/meshToMesh0Templates.C | 477 +++++++++++++++ 45 files changed, 3804 insertions(+), 278 deletions(-) create mode 100644 applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/Make/files create mode 100644 applications/utilities/preProcessing/mapFieldsPar/Make/options create mode 100644 applications/utilities/preProcessing/mapFieldsPar/MapLagrangianFields.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/MapMeshes.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/UnMapped.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/createTimes.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/mapFieldsDict create mode 100644 applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C create mode 100644 applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.C create mode 100644 applications/utilities/preProcessing/mapFieldsPar/mapLagrangian.H create mode 100644 applications/utilities/preProcessing/mapFieldsPar/setTimeIndex.H rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C (99%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H (98%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/direct/directMethod.C (100%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/direct/directMethod.H (98%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C (99%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/mapNearest/mapNearestMethod.H (98%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.C (99%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H (98%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethodI.H (95%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethodNew.C (97%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/meshToMesh.C (99%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/meshToMesh.H (99%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/meshToMeshI.H (97%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/meshToMeshParallelOps.C (99%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/meshToMeshTemplates.C (100%) rename src/sampling/{meshToMeshInterpolation => }/meshToMesh/weightedFvPatchFieldMapper.H (100%) create mode 100644 src/sampling/meshToMesh0/calculateMeshToMesh0Addressing.C create mode 100644 src/sampling/meshToMesh0/calculateMeshToMesh0Weights.C create mode 100644 src/sampling/meshToMesh0/meshToMesh0.C create mode 100644 src/sampling/meshToMesh0/meshToMesh0.H create mode 100644 src/sampling/meshToMesh0/meshToMesh0Templates.C diff --git a/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H new file mode 100644 index 0000000000..672573e8c3 --- /dev/null +++ b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef MapConsistentVolFields_H +#define MapConsistentVolFields_H + +#include "GeometricField.H" +#include "meshToMesh0.H" +#include "IOobjectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template +void MapConsistentVolFields +( + const IOobjectList& objects, + const meshToMesh0& meshToMesh0Interp, + const meshToMesh0::order& mapOrder, + const CombineOp& cop +) +{ + const fvMesh& meshSource = meshToMesh0Interp.fromMesh(); + const fvMesh& meshTarget = meshToMesh0Interp.toMesh(); + + word fieldClassName + ( + GeometricField::typeName + ); + + IOobjectList fields = objects.lookupClass(fieldClassName); + + forAllIter(IOobjectList, fields, fieldIter) + { + Info<< " interpolating " << fieldIter()->name() + << endl; + + // Read field + GeometricField fieldSource + ( + *fieldIter(), + meshSource + ); + + IOobject fieldTargetIOobject + ( + fieldIter()->name(), + meshTarget.time().timeName(), + meshTarget, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (fieldTargetIOobject.headerOk()) + { + // Read fieldTarget + GeometricField fieldTarget + ( + fieldTargetIOobject, + meshTarget + ); + + // Interpolate field + meshToMesh0Interp.interpolate + ( + fieldTarget, + fieldSource, + mapOrder, + cop + ); + + // Write field + fieldTarget.write(); + } + else + { + fieldTargetIOobject.readOpt() = IOobject::NO_READ; + + // Interpolate field + GeometricField fieldTarget + ( + fieldTargetIOobject, + meshToMesh0Interp.interpolate + ( + fieldSource, + mapOrder, + cop + ) + ); + + // Write field + fieldTarget.write(); + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H b/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H index 07d8d8335b..9244091d2e 100644 --- a/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H +++ b/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ Description #include "cloud.H" #include "GeometricField.H" -#include "meshToMesh.H" +#include "meshToMesh0.H" #include "IOobjectList.H" #include "CompactIOField.H" @@ -51,18 +51,19 @@ void MapLagrangianFields ( const string& cloudName, const IOobjectList& objects, - const polyMesh& meshTarget, + const meshToMesh0& meshToMesh0Interp, const labelList& addParticles ) { + const fvMesh& meshTarget = meshToMesh0Interp.toMesh(); + { IOobjectList fields = objects.lookupClass(IOField::typeName); forAllIter(IOobjectList, fields, fieldIter) { - const word& fieldName = fieldIter()->name(); - - Info<< " mapping lagrangian field " << fieldName << endl; + Info<< " mapping lagrangian field " + << fieldIter()->name() << endl; // Read field (does not need mesh) IOField fieldSource(*fieldIter()); @@ -72,7 +73,7 @@ void MapLagrangianFields ( IOobject ( - fieldName, + fieldIter()->name(), meshTarget.time().timeName(), cloud::prefix/cloudName, meshTarget, @@ -99,9 +100,8 @@ void MapLagrangianFields forAllIter(IOobjectList, fieldFields, fieldIter) { - const word& fieldName = fieldIter()->name(); - - Info<< " mapping lagrangian fieldField " << fieldName << endl; + Info<< " mapping lagrangian fieldField " + << fieldIter()->name() << endl; // Read field (does not need mesh) IOField > fieldSource(*fieldIter()); @@ -112,7 +112,7 @@ void MapLagrangianFields ( IOobject ( - fieldName, + fieldIter()->name(), meshTarget.time().timeName(), cloud::prefix/cloudName, meshTarget, diff --git a/applications/utilities/preProcessing/mapFields/MapMeshes.H b/applications/utilities/preProcessing/mapFields/MapMeshes.H index e75819f289..b11138da60 100644 --- a/applications/utilities/preProcessing/mapFields/MapMeshes.H +++ b/applications/utilities/preProcessing/mapFields/MapMeshes.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,9 +27,9 @@ License #define MapMeshes_H #include "MapVolFields.H" +#include "MapConsistentVolFields.H" #include "mapLagrangian.H" #include "UnMapped.H" -#include "pointMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,62 +37,64 @@ namespace Foam { template class CombineOp> -void MapMesh +void MapConsistentMesh ( - const meshToMesh& interp, - const HashSet& selectedFields, - const bool noLagrangian + const fvMesh& meshSource, + const fvMesh& meshTarget, + const meshToMesh0::order& mapOrder ) { - { - const polyMesh& meshSource = interp.srcRegion(); + // Create the interpolation scheme + meshToMesh0 meshToMesh0Interp(meshSource, meshTarget); + Info<< nl + << "Consistently creating and mapping fields for time " + << meshSource.time().timeName() << nl << endl; + + { // Search for list of objects for this time IOobjectList objects(meshSource, meshSource.time().timeName()); // Map volFields // ~~~~~~~~~~~~~ - MapVolFields + MapConsistentVolFields ( objects, - selectedFields, - interp, + meshToMesh0Interp, + mapOrder, CombineOp() ); - - MapVolFields + MapConsistentVolFields ( objects, - selectedFields, - interp, + meshToMesh0Interp, + mapOrder, CombineOp() ); - MapVolFields + MapConsistentVolFields ( objects, - selectedFields, - interp, + meshToMesh0Interp, + mapOrder, CombineOp() ); - MapVolFields + MapConsistentVolFields ( objects, - selectedFields, - interp, + meshToMesh0Interp, + mapOrder, CombineOp() ); - MapVolFields + MapConsistentVolFields ( objects, - selectedFields, - interp, + meshToMesh0Interp, + mapOrder, CombineOp() ); } { - const polyMesh& meshTarget = interp.tgtRegion(); - // Search for list of target objects for this time IOobjectList objects(meshTarget, meshTarget.time().timeName()); @@ -113,10 +115,140 @@ void MapMesh UnMapped(objects); } - if (!noLagrangian) + mapLagrangian(meshToMesh0Interp); +} + + +template class CombineOp> +void MapSubMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const HashTable& patchMap, + const wordList& cuttingPatches, + const meshToMesh0::order& mapOrder +) +{ + // Create the interpolation scheme + meshToMesh0 meshToMesh0Interp + ( + meshSource, + meshTarget, + patchMap, + cuttingPatches + ); + + Info<< nl + << "Mapping fields for time " << meshSource.time().timeName() + << nl << endl; + { - mapLagrangian(interp); + // Search for list of source objects for this time + IOobjectList objects(meshSource, meshSource.time().timeName()); + + // Map volFields + // ~~~~~~~~~~~~~ + MapVolFields + ( + objects, + meshToMesh0Interp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMesh0Interp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMesh0Interp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMesh0Interp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMesh0Interp, + mapOrder, + CombineOp() + ); } + + { + // Search for list of target objects for this time + IOobjectList objects(meshTarget, meshTarget.time().timeName()); + + // Mark surfaceFields as unmapped + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + + // Mark pointFields as unmapped + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + UnMapped(objects); + } + + mapLagrangian(meshToMesh0Interp); +} + + +template class CombineOp> +void MapConsistentSubMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const meshToMesh0::order& mapOrder +) +{ + HashTable patchMap; + HashTable