Numerous useful functions are provided by GMSH API, even Lagrange (and their Gradient) basis function. Integration points, jacobian, FEM basis functions, … Print("Element Tag("+str(segments)+")=)+", "+str(nodes)+"]")Īnd this gives the following result (again, indices can differ on your side) Segment tags composing Line(1) Print("Number of nodes per segment: " +str(nodes_per_elem)) Now we want to loop on the elements composing the Line of elementary tag 1, and for each element, display the tag of each of its vertices (starting and ending point): segments = (1,1) Properties of a segment element (type = 1) You should get: Element type of Line(1) (segment has type 1)Įlement type of Surface(1) (triangle has type 2) Print("Properties of a segment element (type = 1)") Print("Element type of Surface(1) (triangle has type 2)") Return elementName, dim, order, numNodes, nodeCoord, numPrimaryNodes.Īs for the node, you can copy/paste these lines before gmsh.write("square.msh"): print("Element type of Line(1) (segment has type 1)") Get the properties of an element of type elementType: its name( elementName), dimension ( dim), order ( order), number of nodes( numNodes), coordinates of the nodes in the reference element( nodeCoord vector, of length dim times numNodes) and number ofprimary (first order) nodes ( numPrimaryNodes). Get the elements of type elementType classified on the entity of tag tag. GetElementsByType(elementType, tag=-1, task=0, numTasks=1) Get the types of elements in the ( elementary) entity of dimension dim and ( elementary) tag tag. Return elementTypes, elementTags, nodeTags Get the elements classified on the ( elementary) entity of dimension dim and ( elementary) tag tag. This is a sometimes useful but inefficient way of accessing elements, as it relies on a cache stored in the model. Get the type and node tags of the element with ( elementary) tag tag. You should get the following messages (not necessarily the same number/coordinate!) in your terminal Nodes tag on Physical Line 1 Print("Nodes coordinates on Physical Line 1") # Some portions of code will be added here !īy the following line, where we ask GMSH to first provide the tag of the nodes on Physical Line(1) and second, their coordinate: print("Nodes tag on Physical Line 1") Start from the code meshing a square that has been given above and override these line # = The other arguments are treated as in getNodes. Get the nodes classified on the entity of tag tag, for all the elements of type elementType. GetNodesByElementType(elementType, tag=-1, returnParametricCoord=True) Get the nodes from all the elements belonging to the physical group of dimension dim and tag tag. Get the nodes classified on the entity of dimension dim and tag tag. GetNodes(dim=-1, tag=-1, includeBoundary=False, returnParametricCoord=True) Generally, the first quantity of the returned array is what you want. Get the coordinates and the parametric coordinates (if any) of the node with tag tag. For example, to call getNode(12), you should type (12). Methods to get and modify mesh element are placed in the namespace. Running it in a terminal an opening it with GMSH should open a windows as below python square.py # Code to test mesh element access will be added here ! The Surface has a Physical Tag equal to 10, the bottom boundary Line has Physical Tag=1 and the three other are regrouped in the same Physical Tag 2 # File square.py Let us consider a unit square with 0.1 as mesh size. For Julia and C++, the syntax changes but the idea is the same. In this section, you will learn the basic functionality to do that withing Python. For example, if you want to program a finite element solver, you probably needs to access each elements and nodes of the mesh and compute some quantity on it. Now that you know how to generate a mesh with GMSH API, you probably wants to play with the resulting mesh. I also remind you that in VSCode (+ Python extension), the definition of the function are displayed in the text editor: extremly convenient!
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |