53 follower_face(
int id_, Eigen::Vector2d p1_, Eigen::Vector2d p2_, Eigen::Vector2d p3_)
147 edges.setConstant(3 * (
dim - 1), 1, -1);
148 faces.setConstant(4 * (
dim - 2), 1, -1);
149 children.setConstant(std::round(pow(2,
dim)), 1, -1);
196 for (
const auto &edge :
edges)
251 void refine(
const int n_refinement,
const double t)
override;
257 std::pair<RowVectorNd, int>
face_node(
const Navigation::Index &index,
const int n_new_nodes,
const int i,
const int j)
const override;
281 void set_body_ids(
const std::vector<int> &body_ids)
override;
331 std::unique_ptr<Mesh>
copy()
const override;
338 return (
long)((long)984120265 * a[0] + (
long)125965121 * a[1]);
353 int map_id(
const std::vector<int> &map,
const int id)
const
357 assert(
id >= 0 &&
id <
int(map.size()));
377 void traverse_edge(Eigen::Vector2i v,
double p1,
double p2,
int depth, std::vector<follower_edge> &list)
const;
387 int add_element(Eigen::Vector3i v,
int parent = -1);
408 std::unordered_map<Eigen::Vector2i, int, ArrayHasher2D>
midpointMap;
409 std::unordered_map<Eigen::Vector2i, int, ArrayHasher2D>
edgeMap;
2D mesh interface: the elements are the faces (polygons) and the boundary elements are the edges.
Format-independent input used to construct a runtime Mesh.
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
bool has_boundary_ids() const
checks if surface selections are available
virtual int get_default_boundary_id(const int primitive) const
Get the default boundary selection of an element (face in 3d, edge in 2d)
Non-conforming 2D triangle mesh with hanging nodes, for adaptive h-refinement: refine_element() split...
int all_to_valid_elem(const int id) const
int find_edge(Eigen::Vector2i v) const
bool is_boundary_element(const int element_global_id) const override
is cell boundary
void traverse_edge(Eigen::Vector2i v, double p1, double p2, int depth, std::vector< follower_edge > &list) const
void compute_body_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &)> &marker) override
computes boundary selections based on a function
Navigation::Index switch_face(Navigation::Index idx) const override
std::vector< int > valid_to_all_edgeMap
int n_face_neighbors(const int e_id) const
NCMesh2D(NCMesh2D &&)=default
RowVectorNd point(const int global_index) const override
point coordinates
Navigation::Index switch_vertex(Navigation::Index idx) const override
int leader_edge_of_vertex(const int v_id) const
std::unique_ptr< Mesh > copy() const override
Create a copy of the mesh.
void attach_higher_order_nodes(const Eigen::MatrixXd &V, const std::vector< std::vector< int > > &nodes) override
attach high order nodes
int face_edge(const int f_id, const int le_id) const
bool build_topology(const MeshData &data) override
Construct only the dimension-specific topology.
void refine_elements(const std::vector< int > &ids)
Refines the given elements (valid ids) and prepares the mesh.
void prepare_mesh() override
method used to finalize the mesh.
std::vector< ncVert > vertices
void build_edge_follower_chain()
std::vector< int > all_to_valid_elemMap
bool is_conforming() const override
if the mesh is conforming
static double element_weight_to_edge_weight(const int l, const Eigen::Vector2d &pos)
int n_follower_edges(const int e_id) const
void refine_element(int id_full)
Refines one element (full id).
void set_boundary_ids(const std::vector< int > &boundary_ids) override
Set the boundary selection from a vector.
int n_faces() const override
number of faces
void set_point(const int global_index, const RowVectorNd &p) override
Set the point.
int all_to_valid_vertex(const int id) const
std::vector< ncElem > elements
int find_vertex(const int v1, const int v2) const
void set_body_ids(const std::vector< int > &body_ids) override
Set the volume sections.
Navigation::Index switch_edge(Navigation::Index idx) const override
int get_edge(Eigen::Vector2i v)
int add_element(Eigen::Vector3i v, int parent=-1)
void coarsen_element(int id_full)
Coarsens the parent of one element (full id).
int get_vertex(Eigen::Vector2i v)
Navigation::Index get_index_from_face(int f, int lv=0) const override
double edge_length(const int gid) const override
edge length
int get_boundary_id(const int primitive) const override
Get the boundary selection of an element (face in 3d, edge in 2d)
int valid_to_all_edge(const int id) const
int n_vertices() const override
number of vertices
bool is_boundary_edge(const int edge_global_id) const override
is edge boundary
int get_body_id(const int primitive) const override
Get the volume selection of an element (cell in 3d, face in 2d)
void refine(const int n_refinement, const double t) override
refine the mesh
std::pair< RowVectorNd, int > face_node(const Navigation::Index &index, const int n_new_nodes, const int i, const int j) const override
void normalize() override
normalize the mesh
std::vector< int > refineHistory
void stale_index_error() const
Throws: the id maps are stale (prepare_mesh() was not called after editing the mesh).
int valid_to_all_elem(const int id) const
int map_id(const std::vector< int > &map, const int id) const
std::vector< int > valid_to_all_elemMap
int edge_vertex(const int e_id, const int lv_id) const override
id of the edge vertex
int leader_edge_of_edge(const int e_id) const
std::vector< int > all_to_valid_edgeMap
std::vector< int > all_to_valid_vertexMap
std::unordered_map< Eigen::Vector2i, int, ArrayHasher2D > midpointMap
std::vector< ncBoundary > edges
int find_edge(const int v1, const int v2) const
void compute_elements_tag() override
compute element types, see ElementType
int face_vertex(const int f_id, const int lv_id) const override
id of the face vertex
RowVectorNd edge_barycenter(const int index) const override
edge barycenter
int all_to_valid_edge(const int id) const
std::unordered_map< Eigen::Vector2i, int, ArrayHasher2D > edgeMap
int find_vertex(Eigen::Vector2i v) const
void bounding_box(RowVectorNd &min, RowVectorNd &max) const override
computes the bbox of the mesh
int cell_vertex(const int f_id, const int lv_id) const override
id of the vertex of a cell
int face_ref_level(const int f_id) const
int n_face_vertices(const int f_id) const override
number of vertices of a face
int valid_to_all_vertex(const int id) const
virtual ~NCMesh2D()=default
bool index_prepared
Whether the valid <-> all id maps match the current topology.
void build_element_vertex_adjacency()
void compute_boundary_ids(const std::function< int(const size_t, const std::vector< int > &, const RowVectorNd &, bool)> &marker) override
computes boundary selections based on a function
int n_edges() const override
number of edges
NCMesh2D & operator=(const NCMesh2D &)=default
int get_edge(const int v1, const int v2)
NCMesh2D & operator=(NCMesh2D &&)=default
int face_neighbor(const int e_id) const
bool is_boundary_vertex(const int vertex_global_id) const override
is vertex boundary
Eigen::SparseMatrix< bool, Eigen::RowMajor > elementAdj
NCMesh2D(const NCMesh2D &)=default
std::vector< int > valid_to_all_vertexMap
std::pair< RowVectorNd, int > edge_node(const Navigation::Index &index, const int n_new_nodes, const int i) const override
void update_elements_tag() override
Update elements types.
void build_index_mapping()
void append(const Mesh &mesh) override
appends a new mesh to the end of this
void update_labels_after_refinement()
After a refinement: rebuild the body/boundary id arrays from the per-entity labels (inherited by the ...
void remove_elements(const std::vector< bool > &keep) override
Remove all top-dimensional elements whose mask entry is false.
Set of ids stored as a sorted vector: iterates in increasing order like std::set<int>,...
void insert(const int id)
const_iterator cbegin() const
size_t erase(const int id)
Removes id; returns the number of removed ids (0 or 1).
Eigen::Matrix< T, Eigen::Dynamic, 1, Eigen::ColMajor, MaxSize, 1 > InlineVector
Small vector stored inline (no heap allocation), with the VectorXi / VectorXd API; used for the per-e...
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
long operator()(const Eigen::Vector2i &a) const
follower_edge(int id_, double p1_, double p2_)
follower_face(int id_, Eigen::Vector2d p1_, Eigen::Vector2d p2_, Eigen::Vector2d p3_)
int find_opposite_element(int e) const
ncBoundary(const Eigen::VectorXi &vert)
InlineVector< int, 2 > vertices
void remove_element(const int e)
std::vector< int > global_ids
void add_element(const int e)
std::vector< int > followers
InlineVector< int, 1 > faces
InlineVector< int, 3 > vertices
InlineVector< int, 3 > geom_vertices
bool is_not_valid() const
InlineVector< int, 3 > edges
ncElem(const int dim_, const Eigen::VectorXi &vertices_, const int level_, const int parent_)
InlineVector< int, 4 > children
ncVert(const Eigen::VectorXd &pos_)
InlineVector< double, 3 > pos