aboutsummaryrefslogtreecommitdiff
path: root/src/copy_mask.cc
blob: 4dd0538745fe4d917444a86b84c253fe0814b8ea (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
#include <cmath>

#include <cctk.h>
#include <cctk_Arguments.h>
#include <cctk_Parameters.h>

#include "copy_mask.hh"

namespace NoExcision {

#ifdef HAVE_CARPET
  using namespace Carpet;
#endif

  /**
   * Modify the mask according to the CarpetReduce mask in order to be able to do the local reductions.
   */

  extern "C" 
    void CopyMask (CCTK_ARGUMENTS)
    {
      DECLARE_CCTK_ARGUMENTS;
      DECLARE_CCTK_PARAMETERS;

      CCTK_REAL * const weight =
        static_cast <CCTK_REAL *>
        (CCTK_VarDataPtr (cctkGH, 0, "CarpetReduce::weight"));

      if (not weight) {
        CCTK_WARN (CCTK_WARN_ABORT,
                   "CarpetReduce is not active, or CarpetReduce::mask does not have storage");
      }

      for (int k = 0; k < cctk_lsh[2]; ++ k) {
        for (int j = 0; j < cctk_lsh[1]; ++ j) {
          for (int i = 0; i < cctk_lsh[0]; ++ i) {
            int const ind = CCTK_GFINDEX3D (cctkGH, i, j, k);

            red_mask[ind] = weight[ind];
          }
        }
      }

    }


} // namespace NoExcision