-
Notifications
You must be signed in to change notification settings - Fork 258
[WIP] Implement weighted BFBT with different discretization for (BC^{-1}B^T). #6440
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
Open
quangx
wants to merge
4
commits into
geodynamics:main
Choose a base branch
from
quangx:bfbt_v3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,15 +27,19 @@ | |||||||||||||||||||||||
| #include <aspect/mesh_deformation/interface.h> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #include <deal.II/base/signaling_nan.h> | ||||||||||||||||||||||||
| #include <deal.II/lac/diagonal_matrix.h> | ||||||||||||||||||||||||
| #include <deal.II/lac/linear_operator.h> | ||||||||||||||||||||||||
| #include <deal.II/lac/solver_gmres.h> | ||||||||||||||||||||||||
| #include <deal.II/lac/solver_bicgstab.h> | ||||||||||||||||||||||||
| #include <deal.II/lac/solver_cg.h> | ||||||||||||||||||||||||
| #include <deal.II/fe/fe_values.h> | ||||||||||||||||||||||||
| #include <deal.II/lac/trilinos_vector.h> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| namespace aspect | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| namespace internal | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Implement multiplication with Stokes part of system matrix. In essence, this | ||||||||||||||||||||||||
| * object represents a 2x2 block matrix that corresponds to the top left | ||||||||||||||||||||||||
|
|
@@ -165,6 +169,8 @@ namespace aspect | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Implement the block Schur preconditioner for the Stokes system. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
|
|
@@ -381,6 +387,33 @@ namespace aspect | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Given a diagonal matrix stored as a vector, | ||||||||||||||||||||||||
| * create an operator that represents its action. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| template<typename Range, | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| typename Domain, | ||||||||||||||||||||||||
| typename Payload> | ||||||||||||||||||||||||
| LinearOperator<Range, Domain, Payload> diag_operator(const LinearOperator<Range,Domain,Payload> &exemplar, const TrilinosWrappers::MPI::Vector &diagonal) | ||||||||||||||||||||||||
quangx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| LinearOperator<Range, Domain, Payload> return_op; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return_op.reinit_range_vector = exemplar.reinit_range_vector; | ||||||||||||||||||||||||
quangx marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
| return_op.reinit_domain_vector = exemplar.reinit_domain_vector; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return_op.vmult = [&](Range &dest, const Domain &src) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| dest = src; | ||||||||||||||||||||||||
| dest.scale(diagonal); | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
| return return_op; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * This class approximates the Schur Complement inverse operator | ||||||||||||||||||||||||
| * by S^{-1} = (BC^{-1}B^T)^{-1}(BC^{-1}AD^{-1}B^T)(BD^{-1}B^T)^{-1}, | ||||||||||||||||||||||||
|
|
@@ -458,7 +491,15 @@ namespace aspect | |||||||||||||||||||||||
| SolverControl solver_control(5000, 1e-6 * src.l2_norm(), false, true); | ||||||||||||||||||||||||
| SolverCG<TrilinosWrappers::MPI::Vector> solver(solver_control); | ||||||||||||||||||||||||
| //Solve with Schur Complement approximation | ||||||||||||||||||||||||
| solver.solve(mp_matrix, | ||||||||||||||||||||||||
| const auto Op_A = LinearOperator<TrilinosWrappers::MPI::Vector>(system_matrix.block(0,0)); | ||||||||||||||||||||||||
| const auto Op_BT = LinearOperator<TrilinosWrappers::MPI::Vector>(system_matrix.block(0,1)); | ||||||||||||||||||||||||
| const auto Op_B = LinearOperator<TrilinosWrappers::MPI::Vector>(system_matrix.block(1,0)); | ||||||||||||||||||||||||
| const auto Op_C_inv = diag_operator(Op_A,inverse_lumped_mass_matrix); | ||||||||||||||||||||||||
| const auto BC_invBT = Op_B*Op_C_inv*Op_BT; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| solver.solve(BC_invBT, | ||||||||||||||||||||||||
quangx marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
| ptmp, | ||||||||||||||||||||||||
| src, | ||||||||||||||||||||||||
| mp_preconditioner); | ||||||||||||||||||||||||
|
|
@@ -471,7 +512,7 @@ namespace aspect | |||||||||||||||||||||||
| system_matrix.block(1,0).vmult(ptmp,wtmp); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| dst=0; | ||||||||||||||||||||||||
| solver.solve(mp_matrix, | ||||||||||||||||||||||||
| solver.solve(BC_invBT, | ||||||||||||||||||||||||
| dst, | ||||||||||||||||||||||||
| ptmp, | ||||||||||||||||||||||||
| mp_preconditioner); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically have 3 empty lines between top-level constructs. So take one off again here.