aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetRegrid/src/moving.cc
blob: 075fdbb93750af10977460110bb02c66a339fe76 (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
#include <cassert>
#include <cmath>

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

#include "gh.hh"

#include "carpet.hh"
#include "regrid.hh"



namespace CarpetRegrid {
  
  using namespace std;
  using namespace Carpet;
  
  
  
  int Moving (cGH const * const cctkGH,
              gh const & hh,
              gh::rregs & regss)
  {
    DECLARE_CCTK_ARGUMENTS;
    DECLARE_CCTK_PARAMETERS;
    
    assert (refinement_levels >= 1);
    
    regss.resize (refinement_levels);
    
    bvect const symmetric (symmetry_x, symmetry_y, symmetry_z);
    b2vect const ob (false);
    b2vect const rb (true);
    
    assert (! smart_outer_boundaries);
    
    for (size_t rl=1; rl<regss.size(); ++rl) {
      
      // calculate new extent
      CCTK_REAL const argument = 2*M_PI * moving_circle_frequency * cctk_time;
      rvect const pos
        (moving_centre_x + moving_circle_radius * cos(argument),
         moving_centre_y + moving_circle_radius * sin(argument),
         moving_centre_z);
      rvect const radius
        (rvect(moving_region_radius) / rvect(spacereffacts.at(rl-1)));
      
      rvect const rlb (either (symmetric, rvect(0), pos - radius));
      rvect const rub (either (symmetric, radius  , pos + radius));
      
      region_t reg;
      reg.map = Carpet::map;
      reg.outer_boundaries = b2vect (false);
      
      vector<region_t> regs;
      ManualCoordinates_OneLevel
        (cctkGH, hh, rl, refinement_levels, rlb, rub, reg, regs);
      
      regss.at(rl) = regs;
      
    } // for rl
    
    return 1;
  }
  
} // namespace CarpetRegrid