PolyFEM
Loading...
Searching...
No Matches
polyfem::varform::ElasticVarForm Class Reference

#include <ElasticVarForm.hpp>

Inheritance diagram for polyfem::varform::ElasticVarForm:
[legend]
Collaboration diagram for polyfem::varform::ElasticVarForm:
[legend]

Public Member Functions

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 save_json (const Eigen::MatrixXd &solution, std::ostream &out) const override
 Save the solution to a JSON file, for output purposes.
 
void export_data (const Eigen::MatrixXd &solution) const override
 
io::OutputSpace output_space () const override
 Get the output space of the variational formulation, for output purposes.
 
io::OutStatsData compute_errors (const Eigen::MatrixXd &solution) override
 Get the error statistics of the variational formulation, for output purposes.
 
- Public Member Functions inherited from polyfem::varform::VarForm
virtual ~VarForm ()=default
 
virtual std::string name () const =0
 Get the name of the variational formulation.
 
void set_args (const json &args)
 Reset the internal state of the variational formulation, e.g.
 
void set_mesh (std::unique_ptr< mesh::Mesh > mesh, const double loading_mesh_time=0)
 Set the mesh for the variational formulation.
 
void solve (Eigen::MatrixXd &sol)
 Solve the variational formulation and store the solution in the given matrix.
 
void set_time_callback (const std::function< void(int, int, double, double)> &callback)
 
int problem_dimension () const
 Get the problem dimension of the variational formulation, for output purposes.
 
virtual bool is_contact_enabled () const
 Check if contact is enabled for the variational formulation, for output purposes.
 
virtual std::vector< io::OutputFieldoutput_fields (const io::OutputSample &sample, const Eigen::MatrixXd &solution, const io::OutputFieldOptions &options) const =0
 Get the output fields of the variational formulation, for output purposes.
 
const io::OutRuntimeDataoutput_timings () const
 Get the runtime timings of the variational formulation, for output purposes.
 
void save_json (const Eigen::MatrixXd &solution) const
 Save the solution to a JSON file, for output purposes.
 

Protected Member Functions

void reset () override
 
void load_mesh (const mesh::Mesh &mesh, const json &args) override
 
void build_basis (mesh::Mesh &mesh, const bool iso_parametric, const json &args) override
 
void assemble_rhs (const mesh::Mesh &mesh) override
 
void assemble_mass_mat (const mesh::Mesh &mesh, const json &args) override
 
void build_rhs_assembler () override
 
void initial_velocity (Eigen::MatrixXd &velocity) const
 
void initial_acceleration (Eigen::MatrixXd &acceleration) const
 
void initial_elastic_solution (Eigen::MatrixXd &solution) const
 
QuadratureOrders elastic_boundary_samples () const
 
std::vector< int > elastic_primitive_to_node () const
 
std::vector< int > elastic_node_to_primitive () const
 
void build_mesh_matrices (Eigen::MatrixXd &V, Eigen::MatrixXi &F) const
 
void save_elastic_step_state (const double t0, const double dt, const int t, const time_integrator::ImplicitTimeIntegrator *time_integrator) const
 
std::vector< io::OutputFieldelastic_output_fields (const io::OutputSample &sample, const Eigen::MatrixXd &solution, const io::OutputFieldOptions &options, const mesh::Obstacle *obstacle, const time_integrator::ImplicitTimeIntegrator *time_integrator, const std::vector< std::pair< std::string, std::shared_ptr< solver::Form > > > &named_forms, const solver::Form *elastic_form, const solver::ContactForm *contact_form=nullptr) const
 
void append_primary_output_fields (std::vector< io::OutputField > &fields, const io::OutputSample &sample, const Eigen::MatrixXd &solution, const io::OutputFieldOptions &options, const mesh::Obstacle *obstacle=nullptr) const
 
Eigen::MatrixXd displaced_output_normals (const io::OutputSample &sample, const Eigen::MatrixXd &solution) const
 
virtual int n_obstacle_vertices () const
 
- Protected Member Functions inherited from polyfem::varform::VarForm
std::string resolve_output_path (const std::string &path) const
 
std::string resolve_input_path (const std::string &path, const bool only_if_exists=false) const
 
void set_materials (assembler::Assembler &assembler, const int size) const
 
void assign_discr_orders (const json &discr_order, const mesh::Mesh &mesh, Eigen::VectorXi &disc_orders)
 
virtual void solve_problem (Eigen::MatrixXd &sol)=0
 
void prepare ()
 
QuadratureOrders n_boundary_samples (const int discr_order, const int gdiscr_order) const
 
void build_fe_space (mesh::Mesh &mesh, const bool iso_parametric, const Eigen::VectorXi &disc_orders, const std::string &basis_type, const std::string &poly_basis_type, const assembler::Assembler &space_assembler, const int value_dim, const int quadrature_order, const int mass_quadrature_order, const bool use_corner_quadrature, const int n_harmonic_samples, const int integral_constraints, FESpace &space, VarFormBoundaryState &boundary, std::shared_ptr< GeometryMapping > geometry=nullptr)
 
std::shared_ptr< time_integrator::BDFmake_bdf_time_integrator () const
 
void save_step_state (const double t0, const double dt, const int t, const time_integrator::ImplicitTimeIntegrator *time_integrator, const bool rest_mesh_written=false) const
 
void ensure_output_sampler () const
 
void save_restart_json (const double t0, const double dt, const int t, const bool rest_mesh_written) const
 
void save_timestep (const double time, const int t, const double t0, const double dt, const Eigen::MatrixXd &solution) const
 
void save_subsolve (const int i, const int t, const Eigen::MatrixXd &solution) const
 
int output_file_index (const int t) const
 
void notify_time_step (const int t, const int time_steps, const double t0, const double dt) const
 
io::OutGeometryData::ExportOptions export_options (const io::OutputSpace &space) const
 
io::OutputFieldFunction output_field_function (const Eigen::MatrixXd &solution, const io::OutGeometryData::ExportOptions &opts) const
 

Protected Attributes

FESpace space_
 
VarFormBoundaryState boundary_
 
assembler::AssemblyValsCache ass_vals_cache_
 
assembler::AssemblyValsCache mass_ass_vals_cache_
 
assembler::AssemblyValsCache pure_mass_ass_vals_cache_
 
std::shared_ptr< assembler::RhsAssemblerrhs_assembler_
 
StiffnessMatrix mass_
 
StiffnessMatrix pure_mass_
 
double avg_mass_ = 0
 
Eigen::MatrixXd rhs_
 
std::shared_ptr< assembler::Assemblerprimary_assembler_ = nullptr
 
std::shared_ptr< assembler::Massmass_assembler_ = nullptr
 
std::shared_ptr< assembler::HRZMasspure_mass_assembler_ = nullptr
 
double t0 = 0
 
int time_steps = 0
 
double dt = 0
 
- Protected Attributes inherited from polyfem::varform::VarForm
std::shared_ptr< assembler::Problemproblem
 current problem, it contains rhs and bc
 
Units units
 
json args
 
io::OutStatsData stats
 
io::OutRuntimeData timings
 runtime statistics
 
std::string root_path
 
std::string output_path
 
std::unique_ptr< mesh::Meshmesh_
 
std::function< void(int, int, double, double)> time_callback
 
io::OutGeometryData output_geometry_
 
bool output_sampler_initialized_ = false
 
bool prepared_ = false
 

Friends

class polyfem::test::VarFormTestAccess
 

Additional Inherited Members

- Static Protected Member Functions inherited from polyfem::varform::VarForm
static bool read_initial_x_from_file (const std::string &state_path, const std::string &x_name, const bool reorder, const Eigen::VectorXi &in_node_to_node, const int dim, Eigen::MatrixXd &x)
 
static void rebuild_node_positions (const std::vector< basis::ElementBases > &bases, const std::vector< int > &node_ids, std::vector< RowVectorNd > &positions)
 

Detailed Description

Definition at line 23 of file ElasticVarForm.hpp.

Member Function Documentation

◆ append_primary_output_fields()

void polyfem::varform::ElasticVarForm::append_primary_output_fields ( std::vector< io::OutputField > &  fields,
const io::OutputSample sample,
const Eigen::MatrixXd &  solution,
const io::OutputFieldOptions options,
const mesh::Obstacle obstacle = nullptr 
) const
protected

◆ assemble_mass_mat()

◆ assemble_rhs()

void polyfem::varform::ElasticVarForm::assemble_rhs ( const mesh::Mesh mesh)
overrideprotectedvirtual

Implements polyfem::varform::VarForm.

Reimplemented in polyfem::varform::IncompressibleElasticVarForm.

Definition at line 251 of file ElasticVarForm.cpp.

References polyfem::io::OutRuntimeData::assigning_rhs_time, polyfem::mesh::Mesh::bounding_box(), build_rhs_assembler(), polyfem::mesh::Mesh::is_volume(), polyfem::logger(), mass_assembler_, primary_assembler_, polyfem::varform::VarForm::problem, rhs_, rhs_assembler_, polyfem::varform::VarForm::root_path, and polyfem::varform::VarForm::timings.

Referenced by polyfem::varform::IncompressibleElasticVarForm::assemble_rhs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_basis()

void polyfem::varform::ElasticVarForm::build_basis ( mesh::Mesh mesh,
const bool  iso_parametric,
const json args 
)
overrideprotectedvirtual

Implements polyfem::varform::VarForm.

Reimplemented in polyfem::varform::IncompressibleElasticVarForm, and polyfem::varform::NonlinearElasticVarForm.

Definition at line 144 of file ElasticVarForm.cpp.

References polyfem::varform::VarForm::args, ass_vals_cache_, polyfem::varform::VarForm::assign_discr_orders(), polyfem::varform::FESpace::basis_list(), boundary_, polyfem::varform::VarFormBoundaryState::boundary_nodes, polyfem::varform::VarForm::build_fe_space(), polyfem::varform::VarFormBoundaryState::clear_boundary_conditions(), polyfem::io::OutStatsData::compute_mesh_size(), polyfem::io::OutStatsData::count_flipped_elements(), polyfem::mesh::Mesh::dimension(), polyfem::varform::VarFormBoundaryState::dirichlet_nodes, polyfem::varform::VarFormBoundaryState::dirichlet_nodes_position, polyfem::varform::FESpace::geometry_basis_list(), polyfem::assembler::AssemblyValsCache::init(), polyfem::assembler::AssemblyValsCache::init_empty(), polyfem::mesh::Mesh::is_volume(), polyfem::varform::VarFormBoundaryState::local_boundary, polyfem::varform::VarFormBoundaryState::local_neumann_boundary, polyfem::varform::VarFormBoundaryState::local_pressure_boundary, polyfem::varform::VarFormBoundaryState::local_pressure_cavity, polyfem::logger(), mass_ass_vals_cache_, mass_assembler_, polyfem::io::OutStatsData::mesh_size, polyfem::varform::FESpace::n_bases, polyfem::io::OutStatsData::n_flipped, polyfem::varform::VarFormBoundaryState::neumann_nodes, polyfem::varform::VarFormBoundaryState::neumann_nodes_position, polyfem::refinement::APriori::p_refine(), primary_assembler_, polyfem::varform::VarForm::problem, pure_mass_ass_vals_cache_, pure_mass_assembler_, polyfem::varform::VarForm::rebuild_node_positions(), space_, polyfem::varform::FESpace::space_in_node_to_node, polyfem::varform::VarForm::stats, polyfem::varform::VarFormBoundaryState::total_local_boundary, and polyfem::mesh::Mesh::update_nodes().

Referenced by polyfem::varform::IncompressibleElasticVarForm::build_basis().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_mesh_matrices()

void polyfem::varform::ElasticVarForm::build_mesh_matrices ( Eigen::MatrixXd &  V,
Eigen::MatrixXi &  F 
) const
protected

Definition at line 1282 of file ElasticVarForm.cpp.

References polyfem::basis::ElementBases::bases, polyfem::F, space_, and V.

◆ build_rhs_assembler()

void polyfem::varform::ElasticVarForm::build_rhs_assembler ( )
overrideprotectedvirtual

◆ compute_errors()

io::OutStatsData polyfem::varform::ElasticVarForm::compute_errors ( const Eigen::MatrixXd &  solution)
overridevirtual

Get the error statistics of the variational formulation, for output purposes.

Returns
Error statistics

Implements polyfem::varform::VarForm.

Reimplemented in polyfem::varform::IncompressibleElasticVarForm.

Definition at line 1130 of file ElasticVarForm.cpp.

References space_.

◆ displaced_output_normals()

Eigen::MatrixXd polyfem::varform::ElasticVarForm::displaced_output_normals ( const io::OutputSample sample,
const Eigen::MatrixXd &  solution 
) const
protected

Definition at line 1072 of file ElasticVarForm.cpp.

References polyfem::io::OutputSample::element_ids, polyfem::io::Evaluator::interpolate_at_local_vals(), polyfem::io::OutputSample::local_points, polyfem::io::OutputSample::normals, and space_.

Here is the call graph for this function:

◆ elastic_boundary_samples()

QuadratureOrders polyfem::varform::ElasticVarForm::elastic_boundary_samples ( ) const
protected

Definition at line 376 of file ElasticVarForm.cpp.

References polyfem::varform::FESpace::disc_orders, polyfem::varform::VarForm::mesh_, polyfem::varform::VarForm::n_boundary_samples(), and space_.

Referenced by polyfem::varform::LinearElasticVarForm::init_linear_solve(), polyfem::varform::IncompressibleElasticVarForm::solve_static_linear(), polyfem::varform::LinearElasticVarForm::solve_static_linear(), polyfem::varform::IncompressibleElasticVarForm::solve_transient_linear(), and polyfem::varform::LinearElasticVarForm::solve_transient_linear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ elastic_node_to_primitive()

std::vector< int > polyfem::varform::ElasticVarForm::elastic_node_to_primitive ( ) const
protected

Definition at line 397 of file ElasticVarForm.cpp.

References elastic_primitive_to_node(), polyfem::varform::FESpace::geometry, and space_.

Here is the call graph for this function:

◆ elastic_output_fields()

std::vector< io::OutputField > polyfem::varform::ElasticVarForm::elastic_output_fields ( const io::OutputSample sample,
const Eigen::MatrixXd &  solution,
const io::OutputFieldOptions options,
const mesh::Obstacle obstacle,
const time_integrator::ImplicitTimeIntegrator time_integrator,
const std::vector< std::pair< std::string, std::shared_ptr< solver::Form > > > &  named_forms,
const solver::Form elastic_form,
const solver::ContactForm contact_form = nullptr 
) const
protected

◆ elastic_primitive_to_node()

std::vector< int > polyfem::varform::ElasticVarForm::elastic_primitive_to_node ( ) const
protected

Definition at line 383 of file ElasticVarForm.cpp.

References polyfem::varform::FESpace::geometry, polyfem::varform::FESpace::is_iso_parametric(), polyfem::varform::VarForm::mesh_, polyfem::varform::FESpace::mesh_nodes, and space_.

Referenced by elastic_node_to_primitive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_data()

void polyfem::varform::ElasticVarForm::export_data ( const Eigen::MatrixXd &  solution) const
overridevirtual

Implements polyfem::varform::VarForm.

Definition at line 1143 of file ElasticVarForm.cpp.

References polyfem::io::Evaluator::compute_stress_at_quadrature_points(), polyfem::logger(), polyfem::io::OutputSpace::mesh, space_, polyfem::utils::unflatten(), and polyfem::io::write_matrix().

Here is the call graph for this function:

◆ init()

void polyfem::varform::ElasticVarForm::init ( const std::string &  formulation,
const Units units,
const json args,
const std::string &  out_path 
)
overridevirtual

Initialize the variational formulation with the given parameters.

Parameters
formulationname of the variational formulation
unitsunit system to use for the formulation
argsjson input arguments, used to initialize the formulation
out_pathoutput path for the formulation, used to save intermediate data

Reimplemented from polyfem::varform::VarForm.

Reimplemented in polyfem::varform::IncompressibleElasticVarForm, and polyfem::varform::NonlinearElasticVarForm.

Definition at line 62 of file ElasticVarForm.cpp.

References polyfem::varform::VarForm::args, dt, polyfem::problem::ProblemFactory::factory(), polyfem::problem::ProblemFactory::get_problem(), polyfem::varform::VarForm::init(), polyfem::assembler::AssemblerUtils::make_assembler(), mass_assembler_, primary_assembler_, polyfem::varform::VarForm::problem, pure_mass_assembler_, polyfem::varform::VarForm::root_path, t0, time_steps, and polyfem::varform::VarForm::units.

Referenced by polyfem::varform::IncompressibleElasticVarForm::init(), and polyfem::varform::NonlinearElasticVarForm::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initial_acceleration()

void polyfem::varform::ElasticVarForm::initial_acceleration ( Eigen::MatrixXd &  acceleration) const
protected

Definition at line 342 of file ElasticVarForm.cpp.

References polyfem::varform::VarForm::args, polyfem::varform::VarForm::mesh_, polyfem::varform::VarForm::read_initial_x_from_file(), polyfem::varform::VarForm::resolve_input_path(), rhs_assembler_, space_, and polyfem::varform::FESpace::space_in_node_to_node.

Referenced by polyfem::varform::LinearElasticVarForm::init_linear_solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initial_elastic_solution()

void polyfem::varform::ElasticVarForm::initial_elastic_solution ( Eigen::MatrixXd &  solution) const
protected

Definition at line 355 of file ElasticVarForm.cpp.

References polyfem::varform::VarForm::args, polyfem::varform::VarForm::mesh_, polyfem::varform::VarForm::problem, polyfem::varform::VarForm::read_initial_x_from_file(), polyfem::varform::VarForm::resolve_input_path(), rhs_, rhs_assembler_, space_, and polyfem::varform::FESpace::space_in_node_to_node.

Referenced by polyfem::varform::LinearElasticVarForm::init_linear_solve(), polyfem::varform::IncompressibleElasticVarForm::prepare_initial_solution(), and polyfem::varform::LinearElasticVarForm::solve_problem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initial_velocity()

void polyfem::varform::ElasticVarForm::initial_velocity ( Eigen::MatrixXd &  velocity) const
protected

Definition at line 329 of file ElasticVarForm.cpp.

References polyfem::varform::VarForm::args, polyfem::varform::VarForm::mesh_, polyfem::varform::VarForm::read_initial_x_from_file(), polyfem::varform::VarForm::resolve_input_path(), rhs_assembler_, space_, and polyfem::varform::FESpace::space_in_node_to_node.

Referenced by polyfem::varform::LinearElasticVarForm::init_linear_solve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_mesh()

void polyfem::varform::ElasticVarForm::load_mesh ( const mesh::Mesh mesh,
const json args 
)
overrideprotectedvirtual

Implements polyfem::varform::VarForm.

Reimplemented in polyfem::varform::IncompressibleElasticVarForm, and polyfem::varform::NonlinearElasticVarForm.

Definition at line 118 of file ElasticVarForm.cpp.

References polyfem::varform::VarForm::args, polyfem::mesh::Mesh::dimension(), polyfem::mesh::Mesh::get_body_id(), mass_assembler_, polyfem::mesh::Mesh::n_elements(), primary_assembler_, polyfem::varform::VarForm::problem, pure_mass_assembler_, and polyfem::varform::VarForm::set_materials().

Referenced by polyfem::varform::IncompressibleElasticVarForm::load_mesh(), and polyfem::varform::NonlinearElasticVarForm::load_mesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ n_obstacle_vertices()

virtual int polyfem::varform::ElasticVarForm::n_obstacle_vertices ( ) const
inlineprotectedvirtual

Reimplemented in polyfem::varform::NonlinearElasticVarForm.

Definition at line 74 of file ElasticVarForm.hpp.

◆ output_space()

io::OutputSpace polyfem::varform::ElasticVarForm::output_space ( ) const
overridevirtual

Get the output space of the variational formulation, for output purposes.

Returns
Output space

Implements polyfem::varform::VarForm.

Reimplemented in polyfem::varform::NonlinearElasticVarForm.

Definition at line 1105 of file ElasticVarForm.cpp.

References space_.

Referenced by polyfem::varform::NonlinearElasticVarForm::output_space().

Here is the caller graph for this function:

◆ reset()

void polyfem::varform::ElasticVarForm::reset ( )
overrideprotectedvirtual

◆ save_elastic_step_state()

void polyfem::varform::ElasticVarForm::save_elastic_step_state ( const double  t0,
const double  dt,
const int  t,
const time_integrator::ImplicitTimeIntegrator time_integrator 
) const
protected

Definition at line 1256 of file ElasticVarForm.cpp.

References polyfem::F, V, and polyfem::io::MshWriter::write().

Referenced by polyfem::varform::IncompressibleElasticVarForm::solve_transient_linear(), and polyfem::varform::LinearElasticVarForm::solve_transient_linear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_json()

void polyfem::varform::ElasticVarForm::save_json ( const Eigen::MatrixXd &  solution,
std::ostream &  out 
) const
overridevirtual

Save the solution to a JSON file, for output purposes.

Parameters
solutionSolution matrix to save
outOutput stream to save the solution

Implements polyfem::varform::VarForm.

Reimplemented in polyfem::varform::IncompressibleElasticVarForm.

Definition at line 1227 of file ElasticVarForm.cpp.

References polyfem::logger(), and space_.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ polyfem::test::VarFormTestAccess

friend class polyfem::test::VarFormTestAccess
friend

Definition at line 25 of file ElasticVarForm.hpp.

Member Data Documentation

◆ ass_vals_cache_

◆ avg_mass_

double polyfem::varform::ElasticVarForm::avg_mass_ = 0
protected

◆ boundary_

◆ dt

◆ mass_

◆ mass_ass_vals_cache_

◆ mass_assembler_

◆ primary_assembler_

◆ pure_mass_

StiffnessMatrix polyfem::varform::ElasticVarForm::pure_mass_
protected

Definition at line 86 of file ElasticVarForm.hpp.

Referenced by assemble_mass_mat(), and reset().

◆ pure_mass_ass_vals_cache_

assembler::AssemblyValsCache polyfem::varform::ElasticVarForm::pure_mass_ass_vals_cache_
protected

Definition at line 81 of file ElasticVarForm.hpp.

Referenced by assemble_mass_mat(), build_basis(), and reset().

◆ pure_mass_assembler_

std::shared_ptr<assembler::HRZMass> polyfem::varform::ElasticVarForm::pure_mass_assembler_ = nullptr
protected

Definition at line 93 of file ElasticVarForm.hpp.

Referenced by assemble_mass_mat(), build_basis(), init(), load_mesh(), and reset().

◆ rhs_

◆ rhs_assembler_

◆ space_

◆ t0

◆ time_steps

int polyfem::varform::ElasticVarForm::time_steps = 0
protected

The documentation for this class was generated from the following files: