diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 01a5b29eb206ddd3e66c326df9b0b54c297c0282..50017fcb044c7282e9e7b1940070df90778f8560 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -167,16 +167,6 @@ public: */ virtual Element* clone() const = 0; - /** - * This method should be called after at least two nodes of an element - * are collapsed. The node collapsing can/have to lead to an edge collapse. - * This method tries to create a new element of an appropriate type. The - * value of the attribute _value is carried over. In contrast to this the - * neighbor information is not carried over. - * @return an element of a different element type (MeshElemType) or NULL - */ - virtual Element* reviseElement() const = 0; - /** * Computes the length / area / volumen of this element. This is automatically * done at initalisation time but can be repeated by calling this function at any time. diff --git a/MeshLib/Elements/TemplateHex-impl.h b/MeshLib/Elements/TemplateHex-impl.h index cf14ab462d4742f6b659658c9d5914cefc60619b..c31298d9f5290b98f2018e952cb6241ae75c9173 100644 --- a/MeshLib/Elements/TemplateHex-impl.h +++ b/MeshLib/Elements/TemplateHex-impl.h @@ -173,107 +173,4 @@ ElementErrorCode TemplateHex<NNODES,CELLHEXTYPE>::validate() const return error_code; } -template <unsigned NNODES, CellType CELLHEXTYPE> -Element* TemplateHex<NNODES,CELLHEXTYPE>::reviseElement() const -{ - std::vector<size_t> collapsed_edges; - for (size_t edge(0); edge<getNEdges(); edge++) { - if (_nodes[_edge_nodes[edge][0]] == _nodes[_edge_nodes[edge][1]]) { - collapsed_edges.push_back(edge); - } - } - - if (collapsed_edges.size() == 1) { - ERR("[TemplateHex<NNODES,CELLHEXTYPE>::reviseElement()] collapsing of one edge in hexahedron not handled."); - return NULL; - } - - if (collapsed_edges.size() == 2) { - // try to create a prism out of the hex - if (collapsed_edges[0] == 0 && collapsed_edges[1] == 2) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[4]; - prism_nodes[2] = _nodes[5]; - prism_nodes[3] = _nodes[3]; - prism_nodes[4] = _nodes[7]; - prism_nodes[5] = _nodes[6]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 1 && collapsed_edges[1] == 3) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[4]; - prism_nodes[2] = _nodes[7]; - prism_nodes[3] = _nodes[1]; - prism_nodes[4] = _nodes[5]; - prism_nodes[5] = _nodes[6]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 4 && collapsed_edges[1] == 5) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[7]; - prism_nodes[2] = _nodes[3]; - prism_nodes[3] = _nodes[1]; - prism_nodes[4] = _nodes[6]; - prism_nodes[5] = _nodes[2]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 5 && collapsed_edges[1] == 6) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[1]; - prism_nodes[2] = _nodes[4]; - prism_nodes[3] = _nodes[3]; - prism_nodes[4] = _nodes[2]; - prism_nodes[5] = _nodes[7]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 6 && collapsed_edges[1] == 7) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[3]; - prism_nodes[2] = _nodes[4]; - prism_nodes[3] = _nodes[1]; - prism_nodes[4] = _nodes[2]; - prism_nodes[5] = _nodes[5]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 7 && collapsed_edges[1] == 4) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[1]; - prism_nodes[2] = _nodes[5]; - prism_nodes[3] = _nodes[3]; - prism_nodes[4] = _nodes[2]; - prism_nodes[5] = _nodes[6]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 8 && collapsed_edges[1] == 10) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[1]; - prism_nodes[2] = _nodes[4]; - prism_nodes[3] = _nodes[3]; - prism_nodes[4] = _nodes[2]; - prism_nodes[5] = _nodes[7]; - return new Prism(prism_nodes, _value); - } - if (collapsed_edges[0] == 9 && collapsed_edges[1] == 11) { - Node** prism_nodes = new Node*[6]; - prism_nodes[0] = _nodes[0]; - prism_nodes[1] = _nodes[3]; - prism_nodes[2] = _nodes[4]; - prism_nodes[3] = _nodes[1]; - prism_nodes[4] = _nodes[2]; - prism_nodes[5] = _nodes[5]; - return new Prism(prism_nodes, _value); - } - return NULL; - } - - return NULL; -} - } // end namespace MeshLib diff --git a/MeshLib/Elements/TemplateHex.h b/MeshLib/Elements/TemplateHex.h index 27504ac63d45e0fdf99b75daa3325687f28cff3d..1adc68b9238220bbca79b51dedc581cce75f6cfb 100644 --- a/MeshLib/Elements/TemplateHex.h +++ b/MeshLib/Elements/TemplateHex.h @@ -110,12 +110,6 @@ public: */ virtual Element* clone() const; - /** - * Change the element type from hexahedron to a prism if two appropriate edges of the hexahedron are collapsed. - * @return a prism element with nice properties or NULL - */ - virtual Element* reviseElement() const; - protected: /// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra. double computeVolume(); diff --git a/MeshLib/Elements/TemplateLine.h b/MeshLib/Elements/TemplateLine.h index ae9dbcadf4f255aef671922607695606c072dee0..ad07b20c2b668aef1cc15ee68571e6b12ba117df 100644 --- a/MeshLib/Elements/TemplateLine.h +++ b/MeshLib/Elements/TemplateLine.h @@ -88,19 +88,6 @@ public: return new TemplateLine<NNODES,CELLLINETYPE>(*this); } - /** - * If for instance two nodes of the element are collapsed the Edge element disappears. - * @return NULL - */ - virtual Element* reviseElement() const - { - if (_nodes[0] == _nodes[1]) { - return NULL; - } - - return NULL; - } - protected: double computeVolume() { diff --git a/MeshLib/Elements/TemplatePrism-impl.h b/MeshLib/Elements/TemplatePrism-impl.h index cd9a7671fc256dc23485732bbcec84b57b3fca6d..a81ce1ca08e5fb4ec8099e4a8d832a6f70e8598d 100644 --- a/MeshLib/Elements/TemplatePrism-impl.h +++ b/MeshLib/Elements/TemplatePrism-impl.h @@ -182,42 +182,5 @@ ElementErrorCode TemplatePrism<NNODES,CELLPRISMTYPE>::validate() const return error_code; } -template <unsigned NNODES, CellType CELLPRISMTYPE> -Element* TemplatePrism<NNODES,CELLPRISMTYPE>::reviseElement() const -{ - // try to create Pyramid - if (_nodes[_edge_nodes[3][0]] == _nodes[_edge_nodes[3][1]]) { - Node** pyramid_nodes = new Node*[5]; - pyramid_nodes[0] = _nodes[1]; - pyramid_nodes[1] = _nodes[4]; - pyramid_nodes[2] = _nodes[5]; - pyramid_nodes[3] = _nodes[2]; - pyramid_nodes[4] = _nodes[0]; - return new Pyramid(pyramid_nodes, _value); - } - - if (_nodes[_edge_nodes[4][0]] == _nodes[_edge_nodes[4][1]]) { - Node** pyramid_nodes = new Node*[5]; - pyramid_nodes[0] = _nodes[0]; - pyramid_nodes[1] = _nodes[2]; - pyramid_nodes[2] = _nodes[5]; - pyramid_nodes[3] = _nodes[3]; - pyramid_nodes[4] = _nodes[1]; - return new Pyramid(pyramid_nodes, _value); - } - - if (_nodes[_edge_nodes[5][0]] == _nodes[_edge_nodes[5][1]]) { - Node** pyramid_nodes = new Node*[5]; - pyramid_nodes[0] = _nodes[0]; - pyramid_nodes[1] = _nodes[1]; - pyramid_nodes[2] = _nodes[4]; - pyramid_nodes[3] = _nodes[3]; - pyramid_nodes[4] = _nodes[2]; - return new Pyramid(pyramid_nodes, _value); - } - - return NULL; -} - } // end namespace MeshLib diff --git a/MeshLib/Elements/TemplatePrism.h b/MeshLib/Elements/TemplatePrism.h index 41305a7de2f1eeb747ed5bf1b77ab1f035fcaf5e..2faa97f38ea32ac23613650d7f2ab4676a2def47 100644 --- a/MeshLib/Elements/TemplatePrism.h +++ b/MeshLib/Elements/TemplatePrism.h @@ -109,17 +109,6 @@ public: */ virtual Element* clone() const; - /** - * This method should be called after at least two nodes of the prism - * element are collapsed. As a consequence of the node collapsing an edge - * of the prism will be collapsed. If one of the edges 3, 4 or 5 (see - * sketch @ref PrismNodeAndEdgeNumbering) is collapsed we obtain a - * pyramid. In this case the method will create the appropriate - * object of class Pyramid. - * @return a pyramid object or NULL - */ - virtual Element* reviseElement() const; - protected: /// Calculates the volume of a prism by subdividing it into three tetrahedra. double computeVolume(); diff --git a/MeshLib/Elements/TemplatePyramid-impl.h b/MeshLib/Elements/TemplatePyramid-impl.h index f752c750c833b02871a368a257f069306c2068b4..6dc3ed276910d04fec9680a3ab7fbe52aaf4d196 100644 --- a/MeshLib/Elements/TemplatePyramid-impl.h +++ b/MeshLib/Elements/TemplatePyramid-impl.h @@ -182,26 +182,4 @@ ElementErrorCode TemplatePyramid<NNODES,CELLPYRAMIDTYPE>::validate() const return error_code; } -template <unsigned NNODES, CellType CELLPYRAMIDTYPE> -Element* TemplatePyramid<NNODES,CELLPYRAMIDTYPE>::reviseElement() const -{ - // try to create tetrahedron - if (_nodes[_edge_nodes[0][0]] == _nodes[_edge_nodes[0][1]] - || _nodes[_edge_nodes[1][0]] == _nodes[_edge_nodes[1][1]]) { - Node** tet_nodes = new Node*[4]; - for (unsigned k(0); k<4; k++) tet_nodes[k] = _nodes[k]; - return new Tet(tet_nodes, _value); - } - - if (_nodes[_edge_nodes[2][0]] == _nodes[_edge_nodes[2][1]] - || _nodes[_edge_nodes[3][0]] == _nodes[_edge_nodes[3][1]]) { - Node** tet_nodes = new Node*[4]; - for (unsigned k(0); k<3; k++) tet_nodes[k] = _nodes[k]; - tet_nodes[3] = _nodes[4]; - return new Tet(tet_nodes, _value); - } - - return NULL; -} - } // end namespace MeshLib diff --git a/MeshLib/Elements/TemplatePyramid.h b/MeshLib/Elements/TemplatePyramid.h index 6965eca08978be21caa9171c50e92d0d710f82bb..64f7a50c7518cb5e4f5ea1372a6b3a4ff82e1a7d 100644 --- a/MeshLib/Elements/TemplatePyramid.h +++ b/MeshLib/Elements/TemplatePyramid.h @@ -107,17 +107,6 @@ public: */ virtual Element* clone() const; - /** - * This method should be called after at least two nodes of the pyramid - * element are collapsed. As a consequence of the node collapsing an edge - * of the pyramid will be collapsed. If one of the edges 0, 1, 2 or 3 (see - * sketch @ref PyramidNodeAndEdgeNumbering) is collapsed we obtain a - * tetrahedron. In this case the method will create the appropriate - * object of class Tetrahedron. - * @return a Tetrahedron object or NULL - */ - virtual Element* reviseElement() const; - protected: /// Calculates the volume of a prism by subdividing it into two tetrahedra. double computeVolume(); diff --git a/MeshLib/Elements/TemplateQuad-impl.h b/MeshLib/Elements/TemplateQuad-impl.h index b4fb73457aa0ec669b13a6aa72d288d464bcfdfe..781ba81f9c12aaacae13b36f7eaf1e13c84d391d 100644 --- a/MeshLib/Elements/TemplateQuad-impl.h +++ b/MeshLib/Elements/TemplateQuad-impl.h @@ -132,28 +132,5 @@ ElementErrorCode TemplateQuad<NNODES,CELLQUADTYPE>::validate() const return error_code; } -template <unsigned NNODES, CellType CELLQUADTYPE> -Element* TemplateQuad<NNODES,CELLQUADTYPE>::reviseElement() const -{ - if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) { - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; - tri_nodes[0] = _nodes[0]; - tri_nodes[1] = _nodes[2]; - tri_nodes[2] = _nodes[3]; - return new Tri(tri_nodes, _value); - } - - if (_nodes[2] == _nodes[3] || _nodes[3] == _nodes[0]) { - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; - tri_nodes[0] = _nodes[0]; - tri_nodes[1] = _nodes[1]; - tri_nodes[2] = _nodes[2]; - return new Tri(tri_nodes, _value); - } - - // this should not happen - return NULL; -} - } diff --git a/MeshLib/Elements/TemplateQuad.h b/MeshLib/Elements/TemplateQuad.h index e735e46c26330e355fd691d3549c8d62f2d8976c..869539a465ec82efa4208345d0218dd75d278bbd 100644 --- a/MeshLib/Elements/TemplateQuad.h +++ b/MeshLib/Elements/TemplateQuad.h @@ -109,17 +109,6 @@ public: */ virtual Element* clone() const; - /** - * This method should be called after at least two nodes of the quad - * element are collapsed. As a consequence of the node collapsing an edge - * of the quad will be collapsed. If one of the edges (see - * sketch @ref PyramidNodeAndEdgeNumbering) is collapsed we obtain a - * triangle. In this case the method will create the appropriate - * object of class Tri. - * @return a Tri object or NULL - */ - virtual Element* reviseElement() const; - protected: /// Calculates the area of a convex quadliteral by dividing it into two triangles. double computeVolume(); diff --git a/MeshLib/Elements/TemplateTet-impl.h b/MeshLib/Elements/TemplateTet-impl.h index 0da3790c04fa56bc78c287a02af046ec1a1326e6..5b738fee1996c09b17edd72c812cf1096e734587 100644 --- a/MeshLib/Elements/TemplateTet-impl.h +++ b/MeshLib/Elements/TemplateTet-impl.h @@ -152,36 +152,5 @@ ElementErrorCode TemplateTet<NNODES,CELLTETTYPE>::validate() const return error_code; } -template <unsigned NNODES, CellType CELLTETTYPE> -Element* TemplateTet<NNODES,CELLTETTYPE>::reviseElement() const -{ - if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) { - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; - tri_nodes[0] = _nodes[0]; - tri_nodes[1] = _nodes[2]; - tri_nodes[2] = _nodes[3]; - return new Tri(tri_nodes, _value); - } - - if (_nodes[2] == _nodes[0]) { - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; - tri_nodes[0] = _nodes[0]; - tri_nodes[1] = _nodes[1]; - tri_nodes[2] = _nodes[3]; - return new Tri(tri_nodes, _value); - } - - if (_nodes[0] == _nodes[3] || _nodes[1] == _nodes[3] || _nodes[2] == _nodes[3]) { - MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; - tri_nodes[0] = _nodes[0]; - tri_nodes[1] = _nodes[1]; - tri_nodes[2] = _nodes[2]; - return new Tri(tri_nodes, _value); - } - - // this should not happen - return NULL; -} - } // end namespace MeshLib diff --git a/MeshLib/Elements/TemplateTet.h b/MeshLib/Elements/TemplateTet.h index de9f82be76d23bff27942980bda934528372b50d..b21a693b2a281f073f79254a434c9f4b6922d866 100644 --- a/MeshLib/Elements/TemplateTet.h +++ b/MeshLib/Elements/TemplateTet.h @@ -105,15 +105,6 @@ public: */ virtual Element* clone() const; - /** - * This method should be called after at least two nodes of the tetrahedron - * element are collapsed. As a consequence of the node collapsing an edge - * of the tetrahedron will be collapsed. If one edge is collapsed we obtain - * a triangle. - * @return a Triangle object or NULL - */ - virtual Element* reviseElement() const; - protected: /// Calculates the volume of a tetrahedron via the determinant of the matrix given by its four points. double computeVolume(); diff --git a/MeshLib/Elements/TemplateTri-impl.h b/MeshLib/Elements/TemplateTri-impl.h index a32500f043b4dc643e659a5493be6e9baf92ae88..870ef659aa3d62248ee7024fa5d65612dcadf32f 100644 --- a/MeshLib/Elements/TemplateTri-impl.h +++ b/MeshLib/Elements/TemplateTri-impl.h @@ -88,28 +88,6 @@ ElementErrorCode TemplateTri<NNODES,CELLTRITYPE>::validate() const return error_code; } - -template <unsigned NNODES, CellType CELLTRITYPE> -Element* TemplateTri<NNODES,CELLTRITYPE>::reviseElement() const -{ - // try to create an edge - if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) { - Node** nodes = new Node*[2]; - nodes[0] = _nodes[0]; - nodes[1] = _nodes[2]; - return new Line(nodes, _value); - } - - if (_nodes[0] == _nodes[2]) { - Node** nodes = new Node*[2]; - nodes[0] = _nodes[0]; - nodes[1] = _nodes[1]; - return new Line(nodes, _value); - } - - return NULL; -} - template <unsigned NNODES, CellType CELLTRITYPE> unsigned TemplateTri<NNODES,CELLTRITYPE>::identifyFace(Node* nodes[3]) const { diff --git a/MeshLib/Elements/TemplateTri.h b/MeshLib/Elements/TemplateTri.h index 6d1bb35427e60df038df363b04351eb5cdd600fe..499c551cd1c9e79e3118d2322cdfbe723b0aaa92 100644 --- a/MeshLib/Elements/TemplateTri.h +++ b/MeshLib/Elements/TemplateTri.h @@ -111,17 +111,6 @@ public: return new TemplateTri<NNODES,CELLTRITYPE>(*this); } - - /** - * This method should be called after at least two nodes of the triangle - * element are collapsed. As a consequence of the node collapsing an edge - * of the triangle will be collapsed. If one of the edges is collapsed we - * obtain an edge. In this case the method will create the appropriate - * object of class Edge. - * @return an Edge object or NULL - */ - virtual Element* reviseElement() const; - protected: /// Calculates the area of the triangle by returning half of the area of the corresponding parallelogram. double computeVolume() diff --git a/MeshLib/MeshEditing/MeshCoarsener.cpp b/MeshLib/MeshEditing/MeshCoarsener.cpp deleted file mode 100644 index 270b797d6a12652cbd24da622f0141148e7d6afd..0000000000000000000000000000000000000000 --- a/MeshLib/MeshEditing/MeshCoarsener.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date Aug 3, 2012 - * \brief Implementation of the MeshCoarsener class. - * - * \copyright - * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -// ThirdParty/logog -#include "logog/include/logog.hpp" - -#include "MeshCoarsener.h" - -// GeoLib -#include "Grid.h" - -// MeshLib -#include "Mesh.h" -#include "Node.h" -#include "Elements/Element.h" - -namespace MeshLib { - -MeshCoarsener::MeshCoarsener(Mesh const*const mesh) : - _orig_mesh (mesh) -{} - -MeshCoarsener::~MeshCoarsener() -{} - -Mesh* MeshCoarsener::operator()(double min_distance) -{ - // copy mesh nodes, reset mesh node ids and - // store original mesh node ids in a vector - std::vector<Node*> const& orig_nodes(_orig_mesh->getNodes()); - const size_t n_nodes(orig_nodes.size()); - std::vector<Node*> nodes(n_nodes); - std::map<size_t,size_t> orig_ids_map; - for (size_t k(0); k < n_nodes; k++) { - nodes[k] = new Node(orig_nodes[k]->getCoords(), k); - orig_ids_map.insert(std::pair<size_t, size_t>(orig_nodes[k]->getID(), k)); - } - - // init grid - GeoLib::Grid<Node>* grid(new GeoLib::Grid<Node>(nodes.begin(), nodes.end(), 64)); - - // init id map - std::vector<size_t> id_map(n_nodes); - for (size_t k(0); k < n_nodes; k++) { - id_map[k] = nodes[k]->getID(); - } - - const double sqr_min_distance (min_distance * min_distance); - - // do the work - search nearest nodes - for (size_t k(0); k < n_nodes; k++) { - std::vector<std::vector<Node*> const*> node_vecs_intersecting_cube; - Node const*const node(nodes[k]); - const size_t node_id_k(node->getID()); - grid->getPntVecsOfGridCellsIntersectingCube(node->getCoords(), min_distance, node_vecs_intersecting_cube); - - const size_t n_vecs (node_vecs_intersecting_cube.size()); - for (size_t i(0); i<n_vecs; i++) { - std::vector<Node*> const* node_vec (node_vecs_intersecting_cube[i]); - const size_t n_loc_nodes (node_vec->size()); - for (size_t j(0); j<n_loc_nodes; j++) { - Node const*const test_node((*node_vec)[j]); - const size_t test_node_id (test_node->getID()); - if (node_id_k < test_node_id) { - if (MathLib::sqrDist(node->getCoords(), test_node->getCoords()) < sqr_min_distance) { - // two nodes are very close to each other - id_map[test_node_id] = node_id_k; -#ifndef NDEBUG - INFO("distance of nodes with ids %d and %d is %f", node_id_k, test_node_id, sqrt(MathLib::sqrDist(node->getCoords(), test_node->getCoords()))); -#endif - } - } - } - } - } - - // apply changes to id_map - for (size_t k(0), cnt(0); k < n_nodes; k++) { - if (id_map[k] != k) { - if (id_map[k] != id_map[id_map[k]]) { - id_map[k] = id_map[id_map[k]]; - } - } else { - id_map[k] = cnt++; - } - } - - // delete unused nodes - for (size_t k(0), cnt(0); k < n_nodes; k++) { - if (id_map[k] != cnt) { - delete nodes[k]; - nodes[k] = NULL; - } else { - cnt++; - } - } - - // remove NULL-ptr from node vector - for (std::vector<Node*>::iterator it(nodes.begin()); it != nodes.end(); ) { - if (*it == NULL) { - it = nodes.erase (it); - } else { - it++; - } - } - - // reset mesh node ids - const size_t new_n_nodes(nodes.size()); - for (size_t k(0); k < new_n_nodes; k++) { - nodes[k]->setID(k); - } - - // copy mesh elements, reset the node pointers - std::vector<Element*> const& orig_elements(_orig_mesh->getElements()); - const size_t n_elements(orig_elements.size()); - std::vector<Element*> elements(n_elements); - std::vector<size_t> mapped_node_ids_of_element; - for (size_t k(0), cnt(0); k < n_elements; k++) { - Element const*const kth_orig_elem(orig_elements[k]); - const size_t n_nodes_element (kth_orig_elem->getNNodes()); - mapped_node_ids_of_element.clear(); - for (size_t i(0); i<n_nodes_element; i++) { - const size_t orig_node_id (kth_orig_elem->getNode(i)->getID()); - std::map<size_t, size_t>::const_iterator it(orig_ids_map.find(orig_node_id)); - if (it == orig_ids_map.end()) { - ERR("[MeshCoarsener::operator()] could not found mesh node id."); - } else { - mapped_node_ids_of_element.push_back(id_map[it->second]); - } - } - - // check if nodes of the element are collapsed - bool not_collapsed (true); - for (size_t i(0); i<n_nodes_element-1 && not_collapsed; i++) { - const size_t id_i(mapped_node_ids_of_element[i]); - for (size_t j(i+1); j<n_nodes_element && not_collapsed; j++) { - if (id_i == mapped_node_ids_of_element[j]) { - not_collapsed = false; - } - } - } - if (! not_collapsed) { - Element* elem (kth_orig_elem->clone()); - if (elem != NULL) { - for (size_t i(0); i<n_nodes_element; i++) { - elem->setNode(i, nodes[mapped_node_ids_of_element[i]]); - } - Element* revised_elem(elem->reviseElement()); - elements[cnt] = revised_elem; - delete elem; - cnt++; - } - } else { - elements[cnt] = kth_orig_elem->clone(); - for (size_t i(0); i<n_nodes_element; i++) { - elements[cnt]->setNode(i, nodes[mapped_node_ids_of_element[i]]); - } - cnt++; - } - } - - for (std::vector<Element*>::iterator it(elements.begin()); it != elements.end(); ) { - if (*it == NULL) { - it = elements.erase(it); - } else { - it++; - } - } - - return new Mesh (_orig_mesh->getName() + "Collapsed", nodes, elements); -} - -} // end namespace MeshLib diff --git a/MeshLib/MeshEditing/MeshCoarsener.h b/MeshLib/MeshEditing/MeshCoarsener.h deleted file mode 100644 index d9149561e5c76d9fc10f10c40c355c45a9144ca2..0000000000000000000000000000000000000000 --- a/MeshLib/MeshEditing/MeshCoarsener.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \file - * \author Thomas Fischer - * \date Aug 3, 2012 - * \brief Definition of the MeshCoarsener class. - * - * \copyright - * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#ifndef MESHCOARSENER_H_ -#define MESHCOARSENER_H_ - -#include <vector> -#include <cstddef> - -// forward declaration -namespace MeshLib { -class Mesh; -} - -namespace MeshLib { - -/** - * The class MeshCoarsener merges mesh nodes that have a smaller - * distance than a (user) given minimal distance. - */ -class MeshCoarsener { -public: - /** - * Constructor of class MeshCoarsener that takes the mesh object that should be coarsened. - * @param mesh the mesh object - */ - MeshCoarsener(Mesh const*const mesh); - - /** - * destructor. - */ - virtual ~MeshCoarsener(); - - /** - * create new mesh and apply the coarsening process to the mesh - * @param min_distance - */ - Mesh* operator() (double min_distance); - -private: - Mesh const*const _orig_mesh; -}; - -} - -#endif /* MESHCOARSENER_H_ */ diff --git a/MeshLib/MeshInformation.cpp b/MeshLib/MeshInformation.cpp index a3c4131be2eb4b96b7319b772a50bb5540c292cf..ad3faf023c608102144b9c000445df3a85eca69c 100644 --- a/MeshLib/MeshInformation.cpp +++ b/MeshLib/MeshInformation.cpp @@ -36,7 +36,7 @@ const GeoLib::AABB<MeshLib::Node> MeshInformation::getBoundingBox(const MeshLib: const std::array<unsigned, 7> MeshInformation::getNumberOfElementTypes(const MeshLib::Mesh &mesh) { - std::array<unsigned, 7> n_element_types = { 0, 0, 0, 0, 0, 0, 0 }; + std::array<unsigned, 7> n_element_types = {{0, 0, 0, 0, 0, 0, 0}}; const std::vector<MeshLib::Element*> &elements (mesh.getElements()); for (auto it = elements.begin(); it != elements.end(); ++it) { diff --git a/MeshLib/Node.h b/MeshLib/Node.h index f98638815992a60d4cd4d547a7bef05555a92593..e6000a6cd5d1e06584a308f48b60168c2a6e40c7 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -45,7 +45,6 @@ class Node : public GeoLib::PointWithID #endif /* friend classes: */ friend class Mesh; - friend class MeshCoarsener; friend class MeshRevision; diff --git a/SimpleTests/MeshTests/CMakeLists.txt b/SimpleTests/MeshTests/CMakeLists.txt index 3f0f8109c52038f468c0deec6910bce7ba56b0c8..8c1ba689ac823883b83b312a6dda5426fba85c52 100644 --- a/SimpleTests/MeshTests/CMakeLists.txt +++ b/SimpleTests/MeshTests/CMakeLists.txt @@ -30,23 +30,6 @@ TARGET_LINK_LIBRARIES ( MeshRead ${BOOST_LIBRARIES} ) -# Create CollapseMeshNodes executable -ADD_EXECUTABLE( CollapseMeshNodes - CollapseMeshNodes.cpp - ${SOURCES} - ${HEADERS} -) - -TARGET_LINK_LIBRARIES ( CollapseMeshNodes - MeshLib - FileIO - MathLib - BaseLib - GeoLib - logog - ${BOOST_LIBRARIES} -) - # Create MeshSearchTest executable ADD_EXECUTABLE( MeshSearchTest MeshSearchTest.cpp diff --git a/SimpleTests/MeshTests/CollapseMeshNodes.cpp b/SimpleTests/MeshTests/CollapseMeshNodes.cpp deleted file mode 100644 index f3db23d8088601904b6092cfd0284708ba8c8eb2..0000000000000000000000000000000000000000 --- a/SimpleTests/MeshTests/CollapseMeshNodes.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/LICENSE.txt - * - * \file CollapseMeshNodes.cpp - * - * Created on Jul 31, 2012 by Thomas Fischer - */ - -// BaseLib -#include "MemWatch.h" -#include "RunTime.h" -#include "tclap/CmdLine.h" -#include "LogogSimpleFormatter.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" - -// MeshLib -#include "Node.h" -#include "Elements/Element.h" -#include "Mesh.h" -#include "Legacy/MeshIO.h" -#include "MeshEditing/MeshCoarsener.h" - -int main(int argc, char *argv[]) -{ - LOGOG_INITIALIZE(); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog::Cout *logogCout(new logog::Cout); - logogCout->SetFormatter(*custom_format); - - TCLAP::CmdLine cmd("Collapse mesh nodes and, if necessary, remove elements", ' ', "0.1"); - - // Define a value argument and add it to the command line. - // A value arg defines a flag and a type of value that it expects, - // such as "-m meshfile". - TCLAP::ValueArg<std::string> input_mesh_arg("m","mesh","input mesh file name",true,"","string"); - // Add the argument mesh_arg to the CmdLine object. The CmdLine object - // uses this Arg to parse the command line. - cmd.add( input_mesh_arg ); - - TCLAP::ValueArg<std::string> output_mesh_arg("","out-mesh","mesh file name for output",false,"","string"); - cmd.add( output_mesh_arg ); - - TCLAP::ValueArg<double> distance_arg("d","collapse-distance","maximal distance two nodes are collapsed",false,0.01,"for example you can set this parameter to 10^{-6} times maximal area length"); - cmd.add( distance_arg ); - - cmd.parse( argc, argv ); - - std::string fname (input_mesh_arg.getValue()); - - FileIO::Legacy::MeshIO mesh_io; -#ifndef WIN32 - BaseLib::MemWatch mem_watch; - unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); - BaseLib::RunTime run_time; - run_time.start(); -#endif - MeshLib::Mesh* mesh = mesh_io.loadMeshFromFile(fname); -#ifndef WIN32 - if (mesh) { - unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); - INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); - } - run_time.stop(); - if (mesh) { - INFO ("time for reading: %f s", run_time.elapsed()); - } -#endif - -#ifndef WIN32 - unsigned long mem_without_meshgrid (mem_watch.getVirtMemUsage()); - run_time.start(); -#endif - MeshLib::MeshCoarsener mesh_coarsener(mesh); - MeshLib::Mesh *collapsed_mesh(mesh_coarsener (distance_arg.getValue())); - -#ifndef WIN32 - run_time.stop(); - unsigned long mem_with_meshgrid (mem_watch.getVirtMemUsage()); - INFO ("mem for meshgrid: %i MB", (mem_with_meshgrid - mem_without_meshgrid)/(1024*1024)); - INFO ("time for collapsing: %f s", run_time.elapsed()); -#endif - - mesh_io.setMesh(collapsed_mesh); - std::string out_fname (output_mesh_arg.getValue()); - if (out_fname.empty()) { - out_fname = "/home/fischeth/workspace/OGS-6/Build/CollapsedMesh.msh"; - } - INFO ("writing collapsed mesh to %s", out_fname.c_str()); - mesh_io.writeToFile(out_fname); - INFO ("done"); - - delete mesh; - delete collapsed_mesh; - delete custom_format; - delete logogCout; - LOGOG_SHUTDOWN(); - - return 0; -} diff --git a/Tests/MeshLib/TestMeshNodeSearch.cpp b/Tests/MeshLib/TestMeshNodeSearch.cpp index 2ba51b611cab887706dec96098990d12e497f1b2..491e1432fd717dc480fdca6b45fb2640e7e9ff9b 100644 --- a/Tests/MeshLib/TestMeshNodeSearch.cpp +++ b/Tests/MeshLib/TestMeshNodeSearch.cpp @@ -48,11 +48,11 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PointSearch) MeshGeoTools::MeshNodeSearcher mesh_node_searcher(*_quad_mesh); // find ORIGIN - ASSERT_EQ(0, mesh_node_searcher.getMeshNodeIDForPoint(pnt)); + ASSERT_EQ(0u, mesh_node_searcher.getMeshNodeIDForPoint(pnt)); pnt[0] = 0.049; pnt[1] = 0.049; - ASSERT_EQ(0, mesh_node_searcher.getMeshNodeIDForPoint(pnt)); + ASSERT_EQ(0u, mesh_node_searcher.getMeshNodeIDForPoint(pnt)); pnt[0] = 0.051; pnt[1] = 0.049; diff --git a/Tests/MeshLib/TestMeshRevision.cpp b/Tests/MeshLib/TestMeshRevision.cpp index ac3e7d1724c9061709dc53331bd26315b3a8241f..bd51551ef12c3388cc9ec299e41228bd3f675025 100644 --- a/Tests/MeshLib/TestMeshRevision.cpp +++ b/Tests/MeshLib/TestMeshRevision.cpp @@ -32,7 +32,7 @@ TEST(MeshEditing, Tri) nodes.push_back(new MeshLib::Node(0,0,0)); nodes.push_back(new MeshLib::Node(0,0,0.1)); - std::array<MeshLib::Node*, 3> nodes_array = { nodes[0], nodes[1], nodes[2] }; + std::array<MeshLib::Node*, 3> nodes_array = {{nodes[0], nodes[1], nodes[2]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem(new MeshLib::Tri(nodes_array)); elements.push_back(elem); @@ -47,7 +47,6 @@ TEST(MeshEditing, Tri) delete result; result = rev.simplifyMesh("new_mesh", 0.0999); - std::cout << MeshElemType2String(result->getElement(0)->getGeomType()) << std::endl; ASSERT_EQ(MeshElemType::TRIANGLE, result->getElement(0)->getGeomType()); ASSERT_EQ(0.05, result->getElement(0)->getContent()); ASSERT_EQ(3, result->getNNodes()); @@ -62,7 +61,7 @@ TEST(MeshEditing, NonPlanarQuad) nodes.push_back(new MeshLib::Node(1,1,0.1)); nodes.push_back(new MeshLib::Node(1,0,0)); - std::array<MeshLib::Node*, 4> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3] }; + std::array<MeshLib::Node*, 4> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Quad(nodes_array)); elements.push_back(elem); @@ -84,7 +83,7 @@ TEST(MeshEditing, Quad2Line) nodes.push_back(new MeshLib::Node(0,1,0.1)); nodes.push_back(new MeshLib::Node(1,0,0.1)); - std::array<MeshLib::Node*, 4> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3] }; + std::array<MeshLib::Node*, 4> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Quad(nodes_array)); elements.push_back(elem); @@ -108,7 +107,7 @@ TEST(MeshEditing, Quad2Tri) nodes.push_back(new MeshLib::Node(0,1,0.1)); nodes.push_back(new MeshLib::Node(1,1,0.1)); - std::array<MeshLib::Node*, 4> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3] }; + std::array<MeshLib::Node*, 4> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Quad(nodes_array)); elements.push_back(elem); @@ -136,7 +135,7 @@ TEST(MeshEditing, NonPlanarHex) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,1,1)); - std::array<MeshLib::Node*, 8> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7] }; + std::array<MeshLib::Node*, 8> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Hex(nodes_array)); elements.push_back(elem); @@ -165,7 +164,7 @@ TEST(MeshEditing, Hex2PyramidPrism) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,1,1)); - std::array<MeshLib::Node*, 8> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7] }; + std::array<MeshLib::Node*, 8> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Hex(nodes_array)); elements.push_back(elem); @@ -174,7 +173,7 @@ TEST(MeshEditing, Hex2PyramidPrism) MeshLib::MeshRevision rev(mesh); MeshLib::Mesh* result = rev.simplifyMesh("new_mesh", 0.2); - ASSERT_EQ(result->getNElements(), 2); + ASSERT_EQ(2u, result->getNElements()); ASSERT_EQ(MeshElemType::PYRAMID, result->getElement(0)->getGeomType()); ASSERT_EQ(MeshElemType::PRISM, result->getElement(1)->getGeomType()); ASSERT_NEAR(0.3333333333333333, result->getElement(0)->getContent(), std::numeric_limits<double>::epsilon()); @@ -195,7 +194,7 @@ TEST(MeshEditing, Hex2FourTets) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,1,1)); - std::array<MeshLib::Node*, 8> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7] }; + std::array<MeshLib::Node*, 8> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Hex(nodes_array)); elements.push_back(elem); @@ -226,7 +225,7 @@ TEST(MeshEditing, Hex2TwoTets) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(1,1,1)); - std::array<MeshLib::Node*, 8> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7] }; + std::array<MeshLib::Node*, 8> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Hex(nodes_array)); elements.push_back(elem); @@ -252,7 +251,7 @@ TEST(MeshEditing, NonPlanarPyramid) nodes.push_back(new MeshLib::Node(0,1,0)); nodes.push_back(new MeshLib::Node(1,0,1)); - std::array<MeshLib::Node*, 5> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4] }; + std::array<MeshLib::Node*, 5> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Pyramid(nodes_array)); elements.push_back(elem); @@ -278,7 +277,7 @@ TEST(MeshEditing, Pyramid2Tet) nodes.push_back(new MeshLib::Node(1,0,0)); nodes.push_back(new MeshLib::Node(1,0,1)); - std::array<MeshLib::Node*, 5> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4] }; + std::array<MeshLib::Node*, 5> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Pyramid(nodes_array)); elements.push_back(elem); @@ -303,7 +302,7 @@ TEST(MeshEditing, Pyramid2Quad) nodes.push_back(new MeshLib::Node(0,0,0)); nodes.push_back(new MeshLib::Node(1,0,0.1)); - std::array<MeshLib::Node*, 5> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4] }; + std::array<MeshLib::Node*, 5> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Pyramid(nodes_array)); elements.push_back(elem); @@ -328,7 +327,7 @@ TEST(MeshEditing, Pyramid2Tri) nodes.push_back(new MeshLib::Node(0,0,0)); nodes.push_back(new MeshLib::Node(1,0,0.1)); - std::array<MeshLib::Node*, 5> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4] }; + std::array<MeshLib::Node*, 5> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Pyramid(nodes_array)); elements.push_back(elem); @@ -355,7 +354,7 @@ TEST(MeshEditing, NonPlanarPrism) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,-0.5,2)); - std::array<MeshLib::Node*, 6> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5] }; + std::array<MeshLib::Node*, 6> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Prism(nodes_array)); elements.push_back(elem); @@ -381,7 +380,7 @@ TEST(MeshEditing, Prism2TwoTets) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,0,1)); - std::array<MeshLib::Node*, 6> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5] }; + std::array<MeshLib::Node*, 6> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Prism(nodes_array)); elements.push_back(elem); @@ -409,7 +408,7 @@ TEST(MeshEditing, Prism2Quad) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,0,1)); - std::array<MeshLib::Node*, 6> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5] }; + std::array<MeshLib::Node*, 6> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Prism(nodes_array)); elements.push_back(elem); @@ -435,7 +434,7 @@ TEST(MeshEditing, Prism2Tet) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0,0,1)); - std::array<MeshLib::Node*, 6> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5] }; + std::array<MeshLib::Node*, 6> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Prism(nodes_array)); elements.push_back(elem); @@ -461,7 +460,7 @@ TEST(MeshEditing, Prism2Tri) nodes.push_back(new MeshLib::Node(1,1,1)); nodes.push_back(new MeshLib::Node(0.9,0.9,1)); - std::array<MeshLib::Node*, 6> nodes_array = { nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5] }; + std::array<MeshLib::Node*, 6> nodes_array = {{nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5]}}; std::vector<MeshLib::Element*> elements; MeshLib::Element* elem (new MeshLib::Prism(nodes_array)); elements.push_back(elem);