6#ifndef IPPL_FEMVECTOR_H
7#define IPPL_FEMVECTOR_H
32 sizeof(typename detail::ViewType<T, 1>::view_type)>{
43 static constexpr unsigned dim = 1;
68 FEMVector(
size_t n, std::vector<size_t> neighbors,
69 std::vector< Kokkos::View<size_t*> > sendIdxs,
70 std::vector< Kokkos::View<size_t*> > recvIdxs);
146 template <
typename E,
size_t N>
170 KOKKOS_INLINE_FUNCTION
T operator[] (
size_t i)
const;
181 KOKKOS_INLINE_FUNCTION
T operator() (
size_t i)
const;
191 const Kokkos::View<T*>&
getView()
const;
225 template <
typename K>
239 void pack(
const Kokkos::View<size_t*>& idxStore);
256 template <
typename Op>
257 void unpack(
const Kokkos::View<size_t*>& idxStore);
307 std::vector< Kokkos::View<size_t*> > sendIdxs,
308 std::vector< Kokkos::View<size_t*> >
recvIdxs_m);
404 template <
typename T>
411 size_t n = aView.extent(0);
412 Kokkos::parallel_reduce(
"FEMVector innerProduct", n,
413 KOKKOS_LAMBDA(
const size_t i,
T& val){
414 val += aView(i)*bView(i);
416 Kokkos::Sum<T>(localSum)
420 ippl::Comm->allreduce(localSum, globalSum, 1, std::plus<T>());
424 template <
typename T>
429 size_t n = view.extent(0);
432 Kokkos::parallel_reduce(
"FEMVector l0 norm", n,
433 KOKKOS_LAMBDA(
const size_t i,
T& val) {
434 val = Kokkos::max(val, Kokkos::abs(view(i)));
436 Kokkos::Max<T>(local)
439 ippl::Comm->allreduce(local, globalMax, 1, std::greater<T>());
443 Kokkos::parallel_reduce(
"FEMVector lp norm", n,
444 KOKKOS_LAMBDA(
const size_t i,
T& val) {
445 val += std::pow(Kokkos::abs(view(i)), p);
447 Kokkos::Sum<T>(local)
450 ippl::Comm->allreduce(local, globalSum, 1, std::plus<T>());
451 return std::pow(globalSum, 1.0 / p);
T innerProduct(const FEMVector< T > &a, const FEMVector< T > &b)
Calculate the inner product between two ippl::FEMVector(s).
std::unique_ptr< mpi::Communicator > Comm
T norm(const FEMVector< T > &v, int p=2)
1D vector used in the context of FEM.
void unpack(const Kokkos::View< size_t * > &idxStore)
Unpack data from BoundaryInfo::commBuffer_m into FEMVector::data_m after communication.
std::shared_ptr< BoundaryInfo > boundaryInfo_m
Struct holding all the MPI and boundary information.
T value_type
Dummy type definition in order for the detail::Expression defined operators to work.
static constexpr unsigned dim
Dummy parameter in order for the detail::Expression defined operators to work.
void fillHalo()
Copy values from neighboring ranks into local halo.
FEMVector< K > skeletonCopy() const
Create a new FEMVector with different data type, but same size and boundary infromation.
FEMVector< T > & operator=(T value)
Set all the values of the vector to value.
const Kokkos::View< T * > & getView() const
Get underlying data view.
KOKKOS_INLINE_FUNCTION T operator()(size_t i) const
Subscript operator to get value at position i.
Kokkos::View< T * > data_m
Data this object is storing.
void pack(const Kokkos::View< size_t * > &idxStore)
Pack data into BoundaryInfo::commBuffer_m for MPI communication.
void accumulateHalo()
Accumulate halo values in neighbor.
size_t size() const
Get the size (number of elements) of the vector.
KOKKOS_INLINE_FUNCTION T operator[](size_t i) const
Subscript operator to get value at position i.
FEMVector(size_t n, std::vector< size_t > neighbors, std::vector< Kokkos::View< size_t * > > sendIdxs, std::vector< Kokkos::View< size_t * > > recvIdxs)
Constructor taking size, neighbors, and halo exchange indices.
FEMVector< T > deepCopy() const
Create a deep copy, where all the information of this vector is copied to a new one.
void setHalo(T setValue)
Set the halo cells to setValue.
Struct for assigment operator to be used with FEMVector::unpack().
KOKKOS_INLINE_FUNCTION void operator()(T &lhs, const T &rhs) const
Struct for addition+assignment operator to be used with FEMVector::unpack().
KOKKOS_INLINE_FUNCTION void operator()(T &lhs, const T &rhs) const
std::vector< Kokkos::View< size_t * > > recvIdxs_m
Stores indices of FEMVector::data_m which are part of the halo.
std::vector< size_t > neighbors_m
Stores the ranks of the neighboring MPI tasks.
BoundaryInfo(std::vector< size_t > neighbors, std::vector< Kokkos::View< size_t * > > sendIdxs, std::vector< Kokkos::View< size_t * > > recvIdxs_m)
constructor for a BoundaryInfo object.
std::vector< Kokkos::View< size_t * > > sendIdxs_m
Stores indices of FEMVector::data_m which need to be send to the MPI neighbors.
detail::FieldBufferData< T > commBuffer_m
Buffer for MPI communication.