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:
35 const Eigen::MatrixXd &, const io::OutGeometryData::ExportOptions &,
36 const io::OutputSpace &, double, double) const override { return {}; }
37
38 void reset() override;
39 void load_mesh(const mesh::Mesh &mesh, const json &args) override;
40 void build_basis(mesh::Mesh &mesh, bool iso_parametric, const json &args) override;
41 void assemble_rhs(const mesh::Mesh &mesh) override;
42 void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override;
43 void build_rhs_assembler() override;
44 void solve_problem(
45 Eigen::MatrixXd &sol,
46 const InitialConditionOverride *initial_condition_override,
47 const ForwardStepCallback &post_step) override;
48
49 private:
50 int mesh_displacement_ndof() const;
51 int solid_displacement_ndof() const;
54 int total_ndof() const;
55 int pressure_offset() const { return primary_ndof(); }
63 json time_integrator_args(int fe_space_id) const;
66 void prepare_fsi_initial_solution(Eigen::MatrixXd &sol) const;
67 void build_forms(Eigen::MatrixXd &sol, double t);
68 void solve_nonlinear_step(int step, Eigen::MatrixXd &sol);
70 void save_fsi_timestep(double time, int step, const Eigen::MatrixXd &solution) const;
71
76 bool has_solid_ = false;
77 std::string mesh_elastic_formulation_ = "NeoHookean";
78 std::string solid_elastic_formulation_ = "NeoHookean";
80 std::shared_ptr<NonlinearElasticTransientVarForm> solid_varform_;
81 std::vector<std::pair<mesh::Navigation::Index, mesh::Navigation::Index>> interface_2d_;
82 std::vector<std::pair<mesh::Navigation3D::Index, mesh::Navigation3D::Index>> interface_3d_;
85 std::shared_ptr<assembler::Problem> mesh_displacement_problem_;
89 std::shared_ptr<assembler::Assembler> mesh_elastic_assembler_;
90 std::shared_ptr<assembler::Mass> mesh_mass_assembler_;
91 std::shared_ptr<assembler::HRZMass> mesh_pure_mass_assembler_;
92 std::shared_ptr<assembler::RhsAssembler> mesh_rhs_assembler_;
93 Eigen::MatrixXd mesh_rhs_;
94 Eigen::MatrixXd fluid_zero_rhs_;
100
101 std::vector<std::shared_ptr<assembler::MultiSpacesNLAssembler>> ale_assemblers_;
102 std::shared_ptr<time_integrator::ImplicitTimeIntegrator> mesh_displacement_time_integrator_;
103 std::vector<std::shared_ptr<solver::Form>> fsi_forms_;
104 std::vector<std::shared_ptr<solver::AugmentedLagrangianForm>> fsi_al_forms_;
105 std::shared_ptr<solver::NLProblem> fsi_problem_;
106 std::shared_ptr<solver::NavierStokesFSIForm> ale_form_;
107 std::shared_ptr<solver::FSIInterfaceForm> interface_form_;
108 std::shared_ptr<solver::StackedForm> auxiliary_form_;
109 std::shared_ptr<solver::ElasticForm> mesh_elastic_form_;
110 std::shared_ptr<solver::BodyForm> fluid_neumann_form_;
111 std::shared_ptr<solver::BodyForm> mesh_body_form_;
112 std::shared_ptr<solver::NavierStokesFSIAveragePressureForm> average_pressure_form_;
113 };
114} // 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:77
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
io::OutputFieldFunction snapshot_output_fields(const Eigen::MatrixXd &, const io::OutGeometryData::ExportOptions &, const io::OutputSpace &, double, double) const override
Capture mutable timestep data for deferred field evaluation.
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< std::vector< OutputField >(const OutputSample &)> OutputFieldFunction
std::function< void(int step, const Eigen::MatrixXd &solution)> ForwardStepCallback
Definition VarForm.hpp:59
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:156