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" 30 unsigned char dim = 2;
32 int main(
int argc,
char ** argv)
42 <<
" mesh oldsolution newsolution system1 variable1 [sys2 var2...]" << std::endl;
50 libmesh_assert_greater_equal (argc, 6);
62 libMesh::out <<
"Loaded solution " << argv[2] << std::endl;
64 std::vector<unsigned int> old_sys_num((argc-4)/2),
65 new_sys_num((argc-4)/2),
66 old_var_num((argc-4)/2),
67 new_var_num((argc-4)/2);
69 std::vector<const System *> old_system((argc-4)/2);
70 std::vector<System *> new_system((argc-4)/2);
72 for (
int argi = 4; argi < argc; argi += 2)
74 const char * sysname = argv[argi];
75 const char * varname = argv[argi+1];
77 const unsigned int pairnum = (argi-4)/2;
81 const System & old_sys = es1.get_system(sysname);
82 old_system[pairnum] = &old_sys;
83 old_sys_num[pairnum] = old_sys.
number();
87 old_var_num[pairnum] = old_sys.variable_number(varname);
89 const Variable & variable = old_sys.variable(old_var_num[pairnum]);
91 std::string systype = old_sys.system_type();
94 new_system[pairnum] = &new_sys;
95 new_sys_num[pairnum] = new_sys.
number();
97 new_var_num[pairnum] =
110 for (
const auto & old_node : mesh1.local_node_ptr_range())
112 const Node * new_node = *new_nit++;
117 for (
int argi = 4; argi < argc; argi += 2)
119 const unsigned int pairnum = (argi-4)/2;
121 const System & old_sys = *old_system[pairnum];
122 System & new_sys = *new_system[pairnum];
124 const unsigned int n_comp =
125 old_node->n_comp(old_sys_num[pairnum],old_var_num[pairnum]);
126 libmesh_assert_equal_to(n_comp,
127 new_node->
n_comp(new_sys_num[pairnum],new_var_num[pairnum]));
129 for (
unsigned int i=0; i<n_comp; i++)
132 old_index = old_node->dof_number
133 (old_sys_num[pairnum], old_var_num[pairnum], i),
135 (new_sys_num[pairnum], new_var_num[pairnum], i);
145 for (
const auto & old_elem : mesh1.active_local_element_ptr_range())
147 const Elem * new_elem = *new_eit++;
152 for (
int argi = 4; argi < argc; argi += 2)
154 const unsigned int pairnum = (argi-4)/2;
156 const System & old_sys = *old_system[pairnum];
157 System & new_sys = *new_system[pairnum];
159 const unsigned int n_comp =
160 old_elem->n_comp(old_sys_num[pairnum],old_var_num[pairnum]);
161 libmesh_assert_equal_to(n_comp,
162 new_elem->
n_comp(new_sys_num[pairnum],new_var_num[pairnum]));
164 for (
unsigned int i=0; i<n_comp; i++)
167 old_index = old_elem->dof_number
168 (old_sys_num[pairnum], old_var_num[pairnum], i),
170 (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