-
Notifications
You must be signed in to change notification settings - Fork 106
feat: inner products for mixed method #3994
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
chauj96
wants to merge
21
commits into
develop
Choose a base branch
from
feature/inner_products_for_mixed_method
base: develop
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 all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
52439ee
implement mfd for mixed method and update unit tests
chauj96 f7d1850
apply uncrustify
chauj96 e483d46
merge from develop
chauj96 817ed6a
Added helper functions
castelletto1 5560168
unify geometry variable naming
chauj96 8c65d2a
Merge branch 'develop' into feature/inner_products_for_mixed_method
chauj96 3caf737
apply uncrustify formatting
chauj96 5665929
add doxygen documentation for computeM functions
chauj96 41f75ee
apply uncrustify formatting
chauj96 5bdf752
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran 18d1ad0
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran c0963df
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran 410f7b3
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran d3c5c1c
wip: fix qTPFA and BdVLM
OmarDuran 5b450de
fix: centroid computation exact for planar polygons in R3
OmarDuran b5a7c8f
wip
OmarDuran 82fb8b4
test: BdVLM inner product reduce to TPFA on hexahedral cells
OmarDuran 741f602
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran 50db838
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran 3c64f5e
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran 591b396
Merge branch 'develop' into feature/inner_products_for_mixed_method
OmarDuran 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
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
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 |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| #define GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_QUASITPFAINNERPRODUCT_HPP_ | ||
|
|
||
| #include "finiteVolume/mimeticInnerProducts/MimeticInnerProductBase.hpp" | ||
| #include "finiteVolume/mimeticInnerProducts/MimeticInnerProductHelpers.hpp" | ||
|
|
||
| namespace geos | ||
| { | ||
|
|
@@ -63,6 +64,30 @@ class QuasiTPFAInnerProduct : public MimeticInnerProductBase | |
| real64 const & lengthTolerance, | ||
| arraySlice2d< real64 > const & transMatrix ); | ||
|
|
||
| /** | ||
| * @brief Compute the mimetic inner product matrix M in a given element using the quasi TPFA inner product. | ||
| * @param[in] nodePosition the position of the nodes | ||
| * @param[in] faceToNodes the map from the face to their nodes | ||
| * @param[in] elemToFaces the maps from the one-sided face to the corresponding face | ||
| * @param[in] elemCenter the center of the element | ||
| * @param[in] elemVolume the volume of the element | ||
| * @param[in] elemPerm the permeability in the element | ||
| * @param[in] lengthTolerance the tolerance used in the trans calculations | ||
| * @param[inout] M the output inner product matrix | ||
| * | ||
| * @details Reference: K-A Lie, An Introduction to Reservoir Simulation Using MATLAB/GNU Octave (2019) | ||
| */ | ||
| template< localIndex NF > | ||
| GEOS_HOST_DEVICE | ||
| static void | ||
| computeM( arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const & nodePosition, | ||
| ArrayOfArraysView< localIndex const > const & faceToNodes, | ||
| arraySlice1d< localIndex const > const & elemToFaces, | ||
| arraySlice1d< real64 const > const & elemCenter, | ||
| real64 const & elemVolume, | ||
| real64 const (&elemPerm)[ 3 ], | ||
| real64 const & lengthTolerance, | ||
| arraySlice2d< real64 > const & M ); | ||
| }; | ||
|
|
||
| template< localIndex NF > | ||
|
|
@@ -90,6 +115,125 @@ QuasiTPFAInnerProduct::compute( arrayView2d< real64 const, nodes::REFERENCE_POSI | |
| transMatrix ); | ||
| } | ||
|
|
||
| template< localIndex NF > | ||
| GEOS_HOST_DEVICE | ||
| void | ||
| QuasiTPFAInnerProduct::computeM( arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const & nodePosition, | ||
|
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. Looks like a great refactor, I am unclear on why it is not called in |
||
| ArrayOfArraysView< localIndex const > const & faceToNodes, | ||
| arraySlice1d< localIndex const > const & elemToFaces, | ||
| arraySlice1d< real64 const > const & elemCenter, | ||
| real64 const & elemVolume, | ||
| real64 const (&elemPerm)[ 3 ], | ||
| real64 const & lengthTolerance, | ||
| arraySlice2d< real64 > const & M ) | ||
| { | ||
| real64 const areaTolerance = lengthTolerance * lengthTolerance; | ||
|
|
||
| // 0) stabilization parameter for quasi-TPFA | ||
| constexpr real64 tParam = 2.0; | ||
|
|
||
| // 1) assemble permeability tensor and its inverse | ||
| real64 K[3][3] = {{0}}; | ||
| MimeticInnerProductHelpers::makeFullTensor( elemPerm, K ); | ||
|
|
||
| real64 Kinv[3][3] = {{0}}; | ||
| for( int i = 0; i < 3; ++i ) | ||
| { | ||
| Kinv[i][i] = 1.0 / elemPerm[i]; | ||
| } | ||
|
|
||
| // 2) compute C and N | ||
| real64 C[ NF ][ 3 ] = {{ 0 }}; | ||
| real64 N[ NF ][ 3 ] = {{ 0 }}; | ||
|
|
||
| for( localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) | ||
| { | ||
| real64 faceCenter[3], faceNormal[3]; | ||
|
|
||
| real64 const faceArea = | ||
| computationalGeometry::centroid_3DPolygon( | ||
| faceToNodes[elemToFaces[ifaceLoc]], | ||
| nodePosition, | ||
| faceCenter, | ||
| faceNormal, | ||
| areaTolerance ); | ||
|
|
||
| real64 cellToFaceVec[3]; | ||
| MimeticInnerProductHelpers::computeCellToFacetVector( cellToFaceVec, faceCenter, elemCenter ); | ||
| MimeticInnerProductHelpers::orientNormalOutward( cellToFaceVec, faceNormal ); | ||
|
|
||
| for( int d = 0; d < 3; ++d ) | ||
| { | ||
| C[ifaceLoc][d] = cellToFaceVec[d]; | ||
| N[ifaceLoc][d] = faceArea * faceNormal[d]; | ||
| } | ||
| } | ||
|
|
||
| // 3) compute consistency part C K^{-1} C^T / volume | ||
| real64 CKCt[ NF ][ NF ] = {{ 0 }}; | ||
| real64 work[ 3 ][ NF ] = {{ 0 }}; | ||
|
|
||
| LvArray::tensorOps::Rij_eq_AikBjk< 3, NF, 3 >( work, Kinv, C ); | ||
| LvArray::tensorOps::Rij_eq_AikBkj< NF, NF, 3 >( CKCt, C, work ); | ||
| LvArray::tensorOps::scale< NF, NF >( CKCt, 1.0 / elemVolume ); | ||
|
|
||
| // 4) compute W = N K N' | ||
| real64 W[ NF ][ NF ] = {{ 0 }}; | ||
| real64 workNK[ 3 ][ NF ] = {{ 0 }}; | ||
|
|
||
| LvArray::tensorOps::Rij_eq_AikBjk< 3, NF, 3 >( workNK, K, N ); | ||
| LvArray::tensorOps::Rij_eq_AikBkj< NF, NF, 3 >( W, N, workNK ); | ||
|
|
||
| // 5) build Q from N so the stabilization annihilates range(N) (=> M N K = C) | ||
| real64 q0[ NF ], q1[ NF ], q2[ NF ]; | ||
| real64 Qmat[ NF ][ 3 ]; | ||
|
|
||
| for( localIndex i = 0; i < NF; ++i ) | ||
| { | ||
| q0[i] = N[i][0]; | ||
| q1[i] = N[i][1]; | ||
| q2[i] = N[i][2]; | ||
| } | ||
|
|
||
| MimeticInnerProductHelpers::orthonormalize< NF >( q0, q1, q2, Qmat ); | ||
|
|
||
| // 6) compute P = I - Q Q^T | ||
| real64 P[ NF ][ NF ] = {{ 0 }}; | ||
| LvArray::tensorOps::addIdentity< NF >( P, -1.0 ); | ||
| LvArray::tensorOps::Rij_add_AikAjk< NF, 3 >( P, Qmat ); | ||
| LvArray::tensorOps::scale< NF, NF >( P, -1.0 ); | ||
|
|
||
| // 7) compute stabilization term (v/t) P diag(W)^{-1} P | ||
| real64 stab[ NF ][ NF ] = {{ 0 }}; | ||
|
|
||
| for( localIndex i = 0; i < NF; ++i ) | ||
| { | ||
| for( localIndex j = 0; j < NF; ++j ) | ||
| { | ||
| real64 val = 0.0; | ||
| for( localIndex k = 0; k < NF; ++k ) | ||
| { | ||
| if( LvArray::math::abs( W[k][k] ) > 0 ) | ||
| { | ||
| val += P[i][k] * ( 1.0 / W[k][k] ) * P[k][j]; | ||
| } | ||
| } | ||
| stab[i][j] = val; | ||
| } | ||
| } | ||
|
|
||
| real64 const scale = elemVolume / tParam; | ||
|
|
||
| // 8) assemble final M | ||
| for( localIndex i = 0; i < NF; ++i ) | ||
| { | ||
| for( localIndex j = 0; j < NF; ++j ) | ||
| { | ||
| M[i][j] = CKCt[i][j] + scale * stab[i][j]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } // end namespace mimeticInnerProduct | ||
|
|
||
| } // end namespace geos | ||
|
|
||
Oops, something went wrong.
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.
Maybe those two should be moved in
ComputationalGeometryheader so we can factorize use later