Skip to content
Snippets Groups Projects
Commit 3a602ac0 authored by Pavol Margitfalvi's avatar Pavol Margitfalvi
Browse files

add conversion methods to NekArray

parent c46e3165
No related branches found
No related tags found
5 merge requests!22Basic implementation of Matrix-free BwdTrans and padding feature in Field,!11Implement CUDA BwdTrans sum-factorization kernels,!8BwdTrans operator in CUDA,!3First naive implementation,!2Implements BwdTrans StdMat operator
......@@ -13,6 +13,7 @@
#include "MemoryRegionCPU.hpp"
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/BasicUtils/ShapeType.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
/**
* @brief Captures the structure of a block of elements of identical shape
......@@ -120,6 +121,20 @@ public:
return field;
}
template <template <typename> class TMemoryRegion = MemoryRegionCPU>
static Field<TType, TState> fromArray(
std::vector<BlockAttributes> blocks,
Nektar::Array<Nektar::OneD, TType> const &array)
{
auto field = create<MemoryRegionCPU>(blocks);
std::copy(array.begin(), array.end(), field.GetStorage().GetCPUPtr());
field.template GetStorage<TMemoryRegion>(); // convert storage to
// TMemoryRegion
return field;
}
/**
* @brief Get the underlying storage of the field as the requested type.
* @return MemoryRegion storage converted to the requested type
......@@ -244,6 +259,12 @@ public:
return component_names.size();
}
Nektar::Array<Nektar::OneD, TType> toArray() const
{
return Nektar::Array<Nektar::OneD, TType>(m_storage->size(),
m_storage->GetCPUPtr());
}
private:
/**
* @brief Reshapes the current storage interleaving to a non-interleaved
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment