Go to the documentation of this file.
   37 #include "libmesh/libmesh_config.h" 
   38 #include "libmesh/libmesh.h" 
   39 #include "libmesh/mesh.h" 
   40 #include "libmesh/mesh_generation.h" 
   41 #include "libmesh/exodusII_io.h" 
   42 #include "libmesh/gnuplot_io.h" 
   43 #include "libmesh/linear_implicit_system.h" 
   44 #include "libmesh/equation_systems.h" 
   45 #include "libmesh/fe.h" 
   46 #include "libmesh/quadrature_gauss.h" 
   47 #include "libmesh/dof_map.h" 
   48 #include "libmesh/sparse_matrix.h" 
   49 #include "libmesh/numeric_vector.h" 
   50 #include "libmesh/dense_matrix.h" 
   51 #include "libmesh/dense_submatrix.h" 
   52 #include "libmesh/dense_vector.h" 
   53 #include "libmesh/dense_subvector.h" 
   54 #include "libmesh/perf_log.h" 
   55 #include "libmesh/elem.h" 
   56 #include "libmesh/boundary_info.h" 
   57 #include "libmesh/zero_function.h" 
   58 #include "libmesh/dirichlet_boundaries.h" 
   59 #include "libmesh/string_to_enum.h" 
   60 #include "libmesh/getpot.h" 
   61 #include "libmesh/solver_configuration.h" 
   62 #include "libmesh/petsc_linear_solver.h" 
   63 #include "libmesh/petsc_macro.h" 
   64 #include "libmesh/periodic_boundaries.h" 
   65 #include "libmesh/periodic_boundary.h" 
   66 #include "libmesh/enum_solver_package.h" 
   71 #ifdef LIBMESH_ENABLE_PERIODIC 
   94     set_transformation_matrix(get_rotation_matrix());
 
  116     set_transformation_matrix(get_rotation_matrix());
 
  138     R(0,0) = cos(_theta) + u_x*u_x*(1.0 - cos(_theta));
 
  139     R(0,1) = u_x*u_y*(1.0 - cos(_theta)) - u_z*sin(_theta);
 
  140     R(0,2) = u_x*u_z*(1.0 - cos(_theta)) + u_y*sin(_theta);
 
  141     R(1,0) = u_y*u_x*(1.0 - cos(_theta)) + u_z*sin(_theta);
 
  142     R(1,1) = cos(_theta) + u_y*u_y*(1.0 - cos(_theta));
 
  143     R(1,2) = u_y*u_z*(1.0 - cos(_theta)) - u_x*sin(_theta);
 
  144     R(2,0) = u_z*u_x*(1.0 - cos(_theta)) - u_y*sin(_theta);
 
  145     R(2,1) = u_z*u_y*(1.0 - cos(_theta)) + u_x*sin(_theta);
 
  146     R(2,2) = cos(_theta) + u_z*u_z*(1.0 - cos(_theta));
 
  159     for(
unsigned int i=0; i<3; i++)
 
  161       translated_pt(i) = pt(i) - _center(i);
 
  168     get_transformation_matrix().vector_mult_transpose(rotated_pt, translated_pt);
 
  170     Point corresponding_pos;
 
  171     for(
unsigned int i=0; i<3; i++)
 
  173       corresponding_pos(i) = rotated_pt(i) + _center(i);
 
  175     return corresponding_pos;
 
  185     return libmesh_make_unique<AzimuthalPeriodicBoundary>(*
this, t);
 
  197 #endif // LIBMESH_ENABLE_PERIODIC 
  216     return i == j ? 1. : 0.;
 
  228     const Real poisson_ratio = 0.3;
 
  229     const Real young_modulus = 1.;
 
  232     const Real lambda_1 = (young_modulus*poisson_ratio)/((1.+poisson_ratio)*(1.-2.*poisson_ratio));
 
  233     const Real lambda_2 = young_modulus/(2.*(1.+poisson_ratio));
 
  256     fe->attach_quadrature_rule (&qrule);
 
  260     fe_face->attach_quadrature_rule (&qface);
 
  262     const std::vector<Real> & JxW = fe->get_JxW();
 
  263     const std::vector<std::vector<Real>> & phi = fe->get_phi();
 
  264     const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
 
  281     std::vector<dof_id_type> dof_indices;
 
  282     std::vector<std::vector<dof_id_type>> dof_indices_var(3);
 
  287         for (
unsigned int var=0; var<3; var++)
 
  288           dof_map.
dof_indices (elem, dof_indices_var[var], var);
 
  290         const unsigned int n_dofs   = dof_indices.size();
 
  291         const unsigned int n_var_dofs = dof_indices_var[0].size();
 
  295         Ke.
resize (n_dofs, n_dofs);
 
  296         for (
unsigned int var_i=0; var_i<3; var_i++)
 
  297           for (
unsigned int var_j=0; var_j<3; var_j++)
 
  298             Ke_var[var_i][var_j].reposition (var_i*n_var_dofs, var_j*n_var_dofs, n_var_dofs, n_var_dofs);
 
  301         for (
unsigned int var=0; var<3; var++)
 
  302           Fe_var[var].reposition (var*n_var_dofs, n_var_dofs);
 
  304         for (
unsigned int qp=0; qp<qrule.n_points(); qp++)
 
  307             for (
unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
 
  308               for (
unsigned int dof_j=0; dof_j<n_var_dofs; dof_j++)
 
  309                 for (
unsigned int i=0; i<3; i++)
 
  310                   for (
unsigned int j=0; j<3; j++)
 
  311                     for (
unsigned int k=0; k<3; k++)
 
  312                       for (
unsigned int l=0; l<3; l++)
 
  313                         Ke_var[i][k](dof_i,dof_j) +=
 
  318             if(elem->subdomain_id() == 101)
 
  324             else if(elem->subdomain_id() == 1)
 
  330             for (
unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
 
  331               for (
unsigned int i=0; i<3; i++)
 
  332                 Fe_var[i](dof_i) += JxW[qp] * (f_vec(i) * phi[dof_i][qp]);
 
  345 int main (
int argc, 
char ** argv)
 
  352                            "--enable-petsc, --enable-trilinos, or --enable-eigen");
 
  354 #ifndef LIBMESH_HAVE_EXODUS_API 
  356   libmesh_example_requires(
false, 
"--enable-exodus");
 
  360 #ifndef LIBMESH_ENABLE_DIRICHLET 
  361   libmesh_example_requires(
false, 
"--enable-dirichlet");
 
  363 #ifndef LIBMESH_ENABLE_PERIODIC 
  364   libmesh_example_requires(
false, 
"--enable-periodic");
 
  368   const unsigned int dim = 3;
 
  371   libmesh_example_requires(
dim == LIBMESH_DIM, 
"3D support");
 
  374   libmesh_example_requires(
sizeof(
boundary_id_type) > 1, 
"boundary_id_size > 1");
 
  376 #if LIBMESH_BOUNDARY_ID_BYTES > 1 
  388 #ifdef LIBMESH_ENABLE_PERIODIC 
  400     Point center(0., 0., 0.);
 
  401     Point axis(0., 0., 1.);
 
  409     Point center(0., 0., 0.);
 
  410     Point axis(0., 0., 1.);
 
  417 #endif // LIBMESH_ENABLE_PERIODIC 
  419   mesh.
read(
"systems_of_equations_ex9.exo");
 
  432   std::vector<unsigned int> variables;
 
  433   variables.push_back(u_var);
 
  434   variables.push_back(v_var);
 
  435   variables.push_back(w_var);
 
  437   std::set<boundary_id_type> clamped_boundary_ids;
 
  438   clamped_boundary_ids.insert(300);
 
  439   clamped_boundary_ids.insert(400);
 
  441 #ifdef LIBMESH_ENABLE_DIRICHLET 
  447   equation_systems.init();
 
  450   equation_systems.print_info();
 
  456 #ifdef LIBMESH_HAVE_EXODUS_API 
  461 #endif // #ifdef LIBMESH_HAVE_EXODUS_API 
  462 #endif // #if LIBMESH_BOUNDARY_ID_BYTES > 1 
  
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
 
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
 
const MeshBase & get_mesh() const
 
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.
 
NumericVector< Number > * rhs
The system matrix.
 
This class implements specific orders of Gauss quadrature.
 
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.
 
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
 
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
 
Defines a dense submatrix for use in Finite Element-type computations.
 
The base class for defining periodic boundaries.
 
The libMesh namespace provides an interface to certain functionality in the library.
 
const T_sys & get_system(const std::string &name) const
 
AzimuthalPeriodicBoundary(Point center, Point axis, Real angle)
Constructor.
 
Real kronecker_delta(unsigned int i, unsigned int j)
 
virtual void solve() override
Assembles & solves the linear system A*x=b.
 
SolverPackage default_solver_package()
 
unsigned int mesh_dimension() const
 
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
Evaluate the fourth order tensor (C_ijkl) that relates stress to strain.
 
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
 
void resize(const unsigned int new_m, const unsigned int new_n)
Resize the matrix.
 
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
 
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i].
 
This is the MeshBase class.
 
void assemble()
Assemble the system matrix and right-hand side vector.
 
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
 
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.
 
LinearElasticity(EquationSystems &es_in)
 
A Point defines a location in LIBMESH_DIM dimensional Real space.
 
SparseMatrix< Number > * matrix
The system matrix.
 
boundary_id_type myboundary
The boundary ID of this boundary and its counterpart.
 
int main(int argc, char **argv)
 
const FEType & variable_type(const unsigned int c) const
 
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
 
virtual ~AzimuthalPeriodicBoundary()
Destructor.
 
ConstFunction that simply returns 0.
 
void add_periodic_boundary(const PeriodicBoundaryBase &periodic_boundary)
Adds a copy of the specified periodic boundary to the system.
 
virtual std::unique_ptr< PeriodicBoundaryBase > clone(TransformationType t=FORWARD) const override
If we want the DofMap to be able to make copies of references and store them in the underlying map,...
 
Abstract base class to be used for system assembly.
 
This is the EquationSystems class.
 
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
 
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
 
DenseMatrix< Real > get_rotation_matrix() const
Get the rotation matrix for this transformation.
 
void resize(const unsigned int n)
Resize the vector.
 
void swap(Iterator &lhs, Iterator &rhs)
swap, used to implement op=
 
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.
 
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
 
TypeVector< T > unit() const
 
This class handles the numbering of degrees of freedom on a mesh.
 
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the mesh.
 
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
 
unsigned short int variable_number(const std::string &var) const
 
const DofMap & get_dof_map() const
 
virtual Point get_corresponding_pos(const Point &pt) const override
This function should be overridden by derived classes to define how one finds corresponding nodes on ...
 
AzimuthalPeriodicBoundary(const AzimuthalPeriodicBoundary &o, TransformationType t=FORWARD)
Copy constructor, with option for the copy to represent an inverse transformation.
 
void attach_assemble_object(Assembly &assemble)
Register a user object to use in assembling the system matrix and RHS.
 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
 
boundary_id_type pairedboundary
 
Order default_quadrature_order() const
 
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
 
Real kronecker_delta(unsigned int i, unsigned int j)
Kronecker delta function.
 
Defines a dense vector for use in Finite Element-type computations.