Shiokaze Framework
A research-oriented fluid solver for computer graphics
bitmacarray2.h
Go to the documentation of this file.
1 /*
2 ** bitmacarray2.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 August 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_BITMACARRAY2_H
26 #define SHKZ_BITMACARRAY2_H
27 //
29 #include <algorithm>
30 #include <array>
31 //
33 //
35 class bitmacarray2 : public recursive_configurable, public messageable {
38 public:
49  bitmacarray2 ( recursive_configurable *parent, const shape2 &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) {
50  if( parent ) parent->add_child(this);
51  else setup_now();
52  }
61  bitmacarray2( recursive_configurable *parent, std::string core_name="" ) : bitmacarray2(parent,shape2(0,0),core_name) {}
68  bitmacarray2 ( std::string core_name="") : bitmacarray2(nullptr,shape2(0,0),core_name) {}
77  bitmacarray2( const shape2 &shape, std::string core_name="") : bitmacarray2(nullptr,shape,core_name) {}
84  bitmacarray2 ( const bitmacarray2& v ) : m_array_0(this), m_array_1(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  return handled;
102  }
113  virtual bool const_send_message( std::string message, void *ptr ) const override {
114  bool handled (false);
115  if(m_array_0.const_send_message(message,ptr)) handled = true;
116  if(m_array_1.const_send_message(message,ptr)) handled = true;
117  return handled;
118  }
126  copy(array);
127  return *this;
128  }
135  void copy( const bitmacarray2 &array ) {
136  if( this != &array ) {
137  set_type(array.type());
138  for( int dim : DIMS2 ) (*this)[dim].copy(array[dim]);
139  }
140  }
149  void initialize ( const shape2 &shape ) {
150  m_shape = shape;
151  for( int dim : DIMS2 )(*this)[dim].initialize(shape.face(dim));
152  }
159  size_t count () const {
160  size_t sum (0);
161  for( int dim : DIMS2 ) sum += (*this)[dim].count();
162  return sum;
163  }
170  std::array<std::vector<vec2i>,DIM2> actives() const {
171  std::array<std::vector<vec2i>,DIM2> result;
172  m_parallel.for_each( DIM2, [&]( size_t dim ) {
173  result[dim] = (*this)[dim].actives();
174  });
175  return result;
176  }
185  void activate( const std::array<std::vector<vec2i>,DIM2> &active_entries, const std::array<vec2i,DIM2> &offsets={vec2i(),vec2i()} ) {
186  m_parallel.for_each( DIM2, [&]( size_t dim ) {
187  (*this)[dim].activate(active_entries[dim],offsets[dim]);
188  });
189  }
198  void activate_as_bit( const bitmacarray2 &array, const std::array<vec2i,DIM2> &offsets={vec2i(),vec2i()} ) {
199  m_parallel.for_each( DIM2, [&]( size_t dim ) {
200  (*this)[dim].activate_as_bit(array[dim],offsets[dim]);
201  });
202  }
211  template <class Y> void activate_as( const Y &array, const std::array<vec2i,DIM2> &offsets={vec2i(),vec2i()} ) {
212  m_parallel.for_each( DIM2, [&]( size_t dim ) {
213  (*this)[dim].activate_as_bit(array[dim],offsets[dim]);
214  });
215  }
220  void activate_all() {
221  m_parallel.for_each( DIM2, [&]( size_t dim ) {
222  (*this)[dim].activate_all();
223  });
224  }
233  void copy_active_as( const bitmacarray2 &array, const vec2i &offset=vec2i() ) {
234  m_parallel.for_each( DIM2, [&]( size_t dim ) {
235  (*this)[dim].copy_active_as(array[dim],offset);
236  });
237  }
244  shape2 shape() const { return m_shape; }
251  shape2 shape(int dim) const { return (*this)[dim].shape(); }
260  void clear() {
261  for( int dim : DIMS2 )(*this)[dim].clear();
262  }
271  bool operator!=( const bitmacarray2 &v ) const {
272  return ! (*this == v);
273  }
282  bool operator==(const bitmacarray2 &v) const {
283  for( int dim : DIMS2 ) {
284  if((*this)[dim] != v[dim]) return false;
285  }
286  return true;
287  }
294  const bitarray2& operator[](int dim) const {
295  return dim==0 ? m_array_0 : m_array_1;
296  }
303  bitarray2& operator[](int dim) {
304  return dim==0 ? m_array_0 : m_array_1;
305  }
312  void set_thread_num( int number ) {
313  for( int dim : DIMS2 ) (*this)[dim].set_thread_num(number);
314  }
321  int get_thread_num() const {
322  return m_array_0.get_thread_num();
323  }
324  //
325  enum { ACTIVES = true, ALL = false };
332  inline void parallel_actives( std::function<void(typename bitarray2::iterator& it)> func ) { parallel_op(func,ACTIVES); }
339  inline void parallel_all( std::function<void(typename bitarray2::iterator& it)> func ) { parallel_op(func,ALL); }
348  inline void parallel_op( std::function<void(typename bitarray2::iterator& it)> func, bool type=ALL ) {
349  parallel_op([func](int dim, int i, int j, typename bitarray2::iterator& it, int thread_index){
350  func(it);
351  },type);
352  }
359  inline void parallel_actives( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func ) { parallel_op(func,ACTIVES); }
366  inline void parallel_all( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func ) { parallel_op(func,ALL); }
375  inline void parallel_op( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func, bool type=ALL ) {
376  parallel_op([func](int dim, int i, int j, typename bitarray2::iterator& it, int thread_index){
377  func(dim,i,j,it);
378  },type);
379  }
386  inline void parallel_actives( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it, int thread_index)> func ) { parallel_op(func,ACTIVES); }
393  inline void parallel_all( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it, int thread_index)> func ) { parallel_op(func,ALL); }
402  inline void parallel_op( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it, int thread_index)> func, bool type=ALL ) {
403  for( int dim : DIMS2 ) {
404  (*this)[dim].parallel_op([&](int i, int j, typename bitarray2::iterator& it, int thread_index) {
405  func(dim,i,j,it,thread_index);
406  },type);
407  }
408  }
415  inline void const_parallel_all( std::function<void(const typename bitarray2::const_iterator& it)> func ) const { const_parallel_op(func,ALL); }
424  inline void const_parallel_op( std::function<void(const typename bitarray2::const_iterator& it)> func, bool type=ALL ) const {
425  const_parallel_op([func](int dim, int i, int j, const typename bitarray2::const_iterator& it, int thread_index){
426  func(it);
427  },type);
428  }
435  inline void const_parallel_actives( std::function<void(int dim, int i, int j)> func ) const {
436  const_parallel_op([&](int dim, int i, int j, const typename bitarray2::const_iterator& it){ func(dim,i,j); }, ACTIVES); }
443  inline void const_parallel_all( std::function<void(int dim, int i, int j, const typename bitarray2::const_iterator& it)> func ) const { const_parallel_op(func,ALL); }
452  inline void const_parallel_op( std::function<void(int dim, int i, int j, const typename bitarray2::const_iterator& it)> func, bool type=ALL ) const {
453  const_parallel_op([func](int dim, int i, int j, const typename bitarray2::const_iterator& it, int thread_index){
454  func(dim,i,j,it);
455  },type);
456  }
463  inline void const_parallel_actives( std::function<void(int dim, int i, int j, int thread_index)> func ) const { const_parallel_op([&](int dim, int i, int j, const typename bitarray2::const_iterator& it, int thread_index) { func(dim,i,j,thread_index); }, ACTIVES); }
470  inline void const_parallel_all( std::function<void(int dim, int i, int j, const typename bitarray2::const_iterator& it, int thread_index)> func ) const { const_parallel_op(func,ALL); }
479  inline void const_parallel_op( std::function<void(int dim, int i, int j, const typename bitarray2::const_iterator& it, int thread_index)> func, bool type=ALL ) const {
480  for( int dim : DIMS2 ) {
481  (*this)[dim].const_parallel_op([&](int i, int j, const typename bitarray2::const_iterator& it, int thread_index) {
482  func(dim,i,j,it,thread_index);
483  },type);
484  };
485  }
492  inline void serial_actives( std::function<void(typename bitarray2::iterator& it)> func ) { serial_op(func,ACTIVES); }
499  inline void serial_all( std::function<void(typename bitarray2::iterator& it)> func ) { serial_op(func,ALL); }
508  inline void serial_op( std::function<void(typename bitarray2::iterator& it)> func, bool type=ALL ) {
509  serial_op([func](int dim, int i, int j, typename bitarray2::iterator& it) {
510  func(it);
511  },type);
512  }
519  inline void serial_actives( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func ) { serial_op(func,ACTIVES); }
526  inline void serial_all( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func ) { serial_op(func,ALL); }
535  inline void serial_op( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func, bool type=ALL ) {
536  for( int dim : DIMS2 ) {
537  (*this)[dim].serial_op([&](int i, int j, typename bitarray2::iterator& it) {
538  func(dim,i,j,it);
539  },type);
540  }
541  }
548  inline void const_serial_all( std::function<void(const typename bitarray2::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
557  inline void const_serial_op( std::function<void(const typename bitarray2::const_iterator& it)> func, bool type=ALL ) const {
558  const_serial_op([func](int dim, int i, int j, const typename bitarray2::const_iterator& it) {
559  func(it);
560  },type);
561  }
568  inline void const_serial_actives( std::function<void(int dim, int i, int j)> func ) const {
569  const_serial_op([&](int dim, int i, int j, const typename bitarray2::const_iterator& it) { func(dim,i,j); }, ACTIVES); }
576  inline void const_serial_all( std::function<void(int dim, int i, int j, const typename bitarray2::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
585  inline void const_serial_op( std::function<void(int dim, int i, int j, const typename bitarray2::const_iterator& it)> func, bool type=ALL ) const {
586  for( int dim : DIMS2 ) {
587  (*this)[dim].const_serial_op([&](int i, int j, const typename bitarray2::const_iterator& it) {
588  func(dim,i,j,it);
589  },type);
590  }
591  }
598  inline void interruptible_serial_actives( std::function<bool(typename bitarray2::iterator& it)> func ) { serial_op(func,ACTIVES); }
605  inline void interruptible_serial_all( std::function<bool(typename bitarray2::iterator& it)> func ) { serial_op(func,ALL); }
614  inline void interruptible_serial_op( std::function<bool(typename bitarray2::iterator& it)> func, bool type=ALL ) {
615  serial_op([func](int dim, int i, int j, typename bitarray2::iterator& it) {
616  func(it);
617  },type);
618  }
625  inline void interruptible_serial_actives( std::function<bool(int dim, int i, int j, typename bitarray2::iterator& it)> func ) { serial_op(func,ACTIVES); }
632  inline void interruptible_serial_all( std::function<bool(int dim, int i, int j, typename bitarray2::iterator& it)> func ) { serial_op(func,ALL); }
641  inline void interruptible_serial_op( std::function<bool(int dim, int i, int j, typename bitarray2::iterator& it)> func, bool type=ALL ) {
642  for( int dim : DIMS2 ) {
643  (*this)[dim].serial_op([&](int i, int j, typename bitarray2::iterator& it) {
644  func(dim,i,j,it);
645  },type);
646  }
647  }
654  inline void interruptible_const_serial_all( std::function<bool(const typename bitarray2::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
663  inline void interruptible_const_serial_op( std::function<bool(const typename bitarray2::const_iterator& it)> func, bool type=ALL ) const {
664  const_serial_op([func](int dim, int i, int j, const typename bitarray2::const_iterator& it) {
665  func(it);
666  },type);
667  }
674  inline void interruptible_const_serial_actives( std::function<bool(int dim, int i, int j)> func ) const {
675  const_serial_op([&](int dim, int i, int j, const typename bitarray2::const_iterator& it){ return func(dim,i,j); }, ACTIVES); }
682  inline void interruptible_const_serial_all( std::function<bool(int dim, int i, int j, const typename bitarray2::const_iterator& it)> func ) const { const_serial_op(func,ALL); }
691  inline void interruptible_const_serial_op( std::function<bool(int dim, int i, int j, const typename bitarray2::const_iterator& it)> func, bool type=ALL ) const {
692  for( int dim : DIMS2 ) {
693  (*this)[dim].const_serial_op([&](int i, int j, const typename bitarray2::const_iterator& it) {
694  func(dim,i,j,it);
695  },type);
696  }
697  }
706  void dilate( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it, int thread_index)> func, int count=1 ) {
707  while( count -- ) {
708  m_parallel.for_each(DIM2,[&]( size_t dim ) {
709  operator[](dim).dilate([&](int i, int j, typename bitarray2::iterator& it, int thread_index) {
710  func(dim,i,j,it,thread_index);
711  });
712  });
713  }
714  }
723  void dilate( std::function<void(int dim, int i, int j, typename bitarray2::iterator& it)> func, int count=1 ) {
724  dilate([&](int dim, int i, int j, typename bitarray2::iterator& it, int thread_index) {
725  func(dim,i,j,it);
726  },count);
727  }
734  void dilate( int count=1 ) {
735  dilate([&](int dim, int i, int j, typename bitarray2::iterator& it){ it.set(); },count);
736  }
745  void erode( std::function<bool(int dim, int i, int j, int thread_index)> func, int count=1 ) {
746  while( count -- ) {
747  m_parallel.for_each(DIM2,[&]( size_t dim ) {
748  operator[](dim).erode([&](int i, int j, int thread_index) {
749  return func(dim,i,j,thread_index);
750  });
751  });
752  }
753  }
762  void erode( std::function<bool(int dim, int i, int j)> func, int count=1 ) {
763  erode([&](int dim, int i, int j, int thread_index) {
764  return func(dim,i,j);
765  },count);
766  }
773  void erode( int count=1 ) {
774  return erode([&](int dim, int i, int j){ return true; },count);
775  }
782  void set_core_name( std::string core_name ) {
783  m_array_0.set_core_name(core_name);
784  m_array_1.set_core_name(core_name);
785  }
792  std::string get_core_name() const {
793  return m_array_0.get_core_name();
794  }
797  struct type2 {
802  std::string core_name;
824  bool operator==( const type2 &type ) const {
825  return
826  core_name == type.core_name && shape == type.shape &&
827  type0 == type.type0 && type1 == type.type1;
828  }
829  };
836  type2 type() const {
837  return { get_core_name(), m_shape, m_array_0.type(), m_array_1.type() };
838  }
845  void set_type( const type2 &type ) {
846  m_shape = type.shape;
847  m_array_0.set_type(type.type0);
848  m_array_1.set_type(type.type1);
849  }
850 private:
851  parallel_driver m_parallel{this};
852  bitarray2 m_array_0;
853  bitarray2 m_array_1;
854  shape2 m_shape;
855 };
856 //
858 //
859 #endif
bitmacarray2::serial_all
void serial_all(std::function< void(typename bitarray2::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray2.h:499
bitmacarray2::interruptible_serial_actives
void interruptible_serial_actives(std::function< bool(typename bitarray2::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray2.h:598
bitmacarray2::clear
void clear()
Clear out the grid.
Definition: bitmacarray2.h:260
bitmacarray2::activate_all
void activate_all()
Activate all the cells.
Definition: bitmacarray2.h:220
bitarray2::const_send_message
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: bitarray2.h:135
bitmacarray2::type2::core_name
std::string core_name
Core name of the module.
Definition: bitmacarray2.h:802
bitmacarray2::interruptible_const_serial_actives
void interruptible_const_serial_actives(std::function< bool(int dim, int i, int j)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: bitmacarray2.h:674
bitmacarray2::const_serial_actives
void const_serial_actives(std::function< void(int dim, int i, int j)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: bitmacarray2.h:568
bitmacarray2::operator!=
bool operator!=(const bitmacarray2 &v) const
Return if the grid is different from an input array.
Definition: bitmacarray2.h:271
bitmacarray2::get_core_name
std::string get_core_name() const
Get the core name of module of this grid.
Definition: bitmacarray2.h:792
bitmacarray2::const_parallel_actives
void const_parallel_actives(std::function< void(int dim, int i, int j, int thread_index)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: bitmacarray2.h:463
bitmacarray2::serial_actives
void serial_actives(std::function< void(typename bitarray2::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray2.h:492
bitmacarray2::dilate
void dilate(int count=1)
Dilate cells.
Definition: bitmacarray2.h:734
parallel_driver
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
bitarray2::get_thread_num
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: bitarray2.h:470
bitmacarray2::set_core_name
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: bitmacarray2.h:782
bitmacarray2
Two dimensional staggered bit grid class designed to be defined as instance member in recursive_confi...
Definition: bitmacarray2.h:37
bitmacarray2::parallel_actives
void parallel_actives(std::function< void(typename bitarray2::iterator &it)> func)
Loop over all the active cells in parallel.
Definition: bitmacarray2.h:332
bitmacarray2::shape
shape2 shape(int dim) const
Get the shape of the staggered grid of a specified dimension.
Definition: bitmacarray2.h:251
bitmacarray2::activate_as_bit
void activate_as_bit(const bitmacarray2 &array, const std::array< vec2i, DIM2 > &offsets={vec2i(), vec2i()})
Activate cells at the same positons where an input array is active with an offset.
Definition: bitmacarray2.h:198
bitarray2::erode
void erode(std::function< bool(int i, int j, int thread_index)> func, int count=1)
Erode cells.
Definition: bitarray2.h:987
bitmacarray2::type2
Collection of properties of this grid.
Definition: bitmacarray2.h:797
bitmacarray2::parallel_op
void parallel_op(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitmacarray2.h:375
bitmacarray2::bitmacarray2
bitmacarray2(recursive_configurable *parent, const shape2 &shape, std::string core_name="")
Constructor for bitmacarray2.
Definition: bitmacarray2.h:49
bitmacarray2::set_thread_num
void set_thread_num(int number)
Set the number of threads for parallel processing on this grid.
Definition: bitmacarray2.h:312
bitmacarray2::const_serial_all
void const_serial_all(std::function< void(int dim, int i, int j, const typename bitarray2::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray2.h:576
bitmacarray2::get_thread_num
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: bitmacarray2.h:321
bitmacarray2::erode
void erode(std::function< bool(int dim, int i, int j, int thread_index)> func, int count=1)
Erode cells.
Definition: bitmacarray2.h:745
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
bitmacarray2::activate
void activate(const std::array< std::vector< vec2i >, DIM2 > &active_entries, const std::array< vec2i, DIM2 > &offsets={vec2i(), vec2i()})
Activate cells at the positons of active_entries.
Definition: bitmacarray2.h:185
bitmacarray2::serial_actives
void serial_actives(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray2.h:519
bitmacarray2::const_parallel_all
void const_parallel_all(std::function< void(int dim, int i, int j, const typename bitarray2::const_iterator &it)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: bitmacarray2.h:443
bitmacarray2::initialize
void initialize(const shape2 &shape)
Allocate grid memory with value.
Definition: bitmacarray2.h:149
bitmacarray2::bitmacarray2
bitmacarray2(recursive_configurable *parent, std::string core_name="")
Constructor for bitmacarray2.
Definition: bitmacarray2.h:61
bitmacarray2::parallel_op
void parallel_op(std::function< void(typename bitarray2::iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitmacarray2.h:348
bitmacarray2::count
size_t count() const
Function to count the number of active cells.
Definition: bitmacarray2.h:159
bitmacarray2::operator[]
const bitarray2 & operator[](int dim) const
Get the read-only reference to the staggered array of a specified dimension.
Definition: bitmacarray2.h:294
bitmacarray2::parallel_op
void parallel_op(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it, int thread_index)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitmacarray2.h:402
bitmacarray2::interruptible_serial_actives
void interruptible_serial_actives(std::function< bool(int dim, int i, int j, typename bitarray2::iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitmacarray2.h:625
bitmacarray2::erode
void erode(std::function< bool(int dim, int i, int j)> func, int count=1)
Erode cells.
Definition: bitmacarray2.h:762
bitmacarray2::serial_all
void serial_all(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray2.h:526
bitmacarray2::parallel_actives
void parallel_actives(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it, int thread_index)> func)
Loop over all the active cells in parallel.
Definition: bitmacarray2.h:386
bitarray2::type
type2 type() const
Get the type of this grid.
Definition: bitarray2.h:1128
bitmacarray2::interruptible_const_serial_op
void interruptible_const_serial_op(std::function< bool(int dim, int i, int j, const typename bitarray2::const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: bitmacarray2.h:691
bitmacarray2::const_parallel_op
void const_parallel_op(std::function< void(int dim, int i, int j, const typename bitarray2::const_iterator &it)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: bitmacarray2.h:452
bitmacarray2::const_serial_all
void const_serial_all(std::function< void(const typename bitarray2::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray2.h:548
bitmacarray2::actives
std::array< std::vector< vec2i >, DIM2 > actives() const
Function to return the list of active cells positions.
Definition: bitmacarray2.h:170
bitarray2::dilate
void dilate(std::function< void(int i, int j, iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: bitarray2.h:949
bitmacarray2::copy_active_as
void copy_active_as(const bitmacarray2 &array, const vec2i &offset=vec2i())
Copy the states of active and inactive cells as same as input array with an offset.
Definition: bitmacarray2.h:233
bitarray2::set_type
void set_type(const type2 &type)
Set the type of this grid.
Definition: bitarray2.h:1135
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
bitarray2.h
bitmacarray2::bitmacarray2
bitmacarray2(const shape2 &shape, std::string core_name="")
Constructor for bitmacarray2.
Definition: bitmacarray2.h:77
bitmacarray2::const_parallel_all
void const_parallel_all(std::function< void(const typename bitarray2::const_iterator &it)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: bitmacarray2.h:415
bitmacarray2::interruptible_serial_all
void interruptible_serial_all(std::function< bool(typename bitarray2::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray2.h:605
bitmacarray2::interruptible_serial_op
void interruptible_serial_op(std::function< bool(typename bitarray2::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray2.h:614
shape2::face
shape2 face(int dim) const
Get the shape for the staggered grid of a specified dimension from this shape.
Definition: shape.h:257
bitarray2::const_iterator
Read-only iterator.
Definition: bitarray2.h:508
bitmacarray2::serial_op
void serial_op(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray2.h:535
bitmacarray2::send_message
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: bitmacarray2.h:97
bitmacarray2::const_parallel_actives
void const_parallel_actives(std::function< void(int dim, int i, int j)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: bitmacarray2.h:435
bitarray2::iterator::set
void set()
Set a value.
Definition: bitarray2.h:484
bitmacarray2::operator==
bool operator==(const bitmacarray2 &v) const
Return if the grid is same to an input array.
Definition: bitmacarray2.h:282
bitmacarray2::type2::type1
bitarray2::type2 type1
Type for y dimensional grid.
Definition: bitmacarray2.h:817
bitmacarray2::interruptible_const_serial_op
void interruptible_const_serial_op(std::function< bool(const typename bitarray2::const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: bitmacarray2.h:663
bitmacarray2::type2::shape
shape2 shape
Shape of the grid.
Definition: bitmacarray2.h:807
bitmacarray2::const_send_message
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: bitmacarray2.h:113
bitmacarray2::operator=
bitmacarray2 & operator=(const bitmacarray2 &array)
Deep copy operation for bitmacarray2.
Definition: bitmacarray2.h:125
bitarray2::type2
Collection of properties of this grid.
Definition: bitarray2.h:1101
bitarray2::iterator
Writable iterator.
Definition: bitarray2.h:475
bitarray2::send_message
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: bitarray2.h:122
bitmacarray2::parallel_all
void parallel_all(std::function< void(typename bitarray2::iterator &it)> func)
Loop over all the cells in parallel.
Definition: bitmacarray2.h:339
bitmacarray2::const_parallel_op
void const_parallel_op(std::function< void(const typename bitarray2::const_iterator &it)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: bitmacarray2.h:424
recursive_configurable
Extended configurable class that holds multiple children of configurable.
Definition: configurable.h:126
bitmacarray2::bitmacarray2
bitmacarray2(std::string core_name="")
Constructor for bitmacarray2.
Definition: bitmacarray2.h:68
bitmacarray2::erode
void erode(int count=1)
Erode cells.
Definition: bitmacarray2.h:773
vec
Fixed sized vector structure.
Definition: vec.h:38
bitarray2::get_core_name
std::string get_core_name() const
Get the core name of module of this grid.
Definition: bitarray2.h:1078
bitmacarray2::operator[]
bitarray2 & operator[](int dim)
Get the reference to the staggered array of a specified dimension.
Definition: bitmacarray2.h:303
bitmacarray2::parallel_actives
void parallel_actives(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func)
Loop over all the active cells in parallel.
Definition: bitmacarray2.h:359
bitarray2::set_core_name
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: bitarray2.h:1069
bitmacarray2::interruptible_const_serial_all
void interruptible_const_serial_all(std::function< bool(int dim, int i, int j, const typename bitarray2::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray2.h:682
shape2
Structure that defines shape such as width, height.
Definition: shape.h:42
bitmacarray2::dilate
void dilate(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: bitmacarray2.h:706
messageable
Message class.
Definition: messageable.h:36
bitmacarray2::copy
void copy(const bitmacarray2 &array)
Deep copy function for bitmacarray2.
Definition: bitmacarray2.h:135
bitmacarray2::dilate
void dilate(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func, int count=1)
Dilate cells.
Definition: bitmacarray2.h:723
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
bitmacarray2::bitmacarray2
bitmacarray2(const bitmacarray2 &v)
Copy constructor for bitmacarray2.
Definition: bitmacarray2.h:84
bitmacarray2::const_serial_op
void const_serial_op(std::function< void(const typename bitarray2::const_iterator &it)> func, bool type=ALL) const
Loop over the cells in serial order by read-only fashion.
Definition: bitmacarray2.h:557
bitmacarray2::type2::operator==
bool operator==(const type2 &type) const
Check equality.
Definition: bitmacarray2.h:824
bitmacarray2::interruptible_serial_op
void interruptible_serial_op(std::function< bool(int dim, int i, int j, typename bitarray2::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray2.h:641
bitmacarray2::parallel_all
void parallel_all(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it, int thread_index)> func)
Loop over all the cells in parallel.
Definition: bitmacarray2.h:393
bitmacarray2::shape
shape2 shape() const
Get the shape of the array.
Definition: bitmacarray2.h:244
recursive_configurable::add_child
virtual void add_child(configurable *child)
Add a child instance.
Definition: configurable.h:191
bitmacarray2::const_serial_op
void const_serial_op(std::function< void(int dim, int i, int j, const typename bitarray2::const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: bitmacarray2.h:585
bitmacarray2::interruptible_const_serial_all
void interruptible_const_serial_all(std::function< bool(const typename bitarray2::const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: bitmacarray2.h:654
bitmacarray2::type
type2 type() const
Get the type of this grid.
Definition: bitmacarray2.h:836
bitmacarray2::parallel_all
void parallel_all(std::function< void(int dim, int i, int j, typename bitarray2::iterator &it)> func)
Loop over all the cells in parallel.
Definition: bitmacarray2.h:366
bitmacarray2::const_parallel_all
void const_parallel_all(std::function< void(int dim, int i, int j, const typename bitarray2::const_iterator &it, int thread_index)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: bitmacarray2.h:470
bitmacarray2::set_type
void set_type(const type2 &type)
Set the type of this grid.
Definition: bitmacarray2.h:845
bitmacarray2::activate_as
void activate_as(const Y &array, const std::array< vec2i, DIM2 > &offsets={vec2i(), vec2i()})
Activate cells at the same positons where an input array is active with an offset.
Definition: bitmacarray2.h:211
bitmacarray2::type2::type0
bitarray2::type2 type0
Type for x dimensional grid.
Definition: bitmacarray2.h:812
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
bitmacarray2::interruptible_serial_all
void interruptible_serial_all(std::function< bool(int dim, int i, int j, typename bitarray2::iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitmacarray2.h:632
bitmacarray2::const_parallel_op
void const_parallel_op(std::function< void(int dim, int i, int j, const typename bitarray2::const_iterator &it, int thread_index)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: bitmacarray2.h:479
bitmacarray2::serial_op
void serial_op(std::function< void(typename bitarray2::iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitmacarray2.h:508
bitarray2
Two dimensional bit grid class designed to be defined as instance member in recursive_configurable cl...
Definition: bitarray2.h:43