Nektar++
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Friends | List of all members
Nektar::LibUtilities::Field< TData, TState > Class Template Reference

A Field represents expansion data to be operated on. More...

#include <Field.hpp>

Public Types

typedef TData value_type
 

Public Member Functions

 Field ()=default
 
 ~Field ()
 
 Field (const std::string name, const std::vector< BlockAttributes< TState > > blockAttr, const unsigned int num_components, const unsigned int num_homo_modes, const MemAllocType &memAllocType=eHostPageable, const size_t alignment=NektarSpaces::host_memory_alignment)
 Construct a new Field object.
 
 Field (const std::vector< BlockAttributes< TState > > blockAttr, const unsigned int num_components, const unsigned int num_homo_modes, const MemAllocType &memAllocType=eHostPageable, const size_t alignment=NektarSpaces::host_memory_alignment)
 Construct a new Field object.
 
 Field (const std::string name, const std::vector< BlockAttributes< TState > > blockAttr, const std::vector< std::string > components, const unsigned int num_homo_modes, const MemAllocType &memAllocType=eHostPageable, const size_t alignment=NektarSpaces::host_memory_alignment)
 Construct a new Field object.
 
 Field (const std::vector< BlockAttributes< TState > > blockAttr, const std::vector< std::string > components, const unsigned int num_homo_modes, const MemAllocType &memAllocType=eHostPageable, const size_t alignment=NektarSpaces::host_memory_alignment)
 Construct a new Field object.
 
 Field (Field &&rhs)
 Construct a new Field object by moving storage from an existing Field object.
 
 Field (const Field &)=delete
 Constructor methods - No copy methods.
 
Field & operator= (const Field &)=delete
 
Field & operator= (Field &&rhs)
 Move assignment operator.
 
 operator bool () const
 Whether the field has been given storage by a custom constructor.
 
std::vector< unsigned int > GetInterleaveWidth (void) const
 
void SetInterleaveWidth (const unsigned int &interleaveWidth)
 
void SetInterleaveWidth (const std::vector< unsigned int > &interleaveWidths)
 
void SetInterleaveWidth (Field &field)
 
void ReshapeStorage (const unsigned int &interleaveWidth, const std::string &execSpace)
 
void ReshapeStorage (const std::vector< unsigned int > &interleaveWidths, const std::string &execSpace)
 
template<typename MemSpace >
void Initialize (const TData val, const unsigned int streamID=0)
 Templated initialize method: set every entry to val, but the padding, which is zero.
 
template<typename TDataOut = TData, class Alloc = std::allocator<TDataOut>>
std::vector< TDataOut, Alloc > ToVector ()
 Copy the data to a std::vector, component by component and element by element, without padding, whatever the interleave width of each block.
 
template<typename TDataOut = TData>
Nektar::Array< Nektar::OneD, TDataOut > ToArray ()
 Copy the data to a Nektar::Array, component by component and element by element, without padding, whatever the interleave width of each block.
 
template<typename MemSpace >
void Copy (Field &field)
 Templated copy method. This method copies data from a Field.
 
template<typename MemSpace , typename TDataIn , class Alloc = std::allocator<TDataIn>>
void CopyVector (const std::vector< TDataIn, Alloc > &array)
 Templated copy method. This method copies data from a std::vector laid out as ToVector() returns it, and interleaves it to the width of each block.
 
template<typename MemSpace , typename TDataIn >
void CopyArray (const Nektar::Array< Nektar::OneD, TDataIn > &array)
 Templated copy method. This method copies data from a Nektar::Array<Nektar::OneD, TDataIn> laid out as ToArray() returns it, and interleaves it to the width of each block.
 
std::vector< BlockAccessor< TData, TState > > & GetBlocks ()
 Get BlockAccessors for the field.
 
size_t size () const
 Gets the size of the field.
 
std::string GetName (void) const
 Gets the name of the field.
 
unsigned int GetNumComponents () const
 Gets the number of components for a vector field.
 
std::vector< std::string > GetComponentNames () const
 Gets a copy of the components names for a vector field.
 
unsigned int GetNumHomoModes () const
 Gets the number of homogeneous modes.
 

Protected Member Functions

void ReleaseStorage ()
 Free the contiguous host and device storage this field owns, allocated by AllocateFieldStorage(), and mark the field uninstantiated.
 
template<typename TDataOut >
void DeInterleaveToHostPtr (TDataOut *dst, const size_t compSize)
 Copy the data to host memory, component by component and element by element, without padding. Each block is de-interleaved from its own interleave width during the copy; the field itself is left unchanged.
 
template<typename MemSpace , typename TDataIn >
void InterleaveFromHostPtr (const TDataIn *src, const size_t compSize)
 Copy data from host memory, laid out component by component and element by element without padding, to the storage in MemSpace. Each block is copied with an interleave width of 1 and its storage is then reshaped back to its own interleave width.
 

Static Protected Member Functions

template<typename MemSpace >
static void AllocateFieldStorage (Field< TData, TState > *field)
 Allocate contiguous host OR device memory accross all MemoryRegion objects belonging to a Field object pointer.
 

Protected Attributes

bool m_instantiated = false
 Flag indicating if the current object has been instantiated.
 
std::string m_name
 
std::vector< std::string > m_component_names
 
unsigned int m_num_homo_modes = 1
 
TData * m_host = nullptr
 
TData * m_device = nullptr
 
std::vector< BlockAccessor< TData, TState > > m_block_accessors
 
MemAllocType m_memAllocType
 
size_t m_alignment = NektarSpaces::host_memory_alignment
 
std::shared_ptr< SharedFieldStorage< TData > > m_sharedStorage
 Shared storage the field points into, if any.
 
size_t m_sharedStorageOffset = 0
 Offset of the field in m_sharedStorage.
 

Private Member Functions

 Field (const std::string name, const std::vector< BlockAttributes< TState > > blockAttr, const std::vector< std::string > components, const unsigned int num_homo_modes, const std::shared_ptr< SharedFieldStorage< TData > > &storage, const size_t offset)
 Construct a new Field object in storage shared with other fields. For use by MultiField only.
 

Static Private Member Functions

template<typename MemSpace >
static void ZeroPadding (BlockAccessor< TData, TState > &block, const unsigned int streamID)
 Zero the padding of block in place, in MemSpace.
 

Friends

template<typename TDataField , FieldState TStateField>
class BlockAccessor
 
class MultiField< TData, TState >
 

Detailed Description

template<typename TData, FieldState TState>
class Nektar::LibUtilities::Field< TData, TState >

A Field represents expansion data to be operated on.

Template Parameters
TDataThe floating-point representation used by the field.
TStateA FieldState value representing the state of the field.

Definition at line 53 of file LibUtilities/BasicUtils/Field/Field.hpp.

Member Typedef Documentation

◆ value_type

template<typename TData , FieldState TState>
typedef TData Nektar::LibUtilities::Field< TData, TState >::value_type

Definition at line 705 of file LibUtilities/BasicUtils/Field/Field.hpp.

Constructor & Destructor Documentation

◆ Field() [1/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( )
default

◆ ~Field()

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::~Field ( )
inline

Definition at line 60 of file LibUtilities/BasicUtils/Field/Field.hpp.

61 {
63 }
void ReleaseStorage()
Free the contiguous host and device storage this field owns, allocated by AllocateFieldStorage(),...

References Nektar::LibUtilities::Field< TData, TState >::ReleaseStorage().

◆ Field() [2/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( const std::string  name,
const std::vector< BlockAttributes< TState > >  blockAttr,
const unsigned int  num_components,
const unsigned int  num_homo_modes,
const MemAllocType &  memAllocType = eHostPageable,
const size_t  alignment = NektarSpaces::host_memory_alignment 
)
inline

Construct a new Field object.

Parameters
name- Name of the field object.
blockAttr- Block attributes.
num_components- Number of components.
num_homo_modes- Number of homogeneous modes.
memAllocType- [ eHostPageable, eHostPinned, eDeviceMemoryPool, eHostPinnedDeviceMemoryPool]
alignment- Memory alignment to use.

Definition at line 76 of file LibUtilities/BasicUtils/Field/Field.hpp.

81 : m_instantiated(true), m_name(name), m_component_names(num_components),
82 m_num_homo_modes(num_homo_modes), m_memAllocType(memAllocType),
83 m_alignment(alignment)
84 {
85 for (unsigned int blk = 0; blk < blockAttr.size(); ++blk)
86 {
87 auto nsize =
88 blockAttr[blk].CompSize() * num_components * num_homo_modes;
89 auto mr = MemoryRegion<TData>(name + std::to_string(blk), nsize,
90 memAllocType, alignment);
91 this->GetBlocks().push_back(
92 BlockAccessor(blockAttr[blk], std::move(mr), this,
93 num_components, num_homo_modes));
94 }
95 }
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
bool m_instantiated
Flag indicating if the current object has been instantiated.

References Nektar::LibUtilities::Field< TData, TState >::BlockAccessor, and Nektar::LibUtilities::Field< TData, TState >::GetBlocks().

◆ Field() [3/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( const std::vector< BlockAttributes< TState > >  blockAttr,
const unsigned int  num_components,
const unsigned int  num_homo_modes,
const MemAllocType &  memAllocType = eHostPageable,
const size_t  alignment = NektarSpaces::host_memory_alignment 
)
inline

Construct a new Field object.

Parameters
blockAttr- Block attributes.
num_components- Number of components.
num_homo_modes- Number of homogeneous modes.
memAllocType- [ eHostPageable, eHostPinned, eDeviceMemoryPool, eHostPinnedDeviceMemoryPool]
alignment- Memory alignment to use.

Definition at line 107 of file LibUtilities/BasicUtils/Field/Field.hpp.

111 : Field<TData, TState>("", blockAttr, num_components, num_homo_modes,
112 memAllocType, alignment)
113 {
114 }

◆ Field() [4/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( const std::string  name,
const std::vector< BlockAttributes< TState > >  blockAttr,
const std::vector< std::string >  components,
const unsigned int  num_homo_modes,
const MemAllocType &  memAllocType = eHostPageable,
const size_t  alignment = NektarSpaces::host_memory_alignment 
)
inline

Construct a new Field object.

Parameters
name- Name of the field object.
blockAttr- Block attributes.
components- Names of components for vector field.
num_homo_modes- Number of homogeneous modes.
memAllocType- [ eHostPageable, eHostPinned, eDeviceMemoryPool, eHostPinnedDeviceMemoryPool]
alignment- Memory alignment to use.

Definition at line 127 of file LibUtilities/BasicUtils/Field/Field.hpp.

133 : m_instantiated(true), m_name(name), m_component_names(components),
134 m_num_homo_modes(num_homo_modes), m_memAllocType(memAllocType),
135 m_alignment(alignment)
136 {
137 for (unsigned int blk = 0; blk < blockAttr.size(); ++blk)
138 {
139 auto nsize =
140 blockAttr[blk].CompSize() * components.size() * num_homo_modes;
141 auto mr = MemoryRegion<TData>(name + std::to_string(blk), nsize,
142 memAllocType, alignment);
143 this->GetBlocks().push_back(
144 BlockAccessor(blockAttr[blk], std::move(mr), this,
145 components.size(), num_homo_modes));
146 }
147 }

References Nektar::LibUtilities::Field< TData, TState >::BlockAccessor, and Nektar::LibUtilities::Field< TData, TState >::GetBlocks().

◆ Field() [5/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( const std::vector< BlockAttributes< TState > >  blockAttr,
const std::vector< std::string >  components,
const unsigned int  num_homo_modes,
const MemAllocType &  memAllocType = eHostPageable,
const size_t  alignment = NektarSpaces::host_memory_alignment 
)
inline

Construct a new Field object.

Parameters
blockAttr- Block attributes.
components- Names of components for vector field.
num_homo_modes- Number of homogeneous modes.
memAllocType- [ eHostPageable, eHostPinned, eDeviceMemoryPool, eHostPinnedDeviceMemoryPool]
alignment- Memory alignment to use.

Definition at line 159 of file LibUtilities/BasicUtils/Field/Field.hpp.

164 : Field<TData, TState>("", blockAttr, components, num_homo_modes,
165 memAllocType, alignment)
166 {
167 }

◆ Field() [6/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( Field< TData, TState > &&  rhs)
inline

Construct a new Field object by moving storage from an existing Field object.

Parameters
rhs

Definition at line 175 of file LibUtilities/BasicUtils/Field/Field.hpp.

176 : m_instantiated(std::move(rhs.m_instantiated)),
177 m_name(std::move(rhs.m_name)),
178 m_component_names(std::move(rhs.m_component_names)),
179 m_num_homo_modes(std::move(rhs.m_num_homo_modes)),
180 m_host(std::move(rhs.m_host)), m_device(std::move(rhs.m_device)),
181 m_block_accessors(std::move(rhs.m_block_accessors)),
182 m_memAllocType(std::move(rhs.m_memAllocType)),
183 m_alignment(std::move(rhs.m_alignment)),
184 m_sharedStorage(std::move(rhs.m_sharedStorage)),
185 m_sharedStorageOffset(std::move(rhs.m_sharedStorageOffset))
186 {
187 for (auto &blocks : m_block_accessors)
188 {
189 blocks.m_field = this;
190 }
191 rhs.m_instantiated = false;
192 rhs.m_name = "";
193 rhs.m_component_names.clear();
194 rhs.m_num_homo_modes = 1;
195 rhs.m_host = nullptr;
196 rhs.m_device = nullptr;
197 rhs.m_block_accessors.clear();
198 rhs.m_memAllocType = eHostPageable;
199 rhs.m_alignment = NektarSpaces::host_memory_alignment;
200 rhs.m_sharedStorageOffset = 0;
201 }
std::shared_ptr< SharedFieldStorage< TData > > m_sharedStorage
Shared storage the field points into, if any.
size_t m_sharedStorageOffset
Offset of the field in m_sharedStorage.
std::vector< BlockAccessor< TData, TState > > m_block_accessors
static constexpr size_t host_memory_alignment
Definition Backends.hpp:178
@ eHostPageable

References Nektar::eHostPageable, Nektar::NektarSpaces::host_memory_alignment, and Nektar::LibUtilities::Field< TData, TState >::m_block_accessors.

◆ Field() [7/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( const Field< TData, TState > &  )
delete

Constructor methods - No copy methods.

◆ Field() [8/8]

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::Field ( const std::string  name,
const std::vector< BlockAttributes< TState > >  blockAttr,
const std::vector< std::string >  components,
const unsigned int  num_homo_modes,
const std::shared_ptr< SharedFieldStorage< TData > > &  storage,
const size_t  offset 
)
inlineprivate

Construct a new Field object in storage shared with other fields. For use by MultiField only.

The field holds no storage of its own: its blocks point into storage from offset onwards, which must leave room for the whole field.

Warning
This constructor must only be used by MultiField, which owns the shared storage and lays its columns out in it. It is private, with MultiField as friend, so that no other code can build a Field on storage it does not manage.
Parameters
name- Name of the field object.
blockAttr- Block attributes.
components- Names of components for vector field.
num_homo_modes- Number of homogeneous modes.
storage- Storage the field points into.
offset- Offset of the field in storage.

Definition at line 1017 of file LibUtilities/BasicUtils/Field/Field.hpp.

1023 : Field<TData, TState>(name, blockAttr, components, num_homo_modes,
1024 storage->GetMemAllocType(),
1025 storage->GetAlignment())
1026 {
1027 if (offset + this->size() > storage->size())
1028 {
1030 "Field - Shared storage too small for the field.");
1031 }
1032
1033 m_sharedStorage = storage;
1034 m_sharedStorageOffset = offset;
1035 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
size_t size() const
Gets the size of the field.

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::m_sharedStorage, Nektar::LibUtilities::Field< TData, TState >::m_sharedStorageOffset, NEKERROR, and Nektar::LibUtilities::Field< TData, TState >::size().

Member Function Documentation

◆ AllocateFieldStorage()

template<typename TData , FieldState TState>
template<typename MemSpace >
static void Nektar::LibUtilities::Field< TData, TState >::AllocateFieldStorage ( Field< TData, TState > *  field)
inlinestaticprotected

Allocate contiguous host OR device memory accross all MemoryRegion objects belonging to a Field object pointer.

Parameters
field- Field object pointer.

Definition at line 759 of file LibUtilities/BasicUtils/Field/Field.hpp.

760 {
761 if constexpr (std::is_same_v<MemSpace, NektarSpaces::HostSpace>)
762 {
763 size_t alignment_offset = 0;
764
765 // Point the blocks into the shared storage, if any.
766 if (!field->m_host && field->m_sharedStorage)
767 {
768 auto src = field->m_sharedStorage->template GetPtr<MemSpace>() +
769 field->m_sharedStorageOffset;
770 field->m_host = src;
771
772 for (unsigned int blk = 0; blk < field->GetBlocks().size();
773 ++blk)
774 {
775 field->GetBlocks()[blk].m_memory_region.SetHostStorage(src);
776 src += field->GetBlocks()[blk].m_memory_region.size();
777 }
778 }
779
780 // Allocate contiguous host memory accross all MemoryRegions of the
781 // field object.
782 if (!field->m_host)
783 {
784 if (field->m_memAllocType == eHostPageable)
785 {
786 hostMalloc(&field->m_host, field->size() * sizeof(TData),
787 field->m_alignment);
788 }
789 else if (field->m_memAllocType == eHostPinned)
790 {
791 // Add extra bytes for alignment provision
792 size_t aligned_bytes_size =
793 field->size() * sizeof(TData) + field->m_alignment;
794 hostMallocPinned(&field->m_host, aligned_bytes_size);
795 // Compute offset in bytes for non-aligned memory.
796 if ((size_t)field->m_host % field->m_alignment)
797 {
798 alignment_offset =
799 field->m_alignment -
800 (size_t)field->m_host % field->m_alignment;
801 }
802 }
803 // Get aligned memory pointer.
804 auto src = (TData *)((size_t)field->m_host + alignment_offset);
805 std::memset((void *)src, 0, field->size() * sizeof(TData));
806
807 for (unsigned int blk = 0; blk < field->GetBlocks().size();
808 ++blk)
809 {
810 field->GetBlocks()[blk].m_memory_region.SetHostStorage(src);
811 src += field->GetBlocks()[blk].m_memory_region.size();
812 }
813 }
814 }
815 else if constexpr (std::is_same_v<MemSpace, NektarSpaces::DeviceSpace>)
816 {
817 // Point the blocks into the shared storage, if any.
818 if (!field->m_device && field->m_sharedStorage)
819 {
820 auto src = field->m_sharedStorage->template GetPtr<MemSpace>() +
821 field->m_sharedStorageOffset;
822 field->m_device = src;
823
824 for (unsigned int blk = 0; blk < field->GetBlocks().size();
825 ++blk)
826 {
827 field->GetBlocks()[blk].m_memory_region.SetDeviceStorage(
828 src);
829 src += field->GetBlocks()[blk].m_memory_region.size();
830 }
831 }
832
833 // Allocate contiguous device memory accross all MemoryRegions of
834 // the field object.
835 if (!field->m_device)
836 {
837 const unsigned int streamID = 0;
838 deviceMalloc(&field->m_device, field->size() * sizeof(TData),
839 streamID, field->m_memAllocType);
840 deviceMemset(field->m_device, 0, field->size() * sizeof(TData),
841 streamID);
842 nekStreamSynchronize(streamID);
843
844 auto src = field->m_device;
845 for (unsigned int blk = 0; blk < field->GetBlocks().size();
846 ++blk)
847 {
848 field->GetBlocks()[blk].m_memory_region.SetDeviceStorage(
849 src);
850 src += field->GetBlocks()[blk].m_memory_region.size();
851 }
852 }
853 }
854 }
void deviceMemset(TData *dst, const int val, const size_t size, const unsigned int streamID)
static void nekStreamSynchronize(const unsigned int streamID)
Definition Backends.hpp:428
void deviceMalloc(TData **src, const size_t size, const unsigned int streamID, const MemAllocType memAllocType=eHostPageable)
void hostMallocPinned(TData **src, const size_t size)
void hostMalloc(TData **src, const size_t size, const size_t alignment)

References Nektar::deviceMalloc(), Nektar::deviceMemset(), Nektar::eHostPageable, Nektar::eHostPinned, Nektar::hostMalloc(), Nektar::hostMallocPinned(), Nektar::nekStreamSynchronize(), and Nektar::LibUtilities::Field< TData, TState >::size().

◆ Copy()

template<typename TData , FieldState TState>
template<typename MemSpace >
void Nektar::LibUtilities::Field< TData, TState >::Copy ( Field< TData, TState > &  field)
inline

Templated copy method. This method copies data from a Field.

Parameters
field- Field to copy from

Definition at line 462 of file LibUtilities/BasicUtils/Field/Field.hpp.

463 {
464 if (!m_instantiated)
465 {
467 "Field::Copy - Object has not been "
468 "instantiated by custom constructor.");
469 }
470
471 // If not yet allocated, allocate contiguous host OR device memory
472 // across all MemoryRegion objects within the input argument field
473 // object before data copy.
474 AllocateFieldStorage<MemSpace>(&field);
475
476 // If not yet allocated, allocate contiguous host OR device memory
477 // across all MemoryRegion objects within current Field object before
478 // data copy from input argument field object.
479 AllocateFieldStorage<MemSpace>(this);
480
481 if (this->GetBlocks().size() != field.GetBlocks().size())
482 {
483 std::stringstream msg;
484
485 msg << "Field::Copy - "
486 << "Block number mismatch between (" << field.GetName()
487 << ") and (" << this->GetName() << ").";
489 }
490
491 if (this->size() != field.size())
492 {
493 std::stringstream msg;
494
495 msg << "Field::Copy - "
496 << "Memory size mismatch between (" << field.GetName()
497 << ") and (" << this->GetName() << ").";
499 }
500
501 for (unsigned int blk = 0; blk < this->GetBlocks().size(); ++blk)
502 {
503 const unsigned int streamID = blk + 1;
504 this->GetBlocks()[blk].m_memory_region.template Copy<MemSpace>(
505 field.GetBlocks()[blk].m_memory_region, streamID);
506 this->GetBlocks()[blk].template SetInterleaveWidth<TData>(
507 field.GetBlocks()[blk].GetInterleaveWidth());
508 }
509 }
std::string GetName(void) const
Gets the name of the field.

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetName(), Nektar::LibUtilities::Field< TData, TState >::m_instantiated, NEKERROR, and Nektar::LibUtilities::Field< TData, TState >::size().

◆ CopyArray()

template<typename TData , FieldState TState>
template<typename MemSpace , typename TDataIn >
void Nektar::LibUtilities::Field< TData, TState >::CopyArray ( const Nektar::Array< Nektar::OneD, TDataIn > &  array)
inline

Templated copy method. This method copies data from a Nektar::Array<Nektar::OneD, TDataIn> laid out as ToArray() returns it, and interleaves it to the width of each block.

Parameters
array- Nektar::Array to copy from

Definition at line 564 of file LibUtilities/BasicUtils/Field/Field.hpp.

565 {
566 if (!m_instantiated)
567 {
569 "Field::CopyArray - Object has not been "
570 "instantiated by custom constructor.");
571 }
572
573 // If not yet allocated, allocate contiguous host memory across all
574 // MemoryRegion objects within current Field object before data copy
575 // from NekArray.
576 AllocateFieldStorage<MemSpace>(this);
577
578 unsigned int compSize = 0;
579 for (auto &block : this->GetBlocks())
580 {
581 compSize += block.GetNumData() * block.GetNumElements();
582 }
583
584 if (compSize * this->GetNumComponents() * this->GetNumHomoModes() !=
585 array.size())
586 {
587 std::stringstream msg;
588
589 msg << "Field::CopyArray - "
590 << "Memory size mismatch between (Nektar::array) and ("
591 << this->GetName() << ").";
593 }
594
595 InterleaveFromHostPtr<MemSpace>(array.data(), compSize);
596 }
unsigned int GetNumHomoModes() const
Gets the number of homogeneous modes.
unsigned int GetNumComponents() const
Gets the number of components for a vector field.

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetName(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

◆ CopyVector()

template<typename TData , FieldState TState>
template<typename MemSpace , typename TDataIn , class Alloc = std::allocator<TDataIn>>
void Nektar::LibUtilities::Field< TData, TState >::CopyVector ( const std::vector< TDataIn, Alloc > &  array)
inline

Templated copy method. This method copies data from a std::vector laid out as ToVector() returns it, and interleaves it to the width of each block.

Parameters
array- std::vector to copy from

Definition at line 521 of file LibUtilities/BasicUtils/Field/Field.hpp.

522 {
523 if (!m_instantiated)
524 {
526 "Field::CopyVector - Object has not been "
527 "instantiated by custom constructor.");
528 }
529
530 // If not yet allocated, allocate contiguous host memory across all
531 // MemoryRegion objects within current Field object before data copy
532 // from vector.
533 AllocateFieldStorage<MemSpace>(this);
534
535 unsigned int compSize = 0;
536 for (auto &block : this->GetBlocks())
537 {
538 compSize += block.GetNumData() * block.GetNumElements();
539 }
540
541 if (compSize * this->GetNumComponents() * this->GetNumHomoModes() !=
542 array.size())
543 {
544 std::stringstream msg;
545
546 msg << "Field::CopyVector - "
547 << "Memory size mismatch between (std::vector) and ("
548 << this->GetName() << ").";
550 }
551
552 InterleaveFromHostPtr<MemSpace>(array.data(), compSize);
553 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetName(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by BOOST_AUTO_TEST_CASE().

◆ DeInterleaveToHostPtr()

template<typename TData , FieldState TState>
template<typename TDataOut >
void Nektar::LibUtilities::Field< TData, TState >::DeInterleaveToHostPtr ( TDataOut *  dst,
const size_t  compSize 
)
inlineprotected

Copy the data to host memory, component by component and element by element, without padding. Each block is de-interleaved from its own interleave width during the copy; the field itself is left unchanged.

Parameters
dst- host memory to copy to
compSize- number of values of one component in dst

Definition at line 865 of file LibUtilities/BasicUtils/Field/Field.hpp.

866 {
867 const unsigned int nCompHomo =
868 this->GetNumComponents() * this->GetNumHomoModes();
869 for (auto &block : this->GetBlocks())
870 {
871 auto src =
872 block.template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
873 const size_t nSize = block.CompSize();
874 const size_t nElmts = block.GetNumElements();
875 const unsigned int npts = block.GetNumData();
876 const unsigned int interleaveWidth = block.GetInterleaveWidth();
877 const unsigned int elmtGroupSize = npts * interleaveWidth;
878 const size_t numElmtGroups =
879 (nElmts + interleaveWidth - 1) / interleaveWidth;
880 for (unsigned int n = 0; n < nCompHomo; ++n)
881 {
882 if (interleaveWidth == 1)
883 {
884 std::copy(src, src + nElmts * npts, dst + n * compSize);
885 }
886 else
887 {
888 for (size_t e = 0; e < numElmtGroups; ++e)
889 {
890 for (unsigned int vecElem = 0;
891 vecElem < interleaveWidth &&
892 e * interleaveWidth + vecElem < nElmts;
893 ++vecElem)
894 {
895 const TData *elmtSrc =
896 src + e * elmtGroupSize + vecElem;
897 TDataOut *elmtDst =
898 dst + n * compSize +
899 (e * interleaveWidth + vecElem) * npts;
900 for (unsigned int idx = 0; idx < npts; ++idx)
901 {
902 elmtDst[idx] = elmtSrc[idx * interleaveWidth];
903 }
904 }
905 }
906 }
907 src += nSize;
908 }
909 dst += nElmts * npts;
910 }
911 }

References Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes().

Referenced by Nektar::LibUtilities::Field< TData, TState >::ToArray(), and Nektar::LibUtilities::Field< TData, TState >::ToVector().

◆ GetBlocks()

template<typename TData , FieldState TState>
std::vector< BlockAccessor< TData, TState > > & Nektar::LibUtilities::Field< TData, TState >::GetBlocks ( )
inline

Get BlockAccessors for the field.

Returns
std::vector<BlockAccessor>

Definition at line 603 of file LibUtilities/BasicUtils/Field/Field.hpp.

604 {
605 if (!m_instantiated)
606 {
608 "Field::GetBlocks - Object has not been "
609 "instantiated by custom constructor.");
610 }
611
612 return m_block_accessors;
613 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::m_block_accessors, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by TestMath< TData >::abs(), TestMath< TData >::add(), TestIProductWRTPhysNormalDerivTrace< TData >::AddLaplacianOfBasisTerm(), TestIProductWRTPhysTrace< TData >::AddPreFillPhys(), Nektar::detail::HOutflowBndCondOpImpl< ExecSpace, TData >::ApplyNeumannMaps(), Nektar::MultiRegions::PhysTraceExtractOp< TData >::ApplyNormalComponent(), Nektar::MultiRegions::detail::AvgAssmbScatrOpImpl< ExecSpace, TData >::AvgAssmbScatrOpImpl(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), Nektar::FieldStorageUnitTests::BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::BoundaryOp(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::BoundaryOp(), Nektar::detail::DiffusionScalarIPTraceFluxOpImpl< ExecSpace, TData >::BoundaryOp(), Nektar::detail::AdvDiffTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::BoundaryOp(), Nektar::detail::HOPressureBndCondOpImpl< ExecSpace, TData >::BuildBoundaryPhys(), TestMath< TData >::Compare(), TestOp< TData, stateIn, stateOut, TExpList >::Compare(), TestLinearSolver< TData >::Compare(), TestPreconOps< TData >::Compare(), Nektar::LibUtilities::Field< TData, TState >::Copy(), Nektar::LibUtilities::Field< TData, TState >::CopyArray(), Nektar::LibUtilities::Field< TData, TState >::CopyVector(), TestMath< TData >::daxpby(), TestMath< TData >::daxpbypcz(), TestMath< TData >::daxpy(), Nektar::Math::ddot(), Nektar::Math::ddot2(), Nektar::LibUtilities::Field< TData, TState >::DeInterleaveToHostPtr(), TestMath< TData >::div(), TestHelmholtz< TData >::ExpectedSolution(), TestIProductWRTPhysTrace< TData >::ExpectedSolution(), TestLaplacian< TData >::ExpectedSolution(), TestLinAdvDiffReaction< TData >::ExpectedSolution(), TestPhysTraceExtract< TData >::ExpectedSolution(), Nektar::LibUtilities::Field< TData, TState >::Field(), Nektar::LibUtilities::Field< TData, TState >::Field(), TestIProductWRTPhysNormalDerivTrace< TData >::FillVolumeG(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::FlattenBlocks(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::FlipParallelDirBndSign(), Nektar::detail::HOPressureBndCondOpImpl< ExecSpace, TData >::GatherBoundaryElements(), Nektar::detail::HOutflowBndCondOpImpl< ExecSpace, TData >::GatherVelocity(), Nektar::LibUtilities::Field< TData, TState >::Initialize(), TestMath< TData >::inner_product(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::InteriorOp(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::InteriorOp(), Nektar::detail::DiffusionScalarIPTraceFluxOpImpl< ExecSpace, TData >::InteriorOp(), Nektar::detail::AdvDiffTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::InteriorOp(), Nektar::LibUtilities::Field< TData, TState >::InterleaveFromHostPtr(), TestMath< TData >::l1norm(), Nektar::Math::l1norm(), TestMath< TData >::l2norm(), Nektar::Math::l2norm(), TestMath< TData >::linfnorm(), Nektar::Math::linfnorm(), TestMath< TData >::max(), TestParallelReduce< TData >::max(), TestMath< TData >::min(), TestParallelReduce< TData >::min(), TestMath< TData >::mul(), Nektar::MultiRegions::detail::AdvectionDealiasOpImpl< ExecSpace, TData >::MultiplyByAdvVelZ(), TestMath< TData >::neg(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::ParallelOp(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::ParallelOp(), Nektar::detail::DiffusionScalarIPTraceFluxOpImpl< ExecSpace, TData >::ParallelOp(), Nektar::detail::AdvDiffTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::ParallelOp(), Nektar::Math::reduceMax(), Nektar::Math::reduceMin(), Nektar::Math::reduceSum(), Nektar::LibUtilities::Field< TData, TState >::ReshapeStorage(), Nektar::LibUtilities::Field< TData, TState >::ReshapeStorage(), Nektar::FieldStorageUnitTests::RunMultiFieldColumns(), TestPhysTraceExtractBndCond< TData >::RunTestCase(), TestIProductWRTPhysNormalDerivTrace< TData >::RunVectorIdentityCase(), Nektar::MultiRegions::AdvectionOp< TData >::SetAdvVel(), Nektar::MultiRegions::AdvectionDealiasOp< TData >::SetAdvVel(), Nektar::MultiRegions::LinAdvDiffReactionOp< TData >::SetAdvVel(), Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth(), Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth(), Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth(), TestParallelReduce< TData >::SetTestCase(), TestAdvection< TData >::SetTestCase(), TestAdvectionDealias< TData >::SetTestCase(), TestAvgAssmbScatr< TData >::SetTestCase(), TestBwdTrans< TData >::SetTestCase(), TestCurlCurl< TData >::SetTestCase(), TestDivergence< TData >::SetTestCase(), TestExpression< TData >::SetTestCase(), TestIProductWRTBase< TData >::SetTestCase(), TestIProductWRTDerivBase< TData >::SetTestCase(), TestIProductWRTPhysTrace< TData >::SetTestCase(), TestMass< TData >::SetTestCase(), TestMultiplyByElmtInvMass< TData >::SetTestCase(), TestPhysDeriv< TData >::SetTestCase(), TestPhysTraceExtract< TData >::SetTestCase(), TestPhysTraceExtractBndCond< TData >::SetTestCase(), TestFwdTrans< TData >::SetTestCase(), TestHelmSolve< TData >::SetTestCase(), TestLinearADRSolve< TData >::SetTestCase(), TestMaxStdVelocity< TData >::SetTestCase(), TestNormOps< TData >::SetTestCase(), TestPoissonSolve< TData >::SetTestCase(), TestAdvectionWeakDG< TData >::SetTestCase(), TestDiffusionIP< TData >::SetTestCase(), TestAssmbScatr< TData >::SetTestCase(), TestHelmholtz< TData >::SetTestCase(), TestLaplacian< TData >::SetTestCase(), TestLinAdvDiffReaction< TData >::SetTestCase(), TestPreconOps< TData >::SetTestCase(), TestTimeOps< TData >::SetTestCase(), TestPhysGalerkinProject1DScaled< TData >::SetTestCase(), TestPhysInterp1DScaled< TData >::SetTestCase(), TestIProductWRTPhysTrace< TData >::SetTestCaseDivTest(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::SetTraceAdvVel(), Nektar::MultiRegions::HelmholtzOp< TData >::SetVarDiffCoeff(), Nektar::MultiRegions::LaplacianOp< TData >::SetVarDiffCoeff(), Nektar::MultiRegions::LinAdvDiffReactionOp< TData >::SetVarDiffCoeff(), TestMath< TData >::sqrt(), TestMath< TData >::sub(), TestMath< TData >::sum(), TestParallelReduce< TData >::sum(), Nektar::LibUtilities::Field< TData, TState >::ToArray(), Nektar::LibUtilities::Field< TData, TState >::ToVector(), Nektar::detail::HOPressureBndCondOpImpl< ExecSpace, TData >::UpdateFlux(), Nektar::MultiRegions::detail::AssmbScatrOpImpl< ExecSpace, TData, ZERODIR, SIGNCHANGE >::v_Apply(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::v_Apply(), Nektar::MultiRegions::detail::NeuBndCondOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::HOPressureBndCondOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::DiffusionScalarVolFluxOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::AdvDiffCFEVolFluxOpImpl< ExecSpace, EqnOfSParams, TData >::v_Apply(), Nektar::detail::AeroForcesOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::ReynoldsStressOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::EnergyOpImpl< ExecSpace, TData >::v_Apply(), Nektar::MultiRegions::detail::CurlCurlOpImpl< ExecSpace, TData >::v_ApplyFFT(), Nektar::MultiRegions::PhysLiftProjectOp< TData >::v_ApplyLift(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::v_ApplyUnitTest(), Nektar::detail::HOutflowBndCondOpImpl< ExecSpace, TData >::v_UpdatePressure(), and Nektar::detail::DiffusionCFEVolFluxOpImpl< ExecSpace, EqnOfSParams, TData >::ViscousFlux().

◆ GetComponentNames()

template<typename TData , FieldState TState>
std::vector< std::string > Nektar::LibUtilities::Field< TData, TState >::GetComponentNames ( ) const
inline

Gets a copy of the components names for a vector field.

Returns
std::vector<std::string>

Definition at line 676 of file LibUtilities/BasicUtils/Field/Field.hpp.

677 {
678 if (!m_instantiated)
679 {
681 "Field::GetComponentNames - Object has not been "
682 "instantiated by custom constructor.");
683 }
684
685 return m_component_names;
686 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::m_component_names, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by TestAdvectionWeakDG< TData >::RunTestCase().

◆ GetInterleaveWidth()

template<typename TData , FieldState TState>
std::vector< unsigned int > Nektar::LibUtilities::Field< TData, TState >::GetInterleaveWidth ( void  ) const
inline

◆ GetName()

template<typename TData , FieldState TState>
std::string Nektar::LibUtilities::Field< TData, TState >::GetName ( void  ) const
inline

Gets the name of the field.

Returns
std::string

Definition at line 642 of file LibUtilities/BasicUtils/Field/Field.hpp.

643 {
644 if (!m_instantiated)
645 {
647 "Field::GetName - Object has not been "
648 "instantiated by custom constructor.");
649 }
650
651 return m_name;
652 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, Nektar::LibUtilities::Field< TData, TState >::m_name, and NEKERROR.

Referenced by Nektar::LibUtilities::Field< TData, TState >::Copy(), Nektar::LibUtilities::Field< TData, TState >::CopyArray(), and Nektar::LibUtilities::Field< TData, TState >::CopyVector().

◆ GetNumComponents()

template<typename TData , FieldState TState>
unsigned int Nektar::LibUtilities::Field< TData, TState >::GetNumComponents ( ) const
inline

Gets the number of components for a vector field.

Returns
unsigned int

Definition at line 659 of file LibUtilities/BasicUtils/Field/Field.hpp.

660 {
661 if (!m_instantiated)
662 {
664 "Field::GetNumComponents - Object has not been "
665 "instantiated by custom constructor.");
666 }
667
668 return m_component_names.size();
669 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::m_component_names, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by TestMath< TData >::abs(), TestMath< TData >::add(), TestIProductWRTPhysTrace< TData >::AddPreFillPhys(), Nektar::MultiRegions::PhysTraceExtractOp< TData >::ApplyNormalComponent(), Nektar::MultiRegions::IProductWRTPhysNormalDerivTraceOp< TData >::ApplyVector(), Nektar::MultiRegions::detail::AvgAssmbScatrOpImpl< ExecSpace, TData >::AvgAssmbScatrOpImpl(), Nektar::FieldStorageUnitTests::BOOST_AUTO_TEST_CASE(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::BoundaryOp(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::BoundaryOp(), Nektar::detail::DiffusionScalarIPTraceFluxOpImpl< ExecSpace, TData >::BoundaryOp(), Nektar::detail::AdvDiffTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::BoundaryOp(), TestNormOps< TData >::Compare(), TestMath< TData >::Compare(), TestOp< TData, stateIn, stateOut, TExpList >::Compare(), TestLinearSolver< TData >::Compare(), TestPreconOps< TData >::Compare(), Nektar::LibUtilities::Field< TData, TState >::CopyArray(), Nektar::LibUtilities::Field< TData, TState >::CopyVector(), TestMath< TData >::daxpby(), TestMath< TData >::daxpbypcz(), TestMath< TData >::daxpy(), Nektar::LibUtilities::Field< TData, TState >::DeInterleaveToHostPtr(), TestMath< TData >::div(), TestAdvection< TData >::ExpectedSolution(), TestAvgAssmbScatr< TData >::ExpectedSolution(), TestBwdTrans< TData >::ExpectedSolution(), TestCurlCurl< TData >::ExpectedSolution(), TestDivergence< TData >::ExpectedSolution(), TestHelmholtz< TData >::ExpectedSolution(), TestIProductWRTBase< TData >::ExpectedSolution(), TestIProductWRTDerivBase< TData >::ExpectedSolution(), TestIProductWRTPhysTrace< TData >::ExpectedSolution(), TestLaplacian< TData >::ExpectedSolution(), TestLinAdvDiffReaction< TData >::ExpectedSolution(), TestMass< TData >::ExpectedSolution(), TestMultiplyByElmtInvMass< TData >::ExpectedSolution(), TestPhysDeriv< TData >::ExpectedSolution(), TestPhysGalerkinProject1DScaled< TData >::ExpectedSolution(), TestPhysInterp1DScaled< TData >::ExpectedSolution(), TestPhysTraceExtract< TData >::ExpectedSolution(), TestRobin< TData >::ExpectedSolution(), TestFwdTrans< TData >::ExpectedSolution(), TestHelmSolve< TData >::ExpectedSolution(), TestLinearADRSolve< TData >::ExpectedSolution(), TestNormOps< TData >::ExpectedSolution(), TestPoissonSolve< TData >::ExpectedSolution(), TestAdvectionWeakDG< TData >::ExpectedSolution(), TestDiffusionIP< TData >::ExpectedSolution(), TestAdvectionDealias< TData >::ExpectedSolution(), TestAssmbScatr< TData >::ExpectedSolution(), TestDirichlet< TData >::ExpectedSolution(), TestNeumann< TData >::ExpectedSolution(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::FlattenBlocks(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::FlipParallelDirBndSign(), TestHelmholtz< TData >::HomogeneousTrans(), TestLaplacian< TData >::HomogeneousTrans(), TestLinAdvDiffReaction< TData >::HomogeneousTrans(), TestMath< TData >::inner_product(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::InteriorOp(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::InteriorOp(), Nektar::detail::DiffusionScalarIPTraceFluxOpImpl< ExecSpace, TData >::InteriorOp(), Nektar::detail::AdvDiffTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::InteriorOp(), Nektar::LibUtilities::Field< TData, TState >::InterleaveFromHostPtr(), TestMath< TData >::l1norm(), TestMath< TData >::l2norm(), TestMath< TData >::linfnorm(), TestMath< TData >::max(), TestParallelReduce< TData >::max(), TestMath< TData >::min(), TestParallelReduce< TData >::min(), TestMath< TData >::mul(), Nektar::MultiRegions::detail::AdvectionDealiasOpImpl< ExecSpace, TData >::MultiplyByAdvVelZ(), TestMath< TData >::neg(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::ParallelOp(), Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::ParallelOp(), Nektar::detail::DiffusionScalarIPTraceFluxOpImpl< ExecSpace, TData >::ParallelOp(), Nektar::detail::AdvDiffTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::ParallelOp(), TestAdvectionDealias< TData >::RunTestCase(), Nektar::MultiRegions::AdvectionOp< TData >::SetAdvVel(), Nektar::MultiRegions::AdvectionDealiasOp< TData >::SetAdvVel(), Nektar::MultiRegions::LinAdvDiffReactionOp< TData >::SetAdvVel(), TestParallelReduce< TData >::SetTestCase(), TestAdvection< TData >::SetTestCase(), TestAdvectionDealias< TData >::SetTestCase(), TestAvgAssmbScatr< TData >::SetTestCase(), TestBwdTrans< TData >::SetTestCase(), TestCurlCurl< TData >::SetTestCase(), TestDivergence< TData >::SetTestCase(), TestExpression< TData >::SetTestCase(), TestIProductWRTBase< TData >::SetTestCase(), TestIProductWRTDerivBase< TData >::SetTestCase(), TestIProductWRTPhysTrace< TData >::SetTestCase(), TestMass< TData >::SetTestCase(), TestMultiplyByElmtInvMass< TData >::SetTestCase(), TestPhysDeriv< TData >::SetTestCase(), TestPhysTraceExtract< TData >::SetTestCase(), TestPhysTraceExtractBndCond< TData >::SetTestCase(), TestFwdTrans< TData >::SetTestCase(), TestHelmSolve< TData >::SetTestCase(), TestLinearADRSolve< TData >::SetTestCase(), TestMaxStdVelocity< TData >::SetTestCase(), TestNormOps< TData >::SetTestCase(), TestPoissonSolve< TData >::SetTestCase(), TestAdvectionWeakDG< TData >::SetTestCase(), TestDiffusionIP< TData >::SetTestCase(), TestAssmbScatr< TData >::SetTestCase(), TestHelmholtz< TData >::SetTestCase(), TestLaplacian< TData >::SetTestCase(), TestLinAdvDiffReaction< TData >::SetTestCase(), TestTimeOps< TData >::SetTestCase(), TestPhysGalerkinProject1DScaled< TData >::SetTestCase(), TestPhysInterp1DScaled< TData >::SetTestCase(), TestIProductWRTPhysTrace< TData >::SetTestCaseDivTest(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::SetTraceAdvVel(), TestMath< TData >::sqrt(), TestMath< TData >::sub(), TestMath< TData >::sum(), TestParallelReduce< TData >::sum(), Nektar::LibUtilities::Field< TData, TState >::ToArray(), Nektar::LibUtilities::Field< TData, TState >::ToVector(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::UniversalAbsMaxDirBnd(), Nektar::MultiRegions::detail::AssmbScatrOpImpl< ExecSpace, TData, ZERODIR, SIGNCHANGE >::v_Apply(), Nektar::MultiRegions::detail::DirBndCondOpImpl< ExecSpace, TData >::v_Apply(), Nektar::MultiRegions::detail::NeuBndCondOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::ReynoldsStressOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::EnergyOpImpl< ExecSpace, TData >::v_Apply(), Nektar::MultiRegions::PhysLiftProjectOp< TData >::v_ApplyLift(), and Nektar::detail::AdvTraceFluxCFEOpImpl< RiemannKernel, EoSParamType, ExecSpace, TData >::v_ApplyUnitTest().

◆ GetNumHomoModes()

template<typename TData , FieldState TState>
unsigned int Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes ( ) const
inline

Gets the number of homogeneous modes.

Returns
unsigned int

Definition at line 693 of file LibUtilities/BasicUtils/Field/Field.hpp.

694 {
695 if (!m_instantiated)
696 {
698 "Field::GetNumHomoModes - Object has not been "
699 "instantiated by custom constructor.");
700 }
701
702 return m_num_homo_modes;
703 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, Nektar::LibUtilities::Field< TData, TState >::m_num_homo_modes, and NEKERROR.

Referenced by TestIProductWRTPhysTrace< TData >::AddPreFillPhys(), TestMath< TData >::Compare(), TestOp< TData, stateIn, stateOut, TExpList >::Compare(), TestLinearSolver< TData >::Compare(), TestPreconOps< TData >::Compare(), Nektar::LibUtilities::Field< TData, TState >::CopyArray(), Nektar::LibUtilities::Field< TData, TState >::CopyVector(), Nektar::LibUtilities::Field< TData, TState >::DeInterleaveToHostPtr(), TestAdvection< TData >::ExpectedSolution(), TestCurlCurl< TData >::ExpectedSolution(), TestDivergence< TData >::ExpectedSolution(), TestHelmholtz< TData >::ExpectedSolution(), TestIProductWRTDerivBase< TData >::ExpectedSolution(), TestLaplacian< TData >::ExpectedSolution(), TestLinAdvDiffReaction< TData >::ExpectedSolution(), TestMultiplyByElmtInvMass< TData >::ExpectedSolution(), TestPhysDeriv< TData >::ExpectedSolution(), TestFwdTrans< TData >::ExpectedSolution(), TestHelmSolve< TData >::ExpectedSolution(), TestLinearADRSolve< TData >::ExpectedSolution(), TestPoissonSolve< TData >::ExpectedSolution(), TestAdvectionDealias< TData >::ExpectedSolution(), TestHelmholtz< TData >::HomogeneousTrans(), TestLaplacian< TData >::HomogeneousTrans(), TestLinAdvDiffReaction< TData >::HomogeneousTrans(), Nektar::LibUtilities::Field< TData, TState >::InterleaveFromHostPtr(), TestAdvection< TData >::RunTestCase(), TestLinAdvDiffReaction< TData >::RunTestCase(), TestAdvectionDealias< TData >::RunTestCase(), Nektar::MultiRegions::AdvectionOp< TData >::SetAdvVel(), Nektar::MultiRegions::AdvectionDealiasOp< TData >::SetAdvVel(), Nektar::MultiRegions::LinAdvDiffReactionOp< TData >::SetAdvVel(), TestAdvection< TData >::SetTestCase(), TestAdvectionDealias< TData >::SetTestCase(), TestBwdTrans< TData >::SetTestCase(), TestCurlCurl< TData >::SetTestCase(), TestDivergence< TData >::SetTestCase(), TestExpression< TData >::SetTestCase(), TestIProductWRTBase< TData >::SetTestCase(), TestIProductWRTDerivBase< TData >::SetTestCase(), TestIProductWRTPhysTrace< TData >::SetTestCase(), TestMass< TData >::SetTestCase(), TestMultiplyByElmtInvMass< TData >::SetTestCase(), TestPhysDeriv< TData >::SetTestCase(), TestPhysTraceExtract< TData >::SetTestCase(), TestPhysTraceExtractBndCond< TData >::SetTestCase(), TestFwdTrans< TData >::SetTestCase(), TestHelmSolve< TData >::SetTestCase(), TestLinearADRSolve< TData >::SetTestCase(), TestNormOps< TData >::SetTestCase(), TestPoissonSolve< TData >::SetTestCase(), TestAdvectionWeakDG< TData >::SetTestCase(), TestDiffusionIP< TData >::SetTestCase(), TestHelmholtz< TData >::SetTestCase(), TestLaplacian< TData >::SetTestCase(), TestLinAdvDiffReaction< TData >::SetTestCase(), TestPhysGalerkinProject1DScaled< TData >::SetTestCase(), TestPhysInterp1DScaled< TData >::SetTestCase(), TestIProductWRTPhysTrace< TData >::SetTestCaseDivTest(), Nektar::LibUtilities::Field< TData, TState >::ToArray(), Nektar::LibUtilities::Field< TData, TState >::ToVector(), Nektar::detail::AeroForcesOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::ReynoldsStressOpImpl< ExecSpace, TData >::v_Apply(), Nektar::detail::EnergyOpImpl< ExecSpace, TData >::v_Apply(), and Nektar::MultiRegions::PhysLiftProjectOp< TData >::v_ApplyLift().

◆ Initialize()

template<typename TData , FieldState TState>
template<typename MemSpace >
void Nektar::LibUtilities::Field< TData, TState >::Initialize ( const TData  val,
const unsigned int  streamID = 0 
)
inline

Templated initialize method: set every entry to val, but the padding, which is zero.

Parameters
val- Value to set.
streamID- Stream every block is set on. 0, the default, sets each block on its own stream (block index + 1).

Definition at line 356 of file LibUtilities/BasicUtils/Field/Field.hpp.

357 {
358 if (!m_instantiated)
359 {
361 "Field::Initialize - Object has not been "
362 "instantiated by custom constructor.");
363 }
364
365 // If not yet allocated, allocate contiguous host OR device memory
366 // across all MemoryRegion objects within current Field object before
367 // data initialization.
368 AllocateFieldStorage<MemSpace>(this);
369
370 for (unsigned int blk = 0; blk < this->GetBlocks().size(); ++blk)
371 {
372 const unsigned int blkStreamID = streamID == 0 ? blk + 1 : streamID;
373 auto &block = this->GetBlocks()[blk];
374 block.m_memory_region.template Initialize<MemSpace>(val, 0, 0,
375 blkStreamID);
376 if (val != TData(0))
377 {
378 ZeroPadding<MemSpace>(block, blkStreamID);
379 }
380 }
381 }

References Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ InterleaveFromHostPtr()

template<typename TData , FieldState TState>
template<typename MemSpace , typename TDataIn >
void Nektar::LibUtilities::Field< TData, TState >::InterleaveFromHostPtr ( const TDataIn *  src,
const size_t  compSize 
)
inlineprotected

Copy data from host memory, laid out component by component and element by element without padding, to the storage in MemSpace. Each block is copied with an interleave width of 1 and its storage is then reshaped back to its own interleave width.

Parameters
src- host memory to copy from
compSize- number of values of one component in src

Definition at line 923 of file LibUtilities/BasicUtils/Field/Field.hpp.

924 {
925 const unsigned int nCompHomo =
926 this->GetNumComponents() * this->GetNumHomoModes();
927 const std::string execSpace =
928 std::is_same_v<MemSpace, NektarSpaces::HostSpace> ? "Serial"
929 : "Device";
930 for (unsigned int blk = 0; blk < this->GetBlocks().size(); ++blk)
931 {
932 const unsigned int streamID = blk + 1;
933 auto &block = this->GetBlocks()[blk];
934 const size_t nSize = block.CompSize();
935 const size_t nElmts = block.GetNumElements();
936 const unsigned int npts = block.GetNumData();
937 const unsigned int interleaveWidth = block.GetInterleaveWidth();
938 for (unsigned int n = 0; n < nCompHomo; ++n)
939 {
940 block.m_memory_region.template CopyFromHostPtr<MemSpace>(
941 src + n * compSize, nElmts * npts, n * nSize, streamID);
942 }
943 if (interleaveWidth != 1)
944 {
945 block.template SetInterleaveWidth<TData>(1);
946 block.ReshapeStorage(interleaveWidth, execSpace, streamID);
947 }
948 src += nElmts * npts;
949 }
950 }

References Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes().

◆ operator bool()

template<typename TData , FieldState TState>
Nektar::LibUtilities::Field< TData, TState >::operator bool ( ) const
inlineexplicit

Whether the field has been given storage by a custom constructor.

A default-constructed or moved-from field is not instantiated, and every other accessor errors on it - this is the one query that is valid either way, so a caller can test with if (field) before touching.

Definition at line 269 of file LibUtilities/BasicUtils/Field/Field.hpp.

270 {
271 return m_instantiated;
272 }

References Nektar::LibUtilities::Field< TData, TState >::m_instantiated.

◆ operator=() [1/2]

template<typename TData , FieldState TState>
Field & Nektar::LibUtilities::Field< TData, TState >::operator= ( const Field< TData, TState > &  )
delete

◆ operator=() [2/2]

template<typename TData , FieldState TState>
Field & Nektar::LibUtilities::Field< TData, TState >::operator= ( Field< TData, TState > &&  rhs)
inline

Move assignment operator.

Parameters
rhs
Returns
Field&

Definition at line 217 of file LibUtilities/BasicUtils/Field/Field.hpp.

218 {
219 if (this == &rhs)
220 {
221 return *this;
222 }
223
224 // The contiguous storage this field already owns is released before
225 // it takes over the storage of rhs; its blocks only point into it, so
226 // replacing the blocks and pointers alone would leak it. This has to
227 // come before the blocks are replaced: the device size is taken from
228 // them.
230
231 m_instantiated = std::move(rhs.m_instantiated);
232 m_name = std::move(rhs.m_name);
233 m_component_names = std::move(rhs.m_component_names);
234 m_num_homo_modes = std::move(rhs.m_num_homo_modes);
235 m_host = std::move(rhs.m_host);
236 m_device = std::move(rhs.m_device);
237 m_memAllocType = std::move(rhs.m_memAllocType);
238 m_block_accessors = std::move(rhs.m_block_accessors);
239 m_alignment = std::move(rhs.m_alignment);
240 m_sharedStorage = std::move(rhs.m_sharedStorage);
241 m_sharedStorageOffset = std::move(rhs.m_sharedStorageOffset);
242 for (auto &blocks : m_block_accessors)
243 {
244 blocks.m_field = this;
245 }
246
247 rhs.m_instantiated = false;
248 rhs.m_name = "";
249 rhs.m_component_names.clear();
250 rhs.m_num_homo_modes = 1;
251 rhs.m_host = nullptr;
252 rhs.m_device = nullptr;
253 rhs.m_block_accessors.clear();
254 rhs.m_memAllocType = eHostPageable;
255 rhs.m_alignment = NektarSpaces::host_memory_alignment;
256 rhs.m_sharedStorageOffset = 0;
257 return *this;
258 }

References Nektar::eHostPageable, Nektar::NektarSpaces::host_memory_alignment, Nektar::LibUtilities::Field< TData, TState >::m_alignment, Nektar::LibUtilities::Field< TData, TState >::m_block_accessors, Nektar::LibUtilities::Field< TData, TState >::m_component_names, Nektar::LibUtilities::Field< TData, TState >::m_device, Nektar::LibUtilities::Field< TData, TState >::m_host, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, Nektar::LibUtilities::Field< TData, TState >::m_memAllocType, Nektar::LibUtilities::Field< TData, TState >::m_name, Nektar::LibUtilities::Field< TData, TState >::m_num_homo_modes, Nektar::LibUtilities::Field< TData, TState >::m_sharedStorage, Nektar::LibUtilities::Field< TData, TState >::m_sharedStorageOffset, and Nektar::LibUtilities::Field< TData, TState >::ReleaseStorage().

◆ ReleaseStorage()

template<typename TData , FieldState TState>
void Nektar::LibUtilities::Field< TData, TState >::ReleaseStorage ( )
inlineprotected

Free the contiguous host and device storage this field owns, allocated by AllocateFieldStorage(), and mark the field uninstantiated.

The blocks' memory regions only point into this storage and do not own it; storage a block allocated for itself is freed with the block. Shared storage is not freed here, only released by this field.

Definition at line 716 of file LibUtilities/BasicUtils/Field/Field.hpp.

717 {
718 if (m_sharedStorage)
719 {
720 m_sharedStorage.reset();
721 }
722 else
723 {
724 if (m_device)
725 {
726 const unsigned int streamID = 0;
727 deviceFree(m_device, this->size() * sizeof(TData), streamID,
729 nekStreamSynchronize(streamID);
730 }
731
732 if (m_host)
733 {
735 {
737 }
738 else if (m_memAllocType == eHostPinned)
739 {
741 }
742 }
743 }
744
745 m_instantiated = false;
746 m_host = nullptr;
747 m_device = nullptr;
750 }
void deviceFree(TData *src, const size_t size, const unsigned int streamID, const MemAllocType memAllocType=eHostPageable)
void hostFreePinned(TData *src)
void hostFree(TData *src, const size_t alignment)

References Nektar::deviceFree(), Nektar::eHostPageable, Nektar::eHostPinned, Nektar::NektarSpaces::host_memory_alignment, Nektar::hostFree(), Nektar::hostFreePinned(), Nektar::LibUtilities::Field< TData, TState >::m_alignment, Nektar::LibUtilities::Field< TData, TState >::m_device, Nektar::LibUtilities::Field< TData, TState >::m_host, Nektar::LibUtilities::Field< TData, TState >::m_instantiated, Nektar::LibUtilities::Field< TData, TState >::m_memAllocType, Nektar::LibUtilities::Field< TData, TState >::m_sharedStorage, Nektar::LibUtilities::Field< TData, TState >::m_sharedStorageOffset, Nektar::nekStreamSynchronize(), and Nektar::LibUtilities::Field< TData, TState >::size().

Referenced by Nektar::LibUtilities::Field< TData, TState >::operator=(), and Nektar::LibUtilities::Field< TData, TState >::~Field().

◆ ReshapeStorage() [1/2]

template<typename TData , FieldState TState>
void Nektar::LibUtilities::Field< TData, TState >::ReshapeStorage ( const std::vector< unsigned int > &  interleaveWidths,
const std::string &  execSpace 
)
inline

Definition at line 333 of file LibUtilities/BasicUtils/Field/Field.hpp.

335 {
336 ASSERTL1(interleaveWidths.size() == this->GetBlocks().size(),
337 "Number of interleave widths does not match number of "
338 "blocks.");
339 for (unsigned int blk = 0; blk < this->GetBlocks().size(); ++blk)
340 {
341 const unsigned int streamID = blk + 1;
342 this->GetBlocks()[blk].ReshapeStorage(interleaveWidths[blk],
343 execSpace, streamID);
344 }
345 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....

References ASSERTL1, and Nektar::LibUtilities::Field< TData, TState >::GetBlocks().

◆ ReshapeStorage() [2/2]

template<typename TData , FieldState TState>
void Nektar::LibUtilities::Field< TData, TState >::ReshapeStorage ( const unsigned int &  interleaveWidth,
const std::string &  execSpace 
)
inline

◆ SetInterleaveWidth() [1/3]

template<typename TData , FieldState TState>
void Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth ( const std::vector< unsigned int > &  interleaveWidths)
inline

Definition at line 301 of file LibUtilities/BasicUtils/Field/Field.hpp.

302 {
303 ASSERTL1(interleaveWidths.size() == this->GetBlocks().size(),
304 "Number of interleave widths does not match number of "
305 "blocks.");
306 for (unsigned int blk = 0; blk < this->GetBlocks().size(); ++blk)
307 {
308 this->GetBlocks()[blk].template SetInterleaveWidth<TData>(
309 interleaveWidths[blk]);
310 }
311 }

References ASSERTL1, and Nektar::LibUtilities::Field< TData, TState >::GetBlocks().

◆ SetInterleaveWidth() [2/3]

template<typename TData , FieldState TState>
void Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth ( const unsigned int &  interleaveWidth)
inline

◆ SetInterleaveWidth() [3/3]

template<typename TData , FieldState TState>
void Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth ( Field< TData, TState > &  field)
inline

Definition at line 313 of file LibUtilities/BasicUtils/Field/Field.hpp.

314 {
315 for (unsigned int blk = 0; blk < this->GetBlocks().size(); ++blk)
316 {
317 this->GetBlocks()[blk].template SetInterleaveWidth<TData>(
318 field.GetBlocks()[blk].GetInterleaveWidth());
319 }
320 }

References Nektar::LibUtilities::Field< TData, TState >::GetBlocks().

◆ size()

template<typename TData , FieldState TState>
size_t Nektar::LibUtilities::Field< TData, TState >::size ( ) const
inline

◆ ToArray()

template<typename TData , FieldState TState>
template<typename TDataOut = TData>
Nektar::Array< Nektar::OneD, TDataOut > Nektar::LibUtilities::Field< TData, TState >::ToArray ( )
inline

Copy the data to a Nektar::Array, component by component and element by element, without padding, whatever the interleave width of each block.

Returns
Array<Nektar::OneD, TDataOut>

Definition at line 427 of file LibUtilities/BasicUtils/Field/Field.hpp.

428 {
429 if (!m_instantiated)
430 {
432 "Field::ToArray - Object has not been "
433 "instantiated by custom constructor.");
434 }
435
436 // If not yet allocated, allocate contiguous host memory across all
437 // MemoryRegion objects within current Field objects before data copy to
438 // NekArray.
439 AllocateFieldStorage<NektarSpaces::HostSpace>(this);
440
441 unsigned int compSize = 0;
442 for (auto &block : this->GetBlocks())
443 {
444 compSize += block.GetNumData() * block.GetNumElements();
445 }
446
448 compSize * this->GetNumComponents() * this->GetNumHomoModes());
449
450 DeInterleaveToHostPtr(array.data(), compSize);
451
452 return array;
453 }
void DeInterleaveToHostPtr(TDataOut *dst, const size_t compSize)
Copy the data to host memory, component by component and element by element, without padding....

References Nektar::LibUtilities::Field< TData, TState >::DeInterleaveToHostPtr(), Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by ApplyRiemannOperator(), TestAdvection< TData >::ExpectedSolution(), TestAvgAssmbScatr< TData >::ExpectedSolution(), TestBwdTrans< TData >::ExpectedSolution(), TestCurlCurl< TData >::ExpectedSolution(), TestDivergence< TData >::ExpectedSolution(), TestExpression< TData >::ExpectedSolution(), TestHelmholtz< TData >::ExpectedSolution(), TestIProductWRTBase< TData >::ExpectedSolution(), TestIProductWRTDerivBase< TData >::ExpectedSolution(), TestLaplacian< TData >::ExpectedSolution(), TestLinAdvDiffReaction< TData >::ExpectedSolution(), TestMass< TData >::ExpectedSolution(), TestMultiplyByElmtInvMass< TData >::ExpectedSolution(), TestPhysDeriv< TData >::ExpectedSolution(), TestPhysGalerkinProject1DScaled< TData >::ExpectedSolution(), TestPhysInterp1DScaled< TData >::ExpectedSolution(), TestFwdTrans< TData >::ExpectedSolution(), TestHelmSolve< TData >::ExpectedSolution(), TestLinearADRSolve< TData >::ExpectedSolution(), TestPoissonSolve< TData >::ExpectedSolution(), TestAdvectionWeakDG< TData >::ExpectedSolution(), TestDiffusionIP< TData >::ExpectedSolution(), TestAdvectionDealias< TData >::ExpectedSolution(), TestAssmbScatr< TData >::ExpectedSolution(), TestPreconOps< TData >::ExpectedSolution(), and TestAdvectionWeakDG< TData >::SetTestCase().

◆ ToVector()

template<typename TData , FieldState TState>
template<typename TDataOut = TData, class Alloc = std::allocator<TDataOut>>
std::vector< TDataOut, Alloc > Nektar::LibUtilities::Field< TData, TState >::ToVector ( )
inline

Copy the data to a std::vector, component by component and element by element, without padding, whatever the interleave width of each block.

Returns
std::vector

Definition at line 391 of file LibUtilities/BasicUtils/Field/Field.hpp.

392 {
393 if (!m_instantiated)
394 {
396 "Field::ToVector - Object has not been "
397 "instantiated by custom constructor.");
398 }
399
400 // If not yet allocated, allocate contiguous host memory across all
401 // MemoryRegion objects within current Field objects before data copy to
402 // vector.
403 AllocateFieldStorage<NektarSpaces::HostSpace>(this);
404
405 unsigned int compSize = 0;
406 for (auto &block : this->GetBlocks())
407 {
408 compSize += block.GetNumData() * block.GetNumElements();
409 }
410
411 std::vector<TDataOut, Alloc> array(compSize * this->GetNumComponents() *
412 this->GetNumHomoModes());
413
414 DeInterleaveToHostPtr(array.data(), compSize);
415
416 return array;
417 }

References Nektar::LibUtilities::Field< TData, TState >::DeInterleaveToHostPtr(), Nektar::ErrorUtil::efatal, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), Nektar::LibUtilities::Field< TData, TState >::GetNumHomoModes(), Nektar::LibUtilities::Field< TData, TState >::m_instantiated, and NEKERROR.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ ZeroPadding()

template<typename TData , FieldState TState>
template<typename MemSpace >
static void Nektar::LibUtilities::Field< TData, TState >::ZeroPadding ( BlockAccessor< TData, TState > &  block,
const unsigned int  streamID 
)
inlinestaticprivate

Zero the padding of block in place, in MemSpace.

Definition at line 973 of file LibUtilities/BasicUtils/Field/Field.hpp.

975 {
976 auto ptr = block.m_memory_region.template GetPtr<MemSpace, ReadWrite>(
977 streamID);
978 const unsigned int ncomp =
979 block.GetNumComponents() * block.GetNumHomoModes();
980 if constexpr (std::is_same_v<MemSpace, NektarSpaces::HostSpace>)
981 {
982 hostZeroPadding(ptr, ncomp, block.CompSize(),
983 block.GetNumElements(), block.GetNumData(),
984 block.GetInterleaveWidth());
985 }
986 else
987 {
988 deviceZeroPadding(ptr, ncomp, block.CompSize(),
989 block.GetNumElements(), block.GetNumData(),
990 block.GetInterleaveWidth(), streamID);
991 }
992 }
void deviceZeroPadding(TData *dst, const unsigned int ncomp, const size_t compSize, const size_t nelmt, const unsigned int ndata, const unsigned int width, const unsigned int streamID)
void hostZeroPadding(TData *dst, const unsigned int ncomp, const size_t compSize, const size_t nelmt, const unsigned int ndata, const unsigned int width)

Friends And Related Symbol Documentation

◆ BlockAccessor

template<typename TData , FieldState TState>
template<typename TDataField , FieldState TStateField>
friend class BlockAccessor
friend

◆ MultiField< TData, TState >

template<typename TData , FieldState TState>
friend class MultiField< TData, TState >
friend

Definition at line 973 of file LibUtilities/BasicUtils/Field/Field.hpp.

Member Data Documentation

◆ m_alignment

template<typename TData , FieldState TState>
size_t Nektar::LibUtilities::Field< TData, TState >::m_alignment = NektarSpaces::host_memory_alignment
protected

◆ m_block_accessors

template<typename TData , FieldState TState>
std::vector<BlockAccessor<TData, TState> > Nektar::LibUtilities::Field< TData, TState >::m_block_accessors
protected

◆ m_component_names

template<typename TData , FieldState TState>
std::vector<std::string> Nektar::LibUtilities::Field< TData, TState >::m_component_names
protected

◆ m_device

template<typename TData , FieldState TState>
TData* Nektar::LibUtilities::Field< TData, TState >::m_device = nullptr
protected

◆ m_host

template<typename TData , FieldState TState>
TData* Nektar::LibUtilities::Field< TData, TState >::m_host = nullptr
protected

◆ m_instantiated

template<typename TData , FieldState TState>
bool Nektar::LibUtilities::Field< TData, TState >::m_instantiated = false
protected

◆ m_memAllocType

template<typename TData , FieldState TState>
MemAllocType Nektar::LibUtilities::Field< TData, TState >::m_memAllocType
protected

◆ m_name

template<typename TData , FieldState TState>
std::string Nektar::LibUtilities::Field< TData, TState >::m_name
protected

◆ m_num_homo_modes

template<typename TData , FieldState TState>
unsigned int Nektar::LibUtilities::Field< TData, TState >::m_num_homo_modes = 1
protected

◆ m_sharedStorage

template<typename TData , FieldState TState>
std::shared_ptr<SharedFieldStorage<TData> > Nektar::LibUtilities::Field< TData, TState >::m_sharedStorage
protected

◆ m_sharedStorageOffset

template<typename TData , FieldState TState>
size_t Nektar::LibUtilities::Field< TData, TState >::m_sharedStorageOffset = 0
protected