Hello, everyone:
I am working on multiscale problems with fenics 2019.1.
First, I create a rectangle mesh on fenics with triangle elements. Then, I need create mesh on the every elements(triangle) and solve a pde system on this mesh.My problem is that how to create a mesh for a triangle.
A solution I come out is that I get coordinates of the rectangle mesh first,; then ,create a triangle mesh from
three vertices with mshr’s Polygon function. But I meet a problem such as some elements vertices 'order are clockwise and others are anticlockwise.
Attached is my code:
from fenics import *
import numpy as np
import mshr
mesh01 = RectangleMesh(Point(0.0, 0.0), Point(1.0, 1.0), 10, 10)
mesh01_point_data = mesh01.coordinates()
mesh01_cells = mesh01.cells()
cells_data = np.zeros([200, 3, 2])
aa = mesh01_cells.shape[0]
for i in range(aa):
cells_data[i, 0, :] = mesh01_point_data[mesh01_cells[i][0]]
cells_data[i, 1, :] = mesh01_point_data[mesh01_cells[i][1]]
cells_data[i, 2, :] = mesh01_point_data[mesh01_cells[i][2]]
# print(cells_data[0])
# print(cells_data[1])
# print(cells_data[2])
# """
for i in range(5):
domain02 = mshr.Polygon([Point(cells_data[i, 0, :]),
Point(cells_data[i, 1, :]),
Point(cells_data[i, 2, :])])
mesh02 = mshr.generate_mesh(domain02, 5)
Or, Is there any other solution?