|
@@ -654,8 +654,8 @@ bool MultiLayerMie<FloatType>::GetFieldConvergence () {
|
|
|
}
|
|
|
|
|
|
template <typename FloatType>
|
|
|
-void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int side_1_points,
|
|
|
- const int side_2_points,
|
|
|
+void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int first_side_points,
|
|
|
+ const int second_side_points,
|
|
|
const double relative_side_length,
|
|
|
const int plane_selected,
|
|
|
const double at_x, const double at_y,
|
|
@@ -665,35 +665,29 @@ void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int side_1_poi
|
|
|
SetMaxTerms(nmax_in);
|
|
|
std::vector<FloatType> Xp(0), Yp(0), Zp(0);
|
|
|
if (size_param_.size()<1) throw "Expect size_param_ to have at least one element before running a simulation";
|
|
|
- const FloatType max_coord_value = size_param_.back() * relative_side_length;
|
|
|
- const FloatType dx = max_coord_value*2/( (side_1_points<2 ? 2 : side_1_points) - 1.0);
|
|
|
- const FloatType dy = dx, dz = dx;
|
|
|
- auto push_coords = [&](
|
|
|
- const int nx, const int ny, const int nz,
|
|
|
- const FloatType xi, const FloatType yi, const FloatType zi) {
|
|
|
+ const FloatType total_R = size_param_.back();
|
|
|
+ const FloatType second_side_max_coord_value = total_R * relative_side_length;
|
|
|
+ // TODO add test if side_1_points <= 1 or side_2_points <= 1
|
|
|
+ const FloatType space_step = second_side_max_coord_value*2/( (second_side_points<2 ? 2 : second_side_points) - 1.0);
|
|
|
+ auto push_coords = [&](const int nx, const int ny, const int nz) {
|
|
|
+ const FloatType xi = at_x*total_R - space_step*(nx-1)/2;
|
|
|
+ const FloatType yi = at_y*total_R - space_step*(ny-1)/2;
|
|
|
+ const FloatType zi = at_z*total_R - space_step*(nz-1)/2;
|
|
|
for (int i = 0; i < nx; i++) {
|
|
|
for (int j = 0; j < ny; j++) {
|
|
|
for (int k = 0; k < nz; k++) {
|
|
|
- Xp.push_back(xi + static_cast<FloatType>(i) * dx);
|
|
|
- Yp.push_back(yi + static_cast<FloatType>(j) * dy);
|
|
|
- Zp.push_back(zi + static_cast<FloatType>(k) * dz);
|
|
|
+ Xp.push_back(xi + static_cast<FloatType>(i) * space_step);
|
|
|
+ Yp.push_back(yi + static_cast<FloatType>(j) * space_step);
|
|
|
+ Zp.push_back(zi + static_cast<FloatType>(k) * space_step);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
- if (plane_selected == Planes::kEk ) {
|
|
|
- push_coords(side_1_points, 1, side_2_points,
|
|
|
- -max_coord_value+at_x, at_y, -max_coord_value+at_z);
|
|
|
- }
|
|
|
- if (plane_selected == Planes::kHk ) {
|
|
|
- push_coords(1, side_1_points, side_2_points,
|
|
|
- at_x, -max_coord_value+at_y, -max_coord_value+at_z);
|
|
|
- }
|
|
|
- if (plane_selected == Planes::kEH) {
|
|
|
- push_coords(side_1_points, side_2_points, 1,
|
|
|
- -max_coord_value+at_x, -max_coord_value+at_y, at_z);
|
|
|
- }
|
|
|
- const unsigned int total_size = side_1_points*side_2_points;
|
|
|
+ // TODO add test to check that side_2_points is for z-axis
|
|
|
+ if (plane_selected == Planes::kEk) push_coords(first_side_points, 1, second_side_points);
|
|
|
+ if (plane_selected == Planes::kHk) push_coords(1, first_side_points, second_side_points);
|
|
|
+ if (plane_selected == Planes::kEH) push_coords(first_side_points, second_side_points, 1);
|
|
|
+ const unsigned int total_size = first_side_points*second_side_points;
|
|
|
if (Xp.size() != total_size || Yp.size() != total_size || Zp.size() != total_size)
|
|
|
throw std::invalid_argument("Error! Wrong dimension of field monitor points for cartesian grid!");
|
|
|
SetFieldCoords({Xp, Yp, Zp});
|