Go to the documentation of this file.    1 #include <libmesh/mesh.h> 
    2 #include <libmesh/mesh_generation.h> 
    3 #include <libmesh/boundary_info.h> 
    4 #include <libmesh/elem.h> 
    5 #include <libmesh/face_quad4_shell.h> 
    6 #include <libmesh/equation_systems.h> 
    7 #include <libmesh/zero_function.h> 
    8 #include <libmesh/dirichlet_boundaries.h> 
    9 #include <libmesh/dof_map.h> 
   10 #include <libmesh/parallel.h> 
   26   CPPUNIT_TEST( testMesh );
 
   27 # ifdef LIBMESH_ENABLE_DIRICHLET 
   28   CPPUNIT_TEST( testShellFaceConstraints );
 
   32   CPPUNIT_TEST( testEdgeBoundaryConditions );
 
   35   CPPUNIT_TEST_SUITE_END();
 
   61 #ifdef LIBMESH_ENABLE_DEPRECATED 
   62     std::vector<dof_id_type> element_id_list;
 
   63     std::vector<unsigned short int> side_list;
 
   64     std::vector<boundary_id_type> bc_id_list;
 
   72       CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(4), bi.
n_boundary_ids());
 
   79           bool has_bcid = bc_ids.count(i);
 
   81           CPPUNIT_ASSERT(has_bcid);
 
   86 #ifdef LIBMESH_ENABLE_DEPRECATED 
   97 #ifdef LIBMESH_ENABLE_DEPRECATED 
   98         CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(8), element_id_list.size());
 
  100         CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(8), bc_triples.size());
 
  108       CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(3), bi.
n_boundary_ids());
 
  112       CPPUNIT_ASSERT(!bc_ids.count(0));
 
  115           bool has_bcid = bc_ids.count(i);
 
  117           CPPUNIT_ASSERT(has_bcid);
 
  122 #ifdef LIBMESH_ENABLE_DEPRECATED 
  131 #ifdef LIBMESH_ENABLE_DEPRECATED 
  132         CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(6), element_id_list.size());
 
  134         CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(6), bc_triples.size());
 
  138 #ifdef LIBMESH_ENABLE_DEPRECATED 
  139     CPPUNIT_ASSERT(std::find(bc_id_list.begin(), bc_id_list.end(), 0) == bc_id_list.end());
 
  141     typedef std::tuple<dof_id_type, unsigned short int, boundary_id_type> Tuple;
 
  142     CPPUNIT_ASSERT(std::find_if(bc_triples.begin(), bc_triples.end(),
 
  143                                 [](
const Tuple & t)->
bool { 
return std::get<2>(t) == 0; }) == bc_triples.end());
 
  148       CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(3), bi.
n_boundary_ids());
 
  156 #ifdef LIBMESH_ENABLE_DEPRECATED 
  161     CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(0), bi.
n_boundary_ids());
 
  162 #ifdef LIBMESH_ENABLE_DEPRECATED 
  163     CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(0), element_id_list.size());
 
  165     CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(0), bc_triples.size());
 
  170     const unsigned int n_elem = 5;
 
  171     const std::string mesh_filename = 
"cube_mesh.xda";
 
  185       CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(0), bi.
n_edge_conds());
 
  196           unsigned short side_max_x = 0, side_min_y = 0;
 
  197           bool found_side_max_x = 
false, found_side_min_y = 
false;
 
  199           for (
unsigned short side=0; side<elem->n_sides(); side++)
 
  204                   found_side_max_x = 
true;
 
  210                   found_side_min_y = 
true;
 
  217           if (found_side_max_x && found_side_min_y)
 
  218             for (
unsigned short e=0; e<elem->n_edges(); e++)
 
  219               if (elem->is_edge_on_side(e, side_max_x) &&
 
  220                   elem->is_edge_on_side(e, side_min_y))
 
  221                 bi.
add_edge(elem, e, EDGE_BOUNDARY_ID);
 
  243 #ifdef LIBMESH_ENABLE_DIRICHLET 
  293     System & system = es.add_system<
System> (
"SimpleSystem");
 
  298     std::vector<unsigned int> variables;
 
  299     variables.push_back(0);
 
  300     std::set<boundary_id_type> shellface_ids;
 
  301     shellface_ids.insert(20);
 
  311     elem_bottom = 
nullptr;
 
  321     CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(4), static_cast<std::size_t>(system.
n_constrained_dofs()));
 
  328         std::vector<dof_id_type> dof_indices;
 
  330         CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(4), dof_indices.size());
 
  332         for(
unsigned int i=0; i<dof_indices.size(); i++)
 
  339 #endif // LIBMESH_ENABLE_DIRICHLET 
 
Manages consistently variables, degrees of freedom, and coefficient vectors.
 
void remove_id(boundary_id_type id)
Removes all entities (nodes, sides, edges, shellfaces) with boundary id id from their respective cont...
 
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
 
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
 
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
 
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
 
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
 
virtual bool is_serial() const
 
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
 
virtual void write(const std::string &name)=0
 
virtual dof_id_type max_elem_id() const =0
 
The libMesh namespace provides an interface to certain functionality in the library.
 
const Parallel::Communicator & comm() const
 
std::size_t n_shellface_conds() const
 
std::size_t n_edge_conds() const
 
virtual const Node * node_ptr(const dof_id_type i) const =0
 
bool is_constrained_dof(const dof_id_type dof) const
 
processor_id_type processor_id() const
 
const Point & point(const unsigned int i) const
 
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
 
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
 
const std::set< boundary_id_type > & get_boundary_ids() const
 
virtual SimpleRange< element_iterator > element_ptr_range()=0
 
void testEdgeBoundaryConditions()
 
void testShellFaceConstraints()
 
processor_id_type processor_id() const
 
unsigned int add_variable(const std::string &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.
 
libMesh::Parallel::Communicator * TestCommWorld
 
A Point defines a location in LIBMESH_DIM dimensional Real space.
 
std::size_t n_boundary_ids() const
 
ConstFunction that simply returns 0.
 
This is the EquationSystems class.
 
virtual Node *& set_node(const unsigned int i)
 
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
 
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
Add edge edge of element number elem with boundary id id to the boundary information data structure.
 
dof_id_type n_constrained_dofs() const
 
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
 
CPPUNIT_TEST_SUITE_REGISTRATION(BoundaryInfoTest)
 
This is the base class from which all geometric element types are derived.
 
const DofMap & get_dof_map() const
 
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Add shell face shellface of element number elem with boundary id id to the boundary information data ...
 
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
 
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
 
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
 
QuadShell4 is almost identical to Quad4.