Code Monkey home page Code Monkey logo

Comments (2)

jorgensd avatar jorgensd commented on August 24, 2024

The mesh partitioner does not take into account that cells are re-ordered in the mesh creation step.

from dolfinx.

jorgensd avatar jorgensd commented on August 24, 2024

Can be rectified with transfer_cell_meshtags:

from mpi4py import MPI
import numpy as np
import dolfinx

msh_c = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 2, 5, ghost_mode=dolfinx.mesh.GhostMode.none)
msh_c.topology.create_entities(1)
msh_f, parent_cells, _ = dolfinx.mesh.refine_plaza(msh_c, redistribute=False, option=dolfinx.mesh.RefinementOption.parent_cell)

child_vertices = dolfinx.mesh.entities_to_geometry(msh_f, 2, np.arange(len(parent_cells), dtype=np.int32))
parent_vertices = dolfinx.mesh.entities_to_geometry(msh_c, 2, parent_cells)

num_cells = msh_c.topology.index_map(msh_c.topology.dim).size_local
marker = np.arange(num_cells, dtype=np.int32)
ct = dolfinx.mesh.meshtags(msh_c, msh_c.topology.dim, marker, marker)


ct_refined = dolfinx.mesh.MeshTags(dolfinx.cpp.refinement.transfer_cell_meshtag(ct._cpp_object, msh_f.topology, parent_cells))




with dolfinx.io.XDMFFile(msh_c.comm, "ct.xdmf", "w") as xdmf:
    xdmf.write_mesh(msh_c)
    xdmf.write_meshtags(ct, msh_c.geometry)


with dolfinx.io.XDMFFile(msh_f.comm, "ct_refined.xdmf", "w") as xdmf:
    xdmf.write_mesh(msh_f)
    xdmf.write_meshtags(ct_refined, msh_f.geometry)

from dolfinx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.