Skip to content

Functional feature: Computes matrix entries for H1/Hcurl#484

Merged
jonwong12 merged 36 commits intodevelopfrom
feature/jonwong12/gradient_matrix_kernel
Jun 21, 2021
Merged

Functional feature: Computes matrix entries for H1/Hcurl#484
jonwong12 merged 36 commits intodevelopfrom
feature/jonwong12/gradient_matrix_kernel

Conversation

@jonwong12
Copy link
Copy Markdown
Contributor

@jonwong12 jonwong12 commented Jun 8, 2021

This PR adds a gradient_matrix_kernel to functional which will compute the element tangent entries of the residual in the form of a continuous vector K_e of size (test_ndof * test_dim * trial_ndof * trial_dim * num_elem). It should work for H1, Hcurl, and L2 spaces. However L2 is not tested specifically in this PR.

Afterwards an serac::mfem_ext::AssembledSparseMatrix is constructed. This holds the mapping from K_e to a rank-local assembled CSR-matrix. Calling AssembledSparseMatrix.FillData(K_e) will maintain the same sparsity pattern but change matrix entries. AssembledSparseMatrix is derived from mfem::SparseMatrix; however FillData() and ParallelAssemble() methods were added.

Note:
Currently AssembledSparseMatrix uses some "forbidden C++ calls" to get at protected information in mfem::ElementRestriction. Ideally this information would be public in mfem. Additionally there is an mfem issue with L2 when using LEXICOGRAPHIC ordering which a follow-up PR will try to address. For NATIVE ordering, see this branch for a working H1-L2 matrix assembly.

TODO:

  • Add validation checks for hcurl and elasticity
  • Add second method in functional.hpp to update an AssembledSparseMatrix directly

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 8, 2021

Codecov Report

Merging #484 (bb88b6a) into develop (fb35d7b) will increase coverage by 0.34%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #484      +/-   ##
===========================================
+ Coverage    94.72%   95.06%   +0.34%     
===========================================
  Files           68       70       +2     
  Lines         3678     3934     +256     
===========================================
+ Hits          3484     3740     +256     
  Misses         194      194              
Impacted Files Coverage Δ
src/serac/numerics/assembled_sparse_matrix.cpp 100.00% <100.00%> (ø)
src/serac/numerics/assembled_sparse_matrix.hpp 100.00% <100.00%> (ø)
...cs/utilities/functional/detail/metaprogramming.hpp 100.00% <100.00%> (ø)
.../serac/physics/utilities/functional/functional.hpp 97.36% <100.00%> (+0.70%) ⬆️
...rc/serac/physics/utilities/functional/integral.hpp 100.00% <100.00%> (ø)
src/serac/physics/utilities/functional/tensor.hpp 99.58% <100.00%> (+0.01%) ⬆️
...lities/functional/tests/functional_comparisons.cpp 96.31% <100.00%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb35d7b...bb88b6a. Read the comment docs.

@jonwong12
Copy link
Copy Markdown
Contributor Author

jonwong12 commented Jun 8, 2021

@joshessman-llnl I have a issue/branch in MFEM to do this matrix assembly, but I don't know what the timeline for that is. I think they are interested in seeing some benchmarks. In that branch, I just friend AssembledSparseMatrix in mfem::ElementRestriction, so I agree this is a temporary solution.

One point of contention is that MFEM seems more concerned with higher order elements where assembling a matrix may have declining payoffs, whereas for the problems we solve, matrices are useful.

Alternatively this PR doesn't support L2 (LEXICOGRAPHIC ordering, but NATIVE ordering is fine?), because mfem::ElementRestriction and mfem::L2ElementRestriction are not derived from each other. We could re-implement or use variants (and get at protected arrays). @jamiebramwell What are your thoughts on this?

jonwong12 and others added 2 commits June 14, 2021 11:25
Co-authored-by: samuelpmishLLNL <61714427+samuelpmishLLNL@users.noreply.github.com>
Co-authored-by: samuelpmishLLNL <61714427+samuelpmishLLNL@users.noreply.github.com>
@samuelpmishLLNL
Copy link
Copy Markdown
Contributor

This all looks very promising to me!

I want to apologize again for not providing a rich enough set of tools to make the implementation of gradient_matrix_kernel straightforward. I am hopeful that we can significantly simplify gradient_matrix_kernel by adding some additional features to the tensor class. In the meantime, having this working example will be incredibly useful when we eventually pursue that refactor.

jonwong12 and others added 5 commits June 14, 2021 13:00
…related methods to make it easier to understand the intent of the indexing
Co-authored-by: samuelpmishLLNL <61714427+samuelpmishLLNL@users.noreply.github.com>
Co-authored-by: samuelpmishLLNL <61714427+samuelpmishLLNL@users.noreply.github.com>
Co-authored-by: samuelpmishLLNL <61714427+samuelpmishLLNL@users.noreply.github.com>
@jamiebramwell
Copy link
Copy Markdown
Member

@samuelpmishLLNL @samuelpmishLLNL , any open issues in this PR?

@samuelpmishLLNL
Copy link
Copy Markdown
Contributor

I think it looks good, approving now

Copy link
Copy Markdown
Member

@joshessman-llnl joshessman-llnl left a comment

Choose a reason for hiding this comment

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

Just some minor style comments; otherwise, looks good to me!

jonwong12 and others added 5 commits June 17, 2021 15:01
Co-authored-by: Josh Essman <68349992+joshessman-llnl@users.noreply.github.com>
Co-authored-by: Josh Essman <68349992+joshessman-llnl@users.noreply.github.com>
Co-authored-by: Josh Essman <68349992+joshessman-llnl@users.noreply.github.com>
@jonwong12 jonwong12 merged commit 8950660 into develop Jun 21, 2021
@jamiebramwell jamiebramwell deleted the feature/jonwong12/gradient_matrix_kernel branch October 14, 2021 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Ready for active inspection by reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants