/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright held by original author \\/ 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application mapFields Description Maps volume fields from one mesh to another, reading and interpolating all fields present in the time directory of both cases. Parallel and non-parallel cases are handled without the need to reconstruct them first. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" #include "meshToMesh.H" #include "MapVolFields.H" #include "MapConsistentVolFields.H" #include "UnMapped.H" #include "processorFvPatch.H" #include "mapLagrangian.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int getTimeIndex ( const instantList& times, const scalar t ) { int nearestIndex = -1; scalar nearestDiff = Foam::GREAT; forAll(times, timeIndex) { if (times[timeIndex].name() == "constant") continue; scalar diff = fabs(times[timeIndex].value() - t); if (diff < nearestDiff) { nearestDiff = diff; nearestIndex = timeIndex; } } return nearestIndex; } void mapConsistentMesh ( const fvMesh& meshSource, const fvMesh& meshTarget ) { // 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); MapConsistentVolFields(objects, meshToMeshInterp); MapConsistentVolFields(objects, meshToMeshInterp); MapConsistentVolFields(objects, meshToMeshInterp); MapConsistentVolFields(objects, meshToMeshInterp); } { // 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); } void mapSubMesh ( const fvMesh& meshSource, const fvMesh& meshTarget, const HashTable& patchMap, const wordList& cuttingPatches ) { // 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); MapVolFields(objects, meshToMeshInterp); MapVolFields(objects, meshToMeshInterp); MapVolFields(objects, meshToMeshInterp); MapVolFields(objects, meshToMeshInterp); } { // 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); } void mapConsistentSubMesh ( const fvMesh& meshSource, const fvMesh& meshTarget ) { HashTable patchMap; HashTable