PolyFEM
Loading...
Searching...
No Matches
ScalarVarForm.hpp
Go to the documentation of this file.
1#pragma once
2
4
7
8#include <memory>
9
10namespace polysolve::linear
11{
12 class Solver;
13}
14
15namespace polyfem::varform
16{
17 class ScalarVarForm : public VarForm
18 {
20
21 public:
22 std::string name() const override { return "Scalar"; }
23
24 void init(const std::string &formulation, const Units &units, const json &args, const std::string &out_path) override;
25 void save_json(const Eigen::MatrixXd &solution, std::ostream &out) const override;
26 void export_data(const Eigen::MatrixXd &solution) const override;
27 io::OutputSpace output_space() const override;
28 io::OutStatsData compute_errors(const Eigen::MatrixXd &solution) override;
29
30 std::vector<io::OutputField> output_fields(
31 const io::OutputSample &sample,
32 const Eigen::MatrixXd &solution,
33 const io::OutputFieldOptions &options) const override;
34
35 protected:
36 void reset() override;
37 void load_mesh(const mesh::Mesh &mesh, const json &args) override;
38 void build_basis(mesh::Mesh &mesh, const bool iso_parametric, const json &args) override;
39 void assemble_rhs(const mesh::Mesh &mesh) override;
40 void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override;
41
42 protected:
43 void build_rhs_assembler() override;
44
50 std::shared_ptr<assembler::RhsAssembler> rhs_assembler_;
53 double avg_mass_ = 0;
54 Eigen::MatrixXd rhs_;
55
56 std::shared_ptr<assembler::Assembler> primary_assembler_ = nullptr;
57 std::shared_ptr<assembler::Mass> mass_assembler_ = nullptr;
58 std::shared_ptr<assembler::HRZMass> pure_mass_assembler_ = nullptr;
60
61 double t0 = 0;
62 int time_steps = 0;
63 double dt = 0;
64
65 void prepare_initial_solution(Eigen::MatrixXd &solution) const;
66
67 void build_stiffness_mat(StiffnessMatrix &stiffness);
68
69 void solve_problem(
70 Eigen::MatrixXd &sol,
71 const InitialConditionOverride *initial_condition_override,
72 const ForwardStepCallback &post_step) override;
74 const std::unique_ptr<polysolve::linear::Solver> &solver,
76 Eigen::VectorXd &b,
77 const bool compute_spectrum,
78 Eigen::MatrixXd &sol);
80 const std::unique_ptr<polysolve::linear::Solver> &solver,
82 Eigen::VectorXd &b,
83 const bool compute_spectrum,
84 const QuadratureOrders &boundary_samples,
85 const double time,
86 Eigen::MatrixXd &sol);
87 void solve_static(Eigen::MatrixXd &sol, const ForwardStepCallback &post_step);
88 void solve_transient(Eigen::MatrixXd &sol, const ForwardStepCallback &post_step);
89
90 std::shared_ptr<time_integrator::ImplicitTimeIntegrator> time_integrator;
91 };
92} // 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:49
class to store time stepping data
Definition SolveData.hpp:55
A finite-element space for one scalar- or vector-valued field.
Definition FESpace.hpp:59
void save_json(const Eigen::MatrixXd &solution, std::ostream &out) const override
Save the solution to a JSON file, for output purposes.
std::shared_ptr< assembler::HRZMass > pure_mass_assembler_
std::shared_ptr< time_integrator::ImplicitTimeIntegrator > time_integrator
std::shared_ptr< assembler::Mass > mass_assembler_
void solve_problem(Eigen::MatrixXd &sol, const InitialConditionOverride *initial_condition_override, const ForwardStepCallback &post_step) override
io::OutStatsData compute_errors(const Eigen::MatrixXd &solution) override
Get the error statistics of the variational formulation, for output purposes.
std::string name() const override
Get the name of the variational formulation.
void build_basis(mesh::Mesh &mesh, const bool iso_parametric, const json &args) override
void solve_linear_system_with_constraints(const std::unique_ptr< polysolve::linear::Solver > &solver, StiffnessMatrix &A, Eigen::VectorXd &b, const bool compute_spectrum, const QuadratureOrders &boundary_samples, const double time, Eigen::MatrixXd &sol)
assembler::AssemblyValsCache pure_mass_ass_vals_cache_
assembler::AssemblyValsCache mass_ass_vals_cache_
assembler::AssemblyValsCache ass_vals_cache_
void export_data(const Eigen::MatrixXd &solution) const override
void assemble_rhs(const mesh::Mesh &mesh) override
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.
void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override
void build_stiffness_mat(StiffnessMatrix &stiffness)
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 prepare_initial_solution(Eigen::MatrixXd &solution) const
std::shared_ptr< assembler::Assembler > primary_assembler_
std::shared_ptr< assembler::RhsAssembler > rhs_assembler_
void solve_static(Eigen::MatrixXd &sol, const ForwardStepCallback &post_step)
void solve_transient(Eigen::MatrixXd &sol, const ForwardStepCallback &post_step)
friend class polyfem::test::VarFormTestAccess
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.
void load_mesh(const mesh::Mesh &mesh, const json &args) override
io::OutputSpace output_space() const override
Get the output space of the variational formulation, for output purposes.
std::function< void(int step, const Eigen::MatrixXd &solution)> ForwardStepCallback
Definition VarForm.hpp:49
std::array< int, 2 > QuadratureOrders
Definition Types.hpp:19
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