19 auto s_bc = s.clone({s});
21 s_bc.set_eval([=](
const gretl::UpstreamStates& inputs, gretl::DownstreamState& output) {
22 auto s_new = std::make_shared<FiniteElementState>(*inputs[0].get<FEFieldPtr>());
27 s_bc.set_vjp([=](gretl::UpstreamStates& inputs,
const gretl::DownstreamState& output) {
33 return s_bc.finalize();
37 const TimeInfo& time_info,
const FieldState& shape_disp,
const std::vector<FieldState>& states_in,
38 const std::vector<FieldState>& params)
const
41 SLIC_ERROR_IF(states_in.size() != 3,
"ExplicitNewmark is a 2nd order time integrator requiring 3 states.");
55 std::vector<FieldState> states = states_in;
57 if (time_info.
cycle() == 0 || !m_diag_inv) {
59 auto lumped_mass =
computeLumpedMass(mass_residual_eval_.get(), shape_disp, states[DISP], params[DENSITY]);
61 m_diag_inv = std::make_unique<FieldState>(diag_inv);
62 auto zero_mass_res =
evalResidual(residual_eval_.get(), shape_disp, states, params, time_info, ACCEL);
64 states[ACCEL] = a_initial;
67 double start_time = time_info.
time();
68 double end_time = time_info.
time() + time_info.
dt();
70 DoubleState stable_dt = ts_estimator_->dt(shape_disp, states, params);
72 gretl::clone_state([=](
double) {
return start_time; }, [](double, double,
double&, double) {}, stable_dt);
74 while (time.get() < end_time) {
75 if (time.get() + stable_dt.get() > end_time) {
76 stable_dt = end_time - time;
79 time = time + stable_dt;
87 FieldState v_half_step = v + 0.5 * (stable_dt * a);
88 FieldState u_pred = u + stable_dt * v_half_step;
93 std::vector<FieldState> state_pred{u_pred, v_half_step,
zeroCopy(a)};
96 auto zero_mass_res =
evalResidual(residual_eval_.get(), shape_disp, state_pred, params,
103 FieldState v_pred = v_half_step + 0.5 * (stable_dt * a_pred);
105 states = std::vector<FieldState>{u_pred, v_pred, a_pred};
107 if (time.get() < end_time) {
108 stable_dt = ts_estimator_->dt(shape_disp, states, params);
This file contains the declaration of the boundary condition manager class.
A container for the boundary condition information relating to a specific physics module.
const mfem::Array< int > & allEssentialTrueDofs() const
Returns all the true degrees of freedom associated with all the essential BCs.
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
std::vector< FieldState > advanceState(const TimeInfo &time_info, const FieldState &shape_disp, const std::vector< FieldState > &states, const std::vector< FieldState > ¶ms) const override
This is an overloaded member function, provided for convenience. It differs from the above function o...
Implementation of explicit Newmark.
Accelerator functionality.
FieldState diagInverse(const FieldState &x)
gretl-function implementation to compute invert the values for every entry in a FieldState.
FieldState evalResidual(const WeakForm *residual_eval, FieldState shape_disp, const std::vector< FieldState > &states, const std::vector< FieldState > ¶ms, TimeInfo time_info, size_t inertial_index)
gretl-function implementation which evaluates the residual force (which is minus the mechanical force...
gretl::State< double, double > DoubleState
typedef
std::shared_ptr< FiniteElementState > FEFieldPtr
typedef
gretl::State< FEFieldPtr, FEDualPtr > FieldState
typedef
FieldState computeLumpedMass(const WeakForm *mass_residual_eval, const FieldState &shape_u, const FieldState &lumped_field, const FieldState &rho)
gretl-function implementation to compute lumped mass vectors from shape_displacements FieldState and ...
std::shared_ptr< FiniteElementDual > FEDualPtr
typedef
FieldState negativeComponentWiseMult(const FieldState &x, const FieldState &y, const BoundaryConditionManager *bc_manager)
gretl-function implementation which multiplies and then negates x and y component-wise to create a ne...
FieldState applyZeroBoundaryConditions(const FieldState &s, const BoundaryConditionManager *bc_manager)
uses the constrained dofs on the bc_manager to zero the corresponding dofs in FieldState s.
FieldState zeroCopy(const FieldState &x)
gretl-function to make a deep-copy of a FieldState and initialize it to 0.
#define SMITH_MARK_FUNCTION
struct storing time and timestep information
double dt() const
accessor for dt
size_t cycle() const
accessor for cycle
double time() const
accessor for the current time
Base class and implementations of an interface to estimate stable timesteps.