57 #include "libmesh/libmesh.h"    58 #include "libmesh/mesh.h"    59 #include "libmesh/mesh_generation.h"    60 #include "libmesh/mesh_refinement.h"    61 #include "libmesh/exodusII_io.h"    62 #include "libmesh/equation_systems.h"    63 #include "libmesh/fe.h"    64 #include "libmesh/quadrature_gauss.h"    65 #include "libmesh/dof_map.h"    66 #include "libmesh/sparse_matrix.h"    67 #include "libmesh/numeric_vector.h"    68 #include "libmesh/dense_matrix.h"    69 #include "libmesh/dense_vector.h"    70 #include "libmesh/getpot.h"    71 #include "libmesh/elem.h"    72 #include "libmesh/fe_interface.h"    73 #include "libmesh/boundary_info.h"    74 #include "libmesh/linear_implicit_system.h"    75 #include "libmesh/zero_function.h"    76 #include "libmesh/dirichlet_boundaries.h"    77 #include "libmesh/enum_solver_package.h"    83 #define MIN_Z_BOUNDARY 1    84 #define MAX_Z_BOUNDARY 2    85 #define CRACK_BOUNDARY_LOWER 3    86 #define CRACK_BOUNDARY_UPPER 4    98 int main (
int argc, 
char ** argv)
   104 #ifndef LIBMESH_HAVE_EXODUS_API   105   libmesh_example_requires(
false, 
"--enable-exodus");
   109   libmesh_example_requires(3 <= LIBMESH_DIM, 
"3D support");
   112 #ifndef LIBMESH_ENABLE_DIRICHLET   113   libmesh_example_requires(
false, 
"--enable-dirichlet");
   130 #ifdef LIBMESH_ENABLE_DIRICHLET   139 #endif // LIBMESH_ENABLE_DIRICHLET   148     (
mesh, CRACK_BOUNDARY_LOWER, CRACK_BOUNDARY_UPPER);
   153   equation_systems.init();
   154   equation_systems.print_info();
   157   equation_systems.parameters.set<
Real>(
"R") = R;
   164 #ifdef LIBMESH_HAVE_EXODUS_API   170 #ifdef LIBMESH_ENABLE_AMR   173   unsigned int n_refinements =
   176   for (
unsigned int r = 0; r != n_refinements; ++r)
   178       std::cout << 
"Refining the mesh" << std::endl;
   181       equation_systems.reinit();
   187 #ifdef LIBMESH_HAVE_EXODUS_API   189       std::ostringstream 
out;
   190       out << 
"solution_" << r << 
".exo";
   212   const DofMap & dof_map = system.get_dof_map();
   214   FEType fe_type = dof_map.variable_type(0);
   223   fe->attach_quadrature_rule (&qrule);
   224   fe_elem_face->attach_quadrature_rule (&qface);
   225   fe_neighbor_face->attach_quadrature_rule (&qface);
   227   const std::vector<Real> & JxW = fe->get_JxW();
   228   const std::vector<std::vector<Real>> & phi = fe->get_phi();
   229   const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
   231   const std::vector<Real> & JxW_face = fe_elem_face->get_JxW();
   233   const std::vector<Point> & qface_points = fe_elem_face->get_xyz();
   235   const std::vector<std::vector<Real>> & phi_face          = fe_elem_face->get_phi();
   236   const std::vector<std::vector<Real>> & phi_neighbor_face = fe_neighbor_face->get_phi();
   246   std::vector<dof_id_type> dof_indices;
   249   for (
const auto & elem : 
mesh.active_local_element_ptr_range())
   251       dof_map.dof_indices (elem, dof_indices);
   252       const unsigned int n_dofs = dof_indices.size();
   256       Ke.
resize (n_dofs, n_dofs);
   260       for (
unsigned int qp=0; qp<qrule.n_points(); qp++)
   261         for (
unsigned int i=0; i<n_dofs; i++)
   262           for (
unsigned int j=0; j<n_dofs; j++)
   263             Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
   267         for (
auto side : elem->side_index_range())
   268           if (elem->neighbor_ptr(side) == 
nullptr)
   272                   fe_elem_face->reinit(elem, side);
   274                   for (
unsigned int qp=0; qp<qface.n_points(); qp++)
   275                     for (std::size_t i=0; i<phi.size(); i++)
   276                       Fe(i) += JxW_face[qp] * phi_face[i][qp];
   284         for (
auto side : elem->side_index_range())
   285           if (elem->neighbor_ptr(side) == 
nullptr)
   290                   fe_elem_face->reinit(elem, side);
   292                   ElementSideMap::const_iterator ltu_it =
   293                     lower_to_upper.find(std::make_pair(elem, side));
   296                   const Elem * neighbor = ltu_it->second;
   298                   std::vector<Point> qface_neighbor_points;
   301                                       qface_neighbor_points);
   302                   fe_neighbor_face->reinit(neighbor, &qface_neighbor_points);
   304                   std::vector<dof_id_type> neighbor_dof_indices;
   305                   dof_map.dof_indices (neighbor, neighbor_dof_indices);
   306                   const unsigned int n_neighbor_dofs = neighbor_dof_indices.size();
   308                   Kne.
resize (n_neighbor_dofs, n_dofs);
   309                   Ken.
resize (n_dofs, n_neighbor_dofs);
   310                   Kee.
resize (n_dofs, n_dofs);
   311                   Knn.
resize (n_neighbor_dofs, n_neighbor_dofs);
   314                   for (
unsigned int qp=0; qp<qface.n_points(); qp++)
   315                     for (
unsigned int i=0; i<n_dofs; i++)
   316                       for (
unsigned int j=0; j<n_dofs; j++)
   317                         Kee(i,j) -= JxW_face[qp] * (1./R)*(phi_face[i][qp] * phi_face[j][qp]);
   320                   for (
unsigned int qp=0; qp<qface.n_points(); qp++)
   321                     for (
unsigned int i=0; i<n_dofs; i++)
   322                       for (
unsigned int j=0; j<n_neighbor_dofs; j++)
   323                         Ken(i,j) += JxW_face[qp] * (1./R)*(phi_face[i][qp] * phi_neighbor_face[j][qp]);
   326                   for (
unsigned int qp=0; qp<qface.n_points(); qp++)
   327                     for (
unsigned int i=0; i<n_neighbor_dofs; i++)
   328                       for (
unsigned int j=0; j<n_neighbor_dofs; j++)
   329                         Knn(i,j) -= JxW_face[qp] * (1./R)*(phi_neighbor_face[i][qp] * phi_neighbor_face[j][qp]);
   332                   for (
unsigned int qp=0; qp<qface.n_points(); qp++)
   333                     for (
unsigned int i=0; i<n_neighbor_dofs; i++)
   334                       for (
unsigned int j=0; j<n_dofs; j++)
   335                         Kne(i,j) += JxW_face[qp] * (1./R)*(phi_neighbor_face[i][qp] * phi_face[j][qp]);
   337                   matrix.
add_matrix(Kne, neighbor_dof_indices, dof_indices);
   338                   matrix.
add_matrix(Ken, dof_indices, neighbor_dof_indices);
   345       dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
   348       system.rhs->add_vector    (Fe, dof_indices);
 class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line...
This is the EquationSystems class. 
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. 
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
ConstFunction that simply returns 0. 
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
void resize(const unsigned int n)
Resize the vector. 
void assemble_poisson(EquationSystems &es, const ElementSideMap &lower_to_upper)
Assemble the system matrix and rhs vector. 
This is the base class from which all geometric element types are derived. 
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
Order default_quadrature_order() const
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g. 
The libMesh namespace provides an interface to certain functionality in the library. 
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh. 
virtual void solve() override
Assembles & solves the linear system A*x=b. 
const T_sys & get_system(std::string_view name) const
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices. 
This is the MeshBase class. 
This class handles the numbering of degrees of freedom on a mesh. 
int main(int argc, char **argv)
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix. 
const T & get(std::string_view) const
Implements (adaptive) mesh refinement algorithms for a MeshBase. 
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep. 
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary. 
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type. 
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. 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MeshBase & get_mesh() const
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero(). 
This class implements specific orders of Gauss quadrature. 
unsigned int mesh_dimension() const
Parameters parameters
Data structure holding arbitrary parameters. 
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system. 
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default. 
std::map< std::pair< const Elem *, unsigned char >, const Elem * > ElementSideMap
const DofMap & get_dof_map() const
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times. 
const ElementSideMap & get_lower_to_upper() const