18 #include "libmesh/newmark_solver.h" 20 #include "libmesh/diff_solver.h" 21 #include "libmesh/diff_system.h" 22 #include "libmesh/dof_map.h" 23 #include "libmesh/numeric_vector.h" 31 _is_accel_solve(false),
32 _initial_accel_set(false)
69 std::unique_ptr<NumericVector<Number>> new_solution_rate = nonlinear_solution.
clone();
70 (*new_solution_rate) -= old_nonlinear_soln;
78 std::unique_ptr<NumericVector<Number>> new_solution_accel =
old_solution_accel.clone();
79 (*new_solution_accel) *= -(1.0/(2.0*
_beta)-1.0);
104 libmesh_not_implemented();
153 "ERROR: Must first set initial acceleration using one of:\n" 154 "NewmarkSolver::compute_initial_accel()\n" 155 "NewmarkSolver::project_initial_accel()\n");
207 ResFuncType time_deriv,
208 ResFuncType constraint,
209 ReinitFuncType reinit_func)
219 for (
unsigned int i=0; i != n_dofs; ++i)
220 old_elem_solution_rate(i) =
234 for (
unsigned int i=0; i != n_dofs; ++i)
235 old_elem_solution(i) =
257 request_jacobian =
false;
263 if (request_jacobian)
268 for (
unsigned int i=0; i != n_dofs; ++i)
269 old_elem_solution(i) =
274 for (
unsigned int i=0; i != n_dofs; ++i)
275 old_elem_solution_accel(i) =
310 (context.*reinit_func)(1.);
318 bool jacobian_computed = (
_system.
get_physics()->*time_deriv)(request_jacobian, context);
329 jacobian_computed = (
_system.
get_physics()->*constraint)(jacobian_computed, context) &&
333 if (request_jacobian)
335 if (jacobian_computed)
341 return jacobian_computed;
virtual bool element_residual(bool request_jacobian, DiffContext &) override
This method uses the DifferentiablePhysics' element_time_derivative() and element_constraint() to bui...
virtual bool side_constraint(bool request_jacobian, DiffContext &)
Adds the constraint contribution on side of elem to elem_residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
Real _gamma
The value for to employ.
Number old_solution_accel(const dof_id_type global_dof_number) const
void swap(DenseMatrix< T > &other_matrix)
STL-like swap method.
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseVector< T3 > &vec)
Adds factor times vec to this vector.
This class provides all data required for a physics package (e.g.
bool _initial_accel_set
This method requires an initial acceleration.
std::unique_ptr< DiffSolver > _diff_solver
An implicit linear or nonlinear solver to use at each timestep.
const DenseVector< Number > & get_elem_fixed_solution() const
Accessor for element fixed solution.
const DenseVector< Number > & get_elem_solution_rate() const
Accessor for element solution rate of change w.r.t.
virtual bool side_damping_residual(bool request_jacobian, DiffContext &)
Subtracts a damping vector contribution on side of elem from elem_residual.
Number old_nonlinear_solution(const dof_id_type global_dof_number) const
virtual bool side_residual(bool request_jacobian, DiffContext &) override
This method uses the DifferentiablePhysics' side_time_derivative() and side_constraint() to build a f...
virtual std::unique_ptr< NumericVector< T > > clone() const =0
virtual bool nonlocal_time_derivative(bool request_jacobian, DiffContext &)
Adds any nonlocal time derivative contributions (e.g.
virtual bool damping_residual(bool request_jacobian, DiffContext &)
Subtracts a damping vector contribution on elem from elem_residual.
std::unique_ptr< NumericVector< Number > > _old_local_solution_accel
Serial vector of previous time step acceleration .
The libMesh namespace provides an interface to certain functionality in the library.
virtual bool nonlocal_constraint(bool request_jacobian, DiffContext &)
Adds any nonlocal constraint contributions (e.g.
virtual void elem_reinit(Real)
Gives derived classes the opportunity to reinitialize data (FE objects in FEMSystem, for example) needed for an interior integration at a new point within a timestep.
bool _eulerian_time_deriv(bool request_jacobian, DiffContext &)
This method simply combines element_time_derivative() and eulerian_residual(), which makes its addres...
virtual void compute_initial_accel()
This method uses the specified initial displacement and velocity to compute the initial acceleration ...
virtual ~NewmarkSolver()
Destructor.
virtual bool mass_residual(bool request_jacobian, DiffContext &)
Subtracts a mass vector contribution on elem from elem_residual.
NewmarkSolver(sys_type &s)
Constructor.
This class provides a specific system class.
sys_type & _system
A reference to the system we are solving.
virtual bool _general_residual(bool request_jacobian, DiffContext &, ResFuncType mass, ResFuncType damping, ResFuncType time_deriv, ResFuncType constraint, ReinitFuncType reinit)
This method is the underlying implementation of the public residual methods.
Real elem_solution_rate_derivative
The derivative of elem_solution_rate with respect to the current nonlinear solution, for use by systems with non default mass_residual terms.
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution.
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
void set_initial_accel_avail(bool initial_accel_set)
Allow the user to (re)set whether the initial acceleration is available.
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
virtual void advance_timestep() override
This method advances the solution to the next timestep, after a solve() has been performed.
Number old_solution_rate(const dof_id_type global_dof_number) const
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &) override
This method uses the DifferentiablePhysics' nonlocal_time_derivative() and nonlocal_constraint() to b...
Generic class from which second order UnsteadySolvers should subclass.
virtual void solve() override
This method solves for the solution at the next timestep.
const DifferentiablePhysics * get_physics() const
virtual void advance_timestep() override
This method advances the solution to the next timestep, after a solve() has been performed.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void elem_side_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for a side integration at a new poi...
virtual bool nonlocal_damping_residual(bool request_jacobian, DiffContext &)
Subtracts any nonlocal damping vector contributions (e.g.
const DenseVector< Number > & get_elem_solution_accel() const
Accessor for element solution accel of change w.r.t.
virtual unsigned int size() const override final
virtual Real error_order() const override
Error convergence order: 2 for , 1 otherwise.
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...
bool _is_accel_solve
Need to be able to indicate to _general_residual if we are doing an acceleration solve or not...
virtual void solve() override
This method solves for the solution at the next timestep.
virtual bool side_mass_residual(bool request_jacobian, DiffContext &)
Subtracts a mass vector contribution on side of elem from elem_residual.
std::unique_ptr< NumericVector< Number > > _old_local_solution_rate
Serial vector of previous time step velocity .
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual bool side_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on side of elem to elem_residual.
virtual bool element_constraint(bool request_jacobian, DiffContext &)
Adds the constraint contribution on elem to elem_residual.
const DofMap & get_dof_map() const
Real elem_solution_accel_derivative
The derivative of elem_solution_accel with respect to the current nonlinear solution, for use by systems with non default mass_residual terms.
const std::vector< dof_id_type > & get_send_list() const
virtual bool nonlocal_mass_residual(bool request_jacobian, DiffContext &c)
Subtracts any nonlocal mass vector contributions (e.g.
virtual void adjoint_advance_timestep() override
This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been...
void project_initial_accel(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
Specify non-zero initial acceleration.
Real _beta
The value for the to employ.
const NumericVector< Number > & get_vector(std::string_view vec_name) const
bool first_solve
A bool that will be true the first time solve() is called, and false thereafter.
virtual void nonlocal_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for nonlocal calculations at a new ...