|
PolyFEM
|
Global residual form for ALE Navier–Stokes on velocity, pressure, and mesh-displacement spaces. More...
#include <NavierStokesFSIForm.hpp>
Public Types | |
| using | BodyForceEvaluator = assembler::NavierStokesFSIAssemblerData::BodyForceEvaluator |
| using | VelocityTildeUpdater = std::function< void(double time, const Eigen::VectorXd ¤t_velocity, Eigen::VectorXd &velocity_tilde)> |
Public Member Functions | |
| NavierStokesFSIForm (int total_size, int n_velocity_bases, int n_pressure_bases, int n_mesh_displacement_bases, const std::vector< basis::ElementBases > &velocity_bases, const std::vector< basis::ElementBases > &pressure_bases, const std::vector< basis::ElementBases > &mesh_displacement_bases, const std::vector< basis::ElementBases > &geom_bases, const assembler::AssemblyValsCache &velocity_cache, const assembler::AssemblyValsCache &pressure_cache, const assembler::AssemblyValsCache &mesh_displacement_cache, std::vector< std::shared_ptr< assembler::MultiSpacesNLAssembler > > assemblers, const time_integrator::ImplicitTimeIntegrator *velocity_time_integrator, const time_integrator::ImplicitTimeIntegrator *mesh_displacement_time_integrator, double t, double dt, bool is_volume, BodyForceEvaluator body_force_evaluator={}) | |
| std::string | name () const override |
| void | update_quantities (double t, const Eigen::VectorXd &x) override |
| Update time-dependent fields. | |
| void | set_velocity_tilde_updater (VelocityTildeUpdater updater) |
| bool | is_step_valid (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override |
| Determine if a step from solution x0 to solution x1 is allowed. | |
| int | velocity_ndof () const |
| int | pressure_ndof () const |
| int | mesh_displacement_ndof () const |
Public Member Functions inherited from polyfem::solver::Form | |
| virtual | ~Form () |
| virtual void | init (const Eigen::VectorXd &x) |
| Initialize the form. | |
| virtual void | finish () |
| virtual double | value (const Eigen::VectorXd &x) const |
| Compute the value of the form multiplied with the weigth. | |
| Eigen::VectorXd | value_per_element (const Eigen::VectorXd &x) const |
| Compute the value of the form multiplied with the weigth. | |
| virtual void | first_derivative (const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const |
| Compute the first derivative of the value wrt x multiplied with the weigth. | |
| void | second_derivative (const Eigen::VectorXd &x, StiffnessMatrix &hessian) const |
| Compute the second derivative of the value wrt x multiplied with the weigth. | |
| virtual double | max_step_size (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const |
| Determine the maximum step size allowable between the current and next solution. | |
| virtual void | line_search_begin (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) |
| Initialize variables used during the line search. | |
| virtual void | line_search_end () |
| Clear variables used during the line search. | |
| virtual void | post_step (const polysolve::nonlinear::PostStepData &data) |
| Update fields after a step in the optimization. | |
| virtual void | solution_changed (const Eigen::VectorXd &new_x) |
| Update cached fields upon a change in the solution. | |
| virtual void | init_lagging (const Eigen::VectorXd &x) |
| Initialize lagged fields TODO: more than one step. | |
| virtual void | update_lagging (const Eigen::VectorXd &x, const int iter_num) |
| Update lagged fields. | |
| virtual int | max_lagging_iterations () const |
| Get the maximum number of lagging iteration allowable. | |
| virtual bool | uses_lagging () const |
| Does this form require lagging? | |
| virtual void | set_project_to_psd (bool val) |
| Set project to psd. | |
| bool | is_project_to_psd () const |
| Get if the form's second derivative is projected to psd. | |
| void | enable () |
| Enable the form. | |
| void | disable () |
| Disable the form. | |
| void | set_enabled (const bool enabled) |
| Set if the form is enabled. | |
| bool | enabled () const |
| Determine if the form is enabled. | |
| virtual double | weight () const |
| Get the form's multiplicative constant weight. | |
| void | set_weight (const double weight) |
| Set the form's multiplicative constant weight. | |
| virtual bool | is_step_collision_free (const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const |
| Checks if the step is collision free. | |
| void | set_output_dir (const std::string &output_dir) |
| virtual void | set_scale (const double scale) |
| sets the scale for the form | |
Protected Member Functions | |
| double | value_unweighted (const Eigen::VectorXd &x) const override |
| Compute the value of the form. | |
| void | first_derivative_unweighted (const Eigen::VectorXd &x, Eigen::VectorXd &residual) const override |
| Compute the first derivative of the value wrt x. | |
| void | second_derivative_unweighted (const Eigen::VectorXd &x, StiffnessMatrix &jacobian) const override |
| Compute the second derivative of the value wrt x. | |
Protected Member Functions inherited from polyfem::solver::Form | |
| std::string | resolve_output_path (const std::string &path) const |
| virtual Eigen::VectorXd | value_per_element_unweighted (const Eigen::VectorXd &x) const |
| Compute the value of the form multiplied per element. | |
Private Types | |
| using | SpaceValues = std::array< assembler::ElementAssemblyValues, 3 > |
| using | LocalCoefficients = std::array< Eigen::VectorXd, 3 > |
Private Member Functions | |
| void | compute_element_values (int element, SpaceValues &vals, QuadratureVector &da) const |
| Eigen::VectorXd | gather (const Eigen::VectorXd &x, const assembler::ElementAssemblyValues &vals, int components, int global_offset) const |
| void | scatter_local_residual (const SpaceValues &vals, const Eigen::VectorXd &local, Eigen::VectorXd &global) const |
| void | scatter_local_block (const SpaceValues &vals, int row_space, int col_space, const Eigen::MatrixXd &local, std::vector< Eigen::Triplet< double > > &entries) const |
| assembler::NavierStokesFSIAssemblerData | make_data (const SpaceValues &vals, const LocalCoefficients &x, const LocalCoefficients &x_prev, const QuadratureVector &da, const Eigen::VectorXd &velocity_tilde, const Eigen::VectorXd &mesh_velocity) const |
| bool | has_valid_ale_mapping (const Eigen::VectorXd &x) const |
Private Attributes | |
| const int | total_size_ |
| const int | dim_ |
| const std::array< int, 3 > | n_bases_ |
| const std::array< int, 3 > | components_ |
| const std::array< int, 3 > | global_offsets_ |
| const std::array< int, 3 > | global_sizes_ |
| const std::array< std::reference_wrapper< const std::vector< basis::ElementBases > >, 3 > | bases_ |
| const std::vector< basis::ElementBases > & | geom_bases_ |
| const std::array< std::reference_wrapper< const assembler::AssemblyValsCache >, 3 > | caches_ |
| const std::vector< std::shared_ptr< assembler::MultiSpacesNLAssembler > > | assemblers_ |
| const time_integrator::ImplicitTimeIntegrator * | velocity_time_integrator_ |
| const time_integrator::ImplicitTimeIntegrator * | mesh_displacement_time_integrator_ |
| double | t_ |
| const double | dt_ |
| const bool | is_volume_ |
| const BodyForceEvaluator | body_force_evaluator_ |
| VelocityTildeUpdater | velocity_tilde_updater_ |
| Eigen::VectorXd | x_prev_ |
Additional Inherited Members | |
Protected Attributes inherited from polyfem::solver::Form | |
| bool | project_to_psd_ = false |
| If true, the form's second derivative is projected to be positive semidefinite. | |
| double | weight_ = 1 |
| weight of the form (e.g., AL penalty weight or Δt²) | |
| bool | enabled_ = true |
| If true, the form is enabled. | |
| std::string | output_dir_ |
Global residual form for ALE Navier–Stokes on velocity, pressure, and mesh-displacement spaces.
This form owns all element gather/scatter; MultiSpacesNLAssembler implementations remain strictly local.
Definition at line 67 of file NavierStokesFSIForm.hpp.
| using polyfem::solver::NavierStokesFSIForm::BodyForceEvaluator = assembler::NavierStokesFSIAssemblerData::BodyForceEvaluator |
Definition at line 70 of file NavierStokesFSIForm.hpp.
|
private |
Definition at line 112 of file NavierStokesFSIForm.hpp.
|
private |
Definition at line 111 of file NavierStokesFSIForm.hpp.
| using polyfem::solver::NavierStokesFSIForm::VelocityTildeUpdater = std::function<void( double time, const Eigen::VectorXd ¤t_velocity, Eigen::VectorXd &velocity_tilde)> |
Definition at line 71 of file NavierStokesFSIForm.hpp.
| polyfem::solver::NavierStokesFSIForm::NavierStokesFSIForm | ( | int | total_size, |
| int | n_velocity_bases, | ||
| int | n_pressure_bases, | ||
| int | n_mesh_displacement_bases, | ||
| const std::vector< basis::ElementBases > & | velocity_bases, | ||
| const std::vector< basis::ElementBases > & | pressure_bases, | ||
| const std::vector< basis::ElementBases > & | mesh_displacement_bases, | ||
| const std::vector< basis::ElementBases > & | geom_bases, | ||
| const assembler::AssemblyValsCache & | velocity_cache, | ||
| const assembler::AssemblyValsCache & | pressure_cache, | ||
| const assembler::AssemblyValsCache & | mesh_displacement_cache, | ||
| std::vector< std::shared_ptr< assembler::MultiSpacesNLAssembler > > | assemblers, | ||
| const time_integrator::ImplicitTimeIntegrator * | velocity_time_integrator, | ||
| const time_integrator::ImplicitTimeIntegrator * | mesh_displacement_time_integrator, | ||
| double | t, | ||
| double | dt, | ||
| bool | is_volume, | ||
| BodyForceEvaluator | body_force_evaluator = {} |
||
| ) |
Definition at line 201 of file NavierStokesFSIForm.cpp.
|
private |
Definition at line 246 of file NavierStokesFSIForm.cpp.
References bases_, caches_, da, geom_bases_, is_volume_, quadrature, and vals.
Referenced by first_derivative_unweighted(), has_valid_ale_mapping(), and second_derivative_unweighted().
|
overrideprotectedvirtual |
Compute the first derivative of the value wrt x.
| [in] | x | Current solution |
| [out] | gradv | Output gradient of the value wrt x |
Implements polyfem::solver::Form.
Definition at line 345 of file NavierStokesFSIForm.cpp.
References assemblers_, components_, compute_element_values(), polyfem::time_integrator::ImplicitTimeIntegrator::compute_velocity(), da, dim_, gather(), geom_bases_, global_offsets_, global_sizes_, make_data(), mesh_displacement_ndof(), mesh_displacement_time_integrator_, scatter_local_residual(), t_, total_size_, vals, velocity_ndof(), velocity_tilde_updater_, velocity_time_integrator_, x, x_prev_, and polyfem::time_integrator::ImplicitTimeIntegrator::x_tilde().
Referenced by value_unweighted().
|
private |
Definition at line 268 of file NavierStokesFSIForm.cpp.
Referenced by first_derivative_unweighted(), has_valid_ale_mapping(), and second_derivative_unweighted().
|
private |
Definition at line 447 of file NavierStokesFSIForm.cpp.
References compute_element_values(), da, dim_, polyfem::F, gather(), geom_bases_, global_offsets_, vals, and x.
Referenced by is_step_valid().
|
overridevirtual |
Determine if a step from solution x0 to solution x1 is allowed.
| x0 | Current solution |
| x1 | Proposed next solution |
Reimplemented from polyfem::solver::Form.
Definition at line 471 of file NavierStokesFSIForm.cpp.
References has_valid_ale_mapping().
|
private |
Definition at line 282 of file NavierStokesFSIForm.cpp.
References polyfem::time_integrator::ImplicitTimeIntegrator::acceleration_scaling(), body_force_evaluator_, da, dt_, polyfem::time_integrator::ImplicitTimeIntegrator::dv_dx(), mesh_displacement_time_integrator_, polyfem::solver::Form::project_to_psd_, t_, vals, velocity_time_integrator_, and x.
Referenced by first_derivative_unweighted(), and second_derivative_unweighted().
|
inline |
Definition at line 103 of file NavierStokesFSIForm.hpp.
References global_sizes_.
Referenced by first_derivative_unweighted(), and second_derivative_unweighted().
|
inlineoverridevirtual |
Implements polyfem::solver::Form.
Definition at line 96 of file NavierStokesFSIForm.hpp.
|
inline |
Definition at line 102 of file NavierStokesFSIForm.hpp.
References global_sizes_.
|
private |
Definition at line 317 of file NavierStokesFSIForm.cpp.
References components_, entries, global_offsets_, vals, and polyfem::solver::Form::value().
Referenced by second_derivative_unweighted().
|
private |
Definition at line 303 of file NavierStokesFSIForm.cpp.
References components_, global_offsets_, and vals.
Referenced by first_derivative_unweighted().
|
overrideprotectedvirtual |
Compute the second derivative of the value wrt x.
| [in] | x | Current solution |
| [out] | hessian | Output Hessian of the value wrt x |
Implements polyfem::solver::Form.
Definition at line 392 of file NavierStokesFSIForm.cpp.
References assemblers_, components_, compute_element_values(), polyfem::time_integrator::ImplicitTimeIntegrator::compute_velocity(), da, dim_, entries, gather(), geom_bases_, global_offsets_, global_sizes_, make_data(), mesh_displacement_ndof(), mesh_displacement_time_integrator_, scatter_local_block(), t_, total_size_, vals, velocity_ndof(), velocity_tilde_updater_, velocity_time_integrator_, x, x_prev_, and polyfem::time_integrator::ImplicitTimeIntegrator::x_tilde().
|
inline |
Definition at line 98 of file NavierStokesFSIForm.hpp.
References velocity_tilde_updater_.
|
overridevirtual |
Update time-dependent fields.
| t | Current time |
| x | Current solution at time t |
Reimplemented from polyfem::solver::Form.
Definition at line 440 of file NavierStokesFSIForm.cpp.
References t_, total_size_, x, and x_prev_.
|
overrideprotectedvirtual |
Compute the value of the form.
| x | Current solution |
Implements polyfem::solver::Form.
Definition at line 385 of file NavierStokesFSIForm.cpp.
References first_derivative_unweighted(), and x.
|
inline |
Definition at line 101 of file NavierStokesFSIForm.hpp.
References global_sizes_.
Referenced by first_derivative_unweighted(), and second_derivative_unweighted().
|
private |
Definition at line 141 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), and second_derivative_unweighted().
|
private |
Definition at line 138 of file NavierStokesFSIForm.hpp.
Referenced by compute_element_values().
|
private |
Definition at line 147 of file NavierStokesFSIForm.hpp.
Referenced by make_data().
|
private |
Definition at line 140 of file NavierStokesFSIForm.hpp.
Referenced by compute_element_values().
|
private |
Definition at line 135 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), scatter_local_block(), scatter_local_residual(), and second_derivative_unweighted().
|
private |
Definition at line 133 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), has_valid_ale_mapping(), and second_derivative_unweighted().
|
private |
Definition at line 145 of file NavierStokesFSIForm.hpp.
Referenced by make_data().
|
private |
Definition at line 139 of file NavierStokesFSIForm.hpp.
Referenced by compute_element_values(), first_derivative_unweighted(), has_valid_ale_mapping(), and second_derivative_unweighted().
|
private |
Definition at line 136 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), has_valid_ale_mapping(), scatter_local_block(), scatter_local_residual(), and second_derivative_unweighted().
|
private |
Definition at line 137 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), mesh_displacement_ndof(), pressure_ndof(), second_derivative_unweighted(), and velocity_ndof().
|
private |
Definition at line 146 of file NavierStokesFSIForm.hpp.
Referenced by compute_element_values().
|
private |
Definition at line 143 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), make_data(), and second_derivative_unweighted().
|
private |
Definition at line 134 of file NavierStokesFSIForm.hpp.
|
private |
Definition at line 144 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), make_data(), second_derivative_unweighted(), and update_quantities().
|
private |
Definition at line 132 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), second_derivative_unweighted(), and update_quantities().
|
private |
Definition at line 148 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), second_derivative_unweighted(), and set_velocity_tilde_updater().
|
private |
Definition at line 142 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), make_data(), and second_derivative_unweighted().
|
private |
Definition at line 149 of file NavierStokesFSIForm.hpp.
Referenced by first_derivative_unweighted(), second_derivative_unweighted(), and update_quantities().