Several questions while merging mesh files
Dear experts
I want to create several blocks and then merge them (since error occurs when mesh the whole geometry once), the separated mesh looks fine but when I merge them the output mesh looks wired and missing many elements. Here is my code:
#include <gmsh.h>
#include <iostream>
#include <string>
int main(int argc, char** argv){
gmsh::initialize(argc, argv);
for(int n=0; n<2; n++){
char str[20];
char str_save[20];
sprintf(str, "prototype_%d", n);
sprintf(str_save, "prototype_%d.msh", n);
const std::string str_s = str_save;
gmsh::model::add(str);
gmsh::option::setNumber("General.NumThreads", 1000);
gmsh::option::setNumber("Mesh.ElementOrder", 2);
gmsh::option::setNumber("Mesh.HighOrderOptimize", 1);
gmsh::option::setNumber("Mesh.MeshSizeFromCurvature", 10);
std::vector<int> surface_sense, surface_field;
for(int i=0; i<7; i++){
for(int j=0; j<7; j++){
if(i%2 && j%2){
gmsh::model::occ::addCylinder(-25.2+i*8.4, -24+j*8., n*5, 0, 0, 5, 0.125);
surface_sense.push_back( (i*7+j+1)*3-2 );
surface_sense.push_back( (i*7+j+1)*3-1 );
surface_sense.push_back( (i*7+j+1)*3 );
}
else{
gmsh::model::occ::addCylinder(-25.2+i*8.4, -24+j*8., n*5, 0, 0, 5, 0.63);
surface_field.push_back( (i*7+j+1)*3-2 );
surface_field.push_back( (i*7+j+1)*3-1 );
surface_field.push_back( (i*7+j+1)*3 );
}
}
}
gmsh::model::occ::addBox(-26, -25, n*5, 52, 50, 5);
gmsh::model::occ::removeAllDuplicates();
gmsh::model::occ::synchronize();
for(int i=1; i<51; i++){
gmsh::model::addPhysicalGroup(3,{i},i);
}
gmsh::model::addPhysicalGroup(2,{surface_sense},1);
gmsh::model::addPhysicalGroup(2,{surface_field},2);
gmsh::model::addPhysicalGroup(2,{148,149,150,151,152,153},3);
gmsh::model::mesh::generate(3);
gmsh::write(str_s);
}
for(int n=0; n<2; n++){
char* str;
sprintf(str, "prototype_%d.msh", n);
gmsh::merge(str);
}
gmsh::model::occ::synchronize();
gmsh::write("prototype_merged.msh");
gmsh::fltk::run();
gmsh::finalize();
return 0;
}
My questions:
- Gmsh app won't open even I add
gmsh::flak::run()
but I can open gmsh after runtime withgmsh prototype_merged.msh
- Merged mesh looks wired and missing many elements
- If I define a Physical surface "1" for first geometry, then also define physical surface "1" for the 2nd geometry, what will be the Physical surface "1" in merged mesh? Will they been merged also?