Skip to content
Open
11 changes: 2 additions & 9 deletions include/Definitions/global_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

enum class StencilDistributionMethod
{
CPU_TAKE = 0,
CPU_GIVE = 1
TAKE = 0,
GIVE = 1
};

/* Multigrid Cycle Types */
Expand All @@ -34,13 +34,6 @@ enum class ExtrapolationType
COMBINED = 3,
};

/* Smoother Colors */
enum class SmootherColor
{
Black = 0,
White = 1,
};

/* -----------*/
/* Test Cases */
/* -----------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::extrapolated_multigri
/* ------------------------------ */
/* Extrapolated multigrid F-cycle */
/* ------------------------------ */
Level<DomainGeometry, DensityProfileCoefficients>& level = levels_[level_depth];
Level<DomainGeometry, DensityProfileCoefficients>& next_level = levels_[level_depth + 1];
LevelType& level = levels_[level_depth];
LevelType& next_level = levels_[level_depth + 1];

/* ------------ */
/* Presmoothing */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::extrapolated_multigri
/* ------------------------------ */
/* Extrapolated multigrid V-cycle */
/* ------------------------------ */
Level<DomainGeometry, DensityProfileCoefficients>& level = levels_[level_depth];
Level<DomainGeometry, DensityProfileCoefficients>& next_level = levels_[level_depth + 1];
LevelType& level = levels_[level_depth];
LevelType& next_level = levels_[level_depth + 1];

/* ------------ */
/* Presmoothing */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::extrapolated_multigri
/* ------------------------------ */
/* Extrapolated multigrid W-cycle */
/* ------------------------------ */
Level<DomainGeometry, DensityProfileCoefficients>& level = levels_[level_depth];
Level<DomainGeometry, DensityProfileCoefficients>& next_level = levels_[level_depth + 1];
LevelType& level = levels_[level_depth];
LevelType& next_level = levels_[level_depth + 1];

/* ------------ */
/* Presmoothing */
Expand Down
6 changes: 3 additions & 3 deletions include/GMGPolar/MultigridMethods/multigrid_F_Cycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::multigrid_F_Cycle(int
/* ---------------------------------------------------- */
/* Coarsest level: solve A * x = rhs using DirectSolver */
/* ---------------------------------------------------- */
Level<DomainGeometry, DensityProfileCoefficients>& coarsest_level = levels_[level_depth];
LevelType& coarsest_level = levels_[level_depth];

/* Step 1: Copy rhs in solution */
Kokkos::deep_copy(solution, rhs);
Expand All @@ -33,8 +33,8 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::multigrid_F_Cycle(int
/* ----------------- */
/* Multigrid F-cycle */
/* ----------------- */
Level<DomainGeometry, DensityProfileCoefficients>& level = levels_[level_depth];
Level<DomainGeometry, DensityProfileCoefficients>& next_level = levels_[level_depth + 1];
LevelType& level = levels_[level_depth];
LevelType& next_level = levels_[level_depth + 1];

/* ------------ */
/* Presmoothing */
Expand Down
6 changes: 3 additions & 3 deletions include/GMGPolar/MultigridMethods/multigrid_V_Cycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::multigrid_V_Cycle(int
/* ---------------------------------------------------- */
/* Coarsest level: solve A * x = rhs using DirectSolver */
/* ---------------------------------------------------- */
Level<DomainGeometry, DensityProfileCoefficients>& coarsest_level = levels_[level_depth];
LevelType& coarsest_level = levels_[level_depth];

/* Step 1: Copy rhs in solution */
Kokkos::deep_copy(solution, rhs);
Expand All @@ -33,8 +33,8 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::multigrid_V_Cycle(int
/* ----------------- */
/* Multigrid V-cycle */
/* ----------------- */
Level<DomainGeometry, DensityProfileCoefficients>& level = levels_[level_depth];
Level<DomainGeometry, DensityProfileCoefficients>& next_level = levels_[level_depth + 1];
LevelType& level = levels_[level_depth];
LevelType& next_level = levels_[level_depth + 1];

/* ------------ */
/* Presmoothing */
Expand Down
6 changes: 3 additions & 3 deletions include/GMGPolar/MultigridMethods/multigrid_W_Cycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::multigrid_W_Cycle(int
/* ---------------------------------------------------- */
/* Coarsest level: solve A * x = rhs using DirectSolver */
/* ---------------------------------------------------- */
Level<DomainGeometry, DensityProfileCoefficients>& coarsest_level = levels_[level_depth];
LevelType& coarsest_level = levels_[level_depth];

/* Step 1: Copy rhs in solution */
Kokkos::deep_copy(solution, rhs);
Expand All @@ -33,8 +33,8 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::multigrid_W_Cycle(int
/* ----------------- */
/* Multigrid W-cycle */
/* ----------------- */
Level<DomainGeometry, DensityProfileCoefficients>& level = levels_[level_depth];
Level<DomainGeometry, DensityProfileCoefficients>& next_level = levels_[level_depth + 1];
LevelType& level = levels_[level_depth];
LevelType& next_level = levels_[level_depth + 1];

/* ------------ */
/* Presmoothing */
Expand Down
31 changes: 13 additions & 18 deletions include/GMGPolar/gmgpolar.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ template <concepts::DomainGeometry DomainGeometry, concepts::DensityProfileCoeff
class GMGPolar : public IGMGPolar
{
public:
using LevelType = Level<DomainGeometry, DensityProfileCoefficients>;

/* ---------------------------------------------------------------------- */
/* Constructor & Initialization */
/* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -94,7 +96,7 @@ class GMGPolar : public IGMGPolar
/* ---------------- */
/* Multigrid levels */
int number_of_levels_;
std::vector<Level<DomainGeometry, DensityProfileCoefficients>> levels_;
std::vector<LevelType> levels_;

/* ---------------------- */
/* Interpolation operator */
Expand Down Expand Up @@ -145,9 +147,9 @@ class GMGPolar : public IGMGPolar
/* --------------- */
/* Setup Functions */
template <concepts::BoundaryConditions BoundaryConditions, concepts::SourceTerm SourceTerm>
void build_rhs_f(const Level<DomainGeometry, DensityProfileCoefficients>& level, Vector<double> rhs_f,
const BoundaryConditions& boundary_conditions, const SourceTerm& source_term);
void discretize_rhs_f(const Level<DomainGeometry, DensityProfileCoefficients>& level, Vector<double> rhs_f);
void build_rhs_f(const LevelType& level, Vector<double> rhs_f, const BoundaryConditions& boundary_conditions,
const SourceTerm& source_term);
void discretize_rhs_f(const LevelType& level, Vector<double> rhs_f);

/* --------------- */
/* Solve Functions */
Expand All @@ -165,19 +167,13 @@ class GMGPolar : public IGMGPolar
void solveMultigrid(double& initial_residual_norm, double& current_residual_norm,
double& current_relative_residual_norm);
void solvePCG(double& initial_residual_norm, double& current_residual_norm, double& current_relative_residual_norm);
double residualNorm(const ResidualNormType& norm_type,
const Level<DomainGeometry, DensityProfileCoefficients>& level,
ConstVector<double> residual) const;
void evaluateExactError(Level<DomainGeometry, DensityProfileCoefficients>& level,
HostConstVector<double> exact_solution);
void updateResidualNorms(Level<DomainGeometry, DensityProfileCoefficients>& level, int iteration,
double& initial_residual_norm, double& current_residual_norm,
double& current_relative_residual_norm);
double residualNorm(const ResidualNormType& norm_type, const LevelType& level, ConstVector<double> residual) const;
void evaluateExactError(LevelType& level, HostConstVector<double> exact_solution);
void updateResidualNorms(LevelType& level, int iteration, double& initial_residual_norm,
double& current_residual_norm, double& current_relative_residual_norm);
void initRhsHierarchy();
void applyMultigridIterations(Level<DomainGeometry, DensityProfileCoefficients>& level, MultigridCycleType cycle,
int iterations);
void applyExtrapolatedMultigridIterations(Level<DomainGeometry, DensityProfileCoefficients>& level,
MultigridCycleType cycle, int iterations);
void applyMultigridIterations(LevelType& level, MultigridCycleType cycle, int iterations);
void applyExtrapolatedMultigridIterations(LevelType& level, MultigridCycleType cycle, int iterations);

/* ----------------- */
/* Print information */
Expand Down Expand Up @@ -213,8 +209,7 @@ class GMGPolar : public IGMGPolar
void writeToVTK(const std::filesystem::path& file_path, const PolarGrid& grid);

private:
void writeToVTK(const std::filesystem::path& file_path,
const Level<DomainGeometry, DensityProfileCoefficients>& level,
void writeToVTK(const std::filesystem::path& file_path, const LevelType& level,
HostConstVector<double> grid_function);
};

Expand Down
14 changes: 7 additions & 7 deletions include/GMGPolar/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::setup()

auto start_setup_createLevels = std::chrono::high_resolution_clock::now();

if (stencil_distribution_method_ == StencilDistributionMethod::CPU_TAKE) {
if (stencil_distribution_method_ == StencilDistributionMethod::TAKE) {
if (!cache_density_profile_coefficients_ || !cache_domain_geometry_) {
throw std::runtime_error("Error: Caching must be enabled for both density profile coefficients and domain "
"geometry in 'Take' implementation strategy.");
Expand Down Expand Up @@ -190,8 +190,8 @@ int GMGPolar<DomainGeometry, DensityProfileCoefficients>::chooseNumberOfLevels(c
}

template <concepts::DomainGeometry DomainGeometry, concepts::DensityProfileCoefficients DensityProfileCoefficients>
void GMGPolar<DomainGeometry, DensityProfileCoefficients>::discretize_rhs_f(
const Level<DomainGeometry, DensityProfileCoefficients>& level, Vector<double> rhs_f)
void GMGPolar<DomainGeometry, DensityProfileCoefficients>::discretize_rhs_f(const LevelType& level,
Vector<double> rhs_f)
{
const PolarGrid& grid = level.grid();
assert(std::ssize(rhs_f) == grid.numberOfNodes());
Expand Down Expand Up @@ -331,9 +331,9 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::discretize_rhs_f(

template <concepts::DomainGeometry DomainGeometry, concepts::DensityProfileCoefficients DensityProfileCoefficients>
template <concepts::BoundaryConditions BoundaryConditions, concepts::SourceTerm SourceTerm>
void GMGPolar<DomainGeometry, DensityProfileCoefficients>::build_rhs_f(
const Level<DomainGeometry, DensityProfileCoefficients>& level, Vector<double> rhs_f,
const BoundaryConditions& boundary_conditions, const SourceTerm& source_term)
void GMGPolar<DomainGeometry, DensityProfileCoefficients>::build_rhs_f(const LevelType& level, Vector<double> rhs_f,
const BoundaryConditions& boundary_conditions,
const SourceTerm& source_term)
{
const PolarGrid& grid(level.grid());
assert(std::ssize(rhs_f) == grid.numberOfNodes());
Expand Down Expand Up @@ -424,7 +424,7 @@ void GMGPolar<DomainGeometry, DensityProfileCoefficients>::printSettings(const P
std::cout << "Across the origin (Interior boundary condition)\n";
}

if (stencil_distribution_method_ == StencilDistributionMethod::CPU_TAKE) {
if (stencil_distribution_method_ == StencilDistributionMethod::TAKE) {
std::cout << "A-Take (Stencil Distribution)\n";
}
else {
Expand Down
Loading
Loading