PolyFEM
Loading...
Searching...
No Matches
polyfem::io::OutGeometryData Class Reference

Utilies related to export of geometry. More...

#include <OutData.hpp>

Collaboration diagram for polyfem::io::OutGeometryData:
[legend]

Classes

struct  ExportOptions
 different export flags More...
 

Public Member Functions

void init_sampler (const polyfem::mesh::Mesh &mesh, const double vismesh_rel_area)
 unitalize the ref element sampler
 
void build_grid (const polyfem::mesh::Mesh &mesh, const double spacing)
 builds the grid to export the solution
 
void export_data (const OutputSpace &space, const OutputFieldFunction &output_fields, const bool is_time_dependent, const double tend_in, const double dt, const ExportOptions &opts, const std::string &vis_mesh_path) const
 exports everytihng, txt, vtu, etc
 
void save_vtu (const std::string &path, const OutputSpace &space, const OutputFieldFunction &output_fields, const double t, const double dt, const ExportOptions &opts) const
 saves the vtu file for time t
 
void save_volume (const std::string &path, const OutputSpace &space, const OutputFieldFunction &output_fields, const double t, const double dt, const ExportOptions &opts) const
 saves the volume vtu file
 
void save_surface (const std::string &export_surface, const OutputSpace &space, const OutputFieldFunction &output_fields, const double t, const double dt_in, const ExportOptions &opts) const
 saves the surface vtu file for for surface quantites, eg traction forces
 
void save_contact_surface (const std::string &export_surface, const OutputSpace &space, const OutputFieldFunction &output_fields, const double t, const double dt_in, const ExportOptions &opts) const
 saves the surface vtu file for for constact quantites, eg contact or friction forces
 
void save_wire (const std::string &name, const OutputSpace &space, const OutputFieldFunction &output_fields, const double t, const ExportOptions &opts) const
 saves the wireframe
 
void save_points (const std::string &path, const OutputSpace &space, const OutputFieldFunction &output_fields, const ExportOptions &opts) const
 saves the nodal values
 
void save_pvd (const std::string &name, const std::function< std::string(int)> &vtu_names, int time_steps, double t0, double dt, int skip_frame=1) const
 save a PVD of a time dependent simulation
 

Static Public Member Functions

static void extract_boundary_mesh (const mesh::Mesh &mesh, const int n_bases, const std::vector< basis::ElementBases > &bases, const std::vector< mesh::LocalBoundary > &total_local_boundary, Eigen::MatrixXd &node_positions, Eigen::MatrixXi &boundary_edges, Eigen::MatrixXi &boundary_triangles, std::vector< Eigen::Triplet< double > > &displacement_map_entries)
 extracts the boundary mesh
 

Private Member Functions

void build_vis_boundary_mesh (const mesh::Mesh &mesh, const std::vector< basis::ElementBases > &gbases, const std::vector< mesh::LocalBoundary > &total_local_boundary, Eigen::MatrixXd &boundary_vis_vertices, Eigen::MatrixXd &boundary_vis_local_vertices, Eigen::MatrixXi &boundary_vis_elements, Eigen::MatrixXi &boundary_vis_elements_ids, Eigen::MatrixXi &boundary_vis_primitive_ids, Eigen::MatrixXd &boundary_vis_normals) const
 builds the boundary mesh for visualization
 
void build_vis_mesh (const mesh::Mesh &mesh, const Eigen::VectorXi &disc_orders, const std::vector< basis::ElementBases > &gbases, const std::map< int, Eigen::MatrixXd > &polys, const std::map< int, std::pair< Eigen::MatrixXd, Eigen::MatrixXi > > &polys_3d, const bool boundary_only, Eigen::MatrixXd &points, Eigen::MatrixXi &tets, Eigen::MatrixXi &el_id, Eigen::MatrixXd &discr, Eigen::MatrixXd &local_points) const
 builds visualzation mesh, upsampled mesh used for visualization the visualization mesh is a dense mesh per element all disconnected it also retuns the mapping to element id and discretization of every elment works in 2 and 3d.
 
void build_high_order_vis_mesh (const mesh::Mesh &mesh, const Eigen::VectorXi &output_orders, const std::vector< basis::ElementBases > &bases, Eigen::MatrixXd &points, std::vector< paraviewo::CellElement > &elements, Eigen::MatrixXi &el_id, Eigen::MatrixXd &discr, Eigen::MatrixXd &local_points) const
 builds high-der visualzation mesh per element all disconnected it also retuns the mapping to element id and discretization of every elment works in 2 and 3d.
 

Private Attributes

utils::RefElementSampler ref_element_sampler
 used to sample the solution
 
Eigen::MatrixXd grid_points
 grid mesh points to export solution sampled on a grid
 
Eigen::MatrixXi grid_points_to_elements
 grid mesh mapping to fe elements
 
Eigen::MatrixXd grid_points_bc
 grid mesh boundaries
 

Detailed Description

Utilies related to export of geometry.

Definition at line 23 of file OutData.hpp.

Member Function Documentation

◆ build_grid()

void polyfem::io::OutGeometryData::build_grid ( const polyfem::mesh::Mesh mesh,
const double  spacing 
)

builds the grid to export the solution

Parameters
[in]meshmesh
[in]spacinggrid spacing, <=0 mean no grid

Definition at line 1630 of file OutData.cpp.

References polyfem::mesh::Mesh::barycentric_coords(), polyfem::mesh::Mesh::bounding_box(), polyfem::mesh::Mesh::elements_boxes(), grid_points, grid_points_bc, grid_points_to_elements, polyfem::mesh::Mesh::is_simplex(), polyfem::mesh::Mesh::is_volume(), polyfem::logger(), x, y, and z.

Referenced by polyfem::varform::VarForm::ensure_output_sampler().

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

◆ build_high_order_vis_mesh()

void polyfem::io::OutGeometryData::build_high_order_vis_mesh ( const mesh::Mesh mesh,
const Eigen::VectorXi &  output_orders,
const std::vector< basis::ElementBases > &  bases,
Eigen::MatrixXd &  points,
std::vector< paraviewo::CellElement > &  elements,
Eigen::MatrixXi &  el_id,
Eigen::MatrixXd &  discr,
Eigen::MatrixXd &  local_points 
) const
private

builds high-der visualzation mesh per element all disconnected it also retuns the mapping to element id and discretization of every elment works in 2 and 3d.

if the mesh is not simplicial it gets tri/tet halized

Parameters
[in]meshmesh
[in]output_ordersoutput cell order per element
[in]basesbases used to map output reference nodes
[out]pointsmesh points
[out]elementsmesh high-order cells
[out]el_idmapping from points to elements id
[out]discrmapping from points to discretization order

Referenced by save_volume().

Here is the caller graph for this function:

◆ build_vis_boundary_mesh()

void polyfem::io::OutGeometryData::build_vis_boundary_mesh ( const mesh::Mesh mesh,
const std::vector< basis::ElementBases > &  gbases,
const std::vector< mesh::LocalBoundary > &  total_local_boundary,
Eigen::MatrixXd &  boundary_vis_vertices,
Eigen::MatrixXd &  boundary_vis_local_vertices,
Eigen::MatrixXi &  boundary_vis_elements,
Eigen::MatrixXi &  boundary_vis_elements_ids,
Eigen::MatrixXi &  boundary_vis_primitive_ids,
Eigen::MatrixXd &  boundary_vis_normals 
) const
private

builds the boundary mesh for visualization

Parameters
[in]meshmesh
[in]gbasesgeometric bases
[in]total_local_boundaryboundaries
[out]boundary_vis_verticesboundary visualization mesh vertices
[out]boundary_vis_local_verticesboundary visualization mesh vertices pre image in ref element
[out]boundary_vis_elementsboundary visualization mesh connectivity
[out]boundary_vis_elements_idsboundary visualization mesh elements ids
[out]boundary_vis_primitive_idsboundary visualization mesh edge/face id
[out]boundary_vis_normalsboundary visualization mesh normals

Definition at line 495 of file OutData.cpp.

References polyfem::mesh::Mesh::is_volume(), polyfem::utils::BoundarySampler::normal_for_polygon_edge(), polyfem::utils::BoundarySampler::normal_for_prism_face(), polyfem::utils::BoundarySampler::normal_for_pyramid_face(), polyfem::utils::BoundarySampler::normal_for_quad_edge(), polyfem::utils::BoundarySampler::normal_for_quad_face(), polyfem::utils::BoundarySampler::normal_for_tri_edge(), polyfem::utils::BoundarySampler::normal_for_tri_face(), polyfem::utils::RefElementSampler::num_samples(), ref_element_sampler, polyfem::utils::BoundarySampler::sample_parametric_prism_face(), polyfem::utils::BoundarySampler::sample_parametric_pyramid_face(), polyfem::utils::BoundarySampler::sample_parametric_quad_edge(), polyfem::utils::BoundarySampler::sample_parametric_quad_face(), polyfem::utils::BoundarySampler::sample_parametric_tri_edge(), polyfem::utils::BoundarySampler::sample_parametric_tri_face(), polyfem::utils::BoundarySampler::sample_polygon_edge(), and vals.

Referenced by save_surface().

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

◆ build_vis_mesh()

void polyfem::io::OutGeometryData::build_vis_mesh ( const mesh::Mesh mesh,
const Eigen::VectorXi &  disc_orders,
const std::vector< basis::ElementBases > &  gbases,
const std::map< int, Eigen::MatrixXd > &  polys,
const std::map< int, std::pair< Eigen::MatrixXd, Eigen::MatrixXi > > &  polys_3d,
const bool  boundary_only,
Eigen::MatrixXd &  points,
Eigen::MatrixXi &  tets,
Eigen::MatrixXi &  el_id,
Eigen::MatrixXd &  discr,
Eigen::MatrixXd &  local_points 
) const
private

builds visualzation mesh, upsampled mesh used for visualization the visualization mesh is a dense mesh per element all disconnected it also retuns the mapping to element id and discretization of every elment works in 2 and 3d.

if the mesh is not simplicial it gets tri/tet halized

Parameters
[in]meshmesh
[in]disc_ordersdiscretization orders
[in]gbasesgeometric bases
[in]polyspolygons
[in]polys_3dpolyhedra
[in]boundary_onlyis build only elements touching the boundary
[out]pointsmesh points
[out]tetsmesh cells
[out]el_idmapping from points to elements id
[out]discrmapping from points to discretization order

Definition at line 721 of file OutData.cpp.

References polyfem::mesh::Mesh::dimension(), polyfem::mesh::Mesh::is_boundary_element(), polyfem::mesh::Mesh::is_cube(), polyfem::mesh::Mesh::is_prism(), polyfem::mesh::Mesh::is_pyramid(), polyfem::mesh::Mesh::is_simplex(), polyfem::mesh::Mesh::is_volume(), ref_element_sampler, and polyfem::utils::RefElementSampler::simplex_volume().

Referenced by save_volume(), and save_wire().

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

◆ export_data()

void polyfem::io::OutGeometryData::export_data ( const OutputSpace space,
const OutputFieldFunction output_fields,
const bool  is_time_dependent,
const double  tend_in,
const double  dt,
const ExportOptions opts,
const std::string &  vis_mesh_path 
) const

exports everytihng, txt, vtu, etc

Parameters
[in]spaceoutput geometry data
[in]output_fieldscallback appending physics-specific fields
[in]is_time_dependentif the sim is time dependent
[in]tend_inend time
[in]dtdelta t
[in]optsexport options
[in]vis_mesh_pathvtu path

Definition at line 1124 of file OutData.cpp.

References polyfem::logger(), polyfem::io::OutputSpace::mesh, and save_vtu().

Referenced by polyfem::varform::BilaplacianVarForm::export_data(), polyfem::varform::FluidVarForm::export_data(), and polyfem::varform::ScalarVarForm::export_data().

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

◆ extract_boundary_mesh()

void polyfem::io::OutGeometryData::extract_boundary_mesh ( const mesh::Mesh mesh,
const int  n_bases,
const std::vector< basis::ElementBases > &  bases,
const std::vector< mesh::LocalBoundary > &  total_local_boundary,
Eigen::MatrixXd &  node_positions,
Eigen::MatrixXi &  boundary_edges,
Eigen::MatrixXi &  boundary_triangles,
std::vector< Eigen::Triplet< double > > &  displacement_map_entries 
)
static

extracts the boundary mesh

Parameters
[in]meshmesh
[in]n_basesnumber of bases
[in]basesbases
[in]total_local_boundarymesh boundaries
[out]node_positionsnodes positions
[out]boundary_edgesedges
[out]boundary_trianglestriangles
[out]displacement_mapmap of collision mesh vertices to nodes, empty if identity

Definition at line 95 of file OutData.cpp.

References polyfem::basis::Basis::global(), polyfem::mesh::Mesh::has_poly(), polyfem::mesh::Mesh::is_conforming(), polyfem::mesh::Mesh::is_cube(), polyfem::mesh::Mesh::is_prism(), polyfem::mesh::Mesh::is_pyramid(), polyfem::mesh::Mesh::is_simplex(), polyfem::mesh::Mesh::is_simplicial(), polyfem::mesh::Mesh::is_volume(), polyfem::logger(), and polyfem::mesh::Mesh::n_faces().

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

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

◆ init_sampler()

void polyfem::io::OutGeometryData::init_sampler ( const polyfem::mesh::Mesh mesh,
const double  vismesh_rel_area 
)

unitalize the ref element sampler

Parameters
[in]meshmesh
[in]vismesh_rel_arearelative sampling size

Definition at line 1625 of file OutData.cpp.

References polyfem::utils::RefElementSampler::init(), polyfem::mesh::Mesh::is_volume(), polyfem::mesh::Mesh::n_elements(), and ref_element_sampler.

Referenced by polyfem::varform::VarForm::ensure_output_sampler().

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

◆ save_contact_surface()

void polyfem::io::OutGeometryData::save_contact_surface ( const std::string &  export_surface,
const OutputSpace space,
const OutputFieldFunction output_fields,
const double  t,
const double  dt_in,
const ExportOptions opts 
) const

saves the surface vtu file for for constact quantites, eg contact or friction forces

Parameters
[in]export_surfacefilename
[in]spaceoutput geometry data
[in]output_fieldscallback appending physics-specific fields
[in]ttime
[in]dt_indelta_t
[in]optsexport options

Definition at line 1472 of file OutData.cpp.

References polyfem::io::OutputSample::cell_count, polyfem::io::OutputSpace::collision_mesh, polyfem::io::OutputSample::Contact, polyfem::io::OutputSample::domain, polyfem::io::OutputSample::dt, polyfem::io::OutputSample::points, polyfem::io::OutputSample::time, and polyfem::io::OutGeometryData::ExportOptions::use_hdf5.

Referenced by save_vtu().

Here is the caller graph for this function:

◆ save_points()

void polyfem::io::OutGeometryData::save_points ( const std::string &  path,
const OutputSpace space,
const OutputFieldFunction output_fields,
const ExportOptions opts 
) const

saves the nodal values

Parameters
[in]pathfilename
[in]spaceoutput geometry data
[in]output_fieldscallback appending physics-specific fields
[in]optsexport options

Definition at line 1563 of file OutData.cpp.

References polyfem::io::OutputSample::cell_count, polyfem::mesh::Mesh::dimension(), polyfem::io::OutputSpace::dirichlet_nodes, polyfem::io::OutputSpace::dirichlet_nodes_position, polyfem::io::OutputSample::domain, polyfem::io::OutGeometryData::ExportOptions::export_field(), polyfem::mesh::Mesh::get_node_id(), polyfem::io::OutputSpace::mesh, polyfem::io::OutputSample::node_ids, polyfem::io::OutputSample::Points, polyfem::io::OutputSample::points, and polyfem::io::OutGeometryData::ExportOptions::use_hdf5.

Referenced by save_vtu().

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

◆ save_pvd()

void polyfem::io::OutGeometryData::save_pvd ( const std::string &  name,
const std::function< std::string(int)> &  vtu_names,
int  time_steps,
double  t0,
double  dt,
int  skip_frame = 1 
) const

save a PVD of a time dependent simulation

Parameters
[in]namefilename
[in]vtu_namesnames of the vtu files
[in]time_stepstotal time stesp
[in]t0initial time
[in]dtdelta t
[in]skip_frameevery which frame to skip

Definition at line 1617 of file OutData.cpp.

Referenced by polyfem::varform::VarForm::save_timestep().

Here is the caller graph for this function:

◆ save_surface()

void polyfem::io::OutGeometryData::save_surface ( const std::string &  export_surface,
const OutputSpace space,
const OutputFieldFunction output_fields,
const double  t,
const double  dt_in,
const ExportOptions opts 
) const

saves the surface vtu file for for surface quantites, eg traction forces

Parameters
[in]export_surfacefilename
[in]spaceoutput geometry data
[in]output_fieldscallback appending physics-specific fields
[in]ttime
[in]dt_indelta_t
[in]optsexport options

Definition at line 1401 of file OutData.cpp.

References build_vis_boundary_mesh(), polyfem::io::OutputSample::cell_count, polyfem::io::OutputSample::domain, polyfem::io::OutputSample::dt, polyfem::io::OutputSample::element_ids, polyfem::io::OutGeometryData::ExportOptions::export_field(), polyfem::io::OutputSpace::geometry_bases, polyfem::mesh::Mesh::get_boundary_id(), polyfem::mesh::Mesh::is_volume(), polyfem::io::OutputSample::local_points, polyfem::io::OutputSpace::mesh, polyfem::mesh::Mesh::n_elements(), polyfem::io::OutputSample::normals, polyfem::io::OutputSpace::output_orders, polyfem::io::OutputSample::points, polyfem::io::OutputSample::primitive_ids, polyfem::io::OutputSample::Surface, polyfem::io::OutputSample::time, polyfem::io::OutputSpace::total_local_boundary, and polyfem::io::OutGeometryData::ExportOptions::use_hdf5.

Referenced by save_vtu().

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

◆ save_volume()

void polyfem::io::OutGeometryData::save_volume ( const std::string &  path,
const OutputSpace space,
const OutputFieldFunction output_fields,
const double  t,
const double  dt,
const ExportOptions opts 
) const

saves the volume vtu file

Parameters
[in]pathfilename
[in]spaceoutput geometry data
[in]output_fieldscallback appending physics-specific fields
[in]ttime
[in]dtdelta t
[in]optsexport options

Definition at line 1248 of file OutData.cpp.

References polyfem::io::OutGeometryData::ExportOptions::boundary_only, build_high_order_vis_mesh(), build_vis_mesh(), polyfem::io::OutputSample::cell_count, polyfem::mesh::Mesh::dimension(), polyfem::io::OutGeometryData::ExportOptions::discretization_order, polyfem::io::OutputSample::domain, polyfem::io::OutputSample::dt, polyfem::io::OutputSample::element_ids, polyfem::io::OutGeometryData::ExportOptions::export_field(), polyfem::io::OutputSpace::geometry_bases, polyfem::mesh::Obstacle::get_edge_connectivity(), polyfem::mesh::Obstacle::get_face_connectivity(), polyfem::mesh::Obstacle::get_vertex_connectivity(), polyfem::io::OutputSample::Grid, grid_points, grid_points_bc, grid_points_to_elements, polyfem::mesh::Mesh::is_volume(), polyfem::io::OutputSample::local_points, polyfem::io::OutputSpace::mesh, polyfem::mesh::Mesh::n_elements(), polyfem::mesh::Obstacle::n_vertices(), polyfem::io::OutputSpace::obstacle, polyfem::io::OutputSpace::output_orders, polyfem::io::OutputField::Point, polyfem::io::OutputSample::points, polyfem::io::OutputSpace::polys, polyfem::io::OutputSpace::polys_3d, polyfem::io::OutputSample::requested_fields, polyfem::io::OutGeometryData::ExportOptions::sol_on_grid, polyfem::io::OutputSample::time, polyfem::io::OutGeometryData::ExportOptions::use_hdf5, polyfem::io::OutGeometryData::ExportOptions::use_sampler, polyfem::mesh::Obstacle::v(), polyfem::io::OutputSample::Volume, and polyfem::io::write_matrix().

Referenced by save_vtu().

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

◆ save_vtu()

void polyfem::io::OutGeometryData::save_vtu ( const std::string &  path,
const OutputSpace space,
const OutputFieldFunction output_fields,
const double  t,
const double  dt,
const ExportOptions opts 
) const

◆ save_wire()

void polyfem::io::OutGeometryData::save_wire ( const std::string &  name,
const OutputSpace space,
const OutputFieldFunction output_fields,
const double  t,
const ExportOptions opts 
) const

saves the wireframe

Parameters
[in]namefilename
[in]spaceoutput geometry data
[in]output_fieldscallback appending physics-specific fields
[in]ttime
[in]optsexport options

Definition at line 1512 of file OutData.cpp.

References build_vis_mesh(), polyfem::io::OutputSample::cell_count, polyfem::io::OutputSample::domain, polyfem::io::OutputSample::element_ids, polyfem::io::OutputSpace::geometry_bases, polyfem::io::OutputSample::local_points, polyfem::io::OutputSpace::mesh, polyfem::mesh::Mesh::n_elements(), polyfem::io::OutputSpace::output_orders, polyfem::io::OutputSample::points, polyfem::io::OutputSpace::polys, polyfem::io::OutputSpace::polys_3d, polyfem::io::OutputSample::time, polyfem::io::OutGeometryData::ExportOptions::use_hdf5, and polyfem::io::OutputSample::Wire.

Referenced by save_vtu().

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

Member Data Documentation

◆ grid_points

Eigen::MatrixXd polyfem::io::OutGeometryData::grid_points
private

grid mesh points to export solution sampled on a grid

Definition at line 209 of file OutData.hpp.

Referenced by build_grid(), and save_volume().

◆ grid_points_bc

Eigen::MatrixXd polyfem::io::OutGeometryData::grid_points_bc
private

grid mesh boundaries

Definition at line 213 of file OutData.hpp.

Referenced by build_grid(), and save_volume().

◆ grid_points_to_elements

Eigen::MatrixXi polyfem::io::OutGeometryData::grid_points_to_elements
private

grid mesh mapping to fe elements

Definition at line 211 of file OutData.hpp.

Referenced by build_grid(), and save_volume().

◆ ref_element_sampler

utils::RefElementSampler polyfem::io::OutGeometryData::ref_element_sampler
private

used to sample the solution

Definition at line 206 of file OutData.hpp.

Referenced by build_vis_boundary_mesh(), build_vis_mesh(), and init_sampler().


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