PolyFEM
Loading...
Searching...
No Matches
FluidVarForm.hpp
Go to the documentation of this file.
1#pragma once
2
4
7
8namespace polysolve::linear
9{
10 class Solver;
11}
12
13namespace polyfem::solver
14{
15 class AugmentedLagrangianForm;
16 class AveragePressureForm;
17 class BodyForm;
18 class InertiaForm;
19 class Form;
20 class MixedLinearForm;
21 class NavierStokesForm;
22 class NLProblem;
23 class StackedForm;
24} // namespace polyfem::solver
25
26namespace polyfem::varform
27{
28 class FluidVarForm : public VarForm
29 {
31
32 public:
33 void init(const std::string &formulation, const Units &units, const json &args, const std::string &out_path) override;
34 void save_json(const Eigen::MatrixXd &solution, std::ostream &out) const override;
35 void export_data(const Eigen::MatrixXd &solution) const override;
36 io::OutputSpace output_space() const override;
37 io::OutStatsData compute_errors(const Eigen::MatrixXd &solution) override;
38
39 std::vector<io::OutputField> output_fields(
40 const io::OutputSample &sample,
41 const Eigen::MatrixXd &solution,
42 const io::OutputFieldOptions &options) const override;
43
44 protected:
45 void reset() override;
46 void load_mesh(const mesh::Mesh &mesh, const json &args) override;
47 void build_basis(mesh::Mesh &mesh, const bool iso_parametric, const json &args) override;
48 void assemble_rhs(const mesh::Mesh &mesh) override;
49 void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override;
50
51 int primary_ndof() const;
52 int pressure_block_size() const;
53 int stacked_ndof() const;
54
55 void prepare_initial_solution(Eigen::MatrixXd &sol) const;
56 void split_solution(const Eigen::MatrixXd &stacked, Eigen::MatrixXd &primary, Eigen::MatrixXd &pressure) const;
57 void build_stiffness_mat(StiffnessMatrix &stiffness);
59 const std::unique_ptr<polysolve::linear::Solver> &solver,
61 Eigen::VectorXd &b,
62 const bool compute_spectrum,
63 Eigen::MatrixXd &sol);
64
65 void build_rhs_assembler() override;
66
71
74
79
80 std::shared_ptr<assembler::RhsAssembler> rhs_assembler_;
81
84
85 double avg_mass_ = 0;
86 Eigen::MatrixXd rhs_;
87
88 std::shared_ptr<assembler::Assembler> primary_assembler_ = nullptr;
89 std::shared_ptr<assembler::Mass> mass_assembler_ = nullptr;
90 std::shared_ptr<assembler::HRZMass> pure_mass_assembler_ = nullptr;
91 std::shared_ptr<assembler::MixedAssembler> mixed_assembler_ = nullptr;
92 std::shared_ptr<assembler::Assembler> pressure_assembler_ = nullptr;
93 bool use_avg_pressure = true;
94 double t0 = 0;
95 int time_steps = 0;
96 double dt = 0;
97 std::shared_ptr<time_integrator::ImplicitTimeIntegrator> time_integrator;
98 };
99
101 {
102 public:
103 std::string name() const override { return "Stokes"; }
104
105 private:
106 void solve_problem(Eigen::MatrixXd &sol) override;
107 void solve_static_linear(Eigen::MatrixXd &sol);
108 void solve_transient_linear(Eigen::MatrixXd &sol);
109 };
110
112 {
113 public:
114 std::string name() const override { return "NavierStokes"; }
115
116 private:
117 void solve_problem(Eigen::MatrixXd &sol) override;
118 void build_forms(Eigen::MatrixXd &sol, double t);
119 void solve_nonlinear_step(int step, Eigen::MatrixXd &sol);
121
122 Eigen::MatrixXd velocity_rhs_;
123 std::vector<std::shared_ptr<solver::Form>> forms_;
124 std::vector<std::shared_ptr<solver::AugmentedLagrangianForm>> al_forms_;
125 std::shared_ptr<solver::NLProblem> nl_problem_;
126 std::shared_ptr<solver::StackedForm> stacked_form_;
127 std::shared_ptr<solver::NavierStokesForm> navier_stokes_form_;
128 std::shared_ptr<solver::MixedLinearForm> mixed_form_;
129 std::shared_ptr<solver::AveragePressureForm> average_pressure_form_;
130 std::shared_ptr<solver::BodyForm> body_form_;
131 std::shared_ptr<solver::InertiaForm> inertia_form_;
132 };
133} // namespace polyfem::varform
Caches basis evaluation and geometric mapping at every element.
all stats from polyfem
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
Definition Mesh.hpp:41
A finite-element space for one scalar- or vector-valued field.
Definition FESpace.hpp:59
void assemble_rhs(const mesh::Mesh &mesh) override
assembler::AssemblyValsCache pressure_ass_vals_cache_
void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override
void build_basis(mesh::Mesh &mesh, const bool iso_parametric, const json &args) override
std::shared_ptr< assembler::HRZMass > pure_mass_assembler_
io::OutputSpace output_space() const override
Get the output space of the variational formulation, for output purposes.
VarFormBoundaryState pressure_boundary_
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::shared_ptr< time_integrator::ImplicitTimeIntegrator > time_integrator
assembler::AssemblyValsCache ass_vals_cache_
void split_solution(const Eigen::MatrixXd &stacked, Eigen::MatrixXd &primary, Eigen::MatrixXd &pressure) const
std::shared_ptr< assembler::Assembler > primary_assembler_
assembler::AssemblyValsCache pure_mass_ass_vals_cache_
std::shared_ptr< assembler::RhsAssembler > rhs_assembler_
void export_data(const Eigen::MatrixXd &solution) const override
void prepare_initial_solution(Eigen::MatrixXd &sol) const
VarFormBoundaryState boundary_
void save_json(const Eigen::MatrixXd &solution, std::ostream &out) const override
Save the solution to a JSON file, for output purposes.
io::OutStatsData compute_errors(const Eigen::MatrixXd &solution) override
Get the error statistics of the variational formulation, for output purposes.
std::shared_ptr< assembler::Mass > mass_assembler_
friend class polyfem::test::VarFormTestAccess
void solve_linear_system(const std::unique_ptr< polysolve::linear::Solver > &solver, StiffnessMatrix &A, Eigen::VectorXd &b, const bool compute_spectrum, Eigen::MatrixXd &sol)
void build_stiffness_mat(StiffnessMatrix &stiffness)
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::shared_ptr< assembler::Assembler > pressure_assembler_
assembler::AssemblyValsCache mass_ass_vals_cache_
std::shared_ptr< assembler::MixedAssembler > mixed_assembler_
void load_mesh(const mesh::Mesh &mesh, const json &args) override
std::shared_ptr< solver::BodyForm > body_form_
void build_forms(Eigen::MatrixXd &sol, double t)
std::shared_ptr< solver::NavierStokesForm > navier_stokes_form_
std::string name() const override
Get the name of the variational formulation.
std::shared_ptr< solver::MixedLinearForm > mixed_form_
std::shared_ptr< solver::AveragePressureForm > average_pressure_form_
std::shared_ptr< solver::InertiaForm > inertia_form_
std::vector< std::shared_ptr< solver::Form > > forms_
void solve_problem(Eigen::MatrixXd &sol) override
void solve_nonlinear_step(int step, Eigen::MatrixXd &sol)
std::shared_ptr< solver::StackedForm > stacked_form_
std::vector< std::shared_ptr< solver::AugmentedLagrangianForm > > al_forms_
std::shared_ptr< solver::NLProblem > nl_problem_
void solve_transient_linear(Eigen::MatrixXd &sol)
void solve_problem(Eigen::MatrixXd &sol) override
void solve_static_linear(Eigen::MatrixXd &sol)
std::string name() const override
Get the name of the variational formulation.
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