node ordering for 3D structured hexahedral meshes in Ubuntu
codes(c++ api)
gmsh::initialize();
gmsh::model::add("cuboid");//Add a new model, with name name, and set it as the current model
x1 = 2;
y1 = 1;
z1 = 0;
x2 = 1;
y2 = 2;
z2 = 1;
x_N = 1;
y_N = 1;
z_N = 1;
int cuboid_tag, x_number = x_N, y_number = y_N, z_number = z_N;
double dx, dy, dz;
dx = fabs(x2 - x1);
dy = fabs(y1 - y2);
dz = fabs(z2 - z1);
cuboid_tag = gmsh::model::occ::addRectangle(x2, y1, z1, dx, dy);
gmsh::model::occ::synchronize();
std::vector<int> curveLoopTags;
std::vector<std::vector<int> > curveTags;
gmsh::model::occ::getCurveLoops(cuboid_tag, curveLoopTags, curveTags);
for (int i = 0; i < curveTags[0].size(); ++i)
{
double x = 0.0, y = 0.0, z = 0.0;
gmsh::model::occ::getCenterOfMass(1, curveTags[0][i], x, y, z);
double eps = 1e-6;
if(fabs(x - x1) < eps || fabs(x - x2) < eps)
{
if(fabs(y - (y1 + y2) / 2) < eps)
{
gmsh::model::mesh::setTransfiniteCurve(curveTags[0][i], y_number + 1);
}
}
else if(fabs(y - y1) < eps || fabs(y - y2) < eps)
{
if(fabs(x - (x1 + x2) / 2) < eps)
{
gmsh::model::mesh::setTransfiniteCurve(curveTags[0][i], x_number + 1);
}
}
else
{
// do nothing
}
}
gmsh::model::mesh::setTransfiniteSurface(cuboid_tag);//{1,2,3,4}
gmsh::model::occ::synchronize();
// extrude the pattern
// int mesh_layer = static_cast<int>(z_number);
std::vector<std::pair<int, int> > extrude_outDimTags;
const std::vector<int> numElements = {z_number};
// double height = dz / z_number;
const std::vector<double> heights = {1};
gmsh::model::occ::extrude({{2, cuboid_tag}}, 0, 0, dz, extrude_outDimTags, numElements, heights, true);
gmsh::model::occ::synchronize();
gmsh::option::setNumber("General.Terminal", 0);// not print information in Terminal
gmsh::model::mesh::generate(2);
gmsh::model::mesh::recombine();
gmsh::model::occ::synchronize();
gmsh::model::mesh::generate(3);
gmsh::model::occ::synchronize();
gmsh::model::mesh::setOrder(2);
gmsh::write("hex_order2_27.bdf");
gmsh::write("hex_order2_27.msh");
gmsh::finalize();
Question:
I run the codes in windows10 and Ubuntu, respectively. But i found there is something wrong when i did FEM computation in Ubuntu, it is right in win10. The codes are same with each other. Then i compare the difference between these two things. The big difference is the node ordering.
In win10, the result is 27 1 2 3 4 5 6 7 8 9 12 13 10 14 11 16 18 15 20 17 19 21 22 25 23 24 26 27.
In Ubuntu, the result is 27 2 3 4 1 6 7 8 5 10 9 14 11 16 12 18 13 17 15 19 20 21 23 22 24 25 26 27.
Obviously, the node ordering is very different.The node ordering of the win10 is same with Gmsh Reference Manual. The Ubuntu's is not. The node ordering of Gmsh Reference Manual is below:
these two files are the result of Gmsh meshing in win10 and Ubuntu, respectively.
So could you please tell why it happens? Or something i did wrong in codes? And how should i modify the code? Thank you very much!