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 "streams.hpp"
32 
33 #include "KokkosTypes.hpp"
34 #include "ViewAlgorithms.hpp"
35 
36 
37 #ifndef __RESERVE__
38 #define __RESERVE__
39  struct RESERVE{};
40 #endif
41 
42 namespace pFlow
43 {
44 
45 
46 template<typename T, typename MemorySpace>
48 
49 
50 template<typename T, typename MemorySpace=void>
51 class VectorSingle
52 {
53 public:
54 
55  // viewType (view of data host and device)
57 
58  using iterator = T*;
59 
60  using constIterator = const T*;
61 
62  using reference = T&;
63 
64  using constReference = const T&;
65 
66  using valueType = T;
67 
68  using pointer = T*;
69 
70  using constPointer = const T*;
71 
72  // type defs related to Kokkos
74 
75  using deviceType = typename viewType::device_type;
76 
77  using memory_space = typename viewType::memory_space;
78 
79  using execution_space = typename viewType::execution_space;
80 
81 protected:
82 
83  size_t size_ = 0;
84 
85  size_t capacity_ = 0;
86 
88 
89  mutable viewType subView_;
90 
91  mutable bool subViewUpdated_ = false;
92 
93  static const inline real growthFactor_ = vectorGrowthFactor__;
94 
95  static constexpr bool isHostAccessible_ =
96  Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
97 
98  constexpr static inline const char* memoerySpaceName()
99  {
100  return memory_space::name();
101  }
102 
103  static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
104  {
105  return static_cast<size_t>(n*growthFactor_+1);
106  }
107 
108  // use actualCap = true only for reserve
109  INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
110  {
111  if(n > capacity_ )
112  {
113  if(actualCap)
114  capacity_ = n;
115  else
117 
118  Kokkos::resize(view_, capacity_);
119  subViewUpdated_ = false;
120  }
121  if(!actualCap)
122  {
123  setSize(n);
124  }
125  }
126 
128  {
129  size_ = n;
130  subViewUpdated_ = false;
131  }
132 
133  // - update subview
135  {
136  if(subViewUpdated_) return;
137 
138  subView_ = Kokkos::subview(view_, Kokkos::make_pair(0,int(size_)));
139  subViewUpdated_ = true;
140  }
141 
142 
143 public:
144 
145  // - type info
146  TypeInfoTemplateNV2("VectorSingle", T, memoerySpaceName());
147 
149 
150  // - empty constructor
152  :
153  VectorSingle("VectorSingle")
154  {}
155 
156  // empty vector with a name
158  :
159  size_(0),
160  capacity_(2),
162  {
163  changeSize(size_);
164  }
165 
166  // - a vector with size n
167  VectorSingle(size_t n)
168  :
169  VectorSingle("VectorSingle",n)
170  {}
171 
172  // - a vector with name and size n
173  VectorSingle(const word& name, size_t n)
174  :
175  size_(n),
178  {
179  changeSize(size_);
180  }
181 
182  // a vector with size and value
183  VectorSingle(size_t n, const T& val)
184  :
185  VectorSingle("VectorSingle", n , val)
186  {}
187 
188  // a vector with name, size and value
189  VectorSingle(const word& name, size_t n, const T& val)
190  :
192  {
193  assign(n, val);
194  }
195 
196  // a vector with name and reserved capacity
197  VectorSingle(size_t cap, size_t n, RESERVE )
198  :
199  VectorSingle("VectorSingle", cap, n, RESERVE())
200  {}
201 
202 
203  // a vector with name and reserved capacity
204  VectorSingle(const word& name, size_t cap, size_t n, RESERVE )
205  :
207  {
208  reallocate(cap);
209  size_ = n;
210  }
211 
212  // - construct from pFlow::Vector (host memory)
213  VectorSingle(const Vector<T> & src)
214  :
215  VectorSingle("VectorSingle", src)
216  {}
217 
218  // - construct from pFlow::Vector and name
219  VectorSingle(const word& name, const Vector<T> & src)
220  :
222  {
223  assign(src);
224  }
225 
226  // - copy construct (perform deep copy)
228  :
229  VectorSingle(src.name(), src.capacity(), src.size(), RESERVE())
230  {
233  }
234 
235  // - copy construct with a new name
236  VectorSingle(const word& name, const VectorSingle& src)
237  :
238  VectorSingle(name, src.capacity(), src.size(), RESERVE())
239  {
242  }
243 
244  // - copy assignment
246  {
247  if(&rhs == this) return *this;
248  VectorSingle temp(rhs);
249  capacity_ = temp.capacity();
250  size_ = temp.size();
251  view_ = temp.view_;
252  subViewUpdated_ = false;
253 
254  return *this;
255  }
256 
257  // no move construct
258  VectorSingle(VectorSingle&&) = delete;
259 
260  // no move assignment
261  VectorSingle& operator= (VectorSingle&&) = delete;
262 
263 
264  // - clone as a uniquePtr
267  {
268  return makeUnique<VectorSingle>(*this);
269  }
270 
271  // - clone as a pointer
274  {
275  return new VectorSingle(*this);
276  }
277 
279 
280  // - return *this
283  {
284  return *this;
285  }
286 
287  // - return *this
289  const VectorType& VectorField()const
290  {
291  return *this;
292  }
293 
294 
295  // - Device vector range [0,capcity)
298  return view_;
299  }
300 
301  // - Device vector range [0,capacity)
303  const viewType& deviceVectorAll() const {
304  return view_;
305  }
306 
307  // - Device vector range [0, size)
310  updateSubView();
311  return subView_;
312  }
313 
314  // - Device vector range [0, size)
316  const viewType& deviceVector()const{
317  updateSubView();
318  return subView_;
319  }
320 
322  const auto hostVectorAll()const
323  {
324  auto hView = Kokkos::create_mirror_view(view_);
325  copy(hView, view_);
326  return hView;
327  }
328 
331  {
332  auto hView = Kokkos::create_mirror_view(view_);
333  copy(hView, view_);
334  return hView;
335  }
336 
338  const auto hostVector()const
339  {
340  auto hView = Kokkos::create_mirror_view(deviceVector());
341  copy(hView, deviceVector());
342  return hView;
343  }
344 
346  auto hostVector()
347  {
348  auto hView = Kokkos::create_mirror_view(deviceVector());
349  copy(hView, deviceVector());
350  return hView;
351  }
352 
353  // - name of vector
355  const word name()const
356  {
357  return view_.label();
358  }
359 
360  // - size of vector
362  size_t size()const
363  {
364  return size_;
365  }
366 
367  // - capcity of vector
369  size_t capacity()const
370  {
371  return capacity_;
372  }
373 
374  // - if vector is empty
376  bool empty()const
377  {
378  return size_==0;
379  }
380 
381  // - reserve capacity for vector
382  // preserve the content
384  void reserve(size_t cap)
385  {
386  changeSize(cap, true);
387  }
388 
389  // - reallocate memory
390  INLINE_FUNCTION_H void reallocate(size_t cap)
391  {
392  capacity_ = cap;
393  size_ = 0;
395  subViewUpdated_ = false;
396  }
397 
398  INLINE_FUNCTION_H void reallocate(size_t cap, size_t size)
399  {
400  capacity_ = cap;
401  size_ = size;
403  subViewUpdated_ = false;
404  }
405 
406  // resize the vector
408  void resize(size_t n){
409  changeSize(n);
410  }
411 
412  // resize the view and assign value to the most recent view (most updated)
414  void resize(size_t n, const T& val) {
415  assign(n, val);
416  }
417 
418  // - clear the vector
420  void clear() {
421  size_ = 0;
422  subViewUpdated_ = false;
423 
424  }
425 
426  // - fill the range [0,size) with val
428  void fill(const T& val)
429  {
430  if(empty())return;
431  pFlow::fill(deviceVectorAll(),0 ,size_ ,val);
432  }
433 
434  // - host calls only
435  // - assign n first elements to val
436  // resize view
437  // assign value to either side (device/host)
439  void assign(size_t n, const T& val)
440  {
441  if(capacity()<n)
442  {
443  this->reallocate(evalCapacity(n));
444  }
445  size_ = n;
446  this->fill(val);
447  }
448 
449  // - host calls only
450  // - assign source vector
451  // resize views
452  // assign to both sides (device&host)
454  {
455  auto srcSize = src.size();
456  if( capacity() < srcSize )
457  {
458  this->reallocate( src.capacity() );
459  }
460  size_ = srcSize;
461 
462  // - unmanaged view in the host
463  hostViewType1D<const T> temp(src.data(), srcSize );
464  copy(deviceVector(), temp);
465  }
466 
467 
468  //TODO: change it to parallel version
469  // - delete elements from vector
470  // similar memory spaces
471  /*template<class indT, class MSpace>
472  INLINE_FUNCTION_H
473  typename std::enable_if<
474  Kokkos::SpaceAccessibility<
475  execution_space, typename VectorSingle<indT,MSpace>::memory_space>::accessible,
476  bool>::type
477  deleteElement
478  (
479  const VectorSingle<indT,MSpace>& sortedIndices
480  )
481  {
482 
483  auto& indices = sortedIndices.deviceVectorAll();
484  auto& dVec = deviceVectorAll();
485  indT numInd = sortedIndices.size();
486  indT oldSize = this->size();
487 
488  if( numInd == 0 )return true;
489 
490  // an scalalr
491 
492  Kokkos::parallel_for(1, LAMBDA_HD(int nn)
493  {
494  (void)nn;
495  indT n = 0;
496  indT nextInd = indices[0];
497  indT j = indices[0];
498  for(label i=indices[0]; i < oldSize; ++i)
499  {
500  if( n < numInd && i == nextInd )
501  {
502  ++n;
503  nextInd = indices[n];
504  }
505  else
506  {
507  dVec[j] = dVec[i];
508  ++j;
509  }
510  }
511 
512  });
513  typename viewType::execution_space().fence();
514  size_ = oldSize - indices.size();
515  subViewUpdated_ = false;
516 
517  return true;
518  }
519 
520  // different memory spaces
521  template<class indT, class MSpace>
522  INLINE_FUNCTION_H
523  typename std::enable_if<
524  ! Kokkos::SpaceAccessibility<
525  execution_space, typename VectorSingle<indT,MSpace>::memory_space>::accessible,
526  bool>::type
527  deleteElement
528  (
529  const VectorSingle<indT,MSpace>& sortedIndices
530  )
531  {
532 
533  notImplementedFunction;
534  }*/
535 
537  bool insertSetElement(const int32IndexContainer& indices, const T& val)
538  {
539  if(indices.empty()) return true;
540  auto maxInd = indices.max();
541 
542  if(this->empty() || maxInd > size()-1 )
543  {
544  resize(maxInd+1);
545  }
546 
547  if constexpr (isHostAccessible_)
548  {
549  fillSelected(deviceVectorAll(), indices.hostView(), indices.size(), val);
550  return true;
551 
552  }else
553  {
554  fillSelected(deviceVectorAll(), indices.deviceView(), indices.size(), val);
555  return true;
556  }
557 
558  return false;
559  }
560 
562  void sortItems(const int32IndexContainer& indices)
563  {
564  if(indices.size() == 0)
565  {
566  setSize(0);
567  return;
568  }
569 
570  size_t newSize = indices.size();
571  viewType sortedView("sortedView", newSize);
572 
573  using policy = Kokkos::RangePolicy<
575  Kokkos::IndexType<int32> >;
576 
577  auto d_indices = indices.deviceView();
578  auto d_view = view_;
579  Kokkos::parallel_for(
580  "sortItems",
581  newSize,
582  LAMBDA_HD(int32 i){
583  sortedView(i) = d_view(d_indices(i));
584  });
585 
586  Kokkos::fence();
587 
588  setSize(newSize);
589 
590  copy(deviceVector(), sortedView);
591 
592  return;
593 
594  }
595 
597  bool insertSetElement(const int32IndexContainer& indices, const Vector<T>& vals)
598  {
599 
600  //Info<<"start of insertSetElement vecotsingle"<<endInfo;
601  if(indices.size() == 0)return true;
602  if(indices.size() != vals.size())return false;
603 
604  auto maxInd = indices.max();
605  /*output<<"maxInd "<< maxInd<<endl;
606  output<<"size() "<< size()<<endl;*/
607  if(this->empty() || maxInd > size()-1 )
608  {
609  resize(maxInd+1);
610  }
611 
612 
613  hostViewType1D<const T> hVecVals( vals.data(), vals.size());
614  deviceViewType1D<T> dVecVals("dVecVals", indices.size());
615 
616  copy(dVecVals, hVecVals);
617 
618  using policy = Kokkos::RangePolicy<
620  Kokkos::IndexType<int32> >;
621  auto dVec = deviceVectorAll();
622  auto dIndex = indices.deviceView();
623 
624  Kokkos::parallel_for(
625  "insertSetElement",
626  policy(0,indices.size()), LAMBDA_HD(int32 i){
627  dVec(dIndex(i))= dVecVals(i);
628  });
629  Kokkos::fence();
630 
631  return true;
632 
633  }
634 
636  bool insertSetElement(const Vector<int32>& indices, const T& val)
637  {
638  if(indices.empty()) return true;
639 
640  auto maxInd = max(indices);
641 
642  if(this->empty() || maxInd > size()-1 )
643  {
644  resize(maxInd+1);
645  }
646 
647  if constexpr (isHostAccessible_)
648  {
649  hostViewType1D<int32> hostView(const_cast<int32*>(indices.data()), indices.size());
650  fillSelected(deviceVectorAll(), hostView, indices.size(), val);
651  return true;
652 
653  }else
654  {
655 
656  // TODO: remove the const_cast
657  hostViewType1D<int32> hostView(const_cast<int32*>(indices.data()), indices.size());
658  deviceViewType1D<int32> dView("dView", indices.size());
659  copy(dView, hostView);
660  fillSelected(deviceVectorAll(), dView, indices.size(), val);
661  return true;
662  }
663 
664  return false;
665  }
666 
668  bool insertSetElement(const Vector<int32>& indices, const Vector<T>& vals)
669  {
670  if(indices.size() == 0)return true;
671  if(indices.size() != vals.size())return false;
672 
673  auto maxInd = max(indices);
674 
675  if(this->empty() || maxInd > size()-1 )
676  {
677  resize(maxInd+1);
678  }
679 
680  if constexpr (isHostAccessible_)
681  {
682  // TODO: remove const_cast
683  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
684  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
685 
686  fillSelected(deviceVectorAll(), hVecInd, hVecVals, indices.size());
687  return true;
688 
689  }else
690  {
691 
692  // TODO: remove const_cast
693  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
694  deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
695 
696  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
697  deviceViewType1D<T> dVecVals("dVecVals", indices.size());
698 
699  copy(dVecVals, hVecVals);
700  copy(dVecInd, hVecInd);
701 
702  fillSelected(deviceVectorAll(), dVecInd, dVecVals, indices.size());
703  return true;
704  }
705 
706  return false;
707  }
708 
710  bool append(const deviceViewType1D<T>& dVec, size_t numElems)
711  {
712 
713  if(numElems == 0 )return true;
714  auto oldSize = size_;
715  auto newSize = size_ + numElems;
716 
717  if(this->empty() || newSize > capacity() )
718  {
719  resize(newSize);
720  }
721  else
722  {
723  size_ = size_+numElems;
724  }
725 
726  auto dSubView = Kokkos::subview(view_, Kokkos::make_pair(oldSize, newSize));
727  copy(dSubView, dVec);
728 
729  return true;
730  }
731 
733  bool append(const VectorSingle& Vec)
734  {
735  return append(Vec.deviceVector(), Vec.size());
736  }
737 
738  // - host calls only
739  // push a new element at the end
740  // resize if necessary
741  // works on host accessible vector
742  template<bool Enable = true>
743  typename std::enable_if<
744  isHostAccessible_ && Enable,
745  void>::type
746  push_back(const T& val)
747  {
748  if(size_ == capacity_)
749  {
751  }
752  data()[size_++] = val;
753  subViewUpdated_ = false;
754  }
755 
757  return view_.data();
758  }
759 
761  return view_.data();
762  }
763 
764  // - host calls only
765  // works on host accessible vector
766  // returns begin iterator
767  template<bool Enable = true>
769  typename std::enable_if_t<
770  isHostAccessible_ && Enable,
771  iterator>
772  begin(){
773  return data();
774  }
775 
776  // - host calls only
777  // works on host accessible vector
778  // returns begin iterator
779  template<bool Enable = true>
781  typename std::enable_if<
782  isHostAccessible_ && Enable,
783  constIterator>::type
784  begin()const {
785  return data();
786  }
787 
788  // - host calls only
789  // works on host accessible vector
790  // returns end iterator
791  template<bool Enable = true>
793  typename std::enable_if<
794  isHostAccessible_ && Enable,
795  iterator>::type
796  end(){
797  return size_ > 0 ? data() + size_: data();
798  }
799 
800  // host call
801  // returns end iterator
802  template<bool Enable = true>
804  typename std::enable_if<
805  isHostAccessible_ && Enable,
806  constIterator>::type
807  end()const{
808  return size_ > 0 ? data() + size_: data();
809  }
810 
811  // operator to be used on host side vectors
812  template<bool Enable = true>
814  typename std::enable_if<
815  isHostAccessible_ && Enable,
816  reference>::type
818  return view_[i];
819  }
820 
821  template<bool Enable = true>
823  typename std::enable_if<
824  isHostAccessible_ && Enable,
825  constReference>::type
826  operator[](label i)const{
827  return view_[i];
828  }
829 
831 
832  FUNCTION_H
834  iIstream& is,
835  size_t len=0)
836  {
837  Vector<T> vecFromFile;
838  if( !vecFromFile.readVector(is,len) ) return false;
839 
840  this->assign(vecFromFile);
841 
842  return true;
843  }
844 
845  FUNCTION_H
846  bool read(iIstream& is)
847  {
848  return readVector(is);
849  }
850 
851  FUNCTION_H
852  bool write(iOstream& os)const
853  {
854 
855  Vector<T, noConstructAllocator<T>> vecToFile(this->size());
856 
857  const auto dVec = Kokkos::subview(view_, Kokkos::make_pair(0,int(size_)));
858  hostViewType1D<T> mirror(vecToFile.data(), vecToFile.size());
859  copy(mirror,dVec);
860 
861  return vecToFile.write(os);
862  }
863 
864 }; // class VectorSingle
865 
866 template<typename T, typename MemorySpace>
868 {
869  if( !ivec.read(is) )
870  {
871  ioErrorInFile (is.name(), is.lineNumber());
872  fatalExit;
873  }
874  return is;
875 }
876 
877 template<typename T, typename MemorySpace>
879 {
880 
881  if( !ovec.write(os) )
882  {
883  ioErrorInFile(os.name(), os.lineNumber());
884  fatalExit;
885  }
886 
887  return os;
888 }
889 
890 
891 
892 
893 } // - pFlow
894 
896 
897 
898 #endif //__VectorSingle_hpp__
899 
pFlow::VectorSingle::hostVector
const INLINE_FUNCTION_H auto hostVector() const
Definition: VectorSingle.hpp:338
pFlow::vectorGrowthFactor__
const double vectorGrowthFactor__
Definition: globalSettings.hpp:29
pFlow::VectorSingle::hostVector
INLINE_FUNCTION_H auto hostVector()
Definition: VectorSingle.hpp:346
pFlow::VectorSingle::readVector
FUNCTION_H bool readVector(iIstream &is, size_t len=0)
Definition: VectorSingle.hpp:833
pFlow::VectorSingle::VectorField
const INLINE_FUNCTION_H VectorType & VectorField() const
Definition: VectorSingle.hpp:289
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, size_t n, const T &val)
Definition: VectorSingle.hpp:189
pFlow::VectorSingle::fill
INLINE_FUNCTION_H void fill(const T &val)
Definition: VectorSingle.hpp:428
pFlow::Vector::readVector
bool readVector(iIstream &is, size_t len=0)
Definition: Vector.cpp:30
pFlow::VectorSingle::operator=
VectorSingle & operator=(const VectorSingle &rhs)
Definition: VectorSingle.hpp:245
pFlow::VectorSingle::iterator
T * iterator
Definition: VectorSingle.hpp:58
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, const Vector< T > &src)
Definition: VectorSingle.hpp:219
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:414
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:151
pFlow::VectorSingle::hostVectorAll
const INLINE_FUNCTION_H auto hostVectorAll() const
Definition: VectorSingle.hpp:322
pFlow::VectorSingle::sortItems
INLINE_FUNCTION_H void sortItems(const int32IndexContainer &indices)
Definition: VectorSingle.hpp:562
pFlow::indexContainer::max
INLINE_FUNCTION_HD IndexType max() const
Definition: indexContainer.hpp:133
pFlow::VectorSingle< realx3, void >::deviceType
typename viewType::device_type deviceType
Definition: VectorSingle.hpp:75
pFlow::VectorSingle::constReference
const T & constReference
Definition: VectorSingle.hpp:64
pFlow::indexContainer::empty
INLINE_FUNCTION_HD size_t empty() const
Definition: indexContainer.hpp:121
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, const VectorSingle &src)
Definition: VectorSingle.hpp:236
pFlow::VectorSingle::setSize
INLINE_FUNCTION_H void setSize(size_t n)
Definition: VectorSingle.hpp:127
types.hpp
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(const Vector< T > &src)
Definition: VectorSingle.hpp:453
pFlow::VectorSingle::name
const INLINE_FUNCTION_H word name() const
Definition: VectorSingle.hpp:355
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:420
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const Vector< T > &vals)
Definition: VectorSingle.hpp:597
pFlow::VectorSingle::data
INLINE_FUNCTION_H constPointer data() const
Definition: VectorSingle.hpp:760
ViewAlgorithms.hpp
pFlow::VectorSingle::read
FUNCTION_H bool read(iIstream &is)
Definition: VectorSingle.hpp:846
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::VectorSingle::subViewUpdated_
bool subViewUpdated_
Definition: VectorSingle.hpp:91
pFlow::VectorSingle::resize
INLINE_FUNCTION_H void resize(size_t n)
Definition: VectorSingle.hpp:408
pFlow::VectorSingle::deviceVectorAll
const INLINE_FUNCTION_H viewType & deviceVectorAll() const
Definition: VectorSingle.hpp:303
pFlow::VectorSingle::begin
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constIterator >::type begin() const
Definition: VectorSingle.hpp:784
KokkosTypes.hpp
pFlow::VectorSingle::clonePtr
INLINE_FUNCTION_H VectorSingle * clonePtr() const
Definition: VectorSingle.hpp:273
pFlow::indexContainer::size
INLINE_FUNCTION_HD size_t size() const
Definition: indexContainer.hpp:115
pFlow::VectorSingle::deviceVector
const INLINE_FUNCTION_H viewType & deviceVector() const
Definition: VectorSingle.hpp:316
pFlow::Vector::size
auto size() const
Definition: Vector.hpp:301
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:330
pFlow::VectorSingle::VectorSingle
VectorSingle(size_t n)
Definition: VectorSingle.hpp:167
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H size_t capacity() const
Definition: VectorSingle.hpp:369
pFlow::VectorSingle::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: VectorSingle.hpp:98
pFlow::VectorSingle::clone
INLINE_FUNCTION_H uniquePtr< VectorSingle > clone() const
Definition: VectorSingle.hpp:266
pFlow::VectorSingle::size_
size_t size_
Definition: VectorSingle.hpp:83
pFlow::VectorSingle::empty
INLINE_FUNCTION_H bool empty() const
Definition: VectorSingle.hpp:376
pFlow::VectorSingle::append
INLINE_FUNCTION_H bool append(const VectorSingle &Vec)
Definition: VectorSingle.hpp:733
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:98
pFlow::VectorSingle< realx3, void >::memory_space
typename viewType::memory_space memory_space
Definition: VectorSingle.hpp:77
pFlow
Definition: demComponent.hpp:28
pFlow::VectorSingle< realx3, void >::execution_space
typename viewType::execution_space execution_space
Definition: VectorSingle.hpp:79
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:636
RESERVE
Definition: Vector.hpp:38
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name)
Definition: VectorSingle.hpp:157
pFlow::VectorSingle::operator[]
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constReference >::type operator[](label i) const
Definition: VectorSingle.hpp:826
pFlow::VectorSingle::VectorField
INLINE_FUNCTION_H VectorType & VectorField()
Definition: VectorSingle.hpp:282
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::VectorSingle::reference
T & reference
Definition: VectorSingle.hpp:62
globalSettings.hpp
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, size_t n)
Definition: VectorSingle.hpp:173
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::VectorSingle::data
INLINE_FUNCTION_H pointer data()
Definition: VectorSingle.hpp:756
pFlow::indexContainer::hostView
const HostViewType & hostView() const
Definition: indexContainer.hpp:151
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::Vector::capacity
auto capacity() const
Definition: Vector.hpp:306
pFlow::VectorSingle::VectorSingle
VectorSingle(const VectorSingle &src)
Definition: VectorSingle.hpp:227
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:384
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
Definition: VectorSingle.hpp:537
pFlow::VectorSingle::VectorSingle
VectorSingle(const word &name, size_t cap, size_t n, RESERVE)
Definition: VectorSingle.hpp:204
pFlow::VectorSingle::constIterator
const T * constIterator
Definition: VectorSingle.hpp:60
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:47
pFlow::VectorSingle::end
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, iterator >::type end()
Definition: VectorSingle.hpp:796
pFlow::VectorSingle::operator[]
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, reference >::type operator[](label i)
Definition: VectorSingle.hpp:817
pFlow::VectorSingle::push_back
std::enable_if< isHostAccessible_ &&Enable, void >::type push_back(const T &val)
Definition: VectorSingle.hpp:746
pFlow::VectorSingle::subView_
viewType subView_
Definition: VectorSingle.hpp:89
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
streams.hpp
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:134
pFlow::VectorSingle::TypeInfoTemplateNV2
TypeInfoTemplateNV2("VectorSingle", T, memoerySpaceName())
pFlow::VectorSingle::reallocate
INLINE_FUNCTION_H void reallocate(size_t cap)
Definition: VectorSingle.hpp:390
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
Definition: KokkosTypes.hpp:109
pFlow::VectorSingle::append
INLINE_FUNCTION_H bool append(const deviceViewType1D< T > &dVec, size_t numElems)
Definition: VectorSingle.hpp:710
pFlow::Vector::write
bool write(iOstream &os) const
Definition: Vector.hpp:386
pFlow::VectorSingle::VectorSingle
VectorSingle(size_t n, const T &val)
Definition: VectorSingle.hpp:183
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(size_t n, const T &val)
Definition: VectorSingle.hpp:439
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:103
pFlow::VectorSingle::changeSize
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
Definition: VectorSingle.hpp:109
pFlow::VectorSingle::growthFactor_
static const real growthFactor_
Definition: VectorSingle.hpp:93
pFlow::VectorSingle::write
FUNCTION_H bool write(iOstream &os) const
Definition: VectorSingle.hpp:852
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const Vector< T > &vals)
Definition: VectorSingle.hpp:668
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:67
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:221
pFlow::VectorSingle::end
INLINE_FUNCTION_H std::enable_if< isHostAccessible_ &&Enable, constIterator >::type end() const
Definition: VectorSingle.hpp:807
VectorSingleAlgorithms.hpp
pFlow::VectorSingle::deviceVector
INLINE_FUNCTION_H viewType & deviceVector()
Definition: VectorSingle.hpp:309
pFlow::VectorSingle::size
INLINE_FUNCTION_H size_t size() const
Definition: VectorSingle.hpp:362
pFlow::VectorSingle::begin
INLINE_FUNCTION_H std::enable_if_t< isHostAccessible_ &&Enable, iterator > begin()
Definition: VectorSingle.hpp:772
pFlow::VectorSingle::isHostAccessible_
static constexpr bool isHostAccessible_
Definition: VectorSingle.hpp:95
pFlow::VectorSingle::deviceVectorAll
INLINE_FUNCTION_H viewType & deviceVectorAll()
Definition: VectorSingle.hpp:297
pFlow::VectorSingle::VectorSingle
VectorSingle(const Vector< T > &src)
Definition: VectorSingle.hpp:213
pFlow::triple< real >
pFlow::Vector
Definition: Vector.hpp:46
pFlow::VectorSingle::VectorSingle
VectorSingle(size_t cap, size_t n, RESERVE)
Definition: VectorSingle.hpp:197
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::VectorSingle::capacity_
size_t capacity_
Definition: VectorSingle.hpp:85
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:398
pFlow::indexContainer::deviceView
const DeviceViewType & deviceView() const
Definition: indexContainer.hpp:156
pFlow::VectorSingle< realx3, void >::viewType
ViewType1D< realx3, void > viewType
Definition: VectorSingle.hpp:73
pFlow::VectorSingle::view_
viewType view_
Definition: VectorSingle.hpp:87