Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
ad9fb85
wip: adding examples for consistency check
OmarDuran Aug 17, 2025
773121d
wip: add skeletong for an integration test
OmarDuran Aug 17, 2025
8a48f68
wip: adding test file to cmake
OmarDuran Aug 17, 2025
e21fb60
wip: refactor cmake list configuration
OmarDuran Aug 18, 2025
7f437a1
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
6c561af
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
2fc99c0
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
c527a10
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
b1e476b
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
a25454f
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
4af50ac
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
3794be6
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
2122ec0
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
b26dcc8
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
14a4e1a
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
163e0fe
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
8c07fff
wip: testing external meshes
OmarDuran Aug 18, 2025
c6ffaa3
wip: adding parametrization for three kind of meshes and inner products
OmarDuran Aug 18, 2025
1ea2f4f
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
eefa9d5
feature: extending coverage for polyhedral discretizations
OmarDuran Aug 18, 2025
f441cb2
Update src/coreComponents/integrationTest/singlePhaseFlow/polyhedralD…
OmarDuran Aug 18, 2025
70e3b6d
wip: make test compatible with CPU builds
OmarDuran Aug 18, 2025
d8ec8f2
Update src/coreComponents/integrationTest/singlePhaseFlow/polyhedralD…
OmarDuran Aug 18, 2025
2c7ad4c
Update src/coreComponents/integrationTest/singlePhaseFlow/polyhedralD…
OmarDuran Aug 18, 2025
9b6de64
Merge branch 'feat-integration-test-for-mimetic-finite-difference-sin…
OmarDuran Aug 18, 2025
3ec030a
wip: removing events block
OmarDuran Aug 18, 2025
0189aaf
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
8077a93
Update testPolyhedralDiscretizations.cpp
OmarDuran Aug 18, 2025
1f3c709
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Aug 19, 2025
0a2c914
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Aug 20, 2025
bbcb238
wip: rename example input files
OmarDuran Aug 22, 2025
21ef66c
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Aug 22, 2025
2990375
wip: fix xml includes
OmarDuran Aug 22, 2025
3a0f238
Merge branch 'feat-integration-test-for-mimetic-finite-difference-sin…
OmarDuran Aug 22, 2025
a5f62e4
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Aug 25, 2025
8f82611
bug: fix boundary conditions on SinglePhaseHybridFVM
OmarDuran Aug 26, 2025
47c15a5
Update SinglePhaseHybridFVM.cpp
OmarDuran Aug 26, 2025
28ef558
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 9, 2025
08e91c2
fix: constraint on mass flux and removing unnecessarily upwinding
OmarDuran Sep 9, 2025
14ea63b
Update SinglePhaseHybridFVMKernels.hpp
OmarDuran Sep 9, 2025
ed0d26b
Update SinglePhaseHybridFVMKernels.hpp
OmarDuran Sep 9, 2025
973ee85
Update SinglePhaseHybridFVMKernels.hpp
OmarDuran Sep 9, 2025
7e74b38
Update SinglePhaseHybridFVMKernels.hpp
OmarDuran Sep 9, 2025
fb17d87
Update SinglePhaseHybridFVMKernels.hpp
OmarDuran Sep 9, 2025
a6e8557
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 17, 2025
bd819b5
wip: removing files from old location
OmarDuran Sep 17, 2025
ae19d29
wip: relocating files to integrationTests
OmarDuran Sep 17, 2025
112848a
wip: improving conditioning I
OmarDuran Sep 17, 2025
b0dc4d0
wip: Estimate condition number for the meshes in the test.
OmarDuran Sep 17, 2025
7a5a8db
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 17, 2025
6674899
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 17, 2025
fb504d1
wip: using iterative solvers
OmarDuran Sep 18, 2025
31f6b04
wip: restore full test
OmarDuran Sep 18, 2025
cb3c750
wip: format
OmarDuran Sep 18, 2025
724fec3
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 18, 2025
b2d3fd0
wip: Solver type not supported in Trilinos interface
OmarDuran Sep 18, 2025
bc4c1bf
Merge branch 'feat-integration-test-for-mimetic-finite-difference-sin…
OmarDuran Sep 18, 2025
46b08fc
wip: direct solver is supported for all LA interfaces
OmarDuran Sep 18, 2025
e8144eb
Update SinglePhaseReservoirHybridFVM.hpp
OmarDuran Sep 19, 2025
15ce642
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 21, 2025
1f62a28
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 21, 2025
80d50c4
Merge branch 'feat-integration-test-for-mimetic-finite-difference-sin…
OmarDuran Sep 21, 2025
efbfd77
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 21, 2025
2e09da7
wip: remove implicitStepComplete
OmarDuran Sep 21, 2025
ca4dca1
wip: make code CI compliant
OmarDuran Sep 22, 2025
8b34b00
wip: make code CI compliant
OmarDuran Sep 22, 2025
6723dd4
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 23, 2025
0ce6295
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 23, 2025
6080a8b
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 23, 2025
e6fd3cf
Update CMakeLists.txt
OmarDuran Sep 23, 2025
cd4bf2c
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 23, 2025
f2828c1
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 25, 2025
f88f58a
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 26, 2025
36c23ef
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 26, 2025
a17920c
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 27, 2025
9b08468
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 27, 2025
f1d250c
wip: move data using parallelDeviceMemorySpace
OmarDuran Sep 28, 2025
0cec762
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 28, 2025
9dac06a
Update CMakeLists.txt
OmarDuran Sep 28, 2025
a1c758d
Update testSinglePhaseMFDPolyhedral.cpp
OmarDuran Sep 28, 2025
1399aa1
fix: code is finally CI compliant
OmarDuran Sep 28, 2025
53e4657
fix: restore original location
OmarDuran Sep 28, 2025
c1f3598
wip: improving example files
OmarDuran Sep 28, 2025
ffe958a
Update BASELINE_NOTES.md
OmarDuran Sep 28, 2025
df7927b
Update BASELINE_NOTES.md
OmarDuran Sep 28, 2025
2885454
Update BASELINE_NOTES.md
OmarDuran Sep 28, 2025
68fadff
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Sep 29, 2025
86ad010
wip: update base lines
OmarDuran Sep 30, 2025
e2e48a9
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
paveltomin Sep 30, 2025
eb35a4b
Update baseline path in integrated tests configuration
paveltomin Sep 30, 2025
3642a1f
Add link to integrated tests for PR #3780
paveltomin Sep 30, 2025
8f8e524
fix: remove light hack
OmarDuran Oct 1, 2025
a346cad
Merge branch 'develop' into feat-integration-test-for-mimetic-finite-…
OmarDuran Oct 1, 2025
b379cd7
Update HypreExport.cpp
OmarDuran Oct 1, 2025
61c6c64
Update HypreExport.cpp
OmarDuran Oct 1, 2025
43fe816
wip: simplify the logic and remove std::vector
OmarDuran Oct 1, 2025
b1e0894
Update HypreExport.cpp
OmarDuran Oct 1, 2025
733c3b2
Update HypreExport.cpp
OmarDuran Oct 1, 2025
206841b
wip: modify logic to use the same constructor logic.
OmarDuran Oct 2, 2025
17d92c8
wip:
OmarDuran Oct 2, 2025
2392ac1
wip: update rebase lines
OmarDuran Oct 2, 2025
497717f
wip: apply review suggestions
OmarDuran Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip: improving conditioning I
  • Loading branch information
OmarDuran committed Sep 17, 2025
commit 112848a5baa21630d28154e36dfe9a0bac67ab2c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set( gtest_geosx_tests
testThermalSinglePhaseFlow.cpp
testTransmissibility.cpp
testImmiscibleMultiphaseFlow.cpp
testSinglePhaseMFDDiscretization.cpp )
testSinglePhaseMFDPolyhedral.cpp )

if( ENABLE_PVTPackage )
list( APPEND gtest_geosx_tests
Expand All @@ -31,6 +31,32 @@ foreach(test ${gtest_geosx_tests})

geos_add_test( NAME ${test_name}
COMMAND ${test_name} )

set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "TEST_BINARY_DIR=$<TARGET_FILE_DIR:${test_name}>")

# Add TEST_BINARY_DIR as a compile definition
target_compile_definitions(${test_name} PRIVATE TEST_BINARY_DIR=\"$<TARGET_FILE_DIR:${test_name}>\")

# --- Copy mesh file to test binary dir ---
add_custom_command(
TARGET ${test_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/polyhedral_voronoi_regular.vtk
$<TARGET_FILE_DIR:${test_name}>
)
add_custom_command(
TARGET ${test_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/polyhedral_voronoi_lattice.vtk
$<TARGET_FILE_DIR:${test_name}>
)
add_custom_command(
TARGET ${test_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/polyhedral_voronoi_complex.vtk
$<TARGET_FILE_DIR:${test_name}>
)

endforeach()

# For some reason, BLT is not setting CUDA language for these source files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

#include <gtest/gtest.h>
#include "unitTests/fluidFlowTests/testCompFlowUtils.hpp"
#include "integrationTests/fluidFlowTests/testCompFlowUtils.hpp"
#include "mainInterface/initialization.hpp"
#include "mainInterface/ProblemManager.hpp"
#include "mainInterface/GeosxState.hpp"
Expand Down Expand Up @@ -108,7 +108,7 @@ std::string generateXmlInputTPFA( std::string const & meshFile )

<FieldSpecifications>
<FieldSpecification name="initialPressure" initialCondition="1"
setNames="{ all }" objectPath="ElementRegions/Domain" fieldName="pressure" scale="1.0e7"/>
setNames="{ all }" objectPath="ElementRegions/Domain" fieldName="pressure" scale="1.0e7"/>
<FieldSpecification name="west_pressure"
setNames="{ westBC }" objectPath="faceManager" fieldName="pressure" scale="2.0e7"/>
<FieldSpecification name="east_pressure"
Expand Down Expand Up @@ -157,68 +157,68 @@ class TPFAIntegrationTest : public ::testing::TestWithParam< const char * >
std::string testBinaryDir;
};

INSTANTIATE_TEST_SUITE_P(
MeshFiles,
TPFAIntegrationTest,
::testing::Values(
"polyhedral_voronoi_complex.vtk",
"polyhedral_voronoi_lattice.vtk",
"polyhedral_voronoi_regular.vtk"
)
);

TEST_P( TPFAIntegrationTest, PressureFieldL2Error )
{
ProblemManager & problemManager = state.getProblemManager();
DomainPartition & domain = problemManager.getDomainPartition();

// Retrieve the solver using the PhysicsSolverManager
SinglePhaseFVM< SinglePhaseBase > & solver =
dynamic_cast< SinglePhaseFVM< SinglePhaseBase > & >( problemManager.getPhysicsSolverManager().getGroup< SinglePhaseFVM< SinglePhaseBase > >( "SinglePhaseFlow" ) );

// Run the simulation to compute the numerical pressure
solver.setupSystem( domain, solver.getDofManager(), solver.getLocalMatrix(), solver.getSystemRhs(), solver.getSystemSolution() );
solver.implicitStepSetup( 0.0, MAX_TIME_STEP, domain );
solver.solverStep( 0.0, MAX_TIME_STEP, 0, domain );
solver.implicitStepComplete( 0.0, MAX_TIME_STEP, domain );

// Access the mesh and subregion
MeshLevel & mesh = domain.getMeshBody( 0 ).getBaseDiscretization();
CellElementSubRegion & subRegion = mesh.getElemManager().getRegion( 0 ).getSubRegion< CellElementSubRegion >( 0 );

// Retrieve pressure field and cell centers
arrayView2d< real64 const > centers = subRegion.getElementCenter();
arrayView1d< real64 const > volumes = subRegion.getElementVolume();
arrayView1d< real64 const > const p_h = subRegion.getField< fields::flow::pressure >();

// Compute exact pressure and L2 error
real64 l2Error = 0.0;
real64 totalVolume = 0.0;
for( localIndex i = 0; i < subRegion.size(); ++i )
{
real64 x = centers[i][0];
real64 volume = volumes[i];
real64 pNumeric = p_h[i] * to_MPA; // Convert pressure to MPa
real64 pExact = 20.0 * (1.0 - x) + 10.0 * x;
l2Error += (pNumeric - pExact) * (pNumeric - pExact) * volume;
totalVolume += volume;
}

l2Error = std::sqrt( l2Error / totalVolume );

std::string meshFile = GetParam();
if( meshFile == "polyhedral_voronoi_regular.vtk" )
{
// Assert that the L2 error is within machine precision
EXPECT_NEAR( l2Error, 0.0, PRESSURE_L2_TOLERANCE );
}
else
{
// Assert that the L2 error is not exact
EXPECT_GT( l2Error, PRESSURE_L2_TOLERANCE );
}

}
//INSTANTIATE_TEST_SUITE_P(
// MeshFiles,
// TPFAIntegrationTest,
// ::testing::Values(
// "polyhedral_voronoi_complex.vtk",
// "polyhedral_voronoi_lattice.vtk",
// "polyhedral_voronoi_regular.vtk"
// )
// );
//
//TEST_P( TPFAIntegrationTest, PressureFieldL2Error )
//{
// ProblemManager & problemManager = state.getProblemManager();
// DomainPartition & domain = problemManager.getDomainPartition();
//
// // Retrieve the solver using the PhysicsSolverManager
// SinglePhaseFVM< SinglePhaseBase > & solver =
// dynamic_cast< SinglePhaseFVM< SinglePhaseBase > & >( problemManager.getPhysicsSolverManager().getGroup< SinglePhaseFVM< SinglePhaseBase > >( "SinglePhaseFlow" ) );
//
// // Run the simulation to compute the numerical pressure
// solver.setupSystem( domain, solver.getDofManager(), solver.getLocalMatrix(), solver.getSystemRhs(), solver.getSystemSolution() );
// solver.implicitStepSetup( 0.0, MAX_TIME_STEP, domain );
// solver.solverStep( 0.0, MAX_TIME_STEP, 0, domain );
// solver.implicitStepComplete( 0.0, MAX_TIME_STEP, domain );
//
// // Access the mesh and subregion
// MeshLevel & mesh = domain.getMeshBody( 0 ).getBaseDiscretization();
// CellElementSubRegion & subRegion = mesh.getElemManager().getRegion( 0 ).getSubRegion< CellElementSubRegion >( 0 );
//
// // Retrieve pressure field and cell centers
// arrayView2d< real64 const > centers = subRegion.getElementCenter();
// arrayView1d< real64 const > volumes = subRegion.getElementVolume();
// arrayView1d< real64 const > const p_h = subRegion.getField< fields::flow::pressure >();
//
// // Compute exact pressure and L2 error
// real64 l2Error = 0.0;
// real64 totalVolume = 0.0;
// for( localIndex i = 0; i < subRegion.size(); ++i )
// {
// real64 x = centers[i][0];
// real64 volume = volumes[i];
// real64 pNumeric = p_h[i] * to_MPA; // Convert pressure to MPa
// real64 pExact = 20.0 * (1.0 - x) + 10.0 * x;
// l2Error += (pNumeric - pExact) * (pNumeric - pExact) * volume;
// totalVolume += volume;
// }
//
// l2Error = std::sqrt( l2Error / totalVolume );
//
// std::string meshFile = GetParam();
// if( meshFile == "polyhedral_voronoi_regular.vtk" )
// {
// // Assert that the L2 error is within machine precision
// EXPECT_NEAR( l2Error, 0.0, PRESSURE_L2_TOLERANCE );
// }
// else
// {
// // Assert that the L2 error is not exact
// EXPECT_GT( l2Error, PRESSURE_L2_TOLERANCE );
// }
//
//}

std::string generateXmlInputMFD( std::string const & innerProductType,
std::string const & meshFile )
Expand Down Expand Up @@ -267,7 +267,9 @@ std::string generateXmlInputMFD( std::string const & innerProductType,

<FieldSpecifications>
<FieldSpecification name="initialPressure" initialCondition="1"
setNames="{ all }" objectPath="ElementRegions/Domain" fieldName="pressure" scale="1.0e7"/>
setNames="{ all }" objectPath="ElementRegions/Domain" fieldName="pressure" scale="1.0e7"/>
<FieldSpecification name="initialFacePressure" initialCondition="1"
setNames="{ all }" objectPath="faceManager" fieldName="facePressure" scale="1.0e7"/>
<FieldSpecification name="west_pressure"
setNames="{ westBC }" objectPath="faceManager" fieldName="bcPressure" scale="2.0e7"/>
<FieldSpecification name="east_pressure"
Expand Down Expand Up @@ -327,7 +329,7 @@ INSTANTIATE_TEST_SUITE_P(
InnerProductAndMeshes,
MFDIntegrationTest,
::testing::Combine(
::testing::Values( TPFA, QuasiTPFA, QuasiRT, Simple, BdVLM ),
::testing::Values( QuasiTPFA, QuasiRT, Simple, BdVLM ),
::testing::Values(
"polyhedral_voronoi_complex.vtk",
"polyhedral_voronoi_lattice.vtk",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ SinglePhaseHybridFVM::SinglePhaseHybridFVM( const string & name,
void SinglePhaseHybridFVM::registerDataOnMesh( Group & meshBodies )
{
SinglePhaseBase::registerDataOnMesh( meshBodies );

forDiscretizationOnMeshTargets( meshBodies, [&] ( string const &,
MeshLevel & mesh,
string_array const & regionNames )
Expand All @@ -83,9 +82,8 @@ void SinglePhaseHybridFVM::registerDataOnMesh( Group & meshBodies )
// primary variables: face pressures at the previous converged time step
faceManager.registerField< flow::facePressure_n >( getName() );
}
// 3) Register the bc face data
// Register the bc face data
{
// primary variables: face pressures at the previous converged time step
faceManager.registerField< flow::bcPressure >( getName() );
}
} );
Expand Down Expand Up @@ -115,9 +113,7 @@ void SinglePhaseHybridFVM::initializePostInitialConditionsPreSubGroups()
GEOS_MARK_FUNCTION;

SinglePhaseBase::initializePostInitialConditionsPreSubGroups();

DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );

forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
MeshLevel & mesh,
string_array const & regionNames )
Expand Down Expand Up @@ -396,14 +392,14 @@ void SinglePhaseHybridFVM::applyFaceDirichletBC( real64 const time_n,

// next, we use the field specification functions to apply the boundary conditions to the system

// 1. first, populate the face pressure vector at the boundaries of the domain
// Populate the face pressure vector at the boundaries of the domain
fs.applyFieldValue< FieldSpecificationEqual,
parallelDevicePolicy<> >( targetSet,
time_n + dt,
targetGroup,
flow::bcPressure::key() );

// 2. second, modify the residual/jacobian matrix as needed to impose the boundary conditions
// Second, modify the residual/jacobian matrix as needed to impose the boundary conditions
forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOS_HOST_DEVICE ( localIndex const a )
{

Expand All @@ -413,12 +409,12 @@ void SinglePhaseHybridFVM::applyFaceDirichletBC( real64 const time_n,
return;
}

// 2.1 get the dof number of this face
// get the dof number of this face
globalIndex const dofIndex = faceDofNumber[kf];
localIndex const localRow = dofIndex - rankOffset;
real64 rhsValue;

// 2.2 apply field value to the matrix/rhs
// apply field value to the matrix/rhs
FieldSpecificationEqual::SpecifyFieldValue( dofIndex,
rankOffset,
localMatrix,
Expand All @@ -442,7 +438,6 @@ void SinglePhaseHybridFVM::applyAquiferBC( real64 const time,
arrayView1d< real64 > const & localRhs ) const
{
GEOS_MARK_FUNCTION;

GEOS_UNUSED_VAR( time, dt, dofManager, domain, localMatrix, localRhs );
}

Expand All @@ -451,7 +446,6 @@ void SinglePhaseHybridFVM::saveAquiferConvergedState( real64 const & time,
DomainPartition & domain )
{
GEOS_MARK_FUNCTION;

GEOS_UNUSED_VAR( time, dt, domain );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,16 @@ class ElementBasedAssemblyKernel
StackVariables & stack ) const
{
// local (cell-centered) mobility and its derivative w.r.t. pressure
real64 const localMobility = m_mob[m_er][m_esr][ei];
real64 const dLocalMobility_dPres = m_dMob[m_er][m_esr][ei][DerivOffset::dP];
real64 const massMobility = m_mob[m_er][m_esr][ei];
real64 const dmassMobility_dPres = m_dMob[m_er][m_esr][ei][DerivOffset::dP];

for( integer iFaceLoc = 0; iFaceLoc < NUM_FACE; ++iFaceLoc )
{
// now in the following nested loop,
// we compute the contribution of face jFaceLoc to the one sided total mass flux at face iFaceLoc
for( integer jFaceLoc = 0; jFaceLoc < NUM_FACE; ++jFaceLoc )
{
// 1) compute the potential diff between the cell center and the face center
// Compute the potential diff between the cell center and the face center
real64 const ccPres = m_elemPres[ei];
real64 const fPres = m_facePres[m_elemToFaces[ei][jFaceLoc]];

Expand All @@ -405,18 +405,14 @@ class ElementBasedAssemblyKernel
real64 const dPotDif_dFacePres = dPresDif_dFacePres;
real64 const T_ij = stack.transMatrix[iFaceLoc][jFaceLoc];

// massic factor: rho * lambda
real64 const massMobility = ccDens * localMobility;
real64 const dmassMobility_dPres = dCcDens_dPres * localMobility + ccDens * dLocalMobility_dPres;

// T * rho * lambda * (\nabla p - rho * g * \nabla d)
stack.massFlux[iFaceLoc] += T_ij * massMobility * potDif;
// T * lambda * (\nabla p - rho * g * \nabla d)
stack.massFlux[iFaceLoc] += m_dt * T_ij * massMobility * potDif;

// derivatives w.r.t. element-centered pressure
stack.dmassFlux_dPres[iFaceLoc] += T_ij * ( dmassMobility_dPres * potDif + massMobility * dPotDif_dPres );
stack.dmassFlux_dPres[iFaceLoc] += m_dt * T_ij * ( dmassMobility_dPres * potDif + massMobility * dPotDif_dPres );

// derivatives w.r.t. face-centered pressures
stack.dmassFlux_dFacePres[iFaceLoc][jFaceLoc] += T_ij * massMobility * dPotDif_dFacePres;
stack.dmassFlux_dFacePres[iFaceLoc][jFaceLoc] += m_dt * T_ij * massMobility * dPotDif_dFacePres;
}
}
}
Expand All @@ -439,12 +435,12 @@ class ElementBasedAssemblyKernel
for( integer iFaceLoc = 0; iFaceLoc < NUM_FACE; ++iFaceLoc )
{
// accumulate the mass flux divergence and its derivatives using the actual mass flux
stack.divMassFluxes += m_dt * stack.massFlux[iFaceLoc];
stack.dDivMassFluxes_dElemVars[0] += m_dt * stack.dmassFlux_dPres[iFaceLoc];
stack.divMassFluxes += stack.massFlux[iFaceLoc];
stack.dDivMassFluxes_dElemVars[0] += stack.dmassFlux_dPres[iFaceLoc];

for( integer jFaceLoc = 0; jFaceLoc < NUM_FACE; ++jFaceLoc )
{
stack.dDivMassFluxes_dFaceVars[jFaceLoc] += m_dt * stack.dmassFlux_dFacePres[iFaceLoc][jFaceLoc];
stack.dDivMassFluxes_dFaceVars[jFaceLoc] += stack.dmassFlux_dFacePres[iFaceLoc][jFaceLoc];
}

// collect the relevant dof numbers (always local)
Expand All @@ -470,7 +466,6 @@ class ElementBasedAssemblyKernel
real64 const perm[ 3 ] = { m_elemPerm[ei][0][0], m_elemPerm[ei][0][1], m_elemPerm[ei][0][2] };

// recompute the local transmissibility matrix at each iteration
// we can decide later to precompute transMatrix if needed
IP::template compute< NUM_FACE >( m_nodePosition,
m_transMultiplier,
m_faceToNodes,
Expand All @@ -481,14 +476,11 @@ class ElementBasedAssemblyKernel
m_lengthTolerance,
stack.transMatrix );

// compute the one-sided mass fluxes and their derivatives
computeMassFlux( ei, stack );

// at this point, we know the local flow direction in the element
// so we can upwind the transport coefficients (mobilities) at the one sided faces
if( m_elemGhostRank[ei] < 0 )
{

// compute the one-sided mass fluxes and their derivatives
computeMassFlux( ei, stack );

/*
* perform assembly in this element in two steps:
* 1) mass conservation equations
Expand Down