39 : coord_m(rhs.coord_m), maps_m(rhs.maps_m), constantSpacing_m(rhs.constantSpacing_m) {}
41 NDGrid::NDGrid(std::vector<int> size, std::vector<const double*> gridCoordinates)
42 : coord_m(), maps_m(), constantSpacing_m(false) {
43 for (
unsigned int i = 0; i <
size.size(); i++) {
46 "NDGrid::NDGrid(...)",
"ND Grid must be at least 1x1x...x1 grid"));
49 std::vector<double>(gridCoordinates[i], gridCoordinates[i] +
size[i]));
55 : coord_m(nDimensions), maps_m(), constantSpacing_m(true) {
56 for (
int i = 0; i < nDimensions; i++) {
59 "NDGrid::NDGrid(...)",
"ND Grid must be at least 1x1x...x1 grid"));
62 for (
unsigned int j = 0; j <
coord_m[i].size(); j++) {
69 : coord_m(gridCoordinates), maps_m(), constantSpacing_m(false) {
70 for (
unsigned int i = 0; i < gridCoordinates.size(); i++) {
71 if (gridCoordinates[i].
size() < 1) {
73 "NDGrid::NDGrid(...)",
"ND Grid must be at least 1x1x...x1 grid"));
80 double* array =
new double[
coord_m[dimension].size()];
81 for (
unsigned int i = 0; i <
coord_m[dimension].size(); i++) {
82 array[i] =
coord_m[dimension][i];
93 std::vector<int> index(
coord_m.size(), 0);
94 std::vector<int> content(
coord_m.size(), 1);
95 for (
int i =
int(index.size() - 2); i >= 0; i--) {
96 content[i] = content[i + 1] *
coord_m[i + 1].size();
99 for (
int i = 0; i < int(index.size()); i++) {
100 index[i] = difference / content[i];
101 difference -= index[i] * content[i];
103 for (
unsigned int i = 0; i < index.size(); i++) {
106 for (
int i =
int(index.size()) - 1; i > 0; i--) {
117 if (difference < 0) {
120 std::vector<int> index(
coord_m.size(), 0);
121 std::vector<int> content(
coord_m.size(), 1);
122 for (
int i =
int(index.size() - 2); i >= 0; i--) {
123 content[i] = content[i + 1] *
coord_m[i + 1].size();
126 for (
int i = 0; i < int(index.size()); i++) {
127 index[i] = difference / content[i];
128 difference -= index[i] * content[i];
130 for (
unsigned int i = 0; i < index.size(); i++) {
133 for (
int i =
int(index.size()) - 1; i > 0; i--) {
152 while (lhs[i] ==
int(
coord_m[i].
size()) && i > 0) {
164 while (lhs[i] == 0 && i > 0) {
174 for (
unsigned int i = 0; i <
coord_m.size(); i++) {
175 for (
unsigned int j = 0; j <
coord_m[i].size() - 1; j++) {
176 double coord_j1 =
coord_m[i][j + 1];
177 double coord_j0 =
coord_m[i][j];
178 double coord_1 =
coord_m[i][1];
179 double coord_0 =
coord_m[i][0];
180 if (std::abs(1 - (coord_j1 - coord_j0) / (coord_1 - coord_0)) > tolerance_m) {
194 return (lhs[i] > rhs[i]);
199 std::vector<int> index(
coord_m.size(), 0);
200 std::vector<int> content(
coord_m.size(), 1);
201 for (
int i =
int(index.size() - 2); i >= 0; i--) {
202 content[i] = content[i + 1] *
coord_m[i + 1].size();
204 for (
int i = 0; i < int(index.size()); i++) {
205 difference += (lhs.
state_m[i] - 1) * (content[i]);
211 std::vector<int> index(
coord_m.size());
212 std::vector<double> pos(position, position +
coord_m.size());
214 for (
unsigned int i = 0; i <
coord_m.size(); i++) {
215 if (index[i] <
int(
coord_m[i].
size() - 1) && index[i] >= 0) {
217 (2 * (position[i] -
coord_m[i][index[i]])
235 std::vector<std::vector<double> >
coord(
coord_m.size());
236 for (
size_t i = 0; i <
coord.size(); ++i) {
239 "NDGrid::dual(...)",
"ND Grid must be at least 2x2x...x2 grid"));
242 for (
size_t j = 0; j <
coord[i].size(); ++j) {
std::vector< int > state_m
Base class for meshing routines.
virtual Mesh::Iterator & addEquals(Mesh::Iterator &lhs, int difference) const
virtual Mesh::Iterator & addOne(Mesh::Iterator &lhs) const
virtual Mesh::Iterator & subOne(Mesh::Iterator &lhs) const
int toInteger(const Mesh::Iterator &lhs) const
Mesh::Iterator getNearest(const double *position) const
std::vector< std::vector< double > > coord_m
double min(const int &dimension) const
double * newCoordArray(const int &dimension) const
NDGrid()
////// NDGrid ///////
void lowerBound(const std::vector< double > &pos, std::vector< int > &xIndex) const
void setConstantSpacing(bool spacing)
virtual Mesh::Iterator & subEquals(Mesh::Iterator &lhs, int difference) const
int size(const int &dimension) const
double & coord(const int &index, const int &dimension)
virtual bool isGreater(const Mesh::Iterator &lhs, const Mesh::Iterator &rhs) const