Dear all,
I have my own parallel (MPI-based) mesh generator in C++/Python, I’m wonder that if is it possible to directly create fenice/dolfin mesh object using the data in each process and solve it? I tried below MME:
import os, sys
import numpy as np
import fenics as fe
import my_own_mesh_generator as pqm
pqm.MPI_initialize(len(sys.argv), sys.argv) # initiate MPI
fem = pqm.FEM2D() # create mesh generator object
fem.mesh_generator(sys.argv) # generate mesh
pqm.MPI_barrier() # end parallel mesh generation
# Now I have the nodes and elements of each subdomain in each process.
# I hope saving whole mesh into one single file in xdmf format.
comm = fe.MPI.comm_world
rank = fe.MPI.rank(comm)
size = fe.MPI.size(comm)
nodes, cells, total_node, total_cell, Local2Global_node_id = fem.mesh_generator.mesh.info
# The only way I know for saving mesh as xdmf is creating a fenics mesh then writing as below
mesh = fe.Mesh(comm)
editor = fe.MeshEditor()
editor.open(mesh, type="triangle", tdim=2, gdim=2)
editor.init_vertices_global(nodes.shape[0], total_node)
editor.init_cells_global(cells.shape[0], total_cell)
for k, pt in enumerate(nodes):
editor.add_vertex_global(k, Local2Global_node_id[k], pt)
for k, cell in enumerate(cells):
editor.add_cell(k, cell)
editor.close()
with fe.XDMFFile(comm, 'test_mesh.xdmf') as outfile:
outfile.write(mesh)
But I got this error:
*** Error: Unable to get shared mesh entities.
*** Reason: Shared mesh entities have not been computed for dim 0.
*** Where: This error was encountered inside MeshTopology.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 77c758717da1cb8017bf95109363bb1a91a4f8e5
I read one issue report link similar to my question, any update on that? Or this feature is impossible with FEniCS?
Thank you.