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" 49 const std::string & name_in,
50 const unsigned int number_in) :
55 this->
time_solver = std::make_unique<SteadySolver>(*this);
66 for (
const auto & node : this->
get_mesh().local_node_ptr_range())
67 for (
unsigned int d = 0; d <
dim; ++d)
69 unsigned int source_dof = node->dof_number(this->
number(),
var[d], 0);
70 unsigned int dest_dof = node->dof_number(aux_sys.
number(),
undefo_var[d], 0);
82 Order order = (*(this->
get_mesh().elements_begin()))->default_order();
102 FEMSystem::init_data();
126 solver.
quiet =
args(
"solver/quiet",
false);
133 ((
NewtonSolver &) solver).require_residual_reduction =
args(
"solver/nonlinear/require_reduction",
false);
148 FEMContext & c = cast_ref<FEMContext &>(context);
151 FEBase * elem_fe =
nullptr;
159 FEBase * side_fe =
nullptr;
174 FEMContext & c = cast_ref<FEMContext &>(context);
178 FEBase * elem_fe =
nullptr;
182 const std::vector<Real> & JxW = elem_fe->get_JxW();
185 const std::vector<std::vector<RealGradient>> & dphi = elem_fe->get_dphi();
211 std::vector<dof_id_type> undefo_index;
214 bool use_symmetry =
args(
"assembly/use_symmetry",
false);
224 for (
unsigned int qp = 0; qp != n_qpoints; qp++)
227 grad_u(0) = grad_u(1) = grad_u(2) = 0;
228 for (
unsigned int d = 0; d <
dim; ++d)
230 std::vector<Number> u_undefo;
232 aux_system.current_local_solution->get(undefo_index, u_undefo);
233 for (
unsigned int l = 0; l != n_u_dofs; l++)
234 grad_u(d).
add_scaled(dphi[l][qp], u_undefo[l]);
242 for (
unsigned int i = 0; i < n_u_dofs; i++)
247 for (
unsigned int ii = 0; ii <
dim; ++ii)
253 for (
unsigned int j = (use_symmetry ? i : 0); j < n_u_dofs; j++)
256 stiff.
scale(JxW[qp]);
257 for (
unsigned int ii = 0; ii <
dim; ++ii)
259 for (
unsigned int jj = 0; jj <
dim; ++jj)
262 if (use_symmetry && i != j)
271 return request_jacobian;
277 FEMContext & c = cast_ref<FEMContext &>(context);
291 cast_int<boundary_id_type>(
args.vector_variable_size(
"bc/displacement"));
293 libmesh_error_msg_if(num_bc % 4 != 0,
294 "ERROR, Odd number of values in displacement boundary condition.");
303 cast_int<boundary_id_type>(
args(
"bc/displacement", 1, nbc * 4));
312 for (
unsigned int d = 0; d < c.
get_dim(); ++d)
313 diff_value(d) =
args(
"bc/displacement", NAN, nbc * 4 + 1 + d);
318 Real penalty_number =
args(
"bc/displacement_penalty", 1e7);
323 const std::vector<std::vector<Real>> & phi = fe->
get_phi();
324 const std::vector<Real> & JxW = fe->
get_JxW();
325 const std::vector<Point> & coords = fe->
get_xyz();
332 std::vector<dof_id_type> undefo_dofs[3];
333 for (
unsigned int d = 0; d < c.
get_dim(); ++d)
340 for (
unsigned int i = 0; i < n_x_dofs; ++i)
342 for (
unsigned int d = 0; d < c.
get_dim(); ++d)
346 #if LIBMESH_USE_COMPLEX_NUMBERS 347 orig_point(d) += phi[i][qp] * orig_val.real();
349 orig_point(d) += phi[i][qp] * orig_val;
355 Point diff = coords[qp] - orig_point - diff_value;
358 for (
unsigned int i = 0; i < n_x_dofs; ++i)
360 for (
unsigned int d1 = 0; d1 < c.
get_dim(); ++d1)
364 Real val = JxW[qp] * phi[i][qp] * diff(d1) * penalty_number;
367 if (request_jacobian)
369 for (
unsigned int j = 0; j < n_x_dofs; ++j)
371 for (
unsigned int d1 = 0; d1 < c.
get_dim(); ++d1)
375 Real val = JxW[qp] * phi[i][qp] * phi[j][qp] * penalty_number;
384 return request_jacobian;
This is the EquationSystems class.
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 add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
Order
defines an enum for polynomial orders.
This class provides all data required for a physics package (e.g.
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...
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Compute contribution from internal forces in elem_residual and contribution from linearized internal ...
virtual bool side_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on side of elem to elem_residual.
This class implements a constitutive formulation for an Neo-Hookean elastic solid in terms of the cur...
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
const Elem & get_elem() const
Accessor for current Elem object.
void get_residual(DenseVector< Real > &residuum, unsigned int &i)
Return the residual vector for the current state.
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
void resize(const unsigned int n)
Resize the vector.
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
unsigned int n_dof_indices() const
Total number of dof indices on the element.
const EquationSystems & get_equation_systems() const
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
Manages storage and variables for transient systems.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
void scale(const T factor)
Multiplies every element in the vector by factor.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
const T_sys & get_system(std::string_view name) const
unsigned char get_side() const
Accessor for current side of Elem object.
virtual void init_context(DiffContext &context)
const MeshBase & get_mesh() const
This class provides a specific system class.
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
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 char get_dim() const
Accessor for cached mesh dimension.
Number current_solution(const dof_id_type global_dof_number) const
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
This class handles the numbering of degrees of freedom on a mesh.
unsigned int number() const
const T & get(std::string_view) const
void get_linearized_stiffness(DenseMatrix< Real > &stiffness, unsigned int &i, unsigned int &j)
Return the stiffness matrix for the current state.
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...
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class provides all data required for a physics package (e.g.
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.
unsigned int n_points() const
SolidSystem(EquationSystems &es, const std::string &name, const unsigned int number)
virtual_for_inffe const std::vector< Point > & get_xyz() const
unsigned int undefo_var[3]
void scale(const T factor)
Multiplies every element in the matrix by factor.
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false...
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
void mesh_position_set()
Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom co...
unsigned int mesh_dimension() const
Parameters parameters
Data structure holding arbitrary parameters.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
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...
Defines a dense vector for use in Finite Element-type computations.
void mesh_position_get()
Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal c...
virtual void set_mesh_system(System *sys)
Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which...
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
const DofMap & get_dof_map() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
This class forms the foundation from which generic finite elements may be derived.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
Real relative_residual_tolerance
Real relative_step_tolerance
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem. ...
const std::vector< std::vector< OutputShape > > & get_phi() const