diff options
Diffstat (limited to 'src/driver/Newton.cc')
-rw-r--r-- | src/driver/Newton.cc | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/src/driver/Newton.cc b/src/driver/Newton.cc index 26460d2..44ed611 100644 --- a/src/driver/Newton.cc +++ b/src/driver/Newton.cc @@ -83,6 +83,49 @@ void Newton_step(patch_system& ps, const struct verbose_info& verbose_info); } +void track_origin(const cGH* const cctkGH, patch_system& ps, + struct AH_data* const AH_data_ptr, + const int hn, const bool print_algorithm_highlights); + + +//****************************************************************************** +// +// This function reads a coordinate origin from a grid scalar, +// and sets the patch system's origin to that new value +// +// +void track_origin(const cGH* const cctkGH, patch_system& ps, + struct AH_data* const AH_data_ptr, + const int hn, const bool print_algorithm_highlights) +{ +DECLARE_CCTK_ARGUMENTS; +DECLARE_CCTK_PARAMETERS; + +if (AH_data_ptr->depends_on == 0) { + // move the origin as specified in the grid scalars + fp const * const ox = + static_cast<CCTK_REAL const *> + (CCTK_VarDataPtr (cctkGH, 0, track_origin_source_x[hn])); + assert (ox); + fp const * const oy = + static_cast<CCTK_REAL const *> + (CCTK_VarDataPtr (cctkGH, 0, track_origin_source_y[hn])); + assert (oy); + fp const * const oz = + static_cast<CCTK_REAL const *> + (CCTK_VarDataPtr (cctkGH, 0, track_origin_source_z[hn])); + assert (oz); + if (print_algorithm_highlights) { + std::cout << "AHF tracked position ox " << *ox << " oy " << *oy << " oz " << *oz << std::endl; + } + ps.origin_x (*ox); + ps.origin_y (*oy); + ps.origin_z (*oz); +} + +} + + //****************************************************************************** // @@ -331,27 +374,8 @@ if (hs.has_genuine_horizons()) ps.synchronize(); } } - if (track_origin_from_grid_scalar[hn] && AH_data_ptr->depends_on == 0) { - // move the origin as specified in the grid scalars - fp const * const ox = - static_cast<CCTK_REAL const *> - (CCTK_VarDataPtr (cctkGH, 0, track_origin_source_x[hn])); - assert (ox); - fp const * const oy = - static_cast<CCTK_REAL const *> - (CCTK_VarDataPtr (cctkGH, 0, track_origin_source_y[hn])); - assert (oy); - fp const * const oz = - static_cast<CCTK_REAL const *> - (CCTK_VarDataPtr (cctkGH, 0, track_origin_source_z[hn])); - assert (oz); - if (verbose_info.print_algorithm_highlights) { - std::cout << "AHF tracked position ox " << *ox << " oy " << *oy << " oz " << *oz << std::endl; - } - patch_system& ps = *ps_ptr; - ps.origin_x (*ox); - ps.origin_y (*oy); - ps.origin_z (*oz); + if (track_origin_from_grid_scalar[hn]) { + track_origin(cctkGH, *ps_ptr, AH_data_ptr, hn, verbose_info.print_algorithm_highlights); } // modify the initial guess |