27 #include "MeshImplData.hpp"
28 #include "TopologyInfo.hpp"
29 #include "MsqError.hpp"
33 #undef SEPARATE_MID_NODES
43 for (msq_std::vector<Vertex>::const_iterator iter =
vertexList.begin();
45 #ifdef SEPARATE_MID_NODES
46 if (iter->valid && iter->midcount < iter->adjacencies.size())
60 for (msq_std::vector<Element>::const_iterator iter =
elementList.begin();
63 #ifdef SEPARATE_MID_NODES
65 result += from_topo ? from_topo : iter->connectivity.size();
67 result += iter->connectivity.size();
152 for (i = numvert; i <
elementList[index].connectivity.size(); ++
i)
159 for (i = numvert; i <
elementList[index].connectivity.size(); ++
i)
242 if (!vert.adjacencies.empty())
248 vert.coords = coords;
254 const msq_std::vector<size_t>& vertices,
273 for (
unsigned i = numvert; i <
elementList[index].connectivity.size(); ++
i)
276 msq_std::vector<size_t>& conn =
elementList[index].connectivity;
277 for (msq_std::vector<size_t>::iterator iter = conn.begin();
278 iter != conn.end(); ++iter)
280 msq_std::vector<size_t>& adj =
vertexList[*iter].adjacencies;
281 for (msq_std::vector<size_t>::iterator iter2 = adj.begin();
282 iter2 != adj.end(); ++iter2)
295 const msq_std::vector<size_t>& vertices,
305 msq_std::vector<size_t>& conn =
elementList[index].connectivity;
309 for (msq_std::vector<size_t>::iterator iter = conn.begin();
310 iter != conn.end(); ++iter)
318 msq_std::vector<size_t>& adj =
vertexList[*iter].adjacencies;
319 for (msq_std::vector<size_t>::iterator iter2 = adj.begin();
320 iter2 != adj.end(); ++iter2)
324 adj.push_back( index );
329 for (
unsigned i = numvert; i <
elementList[index].connectivity.size(); ++
i)
346 vertexList.push_back( Vertex(coords, fixed ) );
391 size_t* element_handle_array,
392 size_t* element_conn_offsets,
393 size_t* element_conn_indices )
395 msq_std::vector<size_t> vertex_map(
vertexList.size() );
400 #ifdef SEPARATE_MID_NODES
405 vertex_handle_array[vh_index] =
v;
406 vertex_map[
v] = vh_index;
420 #ifdef SEPARATE_MID_NODES
424 cl = elem.connectivity.size();
427 *element_handle_array = e;
428 ++element_handle_array;
430 *element_conn_offsets =
offset;
431 ++element_conn_offsets;
434 msq_std::vector<size_t>::iterator conn = elem.connectivity.begin();
435 msq_std::vector<size_t>::iterator end = conn + cl;
438 *element_conn_indices = vertex_map[*conn];
439 ++element_conn_indices;
444 *element_conn_offsets =
offset;
448 msq_std::vector<size_t>& vertices,
449 msq_std::vector<size_t>& vertex_indices,
450 msq_std::vector<size_t>& index_offsets,
455 vertex_indices.clear();
456 index_offsets.clear();
461 msq_std::vector<size_t> vert_map(
vertexList.size() );
471 if (!vert.valid || !vert.midcount)
475 assert( vert.adjacencies.size() );
476 int elem_indx = vert.adjacencies[0];
481 for (index = 0; index < elem.connectivity.size(); ++index)
482 if (elem.connectivity[index] == v)
484 if (index == elem.connectivity.size())
492 unsigned side_dim, side_num;
494 index, side_dim, side_num, err );
MSQ_ERRRTN(err);
503 unsigned num_corners;
505 elem.topology, side_dim, side_num, num_corners, err );
MSQ_ERRRTN(err);
508 mid_nodes.push_back( v );
512 index_offsets.push_back( vertex_indices.size() );
516 for (
unsigned i = 0; i < num_corners; ++
i)
518 size_t vert_idx = elem.connectivity[corner_indices[
i]];
523 vert_map[vert_idx] = vertices.size();
524 vertices.push_back( vert_idx );
526 vertex_indices.push_back( vert_map[vert_idx] );
529 index_offsets.push_back( vertex_indices.size() );
547 for (
size_t idx = 0; idx <
vertexList.size(); ++idx)
549 list.push_back( idx );
555 for (
size_t idx = 0; idx <
elementList.size(); ++idx)
557 list.push_back( idx );
561 msq_std::vector<size_t>::const_iterator node_iter,
562 msq_std::vector<size_t>::const_iterator node_end,
563 msq_std::vector<size_t>& elems, MsqError& err )
575 for (++node_iter; node_iter != node_end; ++node_iter)
577 msq_std::vector<size_t>::iterator elem_iter = elems.begin();
578 while (elem_iter != elems.end())
580 msq_std::vector<size_t>::const_iterator adj_iter =
vertexList[*node_iter].adjacencies.begin();
581 const msq_std::vector<size_t>::const_iterator adj_end =
vertexList[*node_iter].adjacencies.end();
582 for (; adj_iter != adj_end; ++adj_iter)
583 if (*elem_iter == *adj_iter)
586 if (adj_iter == adj_end)
588 *elem_iter = elems[elems.size()-1];
601 const msq_std::vector<size_t>& nodes,
604 msq_std::vector<size_t> adj_elems;
608 msq_std::vector<size_t>::iterator iter;
609 for (iter = adj_elems.begin(); iter != adj_elems.end(); ++iter)
614 return iter != adj_elems.end();
619 msq_std::vector<size_t> side_nodes;
622 for (
size_t elem = 0; elem <
elementList.size(); ++elem)
630 msq_std::vector<size_t>& conn =
elementList[elem].connectivity;
639 for (
unsigned side = 0; side < num; ++side)
646 for (
unsigned k = 0;
k < count; ++
k)
647 side_nodes.push_back( conn[indices[
k]] );
654 sides.push_back( elem );
655 sides.push_back( side );
663 for (
unsigned side = 0, next = 1; next < conn.size(); ++side, ++next)
666 side_nodes.push_back( conn[side] );
667 side_nodes.push_back( conn[next] );
674 sides.push_back( elem );
675 sides.push_back( side );
683 for (
unsigned side = 0; side < conn.size(); ++side)
692 sides.push_back( elem );
693 sides.push_back( side );
716 while (index < mesh->max_vertex_index() &&
unsigned char get_vertex_byte(size_t index, MsqError &err) const
Get vertex byte.
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
void all_elements(msq_std::vector< size_t > &list, MsqError &err) const
Get all elements.
void fix_vertex(size_t index, bool flag, MsqError &err)
Set vertex fixed flag.
size_t max_vertex_index() const
virtual bool is_at_end() const
Returns false until the iterator has been advanced PAST the last entity.
virtual void operator++()
++iterator
void copy_higher_order(msq_std::vector< size_t > &mid_nodes, msq_std::vector< size_t > &vertices, msq_std::vector< size_t > &vertex_indices, msq_std::vector< size_t > &index_offsets, MsqError &err)
Get all mid-nodes and their adjacent corner vertices.
virtual Mesh::VertexHandle operator*() const
*iterator.
const msq_std::vector< size_t > & element_connectivity(size_t index, MsqError &err) const
Get element connectivity list, including mid-nodes.
msq_std::vector< Element > elementList
Array of elements.
EntityHandle VertexHandle
size_t num_vertices() const
Get number of vertices, does not include mid-nodes.
EntityHandle ElementHandle
void get_adjacent_elements(msq_std::vector< size_t >::const_iterator nodes, msq_std::vector< size_t >::const_iterator nodes_end, msq_std::vector< size_t > &elems_out, MsqError &err)
Get elements adjacent to ALL of the passed nodes.
void reset_element(size_t index, const msq_std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
Clear element at specified index (if any) including connectivity and adjacency data, and re-initialize with passed data.
real *8 function offset(vNorm, x2, y2, z2)
msq_std::vector< size_t > deletedElementList
List of unused indices in element list.
virtual void operator++()
++iterator
virtual ~MeshImplVertIter()
void allocate_vertices(size_t count, MsqError &err)
Allocate space for specified number of vertices.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
size_t add_vertex(const Vector3D &coords, bool fixed, MsqError &err)
Add a new vertex.
static unsigned sides(EntityTopology topo)
Get number of sides a given topology type has.
void clear()
Clear all data.
virtual void restart()
Moves the iterator back to the first entity in the list.
bool has_adjacent_elements(size_t elem, const msq_std::vector< size_t > &nodes, MsqError &err)
helper function for skinning
EntityTopology element_topology(size_t index, MsqError &err) const
Get element type.
invalid function argument passed
const msq_std::vector< size_t > & vertex_adjacencies(size_t index, MsqError &err) const
Get vertex adjacency list.
static unsigned dimension(EntityTopology topo)
Dimension of element topology.
NVec< 3, double > Vector3D
const msq_std::vector< size_t > dummy_list
void skin(msq_std::vector< size_t > &sides, MsqError &err)
Skin mesh.
virtual Mesh::ElementHandle operator*() const
*iterator.
virtual bool is_at_end() const
Returns false until the iterator has been advanced PAST the last entity.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
static unsigned corners(EntityTopology topo)
Get the number of defining vertices for a given element topology.
void set_vertex_coords(size_t index, const Vector3D &coords, MsqError &err)
Set vertex coordinates.
virtual ~MeshImplElemIter()
msq_std::vector< size_t > deletedVertexList
List of unused indices in vertex list.
bool is_vertex_valid(size_t index) const
Check if passed vertex index is valid.
size_t max_element_index() const
size_t add_element(const msq_std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
Add a new element.
const Vector3D & get_vertex_coords(size_t index, MsqError &err) const
Get vertex coordinates.
void set_vertex_byte(size_t index, unsigned char value, MsqError &err)
Set vertex byte.
static const unsigned * side_vertices(EntityTopology topo, unsigned side_dimension, unsigned side_number, unsigned &num_verts_out, MsqError &err)
Get corner indices of side.
bool vertex_is_fixed(size_t index, MsqError &err) const
Get vertex fixed flag.
virtual void restart()
Moves the iterator back to the first entity in the list.
void delete_vertex(size_t index, MsqError &err)
Delete a vertex - may not be referenced by any element.
object is in an invalid state
bool is_mid_node(size_t index) const
Check if the specified node is used as a mid-node on any element.
void allocate_elements(size_t count, MsqError &err)
Allocate space for specified number of elements.
void reset_vertex(size_t index, const Vector3D &coords, bool fixed, MsqError &err)
Set allocated but unset veretx to specified values.
void copy_mesh(size_t *vertex_handle_array, size_t *element_hanlde_array, size_t *element_conn_offsets, size_t *element_conn_indices)
Copy internal representation into CSR rep Does not include mid-nodes.
void all_vertices(msq_std::vector< size_t > &list, MsqError &err) const
Get all vertices, including mid-nodes.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
msq_std::vector< Vertex > vertexList
Array of vertices.
void clear_element(size_t index, MsqError &err)
Clear existing element data.
size_t num_vertex_uses() const
Get number of vertex uses (sum of connectivity length for all elements) Does not count mid-nodes...
void set_element(size_t index, const msq_std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
Set cleared element.
void delete_element(size_t index, MsqError &err)
Delete an element.
static void side_number(EntityTopology topo, unsigned connectivity_length, unsigned node_index, unsigned &side_dimension_out, unsigned &side_number_out, MsqError &err)
Return which side the specified mid-node lies on.
bool is_corner_node(size_t index) const
Check if the specified node is used as a corner vertex on any element.
bool is_element_valid(size_t index) const
Check if passed element index is valid.
size_t num_elements() const
Get number of elements.