Hi,
I am new to dolfinx. How to use mesh partitioner other than “SCOTCH” in dolfinx.
i was able to use it using the below command using dolfin. But dolfinx is not taking this command.
import dolfin as dolf
parameters[“mesh_partitioner”] = “ParMETIS”
I am using both C++ and python for coding in fenicx. So an example in C++ or Python would be helpful
Best Regards,
Leo
Thanks in Advance,
See: dolfinx/test_mesh_partitioners.py at main · FEniCS/dolfinx · GitHub
or similarly: performance-test/mesh.cpp at main · FEniCS/performance-test · GitHub
For reading in from file, here is a C++ example:
std::shared_ptr<mesh::Mesh> mesh;
{
if (dolfinx::MPI::rank(MPI_COMM_WORLD) == 0)
std::cout << "Reading Mesh data ..." << std::endl;
dolfinx::io::XDMFFile file(MPI_COMM_WORLD, mesh_file, "r");
fem::CoordinateElement cmap
= fem::CoordinateElement(mesh::CellType::tetrahedron, 1);
xt::xtensor<double, 2> x;
xt::xtensor<std::int64_t, 2> topology;
x = file.read_geometry_data("Grid");
topology = file.read_topology_data("Grid");
auto [data, offset] = graph::create_adjacency_data(topology);
graph::AdjacencyList<std::int64_t> cells(std::move(data), std::move(offset));
if (dolfinx::MPI::rank(file.comm()) == 0)
std::cout << "Creating Mesh ..." << std::endl;
// Set graph partitioner (prefer ParMETIS)
#ifdef HAS_PARMETIS
auto graph_part = dolfinx::graph::parmetis::partitioner(1.01);
#elif HAS_PTSCOTCH
auto graph_part = dolfinx::graph::scotch::partitioner(
dolfinx::graph::scotch::strategy::scalability);
#elif HAS_KAHIP
auto graph_part = dolfinx::graph::kahip::partitioner();
#else
#error "No mesh partitioner has been selected"
#endif
// Create distributed mesh
auto cell_part = dolfinx::mesh::create_cell_partitioner(graph_part);
mesh = std::make_shared<mesh::Mesh>(mesh::create_mesh(
MPI_COMM_WORLD, cells, cmap, x, mesh::GhostMode::none, cell_part));
}
1 Like