Since GMSH was mentioned in the comments as a possible meshing tool, the common way to deal with it there is to create a Physical Line
.
The simplest .geo
(modeling and meshing a square):
cl=0.5;
Point(1) = {1.,1.,0.,cl};
Point(2) = {-1.,1.,0.,cl};
Point(3) = {-1.,-1.,0.,cl};
Point(4) = {1.,-1.,0.,cl};
Line(1) = {1,2};
Line(2) = {2,3};
Line(3) = {3,4};
Line(4) = {4,1};
Line Loop (1) = {1,2,3,4};
Surface(1) = {1};
Physical Surface(1) = {1}; // that is "1" the tag for your 2-D elements, by default, triangles
Physical Line(2) = {1,2,3,4}; // that is the tag "2" for your contour lines; thus, boundary nodes
After meshing, it will create both 2-D and 1-D mesh elements. Looking inside the generated *.msh
, you will be able to easily distinguish between them. In that way, it would also be easy to assign different boundary conditions to different lines (simply by creating several Physical Line
's).