aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/Restrict.cc
blob: e81a0177165959918c3346586b8ec6f7a98f2937 (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
67
68
69
70
71
#include <assert.h>
#include <math.h>
#include <stdlib.h>

#include "cctk.h"

#include "ggf.hh"
#include "gh.hh"

#include "carpet.hh"

extern "C" {
  static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Restrict.cc,v 1.21 2003/08/10 21:59:51 schnetter Exp $";
  CCTK_FILEVERSION(Carpet_Carpet_Restrict_cc);
}



namespace Carpet {
  
  using namespace std;
  
  
  
  void Restrict (const cGH* cgh)
  {
    assert (component == -1);
    
    Checkpoint ("%*sRestrict", 2*reflevel, "");
    
    // Loop over grid functions with storage
    for (int group=0; group<CCTK_NumGroups(); ++group) {
      if (CCTK_GroupTypeI(group) == CCTK_GF
	  && CCTK_QueryGroupStorageI(cgh, group)) {
        if (arrdata[group].do_transfer) {
          for (int var=0; var<(int)arrdata[group].data.size(); ++var) {
            
            const int tl = 0;
            
            // use background time here (which may not be modified by
            // the user)
            const CCTK_REAL time = tt->time (tl, reflevel, mglevel);
            const CCTK_REAL time1 = tt->time (0, reflevel, mglevel);
            const CCTK_REAL time2 = cgh->cctk_time / cgh->cctk_delta_time;
            assert (fabs((time1 - time2) / (fabs(time1) + fabs(time2) + fabs(cgh->cctk_delta_time))) < 1e-12);
            
            if (reflevel < hh->reflevels()-1) {
              
              for (int c=0; c<hh->components(reflevel); ++c) {
                arrdata[group].data[var]->ref_restrict
                  (tl, reflevel, c, mglevel, time);
              }
              for (int c=0; c<arrdata[group].hh->components(reflevel); ++c) {
                arrdata[group].data[var]->sync (tl, reflevel, c, mglevel);
              }
              
            } // if not finest refinement level
            
          } // loop over variables
        } else {
          char * groupname = CCTK_GroupName(group);
          Checkpoint ("%*s(no restricting for group %s)",
                      2*reflevel, "", groupname);
          free (groupname);
        }
      } // if group has storage
    } // loop over groups
    
  }
  
} // namespace Carpet