PolyFEM
|
Namespaces | |
namespace | StringUtils |
Functions | |
double | triangle_area_2D (const Eigen::Vector2d &a, const Eigen::Vector2d &b, const Eigen::Vector2d &c) |
Compute the signed area of a 2D triangle defined by three points. | |
double | triangle_area_3D (const Eigen::Vector3d &a, const Eigen::Vector3d &b, const Eigen::Vector3d &c) |
Compute the area of a 3D triangle defined by three points. | |
double | triangle_area (const Eigen::MatrixXd V) |
Compute the signed area of a triangle defined by three points. | |
double | tetrahedron_volume (const Eigen::Vector3d &a, const Eigen::Vector3d &b, const Eigen::Vector3d &c, const Eigen::Vector3d &d) |
Compute the signed volume of a tetrahedron defined by four points. | |
double | tetrahedron_volume (const Eigen::MatrixXd V) |
Compute the signed volume of a tetrahedron defined by four points. | |
Eigen::MatrixXd | triangle_to_clockwise_order (const Eigen::MatrixXd &triangle) |
Reorder the vertices of a triangle so they are in clockwise order. | |
std::vector< Eigen::MatrixXd > | triangle_fan (const Eigen::MatrixXd &convex_polygon) |
Convert a convex polygon to a list of triangles fanned around the first vertex. | |
Eigen::VectorXd | barycentric_coordinates (const Eigen::VectorXd &p, const Eigen::MatrixXd &V) |
Compute barycentric coordinates for point p with respect to a simplex. | |
bool | triangle_intersects_disk (const Eigen::Vector2d &t0, const Eigen::Vector2d &t1, const Eigen::Vector2d &t2, const Eigen::Vector2d ¢er, const double radius) |
Determine if a 2D triangle intersects a 2D disk. | |
bool | tetrahedron_intersects_ball (const Eigen::Vector3d &t0, const Eigen::Vector3d &t1, const Eigen::Vector3d &t2, const Eigen::Vector3d &t3, const Eigen::Vector3d ¢er, const double radius) |
Determine if a 3D tetrahedron intersects a 3D ball. | |
bool | are_edges_collinear (const VectorNd &ea0, const VectorNd &ea1, const VectorNd &eb0, const VectorNd &eb1, const double tol=1e-10) |
Determine if two edges are collinear. | |
bool | are_triangles_coplanar (const Eigen::Vector3d &t00, const Eigen::Vector3d &t01, const Eigen::Vector3d &t02, const Eigen::Vector3d &t10, const Eigen::Vector3d &t11, const Eigen::Vector3d &t12, const double tol=1e-10) |
Determine if two triangles are coplanar. | |
bool | are_aabbs_intersecting (const VectorNd &aabb0_min, const VectorNd &aabb0_max, const VectorNd &aabb1_min, const VectorNd &aabb1_max) |
Determine if two axis-aligned bounding boxes intersect. | |
void | triangle_area_2D_gradient (double ax, double ay, double bx, double by, double cx, double cy, double g[6]) |
Compute the gradient of the signed area of a 2D triangle defined by three points. | |
void | triangle_area_2D_hessian (double ax, double ay, double bx, double by, double cx, double cy, double H[36]) |
Compute the Hessian of the signed area of a 2D triangle defined by three points. | |
void | tetrahedron_volume_gradient (double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx, double dy, double dz, double g[12]) |
Compute the gradient of the signed volume of a tetrahedron defined by four points. | |
void | tetrahedron_volume_hessian (double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx, double dy, double dz, double H[144]) |
Compute the gradient of the signed area of a 2D triangle defined by three points. | |
NLOHMANN_JSON_SERIALIZE_ENUM (PiecewiseInterpolation::Extend, {{PiecewiseInterpolation::Extend::CONSTANT, "constant"}, {PiecewiseInterpolation::Extend::EXTRAPOLATE, "extrapolate"}, {PiecewiseInterpolation::Extend::REPEAT, "repeat"}, {PiecewiseInterpolation::Extend::REPEAT_OFFSET, "repeat_offset"}}) | |
Eigen::MatrixXd | extract_nodes (const int dim, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const Eigen::VectorXd &u, int order, int n_elem) |
Eigen::MatrixXd | extract_nodes (const int dim, const basis::ElementBases &basis, const basis::ElementBases &gbasis, const Eigen::VectorXd &u, int order) |
Eigen::VectorXd | robust_evaluate_jacobian (const int order, const Eigen::MatrixXd &cp, const Eigen::MatrixXd &uv) |
std::vector< int > | count_invalid (const int dim, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const Eigen::VectorXd &u) |
std::tuple< bool, int, Tree > | is_valid (const int dim, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const Eigen::VectorXd &u, const double threshold) |
bool | is_valid (const int dim, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const Eigen::VectorXd &u1, const Eigen::VectorXd &u2, const double threshold) |
std::tuple< double, int, double, Tree > | max_time_step (const int dim, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const Eigen::VectorXd &u1, const Eigen::VectorXd &u2, double precision) |
void | apply_common_params (json &args) |
Eigen::Matrix3d | to_rotation_matrix (const json &jr, std::string mode) |
bool | is_param_valid (const json ¶ms, const std::string &key) |
Determine if a key exists and is non-null in a json object. | |
template<typename T > | |
T | deg2rad (T deg) |
template<typename T = json> | |
std::vector< T > | json_as_array (const json &j) |
Return the value of a json object as an array. | |
template<typename T > | |
T | json_value (const json ¶ms, const std::string &key, const T &default_value) |
Get a parameter from a json object or return a default value if the parameter invalid. | |
void | show_matrix_stats (const Eigen::MatrixXd &M) |
template<typename T > | |
T | matrix_inner_product (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &A, const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &B) |
template<typename T , int rows, int cols, int option, int maxRow, int maxCol> | |
T | determinant (const Eigen::Matrix< T, rows, cols, option, maxRow, maxCol > &mat) |
template<typename T > | |
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > | inverse (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > &mat) |
Eigen::SparseMatrix< double > | sparse_identity (int rows, int cols) |
Eigen::VectorXd | flatten (const Eigen::MatrixXd &X) |
Flatten rowwises. | |
Eigen::MatrixXd | unflatten (const Eigen::VectorXd &x, int dim) |
Unflatten rowwises, so every dim elements in x become a row. | |
void | vector2matrix (const Eigen::VectorXd &vec, Eigen::MatrixXd &mat) |
Eigen::SparseMatrix< double > | lump_matrix (const Eigen::SparseMatrix< double > &M) |
Lump each row of a matrix into the diagonal. | |
void | full_to_reduced_matrix (const int full_size, const int reduced_size, const std::vector< int > &removed_vars, const StiffnessMatrix &full, StiffnessMatrix &reduced) |
Map a full size matrix to a reduced one by dropping rows and columns. | |
Eigen::MatrixXd | reorder_matrix (const Eigen::MatrixXd &in, const Eigen::VectorXi &in_to_out, int out_blocks=-1, const int block_size=1) |
Reorder row blocks in a matrix. | |
Eigen::MatrixXd | unreorder_matrix (const Eigen::MatrixXd &out, const Eigen::VectorXi &in_to_out, int in_blocks=-1, const int block_size=1) |
Undo the reordering of row blocks in a matrix. | |
Eigen::MatrixXi | map_index_matrix (const Eigen::MatrixXi &in, const Eigen::VectorXi &index_mapping) |
Map the entrys of an index matrix to new indices. | |
template<typename DstMat , typename SrcMat > | |
void | append_rows (DstMat &dst, const SrcMat &src) |
template<typename DstMat > | |
void | append_rows_of_zeros (DstMat &dst, const size_t n_zero_rows) |
void | maybe_parallel_for (int size, const std::function< void(int, int, int)> &partial_for) |
void | maybe_parallel_for (int size, const std::function< void(int)> &body) |
template<typename LocalStorage > | |
auto | create_thread_storage (const LocalStorage &initial_local_storage) |
template<typename Storages > | |
auto & | get_local_thread_storage (Storages &storage, int thread_id) |
void | par_for (const int size, const std::function< void(int, int, int)> &func) |
size_t | get_n_threads () |
void | regular_2d_grid (const int n, bool tri, Eigen::MatrixXd &V, Eigen::MatrixXi &F) |
Generate a canonical triangle/quad subdivided from a regular grid. | |
void | regular_3d_grid (const int nn, bool tet, Eigen::MatrixXd &V, Eigen::MatrixXi &F, Eigen::MatrixXi &T) |
Generate a canonical tet/hex subdivided from a regular grid. | |
std::string | resolve_path (const std::string &path, const std::string &input_file_path, const bool only_if_exists=false) |
template<int dim> | |
Eigen::Vector< double, dim > | singular_values (const Eigen::Matrix< double, dim, dim > &A) |
void polyfem::utils::append_rows | ( | DstMat & | dst, |
const SrcMat & | src | ||
) |
Definition at line 149 of file MatrixUtils.hpp.
Referenced by polyfem::mesh::Mesh::append(), polyfem::State::build_collision_mesh(), polyfem::mesh::SizingFieldRemesher< WMTKMesh >::compute_contact_sizing_field(), polyfem::mesh::LocalMesh< M >::LocalMesh(), polyfem::mesh::Remesher::project_quantities(), and polyfem::mesh::Remesher::write_mesh().
void polyfem::utils::append_rows_of_zeros | ( | DstMat & | dst, |
const size_t | n_zero_rows | ||
) |
Definition at line 161 of file MatrixUtils.hpp.
Referenced by polyfem::io::OutGeometryData::save_volume().
void polyfem::utils::apply_common_params | ( | json & | args | ) |
Definition at line 14 of file JSONUtils.cpp.
References apply_common_params(), polyfem::log_and_throw_error(), and resolve_path().
Referenced by apply_common_params(), and polyfem::State::init().
bool polyfem::utils::are_aabbs_intersecting | ( | const VectorNd & | aabb0_min, |
const VectorNd & | aabb0_max, | ||
const VectorNd & | aabb1_min, | ||
const VectorNd & | aabb1_max | ||
) |
Determine if two axis-aligned bounding boxes intersect.
aabb0_min | Minimum corner of the first AABB. |
aabb0_max | Maximum corner of the first AABB. |
aabb1_min | Minimum corner of the second AABB. |
aabb1_max | Maximum corner of the second AABB. |
Definition at line 196 of file GeometryUtils.cpp.
Referenced by polyfem::mesh::LocalMesh< M >::ball_selection().
bool polyfem::utils::are_edges_collinear | ( | const VectorNd & | ea0, |
const VectorNd & | ea1, | ||
const VectorNd & | eb0, | ||
const VectorNd & | eb1, | ||
const double | tol = 1e-10 |
||
) |
Determine if two edges are collinear.
ea0 | First vertex of the first edge. |
ea1 | Second vertex of the first edge. |
eb0 | First vertex of the second edge. |
eb1 | Second vertex of the second edge. |
tol | Tolerance for collinearity. |
Definition at line 169 of file GeometryUtils.cpp.
bool polyfem::utils::are_triangles_coplanar | ( | const Eigen::Vector3d & | t00, |
const Eigen::Vector3d & | t01, | ||
const Eigen::Vector3d & | t02, | ||
const Eigen::Vector3d & | t10, | ||
const Eigen::Vector3d & | t11, | ||
const Eigen::Vector3d & | t12, | ||
const double | tol = 1e-10 |
||
) |
Determine if two triangles are coplanar.
t00 | First vertex of the first triangle. |
t01 | Second vertex of the first triangle. |
t02 | Third vertex of the first triangle. |
t10 | First vertex of the second triangle. |
t11 | Second vertex of the second triangle. |
t12 | Third vertex of the second triangle. |
tol | Tolerance for coplanarity. |
Definition at line 182 of file GeometryUtils.cpp.
References polyfem::assembler::cross().
Eigen::VectorXd polyfem::utils::barycentric_coordinates | ( | const Eigen::VectorXd & | p, |
const Eigen::MatrixXd & | V | ||
) |
Compute barycentric coordinates for point p with respect to a simplex.
p | Query point. |
V | Verties of the simplex as rows of a matrix. |
Definition at line 88 of file GeometryUtils.cpp.
References V.
Referenced by polyfem::assembler::MassMatrixAssembler::assemble_cross().
std::vector< int > polyfem::utils::count_invalid | ( | const int | dim, |
const std::vector< basis::ElementBases > & | bases, | ||
const std::vector< basis::ElementBases > & | gbases, | ||
const Eigen::VectorXd & | u | ||
) |
Definition at line 173 of file Jacobian.cpp.
References extract_nodes(), polyfem::utils::NThread::get(), and polyfem::utils::NThread::num_threads().
Referenced by polyfem::io::Evaluator::mark_flipped_cells(), and polyfem::State::solve_tensor_nonlinear().
|
inline |
Referenced by polyfem::assembler::NLAssembler::assemble_energy(), polyfem::assembler::NLAssembler::assemble_energy_per_element(), polyfem::assembler::RhsAssembler::compute_energy(), polyfem::assembler::PressureAssembler::compute_grad_volume(), polyfem::assembler::PressureAssembler::compute_grad_volume_id(), polyfem::assembler::PressureAssembler::compute_hess_volume_2d(), polyfem::assembler::PressureAssembler::compute_hess_volume_3d(), polyfem::assembler::PressureAssembler::compute_volume(), polyfem::solver::InertiaForm::force_shape_derivative(), polyfem::solver::BodyForm::force_shape_derivative(), polyfem::solver::AdjointTools::integrate_objective(), polyfem::assembler::PressureAssembler::is_closed_or_boundary_fixed(), polyfem::solver::InversionBarrierForm::second_derivative_unweighted(), polyfem::solver::SDFTargetForm::solution_changed_step(), and polyfem::solver::MeshTargetForm::solution_changed_step().
|
inline |
Definition at line 18 of file JSONUtils.hpp.
References deg2rad().
Referenced by polyfem::mesh::construct_affine_transformation(), deg2rad(), and to_rotation_matrix().
T polyfem::utils::determinant | ( | const Eigen::Matrix< T, rows, cols, option, maxRow, maxCol > & | mat | ) |
Definition at line 22 of file MatrixUtils.hpp.
Referenced by polyfem::assembler::AMIPSEnergy::compute_energy_aux(), polyfem::assembler::NeoHookeanElasticity::compute_energy_aux(), polyfem::assembler::AMIPSEnergy::compute_energy_hessian_aux_fast(), polyfem::assembler::AMIPSEnergyAutodiff::elastic_energy(), polyfem::assembler::MooneyRivlin3ParamElasticity::elastic_energy(), polyfem::assembler::MooneyRivlinElasticity::elastic_energy(), polyfem::assembler::NeoHookeanAutodiff::elastic_energy(), polyfem::assembler::MooneyRivlin3ParamSymbolic::elastic_energy(), polyfem::utils::AutoFlipSVD< MatrixType >::flip2d(), inverse(), and polyfem::third_invariant().
Eigen::MatrixXd polyfem::utils::extract_nodes | ( | const int | dim, |
const basis::ElementBases & | basis, | ||
const basis::ElementBases & | gbasis, | ||
const Eigen::VectorXd & | u, | ||
int | order | ||
) |
Definition at line 104 of file Jacobian.cpp.
References polyfem::assembler::ElementAssemblyValues::basis_values, polyfem::assembler::ElementAssemblyValues::compute(), polyfem::basis::ElementBases::eval_geom_mapping(), polyfem::autogen::p_nodes_2d(), polyfem::autogen::p_nodes_3d(), and vals.
Eigen::MatrixXd polyfem::utils::extract_nodes | ( | const int | dim, |
const std::vector< basis::ElementBases > & | bases, | ||
const std::vector< basis::ElementBases > & | gbases, | ||
const Eigen::VectorXd & | u, | ||
int | order, | ||
int | n_elem | ||
) |
Definition at line 77 of file Jacobian.cpp.
References polyfem::assembler::ElementAssemblyValues::basis_values, polyfem::assembler::ElementAssemblyValues::compute(), polyfem::autogen::p_nodes_2d(), polyfem::autogen::p_nodes_3d(), and vals.
Referenced by count_invalid(), polyfem::assembler::ElementAssemblyValues::eval_deformed_jacobian_determinant(), is_valid(), is_valid(), and max_time_step().
Eigen::VectorXd polyfem::utils::flatten | ( | const Eigen::MatrixXd & | X | ) |
Flatten rowwises.
Definition at line 34 of file MatrixUtils.cpp.
References x.
Referenced by polyfem::solver::AMIPSForm::AMIPSForm(), polyfem::solver::PeriodicMeshToMesh::apply_jacobian(), polyfem::solver::CollisionBarrierForm::CollisionBarrierForm(), polyfem::solver::BoundarySmoothingForm::compute_partial_gradient(), polyfem::solver::SpatialIntegralForm::compute_partial_gradient_step(), polyfem::assembler::NeoHookeanElasticity::compute_stiffness_value(), polyfem::solver::DeformedCollisionBarrierForm::DeformedCollisionBarrierForm(), polyfem::solver::BSplineParametrization1DTo2D::eval(), polyfem::solver::PeriodicContactForm::force_periodic_shape_derivative(), polyfem::solver::NLHomoProblem::full_to_reduced(), polyfem::io::Evaluator::generate_linear_field(), polyfem::solver::ElasticEnergyForm::get_integral_functional(), polyfem::solver::StressNormForm::get_integral_functional(), polyfem::solver::ComplianceForm::get_integral_functional(), polyfem::solver::StressForm::get_integral_functional(), polyfem::solver::ShapeVariableToSimulation::inverse_eval(), polyfem::solver::PeriodicShapeVariableToSimulation::inverse_eval(), polyfem::solver::BSplineParametrization1DTo2D::inverse_eval(), polyfem::solver::NLHomoProblem::macro_reduced_to_full(), polyfem::State::remesh(), polyfem::mesh::LocalRelaxationData< M >::sol(), polyfem::State::solve_homogenization_step(), and polyfem::solver::MacroStrainLagrangianForm::update_quantities().
void polyfem::utils::full_to_reduced_matrix | ( | const int | full_size, |
const int | reduced_size, | ||
const std::vector< int > & | removed_vars, | ||
const StiffnessMatrix & | full, | ||
StiffnessMatrix & | reduced | ||
) |
Map a full size matrix to a reduced one by dropping rows and columns.
[in] | full_size | Number of variables in the full system. |
[in] | reduced_size | Number of variables in the reduced system. |
[in] | removed_vars | Indices of the variables (rows and columns of full) to remove. |
[in] | full | Full size matrix. |
[out] | reduced | Output reduced size matrix. |
Definition at line 103 of file MatrixUtils.cpp.
References entries, and POLYFEM_SCOPED_TIMER.
Referenced by polyfem::solver::NLProblem::full_hessian_to_reduced_hessian().
|
inline |
Referenced by polyfem::assembler::NLAssembler::assemble_energy(), polyfem::assembler::NLAssembler::assemble_energy_per_element(), polyfem::assembler::RhsAssembler::compute_energy(), polyfem::solver::InertiaForm::force_shape_derivative(), polyfem::solver::BodyForm::force_shape_derivative(), and polyfem::solver::AdjointTools::integrate_objective().
|
inline |
Definition at line 51 of file par_for.hpp.
References polyfem::utils::NThread::get(), and polyfem::utils::NThread::num_threads().
Referenced by par_for(), and polyfem::io::OutStatsData::save_json().
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > polyfem::utils::inverse | ( | const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > & | mat | ) |
Definition at line 38 of file MatrixUtils.hpp.
References determinant().
Referenced by polyfem::mesh::stitch_mesh().
bool polyfem::utils::is_param_valid | ( | const json & | params, |
const std::string & | key | ||
) |
Determine if a key exists and is non-null in a json object.
params | JSON of parameters |
key | Key to check |
Definition at line 131 of file JSONUtils.cpp.
Referenced by polyfem::assembler::MacroStrainValue::init(), polyfem::mesh::LocalRelaxationData< M >::init_assembler(), polyfem::State::init_time(), json_value(), polyfem::State::load_mesh(), polyfem::mesh::read_fem_mesh(), polyfem::mesh::read_obstacle_geometry(), polyfem::mesh::read_obstacle_mesh(), polyfem::OptState::root_path(), polyfem::State::root_path(), polyfem::State::set_materials(), polyfem::State::set_materials(), polyfem::assembler::GenericTensorProblem::set_parameters(), polyfem::assembler::GenericScalarProblem::set_parameters(), and polyfem::State::solve_homogenization().
std::tuple< bool, int, Tree > polyfem::utils::is_valid | ( | const int | dim, |
const std::vector< basis::ElementBases > & | bases, | ||
const std::vector< basis::ElementBases > & | gbases, | ||
const Eigen::VectorXd & | u, | ||
const double | threshold | ||
) |
Definition at line 241 of file Jacobian.cpp.
References extract_nodes(), polyfem::utils::NThread::get(), and polyfem::utils::NThread::num_threads().
Referenced by polyfem::solver::CollisionBarrierForm::is_step_collision_free(), polyfem::solver::ContactForm::is_step_collision_free(), polyfem::mesh::NCMesh2D::refine(), polyfem::mesh::NCMesh3D::refine(), and polyfem::mesh::NCMesh3D::refine_element().
bool polyfem::utils::is_valid | ( | const int | dim, |
const std::vector< basis::ElementBases > & | bases, | ||
const std::vector< basis::ElementBases > & | gbases, | ||
const Eigen::VectorXd & | u1, | ||
const Eigen::VectorXd & | u2, | ||
const double | threshold | ||
) |
Definition at line 298 of file Jacobian.cpp.
References extract_nodes(), polyfem::utils::NThread::get(), and polyfem::utils::NThread::num_threads().
std::vector< T > polyfem::utils::json_as_array | ( | const json & | j | ) |
Return the value of a json object as an array.
If the value is an array return it directly otherwise return a vector with the value.
j | JSON object |
Definition at line 38 of file JSONUtils.hpp.
Referenced by polyfem::assembler::GenericMatParams::add_multimaterial(), polyfem::State::boundary_conditions_ids(), polyfem::State::build_collision_mesh(), polyfem::solver::SolveData::init_forms(), polyfem::State::load_mesh(), polyfem::State::load_mesh(), polyfem::mesh::read_fem_geometry(), polyfem::mesh::read_obstacle_geometry(), and polyfem::problem::NodeProblem::set_parameters().
T polyfem::utils::json_value | ( | const json & | params, |
const std::string & | key, | ||
const T & | default_value | ||
) |
Get a parameter from a json object or return a default value if the parameter invalid.
Similar to json::value() but return default value if the parameter is null.
Definition at line 56 of file JSONUtils.hpp.
References is_param_valid().
Eigen::SparseMatrix< double > polyfem::utils::lump_matrix | ( | const Eigen::SparseMatrix< double > & | M | ) |
Lump each row of a matrix into the diagonal.
M | Matrix to lump. |
Definition at line 84 of file MatrixUtils.cpp.
Referenced by polyfem::State::assemble_mass_mat(), and polyfem::solver::BCLagrangianForm::init_masked_lumped_mass().
Eigen::MatrixXi polyfem::utils::map_index_matrix | ( | const Eigen::MatrixXi & | in, |
const Eigen::VectorXi & | index_mapping | ||
) |
Map the entrys of an index matrix to new indices.
in | Input index matrix. |
index_mapping | Mapping from old to new indices. |
Definition at line 223 of file MatrixUtils.cpp.
Referenced by polyfem::mesh::Remesher::project_quantities(), and polyfem::mesh::LocalMesh< M >::reorder_vertices().
T polyfem::utils::matrix_inner_product | ( | const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & | A, |
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & | B | ||
) |
Definition at line 16 of file MatrixUtils.hpp.
std::tuple< double, int, double, Tree > polyfem::utils::max_time_step | ( | const int | dim, |
const std::vector< basis::ElementBases > & | bases, | ||
const std::vector< basis::ElementBases > & | gbases, | ||
const Eigen::VectorXd & | u1, | ||
const Eigen::VectorXd & | u2, | ||
double | precision | ||
) |
Definition at line 345 of file Jacobian.cpp.
References extract_nodes(), polyfem::utils::NThread::get(), and polyfem::utils::NThread::num_threads().
|
inline |
|
inline |
Referenced by polyfem::assembler::NLAssembler::assemble_energy(), polyfem::assembler::NLAssembler::assemble_energy_per_element(), polyfem::assembler::RhsAssembler::compute_energy(), polyfem::assembler::PressureAssembler::compute_grad_volume(), polyfem::assembler::PressureAssembler::compute_grad_volume_id(), polyfem::assembler::PressureAssembler::compute_hess_volume_2d(), polyfem::assembler::PressureAssembler::compute_hess_volume_3d(), polyfem::assembler::PressureAssembler::compute_volume(), polyfem::solver::InversionBarrierForm::first_derivative_unweighted(), polyfem::solver::InertiaForm::force_shape_derivative(), polyfem::solver::BodyForm::force_shape_derivative(), polyfem::assembler::AssemblyValsCache::init(), polyfem::solver::AdjointTools::integrate_objective(), polyfem::assembler::PressureAssembler::is_closed_or_boundary_fixed(), polyfem::utils::SparseMatrixCache::operator+(), polyfem::utils::SparseMatrixCache::operator+=(), polyfem::solver::InversionBarrierForm::second_derivative_unweighted(), polyfem::solver::SDFTargetForm::solution_changed_step(), polyfem::solver::MeshTargetForm::solution_changed_step(), polyfem::solver::AdjointNLProblem::solve_pde(), polyfem::solver::ContactForm::value_per_element_unweighted(), polyfem::solver::InversionBarrierForm::value_unweighted(), and polyfem::solver::MaxStressForm::value_unweighted_step().
polyfem::utils::NLOHMANN_JSON_SERIALIZE_ENUM | ( | PiecewiseInterpolation::Extend | , |
{{PiecewiseInterpolation::Extend::CONSTANT, "constant"}, {PiecewiseInterpolation::Extend::EXTRAPOLATE, "extrapolate"}, {PiecewiseInterpolation::Extend::REPEAT, "repeat"}, {PiecewiseInterpolation::Extend::REPEAT_OFFSET, "repeat_offset"}} | |||
) |
void polyfem::utils::par_for | ( | const int | size, |
const std::function< void(int, int, int)> & | func | ||
) |
Definition at line 10 of file par_for.cpp.
References get_n_threads(), and x.
void polyfem::utils::regular_2d_grid | ( | const int | n, |
bool | tri, | ||
Eigen::MatrixXd & | V, | ||
Eigen::MatrixXi & | F | ||
) |
Generate a canonical triangle/quad subdivided from a regular grid.
[in] | n | n grid quads |
[in] | tri | is a tri or a quad |
[out] | V | V x 2 output vertices positions |
[out] | F | F x 3 output triangle indices |
Definition at line 31 of file RefElementSampler.cpp.
References polyfem::F, and V.
Referenced by polyfem::utils::RefElementSampler::build().
void polyfem::utils::regular_3d_grid | ( | const int | nn, |
bool | tet, | ||
Eigen::MatrixXd & | V, | ||
Eigen::MatrixXi & | F, | ||
Eigen::MatrixXi & | T | ||
) |
Generate a canonical tet/hex subdivided from a regular grid.
[in] | n | n grid quads |
[in] | tet | is a tet or a hex |
[out] | V | V x 3 output vertices positions |
[out] | F | F x 3 output triangle indices |
[out] | T | F x 4 output tet indices |
Definition at line 116 of file RefElementSampler.cpp.
References polyfem::F, and V.
Referenced by polyfem::utils::RefElementSampler::build().
Eigen::MatrixXd polyfem::utils::reorder_matrix | ( | const Eigen::MatrixXd & | in, |
const Eigen::VectorXi & | in_to_out, | ||
int | out_blocks = -1 , |
||
const int | block_size = 1 |
||
) |
Reorder row blocks in a matrix.
in | Input matrix. |
in_to_out | Mapping from input blocks to output blocks. |
out_blocks | Number of blocks in the output matrix. |
block_size | Size of each block. |
Definition at line 162 of file MatrixUtils.cpp.
Referenced by polyfem::mesh::Remesher::project_quantities(), polyfem::State::remesh(), and polyfem::mesh::LocalMesh< M >::reorder_vertices().
std::string polyfem::utils::resolve_path | ( | const std::string & | path, |
const std::string & | input_file_path, | ||
const bool | only_if_exists = false |
||
) |
Definition at line 103 of file StringUtils.cpp.
Referenced by apply_common_params(), polyfem::utils::Selection::build(), polyfem::State::build_collision_mesh(), polyfem::utils::Selection::build_selections(), polyfem::OptState::init(), polyfem::mesh::read_fem_mesh(), polyfem::mesh::read_obstacle_geometry(), polyfem::mesh::read_obstacle_mesh(), polyfem::State::resolve_input_path(), polyfem::assembler::GenericTensorProblem::set_parameters(), and polyfem::assembler::GenericScalarProblem::set_parameters().
Eigen::VectorXd polyfem::utils::robust_evaluate_jacobian | ( | const int | order, |
const Eigen::MatrixXd & | cp, | ||
const Eigen::MatrixXd & | uv | ||
) |
Definition at line 124 of file Jacobian.cpp.
Referenced by polyfem::assembler::ElementAssemblyValues::eval_deformed_jacobian_determinant().
void polyfem::utils::show_matrix_stats | ( | const Eigen::MatrixXd & | M | ) |
Definition at line 8 of file MatrixUtils.cpp.
References polyfem::logger().
Referenced by polyfem::basis::RBFWithQuadraticLagrange::compute_constraints_matrix_2d_old(), and polyfem::basis::RBFWithQuadraticLagrange::compute_constraints_matrix_3d().
Eigen::Vector< double, dim > polyfem::utils::singular_values | ( | const Eigen::Matrix< double, dim, dim > & | A | ) |
Definition at line 358 of file svd.hpp.
References polyfem::utils::AutoFlipSVD< MatrixType >::singularValues().
Referenced by polyfem::utils::AutoFlipSVD< MatrixType >::fastComputeSingularValues3d(), and polyfem::utils::AutoFlipSVD< MatrixType >::fastSVD3d().
|
inline |
Definition at line 83 of file MatrixUtils.hpp.
Referenced by polyfem::solver::BCLagrangianForm::init_masked_lumped_mass().
bool polyfem::utils::tetrahedron_intersects_ball | ( | const Eigen::Vector3d & | t0, |
const Eigen::Vector3d & | t1, | ||
const Eigen::Vector3d & | t2, | ||
const Eigen::Vector3d & | t3, | ||
const Eigen::Vector3d & | center, | ||
const double | radius | ||
) |
Determine if a 3D tetrahedron intersects a 3D ball.
t0 | Tetrahedron first vertex. |
t1 | Tetrahedron second vertex. |
t2 | Tetrahedron third vertex. |
t3 | Tetrahedron fourth vertex. |
center | Center of the ball. |
radius | Radius of the ball. |
Definition at line 137 of file GeometryUtils.cpp.
Referenced by polyfem::mesh::LocalMesh< M >::ball_selection().
double polyfem::utils::tetrahedron_volume | ( | const Eigen::MatrixXd | V | ) |
Compute the signed volume of a tetrahedron defined by four points.
V | The vertices of the terahedron as rows of a matrix. |
Definition at line 52 of file GeometryUtils.cpp.
References tetrahedron_volume(), and V.
double polyfem::utils::tetrahedron_volume | ( | const Eigen::Vector3d & | a, |
const Eigen::Vector3d & | b, | ||
const Eigen::Vector3d & | c, | ||
const Eigen::Vector3d & | d | ||
) |
Compute the signed volume of a tetrahedron defined by four points.
a | First point of the tetrahedron. |
b | Second point of the tetrahedron. |
c | Third point of the tetrahedron. |
d | Fourth point of the tetrahedron. |
Definition at line 43 of file GeometryUtils.cpp.
Referenced by polyfem::assembler::MassMatrixAssembler::assemble_cross(), polyfem::utils::TetrahedronClipping::clip(), polyfem::solver::InversionBarrierForm::element_volume(), and tetrahedron_volume().
void polyfem::utils::tetrahedron_volume_gradient | ( | double | ax, |
double | ay, | ||
double | az, | ||
double | bx, | ||
double | by, | ||
double | bz, | ||
double | cx, | ||
double | cy, | ||
double | cz, | ||
double | dx, | ||
double | dy, | ||
double | dz, | ||
double | g[12] | ||
) |
Compute the gradient of the signed volume of a tetrahedron defined by four points.
ax | First point's x coordinate. |
ay | First point's y coordinate. |
ay | First point's z coordinate. |
bx | Second point's x coordinate. |
by | Second point's y coordinate. |
by | Second point's z coordinate. |
cx | Third point's x coordinate. |
cy | Third point's y coordinate. |
cy | Third point's z coordinate. |
dx | Fourth point's x coordinate. |
dy | Fourth point's y coordinate. |
dy | Fourth point's z coordinate. |
g | Output gradient with respect to the four points. |
Definition at line 261 of file GeometryUtils.cpp.
Referenced by polyfem::solver::InversionBarrierForm::element_volume_gradient().
void polyfem::utils::tetrahedron_volume_hessian | ( | double | ax, |
double | ay, | ||
double | az, | ||
double | bx, | ||
double | by, | ||
double | bz, | ||
double | cx, | ||
double | cy, | ||
double | cz, | ||
double | dx, | ||
double | dy, | ||
double | dz, | ||
double | H[144] | ||
) |
Compute the gradient of the signed area of a 2D triangle defined by three points.
ax | First point's x coordinate. |
ay | First point's y coordinate. |
ay | First point's z coordinate. |
bx | Second point's x coordinate. |
by | Second point's y coordinate. |
by | Second point's z coordinate. |
cx | Third point's x coordinate. |
cy | Third point's y coordinate. |
cy | Third point's z coordinate. |
dx | Fourth point's x coordinate. |
dy | Fourth point's y coordinate. |
dy | Fourth point's z coordinate. |
g | Output flattened Hessian with respect to the four points. |
Definition at line 295 of file GeometryUtils.cpp.
Referenced by polyfem::solver::InversionBarrierForm::element_volume_hessian().
Eigen::Matrix3d polyfem::utils::to_rotation_matrix | ( | const json & | jr, |
std::string | mode | ||
) |
Definition at line 61 of file JSONUtils.cpp.
References deg2rad().
Referenced by polyfem::mesh::construct_affine_transformation().
double polyfem::utils::triangle_area | ( | const Eigen::MatrixXd | V | ) |
Compute the signed area of a triangle defined by three points.
V | The vertices of the triangle as rows of a matrix. |
Definition at line 30 of file GeometryUtils.cpp.
References triangle_area_2D(), triangle_area_3D(), and V.
Referenced by polyfem::assembler::MassMatrixAssembler::assemble_cross(), polyfem::solver::InversionBarrierForm::element_volume(), polyfem::mesh::irregular_triangle(), and triangle_to_clockwise_order().
double polyfem::utils::triangle_area_2D | ( | const Eigen::Vector2d & | a, |
const Eigen::Vector2d & | b, | ||
const Eigen::Vector2d & | c | ||
) |
Compute the signed area of a 2D triangle defined by three points.
a | First point of the triangle. |
b | Second point of the triangle. |
c | Third point of the triangle. |
Definition at line 14 of file GeometryUtils.cpp.
Referenced by polyfem::mesh::WildRemesher< WMTKMesh >::swap_edge_before(), and triangle_area().
void polyfem::utils::triangle_area_2D_gradient | ( | double | ax, |
double | ay, | ||
double | bx, | ||
double | by, | ||
double | cx, | ||
double | cy, | ||
double | g[6] | ||
) |
Compute the gradient of the signed area of a 2D triangle defined by three points.
ax | First point's x coordinate. |
ay | First point's y coordinate. |
bx | Second point's x coordinate. |
by | Second point's y coordinate. |
cx | Third point's x coordinate. |
cy | Third point's y coordinate. |
g | Output gradient with respect to the three points. |
Definition at line 209 of file GeometryUtils.cpp.
Referenced by polyfem::solver::InversionBarrierForm::element_volume_gradient().
void polyfem::utils::triangle_area_2D_hessian | ( | double | ax, |
double | ay, | ||
double | bx, | ||
double | by, | ||
double | cx, | ||
double | cy, | ||
double | H[36] | ||
) |
Compute the Hessian of the signed area of a 2D triangle defined by three points.
ax | First point's x coordinate. |
ay | First point's y coordinate. |
bx | Second point's x coordinate. |
by | Second point's y coordinate. |
cx | Third point's x coordinate. |
cy | Third point's y coordinate. |
g | Output flattened Hessian with respect to the three points. |
Definition at line 221 of file GeometryUtils.cpp.
Referenced by polyfem::solver::InversionBarrierForm::element_volume_hessian().
double polyfem::utils::triangle_area_3D | ( | const Eigen::Vector3d & | a, |
const Eigen::Vector3d & | b, | ||
const Eigen::Vector3d & | c | ||
) |
Compute the area of a 3D triangle defined by three points.
a | First point of the triangle. |
b | Second point of the triangle. |
c | Third point of the triangle. |
Definition at line 22 of file GeometryUtils.cpp.
Referenced by triangle_area().
std::vector< Eigen::MatrixXd > polyfem::utils::triangle_fan | ( | const Eigen::MatrixXd & | convex_polygon | ) |
Convert a convex polygon to a list of triangles fanned around the first vertex.
convex_polygon | The vertices of the convex polygon as rows of a matrix. |
Definition at line 74 of file GeometryUtils.cpp.
Referenced by polyfem::utils::TriangleClipping::clip().
bool polyfem::utils::triangle_intersects_disk | ( | const Eigen::Vector2d & | t0, |
const Eigen::Vector2d & | t1, | ||
const Eigen::Vector2d & | t2, | ||
const Eigen::Vector2d & | center, | ||
const double | radius | ||
) |
Determine if a 2D triangle intersects a 2D disk.
t0 | Triangle first vertex. |
t1 | Triangle second vertex. |
t2 | Triangle third vertex. |
center | Center of the disk. |
radius | Radius of the disk. |
Definition at line 107 of file GeometryUtils.cpp.
Referenced by polyfem::mesh::LocalMesh< M >::ball_selection().
Eigen::MatrixXd polyfem::utils::triangle_to_clockwise_order | ( | const Eigen::MatrixXd & | triangle | ) |
Reorder the vertices of a triangle so they are in clockwise order.
triangle | The vertices of the triangle as rows of a matrix. |
Definition at line 58 of file GeometryUtils.cpp.
References triangle_area().
Referenced by polyfem::utils::TriangleClipping::clip().
Eigen::MatrixXd polyfem::utils::unflatten | ( | const Eigen::VectorXd & | x, |
int | dim | ||
) |
Unflatten rowwises, so every dim elements in x become a row.
Definition at line 53 of file MatrixUtils.cpp.
References x.
Referenced by polyfem::solver::PeriodicMeshToMesh::apply_jacobian(), polyfem::solver::ProxyContactForceForm::compute_adjoint_rhs_step(), polyfem::solver::ContactForm::compute_displaced_surface(), polyfem::State::compute_force_jacobian_prev(), polyfem::solver::CollisionBarrierForm::compute_partial_gradient(), polyfem::solver::DeformedCollisionBarrierForm::compute_partial_gradient(), polyfem::solver::SpatialIntegralForm::compute_partial_gradient_step(), polyfem::solver::ProxyContactForceForm::compute_partial_gradient_step(), polyfem::solver::FrictionForm::compute_surface_velocities(), polyfem::mesh::constrained_L2_projection(), polyfem::solver::PeriodicMeshToMesh::eval(), polyfem::solver::BSplineParametrization1DTo2D::eval(), polyfem::io::OutGeometryData::export_data(), polyfem::solver::InversionBarrierForm::first_derivative_unweighted(), polyfem::solver::PeriodicContactForm::force_periodic_shape_derivative(), polyfem::solver::FrictionForm::force_shape_derivative(), polyfem::solver::ElasticEnergyForm::get_integral_functional(), polyfem::utils::PiecewiseCubicInterpolation::init(), polyfem::State::init_nonlinear_tensor_solve(), polyfem::solver::PeriodicMeshToMesh::inverse_eval(), polyfem::solver::BSplineParametrization1DTo2D::inverse_eval(), polyfem::solver::BoundedBiharmonicWeights2Dto3D::inverse_eval(), polyfem::solver::CollisionBarrierForm::is_step_collision_free(), polyfem::solver::AMIPSForm::is_step_valid(), polyfem::solver::InversionBarrierForm::is_step_valid(), polyfem::solver::AdjointNLProblem::is_step_valid(), polyfem::solver::CollisionBarrierForm::max_step_size(), polyfem::solver::NLHomoProblem::reduced_to_disp_grad(), polyfem::solver::NLHomoProblem::reduced_to_full(), polyfem::State::remesh(), polyfem::io::OutGeometryData::save_contact_surface(), polyfem::io::OutGeometryData::save_volume(), polyfem::io::OutGeometryData::save_volume_vector_field(), polyfem::solver::InversionBarrierForm::second_derivative_unweighted(), polyfem::solver::CollisionBarrierForm::solution_changed(), polyfem::solver::DeformedCollisionBarrierForm::solution_changed(), polyfem::State::solve_homogenization(), polyfem::State::solve_homogenization_step(), polyfem::solver::PeriodicShapeVariableToSimulation::update(), polyfem::solver::CollisionBarrierForm::value_unweighted(), polyfem::solver::DeformedCollisionBarrierForm::value_unweighted(), polyfem::solver::InversionBarrierForm::value_unweighted(), polyfem::solver::ProxyContactForceForm::value_unweighted_step(), vector2matrix(), polyfem::mesh::Remesher::write_mesh(), and polyfem::mesh::LocalMesh< M >::write_mesh().
Eigen::MatrixXd polyfem::utils::unreorder_matrix | ( | const Eigen::MatrixXd & | out, |
const Eigen::VectorXi & | in_to_out, | ||
int | in_blocks = -1 , |
||
const int | block_size = 1 |
||
) |
Undo the reordering of row blocks in a matrix.
out | Reordered matrix. |
in_to_out | Mapping from input blocks to output blocks. |
in_blocks | Number of blocks in the input matrix. |
block_size | Size of each block. |
Definition at line 193 of file MatrixUtils.cpp.
Referenced by polyfem::mesh::Remesher::project_quantities().
void polyfem::utils::vector2matrix | ( | const Eigen::VectorXd & | vec, |
Eigen::MatrixXd & | mat | ||
) |
Definition at line 69 of file MatrixUtils.cpp.
References unflatten(), and vec.
Referenced by polyfem::solver::ComplianceForm::compute_partial_gradient_step(), polyfem::solver::AdjointTools::compute_shape_derivative_functional_term(), polyfem::solver::StressNormForm::get_integral_functional(), polyfem::solver::ComplianceForm::get_integral_functional(), and polyfem::solver::StressForm::get_integral_functional().