Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring GMGPolar #65

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open

Refactoring GMGPolar #65

wants to merge 55 commits into from

Conversation

mknaranja
Copy link
Member

Merge Request - GuideLine Checklist

Guideline to check code before resolve WIP and approval, respectively.
As many checkboxes as possible should be ticked.

Checks by code author:

Always to be checked:

  • There is at least one issue associated with the pull request.
  • New code adheres with the coding guidelines
  • No large data files have been added to the repository. Maximum size for files should be of the order of KB not MB. In particular avoid adding of pdf, word, or other files that cannot be change-tracked correctly by git.

If functions were changed or functionality was added:

  • Tests for new functionality has been added
  • A local test was succesful

If new functionality was added:

  • There is appropriate documentation of your work. (use doxygen style comments)

If new third party software is used:

  • Did you pay attention to its license? Please remember to add it to the wiki after successful merging.

If new mathematical methods or epidemiological terms are used:

  • Are new methods referenced? Did you provide further documentation?

[ ] The following questions are addressed in the documentation (if need be):

  • Developers (what did you do?, how can it be maintained?)

  • For users (how to use your work?)

  • For admins (how to install and configure your work?)

  • For documentation: Please write or update the Readme in the current working directory!

Checks by code reviewer(s):

  • Is the code clean of development artifacts e.g., unnecessary comments, prints, ...
  • The ticket goals for each associated issue are reached or problems are clearly addressed (i.e., a new issue was introduced).
  • There are appropriate unit tests and they pass.
  • The git history is clean and linearized for the merge request. All reviewers should squash commits and write a simple and meaningful commit message.
  • Coverage report for new code is acceptable.
  • No large data files have been added to the repository. Maximum size for files should be of the order of KB not MB. In particular avoid adding of pdf, word, or other files that cannot be change-tracked correctly by git.

.vscode/settings.json Outdated Show resolved Hide resolved
CITATION.cff Show resolved Hide resolved
LICENSE Outdated Show resolved Hide resolved
.clang-format Outdated Show resolved Hide resolved
Copy link

@ds-aakash ds-aakash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Smoother files were the most difficult to follow. Will you will be documenting them in your report? (colouring and outside/inside sections)
  • A call graph can also be included in the appendix of your report

#include <array>
#include <initializer_list>

enum class StencilType

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StencilType may be a bit misleading name here. ( neighbour type ? )

Copy link
Collaborator

@julianlitz julianlitz Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I find GridPosition or StencilPosition might be clearer. Do you think one of these works better?"

e.g. enum class StencilPosition{TopLeft, Top, TopRight, ...};

BottomRight,
};

class Stencil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stencil is again misleading. When I think of stencil values I would assume they store something like [ 0 1 0 ; 1 -4 1; 0 1 0 ]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's true that the term "stencil" is often associated with structures like convolution masks (e.g., [0, 1, 0; 1, -4, 1; 0, 1, 0]), its broader definition still fits the intended usage here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be add a comment that this Stencil class helps when building sparse matrices


class LevelCache;

class Level

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming this class and use level only for indicating multigrid level

const DensityProfileCoefficients& density_profile_coefficients,
const bool DirBC_Interior, const int num_omp_threads,
const StencilDistributionMethod stencil_distribution_method);
void directSolveInPlace(Vector<double>& x) const;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does InPlace imply you overwrite the RHS with the solution? (maybe add a comment)

Comment on lines +96 to +101
if (row == column) \
center_matrix.main_diagonal(row) += value; \
else if (row == column - 1) \
center_matrix.sub_diagonal(row) += value; \
else if (row == 0 && column == center_matrix.columns() - 1) \
center_matrix.cyclic_corner_element() += value; \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use an inline function here instead of repeating this pattern (ex. update(matrix, value, row, col))

Comment on lines +61 to +65
const int center_index = i_theta; \
const int left_index = i_theta; \
const int right_index = (i_r + 1 == numberSmootherCircles) ? 0 : i_theta; \
const int bottom_index = i_theta_M1; \
const int top_index = i_theta_P1; \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about these indices (row inside their local tridiagonal matrix as you explained)

Comment on lines +895 to +909
else {
auto& solverMatrix = circle_tridiagonal_solver_[circle_Asc_index];

solverMatrix = SymmetricTridiagonalSolver<double>(num_circle_nodes);
solverMatrix.is_cyclic(true);
solverMatrix.cyclic_corner_element() = 0.0;

for (int i = 0; i < num_circle_nodes; i++) {
solverMatrix.main_diagonal(i) = 0.0;
if (i < num_circle_nodes - 1) {
solverMatrix.sub_diagonal(i) = 0.0;
}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be have a different function for zero initializations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments/illustrations explaining node coloring should be very helpful

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using GLOB can cause issues when changing or adding files. CMake files are usually recursive (ex. https://gitlab.com/CLIUtils/modern-cmake/-/tree/master/examples/extended-project)

Copy link
Member Author

@mknaranja mknaranja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget to submit them recently

Comment on lines +17 to +20
# Mumps: Sparse Matrix Solver
set(MUMPS_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/mumps-5.6.2-m4xrhc4mshzrxmgptzbpult3nbf6qrzk")
include_directories(${MUMPS_PREFIX_PATH}/include)
link_directories(${MUMPS_PREFIX_PATH}/lib)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make the use of MUMPS optional? such that we can run it without the corresponding option in the CI? or how did you proceed?

Copy link
Collaborator

@julianlitz julianlitz Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUMPS is currently required for solving the system, as I have removed the custom matrix solver due to its inefficiency. Making MUMPS optional would involve reintroducing the factorization and solve methods into our COO-Matrix class. While this is technically feasible, it would require significant effort to implement and maintain.

If you'd like, I could reintroduce the custom solver to the codebase in March, but I don’t think it’s the best approach to resolve this issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current issue is that the tests are failing because the MUMPS library isn't being found, right? Wouldn't it be best to install MUMPS directly in the CI environment to ensure it's available during the test runs?

CMakeLists.txt Show resolved Hide resolved
link_directories(${MUMPS_PREFIX_PATH}/lib)

# Metis: Matrix reordering for Mumps
set(METIS_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/metis-5.1.0-bgoncx22w55soviybggl5ydjakvkm34v")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I also hardcoded MUMPS path but this should be avoided as much as possible. In particular with options activated by default. Or if it is not even an option.


git clone https://github.com/mknaranja/GMGPolar
## Installing MUMPS using Spack
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new readme seems very nice and helpful but for CI MUMPS should be optional. Or is it included in CI too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment it is required and MUMPS would need to be added to the CI pipeline.

README.md Outdated
@@ -113,3 +125,67 @@ Release Notes

c. Non-default implicit extrapolation with smoothing of all nodes on the finest level [experimental, use with care, convergence cannot be observed with residual] (--extrapolation 2)
6) Optimization of apply_A / build_rhs / apply_prolongation / build_Asc / apply_Asc_ortho

* GMGPolar 2.0
More points
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be more or less fixed now. There were some copy-paste oversights and the formatting wasn't very consistent with the Version 1.0.0 release notes.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants