Skip to content
Snippets Groups Projects
Commit c15cfc44 authored by jstark's avatar jstark
Browse files

Added distFromSol as member variable and public functions for accessing the...

Added distFromSol as member variable and public functions for accessing the final iteration, change, residual and number of points in the NB.
parent ed874550
No related branches found
No related tags found
No related merge requests found
......@@ -240,7 +240,27 @@ public:
/// This timestep is computed according to the grid spacing fulfilling the CFL condition.
return time_step;
}
int get_finalIteration()
{
return final_iter;
}
double get_finalChange()
{
return distFromSol.change;
}
double get_finalResidual()
{
return distFromSol.residual;
}
int get_finalNumberNbPoints()
{
return distFromSol.count;
}
private:
// Some indices for better readability
static constexpr size_t Phi_n_temp = 0; ///< Property index of Phi_0 on the temporary grid.
......@@ -251,6 +271,9 @@ private:
Redist_options redistOptions; ///< Instantiate redistancing options.
grid_in_type &r_grid_in; ///< Define reference to input grid.
DistFromSol distFromSol; ///< Instantiate distance from solution in terms of change, residual, numb. point in NB.
int final_iter = 0; ///< Will be set to the final iteration when redistancing ends.
/// Transform the half-bandwidth in no_of_grid_points into physical half-bandwidth kappa.
double kappa = ceil(redistOptions.width_NB_in_grid_points / 2.0) * get_biggest_spacing(g_temp);
/**@brief Artificial timestep for the redistancing iterations.
......@@ -332,14 +355,12 @@ private:
return (abs(Phi) <= kappa);
}
/** @brief Checks how far current solution is from fulfilling the user-defined convergence criteria.
/** @brief Re-computes the member variables distFromSol.change, distFromSol.residual, distFromSol.count for the
* Phi of the current iteration. Needed to check how far current solution is from fulfilling the user-defined convergence criteria.
*
* @param grid Internal temporary grid.
*
* @return Total residual (1 - phi_gradient_magnitude) and total change from the last time step,
* both normalized by the number of grid nodes in the narrow band.
*/
DistFromSol get_residual_and_change_NB(g_temp_type &grid)
void update_distFromSol(g_temp_type &grid)
{
double max_residual = 0;
double max_change = 0;
......@@ -370,20 +391,22 @@ private:
v_cl.max(max_residual);
v_cl.sum(count);
v_cl.execute();
return {max_change, max_residual, count};
// Update member variable distFromSol
distFromSol.change = max_change;
distFromSol.residual = max_residual;
distFromSol.count = count;
}
/** @brief Prints out the iteration number, residual and change of the current re-distancing iteration
/** @brief Prints out the iteration number, max. change, max. residual and number of points in the narrow band of
* the current re-distancing iteration.
*
* @param grid Internal temporary grid.
* @param iter Current re-distancing iteration.
*
* @return Total residual (1 - phi_gradient_magnitude) and total change from the last time step,
* both normalized by the number of grid nodes in the narrow band.
*/
void print_out_iteration_change_residual(g_temp_type &grid, size_t iter)
{
DistFromSol distFromSol = get_residual_and_change_NB(grid);
update_distFromSol(grid);
auto &v_cl = create_vcluster();
if (v_cl.rank() == 0)
{
......@@ -411,7 +434,7 @@ private:
bool steady_state_NB(g_temp_type &grid)
{
bool steady_state = false;
DistFromSol distFromSol = get_residual_and_change_NB(grid);
update_distFromSol(grid);
if (redistOptions.convTolChange.check && redistOptions.convTolResidual.check)
{
steady_state = (
......@@ -475,6 +498,8 @@ private:
}
}
}
update_distFromSol(grid);
final_iter = i;
// If save_temp_grid set true, save the temporary grid as hdf5 that can be reloaded onto a grid
if (redistOptions.save_temp_grid)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment