Dear @
Thank you very much for your help. Well, here are some questions.
1- I do the mesh transformation from gmsh to fenics using the pattern msh to .xdmf using meshio as below:
import meshio
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
out_mesh = meshio.Mesh(points=mesh.points, cells={
cell_type: cells}, cell_data={"name_to_read": [cell_data]})
if prune_z:
out_mesh.prune_z_0()
return out_mesh
msh = meshio.read("meshtest.msh")
facet_mesh = create_mesh(msh, "triangle", prune_z=True)
meshio.write("meshtest_facet.xdmf", facet_mesh)
triangle_mesh = create_mesh(msh, "tetra", prune_z=True)
meshio.write("meshtest_mesh.xdmf", triangle_mesh)
In your program, wouldn’t that be necessary? It already does the conversion on the bass line, is that it?
# convert Gmsh to XDMF
cashocs.convert('mesh.msh', "mesh.xdmf")
2 - I work with topological optimization of several domains at the same time, so I have dx1, dx2,…,dxn. Where in gmsh I create the independent volumes and pass them to fenics in the style:
# Define 3D geometry
mesh = Mesh()
with XDMFFile("meshtest_mesh.xdmf") as infile:
infile.read(mesh)
mvc2 = MeshValueCollection("size_t", mesh, 2)
with XDMFFile("meshtest_facet.xdmf") as infile:
infile.read(mvc2, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc2)
mvc3 = MeshValueCollection("size_t", mesh, 3)
with XDMFFile("meshtest_mesh.xdmf") as infile:
infile.read(mvc3, "name_to_read")
cf = cpp.mesh.MeshFunctionSizet(mesh, mvc3)
dx1 = Measure("dx", domain=mesh, subdomain_data=cf, subdomain_id=100) # this number 100 is hypothetical, but equal to the one created within gmsh
dx2 = Measure("dx", domain=mesh, subdomain_data=cf, subdomain_id=200)
dx3 = Measure("dx", domain=mesh, subdomain_data=cf, subdomain_id=300)
Would this conversion or consideration be possible in your program?
I imagine that some change would be made in the line below:
# read the mesh into fenics
mesh, subdomains, boundaries, dx, ds, dS = cashocs.import_mesh('mesh.xdmf')
3 - Would it be possible for me to just install cashocs and just perform the transformation according to the .xdmf file generation pattern:
#ParaView Results:
file_results = XDMFFile(MPI.comm_world, "solution.xdmf")
file_results.parameters["flush_output"] = True
file_results.parameters["functions_share_mesh"] = True
file_results.write(rho_opt, 0.)
file_results.write(ud, 0.)
In short, I can take, for example, the result of the code from the first post above (dolfin-adjoint/pyadjoint/blob/master/examples/stokes-topology/stokes-topology.py 1) and transform the .xdmf
to .msh using cashocs?