Efficient extrude with complicated 2D mesh
I have a complicated 2D mesh that I need to extrude into 3D and generate different volume names for each element. I also need to define surface boundaries on 6 sides of the "cube".
Do you recommend any more efficient way other than to extrude each 2D surface individually and assign volume names to each extrusion?
I'm attaching a simple example of what I am talking about, but the actual 2D mesh has 100's of different objects.
Thank you for all your great work!
// Two Rod Mesh Generator
// 2021-06-02
// Run with: gmsh -3 simple.geo
// set characteristic length
lc=0.2;
Mesh.MshFileVersion = 2.2;
Printf("Start");
Printf("lc = %f", lc);
rad=1.0;
Height=4.0;
Physical Volume("mat01")={}; // reserve numbers 1-3
Physical Volume("mat02")={};
Physical Volume("mat03")={};
// ==============================
// define rod 1
Point( 1) = { 2*rad, 2*rad, 0, lc}; // center
Point( 2) = { rad, 2*rad, 0, lc}; // left
Point( 3) = { 2*rad, 3*rad, 0, lc}; // top
Point( 4) = { 3*rad, 2*rad, 0, lc}; // right
Point( 5) = { 2*rad, rad, 0, lc}; // bottom
Circle(10) = { 2, 1, 3};
Circle(11) = { 3, 1, 4};
Circle(12) = { 4, 1, 5};
Circle(13) = { 5, 1, 2};
Line Loop(14) = {10,11,12,13}; // fuel rod surface
Plane Surface(15) = {14}; // fuel region
//Physical Surface("Fuel1")={15};
// ==============================
// define rod 2
Point( 6) = { 5*rad, 2*rad, 0, lc}; // center
Point( 7) = { 4*rad, 2*rad, 0, lc}; // left
Point( 8) = { 5*rad, 3*rad, 0, lc}; // top
Point( 9) = { 6*rad, 2*rad, 0, lc}; // right
Point(10) = { 5*rad, rad, 0, lc}; // bottom
Circle(20) = { 7, 6, 8};
Circle(21) = { 8, 6, 9};
Circle(22) = { 9, 6,10};
Circle(23) = {10, 6, 7};
Line Loop(24) = {20,21,22,23}; // fuel rod surface
Plane Surface(25) = {24}; // fuel region
//Physical Surface("Fuel2")={25};
// ==============================
// define coolant region
Point(11) = { 0, 0, 0, lc};
Point(12) = { 7*rad, 0, 0, lc};
Point(13) = { 7*rad, 4*rad, 0, lc};
Point(14) = { 0, 4*rad, 0, lc};
Line(15) = {11,12};
Line(16) = {12,13};
Line(17) = {13,14};
Line(18) = {14,11};
Line Loop(19) = {15, 16, 17, 18};
Plane Surface(26)={19,24,14}; // coolant
//Physical Surface("RegCool")={26};
// ==============================
// Bottom plane
Physical Surface("Bottom")={15, 25, 26};
//====================================================
// Method 1:
// Extrude each region separately to assign volume names
// The "layers" option will extrude the mesh to create "wedges"
// Remove the "layers" option to get tets
Physical Surface("Top") = {}; // init
Physical Surface("Sides") = {}; // init
newEntities[]=Extrude {0, 0, Height} { Surface{15}; Layers{10}; };
Physical Volume("mat01")+={newEntities[1]};
Physical Surface("Top") += {newEntities[0]};
newEntities[]=Extrude {0, 0, Height} { Surface{25}; Layers{10}; };
Physical Volume("mat02")+={newEntities[1]};
Physical Surface("Top") += {newEntities[0]};
newEntities[]=Extrude {0, 0, Height} { Surface{26}; Layers{10}; };
Physical Volume("mat03")+={newEntities[1]};
Physical Surface("Top") += {newEntities[0]};
Physical Surface("Sides") += {newEntities[2]}; // pick first 4 sides
Physical Surface("Sides") += {newEntities[3]}; // pick first 4 sides
Physical Surface("Sides") += {newEntities[4]}; // pick first 4 sides
Physical Surface("Sides") += {newEntities[5]}; // pick first 4 sides
//====================================================
Printf("Finished successfully");