add_vertex ( i_vert, x, y ) i_vert += 1 # Add the cells (triangular elements) # Loop over the vertices and build two cells for each square # where the selected vertex is in the lower left corner editor. init_vertices ( nvert ) i_vert = 0 for x in xpos : for y in ypos : editor. open ( mesh, 2, 2 ) # Add the vertices (nodes) editor. linspace ( 0, height, ny ) # Create the mesh and open for editing mesh = df. linspace ( 0, length, nx ) ypos = numpy. """ # The number of mesh entities nvert = nx * ny ncell = 2 * ( nx - 1 ) * ( ny - 1 ) # Positions of the vertices xpos = numpy. Should give exactly the same results as using the built in dolfin.RectangleMesh() class So, for posterity, here is a reimplementation of dolfin.RectangleMesh in a much more cumbersome (and flexible) way: import numpy import dolfin as df def create_mesh ( length, height, nx, ny, show = False ): """ While playing with implementing a simple solver for fluid flow in a tank by use of FEniCS to solve the Laplace equation I needed to create my own mesh in code.įEniCS is quite well documented, but I had to look at the source code for some of the mesh conversion routines to find out how to build a mesh from scratch. I may end up doing a large project using FEniCS which is a collection of tools for automated, efficient solution of differential equations using the finite element method.
0 Comments
Leave a Reply. |