Skip to content

Commit

Permalink
🥱
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Dec 16, 2023
1 parent 5777b3c commit ccb1caf
Show file tree
Hide file tree
Showing 34 changed files with 292 additions and 309 deletions.
45 changes: 21 additions & 24 deletions src/amr/physical_models/hybrid_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,30 @@ namespace PHARE::solver
* holds a HybridState and a ResourcesManager.
*/
template<typename GridLayoutT, typename Electromag, typename Ions, typename Electrons,
typename AMR_Types>
typename AMR_Types, typename Grid_t>
class HybridModel : public IPhysicalModel<AMR_Types>
{
public:
static constexpr auto dimension = GridLayoutT::dimension;
using type_list = PHARE::core::type_list<GridLayoutT, Electromag, Ions, Electrons, AMR_Types>;
using Interface = IPhysicalModel<AMR_Types>;
using amr_types = AMR_Types;
using patch_t = typename AMR_Types::patch_t;
using level_t = typename AMR_Types::level_t;
using gridlayout_type = GridLayoutT;
using electromag_type = Electromag;
using vecfield_type = typename Electromag::vecfield_type;
using field_type = typename vecfield_type::field_type;
using grid_type = core::Grid<core::NdArrayVector<dimension, typename field_type::value_type>,
typename field_type::physical_quantity_type>;
using ions_type = Ions;
using type_list
= PHARE::core::type_list<GridLayoutT, Electromag, Ions, Electrons, AMR_Types, Grid_t>;
using Interface = IPhysicalModel<AMR_Types>;
using amr_types = AMR_Types;
using electrons_t = Electrons;
using patch_t = typename AMR_Types::patch_t;
using level_t = typename AMR_Types::level_t;
using gridlayout_type = GridLayoutT;
using electromag_type = Electromag;
using vecfield_type = typename Electromag::vecfield_type;
using field_type = typename vecfield_type::field_type;
using grid_type = Grid_t;
using ions_type = Ions;
using particle_array_type = typename Ions::particle_array_type;
using resources_manager_type = amr::ResourcesManager<gridlayout_type>;
using resources_manager_type = amr::ResourcesManager<gridlayout_type, grid_type>;
using ParticleInitializerFactory
= core::ParticleInitializerFactory<particle_array_type, gridlayout_type>;

static const std::string model_name;
static const inline std::string model_name = "HybridModel";


core::HybridState<Electromag, Ions, Electrons> state;
Expand Down Expand Up @@ -117,8 +118,9 @@ class HybridModel : public IPhysicalModel<AMR_Types>


template<typename GridLayoutT, typename Electromag, typename Ions, typename Electrons,
typename AMR_Types>
void HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types>::initialize(level_t& level)
typename AMR_Types, typename Grid_t>
void HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types, Grid_t>::initialize(
level_t& level)
{
for (auto& patch : level)
{
Expand All @@ -144,8 +146,8 @@ void HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types>::initializ


template<typename GridLayoutT, typename Electromag, typename Ions, typename Electrons,
typename AMR_Types>
void HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types>::fillMessengerInfo(
typename AMR_Types, typename Grid_t>
void HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types, Grid_t>::fillMessengerInfo(
std::unique_ptr<amr::IMessengerInfo> const& info) const
{
auto& hybridInfo = dynamic_cast<amr::HybridMessengerInfo&>(*info);
Expand Down Expand Up @@ -177,11 +179,6 @@ void HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types>::fillMesse



template<typename GridLayoutT, typename Electromag, typename Ions, typename Electrons,
typename AMR_Types>
const std::string HybridModel<GridLayoutT, Electromag, Ions, Electrons, AMR_Types>::model_name
= "HybridModel";

template<typename... Args>
HybridModel<Args...> hybrid_model_from_type_list(core::type_list<Args...>);

Expand Down
10 changes: 4 additions & 6 deletions src/amr/physical_models/mhd_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ namespace PHARE
{
namespace solver
{
template<typename GridLayoutT, typename VecFieldT, typename AMR_Types>
template<typename GridLayoutT, typename VecFieldT, typename AMR_Types, typename Grid_t>
class MHDModel : public IPhysicalModel<AMR_Types>
{
public:
using patch_t = typename AMR_Types::patch_t;
using level_t = typename AMR_Types::level_t;
using Interface = IPhysicalModel<AMR_Types>;

static const std::string model_name;
static constexpr auto dimension = GridLayoutT::dimension;
using resources_manager_type = amr::ResourcesManager<GridLayoutT>;
static const inline std::string model_name = "MHDModel";
static constexpr auto dimension = GridLayoutT::dimension;
using resources_manager_type = amr::ResourcesManager<GridLayoutT, Grid_t>;


explicit MHDModel(std::shared_ptr<resources_manager_type> const& _resourcesManager)
Expand Down Expand Up @@ -67,8 +67,6 @@ namespace solver
std::shared_ptr<resources_manager_type> resourcesManager;
};

template<typename GridLayoutT, typename VecFieldT, typename AMR_Types>
const std::string MHDModel<GridLayoutT, VecFieldT, AMR_Types>::model_name = "MHDModel";


} // namespace solver
Expand Down
7 changes: 3 additions & 4 deletions src/amr/resources_manager/field_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ namespace amr
/** @brief tells SAMRAI which kind of variable, patchdata are used for a Field Resource
* also says the type of the actual data buffer
*/
template<typename ResourcesUser, typename GridLayoutT>
template<typename Grid_t, typename GridLayoutT>
struct UserFieldType
{
using patch_data_type = FieldData<GridLayoutT, typename ResourcesUser::grid_type>;
using variable_type = FieldVariable<GridLayoutT, typename ResourcesUser::grid_type>;
using internal_type_ptr = typename ResourcesUser::field_type*;
using patch_data_type = FieldData<GridLayoutT, Grid_t>;
using variable_type = FieldVariable<GridLayoutT, Grid_t>;
};


Expand Down
1 change: 0 additions & 1 deletion src/amr/resources_manager/particle_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace amr
using particle_array_type = typename ResourcesUser::particle_array_type;
using variable_type = ParticlesVariable<particle_array_type, interp_order>;
using patch_data_type = ParticlesData<particle_array_type>;
using internal_type_ptr = typename ResourcesUser::particle_resource_type*;
};

} // namespace amr
Expand Down
16 changes: 8 additions & 8 deletions src/amr/resources_manager/resources_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@ namespace amr
*
*
*/
template<typename GridLayoutT>
template<typename GridLayoutT, typename Grid_t>
class ResourcesManager
{
public:
static constexpr std::size_t dimension = GridLayoutT::dimension;
static constexpr std::size_t interp_order = GridLayoutT::interp_order;

template<typename ResourcesUser>
using UserField_t = UserFieldType<ResourcesUser, GridLayoutT>;
using UserField_t = UserFieldType<Grid_t, GridLayoutT>;

template<typename ResourcesUser>
using UserParticle_t = UserParticleType<ResourcesUser, interp_order>;
Expand Down Expand Up @@ -137,7 +136,7 @@ namespace amr
{
if constexpr (has_field<ResourcesUser>::value)
{
registerResources_<ResourcesUser, UserField_t<ResourcesUser>>(obj);
registerResources_<ResourcesUser, UserField_t>(obj);
}

if constexpr (has_particles<ResourcesUser>::value)
Expand Down Expand Up @@ -433,7 +432,8 @@ namespace amr

else if constexpr (std::is_same_v<RequestedPtr, UseNullPtr>)
{
return static_cast<typename ResourceType::internal_type_ptr>(nullptr);
return static_cast<decltype(getPatchData_(resourceType, resourcesVariableInfo,
patch))>(nullptr);
}
}

Expand All @@ -446,8 +446,8 @@ namespace amr
{
if constexpr (has_field<ResourcesUser>::value)
{
setResourcesInternal_(obj, UserField_t<ResourcesUser>{},
obj.getFieldNamesAndQuantities(), patch, nullOrResourcePtr);
setResourcesInternal_(obj, UserField_t{}, obj.getFieldNamesAndQuantities(), patch,
nullOrResourcePtr);
}

if constexpr (has_particles<ResourcesUser>::value)
Expand Down Expand Up @@ -492,7 +492,7 @@ namespace amr
return foundResource == std::end(map);
};

if constexpr (isUserFieldType<UserField_t<ResourcesUser>, ResourcesType>::value)
if constexpr (isUserFieldType<UserField_t, ResourcesType>::value)
{
auto const& resourcesProperties = user.getFieldNamesAndQuantities();
for (auto const& properties : resourcesProperties)
Expand Down
19 changes: 9 additions & 10 deletions src/amr/solvers/solver_mhd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,26 @@ namespace solver

virtual ~SolverMHD() = default;

virtual std::string modelName() const override { return MHDModel::model_name; }
std::string modelName() const override { return MHDModel::model_name; }


virtual void
fillMessengerInfo(std::unique_ptr<amr::IMessengerInfo> const& /*info*/) const override
void fillMessengerInfo(std::unique_ptr<amr::IMessengerInfo> const& /*info*/) const override
{
}


virtual void registerResources(IPhysicalModel<AMR_Types>& /*model*/) override {}
void registerResources(IPhysicalModel<AMR_Types>& /*model*/) override {}

// TODO make this a resourcesUser
virtual void allocate(IPhysicalModel<AMR_Types>& /*model*/, patch_t& /*patch*/,
double const /*allocateTime*/) const override
void allocate(IPhysicalModel<AMR_Types>& /*model*/, patch_t& /*patch*/,
double const /*allocateTime*/) const override
{
}

virtual void advanceLevel(hierarchy_t const& /*hierarchy*/, int const /*levelNumber*/,
ISolverModelView& /*view*/,
amr::IMessenger<IPhysicalModel<AMR_Types>>& /*fromCoarser*/,
const double /*currentTime*/, const double /*newTime*/) override
void advanceLevel(hierarchy_t const& /*hierarchy*/, int const /*levelNumber*/,
ISolverModelView& /*view*/,
amr::IMessenger<IPhysicalModel<AMR_Types>>& /*fromCoarser*/,
const double /*currentTime*/, const double /*newTime*/) override
{
}

Expand Down
Loading

0 comments on commit ccb1caf

Please sign in to comment.