34{
36
38
41
43 << " mesh oldsolution newsolution system1 variable1 [sys2 var2...]" << std::endl;
44
45
46
48
49
50
51 libmesh_assert_greater_equal (argc, 6);
52
53 mesh1.read(argv[1]);
57
58 es1.read(argv[2],
59 EquationSystems::READ_HEADER |
60 EquationSystems::READ_DATA |
61 EquationSystems::READ_ADDITIONAL_DATA |
62 EquationSystems::READ_BASIC_ONLY);
63 libMesh::out <<
"Loaded solution " << argv[2] << std::endl;
64
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);
69
70 std::vector<const System *> old_system((argc-4)/2);
71 std::vector<System *> new_system((argc-4)/2);
72
73 for (int argi = 4; argi < argc; argi += 2)
74 {
75 const char * sysname = argv[argi];
76 const char * varname = argv[argi+1];
77
78 const unsigned int pairnum = (argi-4)/2;
79
81
82 const System & old_sys = es1.get_system(sysname);
83 old_system[pairnum] = &old_sys;
84 old_sys_num[pairnum] = old_sys.
number();
85
87
89
91
93
94 System & new_sys = es2.add_system(systype, sysname);
95 new_system[pairnum] = &new_sys;
96 new_sys_num[pairnum] = new_sys.
number();
97
98 new_var_num[pairnum] =
101 }
102
103 es2.init();
104
105
106
107
108
110
111 for (const auto & old_node : mesh1.local_node_ptr_range())
112 {
113 const Node * new_node = *new_nit++;
114
115
117
118 for (int argi = 4; argi < argc; argi += 2)
119 {
120 const unsigned int pairnum = (argi-4)/2;
121
122 const System & old_sys = *old_system[pairnum];
123 System & new_sys = *new_system[pairnum];
124
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]));
129
130 for (unsigned int i=0; i<n_comp; i++)
131 {
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);
138 }
139 }
140 }
141
142
143
145
146 for (const auto & old_elem : mesh1.active_local_element_ptr_range())
147 {
148 const Elem * new_elem = *new_eit++;
149
150
152
153 for (int argi = 4; argi < argc; argi += 2)
154 {
155 const unsigned int pairnum = (argi-4)/2;
156
157 const System & old_sys = *old_system[pairnum];
158 System & new_sys = *new_system[pairnum];
159
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]));
164
165 for (unsigned int i=0; i<n_comp; i++)
166 {
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);
173 }
174 }
175 }
176
177 es2.write(argv[3], EquationSystems::WRITE_DATA);
178
179 return 0;
180}
unsigned int n_comp(const unsigned int s, const unsigned int var) const
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
This is the base class from which all geometric element types are derived.
This is the EquationSystems class.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A Node is like a Point, but with more information.
Manages consistently variables, degrees of freedom, and coefficient vectors.
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
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.
virtual std::string system_type() const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
unsigned int variable_number(std::string_view var) const
bool has_variable(std::string_view var) const
unsigned int number() const
This class defines the notion of a variable in the system.
const std::set< subdomain_id_type > & active_subdomains() const
const FEType & type() const
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
The libMesh namespace provides an interface to certain functionality in the library.
The definition of the const_element_iterator struct.
The definition of the const_node_iterator struct.