Go to the documentation of this file.
   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)
 
  215       for (
unsigned int j = 0; j != 
n_vars; ++j)
 
  220   const std::string outsolnname = cl.follow(std::string(
"out_"+solnname), 
"--outsoln");
 
  222   new_es.
write(outsolnname.c_str(),
 
  225   libMesh::out << 
"Wrote solution " << outsolnname << std::endl;
 
  
Manages consistently variables, degrees of freedom, and coefficient vectors.
 
unsigned int n_vars() const
 
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
 
virtual void init() override
Override the FunctionBase::init() member function by calling our own and specifying the Trees::NODES ...
 
This class provides function-like objects for data distributed over a mesh.
 
const std::string & variable_name(const unsigned int i) const
 
The libMesh namespace provides an interface to certain functionality in the library.
 
T assert_argument(GetPot &cl, const std::string &argname, const char *progname, const T &defaultarg)
 
const T_sys & get_system(const std::string &name) const
 
void usage_error(const char *progname)
 
const Parallel::Communicator & comm() const
 
bool has_system(const std::string &name) const
 
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
 
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
 
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
 
XdrMODE
Defines an enum for read/write mode in Xdr format.
 
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.
 
A Point defines a location in LIBMESH_DIM dimensional Real space.
 
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.
 
std::string current_sys_name
 
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
 
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
 
unsigned int n_systems() const
 
void read(const std::string &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.
 
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
 
This is the EquationSystems class.
 
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
 
const std::string & name() const
 
void write(const std::string &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.
 
const DofMap & get_dof_map() const
 
std::map< std::string, MeshFunction * > mesh_functions
 
int main(int argc, char **argv)
 
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
 
Gradient gradient(const Point &p, const Real time=0.)
 
This class provides the ability to map between arbitrary, user-defined strings and several data types...
 
Parameters parameters
Data structure holding arbitrary parameters.