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::varform
14{
15 class FluidVarForm : public VarForm
16 {
18
19 public:
20 void init(const std::string &formulation, const Units &units, const json &args, const std::string &out_path) override;
21 void save_json(const Eigen::MatrixXd &solution, std::ostream &out) const override;
22 void export_data(const Eigen::MatrixXd &solution) const override;
23 io::OutputSpace output_space() const override;
24 io::OutStatsData compute_errors(const Eigen::MatrixXd &solution) override;
25
26 std::vector<io::OutputField> output_fields(
27 const io::OutputSample &sample,
28 const Eigen::MatrixXd &solution,
29 const io::OutputFieldOptions &options) const override;
30
31 protected:
32 void reset() override;
33 void load_mesh(const mesh::Mesh &mesh, const json &args) override;
34 void build_basis(mesh::Mesh &mesh, const bool iso_parametric, const json &args) override;
35 void assemble_rhs(const mesh::Mesh &mesh) override;
36 void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override;
37
38 int primary_ndof() const;
39 int pressure_block_size() const;
40 int stacked_ndof() const;
41
42 void prepare_initial_solution(Eigen::MatrixXd &sol) const;
43 void split_solution(const Eigen::MatrixXd &stacked, Eigen::MatrixXd &primary, Eigen::MatrixXd &pressure) const;
44 void build_stiffness_mat(StiffnessMatrix &stiffness);
46 const std::unique_ptr<polysolve::linear::Solver> &solver,
48 Eigen::VectorXd &b,
49 const bool compute_spectrum,
50 Eigen::MatrixXd &sol);
51
52 void build_rhs_assembler() override;
53
56
59
64
65 std::shared_ptr<assembler::RhsAssembler> rhs_assembler_;
66
69
70 double avg_mass_ = 0;
71 Eigen::MatrixXd rhs_;
72
73 std::shared_ptr<assembler::Assembler> primary_assembler_ = nullptr;
74 std::shared_ptr<assembler::Mass> mass_assembler_ = nullptr;
75 std::shared_ptr<assembler::HRZMass> pure_mass_assembler_ = nullptr;
76 std::shared_ptr<assembler::MixedAssembler> mixed_assembler_ = nullptr;
77 std::shared_ptr<assembler::Assembler> pressure_assembler_ = nullptr;
78 bool use_avg_pressure = true;
79 double t0 = 0;
80 int time_steps = 0;
81 double dt = 0;
82 std::shared_ptr<time_integrator::ImplicitTimeIntegrator> time_integrator;
83 };
84
86 {
87 public:
88 std::string name() const override { return "Stokes"; }
89
90 private:
91 void solve_problem(Eigen::MatrixXd &sol) override;
92 void solve_static_linear(Eigen::MatrixXd &sol);
93 void solve_transient_linear(Eigen::MatrixXd &sol);
94 };
95
97 {
98 public:
99 std::string name() const override { return "NavierStokes"; }
100
101 private:
102 void solve_problem(Eigen::MatrixXd &sol) override;
103 void solve_static(Eigen::MatrixXd &sol);
104 void solve_transient(Eigen::MatrixXd &sol);
105 };
106} // 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
void solve_transient(Eigen::MatrixXd &sol)
void solve_static(Eigen::MatrixXd &sol)
std::string name() const override
Get the name of the variational formulation.
void solve_problem(Eigen::MatrixXd &sol) override
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