diff --git a/CMakeLists.txt b/CMakeLists.txt index 19d583b30..1878f126a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,8 @@ include(ProjectSetup) # ------------------------------------------------------------------------------ # Primary IPPL options # ------------------------------------------------------------------------------ -set(IPPL_PLATFORMS "OPENMP;CUDA" CACHE STRING "Platforms to build IPPL for") +# set(IPPL_PLATFORMS "OPENMP;CUDA" CACHE STRING "Platforms to build IPPL for") +set(IPPL_PLATFORMS "SERIAL" CACHE STRING "Platforms to build IPPL for") option(BUILD_SHARED_LIBS "Build IPPL as a shared library" OFF) option(IPPL_ENABLE_UNIT_TESTS "Enable unit tests using GoogleTest" OFF) option(IPPL_ENABLE_FFT "Enable FFT support" OFF) diff --git a/alpine/ParticleContainer.hpp b/alpine/ParticleContainer.hpp index 673a43d74..39a1d68c7 100644 --- a/alpine/ParticleContainer.hpp +++ b/alpine/ParticleContainer.hpp @@ -10,16 +10,21 @@ template class ParticleContainer : public ippl::ParticleBase> { using Base = ippl::ParticleBase>; +private: + PLayout_t pl_m; public: ippl::ParticleAttrib q; // charge typename Base::particle_position_type P; // particle velocity typename Base::particle_position_type E; // electric field at particle position -private: - PLayout_t pl_m; public: ParticleContainer(Mesh_t& mesh, FieldLayout_t& FL) - : pl_m(FL, mesh) { + : + pl_m(FL, mesh) + , q("charge") + , P("velocity") + , E("electric_field") + { this->initialize(pl_m); registerAttributes(); setupBCs(); @@ -31,10 +36,6 @@ class ParticleContainer : public ippl::ParticleBase>& pl) { pl_m = pl; } void registerAttributes() { - //only needed for vis - P.set_name("velocity"); - q.set_name("charge"); - E.set_name("electric_field"); // register the particle attributes this->addAttribute(q); this->addAttribute(P); diff --git a/src/Field/BareField.h b/src/Field/BareField.h index 06c80aef5..3904fbaef 100644 --- a/src/Field/BareField.h +++ b/src/Field/BareField.h @@ -64,7 +64,7 @@ namespace ippl { * checks in the rest of the BareField methods to check that the field has * been properly initialized. */ - BareField(); + BareField(const std::string& name_="UNNAMED_BareField"); BareField(const BareField&) = default; @@ -72,7 +72,7 @@ namespace ippl { * @param l of field * @param nghost number of ghost layers */ - BareField(Layout_t& l, int nghost = 1); + BareField(Layout_t& l, int nghost = 1, const std::string& name_="UNNAMED_BareField"); /*! * Creates a new BareField with the same properties and contents @@ -172,6 +172,8 @@ namespace ippl { HostMirror getHostMirror() const { return Kokkos::create_mirror(dview_m); } + const std::string get_name() const{ return dview_m.label(); } + /*! * Generate the range policy for iterating over the field, * excluding ghost layers diff --git a/src/Field/BareField.hpp b/src/Field/BareField.hpp index 9328cd223..e3d0e93a6 100644 --- a/src/Field/BareField.hpp +++ b/src/Field/BareField.hpp @@ -83,13 +83,25 @@ namespace ippl { namespace detail { template struct isExpression> : std::true_type {}; + + template + view_T make_zero_extent_view(const std::string& name, std::index_sequence) { + // Expands to dview_m(name, 0, 0, ..., 0) with Dim zeros + return view_T(name, ((void)I, 0)...); + } + } // namespace detail template - BareField::BareField() + BareField::BareField(const std::string& name_) : nghost_m(1) + , dview_m([&]{return detail::make_zero_extent_view(name_, std::make_index_sequence{});}()) , layout_m(nullptr) {} + + + + template BareField BareField::deepCopy() const { BareField copy(*layout_m, nghost_m); @@ -98,8 +110,9 @@ namespace ippl { } template - BareField::BareField(Layout_t& l, int nghost) + BareField::BareField(Layout_t& l, int nghost, const std::string& name_) : nghost_m(nghost) + , dview_m([&]{return detail::make_zero_extent_view(name_, std::make_index_sequence{});}()) // , owned_m(0) , layout_m(&l) { setup(); diff --git a/src/Field/Field.h b/src/Field/Field.h index eda5713b9..0fcbd3905 100644 --- a/src/Field/Field.h +++ b/src/Field/Field.h @@ -34,7 +34,7 @@ namespace ippl { // 'initialize' function before doing anything else. There are no special // checks in the rest of the Field methods to check that the Field has // been properly initialized. - Field(); + Field(const std::string& name_="UNNAMED_Field"); Field(const Field&) = default; @@ -47,7 +47,7 @@ namespace ippl { virtual ~Field() = default; // Constructors including a Mesh object as argument: - Field(Mesh_t&, Layout_t&, int nghost = 1); + Field(Mesh_t&, Layout_t&, int nghost = 1, const std::string& name_="UNNAMED_Field"); // Initialize the Field, also specifying a mesh void initialize(Mesh_t&, Layout_t&, int nghost = 1); diff --git a/src/Field/Field.hpp b/src/Field/Field.hpp index fbf443572..974f8d709 100644 --- a/src/Field/Field.hpp +++ b/src/Field/Field.hpp @@ -16,8 +16,8 @@ namespace ippl { // checks in the rest of the Field methods to check that the Field has // been properly initialized template - Field::Field() - : BareField_t() + Field::Field(const std::string& name_) + : BareField_t(name_) , mesh_m(nullptr) , bc_m() {} @@ -34,8 +34,8 @@ namespace ippl { ////////////////////////////////////////////////////////////////////////// // Constructors which include a Mesh object as argument template - Field::Field(Mesh_t& m, Layout_t& l, int nghost) - : BareField_t(l, nghost) + Field::Field(Mesh_t& m, Layout_t& l, int nghost, const std::string& name_) + : BareField_t(l, nghost, name_) , mesh_m(&m) { for (unsigned int face = 0; face < 2 * Dim; ++face) { bc_m[face] = diff --git a/src/Particle/ParticleAttrib.h b/src/Particle/ParticleAttrib.h index e694585f8..cc25ca80d 100644 --- a/src/Particle/ParticleAttrib.h +++ b/src/Particle/ParticleAttrib.h @@ -46,6 +46,8 @@ namespace ippl { using size_type = detail::size_type; + ParticleAttrib(const std::string& name_ = "UNNAMED_ParticleAttrib") : dview_m(name_){} + // Create storage for M particle attributes. The storage is uninitialized. // New items are appended to the end of the array. void create(size_type) override; @@ -100,9 +102,7 @@ namespace ippl { HostMirror getHostMirror() const { return Kokkos::create_mirror(dview_m); } - void set_name(const std::string & name_) override { this->name_m = name_; } - - std::string get_name() const override { return this->name_m; } + const std::string get_name() const override { return dview_m.label(); } /*! * Assign the same value to the whole attribute. diff --git a/src/Particle/ParticleAttribBase.h b/src/Particle/ParticleAttribBase.h index 0b02a9739..c8c877a26 100644 --- a/src/Particle/ParticleAttribBase.h +++ b/src/Particle/ParticleAttribBase.h @@ -36,12 +36,8 @@ namespace ippl { template using with_properties = typename WithMemSpace::type; - - ParticleAttribBase(){this->name_m = "UNNAMED_attribute";} - - virtual void set_name(const std::string & name_) = 0; - virtual std::string get_name() const = 0; + virtual const std::string get_name() const = 0; virtual void create(size_type) = 0; @@ -68,7 +64,6 @@ namespace ippl { protected: const size_type* localNum_mp; - std::string name_m; }; } // namespace detail } // namespace ippl diff --git a/src/Particle/ParticleBase.hpp b/src/Particle/ParticleBase.hpp index 37dadcf5c..c6f6961cc 100644 --- a/src/Particle/ParticleBase.hpp +++ b/src/Particle/ParticleBase.hpp @@ -52,8 +52,10 @@ namespace ippl { template - ParticleBase::ParticleBase() - : layout_m(nullptr) + ParticleBase::ParticleBase() : + R("position") + , ID("ID") + , layout_m(nullptr) , localNum_m(0) , totalNum_m(0) , nextID_m(Comm->rank()) @@ -62,8 +64,6 @@ namespace ippl { addAttribute(ID); } addAttribute(R); - ID.set_name("ID"); - R.set_name("position"); } template