diff --git a/src/amr/data/field/field_data.hpp b/src/amr/data/field/field_data.hpp index 385393be7..e1d143d60 100644 --- a/src/amr/data/field/field_data.hpp +++ b/src/amr/data/field/field_data.hpp @@ -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; + using view_type = Grid_t::field_type; /*** \brief Construct a FieldData from information associated to a patch * diff --git a/src/amr/data/particles/particles_data.hpp b/src/amr/data/particles/particles_data.hpp index 803247447..daaacc3cf 100644 --- a/src/amr/data/particles/particles_data.hpp +++ b/src/amr/data/particles/particles_data.hpp @@ -112,6 +112,8 @@ namespace amr static constexpr int ghostSafeMapLayer = 1; public: + using view_type = typename core::ParticlesPack; + ParticlesData(SAMRAI::hier::Box const& box, SAMRAI::hier::IntVector const& ghost, std::string const& name) : SAMRAI::hier::PatchData::PatchData(box, ghost) diff --git a/src/amr/multiphysics_integrator.hpp b/src/amr/multiphysics_integrator.hpp index e6f71d85e..32a39dd5b 100644 --- a/src/amr/multiphysics_integrator.hpp +++ b/src/amr/multiphysics_integrator.hpp @@ -278,25 +278,6 @@ namespace solver /** * @brief see SAMRAI documentation. This function initializes the data on the given level. - * - * The method first checks wether allocation of patch data must be performed. - * If it does, all objects using resources on patches must see their allocate() function - * called. - * - * This is: - * - the model (by definition the model has data defined on patches) - * - the solver (Some solvers has internal data that needs to exist on patches) - * - the messenger (the messenger has data defined on patches for internal reasons) - * - * - * then the level needs to be registered to the messenger. - * - * Then data initialization per se begins and one can be on one of the following cases: - * - * - regridding - * - initialization of the root level - * - initialization of a new level from scratch (not a regridding) - * */ void initializeLevelData(std::shared_ptr const& hierarchy, int const levelNumber, double const initDataTime, @@ -342,7 +323,8 @@ namespace solver // this level is the source or destination // we therefore need to rebuild them auto const finestLvlNbr = hierarchy->getFinestLevelNumber(); - auto nextFiner = (levelNumber == finestLvlNbr) ? levelNumber : levelNumber + 1; + auto const nextFiner + = (levelNumber == finestLvlNbr) ? levelNumber : levelNumber + 1; for (auto ilvl = levelNumber; ilvl <= nextFiner; ++ilvl) { @@ -369,10 +351,13 @@ namespace solver else load_balancer_manager_->estimate(*level, model); - if (static_cast(levelNumber) == model_views_.size()) - model_views_.push_back(solver.make_view(*level, model)); - else - model_views_[levelNumber] = solver.make_view(*level, model); + + model.resources_manager().makeLevelViews(*hierarchy, levelNumber); + + // if (static_cast(levelNumber) == model_views_.size()) + // model_views_.push_back(solver.make_view(*level, model)); + // else + // model_views_[levelNumber] = solver.make_view(*level, model); } diff --git a/src/amr/physical_models/hybrid_model.hpp b/src/amr/physical_models/hybrid_model.hpp index 449bafc22..52e1ca952 100644 --- a/src/amr/physical_models/hybrid_model.hpp +++ b/src/amr/physical_models/hybrid_model.hpp @@ -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 { @@ -27,19 +28,20 @@ class HybridModel : public IPhysicalModel using type_list = PHARE::core::type_list; - using Interface = IPhysicalModel; - 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; + using Interface = IPhysicalModel; + 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; using ParticleInitializerFactory = core::ParticleInitializerFactory; @@ -53,6 +55,11 @@ class HybridModel : public IPhysicalModel virtual void initialize(level_t& level) override; + virtual amr::IResourcesManager& resources_manager() const override + { + return *std::dynamic_pointer_cast(resourcesManager); + } + /** * @brief allocate uses the ResourcesManager to allocate HybridState physical quantities on * the given Patch at the given allocateTime diff --git a/src/amr/physical_models/mhd_model.hpp b/src/amr/physical_models/mhd_model.hpp index 946c51bb8..c60399648 100644 --- a/src/amr/physical_models/mhd_model.hpp +++ b/src/amr/physical_models/mhd_model.hpp @@ -41,6 +41,10 @@ namespace solver virtual void initialize(level_t& /*level*/) override {} + virtual amr::IResourcesManager& resources_manager() const override + { + return *std::dynamic_pointer_cast(resourcesManager); + } virtual void allocate(patch_t& patch, double const allocateTime) override { diff --git a/src/amr/physical_models/physical_model.hpp b/src/amr/physical_models/physical_model.hpp index cde754d02..e5e47694b 100644 --- a/src/amr/physical_models/physical_model.hpp +++ b/src/amr/physical_models/physical_model.hpp @@ -1,6 +1,3 @@ - - - #ifndef PHARE_PHYSICAL_MODEL_HPP #define PHARE_PHYSICAL_MODEL_HPP @@ -8,6 +5,7 @@ #include #include "amr/messengers/messenger_info.hpp" +#include "amr/resources_manager/resources_manager.hpp" namespace PHARE { @@ -43,6 +41,9 @@ namespace solver virtual void initialize(level_t& level) = 0; + virtual amr::IResourcesManager& resources_manager() const = 0; + + /** * @brief allocate must be implemented by concrete subclasses to allocate the model * quantities onto the given patch at the given allocateTime. diff --git a/src/amr/resources_manager/field_resource.hpp b/src/amr/resources_manager/field_resource.hpp index 588cc580a..9aa1f803e 100644 --- a/src/amr/resources_manager/field_resource.hpp +++ b/src/amr/resources_manager/field_resource.hpp @@ -12,10 +12,11 @@ namespace amr * also says the type of the actual data buffer */ template - struct UserFieldType + struct FieldViewInfo { using patch_data_type = FieldData; using variable_type = FieldVariable; + using view_type = patch_data_type::view_type; }; diff --git a/src/amr/resources_manager/particle_resource.hpp b/src/amr/resources_manager/particle_resource.hpp index 9234b0a2f..e625f41d4 100644 --- a/src/amr/resources_manager/particle_resource.hpp +++ b/src/amr/resources_manager/particle_resource.hpp @@ -9,18 +9,20 @@ 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 - struct UserParticleType + template + struct ParticleViewInfo { - static constexpr auto dimension = ResourcesUser::dimension; + static constexpr auto dimension = ParticleArray::dimension; static constexpr auto interp_order = interp; - using particle_array_type = typename ResourcesUser::particle_array_type; + // TODORM this class could be templated by the ParticleArray type and rather + // hard code the link to the ParticlePack here + using particle_array_type = ParticleArray; using variable_type = ParticlesVariable; using patch_data_type = ParticlesData; + using view_type = patch_data_type::view_type; }; } // namespace amr diff --git a/src/amr/resources_manager/resources_guards.hpp b/src/amr/resources_manager/resources_guards.hpp index 937c94558..19c861dc4 100644 --- a/src/amr/resources_manager/resources_guards.hpp +++ b/src/amr/resources_manager/resources_guards.hpp @@ -15,30 +15,15 @@ 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 - class ResourcesGuard + template + 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} { @@ -46,36 +31,34 @@ namespace amr [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_; + std::tuple views_; SAMRAI::hier::Patch const& patch_; ResourcesManager const& resourcesManager_; }; diff --git a/src/amr/resources_manager/resources_manager.hpp b/src/amr/resources_manager/resources_manager.hpp index d3e5c26c9..aa24d95aa 100644 --- a/src/amr/resources_manager/resources_manager.hpp +++ b/src/amr/resources_manager/resources_manager.hpp @@ -1,12 +1,8 @@ #ifndef PHARE_AMR_TOOLS_RESOURCES_MANAGER_HPP #define PHARE_AMR_TOOLS_RESOURCES_MANAGER_HPP -#include "core/def/phare_mpi.hpp" - -#include "core/logger.hpp" #include "field_resource.hpp" -#include "core/hybrid/hybrid_quantities.hpp" #include "particle_resource.hpp" #include "resources_guards.hpp" #include "resources_manager_utilities.hpp" @@ -19,41 +15,77 @@ #include #include +#include namespace PHARE { namespace amr { - /** - * \brief ResourcesInfo contains the SAMRAI variable and patchdata ID to retrieve data from the - * SAMRAI database - */ - struct ResourcesInfo + + template + class HierarchyViews { - std::shared_ptr variable; - int id; - }; + using AnyView = std::variant; + using PatchViews = std::vector; + using LevelViews = std::vector; + + public: + void add(std::string const& name, std::size_t const levelNumber, auto viewPtr) + { + assert(exists_(name)); + if (isNewLevel_(views_[name], levelNumber)) + { + views_[name].emplace_back(PatchViews{}); + } + views_[name][levelNumber].emplace_back(*viewPtr); + } + + // \brief deletes all views for a given level + void resetLevel(std::string const& name, std::size_t const levelNumber) + { + assert(exists_(name)); + if (levelExists_(views_[name], levelNumber)) + views_[name][levelNumber].clear(); + } + + private: + bool exists_(std::string const& name) const + { + return views_.find(name) != std::end(views_); + } + + bool isNewLevel_(LevelViews const& lvlViews, std::size_t const ilvl) const + { + assert(ilvl <= lvlViews.size()); + return ilvl == views_.size(); + } + bool levelExists_(LevelViews const& lvlViews, std::size_t const ilvl) const + { + return !isNewLevel_(lvlViews, ilvl); + } + std::unordered_map views_; + }; /** \brief ResourcesManager is an adapter between PHARE objects that manipulate * data on patches, and the SAMRAI variable database system, storing the data. - * It is used by PHARE to register data to the samrai system, allocate data on patches, and to - * get access to it whenever needed, without having to know the SAMRAI database system. + * It is used by PHARE to register data to the samrai system, allocate data on patches, and + * to get access to it whenever needed, without having to know the SAMRAI database system. * * Objects registering and retrieving data through the ResourcesManager are called - * ResourcesViews. A ResourcesView needs to satisfy a specific interface to work with - * the ResourcesManager. + * Views. Views give PHARE access to data stored on patches, called Resources. * * There are only two kinds of Resources that can be registered to the SAMRAI system via the * ResourcesManager, because them only are associated with a PatchData generalization: * - * - Field - * - ParticleArray + * - Grid, allocates meshed data for the FieldData + * - ParticlePack, holds particle allocated in ParticleArrays in the ParticleData * - * Several kinds of ResourcesView can register their resources to the ResourcesManager + * A View needs to satisfy a specific interface to work with the ResourcesManager. + * Several kinds of View can register their resources to the ResourcesManager * and are identified by the following type traits: * * - has_runtime_subresourceview_list @@ -62,18 +94,18 @@ namespace amr * * for example: * - * - has_compiletime_subresourcesview_list is true because it holds 2 VecFields that - * hold Field objects. + * - has_compiletime_subresourcesview_list is true because it holds 2 VecFields + * that hold Field objects. * - * ResourcesManager is used to register ResourceUsers to the SAMRAI system, this is done - * by calling the registerResources() method. It is also used to allocate already registered - * ResourcesViews on a patch by calling the method allocate(). One can also get the identifier - * (ID) of a patchdata corresponding to one or several ResourcesViews by calling getID() or - * getIDs() methods. + * ResourcesManager is used to register Resources to the SAMRAI system, this is done + * by passing Views attached to these resources to the registerResources() method. + * It is also used to allocate already registered Resources on a patch by calling the method + * allocate(). One can also get the identifier (ID) of a patchdata corresponding to one or + * several Resources by calling getID() or getIDs() methods. * * Data objects like VecField and Ions etc., i.e. ResourcesViews, need to be set on a patch - * before being usable. Having a Patch and several ResourcesViews obj1, obj2, etc. this is done - * by calling: + * before being usable. Having a Patch and several ResourcesViews obj1, obj2, etc. this is + * done by calling: * * dataOnPatch = setOnPatch(patch, obj1, obj2); * @@ -81,20 +113,78 @@ namespace amr * * */ - template - class ResourcesManager - { - using This = ResourcesManager; + class IResourcesManager + { public: + virtual void makeLevelViews(SAMRAI::hier::PatchHierarchy const& hierarchy, + int const levelNumber) + = 0; + + virtual ~IResourcesManager() = default; + }; + + + template + struct ViewMetaWithParticles + { static constexpr std::size_t dimension = GridLayoutT::dimension; static constexpr std::size_t interp_order = GridLayoutT::interp_order; - using UserField_t = UserFieldType; + using FieldViewInfo_t = FieldViewInfo; + using ParticleViewInfo_t = ParticleViewInfo; + + using FieldView_t = typename FieldViewInfo_t::view_type; + using ParticleView_t = typename ParticleViewInfo_t::view_type; + static bool constexpr has_particles = true; + + using HierarchyViews_t = HierarchyViews; + }; + + + template + struct ViewMetaMeshOnly + { + static constexpr std::size_t dimension = GridLayoutT::dimension; + static constexpr std::size_t interp_order = GridLayoutT::interp_order; + + using FieldViewInfo_t = FieldViewInfo; + using FieldView_t = typename FieldViewInfo_t::view_type; + static bool constexpr has_particles = false; + + using HierarchyViews_t = HierarchyViews; + }; + + + template + using SuperDispatcher + = std::conditional_t, + ViewMetaMeshOnly, + ViewMetaWithParticles>; + + template + class ResourcesManager : public SuperDispatcher, + public IResourcesManager + { + using This = ResourcesManager; + + public: + using Super = SuperDispatcher; + static constexpr auto dimension = Super::dimension; + static constexpr auto interp = Super::interp_order; - template - using UserParticle_t = UserParticleType; + enum class Resource_t { Field, Particle }; + /** + * \brief ResourcesInfo contains the SAMRAI variable and patchdata ID to retrieve data + * from the SAMRAI database + */ + struct ResourcesInfo + { + std::shared_ptr variable; + int id; + Resource_t type; + }; ResourcesManager() : variableDatabase_{SAMRAI::hier::VariableDatabase::getDatabase()} @@ -110,86 +200,76 @@ namespace amr ResourcesManager& operator=(ResourcesManager&&) = delete; - /** @brief registerResources takes a ResourcesView to register its resources + /** @brief registerResources takes a View to register its resources * to the SAMRAI data system. * - * the function asks the ResourcesView informations (at least the name) of the - * buffers to register. This information is used to know which kind of + * the function asks the View informations (at least the name) of the + * resources to register. This information is used to know which kind of * SAMRAI patchdata & variable to create, but is also stored to retrieve - * this data when the ResourcesView is later going to ask for it (via the BufferGuard) - * - * The function registers all FieldData for ResourcesView that have Fields, all ParticleData - * for ResourcesView that have particle Arrays. In case the ResourcesView has sub-resources - * we ask for them in a tuple, and recursively call registerResources() for all of the - * unpacked elements + * this data when the View is later going to ask for it. */ - template - void registerResources(ResourcesView& obj) + template + void registerResources(View& view) { - if constexpr (is_resource::value) + if constexpr (is_final_view::value) { - registerResource_(obj); + registerResource_(view); } else { - static_assert(has_sub_resources_v); + static_assert(has_subview_v); - if constexpr (has_runtime_subresourceview_list::value) + if constexpr (has_runtime_views_v) { - for (auto& resourcesUser : obj.getRunTimeResourcesViewList()) + for (auto& resourcesUser : view.getRunTimeResourcesViewList()) { this->registerResources(resourcesUser); } } - if constexpr (has_compiletime_subresourcesview_list::value) + if constexpr (has_compiletime_views_v) { - // unpack the tuple subResources and apply for each element registerResources() - // (recursively) - std::apply( - [this](auto&... subResource) { - (this->registerResources(subResource), ...); - }, - obj.getCompileTimeResourcesViewList()); + // unpack the tuple subResources and apply for each element + // registerResources() (recursively) + std::apply([this](auto&... views) { (this->registerResources(views), ...); }, + view.getCompileTimeResourcesViewList()); } } } - /** @brief allocate the appropriate PatchDatas on the Patch for the ResourcesView + /** @brief allocate the appropriate PatchDatas on the Patch for the View * - * The function allocates all FieldData for ResourcesView that have Fields, all ParticleData - * for ResourcesView that have particle Arrays. In case the ResourcesView has sub-resources - * we ask for them in a tuple, and recursively call allocate() for all of the unpacked - * elements - */ - template - void allocate(ResourcesView& obj, SAMRAI::hier::Patch& patch, - double const allocateTime) const + * The function allocates all FieldData for View that have Fields, all ParticleData + * for a View that have particle packs. In case the View has subviews + * we ask for them in a tuple, and recursively call allocate() */ + template + void allocate(View& view, SAMRAI::hier::Patch& patch, double const allocateTime) const { - if constexpr (is_resource::value) + if constexpr (is_final_view_v) { - allocate_(obj, patch, allocateTime); + allocate_(view, patch, allocateTime); } else { - static_assert(has_sub_resources_v); + static_assert(has_subview_v); - if constexpr (has_runtime_subresourceview_list::value) + if constexpr (has_runtime_views_v) { - for (auto& resourcesUser : obj.getRunTimeResourcesViewList()) + for (auto& subview : view.getRunTimeResourcesViewList()) { - this->allocate(resourcesUser, patch, allocateTime); + this->allocate(subview, patch, allocateTime); } } - if constexpr (has_compiletime_subresourcesview_list::value) + if constexpr (has_compiletime_views_v) { - // unpack the tuple subResources and apply for each element registerResources() - std::apply([this, &patch, allocateTime](auto&... subResource) // - { (this->allocate(subResource, patch, allocateTime), ...); }, - obj.getCompileTimeResourcesViewList()); + // unpack the tuple subResources and apply for each element + // registerResources() + std::apply([this, &patch, allocateTime](auto&... subviews) // + { (this->allocate(subviews, patch, allocateTime), ...); }, + view.getCompileTimeResourcesViewList()); } } } @@ -197,36 +277,31 @@ namespace amr - /** \brief set all passed resources on given Patch + /** \brief attach passed view on resources on the given Patch * - * auto dataOnPatch = setOnPatch(patch, obj1, obj2, ...); + * auto onPatchGuard = setOnPatch(patch, view1, view2, ...); * - * now obj1, obj2 data containers contain data defined on the given patch. - * At the end of the scope of dataOnPatch, obj1 and obj2 will become unusable again + * now view1 and view2 and all their possible subviews are attached to the resources of + * that patch At the end of the scope of onPatchGuard, view1 and view2 will become + * unusable again */ - template - NO_DISCARD constexpr ResourcesGuard - setOnPatch(SAMRAI::hier::Patch const& patch, ResourcesViews&... resourcesUsers) + template + NO_DISCARD constexpr ViewGuard + setOnPatch(SAMRAI::hier::Patch const& patch, Views&... views) { - return ResourcesGuard{patch, *this, - resourcesUsers...}; + return ViewGuard{patch, *this, views...}; } /** @brief getTime is used to get the time of the Resources associated with the given - * ResourcesView on the given patch. + * View on the given patch. */ - template - NO_DISCARD auto getTimes(ResourcesView& obj, SAMRAI::hier::Patch const& patch) const + template + NO_DISCARD auto getTimes(View& obj, SAMRAI::hier::Patch const& patch) const { auto IDs = getIDs(obj); std::vector times; - /*std::transform(std::begin(IDs), std::end(IDs), std::back_inserter(times), - [&patch](auto const& id) { - auto patchdata = patch.getPatchData(id); - return patchdata->getTime(); - });*/ for (auto const& id : IDs) { @@ -239,10 +314,10 @@ namespace amr /** @brief setTime is used to set the time of the Resources associated with the given - * ResourcesView on the given patch. + * View on the given patch. */ - template - void setTime(ResourcesView& obj, SAMRAI::hier::Patch const& patch, double time) const + template + void setTime(View& obj, SAMRAI::hier::Patch const& patch, double time) const { for (auto const& id : getIDs(obj)) { @@ -253,11 +328,11 @@ namespace amr - /** \brief Get all the names and resources id that the resource view + /** \brief Get all the names and resources id that the view * have registered via the ResourcesManager */ - template - NO_DISCARD std::vector getIDs(ResourcesView& obj) const + template + NO_DISCARD std::vector getIDs(View& obj) const { std::vector IDs; this->getIDs_(obj, IDs); @@ -266,12 +341,12 @@ namespace amr - /** \brief Get all the names and resources id that the resource view + /** \brief Get all the names and resources id that the view * have registered via the ResourcesManager */ - NO_DISCARD std::optional getID(std::string const& resourceName) const + NO_DISCARD std::optional getID(std::string const& viewName) const { - auto id = nameToResourceInfo_.find(resourceName); + auto id = nameToResourceInfo_.find(viewName); if (id != std::end(nameToResourceInfo_)) return std::optional{id->second.id}; @@ -290,8 +365,8 @@ namespace amr } - template - void registerForRestarts(ResourcesView const& view) const + template + void registerForRestarts(View const& view) const { auto pdrm = SAMRAI::hier::PatchDataRestartManager::getManager(); @@ -299,8 +374,8 @@ namespace amr pdrm->registerPatchDataForRestart(id); } - template - NO_DISCARD auto restart_patch_data_ids(ResourcesView const& view) const + template + NO_DISCARD auto restart_patch_data_ids(View const& view) const { // true for now with https://github.com/PHAREHUB/PHARE/issues/664 constexpr bool ALL_IDS = true; @@ -319,38 +394,92 @@ namespace amr return ids; } + + + void makeAllViews(SAMRAI::hier::PatchHierarchy const& hierarchy) + { + auto const numberOfLevels = hierarchy.getNumberOfLevels(); + for (auto const& [res_name, res_info] : nameToResourceInfo_) + { + // TODO Note : this can't work if resoruce manager does not span the + // whole hierarchy... + for (auto levelNumber = 0; levelNumber < numberOfLevels; ++levelNumber) + { + makeResourceLevelViews(hierarchy, res_name, res_info, levelNumber); + } + } + } + + void makeLevelViews(SAMRAI::hier::PatchHierarchy const& hierarchy, + int const levelNumber) override + { + for (auto const& [res_name, res_info] : nameToResourceInfo_) + { + makeResourceLevelViews(hierarchy, res_name, res_info, levelNumber); + } + } + + + void makeResourceLevelViews(SAMRAI::hier::PatchHierarchy const& hierarchy, + std::string const& name, ResourcesInfo const& res_info, + int const levelNumber) + { + views_.resetLevel(name, levelNumber); + auto const patchLevel = hierarchy.getPatchLevel(levelNumber); + for (auto patch : *patchLevel) + { + auto const patchdata_id = res_info.id; + auto pdata = patch->getPatchData(patchdata_id); + // take the name and check if it is a field or a particle + // if it is a field, we can create a FieldView else a particlepack + // and set it on the patch + auto resourceType = res_info.type; + if (resourceType == Resource_t::Field) + { + auto const viewPtr + = getResourcesPtr_(res_info, *patch); + views_.add(name, levelNumber, viewPtr); + } + if constexpr (Super::has_particles) + if (resourceType == Resource_t::Particle) + { + auto const viewPtr = getResourcesPtr_( + res_info, *patch); + views_.add(name, levelNumber, viewPtr); + } + } + } + + private: - template - void getIDs_(ResourcesView& obj, std::vector& IDs) const + template + void getIDs_(View& view, std::vector& IDs) const { - if constexpr (is_resource::value) + if constexpr (is_final_view::value) { - auto foundIt = nameToResourceInfo_.find(obj.name()); + auto foundIt = nameToResourceInfo_.find(view.name()); if (foundIt == nameToResourceInfo_.end()) - throw std::runtime_error("Cannot find " + obj.name()); + throw std::runtime_error("Cannot find " + view.name()); IDs.push_back(foundIt->second.id); } else { - static_assert(has_sub_resources_v); + static_assert(has_subview_v); - if constexpr (has_runtime_subresourceview_list::value) + if constexpr (has_runtime_views_v) { - for (auto& resourcesUser : obj.getRunTimeResourcesViewList()) + for (auto& views : view.getRunTimeResourcesViewList()) { - // - this->getIDs_(resourcesUser, IDs); + this->getIDs_(views, IDs); } } - if constexpr (has_compiletime_subresourcesview_list::value) + if constexpr (has_compiletime_views_v) { - // unpack the tuple subResources and apply for each element registerResources() - std::apply( - [this, &IDs](auto&... subResource) { - (this->getIDs_(subResource, IDs), ...); - }, - obj.getCompileTimeResourcesViewList()); + // unpack the tuple subResources and apply for each element + // registerResources() + std::apply([this, &IDs](auto&... views) { (this->getIDs_(views, IDs), ...); }, + view.getCompileTimeResourcesViewList()); } } } @@ -363,83 +492,91 @@ namespace amr /** \brief Returns a pointer to the patch data instantiated in the patch * is used by getResourcesPointer_ when view code wants the pointer to the data */ - template - auto getPatchData_(ResourcesInfo const& resourcesVariableInfo, - SAMRAI::hier::Patch const& patch) const + template + auto getResourcesPtr_(ResourcesInfo const& resourcesVariableInfo, + SAMRAI::hier::Patch const& patch) const { auto patchData = patch.getPatchData(resourcesVariableInfo.variable, context_); - return (std::dynamic_pointer_cast(patchData)) + return (std::dynamic_pointer_cast(patchData)) ->getPointer(); } - /** \brief this specialization of getResourcesPointer_ is used when - * the client code wants to get a pointer to a patch data resource + /** \brief returns either the resource pointer or nullptr depending on whether + * we want to attach or detach a view from the resource */ - template - auto getResourcesPointer_(ResourcesInfo const& resourcesVariableInfo, - SAMRAI::hier::Patch const& patch) const + template + auto getResourceOrNullPtr_(ResourcesInfo const& resourcesVariableInfo, + SAMRAI::hier::Patch const& patch) const { - if constexpr (std::is_same_v) - { - return getPatchData_(resourcesVariableInfo, patch); - } + auto ptr = getResourcesPtr_(resourcesVariableInfo, patch); + auto constexpr attachToResource = std::is_same_v; + auto constexpr detachFromResource = std::is_same_v; - else if constexpr (std::is_same_v) - { - return static_cast(resourcesVariableInfo, - patch))>(nullptr); - } + if constexpr (attachToResource) + return ptr; + + else if constexpr (detachFromResource) + return static_cast(nullptr); } - template - void setResources_(ResourcesView& obj, NullOrResourcePtr nullOrResourcePtr, + template + void setResources_(View& view, NullOrResourcePtr nullOrResourcePtr, SAMRAI::hier::Patch const& patch) const { - if constexpr (is_resource::value) + if constexpr (is_final_view_v) { - setResourcesInternal_(obj, patch, nullOrResourcePtr); + setResourcesInternal_(view, patch, nullOrResourcePtr); } else { - static_assert(has_sub_resources_v); + static_assert(has_subview_v); - if constexpr (has_runtime_subresourceview_list::value) + if constexpr (has_runtime_views_v) { - for (auto& resourcesUser : obj.getRunTimeResourcesViewList()) + for (auto& subview : view.getRunTimeResourcesViewList()) { - this->setResources_(resourcesUser, nullOrResourcePtr, patch); + this->setResources_(subview, nullOrResourcePtr, patch); } } - if constexpr (has_compiletime_subresourcesview_list::value) + if constexpr (has_compiletime_views_v) { - // unpack the tuple subResources and apply for each element setResources_() std::apply( - [this, &patch, &nullOrResourcePtr](auto&... subResource) { - (this->setResources_(subResource, nullOrResourcePtr, patch), ...); + [this, &patch, &nullOrResourcePtr](auto&... subview) { + (this->setResources_(subview, nullOrResourcePtr, patch), ...); }, - obj.getCompileTimeResourcesViewList()); + view.getCompileTimeResourcesViewList()); } } } - template - void registerResource_(ResourcesView const& view) + + + template + void registerResource_(View const& view) { - using ResourcesResolver_t = ResourceResolver; + using ViewInfoResolver_t = ViewInfoResolver; if (nameToResourceInfo_.count(view.name()) == 0) { ResourcesInfo info; - info.variable = ResourcesResolver_t::make_shared_variable(view); + info.variable = ViewInfoResolver_t::make_shared_variable(view); info.id = variableDatabase_->registerVariableAndContext( - info.variable, context_, SAMRAI::hier::IntVector::getZero(dimension_)); + info.variable, context_, SAMRAI::hier::IntVector::getZero(dimension_)); + if constexpr (is_field_v) + { + info.type = Resource_t::Field; + } + else if constexpr (is_particles_v) + { + info.type = Resource_t::Particle; + } nameToResourceInfo_.emplace(view.name(), info); } } @@ -449,29 +586,27 @@ namespace amr /** \brief setResourcesInternal_ aims at setting ResourcesView pointers to the * appropriate data on the Patch or to reset them to nullptr. */ - template - void setResourcesInternal_(ResourcesView& obj, SAMRAI::hier::Patch const& patch, - RequestedPtr) const + template + void setResourcesInternal_(View& view, SAMRAI::hier::Patch const& patch, RequestedPtr) const { - using ResourceResolver_t = ResourceResolver; - using ResourcesType = typename ResourceResolver_t::type; + using ViewInfo = ViewInfoResolver::view_info_type; - auto const& resourceInfoIt = nameToResourceInfo_.find(obj.name()); + auto const& resourceInfoIt = nameToResourceInfo_.find(view.name()); if (resourceInfoIt == nameToResourceInfo_.end()) throw std::runtime_error("Resources not found !"); - obj.setBuffer( - getResourcesPointer_(resourceInfoIt->second, patch)); + view.setBuffer( + getResourceOrNullPtr_(resourceInfoIt->second, patch)); } //! \brief Allocate the data on the given level - template - void allocate_(ResourcesView const& obj, SAMRAI::hier::Patch& patch, + template + void allocate_(View const& view, SAMRAI::hier::Patch& patch, double const allocateTime) const { - std::string const& resourcesName = obj.name(); + std::string const& resourcesName = view.name(); auto const& resourceVariablesInfo = nameToResourceInfo_.find(resourcesName); if (resourceVariablesInfo != nameToResourceInfo_.end()) { @@ -489,9 +624,10 @@ namespace amr std::shared_ptr context_; SAMRAI::tbox::Dimension dimension_; std::map nameToResourceInfo_; + typename Super::HierarchyViews_t views_; - template - friend class ResourcesGuard; + template + friend class ViewGuard; }; } // namespace amr } // namespace PHARE diff --git a/src/amr/resources_manager/resources_manager_utilities.hpp b/src/amr/resources_manager/resources_manager_utilities.hpp index 02b5fca09..7bfcff38c 100644 --- a/src/amr/resources_manager/resources_manager_utilities.hpp +++ b/src/amr/resources_manager/resources_manager_utilities.hpp @@ -17,128 +17,125 @@ namespace PHARE namespace amr { - /** \brief is_field is a traits that permit to check if a ResourceView + /** \brief is_field is a traits that permit to check if a View * is a field */ - template + template struct is_field : std::false_type { }; - template - struct is_field().physicalQuantity())>> + template + struct is_field().physicalQuantity())>> : std::true_type { }; - template - bool constexpr static is_field_v = is_field::value; + template + bool constexpr static is_field_v = is_field::value; - /** \brief is_particles is a traits that permit to check if a ResourceView + /** \brief is_particles is a traits that permit to check if a View * has particles */ - template + template struct is_particles : std::false_type { }; - template + template struct is_particles< - ResourceView, - core::tryToInstanciate().setBuffer( - static_cast*>( - nullptr)))>> : std::true_type + View, core::tryToInstanciate().setBuffer( + static_cast*>(nullptr)))>> + : std::true_type { }; - template - bool constexpr static is_particles_v = is_particles::value; + template + bool constexpr static is_particles_v = is_particles::value; - template - struct is_resource + template + struct is_final_view { - bool constexpr static value = is_field_v or is_particles_v; + bool constexpr static value = is_field_v or is_particles_v; }; - template - bool constexpr static is_resource_v = is_resource::value; + template + bool constexpr static is_final_view_v = is_final_view::value; + - template - class ResourceResolver + template + class ViewInfoResolver { auto constexpr static resolve_t() { - if constexpr (is_field_v) - return typename ResourceManager::UserField_t{}; - else if constexpr (is_particles_v) - return typename ResourceManager::template UserParticle_t{}; + if constexpr (is_field_v) + return typename ResourceManager::Super::FieldViewInfo_t{}; + + else if constexpr (is_particles_v) + return typename ResourceManager::Super::ParticleViewInfo_t{}; + else throw std::runtime_error("bad condition"); } public: - using type = std::decay_t; + using view_info_type = std::decay_t; - auto static make_shared_variable(ResourceView const& view) + auto static make_shared_variable(View const& view) { - if constexpr (is_field_v) - return std::make_shared(view.name(), - view.physicalQuantity()); + if constexpr (is_field_v) + return std::make_shared( + view.name(), view.physicalQuantity()); else - return std::make_shared(view.name()); + return std::make_shared(view.name()); } }; /** @brief has_runtime_subresourceview_list is a compile-time function that returns true if the - * given ResourceView has a runtime list of ResourceViews, like a vector of ResourceViews. + * given View has a runtime list of Views, like a vector of Views. */ - template - struct has_runtime_subresourceview_list : std::false_type + template + struct has_runtime_views : std::false_type { }; - template - struct has_runtime_subresourceview_list< - ResourceView, core::tryToInstanciate< - decltype(std::declval().getRunTimeResourcesViewList())>> + template + struct has_runtime_views< + View, core::tryToInstanciate().getRunTimeResourcesViewList())>> : std::true_type { }; - template - bool constexpr static has_runtime_subresourceview_list_v - = has_runtime_subresourceview_list::value; + template + bool constexpr static has_runtime_views_v = has_runtime_views::value; /** @brief has_compiletime_subresourcesview_list is a compile-time function that returns true if - * the given ResourceView has one or several ResourceViews that can be put in a compile-time + * the given View has one or several Views that can be put in a compile-time * list. */ - template - struct has_compiletime_subresourcesview_list : std::false_type + template + struct has_compiletime_views : std::false_type { }; - template - struct has_compiletime_subresourcesview_list< - ResourceView, core::tryToInstanciate< - decltype(std::declval().getCompileTimeResourcesViewList())>> + template + struct has_compiletime_views< + View, + core::tryToInstanciate().getCompileTimeResourcesViewList())>> : std::true_type { }; - template - bool constexpr static has_compiletime_subresourcesview_list_v - = has_compiletime_subresourcesview_list::value; + template + bool constexpr static has_compiletime_views_v = has_compiletime_views::value; - template - struct has_sub_resources + template + struct has_subview { - bool constexpr static value - = has_compiletime_subresourcesview_list_v or has_runtime_subresourceview_list_v; + bool constexpr static value = has_compiletime_views_v or has_runtime_views_v; }; - template - bool constexpr static has_sub_resources_v = has_sub_resources::value; + template + bool constexpr static has_subview_v = has_subview::value; /** UseResourcePtr is used to select the resources patch data */ struct UseResourcePtr @@ -153,36 +150,36 @@ namespace amr - /** extractNames of direct Field and Particle Resources of the given ResourceView + /** extractNames of direct Field and Particle Resources of the given View * Is called by the other overload of extractNames() */ - template - void extractNames(ResourceView& view, std::vector& names) + template + void extractNames(View& view, std::vector& names) { - if constexpr (is_resource_v) + if constexpr (is_final_view_v) names.push_back(view.name()); } /** @brief extractNames returns a vector of strings containing the names of all resources - * associated with a ResourceView + * associated with a View */ - template - std::vector extractNames(ResourceView& view) + template + std::vector extractNames(View& view) { std::vector names; - if constexpr (has_compiletime_subresourcesview_list::value) + if constexpr (has_compiletime_views_v) { // unpack the tuple subResources and apply for each element registerResources() - std::apply([&names](auto&... subResource) { (extractNames(subResource, names), ...); }, - view.getCompileTimeResourceViewList()); + std::apply([&names](auto&... views) { (extractNames(views, names), ...); }, + view.getCompileTimeViewList()); } - if constexpr (has_runtime_subresourceview_list::value) + if constexpr (has_runtime_views_v) { - for (auto& resourcesUser : view.getRunTimeResourceViewList()) - extractNames(resourcesUser, names); + for (auto& rt_view : view.getRunTimeViewList()) + extractNames(rt_view, names); } extractNames(view, names); diff --git a/tests/amr/messengers/test_messengers.cpp b/tests/amr/messengers/test_messengers.cpp index d9ba9eefd..37869de4b 100644 --- a/tests/amr/messengers/test_messengers.cpp +++ b/tests/amr/messengers/test_messengers.cpp @@ -1,5 +1,3 @@ - - #include "src/simulator/simulator.hpp" #include "src/simulator/phare_types.hpp" #include "src/phare/phare.hpp" @@ -202,11 +200,12 @@ static constexpr std::size_t dim = 1; static constexpr std::size_t interpOrder = 1; static constexpr std::size_t nbRefinePart = 2; -using Simulator = PHARE::Simulator; -using HybridModelT = Simulator::HybridModel; -using MHDModelT = Simulator::MHDModel; -using ResourcesManagerT = typename HybridModelT::resources_manager_type; -using Phare_Types = PHARE::PHARE_Types; +using Simulator = PHARE::Simulator; +using HybridModelT = Simulator::HybridModel; +using MHDModelT = Simulator::MHDModel; +using ResourcesManagerHybrid = typename HybridModelT::resources_manager_type; +using ResourcesManagerMHD = typename MHDModelT::resources_manager_type; +using Phare_Types = PHARE::PHARE_Types; @@ -254,8 +253,8 @@ class HybridMessengers : public ::testing::Test HybridMessengers() { - auto resourcesManagerHybrid = std::make_shared(); - auto resourcesManagerMHD = std::make_shared(); + auto resourcesManagerHybrid = std::make_shared(); + auto resourcesManagerMHD = std::make_shared(); auto hybridModel = std::make_unique(createDict(), resourcesManagerHybrid); auto mhdModel = std::make_unique(resourcesManagerMHD); @@ -447,11 +446,12 @@ struct AfullHybridBasicHierarchy { static constexpr std::size_t interpOrder = 1; - using Simulator = typename PHARE::Simulator; - using HybridModelT = typename Simulator::HybridModel; - using MHDModelT = typename Simulator::MHDModel; - using ResourcesManagerT = typename HybridModelT::resources_manager_type; - using Phare_Types = PHARE::PHARE_Types; + using Simulator = typename PHARE::Simulator; + using HybridModelT = typename Simulator::HybridModel; + using MHDModelT = typename Simulator::MHDModel; + using ResourcesManagerHybrid = typename HybridModelT::resources_manager_type; + using ResourcesManagerMHD = typename MHDModelT::resources_manager_type; + using Phare_Types = PHARE::PHARE_Types; int const firstHybLevel{0}; int const ratio{2}; @@ -463,8 +463,8 @@ struct AfullHybridBasicHierarchy PHARE::initializer::PHAREDict dict{createDict()}; - std::shared_ptr resourcesManagerHybrid{ - std::make_shared()}; + std::shared_ptr resourcesManagerHybrid{ + std::make_shared()}; std::shared_ptr hybridModel{ std::make_shared(dict, resourcesManagerHybrid)}; diff --git a/tests/amr/models/test_models.cpp b/tests/amr/models/test_models.cpp index 7c902de4e..0de42c10a 100644 --- a/tests/amr/models/test_models.cpp +++ b/tests/amr/models/test_models.cpp @@ -50,7 +50,7 @@ using Electrons1D = Electrons; using HybridModelT = HybridModel; using MHDModelT = MHDModel; -using ResourcesManagerT = ResourcesManager; +using ResourcesManagerT = ResourcesManager; using InitFunctionT = PHARE::initializer::InitFunction<1>; diff --git a/tests/amr/resources_manager/test_resources_manager.cpp b/tests/amr/resources_manager/test_resources_manager.cpp index 8ac7ff0d4..7a9f037bb 100644 --- a/tests/amr/resources_manager/test_resources_manager.cpp +++ b/tests/amr/resources_manager/test_resources_manager.cpp @@ -129,7 +129,7 @@ static auto init_dict = createInitDict(); struct IonPopulation1D_P { - IonPopulation1D user{init_dict["ions"]["pop0"]}; + IonPopulation1D view{init_dict["ions"]["pop0"]}; }; @@ -137,7 +137,7 @@ struct VecField1D_P { std::string name = "B"; HybridQuantity::Vector qty{HybridQuantity::Vector::B}; - VecField1D user{name, qty}; + VecField1D view{name, qty}; }; @@ -145,7 +145,7 @@ struct VecField1D_P struct Ions1D_P { - Ions1D user{init_dict["ions"]}; + Ions1D view{init_dict["ions"]}; }; @@ -154,9 +154,9 @@ struct Ions1D_P struct Electromag1D_P { std::string name = "ElectroTest"; - Electromag1D user; + Electromag1D view; Electromag1D_P() - : user{init_dict["electromag"]} + : view{init_dict["electromag"]} { } }; @@ -165,7 +165,7 @@ struct Electromag1D_P struct HybridState1D_P { - HybridState1D user{init_dict}; + HybridState1D view{init_dict}; }; @@ -178,34 +178,32 @@ using VecField1DAndIonPop1D = std::tuple; using Electromag1DOnly = std::tuple; using HybridState1DOnly = std::tuple; -TYPED_TEST_SUITE_P(aResourceUserCollection); +TYPED_TEST_SUITE_P(ViewCollection); -TYPED_TEST_P(aResourceUserCollection, hasPointersValidOnlyWithGuard) +TYPED_TEST_P(ViewCollection, hasPointersValidOnlyWithGuard) { - TypeParam resourceUserCollection; - - auto check = [this](auto& resourceUserPack) { - auto& hierarchy_ = this->hierarchy->hierarchy; - auto& resourceUser = resourceUserPack.user; + TypeParam views; + auto check = [this](auto& view) { + auto& hierarchy_ = this->hierarchy->hierarchy; for (int iLevel = 0; iLevel < hierarchy_->getNumberOfLevels(); ++iLevel) { auto patchLevel = hierarchy_->getPatchLevel(iLevel); for (auto const& patch : *patchLevel) { - auto dataOnPatch = this->resourcesManager.setOnPatch(*patch, resourceUser); - EXPECT_TRUE(resourceUser.isUsable()); - EXPECT_FALSE(resourceUser.isSettable()); + auto dataOnPatch = this->resourcesManager.setOnPatch(*patch, view.view); + EXPECT_TRUE(view.view.isUsable()); + EXPECT_FALSE(view.view.isSettable()); } - EXPECT_FALSE(resourceUser.isUsable()); - EXPECT_TRUE(resourceUser.isSettable()); + EXPECT_FALSE(view.view.isUsable()); + EXPECT_TRUE(view.view.isSettable()); } }; - std::apply(check, resourceUserCollection); + std::apply(check, views); } @@ -214,14 +212,14 @@ TYPED_TEST_P(aResourceUserCollection, hasPointersValidOnlyWithGuard) TEST(usingResourcesManager, toGetTimeOfAResourcesUser) { std::unique_ptr hierarchy; - ResourcesManager>, Grid1D> resourcesManager; + ResourcesManager> resourcesManager; IonPopulation1D_P pop; static_assert(is_particles_v>>); auto s = inputBase + std::string("/input/input_db_1d"); hierarchy = std::make_unique(inputBase + std::string("/input/input_db_1d")); hierarchy->init(); - resourcesManager.registerResources(pop.user); + resourcesManager.registerResources(pop.view); auto& patchHierarchy = hierarchy->hierarchy; double const initDataTime{3.14}; @@ -231,8 +229,8 @@ TEST(usingResourcesManager, toGetTimeOfAResourcesUser) auto patchLevel = patchHierarchy->getPatchLevel(iLevel); for (auto& patch : *patchLevel) { - resourcesManager.allocate(pop.user, *patch, initDataTime); - auto times = resourcesManager.getTimes(pop.user, *patch); + resourcesManager.allocate(pop.view, *patch, initDataTime); + auto times = resourcesManager.getTimes(pop.view, *patch); EXPECT_TRUE(std::equal(std::begin(times) + 1, std::end(times), std::begin(times))); EXPECT_DOUBLE_EQ(initDataTime, times[0]); @@ -243,13 +241,13 @@ TEST(usingResourcesManager, toGetTimeOfAResourcesUser) -REGISTER_TYPED_TEST_SUITE_P(aResourceUserCollection, hasPointersValidOnlyWithGuard); +REGISTER_TYPED_TEST_SUITE_P(ViewCollection, hasPointersValidOnlyWithGuard); typedef ::testing::Types MyTypes; -INSTANTIATE_TYPED_TEST_SUITE_P(testResourcesManager, aResourceUserCollection, MyTypes); +INSTANTIATE_TYPED_TEST_SUITE_P(testResourcesManager, ViewCollection, MyTypes); diff --git a/tests/amr/resources_manager/test_resources_manager.hpp b/tests/amr/resources_manager/test_resources_manager.hpp index c741113e5..71c47cc53 100644 --- a/tests/amr/resources_manager/test_resources_manager.hpp +++ b/tests/amr/resources_manager/test_resources_manager.hpp @@ -25,15 +25,16 @@ using namespace PHARE::amr; -template -class aResourceUserCollection : public ::testing::Test +template +class ViewCollection : public ::testing::Test { public: using Grid_t = Grid, HybridQuantity::Scalar>; std::unique_ptr hierarchy; - ResourcesManager>, Grid_t> resourcesManager; + using Layout = GridLayout>; + ResourcesManager> resourcesManager; - ResourcesUsers users; + View views; void SetUp() { @@ -41,10 +42,10 @@ class aResourceUserCollection : public ::testing::Test hierarchy = std::make_unique(inputBase + std::string("/input/input_db_1d")); hierarchy->init(); - auto registerAndAllocate = [this](auto& resourcesUser) { + auto registerAndAllocate = [this](auto& view) { auto& patchHierarchy = hierarchy->hierarchy; - resourcesManager.registerResources(resourcesUser.user); + resourcesManager.registerResources(view.view); double const initDataTime{0.0}; @@ -53,12 +54,12 @@ class aResourceUserCollection : public ::testing::Test auto patchLevel = patchHierarchy->getPatchLevel(iLevel); for (auto& patch : *patchLevel) { - resourcesManager.allocate(resourcesUser.user, *patch, initDataTime); + resourcesManager.allocate(view.view, *patch, initDataTime); } } }; // end lambda - std::apply(registerAndAllocate, users); + std::apply(registerAndAllocate, views); } };