21#include "libmesh/libmesh.h"
22#include "libmesh/replicated_mesh.h"
23#include "libmesh/default_coupling.h"
24#include "libmesh/checkpoint_io.h"
25#include "libmesh/metis_partitioner.h"
26#include "libmesh/getpot.h"
33 size_t lastdot = filename.find_last_of(
".");
35 if (lastdot == std::string::npos)
38 return filename.substr(0, lastdot);
41int main (
int argc,
char ** argv)
47 libMesh::out <<
"Example: " << argv[0] <<
" --mesh=filename.e --n-procs='4 8 16' "
48 "[--num-ghost-layers <n>] [--dry-run] [--ascii]\n\n"
49 <<
"--mesh Full name of the mesh file to read in. \n"
50 <<
"--n-procs Vector of number of processors.\n"
51 <<
"--num-ghost-layers Number of layers to ghost when partitioning (Default: 1).\n"
52 <<
"--dry-run Only test the partitioning, don't write any files.\n"
53 <<
"--ascii Write ASCII cpa files rather than binary cpr files.\n"
54 <<
"--gz Compress written files in gzip format.\n"
62 std::vector<processor_id_type> all_n_procs;
71 if (num_ghost_layers > 1)
81 for (
const auto & n_procs : all_n_procs)
83 libMesh::out <<
"splitting " << n_procs <<
" ways..." << std::endl;
89 libMesh::out <<
" * writing " << cpr->current_processor_ids().size() <<
" files per process..." << std::endl;
95 cpr->binary() = binary;
96 std::ostringstream outputname;
97 outputname <<
remove_extension(filename) << (binary ?
".cpr" :
".cpa") << (gzip ?
".gz" :
"");
98 cpr->write(outputname.str());
This class implements the default algebraic coupling in libMesh: elements couple to themselves,...
void set_n_levels(unsigned int n_levels)
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
The libMesh namespace provides an interface to certain functionality in the library.
void command_line_vector(const std::string &, std::vector< T > &)
std::unique_ptr< CheckpointIO > split_mesh(MeshBase &mesh, processor_id_type nsplits)
split_mesh takes the given initialized/opened mesh and partitions it into nsplits pieces or chunks.
T command_line_value(const std::string &, T)
bool on_command_line(std::string arg)
std::string remove_extension(const std::string &filename)