28#include "libmesh/libmesh.h"
29#include "libmesh/dof_map.h"
30#include "libmesh/equation_systems.h"
31#include "libmesh/getpot.h"
32#include "libmesh/mesh.h"
33#include "libmesh/mesh_function.h"
34#include "libmesh/numeric_vector.h"
35#include "libmesh/point.h"
36#include "libmesh/replicated_mesh.h"
37#include "libmesh/enum_xdr_mode.h"
38#include "libmesh/utility.h"
48 <<
" --dim d mesh dimension [default: autodetect]\n"
49 <<
" --inmesh filename input mesh file\n"
50 <<
" --insoln filename input solution file\n"
51 <<
" --outmesh filename output mesh file [default: out_<inmesh>]\n"
52 <<
" --outsoln filename output solution file [default: out_<insoln>]\n"
61 const std::string & argname,
62 const char * progname,
65 if (!cl.search(argname))
67 libMesh::err << (
"No " + argname +
" argument found!") << std::endl;
70 return cl.next(defaultarg);
83 const std::string & libmesh_dbg_var(sys_name),
84 const std::string & unknown_name)
98 const std::string & libmesh_dbg_var(sys_name),
99 const std::string & unknown_name)
111int main(
int argc,
char ** argv)
115 GetPot cl(argc, argv);
119 const unsigned char requested_dim =
120 cast_int<unsigned char>(cl.follow(3,
"--dim"));
127 const std::string meshname =
130 old_mesh.
read(meshname);
131 std::cout <<
"Old Mesh:" << std::endl;
135 Mesh new_mesh(init.comm(), requested_dim);
137 const std::string outmeshname = cl.follow(std::string(
"out_"+meshname),
"--outmesh");
139 new_mesh.
read(outmeshname);
140 std::cout <<
"New Mesh:" << std::endl;
147 const std::string solnname =
160 libmesh_error_msg(
"Unrecognized file extension on " << solnname);
162 old_es.
read(solnname, read_mode,
168 new_es.
read(solnname, read_mode,
174 unsigned int n_systems = old_es.
n_systems();
175 libmesh_assert_equal_to (new_es.
n_systems(), n_systems);
179 for (
unsigned int i = 0; i != n_systems; ++i)
192 std::unique_ptr<NumericVector<Number>> comparison_soln =
194 std::vector<Number> global_soln;
197 (*comparison_soln) = global_soln;
201 for (
unsigned int j = 0; j !=
n_vars; ++j)
206 std::make_unique<MeshFunction>(old_es, *comparison_soln,
217 const std::string outsolnname = cl.follow(std::string(
"out_"+solnname),
"--outsoln");
219 new_es.
write(outsolnname.c_str(),
222 libMesh::out <<
"Wrote solution " << outsolnname << std::endl;
This is the EquationSystems class.
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
void write(std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
unsigned int n_systems() const
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
Parameters parameters
Data structure holding arbitrary parameters.
bool has_system(std::string_view name) const
const T_sys & get_system(std::string_view name) const
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
This class provides function-like objects for data distributed over a mesh.
Gradient gradient(const Point &p, const Real time=0.)
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
const Parallel::Communicator & comm() const
This class provides the ability to map between arbitrary, user-defined strings and several data types...
A Point defines a location in LIBMESH_DIM dimensional Real space.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Manages consistently variables, degrees of freedom, and coefficient vectors.
const std::string & name() const
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const std::string & variable_name(const unsigned int i) const
void update_global_solution(std::vector< Number > &global_soln) const
Fill the input vector global_soln so that it contains the global solution on all processors.
unsigned int n_vars() const
const DofMap & get_dof_map() const
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) override
Reads the file specified by name.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
bool contains(std::string_view superstring, std::string_view substring)
Look for a substring within a string.
The libMesh namespace provides an interface to certain functionality in the library.
XdrMODE
Defines an enum for read/write mode in Xdr format.
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
std::map< std::string, std::unique_ptr< MeshFunction > > mesh_functions
void usage_error(const char *progname)
std::string current_sys_name
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
T assert_argument(GetPot &cl, const std::string &argname, const char *progname, const T &defaultarg)