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" 47 <<
" --dim d mesh dimension [default: autodetect]\n" 48 <<
" --inmesh filename input mesh file\n" 49 <<
" --insoln filename input solution file\n" 50 <<
" --outmesh filename output mesh file [default: out_<inmesh>]\n" 51 <<
" --outsoln filename output solution file [default: out_<insoln>]\n" 60 const std::string & argname,
61 const char * progname,
64 if (!cl.search(argname))
66 libMesh::err << (
"No " + argname +
" argument found!") << std::endl;
69 return cl.next(defaultarg);
82 const std::string & libmesh_dbg_var(sys_name),
83 const std::string & unknown_name)
97 const std::string & libmesh_dbg_var(sys_name),
98 const std::string & unknown_name)
110 int main(
int argc,
char ** argv)
114 GetPot cl(argc, argv);
118 const unsigned char requested_dim =
119 cast_int<unsigned char>(cl.follow(3,
"--dim"));
126 const std::string meshname =
129 old_mesh.read(meshname);
130 std::cout <<
"Old Mesh:" << std::endl;
131 old_mesh.print_info();
134 Mesh new_mesh(
init.comm(), requested_dim);
136 const std::string outmeshname = cl.follow(std::string(
"out_"+meshname),
"--outmesh");
138 new_mesh.
read(outmeshname);
139 std::cout <<
"New Mesh:" << std::endl;
140 new_mesh.print_info();
146 const std::string solnname =
154 if (solnname.rfind(
".xdr") < solnname.size())
156 else if (solnname.rfind(
".xda") < solnname.size())
159 libmesh_error_msg(
"Unrecognized file extension on " << solnname);
161 old_es.
read(solnname, read_mode,
167 new_es.
read(solnname, read_mode,
173 unsigned int n_systems = old_es.
n_systems();
174 libmesh_assert_equal_to (new_es.
n_systems(), n_systems);
178 for (
unsigned int i = 0; i != n_systems; ++i)
189 libmesh_assert_equal_to (new_sys.n_vars(),
n_vars);
191 std::unique_ptr<NumericVector<Number>> comparison_soln =
193 std::vector<Number> global_soln;
196 (*comparison_soln) = global_soln;
200 for (
unsigned int j = 0; j !=
n_vars; ++j)
205 std::make_unique<MeshFunction>(old_es, *comparison_soln,
216 const std::string outsolnname = cl.follow(std::string(
"out_"+solnname),
"--outsoln");
218 new_es.
write(outsolnname.c_str(),
221 libMesh::out <<
"Wrote solution " << outsolnname << std::endl;
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
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.
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
This class provides the ability to map between arbitrary, user-defined strings and several data types...
bool has_system(std::string_view name) const
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
Gradient gradient(const Point &p, const Real time=0.)
const Parallel::Communicator & comm() const
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
std::map< std::string, std::unique_ptr< MeshFunction > > mesh_functions
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
The libMesh namespace provides an interface to certain functionality in the library.
const T_sys & get_system(std::string_view name) const
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
XdrMODE
Defines an enum for read/write mode in Xdr format.
int main(int argc, char **argv)
void usage_error(const char *progname)
Manages consistently variables, degrees of freedom, and coefficient vectors.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
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.
const std::string & variable_name(const unsigned int i) const
T assert_argument(GetPot &cl, const std::string &argname, const char *progname, const T &defaultarg)
std::string current_sys_name
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
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...
Parameters parameters
Data structure holding arbitrary parameters.
const std::string & name() const
This class provides function-like objects for data distributed over a mesh.
unsigned int n_vars() const
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) override
Reads the file specified by name.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const DofMap & get_dof_map() const
A Point defines a location in LIBMESH_DIM dimensional Real space.