Skip to content

Commit

Permalink
Post merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
castelletto1 committed Dec 20, 2024
2 parents e4c929a + a9314e2 commit cc53d0d
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/coreComponents/finiteVolume/CellElementStencilTPFA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ CellElementStencilTPFAWrapper::
real64 (& weight)[1][2],
real64 (& dWeight_dVar )[1][2] ) const
{
GEOS_UNUSED_VAR( dCoeff_dVar );

real64 halfWeight[2];
real64 dHalfWeight_dVar[2];

// real64 const tolerance = 1e-30 * lengthTolerance; // TODO: choice of constant based on physics?

Expand All @@ -232,7 +233,6 @@ CellElementStencilTPFAWrapper::
localIndex const ei = m_elementIndices[iconn][i];

halfWeight[i] = m_weights[iconn][i];
dHalfWeight_dVar[i] = m_weights[iconn][i];

// Proper computation
real64 faceNormal[3];
Expand All @@ -247,17 +247,14 @@ CellElementStencilTPFAWrapper::
LvArray::tensorOps::Ri_eq_symAijBj< 3 >( faceConormal, coefficient[er][esr][ei][0], faceNormal );
LvArray::tensorOps::Ri_eq_symAijBj< 3 >( dFaceConormal_dVar, dCoeff_dVar[er][esr][ei][0], faceNormal );
halfWeight[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceConormal );
dHalfWeight_dVar[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], dFaceConormal_dVar );

// correct negative weight issue arising from non-K-orthogonal grids
if( halfWeight[i] < 0.0 )
{
LvArray::tensorOps::Ri_eq_symAijBj< 3 >( faceConormal, coefficient[er][esr][ei][0], m_cellToFaceVec[iconn][i] );
LvArray::tensorOps::Ri_eq_symAijBj< 3 >( dFaceConormal_dVar, dCoeff_dVar[er][esr][ei][0], m_cellToFaceVec[iconn][i] );
halfWeight[i] = m_weights[iconn][i];
dHalfWeight_dVar[i] = m_weights[iconn][i];
halfWeight[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], faceConormal );
dHalfWeight_dVar[i] *= LvArray::tensorOps::AiBi< 3 >( m_cellToFaceVec[iconn][i], dFaceConormal_dVar );
}
}

Expand All @@ -268,25 +265,16 @@ CellElementStencilTPFAWrapper::
real64 const harmonicWeight = sum > 0 ? product / sum : 0.0;
real64 const arithmeticWeight = sum / 2;

real64 dHarmonicWeight_dVar[2];
real64 dArithmeticWeight_dVar[2];

dHarmonicWeight_dVar[0] = sum > 0 ? (dHalfWeight_dVar[0]*sum*halfWeight[1] - dHalfWeight_dVar[0]*halfWeight[0]*halfWeight[1]) / ( sum*sum ) : 0.0;
dHarmonicWeight_dVar[1] = sum > 0 ? (dHalfWeight_dVar[1]*sum*halfWeight[0] - dHalfWeight_dVar[1]*halfWeight[1]*halfWeight[0]) / ( sum*sum ) : 0.0;

dArithmeticWeight_dVar[0] = dHalfWeight_dVar[0] / 2;
dArithmeticWeight_dVar[1] = dHalfWeight_dVar[1] / 2;

real64 const meanPermCoeff = 1.0; //TODO make it a member if it is really necessary

real64 const value = meanPermCoeff * harmonicWeight + (1 - meanPermCoeff) * arithmeticWeight;
for( localIndex ke = 0; ke < 2; ++ke )
{
weight[0][ke] = m_transMultiplier[iconn] * value * (ke == 0 ? 1 : -1);

real64 const dValue_dVar = meanPermCoeff * dHarmonicWeight_dVar[ke] + (1 - meanPermCoeff) * dArithmeticWeight_dVar[ke];
dWeight_dVar[0][ke] = m_transMultiplier[iconn] * dValue_dVar;
}

dWeight_dVar[0][0] = 0.0;
dWeight_dVar[0][1] = 0.0;
}

GEOS_HOST_DEVICE
Expand Down

0 comments on commit cc53d0d

Please sign in to comment.