20 using namespace basis;
22 using namespace utils;
43 void State::load_mesh(GEO::Mesh &meshin,
const std::function<
int(
const size_t,
const std::vector<int> &,
const RowVectorNd &,
bool)> &boundary_marker,
bool non_conforming,
bool skip_boundary_sideset)
49 logger().info(
"Loading mesh...");
53 logger().error(
"Unable to load the mesh");
58 mesh->bounding_box(min, max);
60 logger().info(
"mesh bb min [{}], max [{}]", min, max);
62 if (!skip_boundary_sideset)
63 mesh->compute_boundary_ids(boundary_marker);
65 std::vector<std::shared_ptr<assembler::Assembler>> assemblers;
76 logger().info(
" took {}s", timer.getElapsedTime());
79 logger().info(
"Loading obstacles...");
89 logger().info(
" took {}s", timer.getElapsedTime());
95 const std::vector<std::string> &names,
96 const std::vector<Eigen::MatrixXi> &cells,
97 const std::vector<Eigen::MatrixXd> &vertices)
99 assert(names.size() == cells.size());
100 assert(vertices.size() == cells.size());
101 assert(names.empty());
102 assert(cells.empty());
103 assert(vertices.empty());
110 logger().info(
"Loading mesh ...");
132 mesh->bounding_box(min, max);
134 if (
args[
"solver"][
"advanced"][
"characteristic_length"] > 0)
143 logger().info(
"mesh bb min [{}], max [{}]", min, max);
145 std::vector<std::shared_ptr<assembler::Assembler>> assemblers;
157 logger().info(
" took {}s", timer.getElapsedTime());
162 logger().info(
"Loading obstacles...");
167 mesh->dimension(), non_conforming);
169 logger().info(
" took {}s", timer.getElapsedTime());
174 assert(
bases.size() ==
mesh->n_elements());
176 const int dim =
mesh->dimension();
178 V.resize(n_vertices, dim);
179 F.resize(
bases.size(), dim + 1);
181 for (
int i = 0; i <
bases.size(); i++)
184 for (
int j = 0; j < element.
bases.size(); j++)
187 assert(basis.global().size() == 1);
188 V.row(basis.global()[0].index) = basis.global()[0].node;
190 F(i, j) = basis.global()[0].index;
195 std::unordered_map<int, std::array<bool, 3>>
198 assert(
args[
"boundary_conditions"].contains(bc_type));
199 const std::vector<json> json_bcs =
json_as_array(
args[
"boundary_conditions"][bc_type]);
200 std::unordered_map<int, std::array<bool, 3>> bcs;
201 for (
const json &bc : json_bcs)
203 assert(bc[
"dimension"].size() >=
mesh->dimension());
204 std::array<bool, 3> dimension{{
true,
true,
true}};
205 for (
int d = 0; d < bc[
"dimension"].size(); ++d)
206 dimension[d] = bc[
"dimension"][d];
208 assert(bc.contains(
"id") && bc[
"id"].is_number_integer());
209 bcs[bc[
"id"].get<
int>()] = dimension;
Represents one basis function and its gradient.
Stores the basis functions for a given element in a mesh (facet in 2d, cell in 3d).
std::vector< Basis > bases
one basis function per node in the element
void reset_mesh()
Resets the mesh.
StiffnessMatrix mass
Mass matrix, it is computed only for time dependent problems.
std::unordered_map< int, std::array< bool, 3 > > boundary_conditions_ids(const std::string &bc_type) const
Construct a vector of boundary conditions ids with their dimension flags.
std::vector< mesh::LocalBoundary > local_boundary
mapping from elements to nodes for dirichlet boundary conditions
std::shared_ptr< assembler::Mass > mass_matrix_assembler
std::unique_ptr< mesh::Mesh > mesh
current mesh, it can be a Mesh2D or Mesh3D
Eigen::MatrixXd rhs
System right-hand side.
void build_mesh_matrices(Eigen::MatrixXd &V, Eigen::MatrixXi &F)
Build the mesh matrices (vertices and elements) from the mesh using the bases node ordering.
json args
main input arguments containing all defaults
std::vector< basis::ElementBases > geom_bases_
Geometric mapping bases, if the elements are isoparametric, this list is empty.
void load_mesh(bool non_conforming=false, const std::vector< std::string > &names=std::vector< std::string >(), const std::vector< Eigen::MatrixXi > &cells=std::vector< Eigen::MatrixXi >(), const std::vector< Eigen::MatrixXd > &vertices=std::vector< Eigen::MatrixXd >())
loads the mesh from the json arguments
std::map< int, Eigen::MatrixXd > polys
polygons, used since poly have no geom mapping
int n_pressure_bases
number of pressure bases
int n_bases
number of bases
std::vector< basis::ElementBases > pressure_bases
FE pressure bases for mixed elements, the size is #elements.
mesh::Obstacle obstacle
Obstacles used in collisions.
std::shared_ptr< assembler::Assembler > pressure_assembler
io::OutGeometryData out_geom
visualization stuff
double characteristic_length
std::shared_ptr< assembler::Assembler > assembler
assemblers
std::map< int, basis::InterfaceData > poly_edge_to_data
nodes on the boundary of polygonal elements, used for harmonic bases
void set_materials(std::vector< std::shared_ptr< assembler::Assembler > > &assemblers) const
set the material and the problem dimension
std::vector< basis::ElementBases > bases
FE bases, the size is #elements.
std::shared_ptr< assembler::HRZMass > pure_mass_matrix_assembler
std::vector< mesh::LocalBoundary > local_neumann_boundary
mapping from elements to nodes for neumann boundary conditions
std::vector< int > boundary_nodes
list of boundary nodes
std::shared_ptr< assembler::MixedAssembler > mixed_assembler
void init_sampler(const polyfem::mesh::Mesh &mesh, const double vismesh_rel_area)
unitalize the ref element sampler
Applies geometry JSON semantics while delegating all decoding to MeshLoader.
std::unique_ptr< Mesh > load_fem(const json &geometry, bool non_conforming=false) const
Load and combine the enabled FEM entries in a geometry configuration.
Obstacle load_obstacles(const json &geometry, const std::vector< json > &obstacle_displacements, const std::vector< json > &dirichlet_conditions, int dimension, bool non_conforming=false) const
static std::unique_ptr< Mesh > create(MeshData data, bool non_conforming=false)
Construct a runtime mesh from format-independent decoded data.
static MeshData from_geogram(GEO::Mesh &mesh)
std::vector< T > json_as_array(const json &j)
Return the value of a json object as an array.
bool is_param_valid(const json ¶ms, const std::string &key)
Determine if a key exists and is non-null in a json object.
spdlog::logger & logger()
Retrieves the current logger.
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
void log_and_throw_error(const std::string &msg)