Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rm #945

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Rm #945

Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/amr/data/field/field_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace amr
static constexpr std::size_t dimension = GridLayoutT::dimension;
static constexpr std::size_t interp_order = GridLayoutT::interp_order;
using Geometry = FieldGeometry<GridLayoutT, PhysicalQuantity>;
using Resource_t = Grid_t;

/*** \brief Construct a FieldData from information associated to a patch
*
Expand Down
2 changes: 2 additions & 0 deletions src/amr/data/particles/particles_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ namespace amr
static constexpr int ghostSafeMapLayer = 1;

public:
using Resource_t = typename core::ParticlesPack<ParticleArray>;

ParticlesData(SAMRAI::hier::Box const& box, SAMRAI::hier::IntVector const& ghost,
std::string const& name)
: SAMRAI::hier::PatchData::PatchData(box, ghost)
Expand Down
29 changes: 16 additions & 13 deletions src/amr/physical_models/hybrid_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "amr/messengers/hybrid_messenger_info.hpp"
#include "core/data/vecfield/vecfield.hpp"
#include "core/def.hpp"
#include "core/data/ions/ion_population/particle_pack.hpp"

namespace PHARE::solver
{
Expand All @@ -27,19 +28,21 @@ class HybridModel : public IPhysicalModel<AMR_Types>

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, grid_type>;
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 particle_pack_t = core::ParticlesPack<particle_array_type>;
using resources_manager_type
= amr::ResourcesManager<gridlayout_type, grid_type, particle_pack_t>;
using ParticleInitializerFactory
= core::ParticleInitializerFactory<particle_array_type, gridlayout_type>;

Expand Down
2 changes: 1 addition & 1 deletion src/amr/resources_manager/field_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace amr
* also says the type of the actual data buffer
*/
template<typename Grid_t, typename GridLayoutT>
struct UserFieldType
struct FieldViewInfo
{
using patch_data_type = FieldData<GridLayoutT, Grid_t>;
using variable_type = FieldVariable<GridLayoutT, Grid_t>;
Expand Down
11 changes: 5 additions & 6 deletions src/amr/resources_manager/particle_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ namespace PHARE
{
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
/** @brief tells SAMRAI which kind of variable, patchdata are used for a Particle resource
*/
template<typename ResourcesUser, std::size_t interp>
struct UserParticleType
template<typename ParticleResource, std::size_t interp>
struct ParticleViewInfo
{
static constexpr auto dimension = ResourcesUser::dimension;
static constexpr auto dimension = ParticleResource::dimension;
static constexpr auto interp_order = interp;

using particle_array_type = typename ResourcesUser::particle_array_type;
using particle_array_type = typename ParticleResource::particle_array_type;
using variable_type = ParticlesVariable<particle_array_type, interp_order>;
using patch_data_type = ParticlesData<particle_array_type>;
};
Expand Down
51 changes: 17 additions & 34 deletions src/amr/resources_manager/resources_guards.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,50 @@ namespace PHARE
{
namespace amr
{
/** \brief ResourcesGuards maintain a link with several resources in order to give them
* an access to the data.
*
* At construction it will take the patch, and all resourcesManagerUser object that need to
* be set via the ResourcesManager. Upon destruction, it will put all the previous
* object in an inactive state (for now it just put nullptr on them)

* TODO: add the active mechanism
/** \brief ViewGuard ... TODO fix doc
*/
template<typename ResourcesManager, typename... ResourcesUsers>
class ResourcesGuard
template<typename ResourcesManager, typename... Views>
class ViewGuard
{
public:
/**
* \brief At construction, each resourcesUser will be valid. At destruction time, each
* resourcesUser will be invalid
*
* \param[in] patch
* \param[in] resourcesManager
* \param[in,out] resourcesUsers
*/
ResourcesGuard(SAMRAI::hier::Patch const& patch, ResourcesManager const& resourcesManager,
ResourcesUsers&... resourcesUsers)
: resourcesUsers_{resourcesUsers...}
ViewGuard(SAMRAI::hier::Patch const& patch, ResourcesManager const& resourcesManager,
Views&... views)
: views_{views...}
, patch_{patch}
, resourcesManager_{resourcesManager}
{
std::apply(
[this](auto&... user) {
((resourcesManager_.setResources_(user, UseResourcePtr{}, patch_)), ...);
},
resourcesUsers_);
views_);
}




~ResourcesGuard()
~ViewGuard()
{
// set nullptr to all users in resourcesUsers_
std::apply(
[this](auto&... user) {
((resourcesManager_.setResources_(user, UseNullPtr{}, patch_)), ...);
[this](auto&... view) {
((resourcesManager_.setResources_(view, UseNullPtr{}, patch_)), ...);
},
resourcesUsers_);
views_);
}




// We just need the move constructor for using ResourceManager::createResourcesGuards
ResourcesGuard(ResourcesGuard&&) = default;
ResourcesGuard() = delete;
ResourcesGuard(ResourcesGuard const&) = delete;
ResourcesGuard& operator=(ResourcesGuard const& source) = delete;
ResourcesGuard& operator=(ResourcesGuard&&) = delete;
ViewGuard(ViewGuard&&) = default;
ViewGuard() = delete;
ViewGuard(ViewGuard const&) = delete;
ViewGuard& operator=(ViewGuard const& source) = delete;
ViewGuard& operator=(ViewGuard&&) = delete;



private:
std::tuple<ResourcesUsers&...> resourcesUsers_;
std::tuple<Views&...> views_;
SAMRAI::hier::Patch const& patch_;
ResourcesManager const& resourcesManager_;
};
Expand Down
Loading
Loading