From e6d4b92af1ffa0204fb8225b8991f94293e454e6 Mon Sep 17 00:00:00 2001
From: Klaus <klaus.boehnlein@tu-dresden.de>
Date: Wed, 6 Jul 2022 08:56:40 +0200
Subject: [PATCH] Fix relative path issue (hopefully)

---
 inputs/cellsolver.parset                      |  4 +-
 microstructure_testsuite/helper_functions.py  |  3 +-
 .../microstructure_testsuite.py               | 60 +++++++++++--------
 src/Cell-Problem.cc                           |  3 +-
 4 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/inputs/cellsolver.parset b/inputs/cellsolver.parset
index 1b3fb6f8..2979e774 100644
--- a/inputs/cellsolver.parset
+++ b/inputs/cellsolver.parset
@@ -14,7 +14,7 @@
 
 
 ### Remove/Comment this when running via Python-Script:
-#outputPath = "../../outputs"
+outputPath=/home/klaus/Desktop/DUNE/dune-microstructure/test
 
 
 
@@ -47,7 +47,7 @@ numLevels=2 2
 ########################################################################################
 
 # --- Choose scale ratio gamma:
-gamma=0.45
+gamma=1.0
 
 
 #############################################
diff --git a/microstructure_testsuite/helper_functions.py b/microstructure_testsuite/helper_functions.py
index 1e3e3c1e..ff67f20e 100644
--- a/microstructure_testsuite/helper_functions.py
+++ b/microstructure_testsuite/helper_functions.py
@@ -110,7 +110,7 @@ def listToString(s):
     return (str1.join(str(e) for e in s))
 
 
-def SetParametersCellProblem(mu_,lambda_,rho_,alpha,beta,theta,gamma,gridLevel, ParsetFilePath = os.path.dirname(os.getcwd()) +"/inputs/cellsolver.parset"):
+def SetParametersCellProblem(mu_,lambda_,rho_,alpha,beta,theta,gamma,gridLevel, ParsetFilePath = os.path.dirname(os.getcwd()) +"/inputs/cellsolver.parset", outputPath = os.path.dirname(os.getcwd()) + '/outputs' ):
     print('----set Parameters -----')
     with open(ParsetFilePath, 'r') as file:
         filedata = file.read()
@@ -125,6 +125,7 @@ def SetParametersCellProblem(mu_,lambda_,rho_,alpha,beta,theta,gamma,gridLevel,
     filedata = re.sub('(?m)^mu1\s?=.*','mu1='+str(mu_[0]),filedata)
     filedata = re.sub('(?m)^rho1\s?=.*','rho1='+str(rho_[0]),filedata)
     filedata = re.sub('(?m)^lambda1\s?=.*','lambda1='+str(lambda_[0]),filedata)
+    filedata = re.sub('(?m)^outputPath\s?=\s?.*','outputPath='+str(outputPath),filedata)
     f = open(ParsetFilePath,'w')
     f.write(filedata)
     f.close()
diff --git a/microstructure_testsuite/microstructure_testsuite.py b/microstructure_testsuite/microstructure_testsuite.py
index f5b07312..a02d798b 100644
--- a/microstructure_testsuite/microstructure_testsuite.py
+++ b/microstructure_testsuite/microstructure_testsuite.py
@@ -12,6 +12,7 @@ from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
 import codecs
 import sys
 from helper_functions import *
+import threading
 
 #-------------------------------------------------------------------------------------------------------
 ########################
@@ -25,6 +26,8 @@ BFilePath = os.path.dirname(os.getcwd())+ '/outputs/BMatrix.txt'
 ParsetFilePath = os.path.dirname(os.getcwd()) +"/inputs/cellsolver.parset"
 parset = ' ../inputs/cellsolver.parset'
 executable = ' ../build-cmake/src/Cell-Problem'
+print('outputPath:', outputPath)
+
 
 # ----- Define Input parameters  --------------------
 phases = 2 # number of phases
@@ -48,7 +51,7 @@ gamma=1.0 #scale ratio
 
 
 # --- Choose grid-Level for computation:
-gridLevel = 3
+gridLevel = 2
 
 #############################################
 #  Choose preferred Geometry/Prestrain/Material             //TODO: Add Option for more Phases
@@ -79,8 +82,8 @@ write_VTK = False
 write_L2Error = False
 write_IntegralMean = False
 
-write_LOG = False   # writes Cell-Problem output-LOG in "Cell-Problem_output.log"
-# write_LOG = True   # writes Cell-Problem output-LOG in "Cell-Problem_output.log"
+# write_LOG = False   # writes Cell-Problem output-LOG in "Cell-Problem_output.log"
+write_LOG = True   # writes Cell-Problem output-LOG in "Cell-Problem_output.log"
 
 #---- Some of the old Material definitions use the following input parameters: (not needed when using "two_phase_material_x"):   --------
 mu1 = mu_[0]
@@ -110,31 +113,40 @@ print('---------------------------------------------------------')
 ###########################################################################################################
 
 #Set Parameters
-SetParametersCellProblem(mu_,lambda_,rho_,alpha,beta,theta,gamma,gridLevel, ParsetFilePath)
-
+SetParametersCellProblem(mu_,lambda_,rho_,alpha,beta,theta,gamma,gridLevel, ParsetFilePath, outputPath)
 
 #Run Cell-Problem
-run_CellProblem(executable,
-                parset,
-                gridLevel,
-                gamma,
-                mu1,
-                lambda1,
-                rho1,
-                alpha,
-                beta,
-                theta,
-                material_prestrain_imp,
-                outputPath,
-                write_materialFunctions,
-                write_prestrainFunctions,
-                write_VTK,
-                write_L2Error,
-                write_IntegralMean,
-                write_LOG
-                )
+thread = threading.Thread(target=run_CellProblem(executable,
+                                                    parset,
+                                                    gridLevel,
+                                                    gamma,
+                                                    mu1,
+                                                    lambda1,
+                                                    rho1,
+                                                    alpha,
+                                                    beta,
+                                                    theta,
+                                                    material_prestrain_imp,
+                                                    outputPath,
+                                                    write_materialFunctions,
+                                                    write_prestrainFunctions,
+                                                    write_VTK,
+                                                    write_L2Error,
+                                                    write_IntegralMean,
+                                                    write_LOG
+                                                    )
+                                                    )
+
+
+
+thread.start()
+
+# wait here for the result to be available before continuing
+thread.join()
 
 print('---------------------------------------------------------')
+
+
 #Read effective quantities
 print('Read effective quantities...')
 Q, B = ReadEffectiveQuantities(QFilePath,BFilePath)
diff --git a/src/Cell-Problem.cc b/src/Cell-Problem.cc
index 348371e3..9744b6ed 100644
--- a/src/Cell-Problem.cc
+++ b/src/Cell-Problem.cc
@@ -870,7 +870,8 @@ int main(int argc, char *argv[])
   //--- Output setter
 //   std::string outputPath = parameterSet.get("outputPath", "../../outputs/output.txt");
 //   std::string outputPath = parameterSet.get("outputPath", "/home/klaus/Desktop/DUNE/dune-microstructure/outputs/output.txt");
-  std::string outputPath = parameterSet.get("outputPath", "/home/klaus/Desktop/DUNE/dune-microstructure/outputs");
+//   std::string outputPath = parameterSet.get("outputPath", "/home/klaus/Desktop/DUNE/dune-microstructure/outputs");
+  std::string outputPath = parameterSet.get("outputPath", "../../outputs");
 //   std::string MatlabPath = parameterSet.get("MatlabPath", "/home/klaus/Desktop/DUNE/dune-microstructure/Matlab-Programs");
 //     std::string outputPath = "/home/klaus/Desktop/DUNE/dune-microstructure/outputs/output.txt";
   std::fstream log;
-- 
GitLab