Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions alpine/ParticleContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ template <typename T, unsigned Dim = 3>
class ParticleContainer : public ippl::ParticleBase<ippl::ParticleSpatialLayout<T, Dim>> {
using Base = ippl::ParticleBase<ippl::ParticleSpatialLayout<T, Dim>>;

private:
PLayout_t<T, Dim> pl_m;
public:
ippl::ParticleAttrib<double> q; // charge
typename Base::particle_position_type P; // particle velocity
typename Base::particle_position_type E; // electric field at particle position
private:
PLayout_t<T, Dim> pl_m;

public:
ParticleContainer(Mesh_t<Dim>& mesh, FieldLayout_t<Dim>& FL)
: pl_m(FL, mesh) {
:
pl_m(FL, mesh)
, q("charge")
, P("velocity")
, E("electric_field")
{
this->initialize(pl_m);
registerAttributes();
setupBCs();
Expand All @@ -31,10 +36,6 @@ class ParticleContainer : public ippl::ParticleBase<ippl::ParticleSpatialLayout<
void setPL(std::shared_ptr<PLayout_t<T, Dim>>& 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);
Expand Down
6 changes: 4 additions & 2 deletions src/Field/BareField.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ 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;

/*! Constructor for a BareField. The default constructor is deleted.
* @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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions src/Field/BareField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,25 @@ namespace ippl {
namespace detail {
template <typename T, unsigned Dim, class... ViewArgs>
struct isExpression<BareField<T, Dim, ViewArgs...>> : std::true_type {};

template <typename view_T, size_t... I>
view_T make_zero_extent_view(const std::string& name, std::index_sequence<I...>) {
// Expands to dview_m(name, 0, 0, ..., 0) with Dim zeros
return view_T(name, ((void)I, 0)...);
}

} // namespace detail

template <typename T, unsigned Dim, class... ViewArgs>
BareField<T, Dim, ViewArgs...>::BareField()
BareField<T, Dim, ViewArgs...>::BareField(const std::string& name_)
: nghost_m(1)
, dview_m([&]{return detail::make_zero_extent_view(name_, std::make_index_sequence<Dim>{});}())
, layout_m(nullptr) {}





template <typename T, unsigned Dim, class... ViewArgs>
BareField<T, Dim, ViewArgs...> BareField<T, Dim, ViewArgs...>::deepCopy() const {
BareField<T, Dim, ViewArgs...> copy(*layout_m, nghost_m);
Expand All @@ -98,8 +110,9 @@ namespace ippl {
}

template <typename T, unsigned Dim, class... ViewArgs>
BareField<T, Dim, ViewArgs...>::BareField(Layout_t& l, int nghost)
BareField<T, Dim, ViewArgs...>::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<Dim>{});}())
// , owned_m(0)
, layout_m(&l) {
setup();
Expand Down
4 changes: 2 additions & 2 deletions src/Field/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/Field/Field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace ippl {
// checks in the rest of the Field methods to check that the Field has
// been properly initialized
template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
Field<T, Dim, Mesh, Centering, ViewArgs...>::Field()
: BareField_t()
Field<T, Dim, Mesh, Centering, ViewArgs...>::Field(const std::string& name_)
: BareField_t(name_)
, mesh_m(nullptr)
, bc_m() {}

Expand All @@ -34,8 +34,8 @@ namespace ippl {
//////////////////////////////////////////////////////////////////////////
// Constructors which include a Mesh object as argument
template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
Field<T, Dim, Mesh, Centering, ViewArgs...>::Field(Mesh_t& m, Layout_t& l, int nghost)
: BareField_t(l, nghost)
Field<T, Dim, Mesh, Centering, ViewArgs...>::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] =
Expand Down
6 changes: 3 additions & 3 deletions src/Particle/ParticleAttrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions src/Particle/ParticleAttribBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ namespace ippl {

template <typename... Properties>
using with_properties = typename WithMemSpace<Properties...>::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;

Expand All @@ -68,7 +64,6 @@ namespace ippl {

protected:
const size_type* localNum_mp;
std::string name_m;
};
} // namespace detail
} // namespace ippl
Expand Down
8 changes: 4 additions & 4 deletions src/Particle/ParticleBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
namespace ippl {

template <class PLayout, typename... IP>
ParticleBase<PLayout, IP...>::ParticleBase()
: layout_m(nullptr)
ParticleBase<PLayout, IP...>::ParticleBase() :
R("position")
, ID("ID")
, layout_m(nullptr)
, localNum_m(0)
, totalNum_m(0)
, nextID_m(Comm->rank())
Expand All @@ -62,8 +64,6 @@ namespace ippl {
addAttribute(ID);
}
addAttribute(R);
ID.set_name("ID");
R.set_name("position");
}

template <class PLayout, typename... IP>
Expand Down