40 constantSpacing_m(rhs.constantSpacing_m) {
43NDGrid::NDGrid(std::vector<int> size, std::vector<const double *> gridCoordinates)
44 : coord_m(), maps_m(), constantSpacing_m(false) {
45 for (
unsigned int i=0; i<
size.size(); i++) {
48 "ND Grid must be at least 1x1x...x1 grid"));
50 coord_m.push_back(std::vector<double>(gridCoordinates[i],
51 gridCoordinates[i] +
size[i]));
57 : coord_m(nDimensions), maps_m(), constantSpacing_m(true) {
58 for (
int i=0; i<nDimensions; i++) {
61 "ND Grid must be at least 1x1x...x1 grid"));
64 for (
unsigned int j=0; j<
coord_m[i].size(); j++) {
71 : coord_m(gridCoordinates), maps_m(), constantSpacing_m(false) {
72 for (
unsigned int i=0; i<gridCoordinates.size(); i++) {
73 if (gridCoordinates[i].
size() < 1) {
75 "ND Grid must be at least 1x1x...x1 grid"));
83 double * array =
new double[
coord_m[dimension].size() ];
84 for (
unsigned int i=0; i<
coord_m[dimension].size(); i++) {
85 array[i] =
coord_m[dimension][i];
96 std::vector<int> index(
coord_m.size(),0);
97 std::vector<int> content(
coord_m.size(),1);
98 for (
int i =
int(index.size()-2); i >= 0; i--) {
99 content[i] = content[i+1]*
coord_m[i+1].size();
101 for (
int i = 0; i < int(index.size()); i++) {
102 index[i] = difference/content[i];
103 difference -= index[i] * content[i];
105 for (
unsigned int i=0; i<index.size(); i++) {
108 for (
int i =
int(index.size())-1; i > 0; i--) {
119 if (difference < 0) {
122 std::vector<int> index(
coord_m.size(),0);
123 std::vector<int> content(
coord_m.size(),1);
124 for (
int i =
int(index.size()-2); i >= 0; i--) {
125 content[i] = content[i+1]*
coord_m[i+1].size();
127 for (
int i = 0; i < int(index.size()); i++) {
128 index[i] = difference/content[i];
129 difference -= index[i] * content[i];
131 for (
unsigned int i = 0; i < index.size(); i++) {
134 for (
int i=
int(index.size())-1; i>0; i--) {
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++)
216 if (index[i] <
int(
coord_m[i].
size()-1) && index[i] >= 0) {
217 index[i] += (2*(position[i] -
coord_m[i][index[i]]) >
coord_m[i][index[i]+1]-
coord_m[i][index[i]] ? 2 : 1);
233 std::vector<std::vector<double> >
coord(
coord_m.size());
234 for (
size_t i = 0; i <
coord.size(); ++i) {
237 "ND Grid must be at least 2x2x...x2 grid"));
240 for (
size_t j = 0; j <
coord[i].size(); ++j) {
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Base class for meshing routines.
std::vector< int > state_m
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
std::vector< std::vector< double > > coord_m
Mesh::Iterator getNearest(const double *position) const
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
The base class for all OPAL exceptions.