Shiokaze Framework
A research-oriented fluid solver for computer graphics
bitmacarray3.h
Go to the documentation of this file.
1 /*
2 ** bitmacarray3.h
3 **
4 ** This is part of Shiokaze, a research-oriented fluid solver for computer graphics.
5 ** Created by Ryoichi Ando <rand@nii.ac.jp> on Ausugst 8, 2018.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a copy of
8 ** this software and associated documentation files (the "Software"), to deal in
9 ** the Software without restriction, including without limitation the rights to use,
10 ** copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11 ** Software, and to permit persons to whom the Software is furnished to do so,
12 ** subject to the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included in all copies
15 ** or substantial portions of the Software.
16 **
17 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 ** CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 //
25 #ifndef SHKZ_BITMACARRAY3_H
26 #define SHKZ_BITMACARRAY3_H
27 //
29 #include <algorithm>
30 #include <array>
31 //
33 //
35 class bitmacarray3 : public recursive_configurable, public messageable {
38 public:
49  bitmacarray3 ( recursive_configurable *parent, const shape3 &shape, std::string core_name="") : m_shape(shape), m_array_0(this,shape.face(0),core_name), m_array_1(this,shape.face(1),core_name), m_array_2(this,shape.face(2),core_name) {
50  if( parent ) parent->add_child(this);
51  else setup_now();
52  }
61  bitmacarray3( recursive_configurable *parent, std::string core_name="" ) : bitmacarray3(parent,shape3(0,0,0),core_name) {}
68  bitmacarray3 ( std::string core_name="") : bitmacarray3(nullptr,shape3(0,0,0),core_name) {}
77  bitmacarray3( const shape3 &shape, std::string core_name="") : bitmacarray3(nullptr,shape,core_name) {}
84  bitmacarray3 ( const bitmacarray3& v ) : m_array_0(this), m_array_1(this), m_array_2(this){
85  copy(v);
86  }
97  virtual bool send_message( std::string message, void *ptr ) override {
98  bool handled (false);
99  if( m_array_0.send_message(message,ptr)) handled = true;
100  if( m_array_1.send_message(message,ptr)) handled = true;
101  if( m_array_2.send_message(message,ptr)) handled = true;
102  return handled;
103  }
114  virtual bool const_send_message( std::string message, void *ptr ) const override {
115  bool handled (false);
116  if( m_array_0.const_send_message(message,ptr)) handled = true;
117  if( m_array_1.const_send_message(message,ptr)) handled = true;
118  if( m_array_2.const_send_message(message,ptr)) handled = true;
119  return handled;
120  }
128  copy(array);
129  return *this;
130  }
137  void copy( const bitmacarray3 &array ) {
138  if( this != &array ) {
139  set_type(array.type());
140  for( int dim : DIMS3 ) (*this)[dim].copy(array[dim]);
141  }
142  }
151  void initialize ( const shape3 &shape ) {
152  m_shape = shape;
153  for( int dim : DIMS3 ) (*this)[dim].initialize(shape.face(dim));
154  }
161  size_t count () const {
162  size_t sum (0);
163  for( int dim : DIMS3 ) sum += (*this)[dim].count();
164  return sum;
165  }
172  std::array<std::vector<vec3i>,DIM3> actives() const {
173  std::array<std::vector<vec3i>,DIM3> result;
174  m_parallel.for_each( DIM3, [&]( size_t dim ) {
175  result[dim] = (*this)[dim].actives();
176  });
177  return result;
178  }
187  void activate( const std::array<std::vector<vec3i>,DIM3> &active_entries, const std::array<vec3i,DIM3> &offsets={vec3i(),vec3i(),vec3i()} ) {
188  m_parallel.for_each( DIM3, [&]( size_t dim ) {
189  (*this)[dim].activate(active_entries[dim],offsets[dim]);
190  });
191  }
200  void activate_as_bit( const bitmacarray3 &array, const std::array<vec3i,DIM3> &offsets={vec3i(),vec3i(),vec3i()} ) {
201  m_parallel.for_each( DIM3, [&]( size_t dim ) {
202  (*this)[dim].activate_as_bit(array[dim],offsets[dim]);
203  });
204  }
213  template <class Y> void activate_as( const Y &array, const std::array<vec3i,DIM3> &offsets={vec3i(),vec3i(),vec3i()} ) {
214  m_parallel.for_each( DIM3, [&]( size_t dim ) {
215  (*this)[dim].activate_as(array[dim],offsets[dim]);
216  });
217  }
222  void activate_all() {
223  m_parallel.for_each( DIM3, [&]( size_t dim ) {
224  (*this)[dim].activate_all();
225  });
226  }
235  void copy_active_as( const bitmacarray3 &array, const vec3i &offset=vec3i() ) {
236  m_parallel.for_each( DIM3, [&]( size_t dim ) {
237  (*this)[dim].copy_active_as(array[dim],offset);
238  });
239  }
246  shape3 shape() const { return m_shape; }
253  shape3 shape(int dim) const { return (*this)[dim].shape(); }
262  void clear() {
263  for( int dim : DIMS3 ) (*this)[dim].clear();
264  }
273  bool operator!=( const bitmacarray3 &v ) const {
274  return ! (*this == v);
275  }
284  bool operator==(const bitmacarray3 &v) const {
285  for( int dim : DIMS3 ) {
286  if ((*this)[dim] != v[dim]) return false;
287  }
288  return true;
289  }
296  const bitarray3& operator[](int dim) const {
297  return dim==0 ? m_array_0 : (dim == 1 ? m_array_1 : m_array_2 );
298  }
305  bitarray3& operator[](int dim) {
306  return dim==0 ? m_array_0 : (dim == 1 ? m_array_1 : m_array_2 );
307  }
314  void set_thread_num( int number ) {
315  for( int dim : DIMS3 ) (*this)[dim].set_thread_num(number);
316  }
323  int get_thread_num() const {
324  return m_array_0.get_thread_num();
325  }
326  //
327  enum { ACTIVES = true, ALL = false };
334  inline void parallel_actives( std::function<void(typename bitarray3::iterator& it)> func ) { parallel_op(func,ACTIVES); }
341  inline void parallel_all( std::function<void(typename bitarray3::iterator& it)> func ) { parallel_op(func,ALL); }
350  inline void parallel_op( std::function<void(typename bitarray3::iterator& it)> func, bool type=ALL ) {
351  parallel_op([func](int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index){
352  func(it);
353  },type);
354  }
361  inline void parallel_actives( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func ) { parallel_op(func,ACTIVES); }
368  inline void parallel_all( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func ) { parallel_op(func,ALL); }
377  inline void parallel_op( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func, bool type=ALL ) {
378  parallel_op([func](int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index){
379  func(dim,i,j,k,it);
380  },type);
381  }
388  inline void parallel_actives( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index)> func ) { parallel_op(func,ACTIVES); }
395  inline void parallel_all( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index)> func ) { parallel_op(func,ALL); }
404  inline void parallel_op( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index)> func, bool type=ALL ) {
405  for( int dim : DIMS3 ) {
406  (*this)[dim].parallel_op([&](int i, int j, int k, typename bitarray3::iterator& it, int thread_index) {
407  func(dim,i,j,k,it,thread_index);
408  },type);
409  };
410  }
417  inline void const_parallel_all( std::function<void(const typename bitarray3::const_iterator& it)> func ) const { const_parallel_op(func,ALL); }
426  inline void const_parallel_op( std::function<void(const typename bitarray3::const_iterator& it)> func, bool type=ALL ) const {
427  const_parallel_op([func](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it, int thread_index){
428  func(it);
429  },type);
430  }
437  inline void const_parallel_actives( std::function<void(int dim, int i, int j, int k)> func ) const {
438  const_parallel_op([&](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it){ func(dim,i,j,k); }, ACTIVES); }
445  inline void const_parallel_all( std::function<void(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it)> func ) const { const_parallel_op(func,ALL); }
454  inline void const_parallel_op( std::function<void(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it)> func, bool type=ALL ) const {
455  const_parallel_op([func](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it, int thread_index){
456  func(dim,i,j,k,it);
457  },type);
458  }
465  inline void const_parallel_actives( std::function<void(int dim, int i, int j, int k, int thread_index)> func ) const {
466  const_parallel_op([&](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it, int thread_index){ func(dim,i,j,k,thread_index); }, ACTIVES); }
473  inline void const_parallel_all( std::function<void(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it, int thread_index)> func ) const { const_parallel_op(func,ALL); }
482  inline void const_parallel_op( std::function<void(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it, int thread_index)> func, bool type=ALL ) const {
483  for( int dim : DIMS3 ) {
484  (*this)[dim].const_parallel_op([&](int i, int j, int k, const typename bitarray3::const_iterator& it, int thread_index) {
485  func(dim,i,j,k,it,thread_index);
486  },type);
487  };
488  }
495  inline void serial_actives( std::function<void(typename bitarray3::iterator& it)> func ) { serial_op(func,ACTIVES); }
502  inline void serial_all( std::function<void(typename bitarray3::iterator& it)> func ) { serial_op(func,ALL); }
511  inline void serial_op( std::function<void(typename bitarray3::iterator& it)> func, bool type=ALL ) {
512  serial_op([func](int dim, int i, int j, int k, typename bitarray3::iterator& it) {
513  func(it);
514  },type);
515  }
522  inline void serial_actives( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func ) { serial_op(func,ACTIVES); }
529  inline void serial_all( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func ) { serial_op(func,ALL); }
538  inline void serial_op( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func, bool type=ALL ) {
539  for( int dim : DIMS3 ) {
540  (*this)[dim].serial_op([&](int i, int j, int k, typename bitarray3::iterator& it) {
541  func(dim,i,j,k,it);
542  },type );
543  }
544  }
551  inline void const_serial_all( std::function<void(const typename bitarray3::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
560  inline void const_serial_op( std::function<void(const typename bitarray3::const_iterator& it)> func, bool type=ALL ) const {
561  const_serial_op([func](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it) {
562  func(it);
563  },type);
564  }
571  inline void const_serial_actives( std::function<void(int dim, int i, int j, int k)> func ) const {
572  const_serial_op([&](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it){ func(dim,i,j,k); }, ACTIVES); }
579  inline void const_serial_all( std::function<void(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
588  inline void const_serial_op( std::function<void(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it)> func, bool type=ALL ) const {
589  for( int dim : DIMS3 ) {
590  (*this)[dim].const_serial_op([&](int i, int j, int k, const typename bitarray3::const_iterator& it) {
591  func(dim,i,j,k,it);
592  },type);
593  }
594  }
601  inline void interruptible_serial_actives( std::function<bool(typename bitarray3::iterator& it)> func ) { serial_op(func,ACTIVES); }
608  inline void interruptible_serial_all( std::function<bool(typename bitarray3::iterator& it)> func ) { serial_op(func,ALL); }
617  inline void interruptible_serial_op( std::function<bool(typename bitarray3::iterator& it)> func, bool type=ALL ) {
618  serial_op([func](int dim, int i, int j, int k, typename bitarray3::iterator& it) {
619  func(it);
620  },type);
621  }
628  inline void interruptible_serial_actives( std::function<bool(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func ) { serial_op(func,ACTIVES); }
635  inline void interruptible_serial_all( std::function<bool(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func ) { serial_op(func,ALL); }
644  inline void interruptible_serial_op( std::function<bool(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func, bool type=ALL ) {
645  for( int dim : DIMS3 ) {
646  (*this)[dim].serial_op([&](int i, int j, int k, typename bitarray3::iterator& it) {
647  func(dim,i,j,k,it);
648  },type);
649  }
650  }
657  inline void interruptible_const_serial_all( std::function<bool(const typename bitarray3::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
666  inline void interruptible_const_serial_op( std::function<bool(const typename bitarray3::const_iterator& it)> func, bool type=ALL ) const {
667  const_serial_op([func](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it) {
668  func(it);
669  },type);
670  }
677  inline void interruptible_const_serial_actives( std::function<bool(int dim, int i, int j, int k)> func ) const {
678  const_serial_op([&](int dim, int i, int j, int k, const typename bitarray3::const_iterator& it){ return func(dim,i,j,k); }, ACTIVES); }
685  inline void interruptible_const_serial_all( std::function<bool(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
694  inline void interruptible_const_serial_op( std::function<bool(int dim, int i, int j, int k, const typename bitarray3::const_iterator& it)> func, bool type=ALL ) const {
695  for( int dim : DIMS3 ) {
696  (*this)[dim].const_serial_op([&](int i, int j, int k, const typename bitarray3::const_iterator& it) {
697  func(dim,i,j,k,it);
698  },type);
699  }
700  }
709  void dilate( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index)> func, int count=1 ) {
710  while( count -- ) {
711  m_parallel.for_each(DIM3,[&]( size_t dim ) {
712  operator[](dim).dilate([&](int i, int j, int k, typename bitarray3::iterator& it, int thread_index) {
713  func(dim,i,j,k,it,thread_index);
714  });
715  });
716  }
717  }
726  void dilate( std::function<void(int dim, int i, int j, int k, typename bitarray3::iterator& it)> func, int count=1 ) {
727  dilate([&](int dim, int i, int j, int k, typename bitarray3::iterator& it, int thread_index) {
728  func(dim,i,j,k,it);
729  },count);
730  }
737  void dilate( int count=1 ) {
738  dilate([&](int dim, int i, int j, int k, typename bitarray3::iterator& it){ it.set(); },count);
739  }
748  void erode( std::function<bool(int dim, int i, int j, int k, int thread_index)> func, int count=1 ) {
749  while( count -- ) {
750  m_parallel.for_each(DIM3,[&]( size_t dim ) {
751  operator[](dim).erode([&](int i, int j, int k, int thread_index) {
752  return func(dim,i,j,k,thread_index);
753  });
754  });
755  }
756  }
765  void erode( std::function<bool(int dim, int i, int j, int k)> func, int count=1 ) {
766  erode([&](int dim, int i, int j, int k, int thread_index) {
767  return func(dim,i,j,k);
768  },count);
769  }
776  void erode( int count=1 ) {
777  return erode([&](int dim, int i, int j, int k){ return true; },count);
778  }
785  void set_core_name( std::string core_name ) {
786  m_array_0.set_core_name(core_name);
787  m_array_1.set_core_name(core_name);
788  m_array_2.set_core_name(core_name);
789  }
796  std::string get_core_name() const {
797  return m_array_0.get_core_name();
798  }
801  struct type3 {
806  std::string core_name;
833  bool operator==( const type3 &type ) const {
834  return
835  core_name == type.core_name && shape == type.shape &&
836  type0 == type.type0 && type1 == type.type1 && type2 == type.type2;
837  }
838  };
845  type3 type() const {
846  return { get_core_name(), m_shape, m_array_0.type(), m_array_1.type(), m_array_2.type() };
847  }
854  void set_type( const type3 &type ) {
855  m_shape = type.shape;
856  m_array_0.set_type(type.type0);
857  m_array_1.set_type(type.type1);
858  m_array_2.set_type(type.type2);
859  }
860 private:
861  parallel_driver m_parallel{this};
862  bitarray3 m_array_0;
863  bitarray3 m_array_1;
864  bitarray3 m_array_2;
865  shape3 m_shape;
866  //
867 };
868 //
870 //
871 #endif
bitmacarray3::parallel_actives
void parallel_actives(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it, int thread_index)> func)
Loop over all the active cells in parallel.
Definition: bitmacarray3.h:388
bitmacarray3::clear
void clear()
Clear out the grid.
Definition: bitmacarray3.h:262
bitarray3::dilate
void dilate(std::function< void(int i, int j, int k, iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: bitarray3.h:947
bitmacarray3::const_serial_all
void const_serial_all(std::function< void(const typename bitarray3::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray3.h:551
bitmacarray3::set_thread_num
void set_thread_num(int number)
Set the number of threads for parallel processing on this grid.
Definition: bitmacarray3.h:314
bitmacarray3::const_parallel_op
void const_parallel_op(std::function< void(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it, int thread_index)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: bitmacarray3.h:482
bitarray3::erode
void erode(std::function< bool(int i, int j, int k, int thread_index)> func, int count=1)
Erode cells.
Definition: bitarray3.h:985
parallel_driver
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
bitmacarray3::const_parallel_actives
void const_parallel_actives(std::function< void(int dim, int i, int j, int k, int thread_index)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: bitmacarray3.h:465
bitmacarray3::count
size_t count() const
Function to count the number of active cells.
Definition: bitmacarray3.h:161
bitmacarray3::get_thread_num
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: bitmacarray3.h:323
bitmacarray3::operator[]
const bitarray3 & operator[](int dim) const
Get the read-only reference to the staggered array of a specified dimension.
Definition: bitmacarray3.h:296
bitmacarray3::parallel_actives
void parallel_actives(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func)
Loop over all the active cells in parallel.
Definition: bitmacarray3.h:361
bitmacarray3::const_parallel_op
void const_parallel_op(std::function< void(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: bitmacarray3.h:454
bitmacarray3::interruptible_serial_op
void interruptible_serial_op(std::function< bool(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray3.h:644
bitmacarray3::bitmacarray3
bitmacarray3(const shape3 &shape, std::string core_name="")
Constructor for bitmacarray3.
Definition: bitmacarray3.h:77
recursive_configurable::setup_now
virtual void setup_now(configuration &config=get_global_configuration()) override
Run recursive_load - recursive_configure - recursive_initialize processes.
Definition: configurable.h:227
bitmacarray3::set_core_name
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: bitmacarray3.h:785
bitmacarray3::type3::type2
bitarray3::type3 type2
Type for z dimensional grid.
Definition: bitmacarray3.h:826
bitmacarray3::interruptible_serial_actives
void interruptible_serial_actives(std::function< bool(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray3.h:628
bitmacarray3::bitmacarray3
bitmacarray3(const bitmacarray3 &v)
Copy constructor for bitmacarray3.
Definition: bitmacarray3.h:84
bitmacarray3::operator!=
bool operator!=(const bitmacarray3 &v) const
Return if the grid is different from an input array.
Definition: bitmacarray3.h:273
bitarray3
Three dimensional bit grid class designed to be defined as instance member in recursive_configurable ...
Definition: bitarray3.h:43
bitmacarray3::erode
void erode(int count=1)
Erode cells.
Definition: bitmacarray3.h:776
bitmacarray3::serial_all
void serial_all(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray3.h:529
shape3::face
shape3 face(int dim) const
Get the shape for the staggered grid of a specified dimension from this shape.
Definition: shape.h:707
bitarray3::get_thread_num
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: bitarray3.h:470
bitmacarray3::interruptible_const_serial_all
void interruptible_const_serial_all(std::function< bool(const typename bitarray3::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray3.h:657
bitmacarray3::get_core_name
std::string get_core_name() const
Get the core name of module of this grid.
Definition: bitmacarray3.h:796
shape3
Structure that defines a three dimensional shape such as width, height and depth.
Definition: shape.h:478
bitarray3::iterator
Writable iterator.
Definition: bitarray3.h:475
bitmacarray3::bitmacarray3
bitmacarray3(std::string core_name="")
Constructor for bitmacarray3.
Definition: bitmacarray3.h:68
bitmacarray3::type3::type0
bitarray3::type3 type0
Type for x dimensional grid.
Definition: bitmacarray3.h:816
bitmacarray3::interruptible_const_serial_op
void interruptible_const_serial_op(std::function< bool(const typename bitarray3::const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: bitmacarray3.h:666
bitmacarray3::parallel_actives
void parallel_actives(std::function< void(typename bitarray3::iterator &it)> func)
Loop over all the active cells in parallel.
Definition: bitmacarray3.h:334
bitmacarray3::actives
std::array< std::vector< vec3i >, DIM3 > actives() const
Function to return the list of active cells positions.
Definition: bitmacarray3.h:172
bitmacarray3::parallel_all
void parallel_all(std::function< void(typename bitarray3::iterator &it)> func)
Loop over all the cells in parallel.
Definition: bitmacarray3.h:341
bitmacarray3::serial_actives
void serial_actives(std::function< void(typename bitarray3::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray3.h:495
bitmacarray3::const_parallel_all
void const_parallel_all(std::function< void(const typename bitarray3::const_iterator &it)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: bitmacarray3.h:417
bitmacarray3::parallel_op
void parallel_op(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitmacarray3.h:377
bitarray3::iterator::set
void set()
Set a value.
Definition: bitarray3.h:484
bitmacarray3::shape
shape3 shape(int dim) const
Get the shape of the staggered grid of a specified dimension.
Definition: bitmacarray3.h:253
bitarray3::const_iterator
Read-only iterator.
Definition: bitarray3.h:507
bitmacarray3::dilate
void dilate(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func, int count=1)
Dilate cells.
Definition: bitmacarray3.h:726
bitmacarray3::const_parallel_all
void const_parallel_all(std::function< void(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: bitmacarray3.h:445
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
bitmacarray3::parallel_all
void parallel_all(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it, int thread_index)> func)
Loop over all the cells in parallel.
Definition: bitmacarray3.h:395
bitmacarray3::const_parallel_actives
void const_parallel_actives(std::function< void(int dim, int i, int j, int k)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: bitmacarray3.h:437
bitarray3::send_message
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: bitarray3.h:122
bitmacarray3::interruptible_serial_all
void interruptible_serial_all(std::function< bool(typename bitarray3::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray3.h:608
bitmacarray3::copy_active_as
void copy_active_as(const bitmacarray3 &array, const vec3i &offset=vec3i())
Copy the states of active and inactive cells as same as input array with an offset.
Definition: bitmacarray3.h:235
bitmacarray3::activate_as
void activate_as(const Y &array, const std::array< vec3i, DIM3 > &offsets={vec3i(), vec3i(), vec3i()})
Activate cells at the same positons where an input array is active with an offset.
Definition: bitmacarray3.h:213
bitmacarray3::parallel_op
void parallel_op(std::function< void(typename bitarray3::iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitmacarray3.h:350
bitmacarray3::activate_as_bit
void activate_as_bit(const bitmacarray3 &array, const std::array< vec3i, DIM3 > &offsets={vec3i(), vec3i(), vec3i()})
Activate cells at the same positons where an input array is active with an offset.
Definition: bitmacarray3.h:200
bitmacarray3::interruptible_const_serial_all
void interruptible_const_serial_all(std::function< bool(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray3.h:685
bitarray3::set_type
void set_type(const type3 &type)
Set the type of this grid.
Definition: bitarray3.h:1135
bitmacarray3::bitmacarray3
bitmacarray3(recursive_configurable *parent, std::string core_name="")
Constructor for bitmacarray3.
Definition: bitmacarray3.h:61
bitarray3::type
type3 type() const
Get the type of this grid.
Definition: bitarray3.h:1128
bitmacarray3::const_parallel_op
void const_parallel_op(std::function< void(const typename bitarray3::const_iterator &it)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: bitmacarray3.h:426
bitmacarray3::type3::type1
bitarray3::type3 type1
Type for y dimensional grid.
Definition: bitmacarray3.h:821
bitmacarray3::const_serial_all
void const_serial_all(std::function< void(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray3.h:579
bitmacarray3::const_serial_actives
void const_serial_actives(std::function< void(int dim, int i, int j, int k)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: bitmacarray3.h:571
bitmacarray3::const_send_message
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: bitmacarray3.h:114
bitmacarray3::dilate
void dilate(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: bitmacarray3.h:709
bitmacarray3::operator[]
bitarray3 & operator[](int dim)
Get the reference to the staggered array of a specified dimension.
Definition: bitmacarray3.h:305
bitarray3.h
bitmacarray3::type3::operator==
bool operator==(const type3 &type) const
Check equality.
Definition: bitmacarray3.h:833
bitarray3::set_core_name
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: bitarray3.h:1069
bitmacarray3::erode
void erode(std::function< bool(int dim, int i, int j, int k)> func, int count=1)
Erode cells.
Definition: bitmacarray3.h:765
bitmacarray3::activate_all
void activate_all()
Activate all the cells.
Definition: bitmacarray3.h:222
bitmacarray3::const_serial_op
void const_serial_op(std::function< void(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: bitmacarray3.h:588
bitarray3::type3
Collection of properties of this grid.
Definition: bitarray3.h:1101
bitmacarray3::initialize
void initialize(const shape3 &shape)
Allocate grid memory with value.
Definition: bitmacarray3.h:151
bitmacarray3::interruptible_const_serial_op
void interruptible_const_serial_op(std::function< bool(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: bitmacarray3.h:694
bitmacarray3::interruptible_serial_actives
void interruptible_serial_actives(std::function< bool(typename bitarray3::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray3.h:601
bitmacarray3::serial_all
void serial_all(std::function< void(typename bitarray3::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray3.h:502
recursive_configurable
Extended configurable class that holds multiple children of configurable.
Definition: configurable.h:126
bitarray3::get_core_name
std::string get_core_name() const
Get the core name of module of this grid.
Definition: bitarray3.h:1078
bitmacarray3::const_serial_op
void const_serial_op(std::function< void(const typename bitarray3::const_iterator &it)> func, bool type=ALL) const
Loop over the cells in serial order by read-only fashion.
Definition: bitmacarray3.h:560
vec
Fixed sized vector structure.
Definition: vec.h:38
bitmacarray3::set_type
void set_type(const type3 &type)
Set the type of this grid.
Definition: bitmacarray3.h:854
bitmacarray3::type
type3 type() const
Get the type of this grid.
Definition: bitmacarray3.h:845
bitmacarray3::send_message
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: bitmacarray3.h:97
bitmacarray3::operator==
bool operator==(const bitmacarray3 &v) const
Return if the grid is same to an input array.
Definition: bitmacarray3.h:284
bitmacarray3::copy
void copy(const bitmacarray3 &array)
Deep copy function for bitmacarray3.
Definition: bitmacarray3.h:137
bitmacarray3::const_parallel_all
void const_parallel_all(std::function< void(int dim, int i, int j, int k, const typename bitarray3::const_iterator &it, int thread_index)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: bitmacarray3.h:473
messageable
Message class.
Definition: messageable.h:36
bitmacarray3::erode
void erode(std::function< bool(int dim, int i, int j, int k, int thread_index)> func, int count=1)
Erode cells.
Definition: bitmacarray3.h:748
bitmacarray3::interruptible_const_serial_actives
void interruptible_const_serial_actives(std::function< bool(int dim, int i, int j, int k)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: bitmacarray3.h:677
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
bitmacarray3::interruptible_serial_op
void interruptible_serial_op(std::function< bool(typename bitarray3::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray3.h:617
bitarray3::const_send_message
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: bitarray3.h:135
bitmacarray3::parallel_op
void parallel_op(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it, int thread_index)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitmacarray3.h:404
bitmacarray3::operator=
bitmacarray3 & operator=(const bitmacarray3 &array)
Deep copy operation for bitmacarray3.
Definition: bitmacarray3.h:127
bitmacarray3::serial_op
void serial_op(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray3.h:538
bitmacarray3::dilate
void dilate(int count=1)
Dilate cells.
Definition: bitmacarray3.h:737
bitmacarray3::parallel_all
void parallel_all(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func)
Loop over all the cells in parallel.
Definition: bitmacarray3.h:368
bitmacarray3::type3::shape
shape3 shape
Shape of the grid.
Definition: bitmacarray3.h:811
recursive_configurable::add_child
virtual void add_child(configurable *child)
Add a child instance.
Definition: configurable.h:191
bitmacarray3
Three dimensional staggered bit grid class designed to be defined as instance member in recursive_con...
Definition: bitmacarray3.h:37
bitmacarray3::activate
void activate(const std::array< std::vector< vec3i >, DIM3 > &active_entries, const std::array< vec3i, DIM3 > &offsets={vec3i(), vec3i(), vec3i()})
Activate cells at the positons of active_entries.
Definition: bitmacarray3.h:187
bitmacarray3::serial_op
void serial_op(std::function< void(typename bitarray3::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray3.h:511
bitmacarray3::bitmacarray3
bitmacarray3(recursive_configurable *parent, const shape3 &shape, std::string core_name="")
Constructor for bitmacarray3.
Definition: bitmacarray3.h:49
bitmacarray3::shape
shape3 shape() const
Get the shape of the array.
Definition: bitmacarray3.h:246
bitmacarray3::interruptible_serial_all
void interruptible_serial_all(std::function< bool(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray3.h:635
parallel_driver::for_each
void for_each(size_t size, std::function< void(size_t n, int thread_index)> func) const
Perform a parallel loop operation.
Definition: parallel_driver.h:141
bitmacarray3::type3
Collection of properties of this grid.
Definition: bitmacarray3.h:801
bitmacarray3::serial_actives
void serial_actives(std::function< void(int dim, int i, int j, int k, typename bitarray3::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray3.h:522
bitmacarray3::type3::core_name
std::string core_name
Core name of the module.
Definition: bitmacarray3.h:806