18#include "libmesh/checkpoint_io.h"
36 mesh->getMesh().skip_partitioning(
false);
42 if (
mesh->getFileName() ==
"" && split_file_arg ==
"")
43 mooseError(
"Output mesh file name must be specified (with --split-file) when splitting "
44 "non-file-based meshes");
47 std::vector<unsigned int> splits;
50 mooseError(
"invalid argument for --split-mesh: '", splitstr,
"'");
62 bool checkpoint_binary_flag =
false;
64 if (split_file_arg_ext !=
"")
66 if (split_file_arg_ext ==
"cpr")
67 checkpoint_binary_flag =
true;
68 else if (split_file_arg_ext ==
"cpa.gz")
69 checkpoint_binary_flag =
false;
73 ", must not end in a file extension other than .cpr or .cpa.gz");
80 auto fname =
mesh->getFileName();
82 fname = split_file_arg;
85 for (std::size_t i = 0; i < splits.size(); i++)
87 processor_id_type n = splits[i];
88 Moose::out <<
"Splitting " << n <<
" ways..." << std::endl;
91 Moose::out <<
" - writing " << cp->current_processor_ids().size() <<
" files per process..."
93 cp->binary() = checkpoint_binary_flag;
103 Moose::out <<
"Mesh meta data written into "
104 << std::filesystem::absolute(filenames[0].parent_path()) <<
"." << std::endl;
registerMooseAction("MooseApp", SplitMeshAction, "split_mesh")
std::shared_ptr< MooseMesh > & mesh()
static InputParameters validParams()
MooseApp & _app
The MOOSE application this is associated with.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
std::vector< std::filesystem::path > writeRestartableMetaData(const RestartableDataMapName &name, const std::filesystem::path &folder_base)
Writes the restartable meta data for name with a folder base of folder_base.
static const RestartableDataMapName MESH_META_DATA
const InputParameters & parameters() const
Get the parameters of the object.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
static InputParameters validParams()
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
SplitMeshAction(const InputParameters ¶ms)
processor_id_type processor_id() const
bool tokenizeAndConvert(const std::string &str, std::vector< T > &tokenized_vector, const std::string &delimiter=" \t\n\v\f\r")
tokenizeAndConvert splits a string using delimiter and then converts to type T.
std::string getExtension(const std::string &filename, const bool rfind)
std::string stripExtension(const std::string &s, const bool rfind)
std::unique_ptr< CheckpointIO > split_mesh(MeshBase &mesh, processor_id_type nsplits)