Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class CO2SolubilityUpdate final : public FlashModelBaseUpdate
{
public:

using PhaseProp = MultiFluidVar< real64, 3, multifluid::LAYOUT_PHASE, multifluid::LAYOUT_PHASE_DC >;
using PhaseComp = MultiFluidVar< real64, 4, multifluid::LAYOUT_PHASE_COMP, multifluid::LAYOUT_PHASE_COMP_DC >;
using PhaseProp = MultiFluidVar< real64, 3 >;
using PhaseComp = MultiFluidVar< real64, 4 >;

CO2SolubilityUpdate( arrayView1d< real64 const > const & componentMolarWeight,
TableFunction const & CO2SolubilityTable,
Expand Down
108 changes: 68 additions & 40 deletions src/coreComponents/constitutive/fluid/multifluid/Layouts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "common/DataTypes.hpp"
#include "common/GeosxConfig.hpp"

#include "LvArray/src/typeManipulation.hpp"
#include "RAJA/RAJA.hpp"

namespace geos
Expand All @@ -32,7 +31,7 @@ namespace constitutive
namespace multifluid
{

/// indices of pressure, temperature, and composition derivatives
/// Indices of pressure, temperature, and composition derivatives
struct DerivativeOffset
{
/// index of derivative wrt pressure
Expand All @@ -43,56 +42,85 @@ struct DerivativeOffset
static integer constexpr dC = 2;
};

// Data layout depends on the number of dimensions of the data
template< int NDIM >
struct Layout
{
using PERM = RAJA::PERM_I;
};

#if defined( GEOS_USE_DEVICE )

/// Constitutive model phase property array layout
using LAYOUT_PHASE = RAJA::PERM_JKI;
/// Constitutive model phase property compositional derivative array layout
using LAYOUT_PHASE_DC = RAJA::PERM_JKLI;
template<> struct Layout< 2 >
{
using PERM = RAJA::PERM_JI;
};
template<> struct Layout< 3 >
{
using PERM = RAJA::PERM_JKI;
};
template<> struct Layout< 4 >
{
using PERM = RAJA::PERM_JKLI;
};
template<> struct Layout< 5 >
{
using PERM = RAJA::PERM_JKLMI;
};

#else

template<> struct Layout< 2 >
{
using PERM = RAJA::PERM_IJ;
};
template<> struct Layout< 3 >
{
using PERM = RAJA::PERM_IJK;
};
template<> struct Layout< 4 >
{
using PERM = RAJA::PERM_IJKL;
};
template<> struct Layout< 5 >
{
using PERM = RAJA::PERM_IJKLM;
};

/// Constitutive model phase composition array layout
using LAYOUT_PHASE_COMP = RAJA::PERM_JKLI;
/// Constitutive model phase composition compositional derivative array layout
using LAYOUT_PHASE_COMP_DC = RAJA::PERM_JKLMI;
#endif

/// Constitutive model fluid property array layout
using LAYOUT_FLUID = RAJA::PERM_JI;
/// Constitutive model fluid property compositional derivative array layout
using LAYOUT_FLUID_DC = RAJA::PERM_JKI;
namespace internal
{

#else
template< typename T, int DIM, int USD >
struct ArraySliceOrRefHelper
{
using type = geos::ArraySlice< T, DIM, USD >;
};

/// Constitutive model phase property array layout
using LAYOUT_PHASE = RAJA::PERM_IJK;
/// Constitutive model phase property compositional derivative array layout
using LAYOUT_PHASE_DC = RAJA::PERM_IJKL;
// an array slice of DIM=0 decays to a reference to scalar
template< typename T, int USD >
struct ArraySliceOrRefHelper< T, 0, USD >
{
using type = T &;
};

/// Constitutive model phase composition array layout
using LAYOUT_PHASE_COMP = RAJA::PERM_IJKL;
/// Constitutive model phase composition compositional derivative array layout
using LAYOUT_PHASE_COMP_DC = RAJA::PERM_IJKLM;
template< typename T, int DIM, int USD=DIM-1 >
using ArraySliceOrRef = typename ArraySliceOrRefHelper< T, DIM, USD >::type;

/// Constitutive model fluid property array layout
using LAYOUT_FLUID = RAJA::PERM_IJ;
/// Constitutive model fluid property compositional derivative array layout
using LAYOUT_FLUID_DC = RAJA::PERM_IJK;
} // namespace internal

#endif
template< typename T, int NDIM >
using Array = geos::Array< T, NDIM, typename Layout< NDIM >::PERM >;

/// Constitutive model phase property unit stride dimension
static constexpr int USD_PHASE = LvArray::typeManipulation::getStrideOneDimension( LAYOUT_PHASE{} );
/// Constitutive model phase property compositional derivative unit stride dimension
static constexpr int USD_PHASE_DC = LvArray::typeManipulation::getStrideOneDimension( LAYOUT_PHASE_DC{} );
template< typename T, int NDIM, localIndex CAPACITY >
using StackArray = geos::StackArray< T, NDIM, CAPACITY, typename Layout< NDIM >::PERM >;

/// Constitutive model phase composition unit stride dimension
static constexpr int USD_PHASE_COMP = LvArray::typeManipulation::getStrideOneDimension( LAYOUT_PHASE_COMP{} );
/// Constitutive model phase composition compositional derivative unit stride dimension
static constexpr int USD_PHASE_COMP_DC = LvArray::typeManipulation::getStrideOneDimension( LAYOUT_PHASE_COMP_DC{} );
template< typename T, int NDIM >
using ArrayView = geos::ArrayView< T, NDIM, getUSD< typename Layout< NDIM >::PERM > >;

/// Constitutive model fluid property unit stride dimension
static constexpr int USD_FLUID = LvArray::typeManipulation::getStrideOneDimension( LAYOUT_FLUID{} );
/// Constitutive model fluid property compositional derivative unit stride dimension
static constexpr int USD_FLUID_DC = LvArray::typeManipulation::getStrideOneDimension( LAYOUT_FLUID_DC{} );
template< typename T, int NDIM >
using ArraySlice = internal::ArraySliceOrRef< T, NDIM, getUSD< typename Layout< NDIM >::PERM > >;

} // namespace multifluid
} // namespace constitutive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ void MultiFluidBase::saveConvergedState() const
PhaseProp::ViewTypeConst const phaseInternalEnergy = m_phaseInternalEnergy.toViewConst();
PhaseComp::ViewTypeConst const phaseCompFraction = m_phaseCompFraction.toViewConst();

arrayView2d< real64, multifluid::USD_FLUID > const totalDensity_n = m_totalDensity_n.toView();
arrayView3d< real64, multifluid::USD_PHASE > const phaseDensity_n = m_phaseDensity_n.toView();
arrayView3d< real64, multifluid::USD_PHASE > const phaseEnthalpy_n = m_phaseEnthalpy_n.toView();
arrayView3d< real64, multifluid::USD_PHASE > const phaseInternalEnergy_n = m_phaseInternalEnergy_n.toView();
arrayView4d< real64, multifluid::USD_PHASE_COMP > const phaseCompFraction_n = m_phaseCompFraction_n.toView();
multifluid::ArrayView< real64, 2 > const totalDensity_n = m_totalDensity_n.toView();
multifluid::ArrayView< real64, 3 > const phaseDensity_n = m_phaseDensity_n.toView();
multifluid::ArrayView< real64, 3 > const phaseEnthalpy_n = m_phaseEnthalpy_n.toView();
multifluid::ArrayView< real64, 3 > const phaseInternalEnergy_n = m_phaseInternalEnergy_n.toView();
multifluid::ArrayView< real64, 4 > const phaseCompFraction_n = m_phaseCompFraction_n.toView();

forAll< parallelDevicePolicy<> >( numElem, [=] GEOS_HOST_DEVICE ( localIndex const k )
{
Expand Down
Loading