193 std::vector<std::array<double, 2>>
vertices;
194 std::vector<std::vector<size_t>>
cells;
201 std::unique_ptr<Mesh> mesh = std::make_unique<Mesh>();
202 std::cout <<
"[MeshBuilder] ";
209 mesh->add_vertex(vertex);
218 for (
size_t i = 0;
i <
c.size();
i++)
229 mesh->add_cell(cell);
238 for (
size_t j = 0;
j <
vlist.size();
j++)
245 cell->add_edge(edge);
246 edge->add_cell(cell);
256 Edge *edge =
new Edge(mesh->n_edges(),
Simplex<1>({vertex_coords[i], vertex_coords[i_next]}));
258 mesh->add_edge(edge);
259 cell->add_edge(edge);
260 edge->add_cell(cell);
276 cell->construct_face_normals();
280 build_boundary(mesh.get());
281 std::cout <<
"added " << mesh->n_cells() <<
" cells; Total area = " <<
total_area <<
"\n";
287 throw "Cannot build mesh. Check input file";
293 void build_boundary(Mesh *mesh)
295 for (
auto &face : mesh->get_faces())
297 if (face->n_cells() == 1)
299 face->set_boundary(
true);
300 face->get_cells()[0]->set_boundary(
true);
302 for (
auto &
vert : face->get_vertices())
304 vert->set_boundary(
true);
307 mesh->add_b_face(face);
312 mesh->add_i_face(face);
316 for (
auto &cell : mesh->get_cells())
318 if (cell->is_boundary())
320 mesh->add_b_cell(cell);
324 mesh->add_i_cell(cell);
328 for (
auto &
vert : mesh->get_vertices())
330 if (
vert->is_boundary())
332 mesh->add_b_vertex(
vert);
336 mesh->add_i_vertex(
vert);
340 const std::string _mesh_file;
The MeshBuilder class provides build tools to create a full mesh with all connectivities.
Definition mesh_builder.hpp:172
The MeshReader class provides functions to read a typ2 or GMesh file.
Definition mesh_reader.hpp:29
A Vertex is a Polytope with object_dim = 0.
Definition Polytope2D.hpp:55
for i
Definition convergence_analysis.m:48
for j
Definition convergence_analysis.m:19
Generate vertices vertices
Definition generate_cartesian_mesh.m:26
v3
Definition generate_cartesian_mesh.m:50
v1
Definition generate_cartesian_mesh.m:50
Create grid points x
Definition generate_cartesian_mesh.m:22
v2
Definition generate_cartesian_mesh.m:50
Polytope< DIMENSION > Cell
Definition Polytope2D.hpp:152
std::unique_ptr< Mesh > build_the_mesh(const TransformationType &transformation=[](const std::array< double, 2 > &x) { return x;})
Definition mesh_builder.hpp:189
MeshBuilder(const std::string mesh_file)
Definition mesh_builder.hpp:184
Polytope< 1 > Edge
A Face is a Polytope with object_dim = DIMENSION - 1.
Definition Polytope2D.hpp:148
std::function< std::array< double, 2 >(const std::array< double, 2 > &)> TransformationType
Definition mesh_builder.hpp:174
Polytope< 0 > Vertex
An Edge is a Polytope with object_dim = 1.
Definition Polytope2D.hpp:145
MeshBuilder()
Definition mesh_builder.hpp:179
depending on the Matrix Market format indicated by or array(dense array storage). The data will be duplicated % as appropriate if symmetry is indicated in the header. % % Optionally
double shortest_distance(VectorRd p, VectorRd A, VectorRd B)
Definition mesh_builder.hpp:14
double signed_area(VectorRd A, VectorRd B, VectorRd C)
Definition Mesh2D.hpp:8
std::array< VectorRd, object_dim+1 > Simplex
Definition Polytope2D.hpp:24
Simplices< 2 > simplexify(std::vector< VectorRd > vertices)
Definition mesh_builder.hpp:31
std::vector< Simplex< object_dim > > Simplices
Method to find the center mass of an arbitrary simplex in arbitrary space.
Definition Polytope2D.hpp:29
Eigen::Matrix< double, DIMENSION, 1 > VectorRd
Definition Polytope2D.hpp:20