Skip to content

feat:inner products for mixed method#3994

Draft
chauj96 wants to merge 4 commits intodevelopfrom
feature/inner_products_for_mixed_method
Draft

feat:inner products for mixed method#3994
chauj96 wants to merge 4 commits intodevelopfrom
feature/inner_products_for_mixed_method

Conversation

@chauj96
Copy link
Contributor

@chauj96 chauj96 commented Mar 12, 2026

No description provided.

@chauj96 chauj96 changed the title Feature/inner products for mixed method feat:inner products for mixed method Mar 12, 2026
@chauj96 chauj96 self-assigned this Mar 12, 2026
@chauj96 chauj96 added ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI ci: run code coverage enables running of the code coverage CI jobs flag: no rebaseline Does not require rebaseline labels Mar 12, 2026
Comment on lines +161 to +167
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
M[i][j] = 0.0;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
M[i][j] = 0.0;
}
}
LvArray::tensorOps::fill< NF, NF >( M, 0.0 );

Comment on lines +280 to +323
// 4) U = I - Q Q^T
real64 U[ NF ][ NF ] = {{0}};
LvArray::tensorOps::addIdentity< NF >( U, -1.0 );
LvArray::tensorOps::Rij_add_AikAjk< NF, 3 >( U, Qmat );
LvArray::tensorOps::scale< NF, NF >( U, -1.0 );

// 5) A^{-1} * U * A^{-1}
real64 invA[ NF ];
for( localIndex i = 0; i < NF; ++i )
{
invA[i] = 1.0 / A[i];
}

// temp = A^{-1} * U
real64 temp[ NF ][ NF ];
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
temp[i][j] = invA[i] * U[i][j];
}
}

// Usc = A^{-1} * U * A^{-1}
real64 Usc[ NF ][ NF ];
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
Usc[i][j] = temp[i][j] * invA[j];
}
}

// 6) M = CKCt + (v / t) * Usc
real64 tParam = 2.0 * ( elemPerm[0] + elemPerm[1] + elemPerm[2] );
real64 scale = elemVolume / tParam;

for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
M[i][j] = CKCt[i][j] + scale * Usc[i][j];
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 4) U = I - Q Q^T
real64 U[ NF ][ NF ] = {{0}};
LvArray::tensorOps::addIdentity< NF >( U, -1.0 );
LvArray::tensorOps::Rij_add_AikAjk< NF, 3 >( U, Qmat );
LvArray::tensorOps::scale< NF, NF >( U, -1.0 );
// 5) A^{-1} * U * A^{-1}
real64 invA[ NF ];
for( localIndex i = 0; i < NF; ++i )
{
invA[i] = 1.0 / A[i];
}
// temp = A^{-1} * U
real64 temp[ NF ][ NF ];
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
temp[i][j] = invA[i] * U[i][j];
}
}
// Usc = A^{-1} * U * A^{-1}
real64 Usc[ NF ][ NF ];
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
Usc[i][j] = temp[i][j] * invA[j];
}
}
// 6) M = CKCt + (v / t) * Usc
real64 tParam = 2.0 * ( elemPerm[0] + elemPerm[1] + elemPerm[2] );
real64 scale = elemVolume / tParam;
for( localIndex i = 0; i < NF; ++i )
{
for( localIndex j = 0; j < NF; ++j )
{
M[i][j] = CKCt[i][j] + scale * Usc[i][j];
}
}
// 4) M = CKCt + (v / t) * A^{-1} * ( I - Q Q^T ) * A^{-1}
real64 invA[NF];
for (localIndex i = 0; i < NF; ++i)
{
invA[i] = real64(1) / A[i];
}
// scale = elemVolume / tParam, where tParam = 2 * trace(K)
real64 const tParam = real64(2) * (elemPerm[0] + elemPerm[1] + elemPerm[2]);
real64 const scale = elemVolume / tParam;
for (localIndex i = 0; i < NF; ++i)
{
real64 const invAiScaled = scale * invA[i];
real64 const qi0 = Qmat[i][0];
real64 const qi1 = Qmat[i][1];
real64 const qi2 = Qmat[i][2];
for (localIndex j = i; j < NF; ++j)
{
// qdot = (Q Q^T)_{ij} = sum_k Qik * Qjk, with k in [0,2]
real64 const qdot = qi0*Qmat[j][0] + qi1*Qmat[j][1] + qi2*Qmat[j][2];
real64 const u = (i == j ? real64(1) : real64(0)) - qdot;
real64 const mij = CKCt[i][j] + (invAiScaled * invA[j]) * u;
M[i][j] = mij;
M[j][i] = mij; // symmetry fill
}
}


for( localIndex i = 0; i < NF; ++i )
{
real64 fCenter[3], fNormal[3];
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use a consistent nomenclature across inner products, e.g.:

  • fCenter vs faceCenter
  • fNormal vs faceNormal
  • vec_cf vs cellToFaceVector
  • ...

Let's keep in mind when refactoring nomenclature, that kernels will eventually be used also for flow within surfaces (faults, fractures). Cell seems appropriate. Instead of faces (or edges), we should probably use the term facets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: run code coverage enables running of the code coverage CI jobs ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants