Problem about function "addDiscreteEntity"
Hello!
I'm trying to remesh discrete entities which is from an imported mesh by using function "addDiscreteEntity".
This is my code modified from X2 example running in win-10-X64.
#include <gmsh.h> int main(int argc, char** argv) { gmsh::initialize(); gmsh::model::add("x2"); // The tags of the corresponding nodes: std::vector<std::size_t> nodes; // The x, y, z coordinates of all the nodes: std::vector<double> coords; nodes = { 1, 2, 3, 4 }; coords = { 0.0, 0.0, 0.0,//node 1 0.0, 1.0, 0.0,//node 2 1.0, 0.0, 0.0,//node 3 1.0, 1.0, 0.0 };//node 4 // Create 4 discrete points gmsh::model::addDiscreteEntity(0, 1); gmsh::model::setCoordinates(1, 0.0, 0.0, 0.0); gmsh::model::addDiscreteEntity(0, 2); gmsh::model::setCoordinates(2, 1.0, 0.0, 0.0); gmsh::model::addDiscreteEntity(0, 3); gmsh::model::setCoordinates(3, 1.0, 1.0, 0.0); gmsh::model::addDiscreteEntity(0, 4); gmsh::model::setCoordinates(4, 0.0, 1.0, 0.0); // Create 4 discrete bounding curves, with their boundary points gmsh::model::addDiscreteEntity(1, 1, { 1, 2 }); gmsh::model::addDiscreteEntity(1, 2, { 2, 3 }); gmsh::model::addDiscreteEntity(1, 3, { 3, 4 }); gmsh::model::addDiscreteEntity(1, 4, { 4, 1 }); // Create one discrete surface, with its bounding curves gmsh::model::addDiscreteEntity(2, 1, { 1, 2, 3, 4 }); // Add all the nodes on the surface gmsh::model::mesh::addNodes(2, 1, nodes, coords); // Type 15 for point elements: gmsh::model::mesh::addElementsByType(1, 15, {}, { 1 }); gmsh::model::mesh::addElementsByType(2, 15, {}, { 3 }); gmsh::model::mesh::addElementsByType(3, 15, {}, { 4 }); gmsh::model::mesh::addElementsByType(4, 15, {}, { 2 }); // Type 1 for 2-node line elements: gmsh::model::mesh::addElementsByType(1, 1, {}, { 1, 3 }); gmsh::model::mesh::addElementsByType(2, 1, {}, { 3, 4 }); gmsh::model::mesh::addElementsByType(3, 1, {}, { 2, 4 }); gmsh::model::mesh::addElementsByType(4, 1, {}, { 1, 2 }); // Type 3 for 4-node quadrangle elements: // gmsh::model::mesh::addElementsByType(1, 3, {}, { 1, 3, 4, 2 }); // Fault // Type 2 for 3-node triangle elements: gmsh::model::mesh::addElementsByType(1, 2, {}, { 1,3,2,3,4,2 }); // Right // Reclassify the nodes on the curves and the points (since we put them all on // the surface before with
addNodes' for simplicity)
gmsh::model::mesh::reclassifyNodes();
// Create a geometry for the discrete curves and surfaces, so that we can
// remesh them later on:
gmsh::model::mesh::createGeometry();
gmsh::option::setNumber("Mesh.MeshSizeMin", 0.05);
gmsh::option::setNumber("Mesh.MeshSizeMax", 0.05);
gmsh::model::mesh::generate(2);
gmsh::fltk::run();
gmsh::finalize();
return 0;
}`
When I using function "addElementsByType" to add 3-node triangle elements, remeshing discrete entities is successful. But for 4-node quadrangle elements, remeshing discrete entities is failed.