6#ifndef IPPL_FEMVECTOR_H
7#define IPPL_FEMVECTOR_H
9#include <Kokkos_MathematicalFunctions.hpp>
34 sizeof(typename detail::ViewType<T, 1>::view_type)>{
45 static constexpr unsigned dim = 1;
70 FEMVector(
size_t n, std::vector<size_t> neighbors,
71 std::vector< Kokkos::View<size_t*> > sendIdxs,
72 std::vector< Kokkos::View<size_t*> > recvIdxs);
148 template <
typename E,
size_t N>
172 KOKKOS_INLINE_FUNCTION T
operator[] (
size_t i)
const;
183 KOKKOS_INLINE_FUNCTION T
operator() (
size_t i)
const;
193 const Kokkos::View<T*>&
getView()
const;
227 template <
typename K>
241 void pack(
const Kokkos::View<size_t*>& idxStore);
258 template <
typename Op>
259 void unpack(
const Kokkos::View<size_t*>& idxStore);
267 KOKKOS_INLINE_FUNCTION
void operator()(T& lhs,
const T& rhs)
const {
278 KOKKOS_INLINE_FUNCTION
void operator()(T& lhs,
const T& rhs)
const {
295 struct BoundaryInfo {
308 BoundaryInfo (std::vector<size_t> neighbors,
309 std::vector< Kokkos::View<size_t*> > sendIdxs,
310 std::vector< Kokkos::View<size_t*> > recvIdxs_m);
322 std::vector<size_t> neighbors_m;
337 std::vector< Kokkos::View<size_t*> > sendIdxs_m;
354 std::vector< Kokkos::View<size_t*> > recvIdxs_m;
375 Kokkos::View<T*> data_m;
387 std::shared_ptr<BoundaryInfo> boundaryInfo_m;
406 template <
typename T>
413 size_t n = aView.extent(0);
414 Kokkos::parallel_reduce(
"FEMVector innerProduct", n,
415 KOKKOS_LAMBDA(
const size_t i, T& val){
416 val += aView(i)*bView(i);
418 Kokkos::Sum<T>(localSum)
422 ippl::Comm->allreduce(localSum, globalSum, 1, std::plus<T>());
426 template <
typename T>
427 T norm(
const FEMVector<T>& v,
int p = 2) {
430 auto view = v.getView();
431 size_t n = view.extent(0);
434 Kokkos::parallel_reduce(
"FEMVector l0 norm", n,
435 KOKKOS_LAMBDA(
const size_t i, T& val) {
436 val = Kokkos::max(val, Kokkos::abs(view(i)));
438 Kokkos::Max<T>(local)
441 ippl::Comm->allreduce(local, globalMax, 1, std::greater<T>());
445 Kokkos::parallel_reduce(
"FEMVector lp norm", n,
446 KOKKOS_LAMBDA(
const size_t i, T& val) {
447 val += Kokkos::pow(Kokkos::abs(view(i)), p);
449 Kokkos::Sum<T>(local)
452 ippl::Comm->allreduce(local, globalSum, 1, std::plus<T>());
453 return std::pow(globalSum, 1.0 / p);
460#include "FEMVector.hpp"
1D vector used in the context of FEM.
Definition FEMVector.h:34
void unpack(const Kokkos::View< size_t * > &idxStore)
Unpack data from BoundaryInfo::commBuffer_m into FEMVector::data_m after communication.
Definition FEMVector.hpp:330
T value_type
Dummy type definition in order for the detail::Expression defined operators to work.
Definition FEMVector.h:56
static constexpr unsigned dim
Dummy parameter in order for the detail::Expression defined operators to work.
Definition FEMVector.h:45
void fillHalo()
Copy values from neighboring ranks into local halo.
Definition FEMVector.hpp:38
FEMVector< K > skeletonCopy() const
Create a new FEMVector with different data type, but same size and boundary infromation.
Definition FEMVector.hpp:270
FEMVector< T > & operator=(T value)
Set all the values of the vector to value.
Definition FEMVector.hpp:174
const Kokkos::View< T * > & getView() const
Get underlying data view.
Definition FEMVector.hpp:223
KOKKOS_INLINE_FUNCTION T operator()(size_t i) const
Subscript operator to get value at position i.
Definition FEMVector.hpp:217
void pack(const Kokkos::View< size_t * > &idxStore)
Pack data into BoundaryInfo::commBuffer_m for MPI communication.
Definition FEMVector.hpp:302
void accumulateHalo()
Accumulate halo values in neighbor.
Definition FEMVector.hpp:95
size_t size() const
Get the size (number of elements) of the vector.
Definition FEMVector.hpp:229
KOKKOS_INLINE_FUNCTION T operator[](size_t i) const
Subscript operator to get value at position i.
Definition FEMVector.hpp:211
FEMVector< T > deepCopy() const
Create a deep copy, where all the information of this vector is copied to a new one.
Definition FEMVector.hpp:234
void setHalo(T setValue)
Set the halo cells to setValue.
Definition FEMVector.hpp:152
T innerProduct(const FEMVector< T > &a, const FEMVector< T > &b)
Calculate the inner product between two ippl::FEMVector(s).
Definition FEMVector.h:407
Struct for addition+assignment operator to be used with FEMVector::unpack().
Definition FEMVector.h:277
Struct for assigment operator to be used with FEMVector::unpack().
Definition FEMVector.h:266
Definition IpplExpressions.h:26
Definition HaloCells.h:23