Mesh¶
Interval Element¶
-
mozart.mesh.interval.interval(a, b, M, degree)[source]¶ Generates mesh information on an interval [a,b].
- Parameters
a(float) : coordinate of left-end point of the intervalb(float) : coordinate of right-end point of the intervalM(int) : the number of elementsdegree(int) : polynomial degree for the approximate solution
- Returns
c4n(float array) : coordinates for nodesn4e(int array) : nodes for elementsn4db(int array) : nodes for Dirichlet boundaryind4e(int array) : indices for elements
- Example
>>> c4n, n4e, n4db, ind4e = interval(0,1,4,2) >>> c4n array([ 0. , 0.125, 0.25 , 0.375, 0.5 , 0.625, 0.75 , 0.875, 1. ]) >>> n4e array([[0, 2], [2, 4], [4, 6], [6, 8]]) >>> n4db array([0, 8]) >>> ind4e array([[0, 1, 2], [2, 3, 4], [4, 5, 6], [6, 7, 8]])
Triangle Element¶
-
mozart.mesh.triangle.compute_e4s(n4e)[source]¶ Get a matrix whose each row contains two elements sharing the corresponding side If second column is -1, the corresponding side is on the boundary
- Paramters
n4e(int32 array) : nodes for elements
- Returns
e4s(int32 array) : elements for sides
- Example
>>> n4e = np.array([[1, 3, 0], [3, 1, 2]]) >>> e4s = compute_e4s(n4e) >>> e4s array([[ 0, 1], [ 0, -1], [ 1, -1], [ 0, -1], [ 1, -1]])
-
mozart.mesh.triangle.compute_n4s(n4e)[source]¶ Get a matrix whose each row contains end points of the corresponding side (or edge)
- Paramters
n4e(int32 array) : nodes for elements
- Returns
n4s(int32 array) : nodes for sides
- Example
>>> n4e = np.array([[1, 3, 0], [3, 1, 2]]) >>> n4s = compute_n4s(n4e) >>> n4s array([[1, 3], [3, 0], [1, 2], [0, 1], [2, 3]])
-
mozart.mesh.triangle.compute_s4e(n4e)[source]¶ Get a matrix whose each row contains three side numbers of the corresponding element
- Paramters
n4e(int32 array) : nodes for elements
- Returns
s4e(int32 array) : sides for elements
- Example
>>> n4e = np.array([[1, 3, 0], [3, 1, 2]]) >>> s4e = compute_s4e(n4e) >>> s4e array([[0, 1, 3], [0, 2, 4]])
-
mozart.mesh.triangle.refineUniformRed(c4n, n4e, n4Db, n4Nb)[source]¶ Refine a given mesh uniformly using the red refinement
- Paramters
c4n(float64 array) : coordinates for elementsn4e(int32 array) : nodes for elementsn4Db(int32 array) : nodes for Difichlet boundaryn4Nb(int32 array) : nodes for Neumann boundary
- Returns
c4nNew(float64 array) : coordinates for element obtained from red refinementn4eNew(int32 array) : nodes for element obtained from red refinementn4DbNew(int32 array) : nodes for Dirichlet boundary obtained from red refinementn4NbNew(int32 array) : nodes for Neumann boundary obtained from red refinement
- Example
>>> c4n = np.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]]) >>> n4e = np.array([[1, 3, 0], [3, 1, 2]]) >>> n4Db = np.array([[0, 1], [1, 2]]) >>> n4Nb = np.array([[2, 3],[3, 0]]) >>> c4nNew, n4eNew, n4DbNew, n4NbNew = refineUniformRed(c4n, n4e, n4Db, n4Nb) >>> c4nNew array([[ 0. , 0. ], [ 1. , 0. ], [ 1. , 1. ], [ 0. , 1. ], [ 0.5, 0.5], [ 0. , 0.5], [ 1. , 0.5], [ 0.5, 0. ], [ 0.5, 1. ]]) >>> n4eNew array([[1, 4, 7], [4, 3, 5], [5, 7, 4], [7, 5, 0], [3, 4, 8], [4, 1, 6], [6, 8, 4], [8, 6, 2]]) >>> n4DbNew array([[0, 7], [7, 1], [1, 6], [6, 2]]) >>>n4NbNew array([[2, 8], [8, 3], [3, 5], [5, 0]])
Rectangle Element¶
-
mozart.mesh.rectangle.rectangle(x1, x2, y1, y2, Mx, My, degree)[source]¶ Generates mesh information on the unit square [x1,x2]x[y1,y2].
- Parameters
x1(float) : coordinate of left point on the x-axisx2(float) : coordinate of right point on the x-axisy1(float) : coordinate of bottom point on the y-axisy2(float) : coordinate of top point on the y-axisMx(int) : the number of elements along x-axisMy(int) : the number of elements along y-axisdegree(int) : polynomial degree for the approximate solution
- Returns
c4n(float array) : coordinates for nodesind4e(int array) : indices for elementsn4e(int array) : nodes for elementsn4Db(int array) : nodes for Dirichlet boundary
- Example
>>> c4n, ind4e, n4e, n4Db = rectangle(0,1,0,1,2,2,1) >>> c4n array([[ 0. 0. ] [ 0.5 0. ] [ 1. 0. ] [ 0. 0.5] [ 0.5 0.5] [ 1. 0.5] [ 0. 1. ] [ 0.5 1. ] [ 1. 1. ]]) >>> ind4e array([[0 1 3 4] [1 2 4 5] [3 4 6 7] [4 5 7 8]]) >>> n4e array([[0 1 4 3] [1 2 5 4] [3 4 7 6] [4 5 8 7]]) >>> n4Db array([0 1 2 3 5 6 7 8])
Cube Element¶
-
mozart.mesh.cube.cube(x1, x2, y1, y2, z1, z2, Mx, My, Mz, degree)[source]¶ Generates mesh information on the unit square [x1,x2]x[y1,y2].
- Parameters
x1(float) : coordinate of back point on the x-axisx2(float) : coordinate of front point on the x-axisy1(float) : coordinate of left point on the y-axisy2(float) : coordinate of right point on the y-axisz1(float) : coordinate of bottom point on the z-axisz2(float) : coordinate of top point on the z-axisMx(int) : the number of elements along x-axisMy(int) : the number of elements along y-axisMz(int) : the number of elements along z-axisdegree(int) : polynomial degree for the approximate solution
- Returns
c4n(float array) : coordinates for nodesind4e(int array) : indices for elementsn4e(int array) : nodes for elementsn4Db(int array) : nodes for Dirichlet boundary
- Example
>>> c4n, ind4e, n4e, n4Db = cube(0,1,0,1,0,1,2,2,2,1) >>> c4n array([[ 0. 0. 0. ], [ 0.5 0. 0. ], [ 1. 0. 0. ], [ 0. 0.5 0. ] [ 0.5 0.5 0. ], [ 1. 0.5 0. ], [ 0. 1. 0. ], [ 0.5 1. 0. ] [ 1. 1. 0. ], [ 0. 0. 0.5], [ 0.5 0. 0.5], [ 1. 0. 0.5] [ 0. 0.5 0.5], [ 0.5 0.5 0.5], [ 1. 0.5 0.5], [ 0. 1. 0.5] [ 0.5 1. 0.5], [ 1. 1. 0.5], [ 0. 0. 1. ], [ 0.5 0. 1. ] [ 1. 0. 1. ], [ 0. 0.5 1. ], [ 0.5 0.5 1. ], [ 1. 0.5 1. ] [ 0. 1. 1. ], [ 0.5 1. 1. ], [ 1. 1. 1. ]]) >>> ind4e array([[ 0 1 3 4 9 10 12 13] [ 1 2 4 5 10 11 13 14] [ 3 4 6 7 12 13 15 16] [ 4 5 7 8 13 14 16 17] [ 9 10 12 13 18 19 21 22] [10 11 13 14 19 20 22 23] [12 13 15 16 21 22 24 25] [13 14 16 17 22 23 25 26]]) >>> n4e array([[ 0 1 4 3 9 10 13 12] [ 1 2 5 4 10 11 14 13] [ 3 4 7 6 12 13 16 15] [ 4 5 8 7 13 14 17 16] [ 9 10 13 12 18 19 22 21] [10 11 14 13 19 20 23 22] [12 13 16 15 21 22 25 24] [13 14 17 16 22 23 26 25]]) >>> n4Db array([ 0 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26])