Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshFromVertices in parallel #634

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions festim/meshing/mesh_from_vertices.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ def __init__(self, vertices, **kwargs) -> None:

def generate_mesh_from_vertices(self):
"""Generates a 1D mesh"""
vertices = sorted(np.unique(self.vertices))
nb_points = len(vertices)
nb_cells = nb_points - 1
editor = f.MeshEditor()
mesh = f.Mesh()
editor.open(mesh, "interval", 1, 1) # top. and geom. dimension are both 1
editor.init_vertices(nb_points) # number of vertices
editor.init_cells(nb_cells) # number of cells
for i in range(0, nb_points):
editor.add_vertex(i, np.array([vertices[i]]))
for j in range(0, nb_cells):
editor.add_cell(j, np.array([j, j + 1]))
editor.close()
if f.MPI.comm_world.rank == 0:
KulaginVladimir marked this conversation as resolved.
Show resolved Hide resolved
vertices = sorted(np.unique(self.vertices))
nb_points = len(vertices)
nb_cells = nb_points - 1
editor = f.MeshEditor()
editor.open(mesh, "interval", 1, 1) # top. and geom. dimension are both 1
editor.init_vertices(nb_points) # number of vertices
editor.init_cells(nb_cells) # number of cells
for i in range(0, nb_points):
editor.add_vertex(i, np.array([vertices[i]]))
for j in range(0, nb_cells):
editor.add_cell(j, np.array([j, j + 1]))
editor.close()
f.MeshPartitioning.build_distributed_mesh(mesh)
self.mesh = mesh
Loading