1#include <libmesh/mesh.h>
2#include <libmesh/distributed_mesh.h>
3#include <libmesh/mesh_generation.h>
4#include <libmesh/mesh_refinement.h>
5#include <libmesh/boundary_info.h>
6#include <libmesh/elem.h>
7#include <libmesh/equation_systems.h>
8#include <libmesh/zero_function.h>
9#include <libmesh/dirichlet_boundaries.h>
10#include <libmesh/dof_map.h>
11#include <libmesh/parallel.h>
12#include <libmesh/replicated_mesh.h>
32# ifdef LIBMESH_ENABLE_DIRICHLET
60 const std::string & mesh_creation_type)
63 std::shared_ptr<UnstructuredMesh> mesh_one;
64 std::shared_ptr<UnstructuredMesh> mesh_two;
72 if (mesh_type.compare(
"Mesh") == 0)
76 else if (mesh_type.compare(
"replicated") == 0)
80 else if (mesh_type.compare(
"distributed") == 0)
86 libmesh_error_msg(
"Error: specified mesh_type not understood");
113 const std::set<boundary_id_type> bottom_right_bdry_ids(all_bdry_ids, all_bdry_ids + 1);
116 std::vector<unsigned int> variables = {0};
117 variables.push_back(0);
125 if (mesh_type.compare(
"Mesh") == 0)
129 else if (mesh_type.compare(
"replicated") == 0)
133 else if (mesh_type.compare(
"distributed") == 0)
135 mesh_two = std::make_shared<DistributedMesh>(*
TestCommWorld);
139 libmesh_error_msg(
"Error: specified mesh_type not understood");
142#ifdef LIBMESH_ENABLE_AMR
143 if(mesh_creation_type.compare(
"from_memory") == 0)
158 std::unique_ptr<MeshRefinement> mesh_refinement(std::make_unique<MeshRefinement>(*mesh_two));
160 mesh_refinement->uniformly_refine(1);
162 std::unique_ptr<MeshBase> mesh_two_clone =
173 CPPUNIT_ASSERT(system.
get_mesh() == *mesh_two_clone);
189 else if (mesh_creation_type.compare(
"from_file") == 0)
191 mesh_two->read(
"meshes/mesh_assign_test_mesh.xda");
193 std::unique_ptr<MeshBase> mesh_two_clone =
204 CPPUNIT_ASSERT(system.
get_mesh() == *mesh_two_clone);
215 libmesh_error_msg(
"Error: invalid mesh two case type.");
220 template <
class SrcClass,
class DestClass>
227 DestClass dest_mesh(src_mesh);
232 dof_id_type n_dest_elem = dest_mesh.n_local_elem();
234 dof_id_type n_dest_nodes = dest_mesh.n_local_nodes();
236 CPPUNIT_ASSERT_EQUAL(n_dest_elem, dest_mesh.n_elem());
237 CPPUNIT_ASSERT_EQUAL(n_dest_nodes, dest_mesh.n_nodes());
238 CPPUNIT_ASSERT_EQUAL(src_mesh.n_elem(), dest_mesh.n_elem());
239 CPPUNIT_ASSERT_EQUAL(src_mesh.n_nodes(), dest_mesh.n_nodes());
261 { LOG_UNIT_TEST; testCopyConstruct<ReplicatedMesh, ReplicatedMesh>(); }
264 { LOG_UNIT_TEST; testCopyConstruct<DistributedMesh, ReplicatedMesh>(); }
267 { LOG_UNIT_TEST; testCopyConstruct<ReplicatedMesh, DistributedMesh>(); }
270 { LOG_UNIT_TEST; testCopyConstruct<DistributedMesh, DistributedMesh>(); }
void testReplicatedMeshConstructFromDistributed()
CPPUNIT_TEST(testMeshMoveAssignFromFile)
void testDistributedMeshMoveAssignFromMemory()
CPPUNIT_TEST(testReplicatedMeshMoveAssignFromFile)
CPPUNIT_TEST(testReplicatedMeshMoveAssignFromMemory)
CPPUNIT_TEST(testDistributedMeshConstructFromDistributed)
CPPUNIT_TEST(testMeshMoveAssignFromMemory)
void testMeshMoveAssignFromMemory()
CPPUNIT_TEST(testDistributedMeshMoveAssignFromMemory)
void testDistributedMeshConstructFromDistributed()
void testReplicatedMeshMoveAssignFromMemory()
CPPUNIT_TEST(testDistributedMeshConstructFromReplicated)
CPPUNIT_TEST(testReplicatedMeshConstructFromDistributed)
void testMeshMoveAssign(const std::string &mesh_type, const std::string &mesh_creation_type)
LIBMESH_CPPUNIT_TEST_SUITE(MeshAssignTest)
This test verifies the operations of the move assignment operator for MeshBase and derived classes.
void testDistributedMeshMoveAssignFromFile()
void testReplicatedMeshMoveAssignFromFile()
CPPUNIT_TEST(testReplicatedMeshConstructFromReplicated)
void testReplicatedMeshConstructFromReplicated()
void testDistributedMeshConstructFromReplicated()
CPPUNIT_TEST(testDistributedMeshMoveAssignFromFile)
void testMeshMoveAssignFromFile()
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 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.
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
Communicator * TestCommWorld
CPPUNIT_TEST_SUITE_REGISTRATION(MeshAssignTest)
The libMesh namespace provides an interface to certain functionality in the library.