aboutsummaryrefslogtreecommitdiff
path: root/src/GRHydro_CarpetWeights.cc
blob: 3fb7fcf8557e22cc7e45a3a50f2cfffc7acd303e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 /*@@
   @file     GRHydro_CarpetWeights.cc
   @date     Wed Aug 20 23:08:28 2008
   @author   Luca Baiotti
   @desc 
   Copy the variable CarpetReduce::weight in a GRHydro variable.
   Written with the help of Thomas.
   @enddesc 
 @@*/

#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"

#include "SpaceMask.h"

#include <stdio.h>
#include <stdlib.h>


#ifdef __cplusplus
  extern "C" {
#endif
    
    /* Scheduled functions */
    void GRHydro_CarpetWeights(CCTK_ARGUMENTS);

#ifdef __cplusplus
  } /* extern "C" */
#endif


void GRHydro_CarpetWeights(CCTK_ARGUMENTS)
{

  DECLARE_CCTK_ARGUMENTS;
  DECLARE_CCTK_PARAMETERS;

  int i;

  // Define the variable we will use in Con2Prim (F90) as a pointer to itself
  GRHydro_CarpetWeights = (CCTK_REAL *)(CCTK_VarDataPtr(cctkGH,0,"GRHydro::GRHydro_CarpetWeights"));


  if (CCTK_IsThornActive("CarpetReduce")!=0){
    // If we use Carpet then obtain a pointer to rhe carpet variable. This will be CarpetWeights
    const CCTK_REAL *CarpetWeights = (CCTK_REAL *)(CCTK_VarDataPtr(cctkGH,0,"CarpetReduce::weight"));
    // Then assign the values of the carpet variable to the GRHydro variable
    for (i=0; i < cctk_lsh[0]*cctk_lsh[1]*cctk_lsh[2]; i++)
      {
	GRHydro_CarpetWeights[i] = CarpetWeights[i];
	//printf("%13.12e\n",GRHydro_CarpetWeights[i]);
      }
  }
  else{
    // Then assign the values of the carpet variable to the GRHydro variable
    CCTK_INFO("We are not using Carpet, so I set GRHydro_CarpetWeights equal to 1");
    for (i=0; i < cctk_lsh[0]*cctk_lsh[1]*cctk_lsh[2]; i++)
      {
	GRHydro_CarpetWeights[i] = 1; //if we do not use Carpet then we set this variable to be equal to 1
	//printf("%13.12e\n",GRHydro_CarpetWeights[i]);
      }
  }

  return;
}