Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
multitalentloes committed Sep 17, 2024
1 parent 1ff0e5c commit 345e331
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 40 deletions.
4 changes: 2 additions & 2 deletions opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ template <class TraitsT,
class GasOilMaterialLawT,
class OilWaterMaterialLawT,
class GasWaterMaterialLawT,
bool useSmartPointers = true,
template <typename> class PtrT = std::shared_ptr,
class ParamsT = EclTwoPhaseMaterialParams<TraitsT,
typename GasOilMaterialLawT::Params,
typename OilWaterMaterialLawT::Params,
typename GasWaterMaterialLawT::Params,
useSmartPointers> >
PtrT>>
class EclTwoPhaseMaterial : public TraitsT
{
public:
Expand Down
70 changes: 32 additions & 38 deletions opm/material/fluidmatrixinteractions/EclTwoPhaseMaterialParams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum class EclTwoPhaseApproach {
* Essentially, this class just stores the two parameter objects for
* the twophase capillary pressure laws.
*/
template<class Traits, class GasOilParamsT, class OilWaterParamsT, class GasWaterParamsT, bool useSharedPointers = true>
template<class Traits, class GasOilParamsT, class OilWaterParamsT, class GasWaterParamsT, template <typename> class PtrT = std::shared_ptr>
class EclTwoPhaseMaterialParams : public EnsureFinalized
{
using Scalar = typename Traits::Scalar;
Expand All @@ -61,15 +61,9 @@ class EclTwoPhaseMaterialParams : public EnsureFinalized


// make it possible to opt out of using shared pointers to stay within valid cuda c++
using GasOilParamsPtr = std::conditional_t<useSharedPointers,
std::shared_ptr<GasOilParams>,
GasOilParams*>;
using OilWaterParamsPtr = std::conditional_t<useSharedPointers,
std::shared_ptr<OilWaterParams>,
OilWaterParams*>;
using GasWaterParamsPtr = std::conditional_t<useSharedPointers,
std::shared_ptr<GasWaterParams>,
GasWaterParams*>;
using GasOilParamsPtr = PtrT<GasOilParams>;
using OilWaterParamsPtr = PtrT<OilWaterParams>;
using GasWaterParamsPtr = PtrT<GasWaterParams>;

/*!
* \brief The default constructor.
Expand Down Expand Up @@ -160,33 +154,33 @@ class EclTwoPhaseMaterialParams : public EnsureFinalized

} // namespace Opm

namespace Opm::gpuistl{

/// @brief this function is intented to make a GPU friendly view of the EclTwoPhaseMaterialParams
/// @tparam TraitsT the same traits as in EclTwoPhaseMaterialParams
/// @tparam ContainerType typically const gpuBuffer<scalarType>
/// @tparam ViewType typically gpuView<const scalarType>
/// @param params the parameters object instansiated with gpuBuffers or similar
/// @return the GPU view of the GPU EclTwoPhaseMaterialParams object
template <class TraitsT, class GasOilParamsT, class OilWaterParamsT, class GasWwaterParamsT>
EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, false> make_view(const EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, false>& params) {

// Since the view should mainly work for stuff already initialized on the GPU we know that we already have raw
// pointers that do not need to be further dealt with, this make_view should just pass it on to fit the API
// using twoPhaseParamsWithShared = EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, true>;
// typename twoPhaseParamsWithShared::GasOilParams* gasOilParams = params.gasOilParams().get();
// typename twoPhaseParamsWithShared::OilWaterParams* oilWaterParams = params.oilWaterParams().get();
// typename twoPhaseParamsWithShared::GasWaterParams* gasWaterParams = params.gasWaterParams().get();

auto resultView = EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, false>();
resultView.setGasOilParams(params.gasOilParams());
resultView.setOilWaterParams(params.oilWaterParams());
resultView.setGasWaterParams(params.gasWaterParams());
resultView.setApproach(params.approach());
resultView.finalize();

return resultView;
}
}
// namespace Opm::gpuistl{

// /// @brief this function is intented to make a GPU friendly view of the EclTwoPhaseMaterialParams
// /// @tparam TraitsT the same traits as in EclTwoPhaseMaterialParams
// /// @tparam ContainerType typically const gpuBuffer<scalarType>
// /// @tparam ViewType typically gpuView<const scalarType>
// /// @param params the parameters object instansiated with gpuBuffers or similar
// /// @return the GPU view of the GPU EclTwoPhaseMaterialParams object
// template <class TraitsT, class GasOilParamsT, class OilWaterParamsT, class GasWwaterParamsT>
// EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, false> make_view(const EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, false>& params) {

// // Since the view should mainly work for stuff already initialized on the GPU we know that we already have raw
// // pointers that do not need to be further dealt with, this make_view should just pass it on to fit the API
// // using twoPhaseParamsWithShared = EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, true>;
// // typename twoPhaseParamsWithShared::GasOilParams* gasOilParams = params.gasOilParams().get();
// // typename twoPhaseParamsWithShared::OilWaterParams* oilWaterParams = params.oilWaterParams().get();
// // typename twoPhaseParamsWithShared::GasWaterParams* gasWaterParams = params.gasWaterParams().get();

// auto resultView = EclTwoPhaseMaterialParams<TraitsT, GasOilParamsT, OilWaterParamsT, GasWwaterParamsT, false>();
// resultView.setGasOilParams(params.gasOilParams());
// resultView.setOilWaterParams(params.oilWaterParams());
// resultView.setGasWaterParams(params.gasWaterParams());
// resultView.setApproach(params.approach());
// resultView.finalize();

// return resultView;
// }
// }

#endif

0 comments on commit 345e331

Please sign in to comment.