VectorSingle.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #ifndef __VectorSingle_hpp__
23 #define __VectorSingle_hpp__
24 
25 #include "globalSettings.hpp"
26 #include "types.hpp"
27 #include "typeInfo.hpp"
28 #include "Vector.hpp"
29 #include "indexContainer.hpp"
30 
31 #include "KokkosTypes.hpp"
32 #include "ViewAlgorithms.hpp"
33 
34 
35 #ifndef __RESERVE__
36 #define __RESERVE__
37  struct RESERVE{};
38 #endif
39 
40 namespace pFlow
41 {
42 
43 
44 template<typename T, typename MemorySpace>
46 
47 
48 template<typename T, typename MemorySpace=void>
49 class VectorSingle
50 {
51 public:
52 
53  // viewType (view of data host and device)
55 
56  using iterator = T*;
57 
58  using constIterator = const T*;
59 
60  using reference = T&;
61 
62  using constReference = const T&;
63 
64  using valueType = T;
65 
66  using pointer = T*;
67 
68  using constPointer = const T*;
69 
70  // type defs related to Kokkos
72 
73  using deviceType = typename viewType::device_type;
74 
75  using memory_space = typename viewType::memory_space;
76 
77  using execution_space = typename viewType::execution_space;
78 
79 protected:
80 
81  size_t size_ = 0;
82 
83  size_t capacity_ = 0;
84 
86 
87  mutable viewType subView_;
88 
89  mutable bool subViewUpdated_ = false;
90 
91  static const inline real growthFactor_ = vectorGrowthFactor__;
92 
93  static constexpr bool isHostAccessible_ =
94  Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
95 
96  constexpr static inline const char* memoerySpaceName()
97  {
98  return memory_space::name();
99  }
100 
101  static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
102  {
103  return static_cast<size_t>(n*growthFactor_+1);
104  }
105 
106  // use actualCap = true only for reserve
107  INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
108  {
109  if(n >= capacity_ )
110  {
111  if(actualCap)
112  capacity_ = n;
113  else
115 
116  Kokkos::resize(view_, capacity_);
117  subViewUpdated_ = false;
118  }
119  if(!actualCap)
120  {
121  setSize(n);
122  }
123  }
124 
126  {
127  size_ = n;
128  subViewUpdated_ = false;
129  }
130 
131  // - update subview
133  {
134  if(subViewUpdated_) return;
135 
136  subView_ = Kokkos::subview(view_, Kokkos::make_pair(0,int(size_)));
137  subViewUpdated_ = true;
138  }
139 
140 
141 public:
142 
143  // - type info
144  TypeInfoTemplateNV2("VectorSingle", T, memoerySpaceName());
145 
147 
148  // - empty constructor
150  :
151  VectorSingle("VectorSingle")
152  {}
153 
154  // empty vector with a name
156  :
157  size_(0),
158  capacity_(2),
160  {
161  changeSize(size_);
162  }
163 
164  // - a vector with size n
165  VectorSingle(size_t n)
166  :
167  VectorSingle("VectorSingle",n)
168  {}
169 
170  // - a vector with name and size n
171  VectorSingle(const word& name, size_t n)
172  :
173  size_(n),
176  {
177  changeSize(size_);
178  }
179 
180  // a vector with size and value
181  VectorSingle(size_t n, const T& val)
182  :
183  VectorSingle("VectorSingle", n , val)
184  {}
185 
186  // a vector with name, size and value
187  VectorSingle(const word& name, size_t n, const T& val)
188  :
190  {
191  assign(n, val);
192  }
193 
194  // a vector with name and reserved capacity
195  VectorSingle(size_t cap, size_t n, RESERVE )
196  :
197  VectorSingle("VectorSingle", cap, n, RESERVE())
198  {}
199 
200 
201  // a vector with name and reserved capacity
202  VectorSingle(const word& name, size_t cap, size_t n, RESERVE )
203  :
205  {
206  reallocate(cap);
207  size_ = n;
208  }
209 
210  // - construct from pFlow::Vector (host memory)
211  VectorSingle(const Vector<T> & src)
212  :
213  VectorSingle("VectorSingle", src)
214  {}
215 
216  // - construct from pFlow::Vector and name
217  VectorSingle(const word& name, const Vector<T> & src)
218  :
220  {
221  assign(src);
222  }
223 
224  // - copy construct (perform deep copy)
226  :
227  VectorSingle(src.name(), src.capacity(), src.size(), RESERVE())
228  {
231  }
232 
233  // - copy construct with a new name
234  VectorSingle(const word& name, const VectorSingle& src)
235  :
236  VectorSingle(name, src.capacity(), src.size(), RESERVE())
237  {
240  }
241 
242  // - copy assignment
244  {
245  if(&rhs == this) return *this;
246  VectorSingle temp(rhs);
247  capacity_ = temp.capacity();
248  size_ = temp.size();
249  view_ = temp.view_;
250  subViewUpdated_ = false;
251 
252  return *this;
253  }
254 
255  // no move construct
256  VectorSingle(VectorSingle&&) = delete;
257 
258  // no move assignment
259  VectorSingle& operator= (VectorSingle&&) = delete;
260 
261 
262  // - clone as a uniquePtr
265  {
266  return makeUnique<VectorSingle>(*this);
267  }
268 
269  // - clone as a pointer
272  {
273  return new VectorSingle(*this);
274  }
275 
277 
278  // - return *this
281  {
282  return *this;
283  }
284 
285  // - return *this
287  const VectorType& VectorField()const
288  {
289  return *this;
290  }
291 
292 
293  // - Device vector range [0,capcity)
296  return view_;
297  }
298 
299  // - Device vector range [0,capacity)
301  const viewType& deviceVectorAll() const {
302  return view_;
303  }
304 
305  // - Device vector range [0, size)
308  updateSubView();
309  return subView_;
310  }
311 
312  // - Device vector range [0, size)
314  const viewType& deviceVector()const{
315  updateSubView();
316  return subView_;
317  }
318 
320  const auto hostVectorAll()const
321  {
322  auto hView = Kokkos::create_mirror_view(view_);
323  copy(hView, view_);
324  return hView;
325  }
326 
329  {
330  auto hView = Kokkos::create_mirror_view(view_);
331  copy(hView, view_);
332  return hView;
333  }
334 
336  const auto hostVector()const
337  {
338  auto hView = Kokkos::create_mirror_view(deviceVector());
339  copy(hView, deviceVector());
340  return hView;
341  }
342 
344  auto hostVector()
345  {
346  auto hView = Kokkos::create_mirror_view(deviceVector());
347  copy(hView, deviceVector());
348  return hView;
349  }
350 
351  // - name of vector
353  const word name()const
354  {
355  return view_.label();
356  }
357 
358  // - size of vector
360  size_t size()const
361  {
362  return size_;
363  }
364 
365  // - capcity of vector
367  size_t capacity()const
368  {
369  return capacity_;
370  }
371 
372  // - if vector is empty
374  bool empty()const
375  {
376  return size_==0;
377  }
378 
379  // - reserve capacity for vector
380  // preserve the content
382  void reserve(size_t cap)
383  {
384  changeSize(cap, true);
385  }
386 
387  // - reallocate memory
388  INLINE_FUNCTION_H void reallocate(size_t cap)
389  {
390  capacity_ = cap;
391  size_ = 0;
393  subViewUpdated_ = false;
394  }
395 
396  INLINE_FUNCTION_H void reallocate(size_t cap, size_t size)
397  {
398  capacity_ = cap;
399  size_ = size;
401  subViewUpdated_ = false;
402  }
403 
404  // resize the vector
406  void resize(size_t n){
407  changeSize(n);
408  }
409 
410  // resize the view and assign value to the most recent view (most updated)
412  void resize(size_t n, const T& val) {
413  assign(n, val);
414  }
415 
416  // - clear the vector
418  void clear() {
419  size_ = 0;
420  subViewUpdated_ = false;
421 
422  }
423 
424  // - fill the range [0,size) with val
426  void fill(const T& val)
427  {
428  if(empty())return;
429  pFlow::fill(deviceVectorAll(),0 ,size_ ,val);
430  }
431 
432  // - host calls only
433  // - assign n first elements to val
434  // resize view
435  // assign value to either side (device/host)
437  void assign(size_t n, const T& val)
438  {
439  if(capacity()<n)
440  {
441  this->reallocate(evalCapacity(n));
442  }
443  size_ = n;
444  this->fill(val);
445  }
446 
447  // - host calls only
448  // - assign source vector
449  // resize views
450  // assign to both sides (device&host)
452  {
453  auto srcSize = src.size();
454  if( capacity() < srcSize )
455  {
456  this->reallocate( src.capacity() );
457  }
458  size_ = srcSize;
459 
460  // - unmanaged view in the host
461  hostViewType1D<const T> temp(src.data(), srcSize );
462  copy(deviceVector(), temp);
463  }
464 
465 
466  //TODO: change it to parallel version
467  // - delete elements from vector
468  // similar memory spaces
469  /*template<class indT, class MSpace>
470  INLINE_FUNCTION_H
471  typename std::enable_if<
472  Kokkos::SpaceAccessibility<
473  execution_space, typename VectorSingle<indT,MSpace>::memory_space>::accessible,
474  bool>::type
475  deleteElement
476  (
477  const VectorSingle<indT,MSpace>& sortedIndices
478  )
479  {
480 
481  auto& indices = sortedIndices.deviceVectorAll();
482  auto& dVec = deviceVectorAll();
483  indT numInd = sortedIndices.size();
484  indT oldSize = this->size();
485 
486  if( numInd == 0 )return true;
487 
488  // an scalalr
489 
490  Kokkos::parallel_for(1, LAMBDA_HD(int nn)
491  {
492  (void)nn;
493  indT n = 0;
494  indT nextInd = indices[0];
495  indT j = indices[0];
496  for(label i=indices[0]; i < oldSize; ++i)
497  {
498  if( n < numInd && i == nextInd )
499  {
500  ++n;
501  nextInd = indices[n];
502  }
503  else
504  {
505  dVec[j] = dVec[i];
506  ++j;
507  }
508  }
509 
510  });
511  typename viewType::execution_space().fence();
512  size_ = oldSize - indices.size();
513  subViewUpdated_ = false;
514 
515  return true;
516  }
517 
518  // different memory spaces
519  template<class indT, class MSpace>
520  INLINE_FUNCTION_H
521  typename std::enable_if<
522  ! Kokkos::SpaceAccessibility<
523  execution_space, typename VectorSingle<indT,MSpace>::memory_space>::accessible,
524  bool>::type
525  deleteElement
526  (
527  const VectorSingle<indT,MSpace>& sortedIndices
528  )
529  {
530 
531  notImplementedFunction;
532  }*/
533 
535  bool insertSetElement(const int32IndexContainer& indices, const T& val)
536  {
537  if(indices.empty()) return true;
538  auto maxInd = indices.max();
539 
540  if(this->empty() || maxInd > size()-1 )
541  {
542  resize(maxInd+1);
543  }
544 
545  if constexpr (isHostAccessible_)
546  {
547  fillSelected(deviceVectorAll(), indices.hostView(), indices.size(), val);
548  return true;
549 
550  }else
551  {
552  fillSelected(deviceVectorAll(), indices.deviceView(), indices.size(), val);
553  return true;
554  }
555 
556  return false;
557  }
558 
560  bool insertSetElement(const int32IndexContainer& indices, const Vector<T>& vals)
561  {
562 
563  //Info<<"start of insertSetElement vecotsingle"<<endInfo;
564  if(indices.size() == 0)return true;
565  if(indices.size() != vals.size())return false;
566 
567  auto maxInd = indices.max();
568 
569  if(this->empty() || maxInd > size()-1 )
570  {
571  resize(maxInd+1);
572  }
573 
574 
575  hostViewType1D<const T> hVecVals( vals.data(), vals.size());
576  deviceViewType1D<T> dVecVals("dVecVals", indices.size());
577 
578  copy(dVecVals, hVecVals);
579 
580  using policy = Kokkos::RangePolicy<
582  Kokkos::IndexType<int32> >;
583  auto dVec = deviceVectorAll();
584  auto dIndex = indices.deviceView();
585 
586  Kokkos::parallel_for(
587  "insertSetElement",
588  policy(0,indices.size()), LAMBDA_HD(int32 i){
589  dVec(dIndex(i))= dVecVals(i);
590  });
591  Kokkos::fence();
592 
593  return true;
594 
595  }
596 
598  bool insertSetElement(const Vector<int32>& indices, const T& val)
599  {
600  if(indices.empty()) return true;
601 
602  auto maxInd = max(indices);
603 
604  if(this->empty() || maxInd > size()-1 )
605  {
606  resize(maxInd+1);
607  }
608 
609  if constexpr (isHostAccessible_)
610  {
611  hostViewType1D<int32> hostView(const_cast<int32*>(indices.data()), indices.size());
612  fillSelected(deviceVectorAll(), hostView, indices.size(), val);
613  return true;
614 
615  }else
616  {
617 
618  // TODO: remove the const_cast
619  hostViewType1D<int32> hostView(const_cast<int32*>(indices.data()), indices.size());
620  deviceViewType1D<int32> dView("dView", indices.size());
621  copy(dView, hostView);
622  fillSelected(deviceVectorAll(), dView, indices.size(), val);
623  return true;
624  }
625 
626  return false;
627  }
628 
630  bool insertSetElement(const Vector<int32>& indices, const Vector<T>& vals)
631  {
632  if(indices.size() == 0)return true;
633  if(indices.size() != vals.size())return false;
634 
635  auto maxInd = max(indices);
636 
637  if(this->empty() || maxInd > size()-1 )
638  {
639  resize(maxInd+1);
640  }
641 
642  if constexpr (isHostAccessible_)
643  {
644  // TODO: remove const_cast
645  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
646  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
647 
648  fillSelected(deviceVectorAll(), hVecInd, hVecVals, indices.size());
649  return true;
650 
651  }else
652  {
653 
654  // TODO: remove const_cast
655  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
656  deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
657 
658  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
659  deviceViewType1D<T> dVecVals("dVecVals", indices.size());
660 
661  copy(dVecVals, hVecVals);
662  copy(dVecInd, hVecInd);
663 
664  fillSelected(deviceVectorAll(), dVecInd, dVecVals, indices.size());
665  return true;
666  }
667 
668  return false;
669  }
670 
672  bool append(const deviceViewType1D<T>& dVec, size_t numElems)
673  {
674 
675  if(numElems == 0 )return true;
676  auto oldSize = size_;
677  auto newSize = size_ + numElems;
678 
679  if(this->empty() || newSize > capacity() )
680  {
681  resize(newSize);
682  }
683  else
684  {
685  size_ = size_+numElems;
686  }
687 
688  auto dSubView = Kokkos::subview(view_, Kokkos::make_pair(oldSize, newSize));
689  copy(dSubView, dVec);
690 
691  return true;
692  }
693 
695  bool append(const VectorSingle& Vec)
696  {
697  return append(Vec.deviceVector(), Vec.size());
698  }
699 
700  // - host calls only
701  // push a new element at the end
702  // resize if necessary
703  // works on host accessible vector
704  template<bool Enable = true>
705  typename std::enable_if<
706  isHostAccessible_ && Enable,
707  void>::type
708  push_back(const T& val)
709  {
711  data()[size_++] = val;
712  subViewUpdated_ = false;
713  }
714 
716  return view_.data();
717  }
718 
720  return view_.data();
721  }
722 
723  // - host calls only
724  // works on host accessible vector
725  // returns begin iterator
726  template<bool Enable = true>
728  typename std::enable_if_t<
729  isHostAccessible_ && Enable,
730  iterator>
731  begin(){
732  return data();
733  }
734 
735  // - host calls only
736  // works on host accessible vector
737  // returns begin iterator
738  template<bool Enable = true>
740  typename std::enable_if<
741  isHostAccessible_ && Enable,
742  constIterator>::type
743  begin()const {
744  return data();
745  }
746 
747  // - host calls only
748  // works on host accessible vector
749  // returns end iterator
750  template<bool Enable = true>
752  typename std::enable_if<
753  isHostAccessible_ && Enable,
754  iterator>::type
755  end(){
756  return size_ > 0 ? data() + size_: data();
757  }
758 
759  // host call
760  // returns end iterator
761  template<bool Enable = true>
763  typename std::enable_if<
764  isHostAccessible_ && Enable,
765  constIterator>::type
766  end()const{
767  return size_ > 0 ? data() + size_: data();
768  }
769 
770  // operator to be used on host side vectors
771  template<bool Enable = true>
773  typename std::enable_if<
774  isHostAccessible_ && Enable,
775  reference>::type
777  return view_[i];
778  }
779 
780  template<bool Enable = true>
782  typename std::enable_if<
783  isHostAccessible_ && Enable,
784  constReference>::type
785  operator[](label i)const{
786  return view_[i];
787  }
788 
790 
791  FUNCTION_H
792  bool read(iIstream& is)
793  {
794  Vector<T> vecFromFile;
795  if( !vecFromFile.read(is) ) return false;
796 
797  this->assign(vecFromFile);
798 
799  return true;
800  }
801 
802  FUNCTION_H
803  bool write(iOstream& os)const
804  {
805 
806  Vector<T, noConstructAllocator<T>> vecToFile(this->size());
807 
808  const auto dVec = Kokkos::subview(view_, Kokkos::make_pair(0,int(size_)));
809  hostViewType1D<T> mirror(vecToFile.data(), vecToFile.size());
810  copy(mirror,dVec);
811 
812  return vecToFile.write(os);
813  }
814 
815 }; // class VectorSingle
816 
817 template<typename T, typename MemorySpace>
819 {
820  if( !ivec.read(is) )
821  {
822  ioErrorInFile (is.name(), is.lineNumber());
823  fatalExit;
824  }
825  return is;
826 }
827 
828 template<typename T, typename MemorySpace>
830 {
831 
832  if( !ovec.write(os) )
833  {
834  ioErrorInFile(os.name(), os.lineNumber());
835  fatalExit;
836  }
837 
838  return os;
839 }
840 
841 
842 
843 
844 } // - pFlow
845 
847 
848 
849 #endif //__VectorSingle_hpp__
850 
pFlow::VectorSingle::hostVector
const INLINE_FUNCTION_H auto hostVector() const
Definition: VectorSingle.hpp:336
pFlow::vectorGrowthFactor__
const double vectorGrowthFactor__
Definition: globalSettings.hpp:29
pFlow::Vector::read
bool read(iIstream &is)
Definition: Vector.hpp:378
pFlow::VectorSingle::hostVector
INLINE_FUNCTION_H auto hostVector()
Definition: VectorSingle.hpp:344
pFlow::VectorSingle::VectorField
const INLINE_FUNCTION_H VectorType & VectorField() const
Definition: VectorSingle.hpp:287
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, size_t n, const T &val)
Definition: VectorSingle.hpp:187
pFlow::VectorSingle::fill
INLINE_FUNCTION_H void fill(const T &val)
Definition: VectorSingle.hpp:426
pFlow::VectorSingle::operator=
VectorSingle & operator=(const VectorSingle &rhs)
Definition: VectorSingle.hpp:243
pFlow::VectorSingle::iterator
T * iterator
Definition: VectorSingle.hpp:56
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, const Vector< T > &src)
Definition: VectorSingle.hpp:217
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::VectorSingle::resize
INLINE_FUNCTION_H void resize(size_t n, const T &val)
Definition: VectorSingle.hpp:412
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::VectorSingle::VectorSingle
VectorSingle()
Definition: VectorSingle.hpp:149
pFlow::VectorSingle::hostVectorAll
const INLINE_FUNCTION_H auto hostVectorAll() const
Definition: VectorSingle.hpp:320
pFlow::indexContainer::max
INLINE_FUNCTION_HD IndexType max() const
Definition: indexContainer.hpp:125
pFlow::VectorSingle< realx3, void >::deviceType
typename viewType::device_type deviceType
Definition: VectorSingle.hpp:73
pFlow::VectorSingle::constReference
const T & constReference
Definition: VectorSingle.hpp:62
pFlow::indexContainer::empty
INLINE_FUNCTION_HD size_t empty() const
Definition: indexContainer.hpp:113
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, const VectorSingle &src)
Definition: VectorSingle.hpp:234
pFlow::VectorSingle::setSize
INLINE_FUNCTION_H void setSize(size_t n)
Definition: VectorSingle.hpp:125
types.hpp
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(const Vector< T > &src)
Definition: VectorSingle.hpp:451
pFlow::VectorSingle::name
const INLINE_FUNCTION_H word name() const
Definition: VectorSingle.hpp:353
pFlow::copy
INLINE_FUNCTION_H void copy(const ViewType1D< dType, dProperties... > &dst, const ViewType1D< sType, sProperties... > &src)
Definition: ViewAlgorithms.hpp:296
pFlow::VectorSingle::clear
INLINE_FUNCTION_H void clear()
Definition: VectorSingle.hpp:418
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const Vector< T > &vals)
Definition: VectorSingle.hpp:560
pFlow::VectorSingle::data
INLINE_FUNCTION_H constPointer data() const
Definition: VectorSingle.hpp:719
ViewAlgorithms.hpp
pFlow::VectorSingle::read
FUNCTION_H bool read(iIstream &is)
Definition: VectorSingle.hpp:792
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::VectorSingle::subViewUpdated_
bool subViewUpdated_
Definition: VectorSingle.hpp:89
pFlow::VectorSingle::resize
INLINE_FUNCTION_H void resize(size_t n)
Definition: VectorSingle.hpp:406
pFlow::VectorSingle::deviceVectorAll
const INLINE_FUNCTION_H viewType & deviceVectorAll() const
Definition: VectorSingle.hpp:301
pFlow::VectorSingle::begin
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constIterator >::type begin() const
Definition: VectorSingle.hpp:743
KokkosTypes.hpp
pFlow::VectorSingle::clonePtr
INLINE_FUNCTION_H VectorSingle * clonePtr() const
Definition: VectorSingle.hpp:271
pFlow::indexContainer::size
INLINE_FUNCTION_HD size_t size() const
Definition: indexContainer.hpp:107
pFlow::VectorSingle::deviceVector
const INLINE_FUNCTION_H viewType & deviceVector() const
Definition: VectorSingle.hpp:314
pFlow::Vector::size
auto size() const
Definition: Vector.hpp:299
pFlow::reallocNoInit
INLINE_FUNCTION_H void reallocNoInit(ViewType1D< Type, Properties... > &view, int32 len)
Definition: KokkosUtilities.hpp:60
pFlow::VectorSingle::hostVectorAll
INLINE_FUNCTION_H auto hostVectorAll()
Definition: VectorSingle.hpp:328
pFlow::VectorSingle::VectorSingle
VectorSingle(size_t n)
Definition: VectorSingle.hpp:165
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H size_t capacity() const
Definition: VectorSingle.hpp:367
pFlow::VectorSingle::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: VectorSingle.hpp:96
pFlow::VectorSingle::clone
INLINE_FUNCTION_H uniquePtr< VectorSingle > clone() const
Definition: VectorSingle.hpp:264
pFlow::VectorSingle::size_
size_t size_
Definition: VectorSingle.hpp:81
pFlow::VectorSingle::empty
INLINE_FUNCTION_H bool empty() const
Definition: VectorSingle.hpp:374
pFlow::VectorSingle::append
INLINE_FUNCTION_H bool append(const VectorSingle &Vec)
Definition: VectorSingle.hpp:695
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
pFlow::VectorSingle< realx3, void >::memory_space
typename viewType::memory_space memory_space
Definition: VectorSingle.hpp:75
pFlow
Definition: demComponent.hpp:28
pFlow::VectorSingle< realx3, void >::execution_space
typename viewType::execution_space execution_space
Definition: VectorSingle.hpp:77
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const T &val)
Definition: VectorSingle.hpp:598
RESERVE
Definition: Vector.hpp:38
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name)
Definition: VectorSingle.hpp:155
pFlow::VectorSingle::operator[]
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constReference >::type operator[](label i) const
Definition: VectorSingle.hpp:785
pFlow::VectorSingle::VectorField
INLINE_FUNCTION_H VectorType & VectorField()
Definition: VectorSingle.hpp:280
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::VectorSingle::reference
T & reference
Definition: VectorSingle.hpp:60
globalSettings.hpp
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, size_t n)
Definition: VectorSingle.hpp:171
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::VectorSingle::data
INLINE_FUNCTION_H pointer data()
Definition: VectorSingle.hpp:715
pFlow::indexContainer::hostView
const HostViewType & hostView() const
Definition: indexContainer.hpp:143
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::Vector::capacity
auto capacity() const
Definition: Vector.hpp:304
pFlow::VectorSingle::VectorSingle
VectorSingle(const VectorSingle &src)
Definition: VectorSingle.hpp:225
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::VectorSingle::reserve
INLINE_FUNCTION_H void reserve(size_t cap)
Definition: VectorSingle.hpp:382
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
Definition: VectorSingle.hpp:535
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, size_t cap, size_t n, RESERVE)
Definition: VectorSingle.hpp:202
pFlow::VectorSingle::constIterator
const T * constIterator
Definition: VectorSingle.hpp:58
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::VectorSingle
Definition: VectorSingle.hpp:45
pFlow::VectorSingle::end
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, iterator >::type end()
Definition: VectorSingle.hpp:755
pFlow::VectorSingle::operator[]
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, reference >::type operator[](label i)
Definition: VectorSingle.hpp:776
pFlow::VectorSingle::push_back
std::enable_if< isHostAccessible_ &&Enable, void >::type push_back(const T &val)
Definition: VectorSingle.hpp:708
pFlow::VectorSingle::subView_
viewType subView_
Definition: VectorSingle.hpp:87
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pFlow::VectorSingle::updateSubView
INLINE_FUNCTION_H void updateSubView() const
Definition: VectorSingle.hpp:132
pFlow::VectorSingle::TypeInfoTemplateNV2
TypeInfoTemplateNV2("VectorSingle", T, memoerySpaceName())
pFlow::VectorSingle::reallocate
INLINE_FUNCTION_H void reallocate(size_t cap)
Definition: VectorSingle.hpp:388
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
Definition: KokkosTypes.hpp:104
pFlow::VectorSingle::append
INLINE_FUNCTION_H bool append(const deviceViewType1D< T > &dVec, size_t numElems)
Definition: VectorSingle.hpp:672
pFlow::Vector::write
bool write(iOstream &os) const
Definition: Vector.hpp:383
pFlow::VectorSingle::VectorSingle
VectorSingle(size_t n, const T &val)
Definition: VectorSingle.hpp:181
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(size_t n, const T &val)
Definition: VectorSingle.hpp:437
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::VectorSingle::evalCapacity
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
Definition: VectorSingle.hpp:101
pFlow::VectorSingle::changeSize
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
Definition: VectorSingle.hpp:107
pFlow::VectorSingle::growthFactor_
static const real growthFactor_
Definition: VectorSingle.hpp:91
pFlow::VectorSingle::write
FUNCTION_H bool write(iOstream &os) const
Definition: VectorSingle.hpp:803
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const Vector< T > &vals)
Definition: VectorSingle.hpp:630
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
typeInfo.hpp
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
Definition: KokkosTypes.hpp:62
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::VectorSingle::end
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constIterator >::type end() const
Definition: VectorSingle.hpp:766
VectorSingleAlgorithms.hpp
pFlow::VectorSingle::deviceVector
INLINE_FUNCTION_H viewType & deviceVector()
Definition: VectorSingle.hpp:307
pFlow::VectorSingle::size
INLINE_FUNCTION_H size_t size() const
Definition: VectorSingle.hpp:360
pFlow::VectorSingle::begin
INLINE_FUNCTION_H std::enable_if_t< isHostAccessible_ &&Enable, iterator > begin()
Definition: VectorSingle.hpp:731
pFlow::VectorSingle::isHostAccessible_
static constexpr bool isHostAccessible_
Definition: VectorSingle.hpp:93
pFlow::VectorSingle::deviceVectorAll
INLINE_FUNCTION_H viewType & deviceVectorAll()
Definition: VectorSingle.hpp:295
pFlow::VectorSingle::VectorSingle
VectorSingle(const Vector< T > &src)
Definition: VectorSingle.hpp:211
pFlow::triple< real >
pFlow::Vector
Definition: Vector.hpp:46
pFlow::VectorSingle::VectorSingle
VectorSingle(size_t cap, size_t n, RESERVE)
Definition: VectorSingle.hpp:195
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::VectorSingle::capacity_
size_t capacity_
Definition: VectorSingle.hpp:83
indexContainer.hpp
pFlow::fillSelected
bool fillSelected(ViewType1D< Type, properties... > view, const ViewType1D< indexType, indexProperties... > indices, const int32 numElems, const Type val, typename std::enable_if_t< areAccessible< typename ViewType1D< Type, properties... >::execution_space, typename ViewType1D< indexType, indexProperties... >::memory_space >(), bool >=true)
Definition: ViewAlgorithms.hpp:147
Vector.hpp
pFlow::indexContainer< int32 >
pFlow::VectorSingle::reallocate
INLINE_FUNCTION_H void reallocate(size_t cap, size_t size)
Definition: VectorSingle.hpp:396
pFlow::indexContainer::deviceView
const DeviceViewType & deviceView() const
Definition: indexContainer.hpp:148
pFlow::VectorSingle< realx3, void >::viewType
ViewType1D< realx3, void > viewType
Definition: VectorSingle.hpp:71
pFlow::VectorSingle::view_
viewType view_
Definition: VectorSingle.hpp:85