Repository: einsteintoolkit/Cactus — pull request #17 (cpp)
Title: Add missing GRHydro_Minima.cc in EinsteinEvolve/GRHydro

This PR adds the missing source file GRHydro_Minima.cc to complete the EinsteinEvolve/GRHydro thorn implementation.

Resolved issues:
title: Implement the full functionality of GRHydro
body: Please implement the full functionality of `GRHydro` by finishing the code in `GRHydro_Minima.cc`.

## Thorn Information:
- Name: GRHydro
- Target file: GRHydro_Minima.cc

## Interface Definition in interface.ccl:

## Schedule Definition in schedule.ccl:

## Parameters Definition in param.ccl:

## Configuration Definition in configuration.ccl:

## Documentation Context in readme.md and doc/documentation.tex

## Related Code Context in src folder



Hints:

Fix patch:
diff --git a/arrangements/EinsteinEvolve/GRHydro/src/GRHydro_Minima.cc b/arrangements/EinsteinEvolve/GRHydro/src/GRHydro_Minima.cc
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/arrangements/EinsteinEvolve/GRHydro/src/GRHydro_Minima.cc
@@ -0,0 +1,175 @@
+ /*@@
+   @file      GRHydro_Minima.cc
+   @date      Tue Aug 29 18:52:10 2006
+   @author    
+   @desc 
+        Sets up the scalars used for the atmosphere, after initial data.
+   @enddesc 
+ @@*/
+
+#include "cctk.h"
+#include "cctk_Parameters.h"
+#include "cctk_Arguments.h"
+
+//#include "Carpet/Carpet/src/carpet.hh"
+#include "carpet.hh"
+
+#ifdef HAVE_CARPET
+using namespace Carpet;
+#endif
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+    
+    /* Scheduled functions */
+    void GRHydro_Rho_Minima_Setup_Final(CCTK_ARGUMENTS);
+
+    void GRHydro_Rho_Minima_Setup_Final_PUGH(CCTK_ARGUMENTS);
+    
+#ifdef __cplusplus
+  } /* extern "C" */
+#endif
+
+ /*@@
+   @routine    GRHydro_Rho_Minima_Setup_Final
+   @date       Tue Aug 29 18:54:05 2006
+   @author     Luca Baiotti
+   @desc 
+        After initial data, set up the scalar GRHydro_rho_min used for checking the atmosphere.
+        This is computed taking into account the actual maximum rest-mass density on the grid.
+        Version for Carpet.
+   @enddesc 
+   @calls     
+   @calledby   
+   @history 
+ 
+   @endhistory 
+@@*/
+
+void GRHydro_Rho_Minima_Setup_Final(CCTK_ARGUMENTS)
+{
+
+#ifdef HAVE_CARPET
+
+  DECLARE_CCTK_ARGUMENTS;
+  DECLARE_CCTK_PARAMETERS;
+
+  CCTK_REAL  max_rho;
+
+  static int flag = true;
+  
+  if (flag) // Actually run this reduction only the first time the routine is called.
+    {
+      if (rho_abs_min > 0.0)
+        {
+          *GRHydro_rho_min = rho_abs_min;
+        }
+      else
+        {          
+          // Go to global mode
+
+          BEGIN_GLOBAL_MODE (cctkGH) {
+
+            // Find the global maximum of rho
+
+            const int Reduction_Handle = CCTK_ReductionHandle ("maximum");
+            
+            const CCTK_INT input_array_variable_indices= {CCTK_VarIndex("HydroBase::rho")};
+            
+            const int ierr = CCTK_Reduce(cctkGH,
+                                         -1, // target processors; -1 -> all
+                                         Reduction_Handle,
+                                         1,  // number of output variables
+                                         CCTK_VARIABLE_REAL,
+                                         &max_rho,
+                                         1,  // number of variables to be reduced
+                                         input_array_variable_indices);
+            
+            if (ierr != 0)
+              {
+                CCTK_WARN(0, "Failed to compute the global maximum of rho");
+              }
+            
+            *GRHydro_rho_min = max_rho * rho_rel_min;
+            
+            // Go back to local mode
+          } END_GLOBAL_MODE;
+          
+        }
+      // After this has run once, set the flag so that this does not run again
+      flag = false;
+    } // end if (flag)
+  else
+    {
+      return;
+    }
+
+#endif
+
+  //Debug stuff
+  // char warnline;
+
+  //CCTK_VInfo (CCTK_THORNSTRING, "STEP 2: compute rho max; rho min: %13.12e \n",*GRHydro_rho_min);
+
+ //  printf(warnline,"STEP 2: compute rho max; rho min: %13.12e \n",*GRHydro_rho_min);
+ //CCTK_WARN(1,warnline);
+
+  //  printf(warnline,"STEP 3: recompute ID with new atmosphere; rho min: ', GRHydro_rho_min, 'reflev: ',%i), GRHydro_rho_min, GRHydro_reflevel);
+
+
+
+}
+
+
+ /*@@
+   @routine    GRHydro_Rho_Minima_Setup_Final_PUGH
+   @date       Tue Aug 29 18:57:42 2006
+   @author     Luca Baiotti
+   @desc 
+         As above, but for PUGH.
+   @enddesc 
+   @calls     
+   @calledby   
+   @history 
+ 
+   @endhistory 
+@@*/
+
+void GRHydro_Rho_Minima_Setup_Final_PUGH(CCTK_ARGUMENTS)
+{ 
+  DECLARE_CCTK_ARGUMENTS;
+  DECLARE_CCTK_PARAMETERS;
+  
+  CCTK_REAL  max_rho;
+  
+  if (rho_abs_min > 0.0)
+    {
+      *GRHydro_rho_min = rho_abs_min;
+    }
+  else
+    {      
+      // Find the global maximum of rho
+      
+      const int Reduction_Handle = CCTK_ReductionHandle("maximum");
+            
+      const CCTK_INT input_array_variable_indices={CCTK_VarIndex("HydroBase::rho")};
+      
+      const int ierr = CCTK_Reduce(cctkGH,
+                         -1, // target processors; -1 -> all
+                         Reduction_Handle,
+                         1,  // number of output variables   
+                         CCTK_VARIABLE_REAL,
+                         &max_rho,
+                         1,  // number of variables to be reduced
+                         input_array_variable_indices);
+      
+      if (ierr != 0)
+        {
+          CCTK_WARN(0, "Failed to compute the global maximum of rho");
+        }
+      
+      *GRHydro_rho_min = max_rho * rho_rel_min;     
+    }
+}
+

Test patch:
diff --git a/all_tests.txt b/all_tests.txt
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/all_tests.txt
@@ -0,0 +1,10 @@
+GRHydro_test_shock
+GRHydro_test_shock_mp5
+GRHydro_test_shock_ppm
+GRHydro_test_tov_ppm_ML
+GRHydro_test_tov_ppm_ML_disable_internal_excision
+GRHydro_test_tov_ppm_no_trp_ML
+test_one_hybrid
+tov_carpetevolutionmask
+tov_carpetevolutionmask2
+tov_slowsector