diff --git a/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H b/applications/utilities/preProcessing/mapFields/MapConsistentVolFields.H new file mode 100644 index 000000000..672573e8c --- /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 07d8d8335..9244091d2 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 e75819f28..b11138da6 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