Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <deque> 7 : 8 : #include "DataStructures/LinkedMessageId.hpp" 9 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp" 10 : #include "ParallelAlgorithms/ApparentHorizonFinder/Storage.hpp" 11 : #include "Utilities/Gsl.hpp" 12 : 13 : template <size_t VolumeDim> 14 : class Domain; 15 : class FastFlow; 16 : namespace ylm { 17 : template <typename Frame> 18 : class Strahlkorper; 19 : } // namespace ylm 20 : 21 : namespace ah { 22 : /*! 23 : * \brief Compute the target points for the current iteration. 24 : * 25 : * \details Returns whether the computation of the target points was successful 26 : * or if there are some points outside the domain. If computation fails, one of 27 : * two attempts to recover will happen: 28 : * 29 : * - For the zeroth fast flow iteration, this will increase the $l=0,m=0$ 30 : * coefficient (i.e. the size) by 50%. 31 : * - For all other iterations, the coefficients become 32 : * \begin{equation} 33 : * S^{\mathrm{new}}_{lm} = \frac{1}{2}\left(S^{\mathrm{previous}}_{lm} + 34 : * S^{\mathrm{failed}}_{lm}\right) 35 : * \end{equation} 36 : * where $S^{\mathrm{failed}}_{lm}$ are the coefficients of the failed 37 : * computation and $S^{\mathrm{previous}}_{lm}$ are the coefficients from 38 : * the previous successful iteration. 39 : * 40 : * This function will try recomputing the coords using the above two rules 41 : * \p max_compute_coords_retries times before returning false. 42 : * 43 : * \param current_iteration The returned pointer to the current Iteration object 44 : * \param block_order Priority order to search blocks for containing points 45 : * (see `::block_logical_coordinates` for details) 46 : * \param time The current time 47 : * \param fast_flow The FastFlow object for the current horizon find 48 : * \param initial_guess If the current iteration number is zero and 49 : * rerunning_with_higher_resolution == false, current_iteration is set to 50 : * this Strahlkorper 51 : * \param previous_iteration_surface If empty, current_iteration is set to 52 : * initial_guess; if one previous iteration, current_iteration is set to 53 : * that previous iteration; if two previous iterations, current_iteration 54 : * is set by linearly extrapolating in time the two pervious iterations; 55 : * if three or more previous iterations, current_iteration is set by 56 : * quadratic extrpolation of the three most recent iterations 57 : * \param previous_surfaces Previously successful iteratios used to attempt to 58 : * recover when some points are outside the domain. 59 : * \param max_compute_coords_retries Retry up to this many times before 60 : * returning false 61 : * \param domain The spatial domain in which the horizon is being found 62 : * \param functions_of_time The functions of time for the current domain 63 : * \param current_resolution_l Optional; if specified, current_iteration is 64 : * prolonged or restricted to this resolution 65 : * \param rerunning_with_higher_resolution Must be false unless 66 : * current_resolution_l is set; if true, then on iteration zero, set 67 : * the initial guess to the previous iteration surface 68 : * \returns Whether or not set_current_iteration_coords succeeded 69 : */ 70 : template <typename Fr> 71 1 : bool set_current_iteration_coords( 72 : gsl::not_null<ah::Storage::Iteration<Fr>*> current_iteration, 73 : gsl::not_null<std::vector<size_t>*> block_order, 74 : const LinkedMessageId<double>& time, const FastFlow& fast_flow, 75 : const ylm::Strahlkorper<Fr>& initial_guess, 76 : const ylm::Strahlkorper<Fr>& previous_iteration_surface, 77 : const std::deque<ah::Storage::PreviousSurface<Fr>>& previous_surfaces, 78 : size_t max_compute_coords_retries, const Domain<3>& domain, 79 : const domain::FunctionsOfTimeMap& functions_of_time, 80 : const std::optional<size_t>& current_resolution_l = std::nullopt, 81 : bool rerunning_with_higher_resolution = false); 82 : } // namespace ah