From 0f2e8be91c6bea6de15e1bb7f828e7ec4eac683b Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 22 Dec 2011 11:39:54 +0000 Subject: [PATCH] ENH: mapFields: add -subtract option to subtract whilst mapping --- .../mapFields/MapConsistentVolFields.H | 20 +- .../preProcessing/mapFields/MapMeshes.H | 263 ++++++++++++++++++ .../preProcessing/mapFields/MapVolFields.H | 13 +- .../preProcessing/mapFields/mapFields.C | 217 ++++++--------- .../meshToMesh/meshToMesh.H | 45 +-- .../meshToMesh/meshToMeshInterpolate.C | 121 ++++---- 6 files changed, 476 insertions(+), 203 deletions(-) create mode 100644 applications/utilities/preProcessing/mapFields/MapMeshes.H diff --git a/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H index 2a203eac48..9015c473a2 100644 --- a/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H +++ b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H @@ -35,12 +35,13 @@ License namespace Foam { -template +template void MapConsistentVolFields ( const IOobjectList& objects, const meshToMesh& meshToMeshInterp, - const meshToMesh::order& mapOrder + const meshToMesh::order& mapOrder, + const CombineOp& cop ) { const fvMesh& meshSource = meshToMeshInterp.fromMesh(); @@ -84,7 +85,13 @@ void MapConsistentVolFields ); // Interpolate field - meshToMeshInterp.interpolate(fieldTarget, fieldSource, mapOrder); + meshToMeshInterp.interpolate// > + ( + fieldTarget, + fieldSource, + mapOrder, + cop + ); // Write field fieldTarget.write(); @@ -97,7 +104,12 @@ void MapConsistentVolFields GeometricField fieldTarget ( fieldTargetIOobject, - meshToMeshInterp.interpolate(fieldSource, mapOrder) + meshToMeshInterp.interpolate// > + ( + fieldSource, + mapOrder, + cop + ) ); // Write field diff --git a/applications/utilities/preProcessing/mapFields/MapMeshes.H b/applications/utilities/preProcessing/mapFields/MapMeshes.H new file mode 100644 index 0000000000..e497eb0ccd --- /dev/null +++ b/applications/utilities/preProcessing/mapFields/MapMeshes.H @@ -0,0 +1,263 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 MapMeshes_H +#define MapMeshes_H + +#include "MapVolFields.H" +#include "MapConsistentVolFields.H" +#include "mapLagrangian.H" +#include "UnMapped.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template class CombineOp> +void MapConsistentMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const meshToMesh::order& mapOrder +) +{ + // Create the interpolation scheme + meshToMesh meshToMeshInterp(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 + // ~~~~~~~~~~~~~ + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapConsistentVolFields + ( + objects, + meshToMeshInterp, + 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(meshToMeshInterp); +} + + +template class CombineOp> +void MapSubMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const HashTable& patchMap, + const wordList& cuttingPatches, + const meshToMesh::order& mapOrder +) +{ + // Create the interpolation scheme + meshToMesh meshToMeshInterp + ( + meshSource, + meshTarget, + patchMap, + cuttingPatches + ); + + Info<< nl + << "Mapping fields for time " << meshSource.time().timeName() + << nl << endl; + + { + // Search for list of source objects for this time + IOobjectList objects(meshSource, meshSource.time().timeName()); + + // Map volFields + // ~~~~~~~~~~~~~ + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + mapOrder, + CombineOp() + ); + MapVolFields + ( + objects, + meshToMeshInterp, + 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(meshToMeshInterp); +} + + +template class CombineOp> +void MapConsistentSubMesh +( + const fvMesh& meshSource, + const fvMesh& meshTarget, + const meshToMesh::order& mapOrder +) +{ + HashTable patchMap; + HashTable