Go to the documentation of this file.
23 #include "libmesh/boundary_info.h"
24 #include "libmesh/diff_solver.h"
25 #include "libmesh/dof_map.h"
26 #include "libmesh/equation_systems.h"
27 #include "libmesh/fe_base.h"
28 #include "libmesh/fem_context.h"
29 #include "libmesh/getpot.h"
30 #include "libmesh/mesh.h"
31 #include "libmesh/newton_solver.h"
32 #include "libmesh/numeric_vector.h"
33 #include "libmesh/quadrature.h"
34 #include "libmesh/sparse_matrix.h"
35 #include "libmesh/steady_solver.h"
36 #include "libmesh/transient_system.h"
37 #include "libmesh/node.h"
38 #include "libmesh/elem.h"
39 #include "libmesh/auto_ptr.h"
53 const std::string & name_in,
54 const unsigned int number_in) :
59 this->
time_solver = libmesh_make_unique<SteadySolver>(*
this);
70 for (
const auto & node : this->
get_mesh().local_node_ptr_range())
71 for (
unsigned int d = 0; d <
dim; ++d)
73 unsigned int source_dof = node->dof_number(this->
number(),
var[d], 0);
74 unsigned int dest_dof = node->dof_number(aux_sys.
number(),
undefo_var[d], 0);
106 FEMSystem::init_data();
130 solver.
quiet =
args(
"solver/quiet",
false);
137 ((
NewtonSolver &) solver).require_residual_reduction =
args(
"solver/nonlinear/require_reduction",
false);
152 FEMContext & c = cast_ref<FEMContext &>(context);
155 FEBase * elem_fe =
nullptr;
163 FEBase * side_fe =
nullptr;
178 FEMContext & c = cast_ref<FEMContext &>(context);
182 FEBase * elem_fe =
nullptr;
186 const std::vector<Real> & JxW = elem_fe->
get_JxW();
189 const std::vector<std::vector<RealGradient>> & dphi = elem_fe->
get_dphi();
215 std::vector<dof_id_type> undefo_index;
218 bool use_symmetry =
args(
"assembly/use_symmetry",
false);
228 for (
unsigned int qp = 0; qp != n_qpoints; qp++)
231 grad_u(0) = grad_u(1) = grad_u(2) = 0;
232 for (
unsigned int d = 0; d <
dim; ++d)
234 std::vector<Number> u_undefo;
236 aux_system.current_local_solution->get(undefo_index, u_undefo);
237 for (
unsigned int l = 0; l != n_u_dofs; l++)
238 grad_u(d).
add_scaled(dphi[l][qp], u_undefo[l]);
246 for (
unsigned int i = 0; i < n_u_dofs; i++)
251 for (
unsigned int ii = 0; ii <
dim; ++ii)
257 for (
unsigned int j = (use_symmetry ? i : 0); j < n_u_dofs; j++)
260 stiff.
scale(JxW[qp]);
261 for (
unsigned int ii = 0; ii <
dim; ++ii)
263 for (
unsigned int jj = 0; jj <
dim; ++jj)
266 if (use_symmetry && i != j)
275 return request_jacobian;
281 FEMContext & c = cast_ref<FEMContext &>(context);
295 cast_int<boundary_id_type>(
args.vector_variable_size(
"bc/displacement"));
297 libmesh_error_msg(
"ERROR, Odd number of values in displacement boundary condition.");
305 cast_int<boundary_id_type>(
args(
"bc/displacement", 1, nbc * 4));
308 if (!this->
get_mesh().get_boundary_info().has_boundary_id
314 for (
unsigned int d = 0; d < c.
get_dim(); ++d)
315 diff_value(d) =
args(
"bc/displacement", NAN, nbc * 4 + 1 + d);
320 Real penalty_number =
args(
"bc/displacement_penalty", 1e7);
325 const std::vector<std::vector<Real>> & phi = fe->
get_phi();
326 const std::vector<Real> & JxW = fe->
get_JxW();
327 const std::vector<Point> & coords = fe->
get_xyz();
334 std::vector<dof_id_type> undefo_dofs[3];
335 for (
unsigned int d = 0; d < c.
get_dim(); ++d)
342 for (
unsigned int i = 0; i < n_x_dofs; ++i)
344 for (
unsigned int d = 0; d < c.
get_dim(); ++d)
348 #if LIBMESH_USE_COMPLEX_NUMBERS
349 orig_point(d) += phi[i][qp] * orig_val.real();
351 orig_point(d) += phi[i][qp] * orig_val;
357 Point diff = coords[qp] - orig_point - diff_value;
360 for (
unsigned int i = 0; i < n_x_dofs; ++i)
362 for (
unsigned int d1 = 0; d1 < c.
get_dim(); ++d1)
366 Real val = JxW[qp] * phi[i][qp] * diff(d1) * penalty_number;
369 if (request_jacobian)
371 for (
unsigned int j = 0; j < n_x_dofs; ++j)
373 for (
unsigned int d1 = 0; d1 < c.
get_dim(); ++d1)
377 Real val = JxW[qp] * phi[i][qp] * phi[j][qp] * penalty_number;
386 return request_jacobian;
Manages consistently variables, degrees of freedom, and coefficient vectors.
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time.
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
const EquationSystems & get_equation_systems() const
virtual bool side_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on side of elem to elem_residual.
const std::vector< Point > & get_xyz() const
virtual void set_mesh_system(System *sys)
Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which...
Manages storage and variables for transient systems.
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 void set_mesh_z_var(unsigned int var)
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z...
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Compute contribution from internal forces in elem_residual and contribution from linearized internal ...
unsigned int n_points() const
The libMesh namespace provides an interface to certain functionality in the library.
unsigned char get_side() const
Accessor for current side of Elem object.
This class forms the foundation from which generic finite elements may be derived.
const T_sys & get_system(const std::string &name) const
const std::vector< Real > & get_JxW() const
const Elem & get_elem() const
Accessor for current Elem object.
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
unsigned int number() const
virtual void set_mesh_x_var(unsigned int var)
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x...
unsigned int mesh_dimension() const
virtual void init_context(DiffContext &context)
const std::vector< std::vector< OutputGradient > > & get_dphi() const
virtual element_iterator elements_begin()=0
Iterate over all the elements in the Mesh.
virtual void set_mesh_y_var(unsigned int var)
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y...
This class provides a specific system class.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
Number current_solution(const dof_id_type global_dof_number) const
void get_residual(DenseVector< Real > &residuum, unsigned int &i)
Return the residual vector for the current state.
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
Real relative_step_tolerance
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
void mesh_position_get()
Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal c...
const MeshBase & get_mesh() 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.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
A Point defines a location in LIBMESH_DIM dimensional Real space.
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
unsigned int n_dof_indices() const
Total number of dof indices on the element.
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
This class provides all data required for a physics package (e.g.
This is the EquationSystems class.
SolidSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
void init_for_qp(VectorValue< Gradient > &grad_u, unsigned int qp)
Initialize the class for the given displacement gradient at the specified quadrature point.
void mesh_position_set()
Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom co...
void resize(const unsigned int n)
Resize the vector.
Real relative_residual_tolerance
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
unsigned int undefo_var[3]
void scale(const T factor)
Multiplies every element in the vector by factor.
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
This class handles the numbering of degrees of freedom on a mesh.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem.
unsigned char get_dim() const
Accessor for cached mesh dimension.
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...
const DofMap & get_dof_map() const
This class implements a constitutive formulation for an Neo-Hookean elastic solid in terms of the cur...
void get_linearized_stiffness(DenseMatrix< Real > &stiffness, unsigned int &i, unsigned int &j)
Return the stiffness matrix for the current state.
const std::vector< std::vector< OutputShape > > & get_phi() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
const T & get(const std::string &) const
void scale(const T factor)
Multiplies every element in the matrix by factor.
Defines a dense vector for use in Finite Element-type computations.
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
This class provides all data required for a physics package (e.g.
Parameters parameters
Data structure holding arbitrary parameters.