22 #include "libmesh/libmesh.h"    24 #include "libmesh/equation_systems.h"    25 #include "libmesh/mesh.h"    26 #include "libmesh/numeric_vector.h"    27 #include "libmesh/id_types.h"    28 #include "libmesh/elem.h"    29 #include "libmesh/variable.h"    31 unsigned char dim = 2; 
    33 int main(
int argc, 
char ** argv)
    43                << 
" mesh oldsolution newsolution system1 variable1 [sys2 var2...]" << std::endl;
    51   libmesh_assert_greater_equal (argc, 6);
    63   libMesh::out << 
"Loaded solution " << argv[2] << std::endl;
    65   std::vector<unsigned int> old_sys_num((argc-4)/2),
    66     new_sys_num((argc-4)/2),
    67     old_var_num((argc-4)/2),
    68     new_var_num((argc-4)/2);
    70   std::vector<const System *> old_system((argc-4)/2);
    71   std::vector<System *> new_system((argc-4)/2);
    73   for (
int argi = 4; argi < argc; argi += 2)
    75       const char * sysname = argv[argi];
    76       const char * varname = argv[argi+1];
    78       const unsigned int pairnum = (argi-4)/2;
    82       const System & old_sys = es1.get_system(sysname);
    83       old_system[pairnum] = &old_sys;
    84       old_sys_num[pairnum] = old_sys.
number();
    88       old_var_num[pairnum] = old_sys.variable_number(varname);
    90       const Variable & variable = old_sys.variable(old_var_num[pairnum]);
    92       std::string systype = old_sys.system_type();
    95       new_system[pairnum] = &new_sys;
    96       new_sys_num[pairnum] = new_sys.
number();
    98       new_var_num[pairnum] =
   111   for (
const auto & old_node : mesh1.local_node_ptr_range())
   113       const Node * new_node = *new_nit++;
   118       for (
int argi = 4; argi < argc; argi += 2)
   120           const unsigned int pairnum = (argi-4)/2;
   122           const System & old_sys = *old_system[pairnum];
   123           System & new_sys = *new_system[pairnum];
   125           const unsigned int n_comp =
   126             old_node->n_comp(old_sys_num[pairnum],old_var_num[pairnum]);
   127           libmesh_assert_equal_to(n_comp,
   128                                   new_node->
n_comp(new_sys_num[pairnum],new_var_num[pairnum]));
   130           for (
unsigned int i=0; i<n_comp; i++)
   133                 old_index = old_node->dof_number
   134                 (old_sys_num[pairnum], old_var_num[pairnum], i),
   136                 (new_sys_num[pairnum], new_var_num[pairnum], i);
   146   for (
const auto & old_elem : mesh1.active_local_element_ptr_range())
   148       const Elem * new_elem = *new_eit++;
   153       for (
int argi = 4; argi < argc; argi += 2)
   155           const unsigned int pairnum = (argi-4)/2;
   157           const System & old_sys = *old_system[pairnum];
   158           System & new_sys = *new_system[pairnum];
   160           const unsigned int n_comp =
   161             old_elem->n_comp(old_sys_num[pairnum],old_var_num[pairnum]);
   162           libmesh_assert_equal_to(n_comp,
   163                                   new_elem->
n_comp(new_sys_num[pairnum],new_var_num[pairnum]));
   165           for (
unsigned int i=0; i<n_comp; i++)
   168                 old_index = old_elem->dof_number
   169                 (old_sys_num[pairnum], old_var_num[pairnum], i),
   171                 (new_sys_num[pairnum], new_var_num[pairnum], i);
 int main(int argc, char **argv)
This is the EquationSystems class. 
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
A Node is like a Point, but with more information. 
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_comp(const unsigned int s, const unsigned int var) const
The definition of the const_element_iterator struct. 
This is the base class from which all geometric element types are derived. 
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g. 
The libMesh namespace provides an interface to certain functionality in the library. 
unsigned int number() const
This class defines the notion of a variable in the system. 
const std::set< subdomain_id_type > & active_subdomains() const
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. 
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system. 
The definition of the const_node_iterator struct. 
virtual void init()
Initialize all the systems. 
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array. 
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default. 
const FEType & type() const