Skip to content
Snippets Groups Projects
Commit 2f78edbf authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Reorder corners coordinates for convenience

Previously one required that corners a and b were defined such that
a[i]<b[j]. It is no more the case.

Also check that `a[i]-b[j] != 0`. This avoids crashes which would be
difficult to track.
parent 95f2c6f0
No related branches found
No related tags found
1 merge request!37Feature/language
......@@ -531,7 +531,23 @@ CartesianMeshBuilder::CartesianMeshBuilder(const TinyVector<Dimension>& a,
const TinyVector<Dimension, uint64_t>& size)
{
if (parallel::rank() == 0) {
this->_buildCartesianMesh(a, b, size);
TinyVector lenght = b - a;
for (size_t i = 0; i < Dimension; ++i) {
if (lenght[i] == 0) {
throw NormalError("invalid box definition corners share a component");
}
}
TinyVector<Dimension> corner0 = a;
TinyVector<Dimension> corner1 = b;
for (size_t i = 0; i < Dimension; ++i) {
if (corner0[i] > corner1[i]) {
std::swap(corner0[i], corner1[i]);
}
}
this->_buildCartesianMesh(corner0, corner1, size);
}
this->_dispatch<Dimension>();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment