Shiokaze Framework
A research-oriented fluid solver for computer graphics
array_core2.h
Go to the documentation of this file.
1 /*
2 ** array_core2.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 Feb 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_ARRAY_CORE2_H
26 #define SHKZ_ARRAY_CORE2_H
27 //
30 #include <functional>
31 #include <vector>
32 //
34 //
39 public:
40  //
41  DEFINE_MODULE(array_core2,"Array Core 2D","Array","Array core module")
42  //
43  array_core2() = default;
44  virtual ~array_core2() = default;
55  virtual void initialize( unsigned nx, unsigned ny, unsigned element_size ) = 0;
66  virtual void get( unsigned &nx, unsigned &ny, unsigned &element_size ) const = 0;
75  virtual size_t count( const parallel_driver &parallel ) const = 0;
86  virtual void copy( const array_core2 &array, std::function<void(void *target, const void *src)> copy_func, const parallel_driver &parallel ) = 0;
97  virtual void set( int i, int j, std::function<void(void *value_ptr, bool &active)> func ) = 0;
110  virtual const void * operator()( int i, int j, bool &filled ) const = 0;
119  virtual void parallel_actives ( std::function<void(int i, int j, void *value_ptr, bool &active, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) = 0;
126  virtual void serial_actives ( std::function<bool(int i, int j, void *value_ptr, bool &active, const bool &filled )> func ) = 0;
135  virtual void const_parallel_actives ( std::function<void(int i, int j, const void *value_ptr, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) const = 0;
142  virtual void const_serial_actives ( std::function<bool(int i, int j, const void *value_ptr, const bool &filled )> func ) const = 0;
151  virtual void parallel_all ( std::function<void(int i, int j, void *value_ptr, bool &active, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) = 0;
160  virtual void serial_all ( std::function<bool(int i, int j, void *value_ptr, bool &active, const bool &filled )> func ) = 0;
169  virtual void const_parallel_all ( std::function<void(int i, int j, const void *value_ptr, const bool &active, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) const = 0;
176  virtual void const_serial_all ( std::function<bool(int i, int j, const void *value_ptr, const bool &active, const bool &filled )> func ) const = 0;
185  virtual void dilate( std::function<void(int i, int j, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel ) = 0;
194  virtual void flood_fill( std::function<bool(void *value_ptr)> inside_func, const parallel_driver &parallel ) = 0;
203  virtual void const_parallel_inside ( std::function<void(int i, int j, const void *value_ptr, const bool &active, int thread_index )> func, const parallel_driver &parallel ) const = 0;
210  virtual void const_serial_inside ( std::function<bool(int i, int j, const void *value_ptr, const bool &active )> func ) const = 0;
211  //
212 protected:
213  //
214  array_core2( const array_core2 & ) = delete;
215  void operator=( const array_core2 & ) = delete;
216  //
217 };
218 //
219 using array2_ptr = std::unique_ptr<array_core2>;
220 //
222 //
223 #endif
224 //
array_core2::count
virtual size_t count(const parallel_driver &parallel) const =0
Count the number of active cells.
parallel_driver
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
array_core2::set
virtual void set(int i, int j, std::function< void(void *value_ptr, bool &active)> func)=0
Set a value of a cell.
array_core2::const_serial_all
virtual void const_serial_all(std::function< bool(int i, int j, const void *value_ptr, const bool &active, const bool &filled)> func) const =0
Loop over all the cells in serial order by read-only fashion.
array_core2::parallel_actives
virtual void parallel_actives(std::function< void(int i, int j, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel)=0
Loop over all the active cells in parallel.
array_core2::copy
virtual void copy(const array_core2 &array, std::function< void(void *target, const void *src)> copy_func, const parallel_driver &parallel)=0
Copy grid.
DEFINE_MODULE
#define DEFINE_MODULE(CLASS_T, LNG_NAME, ARG_NAME, DESCRIPTION)
Definition that simplifies the loading module.
Definition: recursive_configurable_module.h:39
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
array_core2::const_parallel_actives
virtual void const_parallel_actives(std::function< void(int i, int j, const void *value_ptr, const bool &filled, int thread_index)> func, const parallel_driver &parallel) const =0
Loop over all the active cells in parallel by read-only fashion.
array_core2::get
virtual void get(unsigned &nx, unsigned &ny, unsigned &element_size) const =0
Get grid information.
array_core2
Core module class for two dimensional array designed to be used in array2 class.
Definition: array_core2.h:38
array_core2::serial_all
virtual void serial_all(std::function< bool(int i, int j, void *value_ptr, bool &active, const bool &filled)> func)=0
Loop over all the cells in serial order.
parallel_driver.h
array_core2::const_serial_inside
virtual void const_serial_inside(std::function< bool(int i, int j, const void *value_ptr, const bool &active)> func) const =0
Loop over all the filled cells in serial order by read-only fashion.
array_core2::initialize
virtual void initialize(unsigned nx, unsigned ny, unsigned element_size)=0
Allocate grid memory with value.
array_core2::const_parallel_inside
virtual void const_parallel_inside(std::function< void(int i, int j, const void *value_ptr, const bool &active, int thread_index)> func, const parallel_driver &parallel) const =0
Loop over all the filled cells in parallel by read-only fashion.
array_core2::serial_actives
virtual void serial_actives(std::function< bool(int i, int j, void *value_ptr, bool &active, const bool &filled)> func)=0
Loop over all the active cells in serial order.
array_core2::const_serial_actives
virtual void const_serial_actives(std::function< bool(int i, int j, const void *value_ptr, const bool &filled)> func) const =0
Loop over all the active cells in serial order by read-only fashion.
array_core2::const_parallel_all
virtual void const_parallel_all(std::function< void(int i, int j, const void *value_ptr, const bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel) const =0
Loop over all the cells in parallel by read-only fashion.
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
recursive_configurable_module.h
array_core2::flood_fill
virtual void flood_fill(std::function< bool(void *value_ptr)> inside_func, const parallel_driver &parallel)=0
Perform flood fill.
recursive_configurable_module
recursive_configurable class that also inherits module.
Definition: recursive_configurable_module.h:49
array_core2::dilate
virtual void dilate(std::function< void(int i, int j, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel)=0
Dilate cells.
array_core2::parallel_all
virtual void parallel_all(std::function< void(int i, int j, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel)=0
Loop over all the cells in parallel.