Shiokaze Framework
A research-oriented fluid solver for computer graphics
array_core3.h
Go to the documentation of this file.
1 /*
2 ** array_core3.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_CORE3_H
26 #define SHKZ_ARRAY_CORE3_H
27 //
30 #include <functional>
31 #include <vector>
32 //
34 //
39 public:
40  //
41  DEFINE_MODULE(array_core3,"Array Core 3D","Array","Array core module")
42  //
43  array_core3() = default;
44  virtual ~array_core3() = default;
57  virtual void initialize( unsigned nx, unsigned ny, unsigned nz, unsigned element_size ) = 0;
70  virtual void get( unsigned &nx, unsigned &ny, unsigned &nz, unsigned &element_size ) const = 0;
79  virtual size_t count( const parallel_driver &parallel ) const = 0;
90  virtual void copy( const array_core3 &array, std::function<void(void *target, const void *src)> copy_func, const parallel_driver &parallel ) = 0;
103  virtual void set( int i, int j, int k, std::function<void(void *value_ptr, bool &active)> func ) = 0;
118  virtual const void * operator()( int i, int j, int k, bool &filled ) const = 0;
127  virtual void parallel_actives ( std::function<void(int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) = 0;
134  virtual void serial_actives ( std::function<bool(int i, int j, int k, void *value_ptr, bool &active, const bool &filled )> func ) = 0;
141  virtual void const_parallel_actives ( std::function<void(int i, int j, int k, const void *value_ptr, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) const = 0;
148  virtual void const_serial_actives ( std::function<bool(int i, int j, int k, const void *value_ptr, const bool &filled )> func ) const = 0;
157  virtual void parallel_all ( std::function<void(int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) = 0;
166  virtual void serial_all ( std::function<bool(int i, int j, int k, void *value_ptr, bool &active, const bool &filled )> func ) = 0;
175  virtual void const_parallel_all ( std::function<void(int i, int j, int k, const void *value_ptr, const bool &active, const bool &filled, int thread_index )> func, const parallel_driver &parallel ) const = 0;
184  virtual void const_serial_all ( std::function<bool(int i, int j, int k, const void *value_ptr, const bool &active, const bool &filled )> func ) const = 0;
193  virtual void dilate( std::function<void(int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel ) = 0;
202  virtual void flood_fill( std::function<bool(void *value_ptr)> inside_func, const parallel_driver &parallel ) = 0;
211  virtual void const_parallel_inside ( std::function<void(int i, int j, int k, const void *value_ptr, const bool &active, int thread_index )> func, const parallel_driver &parallel ) const = 0;
218  virtual void const_serial_inside ( std::function<bool(int i, int j, int k, const void *value_ptr, const bool &active)> func ) const = 0;
219  //
220 protected:
221  //
222  array_core3( const array_core3 & ) = delete;
223  void operator=( const array_core3 & ) = delete;
224  //
225 };
226 //
227 using array3_ptr = std::unique_ptr<array_core3>;
228 //
230 //
231 #endif
232 //
array_core3::set
virtual void set(int i, int j, int k, std::function< void(void *value_ptr, bool &active)> func)=0
Set a value of a cell.
array_core3::const_serial_all
virtual void const_serial_all(std::function< bool(int i, int j, int k, 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_core3::parallel_all
virtual void parallel_all(std::function< void(int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel)=0
Loop over all the cells in parallel.
parallel_driver
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
array_core3::const_parallel_all
virtual void const_parallel_all(std::function< void(int i, int j, int k, 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.
array_core3
Core module class for three dimensional array designed to be used in array3 class.
Definition: array_core3.h:38
array_core3::serial_actives
virtual void serial_actives(std::function< bool(int i, int j, int k, void *value_ptr, bool &active, const bool &filled)> func)=0
Loop over all the active cells in serial order.
array_core3::const_parallel_inside
virtual void const_parallel_inside(std::function< void(int i, int j, int k, 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_core3::get
virtual void get(unsigned &nx, unsigned &ny, unsigned &nz, unsigned &element_size) const =0
Get grid information.
array_core3::initialize
virtual void initialize(unsigned nx, unsigned ny, unsigned nz, unsigned element_size)=0
Allocate grid memory with value.
array_core3::flood_fill
virtual void flood_fill(std::function< bool(void *value_ptr)> inside_func, const parallel_driver &parallel)=0
Perform flood fill.
array_core3::count
virtual size_t count(const parallel_driver &parallel) const =0
Count the number of active cells.
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_core3::copy
virtual void copy(const array_core3 &array, std::function< void(void *target, const void *src)> copy_func, const parallel_driver &parallel)=0
Copy grid.
array_core3::const_serial_inside
virtual void const_serial_inside(std::function< bool(int i, int j, int k, const void *value_ptr, const bool &active)> func) const =0
Loop over all the filled cells in serial order by read-only fashion.
array_core3::const_serial_actives
virtual void const_serial_actives(std::function< bool(int i, int j, int k, const void *value_ptr, const bool &filled)> func) const =0
Loop over all the active cells in serial order by read-only fashion.
array_core3::serial_all
virtual void serial_all(std::function< bool(int i, int j, int k, void *value_ptr, bool &active, const bool &filled)> func)=0
Loop over all the cells in serial order.
array_core3::dilate
virtual void dilate(std::function< void(int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_index)> func, const parallel_driver &parallel)=0
Dilate cells.
parallel_driver.h
array_core3::const_parallel_actives
virtual void const_parallel_actives(std::function< void(int i, int j, int k, 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_core3::parallel_actives
virtual void parallel_actives(std::function< void(int i, int j, int k, 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.
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
recursive_configurable_module.h
recursive_configurable_module
recursive_configurable class that also inherits module.
Definition: recursive_configurable_module.h:49