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

WIP: Add FV method for T8codeMesh #1844

Draft
wants to merge 97 commits into
base: main
Choose a base branch
from

Conversation

bennibolm
Copy link
Contributor

@bennibolm bennibolm commented Feb 13, 2024

This PR adds the implementation of a first-order and second order finite volume scheme.
The mesh is organized with t8code. Therefore, it supports MPI parallelization.

Visualization is implemented using a t8code routine directly and therefore without .h5 files and Trixi2Vtk.

Short summary about the current status:

  • Life time issue for the GC tracked Julia object used in C. Using mapping coordinates2mapping (closure) is cleaned up by Julia's GC, while still used in t8code. -> SegFaults. Current solution: Deactivating the GC during the simulation in elixir.

TODOs:

Open things/problems:

  • Check if convergence_test works parallel. Seems to work in 1c7413d
  • Reconstruction stencil on periodic boundaries
  • Second order extended reconstruction stencil. Adapt smaller reconstruction stencils
  • MPI parallel with extended reconstruction stencil (Problem: Using data from other ranks)

Copy link
Contributor

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Copy link

codecov bot commented Feb 13, 2024

Codecov Report

Attention: Patch coverage is 91.43780% with 106 lines in your changes missing coverage. Please review.

Project coverage is 96.23%. Comparing base (9c69e10) to head (d95def6).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/solvers/fv_t8code/containers.jl 82.08% 50 Missing ⚠️
src/meshes/t8code_mesh.jl 93.19% 25 Missing ⚠️
src/solvers/fv_t8code/fv.jl 95.35% 20 Missing ⚠️
examples/t8code_3d_fv/elixir_advection_basic.jl 0.00% 5 Missing ⚠️
examples/t8code_2d_fv/elixir_advection_basic.jl 50.00% 4 Missing ⚠️
src/callbacks_step/save_solution.jl 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1844      +/-   ##
==========================================
- Coverage   96.39%   96.23%   -0.15%     
==========================================
  Files         483      490       +7     
  Lines       38333    39570    +1237     
==========================================
+ Hits        36948    38079    +1131     
- Misses       1385     1491     +106     
Flag Coverage Δ
unittests 96.23% <91.44%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 1169 to 1179
# Simple meshes
# Temporary routines to create simple `cmesh`s by hand

# Directly ported from: `src/t8_cmesh/t8_cmesh_examples.c: t8_cmesh_new_periodic_hybrid`.
function cmesh_new_periodic_hybrid(comm)::t8_cmesh_t
n_dims = 2
vertices = [ # Just all vertices of all trees. partly duplicated
-1.0, -1.0, 0, # tree 0, triangle
0, -1.0, 0,
0, 0, 0,
-1.0, -1.0, 0, # tree 1, triangle
Copy link
Contributor Author

@bennibolm bennibolm Feb 20, 2024

Choose a reason for hiding this comment

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

The following 300 lines are just by-hand building routines for simple cmeshs. This is only temporary and will be deleted in the future.

src/meshes/mesh_io.jl Outdated Show resolved Hide resolved
src/meshes/t8code_mesh.jl Outdated Show resolved Hide resolved
Comment on lines +278 to +281
function integrate_via_indices(func::Func, u,
mesh::T8codeMesh, equations,
solver::FV, cache, args...;
normalize = true) where {Func}
Copy link
Contributor Author

@bennibolm bennibolm Feb 20, 2024

Choose a reason for hiding this comment

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

TODO: Relocate this routine, calc_error_norms and analyze to analysis.jl since they are dimension independent.

bennibolm and others added 9 commits October 15, 2024 10:56
* Add first version of 3d support

* Complete 3d support

* Add 3d elixirs and tests

* Adapt name in elixir

* Reduce initial refinement level of one test

* Simplify NDIMS=3

* Add 3d mpi tests

* Remove initial_condition from rhs; fmt

* Fix parameter in `x_trans_periodic_3d`

* Remove comment

* Some last changes

* fmt
test/Project.toml Outdated Show resolved Hide resolved
@bennibolm
Copy link
Contributor Author

bennibolm commented Nov 15, 2024

I again have the problem in the tests, that finalize(mesh) cleans up the mesh but afterward it is still needed to check the allocations. But somehow only for the first test with elixir_advection_basic.jl (which is the first test in general). And only for the run with coverage.

@bennibolm
Copy link
Contributor Author

bennibolm commented Nov 25, 2024

Short summary of the current status:

  1. Life time issue for the GC tracked Julia object used in C. Using mapping coordinates2mapping (closure) is cleaned up by Julia's GC, while still used in t8code. -> SegFaults. Current solution: Deactivating the GC during the simulation in elixir.
  2. Mesh structures on t8code side are not properly finalized automatically. Require finalization at end of elixir (same for DG). BUT: During testing, the mesh is needed for allocation checks. Leads to SegFaults sometimes (see WIP: Add FV method for T8codeMesh #1844 (comment)).

@bennibolm
Copy link
Contributor Author

bennibolm commented Nov 26, 2024

Regarding

  1. Mesh structures on t8code side are not properly finalized automatically. Require finalization at end of elixir (same for DG). BUT: During testing, the mesh is needed for allocation checks. Leads to SegFaults sometimes (see WIP: Add FV method for T8codeMesh #1844 (comment)).

I moved the allocation tests to the elixir for now in 155887b.
Now, most of the tests run.
Things to monitor: Error in Codecoverage for t8code_fv test (only once/ normal codecov failure?); Failing mpi tests for iOs and Windows (always? Yes, in every of three runs now).

@bennibolm
Copy link
Contributor Author

In d7770ef, there was also an error in the mpi run on linux. It was the often seen error, which looks like this
AssertionError: length(u_ode) == nvariables(equations) * nelements(mesh, solver, cache) (https://github.com/trixi-framework/Trixi.jl/actions/runs/12082232552/job/33692896809#step:7:14394)
It is not present in the next run. Nevertheless, somehow this next run stops at the end of tests without coverage (https://github.com/trixi-framework/Trixi.jl/actions/runs/12083207676/job/33695874959?pr=1844#step:7:14742) without any shown reason.

@bennibolm
Copy link
Contributor Author

Update after 9c69e10 was merged:
The allocation tests are working again within the test files.
I still have the failing mpi tests for macos and windows.

@JoshuaLampert
Copy link
Member

I still have the failing mpi tests for macos and windows.

Thanks to @jmark, these are hopefully fixed after merging DLR-AMR/T8code.jl#78 and updating to the latest T8code.jl version.

@bennibolm
Copy link
Contributor Author

I still have the failing mpi tests for macos and windows.

Thanks to @jmark, these are hopefully fixed after merging DLR-AMR/T8code.jl#78 and updating to the latest T8code.jl version.

Unfortunately not 😞 Assuming I'm not missing anything

@JoshuaLampert
Copy link
Member

But this error from before disappeared, right? I guess, there were two probably independent issues before.

@JoshuaLampert
Copy link
Member

These explicit disabling of the GC should not be necessary anymore after #2172 or are they, @jmark?

@bennibolm
Copy link
Contributor Author

But this error from before disappeared, right? I guess, there were two probably independent issues before.

Oh yes, this can be true.

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