View Issue Details

IDProjectCategoryView StatusLast Update
0003780OpenFOAMFeaturepublic2024-07-10 16:47
Reportercgoessni Assigned Towill  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionwon't fix 
Platformamd64OSCentOSOS Version7
Summary0003780: only move unmapped fields if command line option is set
DescriptionmapFields and mapFieldsPar would move unmapped target fields to $FIELD_NAME.unmapped. This makes automatisation difficult. Thus, add an option moveUnmapped and only if this option is set, mapFields{,Par} would move unmapped target fields.

Patch attached.
TagsNo tags attached.

Activities

cgoessni

2022-01-13 06:19

reporter  

moveUnmapped.txt (10,397 bytes)   
--- applications/utilities/preProcessing/mapFields/MapMeshes.H.orig	2022-01-13 06:57:34.271150370 +0100
+++ applications/utilities/preProcessing/mapFields/MapMeshes.H	2022-01-13 07:06:46.937043450 +0100
@@ -41,7 +41,8 @@
 (
     const fvMesh& meshSource,
     const fvMesh& meshTarget,
-    const meshToMesh0::order& mapOrder
+    const meshToMesh0::order& mapOrder,
+    const bool moveUnmapped
 )
 {
     // Create the interpolation scheme
@@ -94,6 +95,7 @@
         );
     }
 
+    if (moveUnmapped)
     {
         // Search for list of target objects for this time
         IOobjectList objects(meshTarget, meshTarget.time().timeName());
@@ -126,7 +128,8 @@
     const fvMesh& meshTarget,
     const HashTable<word>& patchMap,
     const wordList& cuttingPatches,
-    const meshToMesh0::order& mapOrder
+    const meshToMesh0::order& mapOrder,
+    const bool moveUnmapped
 )
 {
     // Create the interpolation scheme
@@ -185,6 +188,7 @@
         );
     }
 
+    if (moveUnmapped)
     {
         // Search for list of target objects for this time
         IOobjectList objects(meshTarget, meshTarget.time().timeName());
@@ -215,7 +219,8 @@
 (
     const fvMesh& meshSource,
     const fvMesh& meshTarget,
-    const meshToMesh0::order& mapOrder
+    const meshToMesh0::order& mapOrder,
+    const bool moveUnmapped
 )
 {
     HashTable<word> patchMap;
@@ -247,7 +252,8 @@
         meshTarget,
         patchMap,
         cuttingPatchTable.toc(),
-        mapOrder
+        mapOrder,
+        moveUnmapped
     );
 }
 
--- applications/utilities/preProcessing/mapFields/mapFields.C.orig	2022-01-13 06:57:51.230718321 +0100
+++ applications/utilities/preProcessing/mapFields/mapFields.C	2022-01-13 07:05:38.604826011 +0100
@@ -78,7 +78,8 @@
     const HashTable<word>& patchMap,
     const wordList& cuttingPatches,
     const meshToMesh0::order& mapOrder,
-    const bool subtract
+    const bool subtract,
+    const bool moveUnmapped
 )
 {
     if (subtract)
@@ -89,7 +90,8 @@
             meshTarget,
             patchMap,
             cuttingPatches,
-            mapOrder
+            mapOrder,
+            moveUnmapped
         );
     }
     else
@@ -100,7 +102,8 @@
             meshTarget,
             patchMap,
             cuttingPatches,
-            mapOrder
+            mapOrder,
+            moveUnmapped
         );
     }
 }
@@ -111,7 +114,8 @@
     const fvMesh& meshSource,
     const fvMesh& meshTarget,
     const meshToMesh0::order& mapOrder,
-    const bool subtract
+    const bool subtract,
+    const bool moveUnmapped
 )
 {
     if (subtract)
@@ -120,7 +124,8 @@
         (
             meshSource,
             meshTarget,
-            mapOrder
+            mapOrder,
+            moveUnmapped
         );
     }
     else
@@ -129,7 +134,8 @@
         (
             meshSource,
             meshTarget,
-            mapOrder
+            mapOrder,
+            moveUnmapped
         );
     }
 }
@@ -228,6 +234,11 @@
         "subtract",
         "subtract mapped source from target"
     );
+    argList::addBoolOption
+    (
+        "moveUnmapped",
+        "append \".unmapped\" to unmapped fields in the target time directory"
+    );
 
     argList args(argc, argv);
 
@@ -296,6 +307,12 @@
         Info<< "Subtracting mapped source field from target" << endl;
     }
 
+    const bool moveUnmapped = args.optionFound("moveUnmapped");
+    if (moveUnmapped)
+    {
+        Info<< "Moving unmapped fields to \".unmapped\"" << endl;
+    }
+
 
     #include "createTimes.H"
 
@@ -383,7 +400,8 @@
                     meshSource,
                     meshTarget,
                     mapOrder,
-                    subtract
+                    subtract,
+                    moveUnmapped
                 );
             }
             else
@@ -395,7 +413,8 @@
                     patchMap,
                     cuttingPatches,
                     mapOrder,
-                    subtract
+                    subtract,
+                    moveUnmapped
                 );
             }
         }
@@ -462,7 +481,8 @@
                     meshSource,
                     meshTarget,
                     mapOrder,
-                    subtract
+                    subtract,
+                    moveUnmapped
                 );
             }
             else
@@ -474,7 +494,8 @@
                     patchMap,
                     addProcessorPatches(meshTarget, cuttingPatches),
                     mapOrder,
-                    subtract
+                    subtract,
+                    moveUnmapped
                 );
             }
         }
@@ -591,7 +612,8 @@
                                 meshSource,
                                 meshTarget,
                                 mapOrder,
-                                subtract
+                                subtract,
+                                moveUnmapped
                             );
                         }
                         else
@@ -603,7 +625,8 @@
                                 patchMap,
                                 addProcessorPatches(meshTarget, cuttingPatches),
                                 mapOrder,
-                                subtract
+                                subtract,
+                                moveUnmapped
                             );
                         }
                     }
@@ -642,7 +665,14 @@
 
         if (consistent)
         {
-            mapConsistentMesh(meshSource, meshTarget, mapOrder, subtract);
+            mapConsistentMesh
+            (
+                meshSource,
+                meshTarget,
+                mapOrder,
+                subtract,
+                moveUnmapped
+            );
         }
         else
         {
@@ -653,7 +683,8 @@
                 patchMap,
                 cuttingPatches,
                 mapOrder,
-                subtract
+                subtract,
+                moveUnmapped
             );
         }
     }
--- applications/utilities/preProcessing/mapFieldsPar/MapMeshes.H.orig	2022-01-13 07:10:15.797509461 +0100
+++ applications/utilities/preProcessing/mapFieldsPar/MapMeshes.H	2022-01-13 07:10:54.818489618 +0100
@@ -41,7 +41,8 @@
 (
     const meshToMesh& interp,
     const HashSet<word>& selectedFields,
-    const bool noLagrangian
+    const bool noLagrangian,
+    const bool moveUnmapped
 )
 {
     {
@@ -90,6 +91,7 @@
         );
     }
 
+    if (moveUnmapped)
     {
         const polyMesh& meshTarget = interp.tgtRegion();
 
--- applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C.orig	2022-01-13 07:10:21.830351558 +0100
+++ applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C	2022-01-13 07:13:41.222151121 +0100
@@ -44,7 +44,8 @@
     const meshToMesh::interpolationMethod& mapMethod,
     const bool subtract,
     const HashSet<word>& selectedFields,
-    const bool noLagrangian
+    const bool noLagrangian,
+    const bool moveUnmapped
 )
 {
     Info<< nl << "Consistently creating and mapping fields for time "
@@ -58,7 +59,8 @@
         (
             interp,
             selectedFields,
-            noLagrangian
+            noLagrangian,
+            moveUnmapped
         );
     }
     else
@@ -67,7 +69,8 @@
         (
             interp,
             selectedFields,
-            noLagrangian
+            noLagrangian,
+            moveUnmapped
         );
     }
 }
@@ -82,7 +85,8 @@
     const meshToMesh::interpolationMethod& mapMethod,
     const bool subtract,
     const HashSet<word>& selectedFields,
-    const bool noLagrangian
+    const bool noLagrangian,
+    const bool moveUnmapped
 )
 {
     Info<< nl << "Creating and mapping fields for time "
@@ -103,7 +107,8 @@
         (
             interp,
             selectedFields,
-            noLagrangian
+            noLagrangian,
+            moveUnmapped
         );
     }
     else
@@ -112,7 +117,8 @@
         (
             interp,
             selectedFields,
-            noLagrangian
+            noLagrangian,
+            moveUnmapped
         );
     }
 }
@@ -203,6 +209,11 @@
         "noLagrangian",
         "skip mapping lagrangian positions and fields"
     );
+    argList::addBoolOption
+    (
+        "moveUnmapped",
+        "append \".unmapped\" to unmapped fields in the target time directory"
+    );
 
     argList args(argc, argv);
 
@@ -248,6 +259,12 @@
         Info<< "Subtracting mapped source field from target" << endl;
     }
 
+    const bool moveUnmapped = args.optionFound("moveUnmapped");
+    if (moveUnmapped)
+    {
+        Info<< "Moving unmapped fields to \".unmapped\"" << endl;
+    }
+
     HashSet<word> selectedFields;
     if (args.optionFound("fields"))
     {
@@ -316,7 +333,8 @@
             mapMethod,
             subtract,
             selectedFields,
-            noLagrangian
+            noLagrangian,
+            moveUnmapped
         );
     }
     else
@@ -330,7 +348,8 @@
             mapMethod,
             subtract,
             selectedFields,
-            noLagrangian
+            noLagrangian,
+            moveUnmapped
         );
     }
 
--- etc/config.sh/bash_completion.orig	2022-01-13 07:08:43.367911023 +0100
+++ etc/config.sh/bash_completion	2022-01-13 07:14:15.980248291 +0100
@@ -1995,7 +1995,7 @@
     local line=${COMP_LINE}
     local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ")
 
-    opts="-case -consistent -doc -fileHandler -help -libs -mapMethod -noFunctionObjects -parallelSource -parallelTarget -sourceRegion -sourceTime -srcDoc -subtract -targetRegion"
+    opts="-case -consistent -doc -fileHandler -help -libs -mapMethod -moveUnmapped -noFunctionObjects -parallelSource -parallelTarget -sourceRegion -sourceTime -srcDoc -subtract -targetRegion"
     for o in $used ; do opts="${opts/$o/}" ; done
     extra="-d"
 
@@ -2026,7 +2026,7 @@
     local line=${COMP_LINE}
     local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ")
 
-    opts="-case -consistent -doc -fields -fileHandler -help -hostRoots -libs -mapMethod -noFunctionObjects -noLagrangian -parallel -roots -sourceRegion -sourceTime -srcDoc -subtract -targetRegion"
+    opts="-case -consistent -doc -fields -fileHandler -help -hostRoots -libs -mapMethod -moveUnmapped -noFunctionObjects -noLagrangian -parallel -roots -sourceRegion -sourceTime -srcDoc -subtract -targetRegion"
     for o in $used ; do opts="${opts/$o/}" ; done
     extra="-d"
 
moveUnmapped.txt (10,397 bytes)   

will

2024-07-10 16:47

manager   ~0013310

Old report. The necessity and/or benefit of this change has not been demonstrated. Adding ".unmapped" is useful because it prevents the solver from trying to load the flux (99% of time is the only non-vol-field), which will cause errors if it relates to a different mesh structure. The same is true of point fields. Closing.

Issue History

Date Modified Username Field Change
2022-01-13 06:19 cgoessni New Issue
2022-01-13 06:19 cgoessni File Added: moveUnmapped.txt
2024-07-10 16:47 will Assigned To => will
2024-07-10 16:47 will Status new => closed
2024-07-10 16:47 will Resolution open => won't fix
2024-07-10 16:47 will Note Added: 0013310