PolyFEM
Loading...
Searching...
No Matches
NavierStokesFSIVarForm.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace polyfem::solver
7{
8 class ElasticForm;
9 class FSIInterfaceForm;
10 class NavierStokesFSIAveragePressureForm;
11 class NavierStokesFSIForm;
12} // namespace polyfem::solver
13
14namespace polyfem::varform
15{
16 class NonlinearElasticTransientVarForm;
17
19 {
21
22 public:
23 using FluidVarForm::FluidVarForm;
24 std::string name() const override { return "NavierStokesFSI"; }
25 void init(const std::string &formulation, const Units &units, const json &args, const std::string &out_path) override;
26 void serialize_checkpoint(io::CheckpointWriter &writer, const Eigen::MatrixXd &solution, const io::CheckpointMetadata &metadata) const override;
27 void deserialize_checkpoint(const io::CheckpointReader &reader, Eigen::MatrixXd &solution) override;
28 std::vector<io::OutputField> output_fields(
29 const io::OutputSample &sample,
30 const Eigen::MatrixXd &solution,
31 const io::OutputFieldOptions &options) const override;
32
33 protected:
34 void reset() override;
35 void load_mesh(const mesh::Mesh &mesh, const json &args) override;
36 void build_basis(mesh::Mesh &mesh, bool iso_parametric, const json &args) override;
37 void assemble_rhs(const mesh::Mesh &mesh) override;
38 void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override;
39 void build_rhs_assembler() override;
40 void solve_problem(
41 Eigen::MatrixXd &sol,
42 const InitialConditionOverride *initial_condition_override,
43 const ForwardStepCallback &post_step) override;
44
45 private:
46 int mesh_displacement_ndof() const;
47 int solid_displacement_ndof() const;
50 int total_ndof() const;
51 int pressure_offset() const { return primary_ndof(); }
59 json time_integrator_args(int fe_space_id) const;
62 void prepare_fsi_initial_solution(Eigen::MatrixXd &sol) const;
63 void build_forms(Eigen::MatrixXd &sol, double t);
64 void solve_nonlinear_step(int step, Eigen::MatrixXd &sol);
66 void save_fsi_timestep(double time, int step, const Eigen::MatrixXd &solution) const;
67
72 bool has_solid_ = false;
73 std::string mesh_elastic_formulation_ = "NeoHookean";
74 std::string solid_elastic_formulation_ = "NeoHookean";
76 std::shared_ptr<NonlinearElasticTransientVarForm> solid_varform_;
77 std::vector<std::pair<mesh::Navigation::Index, mesh::Navigation::Index>> interface_2d_;
78 std::vector<std::pair<mesh::Navigation3D::Index, mesh::Navigation3D::Index>> interface_3d_;
81 std::shared_ptr<assembler::Problem> mesh_displacement_problem_;
85 std::shared_ptr<assembler::Assembler> mesh_elastic_assembler_;
86 std::shared_ptr<assembler::Mass> mesh_mass_assembler_;
87 std::shared_ptr<assembler::HRZMass> mesh_pure_mass_assembler_;
88 std::shared_ptr<assembler::RhsAssembler> mesh_rhs_assembler_;
89 Eigen::MatrixXd mesh_rhs_;
90 Eigen::MatrixXd fluid_zero_rhs_;
96
97 std::vector<std::shared_ptr<assembler::MultiSpacesNLAssembler>> ale_assemblers_;
98 std::shared_ptr<time_integrator::ImplicitTimeIntegrator> mesh_displacement_time_integrator_;
99 std::vector<std::shared_ptr<solver::Form>> fsi_forms_;
100 std::vector<std::shared_ptr<solver::AugmentedLagrangianForm>> fsi_al_forms_;
101 std::shared_ptr<solver::NLProblem> fsi_problem_;
102 std::shared_ptr<solver::NavierStokesFSIForm> ale_form_;
103 std::shared_ptr<solver::FSIInterfaceForm> interface_form_;
104 std::shared_ptr<solver::StackedForm> auxiliary_form_;
105 std::shared_ptr<solver::ElasticForm> mesh_elastic_form_;
106 std::shared_ptr<solver::BodyForm> fluid_neumann_form_;
107 std::shared_ptr<solver::BodyForm> mesh_body_form_;
108 std::shared_ptr<solver::NavierStokesFSIAveragePressureForm> average_pressure_form_;
109 };
110} // namespace polyfem::varform
Caches basis evaluation and geometric mapping at every element.
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
Definition Mesh.hpp:50
A finite-element space for one scalar- or vector-valued field.
Definition FESpace.hpp:59
int n_bases
Number of globally indexed scalar basis functions in the space.
Definition FESpace.hpp:65
std::shared_ptr< NonlinearElasticTransientVarForm > solid_varform_
void prepare_fsi_initial_solution(Eigen::MatrixXd &sol) const
std::shared_ptr< time_integrator::ImplicitTimeIntegrator > mesh_displacement_time_integrator_
std::vector< io::OutputField > output_fields(const io::OutputSample &sample, const Eigen::MatrixXd &solution, const io::OutputFieldOptions &options) const override
Get the output fields of the variational formulation, for output purposes.
std::string name() const override
Get the name of the variational formulation.
std::shared_ptr< solver::NLProblem > fsi_problem_
std::shared_ptr< assembler::Assembler > mesh_elastic_assembler_
std::shared_ptr< assembler::Problem > mesh_displacement_problem_
std::shared_ptr< assembler::HRZMass > mesh_pure_mass_assembler_
std::vector< std::shared_ptr< solver::Form > > fsi_forms_
void serialize_checkpoint(io::CheckpointWriter &writer, const Eigen::MatrixXd &solution, const io::CheckpointMetadata &metadata) const override
std::vector< std::shared_ptr< assembler::MultiSpacesNLAssembler > > ale_assemblers_
void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override
void load_mesh(const mesh::Mesh &mesh, const json &args) override
std::shared_ptr< solver::NavierStokesFSIForm > ale_form_
std::shared_ptr< solver::FSIInterfaceForm > interface_form_
void solve_problem(Eigen::MatrixXd &sol, const InitialConditionOverride *initial_condition_override, const ForwardStepCallback &post_step) override
void build_forms(Eigen::MatrixXd &sol, double t)
std::shared_ptr< solver::BodyForm > mesh_body_form_
std::shared_ptr< assembler::RhsAssembler > mesh_rhs_assembler_
void save_fsi_timestep(double time, int step, const Eigen::MatrixXd &solution) const
std::shared_ptr< solver::ElasticForm > mesh_elastic_form_
std::vector< std::pair< mesh::Navigation::Index, mesh::Navigation::Index > > interface_2d_
std::vector< std::pair< mesh::Navigation3D::Index, mesh::Navigation3D::Index > > interface_3d_
void build_basis(mesh::Mesh &mesh, bool iso_parametric, const json &args) override
std::shared_ptr< solver::BodyForm > fluid_neumann_form_
void deserialize_checkpoint(const io::CheckpointReader &reader, Eigen::MatrixXd &solution) override
std::vector< std::shared_ptr< solver::AugmentedLagrangianForm > > fsi_al_forms_
assembler::AssemblyValsCache mesh_displacement_mass_ass_vals_cache_
void solve_nonlinear_step(int step, Eigen::MatrixXd &sol)
std::shared_ptr< assembler::Mass > mesh_mass_assembler_
std::shared_ptr< solver::StackedForm > auxiliary_form_
void assemble_rhs(const mesh::Mesh &mesh) override
assembler::AssemblyValsCache mesh_displacement_pure_mass_ass_vals_cache_
std::shared_ptr< solver::NavierStokesFSIAveragePressureForm > average_pressure_form_
assembler::AssemblyValsCache mesh_displacement_ass_vals_cache_
void init(const std::string &formulation, const Units &units, const json &args, const std::string &out_path) override
Initialize the variational formulation with the given parameters.
std::function< void(int step, const Eigen::MatrixXd &solution)> ForwardStepCallback
Definition VarForm.hpp:53
nlohmann::json json
Definition Common.hpp:9
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:24
Temporary compatibility wrapper for boundary data belonging to one FE space.
Definition FESpace.hpp:152