"Fossies" - the Fresh Open Source Software Archive

Member "gmsh-4.3.0-source/tutorial/t1.geo" (23 Jan 2019, 3543 Bytes) of package /linux/privat/gmsh-4.3.0-source.tgz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 /*********************************************************************
    2  *
    3  *  Gmsh tutorial 1
    4  *
    5  *  Variables, elementary entities (points, curves, surfaces), physical
    6  *  entities (points, curves, surfaces)
    7  *
    8  *********************************************************************/
    9 
   10 // The simplest construction in Gmsh's scripting language is the
   11 // `affectation'. The following command defines a new variable `lc':
   12 
   13 lc = 1e-2;
   14 
   15 // This variable can then be used in the definition of Gmsh's simplest
   16 // `elementary entity', a `Point'. A Point is defined by a list of four numbers:
   17 // three coordinates (X, Y and Z), and a characteristic length (lc) that sets
   18 // the target element size at the point:
   19 
   20 Point(1) = {0, 0, 0, lc};
   21 
   22 // The distribution of the mesh element sizes is then obtained by interpolation
   23 // of these characteristic lengths throughout the geometry. Another method to
   24 // specify characteristic lengths is to use general mesh size Fields (see
   25 // `t10.geo'). A particular case is the use of a background mesh (see `t7.geo').
   26 
   27 // We can then define some additional points as well as our first curve.  Curves
   28 // are Gmsh's second type of elementery entities, and, amongst curves, straight
   29 // lines are the simplest. A straight line is defined by a list of point
   30 // numbers. In the commands below, for example, the line 1 starts at point 1 and
   31 // ends at point 2:
   32 
   33 Point(2) = {.1, 0,  0, lc} ;
   34 Point(3) = {.1, .3, 0, lc} ;
   35 Point(4) = {0,  .3, 0, lc} ;
   36 
   37 Line(1) = {1,2} ;
   38 Line(2) = {3,2} ;
   39 Line(3) = {3,4} ;
   40 Line(4) = {4,1} ;
   41 
   42 // The third elementary entity is the surface. In order to define a simple
   43 // rectangular surface from the four curves defined above, a curve loop has first
   44 // to be defined. A curve loop is a list of connected curves, a sign being
   45 // associated with each curve (depending on the orientation of the curve):
   46 
   47 Curve Loop(1) = {4,1,-2,3} ;
   48 
   49 // We can then define the surface as a list of curve loops (only one here, since
   50 // there are no holes--see `t4.geo'):
   51 
   52 Plane Surface(1) = {1} ;
   53 
   54 // At this level, Gmsh knows everything to display the rectangular surface 6 and
   55 // to mesh it. An optional step is needed if we want to group elementary
   56 // geometrical entities into more meaningful groups, e.g. to define some
   57 // mathematical ("domain", "boundary"), functional ("left wing", "fuselage") or
   58 // material ("steel", "carbon") properties.
   59 //
   60 // Such groups are called "Physical Groups" in Gmsh. By default, if physical
   61 // groups are defined, Gmsh will export in output files only those elements that
   62 // belong to at least one physical group. (To force Gmsh to save all elements,
   63 // whether they belong to physical groups or not, set "Mesh.SaveAll=1;", or
   64 // specify "-save_all" on the command line.)
   65 //
   66 // Here we define a physical curve that groups the left, bottom and right lines
   67 // in a single group (with prescribed tag 5); and a physical surface with name
   68 // "My surface" (with an automatic tag) containg the geometrical surface 1:
   69 
   70 Physical Curve(5) = {1, 2, 4} ;
   71 Physical Surface("My surface") = {1} ;
   72 
   73 // Note that starting with Gmsh 3.0, models can be built using different
   74 // geometry kernels than the default "built-in" kernel. By specifying
   75 //
   76 //   SetFactory("OpenCASCADE");
   77 //
   78 // any subsequent command in the .geo file would be handled by the OpenCASCADE
   79 // geometry kernel instead of the built-in kernel. A rectangular surface could
   80 // then simply be created with
   81 //
   82 //   Rectangle(2) = {.2, 0, 0, 0.1, 0.3};
   83 //
   84 // See tutorial/t16.geo for a complete example, and demos/boolean for more.