Build a 2d 2x2 square mesh (mesh_one) covering [0.0, 1.0] x [0.0, 1.0] with linear Quad elements. A new mesh will later be moved to this same object using MeshBase::operator = (&&).
Create an ES based on the mesh, with a single variable. We will set non-homogenous bc u = 1.0 on the bottom and right sides of the mesh. After moving a new mesh into mesh_one, we will verify that u is projected properly onto the new mesh_one topology.
Build another 2d 2x2 square mesh (mesh_two) covering [0.0, 1.0] x [0.0, 1.0] with linear Quad elements. We will later refine this mesh and replace mesh_one with it.
61 {
62
63 std::shared_ptr<UnstructuredMesh> mesh_one;
64 std::shared_ptr<UnstructuredMesh> mesh_two;
65
72 if (mesh_type.compare("Mesh") == 0)
73 {
74 mesh_one = std::make_shared<Mesh>(*TestCommWorld);
75 }
76 else if (mesh_type.compare("replicated") == 0)
77 {
78 mesh_one = std::make_shared<ReplicatedMesh>(*TestCommWorld);
79 }
80 else if (mesh_type.compare("distributed") == 0)
81 {
82 mesh_one = std::make_shared<DistributedMesh>(*TestCommWorld);
83 }
84 else
85 {
86 libmesh_error_msg("Error: specified mesh_type not understood");
87 }
88
90 2, 2,
91 0., 1.,
92 0., 1.,
94
95
96
97
104 System & system = es.add_system<
System> (
"SimpleSystem");
106
107
108
110
111
113 const std::set<boundary_id_type> bottom_right_bdry_ids(all_bdry_ids, all_bdry_ids + 1);
114
115
116 std::vector<unsigned int> variables = {0};
117 variables.push_back(0);
118
120
122
123 es.init();
124
125 if (mesh_type.compare("Mesh") == 0)
126 {
127 mesh_two = std::make_shared<Mesh>(*TestCommWorld);
128 }
129 else if (mesh_type.compare("replicated") == 0)
130 {
131 mesh_two = std::make_shared<ReplicatedMesh>(*TestCommWorld);
132 }
133 else if (mesh_type.compare("distributed") == 0)
134 {
135 mesh_two = std::make_shared<DistributedMesh>(*TestCommWorld);
136 }
137 else
138 {
139 libmesh_error_msg("Error: specified mesh_type not understood");
140 }
141
142#ifdef LIBMESH_ENABLE_AMR
143 if(mesh_creation_type.compare("from_memory") == 0)
144 {
152 2, 2,
153 0., 1.,
154 0., 1.,
156
157
158 std::unique_ptr<MeshRefinement> mesh_refinement(std::make_unique<MeshRefinement>(*mesh_two));
159
160 mesh_refinement->uniformly_refine(1);
161
162 std::unique_ptr<MeshBase> mesh_two_clone =
163 mesh_two->clone();
164
165
169
170
172
173 CPPUNIT_ASSERT(system.
get_mesh() == *mesh_two_clone);
174
175
176
178
179
181
182
183
184
186
188 }
189 else if (mesh_creation_type.compare("from_file") == 0)
190 {
191 mesh_two->read("meshes/mesh_assign_test_mesh.xda");
192
193 std::unique_ptr<MeshBase> mesh_two_clone =
194 mesh_two->clone();
195
198
200
201
203
204 CPPUNIT_ASSERT(system.
get_mesh() == *mesh_two_clone);
205
208
210
212 }
213 else
214 {
215 libmesh_error_msg("Error: invalid mesh two case type.");
216 }
217#endif
218 }
Function that returns a single value that never changes.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
This is the EquationSystems class.
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
virtual void reinit_mesh()
Handle the association of a completely new mesh with the EquationSystem and all the Systems assigned ...
virtual dof_id_type n_elem() const =0
virtual void write(const std::string &name) const =0
virtual void clear()
Deletes all the element and node data that is currently stored.
virtual MeshBase & assign(MeshBase &&other_mesh)=0
Shim to allow operator = (&&) to behave like a virtual function without having to be one.
Manages consistently variables, degrees of freedom, and coefficient vectors.
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.
const DofMap & get_dof_map() const
const EquationSystems & get_equation_systems() const
const MeshBase & get_mesh() const