Peano
Loading...
Searching...
No Matches
Block.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include "BlockBoundary.h"
6
7#include <string>
8#include <vector>
9
10namespace toolbox {
11 namespace curvi {
12 class Block {
13 public:
15
16 Block(Coordinate a_coords[3], int a_index_offset[3], int a_index_size[3], std::vector<double> a_nodes);
17
19 Block(BlockBoundary boundary, int a_index_offset[3], int a_index_size[3]);
20
21 Block(const Block& block); /*Copy constructor*/
22 Block& operator=(Block block); /*Copy assignment*/
23
24 Coordinate getCoord(int idx) const;
25 void getCoord(Coordinate a_coord[3]) const;
26 void getIndexSize(int a_index_size[3]) const;
27 void getIndexOffset(int a_index_offset[3]) const;
28
30 std::function<void(const Block&, int, int, int, Block&)> func,
31 int mode_z,
32 int mode_y,
33 int mode_x
34 ) const;
35
36
38 std::function<void(const Block&, int, int, int, Block&)> func,
39 int in_z,
40 int in_y,
41 int in_x,
42 int out_z,
43 int out_y,
44 int out_x
45 ) const;
46
47 /* Block interpolate(const std::vector<double>& nodes, */
48 /* int mode_z, int mode_y , int mode_x) const; */
49
50 void interpolate(const double node[3], double result[3], const int strip = 10) const;
51
52 Block getMetricDerivatives(double** dudx, int nodes_z, int nodes_y, int nodes_x, double dx[3]) const;
53
54 void getIndexRange(Coordinate coord, int start, int end, std::vector<int>& a_range) const;
55 void getIndexRange(Coordinate coord, std::vector<int>& a_range) const;
56
62 friend Block operator+(Block lhs, const Block& rhs) /*merge blocks*/;
63
64 double& operator()(int coord, int k, int j, int i);
65 const double& operator()(int coord, int k, int j, int i) const;
66
67 double& operator()(int coord, Coordinate coord_k, int k, Coordinate coord_j, int j, Coordinate coord_i, int i);
68
69 const double& operator()(
70 int coord,
71 Coordinate coord_k,
72 int k,
73 Coordinate coord_j,
74 int j,
75 Coordinate coord_i,
76 int i
77 ) const;
78
79 std::string toString() const;
80
81 void appendToNetCDF(std::string filename, std::string prefix);
82 void toNetCDF(std::string filename) const;
83
84 private:
85 std::vector<double> nodes;
88 int index_size[3];
89 };
90 } // namespace curvi
91} // namespace toolbox
void toNetCDF(std::string filename) const
friend Block operator+(Block lhs, const Block &rhs)
void getIndexRange(Coordinate coord, int start, int end, std::vector< int > &a_range) const
Block getMetricDerivatives(double **dudx, int nodes_z, int nodes_y, int nodes_x, double dx[3]) const
void appendToNetCDF(std::string filename, std::string prefix)
int index_offset[3]
Definition Block.h:87
std::string toString() const
void getCoord(Coordinate a_coord[3]) const
Block(BlockBoundary boundary)
Coordinate getCoord(int idx) const
Block resample(std::function< void(const Block &, int, int, int, Block &)> func, int in_z, int in_y, int in_x, int out_z, int out_y, int out_x) const
double & operator()(int coord, Coordinate coord_k, int k, Coordinate coord_j, int j, Coordinate coord_i, int i)
Block(const Block &block)
std::vector< double > nodes
Definition Block.h:85
void getIndexOffset(int a_index_offset[3]) const
Block(BlockBoundary boundary, int a_index_offset[3], int a_index_size[3])
double & operator()(int coord, int k, int j, int i)
Block apply(std::function< void(const Block &, int, int, int, Block &)> func, int mode_z, int mode_y, int mode_x) const
Coordinate coords[3]
Definition Block.h:86
const double & operator()(int coord, int k, int j, int i) const
void getIndexSize(int a_index_size[3]) const
Block & operator=(Block block)
const double & operator()(int coord, Coordinate coord_k, int k, Coordinate coord_j, int j, Coordinate coord_i, int i) const
void getIndexRange(Coordinate coord, std::vector< int > &a_range) const
Block(Coordinate a_coords[3], int a_index_offset[3], int a_index_size[3], std::vector< double > a_nodes)
void interpolate(const double node[3], double result[3], const int strip=10) const