Dear Daegil and Timo,
Not sure if this thread is finished, but I thought I would offer some information.
As always I have the disclaimer that "I don't know what I am talking about." :)
I may have run into some similar problems as you Daegil with creating a mesh.
Somehow, I believe the boundary conditions are affected by the gmsh .msh file
when you try to use it with deal.ii
Most likely this is because gmsh just was not made to do hexahedrons.
The problem with gmsh seems to come from certain elements or geometric
objects that result in compiling the .geo file and getting the .msh file
You will get nodes, lines, faces,... and volume elements in the .msh file.
I think that I downloaded a gmsh manual that will tell you the
numbering used in the .msh file that indicates each of these objects.
Depending on what you get in your mesh file, one possibility is to remove
all but the nodes and the volume elements. I believe this will get rid of
the boundary condition problem that you might be experiencing.
The other option, if your mesh is not too complicated is to code it yourself.
You can do this with gmsh. A sample .geo code is located below that hopefully
can help you get started. I ran into another code online that did this, but cannot
seem to find it anymore.
You can save this code as a .geo file and then open it with gmsh
As indicated at the bottom of the code, do mesh 3d with gmsh and save
the resulting mesh. It looks like you will only get the node and volume
elements you want if you do this. (You might be able to figure out how to make
your grid in gmsh and get just the nodes and volume elements without having to write a code).
Hope this helps.
Dan Brauss
// electrode.geo
// this is supposed to be a mesh of an electrode
// Note: Orientation - the overall 4 pieces are referred to with "front" and "back"
// This reference is with respect to the positive x-axis
// (facing into the positive x-axis and seeing the yz-plane
// in the background. The "left" is with respect to the negative
// side of the y-axis and the "right" is with respect to the
// positive side of the y-axis. This is true for the pieces (subvolumes)
// As we create a piece, the reference for the surfaces may be
// different than the pieces and depend on the piece. When we
// finish creating a piece and move to the next piece, the reference to
// the parts of the piece are with respect to the new orientation. We
// create the pieces in a circle going counterclockwise and rotate our
// reference frame in that direction. For example, when going from the
// first piece to the second, we go from facing into the positive x-axis
// and having the xy-plane in the background to facing into the positive
// y-axis and having the xz-plane in the background. We refer to the
// components of the piece with "left" and "right" but from this new viewpoint.
Mesh.MshFileVersion = 1; // saving in a file format that can be used with dealii
lc = 0.10; // default distance between nodes
m = 4; // nodes per line
width = 0.60; // width of electrode
height = 0.40; // height of electrode
//************************************
// First Piece of Electrode (Back Left)
//************************************************
back_length = 1.60;
front_length = 1.00;
Point(1) = {0.20, 0.0, 0.0, lc}; //back bottom right
Point(2) = {0.20+width, 0.0, 0.0, lc}; //front bottom right
Point(3) = {0.20+width, 0.0, 0.0 + height, lc}; // front top right
Point(4) = {0.20, 0.0, 0.0 + height, lc}; // back top right
Point(11) = {0.20, 0.0-back_length, 0.0, lc}; // back bottom left
Point(12) = {0.20+width, 0.0-front_length,0.0,lc}; // front bottom left
Point(13) = {0.20+width,0.0-front_length,0.0+height,lc}; // front top left
Point(14) = {0.20, 0.0-back_length, 0.0 + height, lc}; // back top left
Line(1) = {1,2}; // right side bottom
Line(2) = {2,3}; // right side front
Line(3) = {3,4}; // right side top
Line(4) = {4,1}; // right side back
Transfinite Line{1,2,3,4} = m;
Line Loop(5) = {1,2,3,4};
Ruled Surface(1) = {5}; // right surface
Transfinite Surface{1} = {1,2,3,4};
Recombine Surface{1};
Line(11) = {11,12}; // back right
Line(12) = {12,13}; // back top
Line(13) = {13,14}; // back left
Line(14) = {14,11}; // back bottom
Transfinite Line{11,12,13,14} = m;
Line Loop(15) = {11,12,13,14};
Ruled Surface(6) = {15}; // left surface
Transfinite Surface{6} = {11,12,13,14};
Recombine Surface{6};
// Front Surface
Line(5) = {1,11};
Line(6) = {2,12};
Line(7) = {3,13};
Line(8) = {4,14};
Transfinite Line{5,6,7,8} = m;
Line Loop(16) = {-6,2,7,-12};
Ruled Surface(2) = {16}; // front surface
Transfinite Surface{2} = {2,3,12,13};
Recombine Surface{2};
Line Loop(17) = {-5,-4,8,14};
Ruled Surface(3) = {17}; // back surface
Transfinite Surface{3} = {1,4,11,14};
Recombine Surface{3};
Line Loop(18) = {-6,-1,5,11};
Ruled Surface(4) = {18}; // bottom surface
Transfinite Surface{4} = {12,2,1,11};
Recombine Surface{4};
Line Loop(19) = {-7,3,8,-13};
Ruled Surface(5) = {19}; // top surface
Transfinite Surface{5} = {13,3,4,14};
Recombine Surface{5};
Surface Loop(7) = {1,2,3,4,5,6};
Volume(1) = {7};
Transfinite Volume{1} = {1,2,3,4,11,12,13,14};
//************************************
// Second Piece of Electrode (Left)
//************************************************
left_length = 2.40;
right_length = 1.20;
Point(21) = {0.20+left_length,0.0-back_length,0.0, lc};
//front bottom left
Point(22) = {0.20+width+right_length,0.0-front_length,0.0,lc};
//front bottom right
Point(23) = {0.20+width+right_length,0.0-front_length,0.0+height,lc};
//front top right
Point(24) = {0.20+left_length,0.0-back_length,0.0+height,lc};
// front top left
Line(21) = {21,22}; // back right
Line(22) = {22,23}; // back top
Line(23) = {23,24}; // back left
Line(24) = {24,21}; // back bottom
Transfinite Line{21,22,23,24} = m;
Line Loop(25) = {21,22,23,24};
Ruled Surface(16) = {25}; // left surface
Transfinite Surface{16} = {21,22,23,24};
Recombine Surface{16};
// Front Surface
Line(15) = {11,21};
Line(16) = {12,22};
Line(17) = {13,23};
Line(18) = {14,24};
Transfinite Line{15,16,17,18} = m;
Line Loop(26) = {-16,12,17,-22};
Ruled Surface(12) = {26}; // front surface
Transfinite Surface{12} = {12,13,22,23};
Recombine Surface{12};
Line Loop(27) = {-15,-14,18,24};
Ruled Surface(13) = {27}; // back surface
Transfinite Surface{13} = {11,14,21,24};
Recombine Surface{13};
Line Loop(28) = {-16,-11,15,21};
Ruled Surface(14) = {28}; // bottom surface
Transfinite Surface{14} = {22,12,11,21};
Recombine Surface{14};
Line Loop(29) = {-17,13,18,-23};
Ruled Surface(15) = {29}; // top surface
Transfinite Surface{15} = {23,13,14,24};
Recombine Surface{15};
Surface Loop(17) = {6,12,13,14,15,16};
Volume(2) = {17};
Transfinite Volume{2} = {11,12,13,14,21,22,23,24};
//************************************
// Third Piece of Electrode (Front)
//************************************************
back_length = 3.00;
front_length = 4.20; // front is not from a rotation but similar to
// the first piece
Point(31) = {2.00+width,-1.6+front_length,0.0, lc}; // back top left
Point(32) = {2.00, -1.0+back_length, 0.0, lc}; //back bottom right
Point(33) = {2.00, -1.0+back_length,0.0+height,lc}; // back top right
Point(34) = {2.00+width,-1.6+front_length,0.0+height,lc}; // back bottom left
Line(31) = {31,32}; // back right
Line(32) = {32,33}; // back top
Line(33) = {33,34}; // back left
Line(34) = {34,31}; // back bottom
Transfinite Line{31,32,33,34} = m;
Line Loop(35) = {31,32,33,34};
Ruled Surface(26) = {35}; // left surface
Transfinite Surface{26} = {31,32,33,34};
Recombine Surface{26};
Line(25) = {21,31}; // front bottom
Line(26) = {22,32}; // back bottom
Line(27) = {23,33}; // back top
Line(28) = {24,34}; // front top
Transfinite Line{25,26,27,28} = m;
Line Loop(36) = {-26,22,27,-32};
Ruled Surface(22) = {36}; // front surface
Transfinite Surface{22} = {22,23,32,33};
Recombine Surface{22};
Line Loop(37) = {-25,-24,28,34};
Ruled Surface(23) = {37}; // back surface
Transfinite Surface{23} = {21,24,31,34};
Recombine Surface{23};
Line Loop(38) = {-26,-21,25,31};
Ruled Surface(24) = {38}; // bottom surface
Transfinite Surface{24} = {32,22,21,31};
Recombine Surface{24};
Line Loop(39) = {-27,23,28,-33};
Ruled Surface(25) = {39}; // top surface
Transfinite Surface{25} = {33,23,24,34};
Recombine Surface{25};
Surface Loop(27) = {16,22,23,24,25,26};
Volume(3) = {27};
Transfinite Volume{3} = {21,22,23,24,31,32,33,34};
//************************************
// Fourth Piece of Electrode (Right Side)
//************************************************
left_length = 1.20;
right_length = 2.40;
Point(41) = {2.60-right_length,2.60,0.0, lc}; // back bottom left
Point(42) = {2.00-left_length,2.00, 0.0, lc}; //front bottom left
Point(43) = {2.00-left_length,2.00, 0.0+height, lc}; //front top left
Point(44) = {2.60-right_length,2.60,0.0+height, lc}; // back top left
Line(41) = {41,42}; // back right
Line(42) = {42,43}; // back top
Line(43) = {43,44}; // back left
Line(44) = {44,41}; // back bottom
Transfinite Line{41,42,43,44} = m;
Line Loop(45) = {41,42,43,44};
Ruled Surface(36) = {45}; // left surface
Transfinite Surface{36} = {41,42,43,44};
Recombine Surface{36};
Line(35) = {31,41}; // front bottom
Line(36) = {32,42}; // back bottom
Line(37) = {33,43}; // back top
Line(38) = {34,44}; // front top
Transfinite Line{35,36,37,38} = m;
Line Loop(46) = {-36,32,37,-42};
Ruled Surface(32) = {46}; // front surface
Transfinite Surface{32} = {32,33,42,43};
Recombine Surface{32};
Line Loop(47) = {-35,-34,38,44};
Ruled Surface(33) = {47}; // back surface
Transfinite Surface{33} = {31,34,41,44};
Recombine Surface{33};
Line Loop(48) = {-36,-31,35,41};
Ruled Surface(34) = {48}; // bottom surface
Transfinite Surface{34} = {42,32,31,41};
Recombine Surface{34};
Line Loop(49) = {-37,33,38,-43};
Ruled Surface(35) = {49}; // top surface
Transfinite Surface{35} = {43,33,34,44};
Recombine Surface{35};
Surface Loop(37) = {26,32,33,34,35,36};
Volume(4) = {37};
Transfinite Volume{4} = {31,32,33,34,41,42,43,44};
//************************************
// Fifth Piece of Electrode (Right Side)
//************************************************
back_length = 1.60;
front_length = 1.00;
left_length = 1.20;
right_length = 2.40;
Point(51) = {2.60-right_length,2.60-back_length,0.0, lc};
// back bottom left
Point(52) = {2.00-left_length,2.00-front_length, 0.0, lc};
//front bottom left
Point(53) = {2.00-left_length,2.00-front_length, 0.0+height, lc};
//front top left
Point(54) = {2.60-right_length,2.60-back_length,0.0+height, lc};
// back top left
Line(51) = {51,52}; // back right
Line(52) = {52,53}; // back top
Line(53) = {53,54}; // back left
Line(54) = {54,51}; // back bottom
Transfinite Line{51,52,53,54} = m;
Line Loop(55) = {51,52,53,54};
Ruled Surface(46) = {55}; // left surface
Transfinite Surface{46} = {51,52,53,54};
Recombine Surface{46};
Line(45) = {41,51}; // front bottom
Line(46) = {42,52}; // back bottom
Line(47) = {43,53}; // back top
Line(48) = {44,54}; // front top
Transfinite Line{45,46,47,48} = m;
Line Loop(56) = {-46,42,47,-52};
Ruled Surface(42) = {56}; // front surface
Transfinite Surface{42} = {42,43,52,53};
Recombine Surface{42};
Line Loop(57) = {-45,-44,48,54};
Ruled Surface(43) = {57}; // back surface
Transfinite Surface{43} = {41,44,51,54};
Recombine Surface{43};
Line Loop(58) = {-46,-41,45,51};
Ruled Surface(44) = {58}; // bottom surface
Transfinite Surface{44} = {52,42,41,51};
Recombine Surface{44};
Line Loop(59) = {-47,43,48,-53};
Ruled Surface(45) = {59}; // top surface
Transfinite Surface{45} = {53,43,44,54};
Recombine Surface{45};
Surface Loop(47) = {36,42,43,44,45,46};
Volume(5) = {47};
Transfinite Volume{5} = {41,42,43,44,51,52,53,54};
Physical Volume(1) = {1,2,3,4,5};
// This call eliminates the need to delete
// elements (shown below)
// *Do Mesh 3d only
// *Then save msh file
// *Then delete all element types that are
// not 8 node hexahedron (elm-type 5)