MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::MeshPartitioner Class Reference

Class that allows serial meshes to be partitioned into MeshPart objects, typically one MeshPart at a time, which can then be used to write the local mesh in parallel MFEM mesh format. More...

#include <mesh.hpp>

Collaboration diagram for mfem::MeshPartitioner:
[legend]

Public Member Functions

 MeshPartitioner (Mesh &mesh_, int num_parts_, int *partitioning_=NULL, int part_method=1)
 Construct a MeshPartitioner.
 
void ExtractPart (int part_id, MeshPart &mesh_part) const
 Construct a MeshPart corresponding to the given part_id.
 
std::unique_ptr< FiniteElementSpaceExtractFESpace (MeshPart &mesh_part, const FiniteElementSpace &global_fespace) const
 Construct a local version of the given FiniteElementSpace global_fespace corresponding to the given mesh_part.
 
std::unique_ptr< GridFunctionExtractGridFunction (const MeshPart &mesh_part, const GridFunction &global_gf, FiniteElementSpace &local_fespace) const
 Construct a local version of the given GridFunction, global_gf, corresponding to the given mesh_part. The respective data is copied from global_gf to the returned local GridFunction.
 

Protected Attributes

Meshmesh
 
Array< int > partitioning
 
Table part_to_element
 
Table part_to_boundary
 
Table edge_to_element
 
Table vertex_to_element
 

Detailed Description

Class that allows serial meshes to be partitioned into MeshPart objects, typically one MeshPart at a time, which can then be used to write the local mesh in parallel MFEM mesh format.

Sample usage of this class: partition a serial mesh and save it in parallel MFEM format:

// The array 'partitioning' can be obtained e.g. from
// mesh->GeneratePartitioning():
void usage1(Mesh *mesh, int num_parts, int *partitioning)
{
MeshPartitioner partitioner(*mesh, num_parts, partitioning);
MeshPart mesh_part;
for (int i = 0; i < num_parts; i++)
{
partitioner.ExtractPart(i, mesh_part);
ofstream omesh(MakeParFilename("my-mesh.", i));
mesh_part.Print(omesh);
}
}
Class containing a minimal description of a part (a subset of the elements) of a Mesh and its connect...
Definition mesh.hpp:2479
void Print(std::ostream &os) const
Write the MeshPart to a stream using the parallel format "MFEM mesh v1.2".
Definition mesh.cpp:13338
Class that allows serial meshes to be partitioned into MeshPart objects, typically one MeshPart at a ...
Definition mesh.hpp:2707
Array< int > partitioning
Definition mesh.hpp:2710
Mesh data type.
Definition mesh.hpp:56
std::string MakeParFilename(const std::string &prefix, const int myid, const std::string suffix, const int width)
Construct a string of the form "<prefix><myid><suffix>" where the integer myid is padded with leading...
Definition globals.cpp:43

This class can also be used to partition a mesh and GridFunction(s) and save them in parallel:

// The array 'partitioning' can be obtained e.g. from
// mesh->GeneratePartitioning():
void usage2(Mesh *mesh, int num_parts, int *partitioning,
{
MeshPartitioner partitioner(*mesh, num_parts, partitioning);
MeshPart mesh_part;
for (int i = 0; i < num_parts; i++)
{
partitioner.ExtractPart(i, mesh_part);
ofstream omesh(MakeParFilename("my-mesh.", i));
mesh_part.Print(omesh);
auto lfes = partitioner.ExtractFESpace(mesh_part, *gf->FESpace());
auto lgf = partitioner.ExtractGridFunction(mesh_part, *gf, *lfes);
ofstream ofield(MakeParFilename("my-field.", i));
lgf->Save(ofield);
}
}
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
FiniteElementSpace * FESpace()
Definition gridfunc.hpp:696

Definition at line 2706 of file mesh.hpp.

Constructor & Destructor Documentation

◆ MeshPartitioner()

mfem::MeshPartitioner::MeshPartitioner ( Mesh & mesh_,
int num_parts_,
int * partitioning_ = NULL,
int part_method = 1 )

Construct a MeshPartitioner.

Parameters
[in]mesh_Mesh to be partitioned into MeshParts.
[in]num_parts_Number of parts to partition the mesh into.
[in]partitioning_Partitioning array: for every element in the mesh gives the partition it belongs to; if NULL, partitioning will be generated internally by calling Mesh::GeneratePartitioning().
[in]part_methodPartitioning method to be used in the call to Mesh::GeneratePartitioning() when the provided input partitioning is NULL.

Definition at line 13601 of file mesh.cpp.

Member Function Documentation

◆ ExtractFESpace()

std::unique_ptr< FiniteElementSpace > mfem::MeshPartitioner::ExtractFESpace ( MeshPart & mesh_part,
const FiniteElementSpace & global_fespace ) const

Construct a local version of the given FiniteElementSpace global_fespace corresponding to the given mesh_part.

Parameters
[in,out]mesh_partMeshPart on which to construct the local FiniteElementSpace; this object is generally modified by this call since it calls mesh_part.GetMesh() to ensure the local mesh is constructed.
[in]global_fespaceThe global FiniteElementSpace that should be restricted to the mesh_part.
Returns
A FiniteElementSpace pointer stored in a unique_ptr. The returned local FiniteElementSpace is built on the Mesh object contained in mesh_part (MeshPart::mesh) and it reuses the FiniteElementCollection of the global_fespace.

Definition at line 14142 of file mesh.cpp.

◆ ExtractGridFunction()

std::unique_ptr< GridFunction > mfem::MeshPartitioner::ExtractGridFunction ( const MeshPart & mesh_part,
const GridFunction & global_gf,
FiniteElementSpace & local_fespace ) const

Construct a local version of the given GridFunction, global_gf, corresponding to the given mesh_part. The respective data is copied from global_gf to the returned local GridFunction.

Parameters
[in]mesh_partMeshPart on which to construct the local GridFunction.
[in]global_gfThe global GridFunction that should be restricted to the mesh_part.
[in,out]local_fespaceThe local FiniteElementSpace corresponding to mesh_part, e.g. constructed by the method ExtractFESpace().
Returns
A GridFunction pointer stored in a unique_ptr. The returned local GridFunction is initialized with data appropriately copied from global_gf.

Definition at line 14157 of file mesh.cpp.

◆ ExtractPart()

void mfem::MeshPartitioner::ExtractPart ( int part_id,
MeshPart & mesh_part ) const

Construct a MeshPart corresponding to the given part_id.

Parameters
[in]part_idPartition index to extract; valid values are in the range [0, num_parts).
[out]mesh_partOutput MeshPart object; its contents is overwritten, while potentially reusing existing dynamic memory allocations.

Definition at line 13672 of file mesh.cpp.

Member Data Documentation

◆ edge_to_element

Table mfem::MeshPartitioner::edge_to_element
protected

Definition at line 2713 of file mesh.hpp.

◆ mesh

Mesh& mfem::MeshPartitioner::mesh
protected

Definition at line 2709 of file mesh.hpp.

◆ part_to_boundary

Table mfem::MeshPartitioner::part_to_boundary
protected

Definition at line 2712 of file mesh.hpp.

◆ part_to_element

Table mfem::MeshPartitioner::part_to_element
protected

Definition at line 2711 of file mesh.hpp.

◆ partitioning

Array<int> mfem::MeshPartitioner::partitioning
protected

Definition at line 2710 of file mesh.hpp.

◆ vertex_to_element

Table mfem::MeshPartitioner::vertex_to_element
protected

Definition at line 2714 of file mesh.hpp.


The documentation for this class was generated from the following files: