PolyFEM
Loading...
Searching...
No Matches
ScalarVarForm.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <memory>
6
7namespace polysolve::linear
8{
9 class Solver;
10}
11
12namespace polyfem::varform
13{
14 class ScalarVarForm : public VarForm
15 {
17
18 public:
19 std::string name() const override { return "Scalar"; }
20
21 void init(const std::string &formulation, const Units &units, const json &args, const std::string &out_path) override;
22 void save_json(const Eigen::MatrixXd &solution, std::ostream &out) const override;
23 void export_data(const Eigen::MatrixXd &solution) const override;
24 io::OutputSpace output_space() const override;
25 io::OutStatsData compute_errors(const Eigen::MatrixXd &solution) override;
26
27 std::vector<io::OutputField> output_fields(
28 const io::OutputSample &sample,
29 const Eigen::MatrixXd &solution,
30 const io::OutputFieldOptions &options) const override;
31
32 protected:
33 void reset() override;
34 void load_mesh(const mesh::Mesh &mesh, const json &args) override;
35 void build_basis(mesh::Mesh &mesh, const bool iso_parametric, const json &args) override;
36 void assemble_rhs(const mesh::Mesh &mesh) override;
37 void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override;
38
39 private:
40 void build_rhs_assembler() override;
41
47 std::shared_ptr<assembler::RhsAssembler> rhs_assembler_;
50 double avg_mass_ = 0;
51 Eigen::MatrixXd rhs_;
52
53 std::shared_ptr<assembler::Assembler> primary_assembler_ = nullptr;
54 std::shared_ptr<assembler::Mass> mass_assembler_ = nullptr;
55 std::shared_ptr<assembler::HRZMass> pure_mass_assembler_ = nullptr;
56
57 double t0 = 0;
58 int time_steps = 0;
59 double dt = 0;
60
61 void prepare_initial_solution(Eigen::MatrixXd &solution) const;
62
63 void build_stiffness_mat(StiffnessMatrix &stiffness);
64
65 void solve_problem(Eigen::MatrixXd &sol) override;
67 const std::unique_ptr<polysolve::linear::Solver> &solver,
69 Eigen::VectorXd &b,
70 const bool compute_spectrum,
71 Eigen::MatrixXd &sol);
72 void solve_static(Eigen::MatrixXd &sol);
73 void solve_transient(Eigen::MatrixXd &sol);
74
75 std::shared_ptr<time_integrator::ImplicitTimeIntegrator> time_integrator;
76 };
77} // 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 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_
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
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 solve_problem(Eigen::MatrixXd &sol) override
void solve_static(Eigen::MatrixXd &sol)
void assemble_mass_mat(const mesh::Mesh &mesh, const json &args) override
void solve_transient(Eigen::MatrixXd &sol)
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_
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.
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