Skip to content

Commit

Permalink
Use Checkpoint files to read split meshes for DistributedMesh refs id…
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud authored and permcody committed Feb 15, 2017
1 parent a3257ce commit 8c0d3dc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions framework/include/mesh/FileMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class FileMesh : public MooseMesh
protected:
/// the file_name from whence this mesh came
std::string _file_name;
/// Whether or not we're reading a checkpoint file
bool _is_checkpoint;
/// Auxiliary object for restart
std::unique_ptr<ExodusII_IO> _exreader;
};
Expand Down
34 changes: 32 additions & 2 deletions framework/src/mesh/FileMesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// libMesh includes
#include "libmesh/exodusII_io.h"
#include "libmesh/nemesis_io.h"
#include "libmesh/checkpoint_io.h"
#include "libmesh/parallel_mesh.h"

template<>
Expand All @@ -29,19 +30,24 @@ InputParameters validParams<FileMesh>()
InputParameters params = validParams<MooseMesh>();
params.addRequiredParam<MeshFileName>("file", "The name of the mesh file to read");
params.addClassDescription("Read a mesh from a file.");
params.addParam<bool>("checkpoint", false, "Whether or not the file format is a checkpoint file");
return params;
}

FileMesh::FileMesh(const InputParameters & parameters) :
MooseMesh(parameters),
_file_name(getParam<MeshFileName>("file"))
_file_name(getParam<MeshFileName>("file")),
_is_checkpoint(getParam<bool>("checkpoint")),
_exreader(NULL)
{
getMesh().set_mesh_dimension(getParam<MooseEnum>("dim"));
}

FileMesh::FileMesh(const FileMesh & other_mesh) :
MooseMesh(other_mesh),
_file_name(other_mesh._file_name)
_file_name(other_mesh._file_name),
_is_checkpoint(other_mesh._is_checkpoint),
_exreader(NULL)
{
}

Expand Down Expand Up @@ -77,6 +83,30 @@ FileMesh::buildMesh()
getMesh().prepare_for_use();
getMesh().skip_partitioning(skip_partitioning_later);
}
else if (_is_checkpoint)
{
CheckpointIO reader(getMesh());

reader.binary() = true;

auto & mesh = getMesh();

DistributedMesh * pmesh = cast_ptr<DistributedMesh *>(&mesh);

if (pmesh)
reader.parallel() = true;

reader.read(_file_name);

mesh.update_parallel_id_counts();
//mesh.find_neighbors(true, true);
//mesh.update_parallel_id_counts();
//mesh.redistribute();
//mesh.delete_remote_elements();
mesh.skip_partitioning(true);
mesh.prepare_for_use();
mesh.print_info();
}
else // not reading Nemesis files
{
MooseUtils::checkFileReadable(_file_name);
Expand Down

0 comments on commit 8c0d3dc

Please sign in to comment.