View Issue Details

IDProjectCategoryView StatusLast Update
0002229OpenFOAMPatchpublic2016-09-17 14:54
Reporteralexeym Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSScientificOS Version7.1
Summary0002229: mapFields does not reset FOAM_CASE environment variable for source case
DescriptionmapFields utility does not reset FOAM_CASE and FOAM_CASE_NAME environment variables for source case. If, for example, source case uses these variables in dictionaries it leads to wrong substitution (I discovered the bug on the cases with #include directives in controlDict).
Steps To Reproduce1. Unpack case.tar.gz (modified cavity tutorial case).
2. There are two folders source (cavity case modified to use #include directives) and target (cavity case with twice dense mesh). Run Prepare script in target folder.
3. Enjoy mapFields output.
Additional InformationPatch does three things:
1. Resolves absolute path to target case.
2. Sets FOAM_CASE and FOAM_CASE_NAME variables before creation of time in source case.
3. Restores these variables to original values after creation of time in source case.
TagsNo tags attached.

Activities

alexeym

2016-09-02 09:20

reporter  

case.tar.gz (51,657 bytes)

alexeym

2016-09-02 09:20

reporter  

mapFields.patch (1,801 bytes)   
 applications/utilities/preProcessing/mapFields/createTimes.H | 6 ++++++
 applications/utilities/preProcessing/mapFields/mapFields.C   | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/applications/utilities/preProcessing/mapFields/createTimes.H b/applications/utilities/preProcessing/mapFields/createTimes.H
index 91e6a34..bcac99a 100644
--- a/applications/utilities/preProcessing/mapFields/createTimes.H
+++ b/applications/utilities/preProcessing/mapFields/createTimes.H
@@ -1,11 +1,17 @@
     Info<< "\nCreate databases as time" << endl;
 
+    const auto caseDirOrig = getEnv("FOAM_CASE");
+    const auto caseNameOrig = getEnv("FOAM_CASE_NAME");
+    setEnv("FOAM_CASE", rootDirSource/caseDirSource, true);
+    setEnv("FOAM_CASE_NAME", caseDirSource, true);
     Time runTimeSource
     (
         Time::controlDictName,
         rootDirSource,
         caseDirSource
     );
+    setEnv("FOAM_CASE", caseDirOrig, true);
+    setEnv("FOAM_CASE_NAME", caseNameOrig, true);
 
     Time runTimeTarget
     (
diff --git a/applications/utilities/preProcessing/mapFields/mapFields.C b/applications/utilities/preProcessing/mapFields/mapFields.C
index 16e70e8..1dca92e 100644
--- a/applications/utilities/preProcessing/mapFields/mapFields.C
+++ b/applications/utilities/preProcessing/mapFields/mapFields.C
@@ -236,8 +236,8 @@ int main(int argc, char *argv[])
     fileName rootDirTarget(args.rootPath());
     fileName caseDirTarget(args.globalCaseName());
 
-    const fileName casePath = args[1];
-    const fileName rootDirSource = casePath.path();
+    fileName casePath = args[1];
+    const fileName rootDirSource = casePath.path().toAbsolute();
     const fileName caseDirSource = casePath.name();
 
     Info<< "Source: " << rootDirSource << " " << caseDirSource << endl;
mapFields.patch (1,801 bytes)   

henry

2016-09-17 14:54

manager   ~0006874

Resolved in OpenFOAM-dev commit fba2c4f29b3fa9d58351f18e19ac14679f0703bd
Resolved in OpenFOAM-4.x by commit be7fba6cff9bbf6820c5cb278a3ecad6bea61241

Issue History

Date Modified Username Field Change
2016-09-02 09:20 alexeym New Issue
2016-09-02 09:20 alexeym File Added: case.tar.gz
2016-09-02 09:20 alexeym File Added: mapFields.patch
2016-09-17 14:54 henry Assigned To => henry
2016-09-17 14:54 henry Status new => resolved
2016-09-17 14:54 henry Resolution open => fixed
2016-09-17 14:54 henry Fixed in Version => 4.x
2016-09-17 14:54 henry Note Added: 0006874