ikarus-project / ikarus

Ikarus is a C++-based library that uses DUNE modules to solve partial differential equations with the finite element method and more.
https://ikarus-project.github.io/
Other
5 stars 3 forks source link

refactor febase to handle any type of basis #256

Closed tarun-mitruka closed 6 months ago

tarun-mitruka commented 6 months ago

This PR is focused to handle the issue #241 to add handling of composite basis. In this PR, powerbasisfe.hh and scalarfe.hh are merged to a file febases.hh. This is done to avoid duplication of code while adding another class to handle a composite basis. Due to this refactoring, the file febases.hh now resides outside - ikarus/finiteelements/febases.hh and the folder ikarus/finiteelements/febases/autodifffe.hh is now renamed to ikarus/finiteelements/autodiff/autodifffe.hh. autodiffhelper.hh will be moved from utils to this folder in a separate PR while handling #257.

Global indices can now handle, for example, the following basis types:

A composite basis itself cannot have another composite basis though. The existing finite elements itself will be refactored to accommodate the changes in this PR while handling the issue #244.

!!! UPDATE Nested composite basis can also be handled after refactoring. BlockedInterleaved can also be handled by the global indices.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.59%. Comparing base (f10add6) to head (0764350).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #256 +/- ## ========================================== + Coverage 92.55% 92.59% +0.03% ========================================== Files 56 57 +1 Lines 1975 1984 +9 ========================================== + Hits 1828 1837 +9 Misses 147 147 ``` | [Flag](https://app.codecov.io/gh/ikarus-project/ikarus/pull/256/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ikarus-project) | Coverage Δ | | |---|---|---| | [tests](https://app.codecov.io/gh/ikarus-project/ikarus/pull/256/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ikarus-project) | `92.59% <100.00%> (+0.03%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ikarus-project#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tarun-mitruka commented 6 months ago

Thanks for the review Alex. This PR is marked as draft as per the discussion of having an implementation that extends the idea of functionalities like applyToTree and forEachNode available in dune-typetree. The idea is to have a function like forEachPowerNode which could use these existing functions and still manage the indices in the desired FlatInterleaved format. The aim is then to have a neater readable code which avoids a recursive call to a function.

rath3t commented 6 months ago

Actually we discussed it with a function forEachPowerOrLeafNode

tarun-mitruka commented 6 months ago

This is evolving nicely but there are still things to make easier. We can also look at it together. Furthermore, we also have to modify src/iks003_incompressibleLinearElasticity.cppbecause this breaks now, doesnt it? Maybe we want to make the function there a free function for the educational aspect or remove it completly.

It actually doesnt brake but the globalFlatIndices member function is stale now and unused. Maybe this also has to be refactored in the docs?

I fixed the existing documentation related to globalFlatIndices in docs/website/01_framework/finiteElements.md. The examples are currently not breaking as the checks are passing. We can discuss if we want to use this feature and modify the examples itself altogether, like also the cantilever beam example can be simplified using this PR, or leave some examples untouched for training/academic purposes.

rath3t commented 6 months ago

The src/iks003_incompressibleLinearElasticity.cpp has to be refactored for sure in some way, sicne now it shows a completely unused function. We can move the member function to a free function for training/academic purposes or remove the member function completely.

tarun-mitruka commented 6 months ago

The src/iks003_incompressibleLinearElasticity.cpp has to be refactored for sure in some way, sicne now it shows a completely unused function. We can move the member function to a free function for training/academic purposes or remove the member function completely.

Ah okay. Now I got what you meant. Then I remove it from iks003. This doesn't affect the documentation. For training/academic purposes, one can still refer to iks002 to understand the working of this functionality.

tarun-mitruka commented 6 months ago

FEBase class now handles the localView correctly depending on non-type template bool useFlat=false/true for both flat and untouched version of the basis. This notion is also passed on to the finite elements. Refactoring of the finite elements itself to handle any basis type will be done while handling #244 and adding more tests to handle BlockedInterleaved indices for the local assemblers will be done in a separate PR, may be while handling #228.