VectorDual.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 #ifndef __VectorDual_hpp__
22 #define __VectorDual_hpp__
23 
24 #include "globalSettings.hpp"
25 #include "types.hpp"
26 #include "typeInfo.hpp"
27 #include "Vector.hpp"
28 #include "streams.hpp"
29 
30 #include "KokkosTypes.hpp"
31 #include "ViewAlgorithms.hpp"
32 
33 #ifndef __RESERVE__
34 #define __RESERVE__
35  struct RESERVE{};
36 #endif
37 
38 
39 namespace pFlow
40 {
41 
42 template<typename T, typename MemorySpace>
43 class VectorDual;
44 
45 
46 template<typename T, typename MemorySpace=void>
47 class VectorDual
48 {
49 public:
50 
51  using iterator = T*;
52 
53  using constIterator = const T*;
54 
55  using reference = T&;
56 
57  using constReference = const T&;
58 
59  using valueType = T;
60 
61  using pointer = T*;
62 
63  using constPointer = const T*;
64 
66 
67  // dualViewType (view of data host and device)
68  using dualViewType = Kokkos::DualView<T*, MemorySpace>;
69 
70  // mirror scape of device view
71  using hostMirrorSpace = typename dualViewType::host_mirror_space;
72 
73  // - viewType of data on device
74  using deviceViewType = typename dualViewType::t_dev;
75 
76  // - viewType of data on host
77  using hostViewType = typename dualViewType::t_host;
78 
79  using deviceType = typename deviceViewType::device_type;
80 
81  using hostType = typename hostViewType::device_type;
82 
83  // to be consistent
85 
86  // we assume device view is the primary side
87  using memory_space = typename viewType::memory_space;
88 
89  // we assume device view is the primary side
90  using execution_space = typename deviceType::execution_space;
91 
92 protected:
93 
94  size_t size_ = 0;
95 
96  size_t capacity_ = 0;
97 
99 
101 
103 
104  mutable bool subViewsUpdated_ = false;
105 
106  static const inline real growthFactor_ = vectorGrowthFactor__;
107 
108  // is host accepsibble from device prespective
109  static constexpr bool isHostAccessible_ =
110  Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
111 
112  // host-device name
113  static inline const word hdName__ =
114  word(hostType::memory_space::name())+
115  word(deviceType::memory_space::name());
116 
117 
118  constexpr static inline const char* memoerySpaceName()
119  {
120  return hdName__.data();
121  }
122 
123  static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
124  {
125  return static_cast<size_t>(n*growthFactor_+1);
126  }
127 
128  // use actualCap = true only for reserve
129  INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
130  {
131  if(n >= capacity_ )
132  {
133  if(actualCap)
134  capacity_ = n;
135  else
137 
138  dualView_.resize(capacity_);
139  subViewsUpdated_ = false;
140  syncViews();
141 
142  }
143  if(!actualCap)
144  {
145  setSize(n);
146  }
147  }
148 
149  INLINE_FUNCTION_H void setSize(size_t n) {
150  size_ = n;
151  subViewsUpdated_ = false;
152  }
153 
154  // - seems strange, since we actually are updating values,
155  // but in fact the content of object is actually const.
157  {
158  if(subViewsUpdated_)return;
159 
160  hostSubView_ = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_)));
161  deviceSubView_ = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_)));
162  subViewsUpdated_ = true;
163  }
164 
165 public:
166 
167  // - type info
168  TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName());
169 
171 
172  // - empty
174  :
175  VectorDual("VectorDual")
176  {
177  }
178 
180  :
181  size_(0),
182  capacity_(2),
184  {
185  changeSize(size_);
186  }
187 
188  // - with size n
189  VectorDual(size_t n)
190  :
191  VectorDual("VectorDual",n)
192  {}
193 
194  // - with name and size n
195  VectorDual(const word& name, size_t n)
196  :
197  size_(n),
200  {
201  changeSize(size_);
202  }
203 
204  // with size and value, apply on both views
205  VectorDual(size_t n, const T& val)
206  :
207  VectorDual("VectorDual", n , val)
208  {}
209 
210  // with name, size and value, apply on both views
211  VectorDual(const word& name, size_t n, const T& val)
212  :
213  VectorDual(name, n)
214  {
215  assign(n, val);
216  }
217 
218  VectorDual(size_t cap, size_t n, RESERVE )
219  :
220  VectorDual("VectorDual", cap, n, RESERVE())
221  {}
222 
223  VectorDual(const word& name, size_t cap, size_t n, RESERVE )
224  :
226  {
227  reallocate(cap);
228  setSize(n);
229 
230  }
231 
232  VectorDual(const Vector<T> & src)
233  :
234  VectorDual("VectorDual", src)
235  {}
236 
237  VectorDual(const word& name, const Vector<T> & src)
238  :
240  {
241  assign(src);
242  }
243 
244  // - copy construct (perform deep copy)
245  // preserve the sync status of the views
246  VectorDual(const VectorDual& src)
247  :
248  VectorDual(src.name(), src.capacity(), src.size(), RESERVE())
249  {
250  // transfer the sync status
251  if(src.hostRequiresSync())
252  {
253  modifyOnDevice();
254  }else if( src.deviceRequiresSync())
255  {
256  modifyOnHost();
257  }else
258  {
259  dualView_.clear_sync_state();
260  }
261 
262  Kokkos::deep_copy(hostVector(), src.hostVector());
263  Kokkos::deep_copy(deviceVector(), src.deviceVector());
264  }
265 
266  // copy construct with new name
267  VectorDual(const word& name, const VectorDual& src)
268  :
269  VectorDual(name, src.capacity(), src.size(), RESERVE())
270  {
271  // transfer the sync status
272  if(src.hostRequiresSync())
273  {
274  modifyOnDevice();
275  }else if( src.deviceRequiresSync())
276  {
277  modifyOnHost();
278  }else
279  {
280  dualView_.clear_sync_state();
281  }
282 
283  Kokkos::deep_copy(hostVector(), src.hostVector());
284  Kokkos::deep_copy(deviceVector(), src.deviceVector());
285  }
286 
287  // - copy assignment
289  {
290  if(&rhs == this) return *this;
291 
292  VectorDual temp(rhs);
293  capacity_ = temp.capacity();
294  setSize( temp.size());
295  dualView_ = temp.dualView_;
296 
297  return *this;
298  }
299 
300  // no move construct
301  VectorDual(VectorDual&&) = delete;
302 
303  // no move assignment
304  VectorDual& operator= (VectorDual&&) = delete;
305 
306  // - clone as a uniquePtr
308  {
309  return makeUnique<VectorDual>(*this);
310  }
311 
312  // - clone as a pointer
314  {
315  return new VectorDual(*this);
316  }
317 
318 
320  // - return *this
323  {
324  return *this;
325  }
326 
327  // - return *this
329  const VectorType& VectorField()const
330  {
331  return *this;
332  }
333 
334  // - Device vector
336  return dualView_.d_view;
337  }
338 
339  // - Device vector
341  return dualView_.d_view;
342  }
343 
344  // - Host vector
346  return dualView_.h_view;
347  }
348 
349  // - Host Vector
351  return dualView_.h_view;
352  }
353 
355  updateSubViews();
356  return deviceSubView_;
357  }
358 
360  updateSubViews();
361  return deviceSubView_;
362  }
363 
365  updateSubViews();
366  return hostSubView_;
367  }
368 
370  updateSubViews();
371  return hostSubView_;
372  }
373 
376  {
377  return Kokkos::subview(dualView_.h_view, Kokkos::make_pair(start,end));
378  }
379 
382  {
383  return Kokkos::subview(dualView_.d_view, Kokkos::make_pair(start,end));
384  }
385 
387  {
388  return dualView_.h_view.label();
389  }
390 
391  INLINE_FUNCTION_H size_t size()const
392  {
393  return size_;
394  }
395 
397  {
398  return capacity_;
399  }
400 
402  {
403  return size_==0;
404  }
405 
406  // - reserve capacity for vector
407  // preserve the content
408  INLINE_FUNCTION_H void reserve(size_t cap)
409  {
410  changeSize(cap, true);
411  }
412  // resize the views
413  // no syncronization occurs
415  {
416  changeSize(n);
417  }
418 
419  INLINE_FUNCTION_H void reallocate(size_t cap)
420  {
421  capacity_ = cap;
422  setSize(0);
423  dualView_.realloc(cap);
424  dualView_.clear_sync_state();
425 
426 
427  }
428 
430  {
431  changeSize(n);
432  syncViews();
433  }
434 
435  // resize the view and assign value to the most recent view (most updated)
436  // no syncronization occurs
437  INLINE_FUNCTION_H void resize(size_t n, const T& val) {
438  assign(n, val);
439  }
440 
441  // resize the view and assign value to the most recent view (most updated)
442  // and syncronize both views
443  INLINE_FUNCTION_H void resizeSync(size_t n, const T& val){
444  assign(n,val);
445  syncViews();
446  }
447 
449 
450  setSize(0);
451  dualView_.clear_sync_state();
452  }
453 
454  // - fill both views with val
455  INLINE_FUNCTION_H void fill(const T& val)
456  {
457  if(empty())return;
458  Kokkos::deep_copy(deviceVector(),val);
459  Kokkos::deep_copy(hostVector(),val);
460  dualView_.clear_sync_state();
461  }
462 
463  INLINE_FUNCTION_H void fillHost(const T& val)
464  {
465  if(empty())return;
466  Kokkos::deep_copy(hostVector(),val);
467  modifyOnHost();
468  }
469 
470  INLINE_FUNCTION_H void fillDevice(const T& val)
471  {
472  if(empty())return;
473  Kokkos::deep_copy(deviceVector(),val);
474  modifyOnDevice();
475  }
476 
477  // - host calls only
478  // - assign n first elements to val
479  // resize views
480  // assign value to both sides (device&host)
481  FUNCTION_H void assign(size_t n, const T& val)
482  {
483 
484  if( n>= capacity_ )
485  {
487  }
488  setSize(n);
489  fill(val);
490  }
491 
492  // - host calls only
493  // - assign source vector
494  // resize views
495  // assign to both sides (device&host)
496  FUNCTION_H void assign(const Vector<T>& src)
497  {
498  auto srcSize = src.size();
499  if( capacity() < srcSize )
500  {
501  reallocate( evalCapacity(srcSize) );
502  }
503 
504  setSize(0);
505  dualView_.clear_sync_state();
506  for( auto& elem:src )
507  {
508  this->push_back(elem);
509  }
510  syncViews();
511  }
512 
513  // TODO: this part may be implemented in parallel
514  bool deleteElement
515  (
516  const Vector<label>& indices
517  )
518  {
519  if( indices.size() == 0 )return true;
520 
521  if( *(indices.end()-1) >= size() ) return false;
522 
523  auto oldSize = this->size();
524  auto nextInd = indices.begin();
525  label j = indices[0];
526  for(label i=indices[0]; i < oldSize; ++i)
527  {
528  if( nextInd != indices.end() && i == *nextInd )
529  {
530  ++nextInd;
531  }
532  else
533  {
534  dualView_.h_view[j] = dualView_.h_view[i];
535  ++j;
536  }
537  }
538 
539  setSize( oldSize - indices.size() );
540  modifyOnHost();
541 
542  // TODO: deep_copy should be changed to a range shorter than the vector size
543  syncViews();
544 
545  return true;
546  }
547 
549  bool insertSetElement(const int32IndexContainer& indices, const T& val)
550  {
551  if(indices.size() == 0)return true;
552 
553  auto maxInd = indices.max();
554 
555  if(this->empty() || maxInd > size()-1 )
556  {
557  resize(maxInd+1);
558  }
559  fillSelected(hostVectorAll(), indices.hostView(), indices.size(), val);
560 
561  auto dIndices = indices.deviceView();
562  auto dVals = deviceVectorAll();
563 
564  Kokkos::parallel_for(
565  "fillSelected",
566  indices.size(),
567  LAMBDA_HD(int32 i){
568  dVals[dIndices[i]]= val;
569 
570  });
571  Kokkos::fence();
572 
573  return true;
574 
575  }
576 
577  template<typename side=HostSide>
579  bool insertSetElement
580  (
581  const int32IndexContainer& indices,
582  const Vector<T>& vals
583  )
584  {
585  if(indices.size() == 0)return true;
586  if(indices.size() != vals.size())return false;
587 
588  auto maxInd = indices.max();
589  auto minInd = indices.min();
590 
591  if(this->empty() || maxInd > size()-1 )
592  {
593  resize(maxInd+1);
594  }
595 
596  if constexpr (std::is_same<side,HostSide>::value )
597  {
598 
599  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
600  //fillSelected(hostVector(), indices.hostView(), hVecVals, indices.size());
601 
602  pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>(
603  hostVectorAll().data(),
604  indices.hostView().data(),
605  hVecVals.data(),
606  indices.size());
607 
608  modifyOnHost();
609 
610  syncViews(minInd, maxInd+1);
611  }
612  else
613  {
614 
615  pFlow::hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
616  pFlow::deviceViewType1D<T> dVecVals("dVecVals", indices.size());
617 
618  Kokkos::deep_copy(dVecVals, hVecVals);
619 
620 
621  //fillSelected(deviceVector(), indices.deviceView(), dVecVals, indices.size());
622  pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
623  deviceVectorAll().data(),
624  indices.deviceView().data(),
625  dVecVals.data(),
626  indices.size());
627 
628  modifyOnDevice();
629 
630  // TODO: deep_copy should be changed to a range shorter than the vector size
631  syncViews(minInd, maxInd+1);
632 
633  }
634 
635  return true;
636 
637  }
638 
639  template<typename side=HostSide>
641  bool insertSetElement(const Vector<int32>& indices, const T& val)
642  {
643  if(indices.size() == 0)return true;
644 
645  auto maxInd = max(indices);
646  auto minInd = min(indices);
647 
648  if(this->empty() || maxInd > size()-1 )
649  {
650  resize(maxInd+1);
651  }
652 
653  if constexpr (std::is_same<side,HostSide>::value )
654  {
655  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
656  fillSelected( hostVectorAll(), hVecInd, indices.size(), val);
657 
658  modifyOnHost();
659  syncViews(minInd, maxInd+1);
660 
661  return true;
662  }
663  else
664  {
665 
666  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
667  deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
668  Kokkos::deep_copy(dVecInd, hVecInd);
669  fillSelected(deviceVectorAll(), dVecInd, indices.size(), val);
670 
671  modifyOnDevice();
672 
673  // TODO: deep_copy should be changed to a range shorter than the vector size
674  syncViews(minInd, maxInd+1);
675  return true;
676 
677  }
678 
679  return false;
680 
681  }
682 
683  template<typename side=HostSide>
685  bool insertSetElement
686  (
687  const Vector<int32>& indices,
688  const Vector<T>& vals
689  )
690  {
691  if(indices.size() == 0)return true;
692  if(indices.size() != vals.size())return false;
693 
694  auto maxInd = max(indices);
695  auto minInd = min(indices);
696 
697  if(this->empty() || maxInd > size()-1 )
698  {
699  resize(maxInd+1);
700  }
701 
702  if constexpr (std::is_same<side,HostSide>::value )
703  {
704  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
705  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
706 
707  fillSelected(hostVectorAll(), hVecInd, hVecVals, indices.size());
708 
709  modifyOnHost();
710 
711  syncViews(minInd, maxInd+1);
712  }
713  else
714  {
715 
716  pFlow::hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
717  pFlow::deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
718 
719  pFlow::hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
720  pFlow::deviceViewType1D<T> dVecVals("dVecVals", indices.size());
721 
722  Kokkos::deep_copy(dVecVals, hVecVals);
723  Kokkos::deep_copy(dVecInd, hVecInd);
724 
725  fillSelected(deviceVectorAll(), dVecInd, dVecVals, indices.size());
726 
727  modifyOnDevice();
728 
729  // TODO: deep_copy should be changed to a range shorter than the vector size
730  syncViews(minInd, maxInd+1);
731 
732  }
733 
734  return true;
735 
736  }
737 
738  // push a new element at the end
739  // resize if necessary
740  // first sycn to host side
741  void push_back(const T& val)
742  {
743 
744  syncToHost();
745  modifyOnHost();
746 
748  data()[size_++] = val;
749  subViewsUpdated_ = false;
750 
751  }
752 
754  return dualView_.h_view.data();
755  }
756 
758  return dualView_.h_view.data();
759  }
760 
761  // host call
762  // returns begin iterator
764  return data();
765  }
766 
767  // host call
768  // returns begin iterator
770  return data();
771  }
772 
773  // host call
774  // returns end iterator
776  return size_ > 0 ? data() + size_: data();
777  }
778 
779  // host call
780  // returns end iterator
782  return size_ > 0 ? data() + size_: data();
783  }
784 
786  return dualView_.h_view[i];
787  }
788 
790  return dualView_.h_view[i];
791  }
792 
793 
795 
797  {
798  dualView_.modify_host();
799  }
800 
802  {
803  dualView_.modify_device();
804  }
805 
807  {
808  return dualView_.template need_sync<hostType>();
809  }
810 
812  {
813  return dualView_.template need_sync<deviceType>();
814  }
815 
817  {
818  return std::is_same<hostType,deviceType>::value;
819  }
820 
821  // - copy from host to device
822  // set both views to updated
824  {
825  if(empty())return;
826 
827  Kokkos::deep_copy(deviceVector(), hostVector());
828  dualView_.clear_sync_state();
829  }
830 
832  void copyHostToDevice(int32 start, int32 end, bool setUpdated = true)
833  {
834  if(empty())return;
835  Kokkos::deep_copy(deviceVector(start, end), hostVector(start, end));
836  if(setUpdated)
837  dualView_.clear_sync_state();
838  }
839 
840  // - copy from device to host
841  // set both views to updated
843  {
844  if(empty())return;
845  Kokkos::deep_copy(hostVector(), deviceVector());
846  dualView_.clear_sync_state();
847  }
848 
850  void copyDeviceToHost(int32 start, int32 end, bool setUpdated = true)
851  {
852  if(empty())return;
853  Kokkos::deep_copy(hostVector(start, end), deviceVector(start, end));
854  if(setUpdated)
855  dualView_.clear_sync_state();
856  }
857 
859  {
860  if(hostRequiresSync())
861  {
863  }
864  }
865 
867  {
868  if(deviceRequiresSync())
869  {
871  }
872  }
873  // - check which side requires update and
874  // apply the update
876  {
877  if(deviceRequiresSync())
878  {
880  }
881  else if(hostRequiresSync())
882  {
884  }
885  }
886 
888  {
889  if(deviceRequiresSync())
890  {
891  copyHostToDevice(start, end);
892  }
893  else if(hostRequiresSync())
894  {
895  copyDeviceToHost(start, end);
896  }
897  }
898 
900  FUNCTION_H
901  bool read(iIstream& is)
902  {
903  Vector<T> vecFromFile;
904  if( !vecFromFile.read(is) ) return false;
905 
906  this->assign(vecFromFile);
907 
908  return true;
909  }
910 
911  FUNCTION_H
912  bool write(iOstream& os) const
913  {
914  // since the object should be const, no way to syncViews
915 
916  Vector<T, noConstructAllocator<T>> vecToFile(this->size());
917  hostViewType1D<T> mirror(vecToFile.data(), vecToFile.size());
918 
919 
920  if(hostRequiresSync()) // device is updated
921  {
922  //const auto dVec = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_)));
923  Kokkos::deep_copy(mirror,deviceVector());
924  }
925  else // either host is updated or both sides are syncronized
926  {
927  //const auto hVec = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_)));
928  Kokkos::deep_copy(mirror,hostVector());
929  }
930  return vecToFile.write(os);
931  }
932 };
933 
934 template<typename T, typename memory_space>
936 {
937  if( !ivec.read(is) )
938  {
939  ioErrorInFile (is.name(), is.lineNumber());
940  fatalExit;
941  }
942  return is;
943 }
944 
945 template<typename T, typename memory_space>
947 {
948 
949  if( !ovec.write(os) )
950  {
951  ioErrorInFile(os.name(), os.lineNumber());
952  fatalExit;
953  }
954 
955  return os;
956 }
957 
958 
959 } // pFlow
960 
961 #include "VectorDualAlgorithms.hpp"
962 
963 
964 #endif //__VectorDual_hpp__
965 
pFlow::vectorGrowthFactor__
const double vectorGrowthFactor__
Definition: globalSettings.hpp:29
pFlow::VectorDual::empty
INLINE_FUNCTION_H bool empty() const
Definition: VectorDual.hpp:401
pFlow::Vector::read
bool read(iIstream &is)
Definition: Vector.hpp:378
pFlow::VectorDual::resizeSync
INLINE_FUNCTION_H void resizeSync(size_t n, const T &val)
Definition: VectorDual.hpp:443
pFlow::VectorDual< int8 >::hostType
typename hostViewType::device_type hostType
Definition: VectorDual.hpp:81
pFlow::VectorDual< int8 >::deviceViewType
typename dualViewType::t_dev deviceViewType
Definition: VectorDual.hpp:74
pFlow::VectorDual< int8 >::iterator
int8 * iterator
Definition: VectorDual.hpp:51
pFlow::VectorDual::hostVector
const INLINE_FUNCTION_H hostViewType & hostVector() const
Definition: VectorDual.hpp:369
pFlow::VectorDual::VectorDual
VectorDual(size_t n)
Definition: VectorDual.hpp:189
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews()
Definition: VectorDual.hpp:875
pFlow::VectorDual::begin
INLINE_FUNCTION_H iterator begin()
Definition: VectorDual.hpp:763
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
VectorDualAlgorithms.hpp
pFlow::VectorDual::hostVectorAll
INLINE_FUNCTION_H hostViewType & hostVectorAll()
Definition: VectorDual.hpp:345
pFlow::VectorDual< int8 >::memory_space
typename viewType::memory_space memory_space
Definition: VectorDual.hpp:87
pFlow::VectorDual::VectorDual
VectorDual(size_t cap, size_t n, RESERVE)
Definition: VectorDual.hpp:218
pFlow::VectorDual::clonePtr
INLINE_FUNCTION_H VectorDual * clonePtr() const
Definition: VectorDual.hpp:313
pFlow::VectorDual::hostVector
INLINE_FUNCTION_H hostViewType hostVector(int32 start, int32 end) const
Definition: VectorDual.hpp:375
pFlow::indexContainer::max
INLINE_FUNCTION_HD IndexType max() const
Definition: indexContainer.hpp:125
pFlow::VectorDual::fill
INLINE_FUNCTION_H void fill(const T &val)
Definition: VectorDual.hpp:455
pFlow::VectorDual::syncToDevice
INLINE_FUNCTION_H void syncToDevice()
Definition: VectorDual.hpp:866
types.hpp
pFlow::VectorDual::deviceVector
INLINE_FUNCTION_H deviceViewType deviceVector(int32 start, int32 end) const
Definition: VectorDual.hpp:381
pFlow::VectorDual::resize
INLINE_FUNCTION_H void resize(size_t n)
Definition: VectorDual.hpp:414
pFlow::VectorDual::VectorDual
VectorDual(const VectorDual &src)
Definition: VectorDual.hpp:246
pFlow::VectorDual::push_back
void push_back(const T &val)
Definition: VectorDual.hpp:741
pFlow::VectorDual::VectorDual
VectorDual(const word &name, const Vector< T > &src)
Definition: VectorDual.hpp:237
pFlow::VectorDual::clone
INLINE_FUNCTION_H uniquePtr< VectorDual > clone() const
Definition: VectorDual.hpp:307
pFlow::VectorDual::hdName__
static const word hdName__
Definition: VectorDual.hpp:113
pFlow::VectorDual::data
INLINE_FUNCTION_H pointer data()
Definition: VectorDual.hpp:753
pFlow::VectorDual::operator[]
INLINE_FUNCTION_H reference operator[](label i)
Definition: VectorDual.hpp:785
ViewAlgorithms.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
KokkosTypes.hpp
pFlow::VectorDual::copyDeviceToHost
INLINE_FUNCTION_H void copyDeviceToHost(int32 start, int32 end, bool setUpdated=true)
Definition: VectorDual.hpp:850
pFlow::VectorDual::assign
FUNCTION_H void assign(const Vector< T > &src)
Definition: VectorDual.hpp:496
pFlow::VectorDual::assign
FUNCTION_H void assign(size_t n, const T &val)
Definition: VectorDual.hpp:481
pFlow::indexContainer::size
INLINE_FUNCTION_HD size_t size() const
Definition: indexContainer.hpp:107
pFlow::Vector::size
auto size() const
Definition: Vector.hpp:299
pFlow::VectorDual::name
const INLINE_FUNCTION_H word name() const
Definition: VectorDual.hpp:386
pFlow::VectorDual::capacity
INLINE_FUNCTION_H size_t capacity() const
Definition: VectorDual.hpp:396
pFlow::VectorDual::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const T &val)
Definition: VectorDual.hpp:641
pFlow::VectorDual::reserve
INLINE_FUNCTION_H void reserve(size_t cap)
Definition: VectorDual.hpp:408
pFlow::VectorDual< int8 >::deviceType
typename deviceViewType::device_type deviceType
Definition: VectorDual.hpp:79
pFlow::VectorDual::modifyOnHost
INLINE_FUNCTION_H void modifyOnHost()
Definition: VectorDual.hpp:796
pFlow::VectorDual::read
FUNCTION_H bool read(iIstream &is)
Definition: VectorDual.hpp:901
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
pFlow::VectorDual::syncToHost
INLINE_FUNCTION_H void syncToHost()
Definition: VectorDual.hpp:858
pFlow::VectorDual::deviceVectorAll
const INLINE_FUNCTION_H deviceViewType & deviceVectorAll() const
Definition: VectorDual.hpp:340
pFlow
Definition: demComponent.hpp:28
pFlow::VectorDual::operator=
VectorDual & operator=(const VectorDual &rhs)
Definition: VectorDual.hpp:288
pFlow::VectorDual::hostVectorAll
const INLINE_FUNCTION_H hostViewType & hostVectorAll() const
Definition: VectorDual.hpp:350
pFlow::VectorDual::modifyOnDevice
INLINE_FUNCTION_H void modifyOnDevice()
Definition: VectorDual.hpp:801
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t n, const T &val)
Definition: VectorDual.hpp:211
pFlow::VectorDual< int8 >::dualViewType
Kokkos::DualView< int8 *, void > dualViewType
Definition: VectorDual.hpp:68
pFlow::VectorDual::deviceSubView_
deviceViewType deviceSubView_
Definition: VectorDual.hpp:100
pFlow::indexContainer::min
INLINE_FUNCTION_HD IndexType min() const
Definition: indexContainer.hpp:119
RESERVE
Definition: Vector.hpp:38
pFlow::VectorDual::deviceVectorAll
INLINE_FUNCTION_H deviceViewType & deviceVectorAll()
Definition: VectorDual.hpp:335
pFlow::VectorDual::operator[]
INLINE_FUNCTION_H constReference operator[](label i) const
Definition: VectorDual.hpp:789
pFlow::VectorDual< int8 >::pointer
int8 * pointer
Definition: VectorDual.hpp:61
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t n)
Definition: VectorDual.hpp:195
pFlow::VectorDual::VectorDual
VectorDual(const word &name, const VectorDual &src)
Definition: VectorDual.hpp:267
pFlow::VectorDual::end
INLINE_FUNCTION_H iterator end()
Definition: VectorDual.hpp:775
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::VectorDual::resize
INLINE_FUNCTION_H void resize(size_t n, const T &val)
Definition: VectorDual.hpp:437
pFlow::VectorDual::setSize
INLINE_FUNCTION_H void setSize(size_t n)
Definition: VectorDual.hpp:149
globalSettings.hpp
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::indexContainer::hostView
const HostViewType & hostView() const
Definition: indexContainer.hpp:143
pFlow::VectorDual< int8 >::execution_space
typename deviceType::execution_space execution_space
Definition: VectorDual.hpp:90
pFlow::VectorDual::clear
INLINE_FUNCTION_H void clear()
Definition: VectorDual.hpp:448
pFlow::VectorDual::updateSubViews
INLINE_FUNCTION_H void updateSubViews() const
Definition: VectorDual.hpp:156
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::VectorDual
Definition: VectorDual.hpp:43
pFlow::VectorDual::copyHostToDevice
INLINE_FUNCTION_H void copyHostToDevice()
Definition: VectorDual.hpp:823
pFlow::VectorDual< int8 >::valueType
int8 valueType
Definition: VectorDual.hpp:59
pFlow::VectorDual::hostVector
INLINE_FUNCTION_H hostViewType & hostVector()
Definition: VectorDual.hpp:364
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews(int32 start, int32 end)
Definition: VectorDual.hpp:887
pFlow::VectorDual::deviceVector
const INLINE_FUNCTION_H deviceViewType & deviceVector() const
Definition: VectorDual.hpp:359
pFlow::VectorDual< int8 >::reference
int8 & reference
Definition: VectorDual.hpp:55
pFlow::VectorDual::copyDeviceToHost
INLINE_FUNCTION_H void copyDeviceToHost()
Definition: VectorDual.hpp:842
pFlow::VectorDual::changeSize
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
Definition: VectorDual.hpp:129
pFlow::VectorDual::VectorField
INLINE_FUNCTION_H VectorType & VectorField()
Definition: VectorDual.hpp:322
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::VectorDual::VectorField
const INLINE_FUNCTION_H VectorType & VectorField() const
Definition: VectorDual.hpp:329
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::VectorDual::capacity_
size_t capacity_
Definition: VectorDual.hpp:96
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::VectorDual::evalCapacity
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
Definition: VectorDual.hpp:123
pFlow::VectorDual::VectorDual
VectorDual(const word &name)
Definition: VectorDual.hpp:179
pFlow::VectorDual::reallocate
INLINE_FUNCTION_H void reallocate(size_t cap)
Definition: VectorDual.hpp:419
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::VectorDual::deviceRequiresSync
INLINE_FUNCTION_H bool deviceRequiresSync() const
Definition: VectorDual.hpp:811
streams.hpp
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pFlow::VectorDual< int8 >::constIterator
const int8 * constIterator
Definition: VectorDual.hpp:53
pFlow::VectorDual< int8 >::constReference
const int8 & constReference
Definition: VectorDual.hpp:57
pFlow::VectorDual::areViewsSimilar
INLINE_FUNCTION_H bool areViewsSimilar() const
Definition: VectorDual.hpp:816
pFlow::VectorDual::resizeSync
INLINE_FUNCTION_H void resizeSync(size_t n)
Definition: VectorDual.hpp:429
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
Definition: KokkosTypes.hpp:104
pFlow::Vector::write
bool write(iOstream &os) const
Definition: Vector.hpp:383
pFlow::VectorDual::VectorDual
VectorDual(const Vector< T > &src)
Definition: VectorDual.hpp:232
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t cap, size_t n, RESERVE)
Definition: VectorDual.hpp:223
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::VectorDual::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: VectorDual.hpp:118
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::VectorDual::copyHostToDevice
INLINE_FUNCTION_H void copyHostToDevice(int32 start, int32 end, bool setUpdated=true)
Definition: VectorDual.hpp:832
pFlow::VectorDual::deviceVector
INLINE_FUNCTION_H deviceViewType & deviceVector()
Definition: VectorDual.hpp:354
pFlow::VectorDual::VectorDual
VectorDual()
Definition: VectorDual.hpp:173
pFlow::VectorDual::data
INLINE_FUNCTION_H constPointer data() const
Definition: VectorDual.hpp:757
pFlow::VectorDual::growthFactor_
static const real growthFactor_
Definition: VectorDual.hpp:106
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::VectorDual::end
INLINE_FUNCTION_H constIterator end() const
Definition: VectorDual.hpp:781
typeInfo.hpp
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::VectorDual::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
Definition: VectorDual.hpp:549
pFlow::VectorDual::fillHost
INLINE_FUNCTION_H void fillHost(const T &val)
Definition: VectorDual.hpp:463
pFlow::VectorDual::VectorDual
VectorDual(size_t n, const T &val)
Definition: VectorDual.hpp:205
pFlow::VectorDual::write
FUNCTION_H bool write(iOstream &os) const
Definition: VectorDual.hpp:912
pFlow::VectorDual< int8 >::constPointer
const int8 * constPointer
Definition: VectorDual.hpp:63
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::VectorDual::deleteElement
bool deleteElement(const Vector< label > &indices)
Definition: VectorDual.hpp:515
pFlow::VectorDual::hostRequiresSync
INLINE_FUNCTION_H bool hostRequiresSync() const
Definition: VectorDual.hpp:806
pFlow::VectorDual::subViewsUpdated_
bool subViewsUpdated_
Definition: VectorDual.hpp:104
pFlow::VectorDual< int8 >::hostViewType
typename dualViewType::t_host hostViewType
Definition: VectorDual.hpp:77
pFlow::Vector
Definition: Vector.hpp:46
pFlow::VectorDual< int8 >::hostMirrorSpace
typename dualViewType::host_mirror_space hostMirrorSpace
Definition: VectorDual.hpp:71
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::VectorDual::dualView_
dualViewType dualView_
Definition: VectorDual.hpp:98
pFlow::VectorDual< int8 >::viewType
dualViewType viewType
Definition: VectorDual.hpp:84
pFlow::VectorDual::size
INLINE_FUNCTION_H size_t size() const
Definition: VectorDual.hpp:391
pFlow::min
T min(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:138
pFlow::VectorDual::isHostAccessible_
static constexpr bool isHostAccessible_
Definition: VectorDual.hpp:109
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::VectorDual::hostSubView_
hostViewType hostSubView_
Definition: VectorDual.hpp:102
pFlow::indexContainer< int32 >
pFlow::VectorDual::begin
INLINE_FUNCTION_H constIterator begin() const
Definition: VectorDual.hpp:769
pFlow::indexContainer::deviceView
const DeviceViewType & deviceView() const
Definition: indexContainer.hpp:148
pFlow::VectorDual::size_
size_t size_
Definition: VectorDual.hpp:94
pFlow::VectorDual::TypeInfoTemplateNV2
TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName())
pFlow::VectorDual::fillDevice
INLINE_FUNCTION_H void fillDevice(const T &val)
Definition: VectorDual.hpp:470