www.cemf.ir
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(hostView(), src.hostView());
263  Kokkos::deep_copy(deviceView(), src.deviceView());
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(hostView(), src.hostView());
284  Kokkos::deep_copy(deviceView(), src.deviceView());
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(deviceView(),val);
459  Kokkos::deep_copy(hostView(),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(hostView(),val);
467  modifyOnHost();
468  }
469 
470  INLINE_FUNCTION_H void fillDevice(const T& val)
471  {
472  if(empty())return;
473  Kokkos::deep_copy(deviceView(),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  void sortItems(const int32IndexContainer& indices)
550  {
551  if(indices.size() == 0)
552  {
553  setSize(0);
554  return;
555  }
556  size_t newSize = indices.size();
557 
558  deviceViewType sortedView("sortedView", newSize);
559  auto dVec = deviceViewAll();
560 
561  auto d_indices = indices.deviceView();
562 
563  Kokkos::parallel_for(
564  "sortItems",
565  newSize,
566  LAMBDA_HD(int32 i){
567  sortedView[i] = dVec[d_indices[i]];
568  }
569  );
570 
571  Kokkos::fence();
572  setSize(newSize);
573  copy(deviceView(), sortedView);
574  modifyOnDevice();
575  syncViews();
576  }
577 
579  bool insertSetElement(const int32IndexContainer& indices, const T& val)
580  {
581  if(indices.size() == 0)return true;
582 
583  auto maxInd = indices.max();
584 
585  if(this->empty() || maxInd > size()-1 )
586  {
587  resize(maxInd+1);
588  }
589  fillSelected(hostViewAll(), indices.hostView(), indices.size(), val);
590 
591  auto dIndices = indices.deviceView();
592  auto dVals = deviceViewAll();
593 
594  Kokkos::parallel_for(
595  "fillSelected",
596  indices.size(),
597  LAMBDA_HD(int32 i){
598  dVals[dIndices[i]]= val;
599 
600  });
601  Kokkos::fence();
602 
603  return true;
604 
605  }
606 
607  template<typename side=HostSide>
609  bool insertSetElement
610  (
611  const int32IndexContainer& indices,
612  const Vector<T>& vals
613  )
614  {
615  if(indices.size() == 0)return true;
616  if(indices.size() != vals.size())return false;
617 
618  auto maxInd = indices.max();
619  auto minInd = indices.min();
620 
621  if(this->empty() || maxInd > size()-1 )
622  {
623  resize(maxInd+1);
624  }
625 
626  if constexpr (std::is_same<side,HostSide>::value )
627  {
628 
629  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
630  //fillSelected(hostView(), indices.hostView(), hVecVals, indices.size());
631 
632  pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>(
633  hostViewAll().data(),
634  indices.hostView().data(),
635  hVecVals.data(),
636  indices.size());
637 
638  modifyOnHost();
639 
640  syncViews(minInd, maxInd+1);
641  }
642  else
643  {
644 
645  pFlow::hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
646  pFlow::deviceViewType1D<T> dVecVals("dVecVals", indices.size());
647 
648  Kokkos::deep_copy(dVecVals, hVecVals);
649 
650 
651  //fillSelected(deviceView(), indices.deviceView(), dVecVals, indices.size());
652  pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
653  deviceViewAll().data(),
654  indices.deviceView().data(),
655  dVecVals.data(),
656  indices.size());
657 
658  modifyOnDevice();
659 
660  // TODO: deep_copy should be changed to a range shorter than the vector size
661  syncViews(minInd, maxInd+1);
662 
663  }
664 
665  return true;
666 
667  }
668 
669  template<typename side=HostSide>
671  bool insertSetElement(const Vector<int32>& indices, const T& val)
672  {
673  if(indices.size() == 0)return true;
674 
675  auto maxInd = max(indices);
676  auto minInd = min(indices);
677 
678  if(this->empty() || maxInd > size()-1 )
679  {
680  resize(maxInd+1);
681  }
682 
683  if constexpr (std::is_same<side,HostSide>::value )
684  {
685  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
686  fillSelected( hostViewAll(), hVecInd, indices.size(), val);
687 
688  modifyOnHost();
689  syncViews(minInd, maxInd+1);
690 
691  return true;
692  }
693  else
694  {
695 
696  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
697  deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
698  Kokkos::deep_copy(dVecInd, hVecInd);
699  fillSelected(deviceViewAll(), dVecInd, indices.size(), val);
700 
701  modifyOnDevice();
702 
703  // TODO: deep_copy should be changed to a range shorter than the vector size
704  syncViews(minInd, maxInd+1);
705  return true;
706 
707  }
708 
709  return false;
710 
711  }
712 
713  template<typename side=HostSide>
715  bool insertSetElement
716  (
717  const Vector<int32>& indices,
718  const Vector<T>& vals
719  )
720  {
721  if(indices.size() == 0)return true;
722  if(indices.size() != vals.size())return false;
723 
724  auto maxInd = max(indices);
725  auto minInd = min(indices);
726 
727  if(this->empty() || maxInd > size()-1 )
728  {
729  resize(maxInd+1);
730  }
731 
732  if constexpr (std::is_same<side,HostSide>::value )
733  {
734  hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
735  hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
736 
737  fillSelected(hostViewAll(), hVecInd, hVecVals, indices.size());
738 
739  modifyOnHost();
740 
741  syncViews(minInd, maxInd+1);
742  }
743  else
744  {
745 
746  pFlow::hostViewType1D<int32> hVecInd( const_cast<int32*>(indices.data()), indices.size());
747  pFlow::deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
748 
749  pFlow::hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
750  pFlow::deviceViewType1D<T> dVecVals("dVecVals", indices.size());
751 
752  Kokkos::deep_copy(dVecVals, hVecVals);
753  Kokkos::deep_copy(dVecInd, hVecInd);
754 
755  fillSelected(deviceViewAll(), dVecInd, dVecVals, indices.size());
756 
757  modifyOnDevice();
758 
759  // TODO: deep_copy should be changed to a range shorter than the vector size
760  syncViews(minInd, maxInd+1);
761 
762  }
763 
764  return true;
765 
766  }
767 
768  // push a new element at the end
769  // resize if necessary
770  // first sycn to host side
771  void push_back(const T& val)
772  {
773 
774  syncToHost();
775  modifyOnHost();
776 
777  if(size_ == capacity_)
778  {
780 
781  }
782  data()[size_++] = val;
783  subViewsUpdated_ = false;
784 
785  }
786 
788  return dualView_.h_view.data();
789  }
790 
792  return dualView_.h_view.data();
793  }
794 
795  // host call
796  // returns begin iterator
798  return data();
799  }
800 
801  // host call
802  // returns begin iterator
804  return data();
805  }
806 
807  // host call
808  // returns end iterator
810  return size_ > 0 ? data() + size_: data();
811  }
812 
813  // host call
814  // returns end iterator
816  return size_ > 0 ? data() + size_: data();
817  }
818 
820  return dualView_.h_view[i];
821  }
822 
824  return dualView_.h_view[i];
825  }
826 
827 
829 
831  {
832  dualView_.modify_host();
833  }
834 
836  {
837  dualView_.modify_device();
838  }
839 
841  {
842  return dualView_.template need_sync<hostType>();
843  }
844 
846  {
847  return dualView_.template need_sync<deviceType>();
848  }
849 
851  {
852  return std::is_same<hostType,deviceType>::value;
853  }
854 
855  // - copy from host to device
856  // set both views to updated
858  {
859  if(empty())return;
860 
861  Kokkos::deep_copy(deviceView(), hostView());
862  dualView_.clear_sync_state();
863  }
864 
866  void copyHostToDevice(int32 start, int32 end, bool setUpdated = true)
867  {
868  if(empty())return;
869  Kokkos::deep_copy(deviceView(start, end), hostView(start, end));
870  if(setUpdated)
871  dualView_.clear_sync_state();
872  }
873 
874  // - copy from device to host
875  // set both views to updated
877  {
878  if(empty())return;
879  Kokkos::deep_copy(hostView(), deviceView());
880  dualView_.clear_sync_state();
881  }
882 
884  void copyDeviceToHost(int32 start, int32 end, bool setUpdated = true)
885  {
886  if(empty())return;
887  Kokkos::deep_copy(hostView(start, end), deviceView(start, end));
888  if(setUpdated)
889  dualView_.clear_sync_state();
890  }
891 
893  {
894  if(hostRequiresSync())
895  {
897  }
898  }
899 
901  {
902  if(deviceRequiresSync())
903  {
905  }
906  }
907  // - check which side requires update and
908  // apply the update
910  {
911  if(deviceRequiresSync())
912  {
914  }
915  else if(hostRequiresSync())
916  {
918  }
919  }
920 
922  {
923  if(deviceRequiresSync())
924  {
925  copyHostToDevice(start, end);
926  }
927  else if(hostRequiresSync())
928  {
929  copyDeviceToHost(start, end);
930  }
931  }
932 
934  FUNCTION_H
936  iIstream& is,
937  size_t len=0)
938  {
939  Vector<T> vecFromFile;
940  if( !vecFromFile.readVector(is,len) ) return false;
941 
942  this->assign(vecFromFile);
943 
944  return true;
945  }
946 
947  FUNCTION_H
948  bool read(iIstream& is)
949  {
950  return readVector(is);
951  }
952 
953  FUNCTION_H
954  bool write(iOstream& os) const
955  {
956  // since the object should be const, no way to syncViews
957 
958  Vector<T, noConstructAllocator<T>> vecToFile(this->size());
959  hostViewType1D<T> mirror(vecToFile.data(), vecToFile.size());
960 
961 
962  if(hostRequiresSync()) // device is updated
963  {
964  //const auto dVec = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_)));
965  Kokkos::deep_copy(mirror,deviceView());
966  }
967  else // either host is updated or both sides are syncronized
968  {
969  //const auto hVec = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_)));
970  Kokkos::deep_copy(mirror,hostView());
971  }
972  return vecToFile.write(os);
973  }
974 };
975 
976 template<typename T, typename memory_space>
978 {
979  if( !ivec.read(is) )
980  {
981  ioErrorInFile (is.name(), is.lineNumber());
982  fatalExit;
983  }
984  return is;
985 }
986 
987 template<typename T, typename memory_space>
989 {
990 
991  if( !ovec.write(os) )
992  {
993  ioErrorInFile(os.name(), os.lineNumber());
994  fatalExit;
995  }
996 
997  return os;
998 }
999 
1000 
1001 } // pFlow
1002 
1003 #include "VectorDualAlgorithms.hpp"
1004 
1005 
1006 #endif //__VectorDual_hpp__
1007 
pFlow::VectorDual::empty
INLINE_FUNCTION_H bool empty() const
Definition: VectorDual.hpp:401
pFlow::VectorDual::resizeSync
INLINE_FUNCTION_H void resizeSync(size_t n, const T &val)
Definition: VectorDual.hpp:443
pFlow::VectorDual< multiRotatingAxis >::hostType
typename hostViewType::device_type hostType
Definition: VectorDual.hpp:81
pFlow::VectorDual< multiRotatingAxis >::deviceViewType
typename dualViewType::t_dev deviceViewType
Definition: VectorDual.hpp:74
pFlow::VectorDual::VectorDual
VectorDual(size_t n)
Definition: VectorDual.hpp:189
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews()
Definition: VectorDual.hpp:909
pFlow::VectorDual::begin
INLINE_FUNCTION_H iterator begin()
Definition: VectorDual.hpp:797
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
VectorDualAlgorithms.hpp
pFlow::VectorDual::deviceView
INLINE_FUNCTION_H deviceViewType deviceView(int32 start, int32 end) const
Definition: VectorDual.hpp:381
pFlow::VectorDual< multiRotatingAxis >::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::indexContainer::max
INLINE_FUNCTION_HD IndexType max() const
Max value of indices.
Definition: indexContainer.hpp:196
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:900
types.hpp
pFlow::copy
INLINE_FUNCTION_H void copy(const ViewType1D< dType, dProperties... > &dst, const ViewType1D< sType, sProperties... > &src)
Definition: ViewAlgorithms.hpp:234
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:771
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:787
pFlow::VectorDual::operator[]
INLINE_FUNCTION_H reference operator[](label i)
Definition: VectorDual.hpp:819
ViewAlgorithms.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
KokkosTypes.hpp
pFlow::VectorDual::copyDeviceToHost
INLINE_FUNCTION_H void copyDeviceToHost(int32 start, int32 end, bool setUpdated=true)
Definition: VectorDual.hpp:884
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
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::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::VectorDual::deviceViewAll
const INLINE_FUNCTION_H deviceViewType & deviceViewAll() const
Definition: VectorDual.hpp:340
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::deviceView
const INLINE_FUNCTION_H deviceViewType & deviceView() const
Definition: VectorDual.hpp:359
pFlow::VectorDual::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const T &val)
Definition: VectorDual.hpp:671
pFlow::VectorDual::reserve
INLINE_FUNCTION_H void reserve(size_t cap)
Definition: VectorDual.hpp:408
pFlow::VectorDual< multiRotatingAxis >::deviceType
typename deviceViewType::device_type deviceType
Definition: VectorDual.hpp:79
pFlow::VectorDual::modifyOnHost
INLINE_FUNCTION_H void modifyOnHost()
Definition: VectorDual.hpp:830
pFlow::VectorDual::read
FUNCTION_H bool read(iIstream &is)
Definition: VectorDual.hpp:948
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
pFlow::VectorDual::syncToHost
INLINE_FUNCTION_H void syncToHost()
Definition: VectorDual.hpp:892
pFlow
Definition: demGeometry.hpp:27
pFlow::VectorDual::operator=
VectorDual & operator=(const VectorDual &rhs)
Definition: VectorDual.hpp:288
pFlow::VectorDual::modifyOnDevice
INLINE_FUNCTION_H void modifyOnDevice()
Definition: VectorDual.hpp:835
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t n, const T &val)
Definition: VectorDual.hpp:211
pFlow::VectorDual< multiRotatingAxis >::dualViewType
Kokkos::DualView< multiRotatingAxis *, void > dualViewType
Definition: VectorDual.hpp:68
pFlow::VectorDual::deviceSubView_
deviceViewType deviceSubView_
Definition: VectorDual.hpp:100
pFlow::indexContainer::min
INLINE_FUNCTION_HD IndexType min() const
Min value of indices.
Definition: indexContainer.hpp:189
RESERVE
Definition: Vector.hpp:40
pFlow::VectorDual::operator[]
INLINE_FUNCTION_H constReference operator[](label i) const
Definition: VectorDual.hpp:823
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t n)
Definition: VectorDual.hpp:195
pFlow::fillSelected
bool fillSelected(ViewType1D< Type, properties... > view, ViewType1D< indexType, indexProperties... > indices, uint32 numElems, Type val)
Definition: ViewAlgorithms.hpp:135
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:809
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::multiRotatingAxis
Defines an axis of rotation that rotates around itself and rotates around another axis.
Definition: multiRotatingAxis.hpp:75
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::VectorDual::sortItems
INLINE_FUNCTION_H void sortItems(const int32IndexContainer &indices)
Definition: VectorDual.hpp:549
pFlow::indexContainer::hostView
const HostViewType & hostView() const
Return Host veiw.
Definition: indexContainer.hpp:202
pFlow::VectorDual::deviceViewAll
INLINE_FUNCTION_H deviceViewType & deviceViewAll()
Definition: VectorDual.hpp:335
pFlow::VectorDual< multiRotatingAxis >::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:50
pFlow::VectorDual
Definition: VectorDual.hpp:43
pFlow::VectorDual::copyHostToDevice
INLINE_FUNCTION_H void copyHostToDevice()
Definition: VectorDual.hpp:857
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews(int32 start, int32 end)
Definition: VectorDual.hpp:921
pFlow::VectorDual::copyDeviceToHost
INLINE_FUNCTION_H void copyDeviceToHost()
Definition: VectorDual.hpp:876
pFlow::VectorDual::hostViewAll
const INLINE_FUNCTION_H hostViewType & hostViewAll() const
Definition: VectorDual.hpp:350
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
pFlow::gSettings::vectorGrowthFactor__
const double vectorGrowthFactor__
Definition: globalSettings.cpp:9
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::VectorDual::hostView
INLINE_FUNCTION_H hostViewType hostView(int32 start, int32 end) const
Definition: VectorDual.hpp:375
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::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::VectorDual::reallocate
INLINE_FUNCTION_H void reallocate(size_t cap)
Definition: VectorDual.hpp:419
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::VectorDual::deviceRequiresSync
INLINE_FUNCTION_H bool deviceRequiresSync() const
Definition: VectorDual.hpp:845
streams.hpp
pFlow::VectorDual::areViewsSimilar
INLINE_FUNCTION_H bool areViewsSimilar() const
Definition: VectorDual.hpp:850
pFlow::VectorDual::resizeSync
INLINE_FUNCTION_H void resizeSync(size_t n)
Definition: VectorDual.hpp:429
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
1D array (vector with host memeory space)
Definition: KokkosTypes.hpp:136
pFlow::VectorDual::deviceView
INLINE_FUNCTION_H deviceViewType & deviceView()
Definition: VectorDual.hpp:354
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::Vector::write
bool write(iOstream &os) const
Definition: Vector.hpp:328
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:42
pFlow::VectorDual::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: VectorDual.hpp:118
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::VectorDual::copyHostToDevice
INLINE_FUNCTION_H void copyHostToDevice(int32 start, int32 end, bool setUpdated=true)
Definition: VectorDual.hpp:866
pFlow::VectorDual::VectorDual
VectorDual()
Definition: VectorDual.hpp:173
pFlow::VectorDual::data
INLINE_FUNCTION_H constPointer data() const
Definition: VectorDual.hpp:791
pFlow::VectorDual::growthFactor_
static const real growthFactor_
Definition: VectorDual.hpp:106
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::VectorDual::end
INLINE_FUNCTION_H constIterator end() const
Definition: VectorDual.hpp:815
typeInfo.hpp
pFlow::VectorDual::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
Definition: VectorDual.hpp:579
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:954
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
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:840
pFlow::indexContainer::size
INLINE_FUNCTION_HD auto size() const
Size.
Definition: indexContainer.hpp:175
pFlow::VectorDual::subViewsUpdated_
bool subViewsUpdated_
Definition: VectorDual.hpp:104
pFlow::VectorDual< multiRotatingAxis >::hostViewType
typename dualViewType::t_host hostViewType
Definition: VectorDual.hpp:77
pFlow::Vector
Definition: Vector.hpp:48
pFlow::VectorDual< multiRotatingAxis >::hostMirrorSpace
typename dualViewType::host_mirror_space hostMirrorSpace
Definition: VectorDual.hpp:71
pFlow::VectorDual::hostView
const INLINE_FUNCTION_H hostViewType & hostView() const
Definition: VectorDual.hpp:369
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::VectorDual::dualView_
dualViewType dualView_
Definition: VectorDual.hpp:98
pFlow::VectorDual< multiRotatingAxis >::viewType
dualViewType viewType
Definition: VectorDual.hpp:84
pFlow::VectorDual::size
INLINE_FUNCTION_H size_t size() const
Definition: VectorDual.hpp:391
pFlow::VectorDual::isHostAccessible_
static constexpr bool isHostAccessible_
Definition: VectorDual.hpp:109
Vector.hpp
pFlow::VectorDual::hostSubView_
hostViewType hostSubView_
Definition: VectorDual.hpp:102
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::VectorDual::hostViewAll
INLINE_FUNCTION_H hostViewType & hostViewAll()
Definition: VectorDual.hpp:345
pFlow::VectorDual::begin
INLINE_FUNCTION_H constIterator begin() const
Definition: VectorDual.hpp:803
pFlow::indexContainer::deviceView
const DeviceViewType & deviceView() const
Return Device view.
Definition: indexContainer.hpp:208
pFlow::VectorDual::readVector
FUNCTION_H bool readVector(iIstream &is, size_t len=0)
Definition: VectorDual.hpp:935
pFlow::VectorDual::size_
size_t size_
Definition: VectorDual.hpp:94
pFlow::VectorDual::hostView
INLINE_FUNCTION_H hostViewType & hostView()
Definition: VectorDual.hpp:364
pFlow::VectorDual::TypeInfoTemplateNV2
TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName())
pFlow::VectorDual::fillDevice
INLINE_FUNCTION_H void fillDevice(const T &val)
Definition: VectorDual.hpp:470