From 87c685aba3c24c8cee81f1e86372f9606a1ab531 Mon Sep 17 00:00:00 2001 From: Norihiro Watanabe <norihiro.watanabe@ufz.de> Date: Mon, 31 Mar 2014 16:50:59 +0200 Subject: [PATCH] add dimension, n_all_nodes, n_base_nodes to element classes as static const --- MeshLib/Elements/Cell.cpp | 3 +++ MeshLib/Elements/Cell.h | 3 +++ MeshLib/Elements/TemplateHex-impl.h | 6 ++++++ MeshLib/Elements/TemplateHex.h | 6 ++++++ MeshLib/Elements/TemplateLine-impl.h | 9 +++++++++ MeshLib/Elements/TemplateLine.h | 9 +++++++++ MeshLib/Elements/TemplatePrism-impl.h | 6 ++++++ MeshLib/Elements/TemplatePrism.h | 6 ++++++ MeshLib/Elements/TemplatePyramid-impl.h | 6 ++++++ MeshLib/Elements/TemplatePyramid.h | 6 ++++++ MeshLib/Elements/TemplateQuad-impl.h | 15 +++++++++++++++ MeshLib/Elements/TemplateQuad.h | 15 --------------- MeshLib/Elements/TemplateTet-impl.h | 6 ++++++ MeshLib/Elements/TemplateTet.h | 6 ++++++ MeshLib/Elements/TemplateTri-impl.h | 13 +++++++++++++ MeshLib/Elements/TemplateTri.h | 13 ++++++------- 16 files changed, 106 insertions(+), 22 deletions(-) diff --git a/MeshLib/Elements/Cell.cpp b/MeshLib/Elements/Cell.cpp index 9f3cb643618..f65b8a5e7e8 100644 --- a/MeshLib/Elements/Cell.cpp +++ b/MeshLib/Elements/Cell.cpp @@ -17,6 +17,9 @@ #include "Vector3.h" namespace MeshLib { + +const unsigned Cell::dimension = 3u; + /* Cell::Cell(Node** nodes, MeshElemType type, unsigned value) : Element(nodes, type, value) diff --git a/MeshLib/Elements/Cell.h b/MeshLib/Elements/Cell.h index 6db9df79cc2..6cbb2688160 100644 --- a/MeshLib/Elements/Cell.h +++ b/MeshLib/Elements/Cell.h @@ -26,6 +26,9 @@ namespace MeshLib { class Cell : public Element { public: + /// Constant: Dimension of this mesh element + static const unsigned dimension; + /// Returns the length, area or volume of a 1D, 2D or 3D element double getContent() const { return _volume; }; diff --git a/MeshLib/Elements/TemplateHex-impl.h b/MeshLib/Elements/TemplateHex-impl.h index 3a495484b18..0a448896bf2 100644 --- a/MeshLib/Elements/TemplateHex-impl.h +++ b/MeshLib/Elements/TemplateHex-impl.h @@ -22,6 +22,12 @@ namespace MeshLib { +template <unsigned NNODES, CellType CELLHEXTYPE> +const unsigned TemplateHex<NNODES, CELLHEXTYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLHEXTYPE> +const unsigned TemplateHex<NNODES, CELLHEXTYPE>::n_base_nodes = 8; + template <unsigned NNODES, CellType CELLHEXTYPE> const unsigned TemplateHex<NNODES,CELLHEXTYPE>::_face_nodes[6][4] = { diff --git a/MeshLib/Elements/TemplateHex.h b/MeshLib/Elements/TemplateHex.h index ba3567a3b77..f44073f943c 100644 --- a/MeshLib/Elements/TemplateHex.h +++ b/MeshLib/Elements/TemplateHex.h @@ -50,6 +50,12 @@ template <unsigned NNODES, CellType CELLHEXTYPE> class TemplateHex : public Cell { public: + /// Constant: The number of all nodes for this element + static const unsigned n_all_nodes; + + /// Constant: The number of base nodes for this element + static const unsigned n_base_nodes; + /// Constructor with an array of mesh nodes. TemplateHex(Node* nodes[NNODES], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); diff --git a/MeshLib/Elements/TemplateLine-impl.h b/MeshLib/Elements/TemplateLine-impl.h index dc9d537568a..692770bf41f 100644 --- a/MeshLib/Elements/TemplateLine-impl.h +++ b/MeshLib/Elements/TemplateLine-impl.h @@ -58,5 +58,14 @@ ElementErrorCode TemplateLine<NNODES,CELLLINETYPE>::validate() const return error_code; } +template <unsigned NNODES, CellType CELLLINETYPE> +const unsigned TemplateLine<NNODES, CELLLINETYPE>::dimension = 1u; + +template <unsigned NNODES, CellType CELLLINETYPE> +const unsigned TemplateLine<NNODES, CELLLINETYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLLINETYPE> +const unsigned TemplateLine<NNODES, CELLLINETYPE>::n_base_nodes = 2u; + } // namespace MeshLib diff --git a/MeshLib/Elements/TemplateLine.h b/MeshLib/Elements/TemplateLine.h index 8341a59c00e..48eb3747a25 100644 --- a/MeshLib/Elements/TemplateLine.h +++ b/MeshLib/Elements/TemplateLine.h @@ -38,6 +38,15 @@ template<unsigned NNODES, CellType CELLLINETYPE> class TemplateLine : public Element { public: + /// Constant: Dimension of this mesh element + static const unsigned dimension; + + /// Constant: The number of all nodes for this element + static const unsigned n_all_nodes; + + /// Constant: The number of base nodes for this element + static const unsigned n_base_nodes; + /// Constructor with an array of mesh nodes. TemplateLine(Node* nodes[NNODES], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); diff --git a/MeshLib/Elements/TemplatePrism-impl.h b/MeshLib/Elements/TemplatePrism-impl.h index 2fc811a73d9..6910f7b88be 100644 --- a/MeshLib/Elements/TemplatePrism-impl.h +++ b/MeshLib/Elements/TemplatePrism-impl.h @@ -24,6 +24,12 @@ namespace MeshLib { +template <unsigned NNODES, CellType CELLPRISMTYPE> +const unsigned TemplatePrism<NNODES, CELLPRISMTYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLPRISMTYPE> +const unsigned TemplatePrism<NNODES, CELLPRISMTYPE>::n_base_nodes = 6; + template <unsigned NNODES, CellType CELLPRISMTYPE> const unsigned TemplatePrism<NNODES,CELLPRISMTYPE>::_face_nodes[5][4] = { diff --git a/MeshLib/Elements/TemplatePrism.h b/MeshLib/Elements/TemplatePrism.h index 98afdec004f..3bdace172e2 100644 --- a/MeshLib/Elements/TemplatePrism.h +++ b/MeshLib/Elements/TemplatePrism.h @@ -48,6 +48,12 @@ template <unsigned NNODES, CellType CELLPRISMTYPE> class TemplatePrism : public Cell { public: + /// Constant: The number of all nodes for this element + static const unsigned n_all_nodes; + + /// Constant: The number of base nodes for this element + static const unsigned n_base_nodes; + /// Constructor with an array of mesh nodes. TemplatePrism(Node* nodes[NNODES], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); diff --git a/MeshLib/Elements/TemplatePyramid-impl.h b/MeshLib/Elements/TemplatePyramid-impl.h index 31afb22c029..c37d6d40c1c 100644 --- a/MeshLib/Elements/TemplatePyramid-impl.h +++ b/MeshLib/Elements/TemplatePyramid-impl.h @@ -24,6 +24,12 @@ namespace MeshLib { +template <unsigned NNODES, CellType CELLPYRAMIDTYPE> +const unsigned TemplatePyramid<NNODES, CELLPYRAMIDTYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLPYRAMIDTYPE> +const unsigned TemplatePyramid<NNODES, CELLPYRAMIDTYPE>::n_base_nodes = 5; + template <unsigned NNODES, CellType CELLPYRAMIDTYPE> const unsigned TemplatePyramid<NNODES,CELLPYRAMIDTYPE>::_face_nodes[5][4] = { diff --git a/MeshLib/Elements/TemplatePyramid.h b/MeshLib/Elements/TemplatePyramid.h index 2630e3c65af..687913dbfe3 100644 --- a/MeshLib/Elements/TemplatePyramid.h +++ b/MeshLib/Elements/TemplatePyramid.h @@ -46,6 +46,12 @@ template <unsigned NNODES, CellType CELLPYRAMIDTYPE> class TemplatePyramid : public Cell { public: + /// Constant: The number of all nodes for this element + static const unsigned n_all_nodes; + + /// Constant: The number of base nodes for this element + static const unsigned n_base_nodes; + /// Constructor with an array of mesh nodes. TemplatePyramid(Node* nodes[NNODES], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); diff --git a/MeshLib/Elements/TemplateQuad-impl.h b/MeshLib/Elements/TemplateQuad-impl.h index 75f4f97f0a2..3cee0ef1153 100644 --- a/MeshLib/Elements/TemplateQuad-impl.h +++ b/MeshLib/Elements/TemplateQuad-impl.h @@ -24,6 +24,21 @@ namespace MeshLib { +template <unsigned NNODES, CellType CELLQUADTYPE> +const unsigned TemplateQuad<NNODES, CELLQUADTYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLQUADTYPE> +const unsigned TemplateQuad<NNODES, CELLQUADTYPE>::n_base_nodes = 4; + +template <unsigned NNODES, CellType CELLQUADTYPE> +const unsigned TemplateQuad<NNODES, CELLQUADTYPE>::_edge_nodes[4][2] = +{ + {0, 1}, // Edge 0 + {1, 2}, // Edge 1 + {2, 3}, // Edge 2 + {0, 3} // Edge 3 +}; + template <unsigned NNODES, CellType CELLQUADTYPE> TemplateQuad<NNODES,CELLQUADTYPE>::TemplateQuad(Node* nodes[NNODES], unsigned value, std::size_t id) : Face(value, id) diff --git a/MeshLib/Elements/TemplateQuad.h b/MeshLib/Elements/TemplateQuad.h index 909ecdce735..81b61de3208 100644 --- a/MeshLib/Elements/TemplateQuad.h +++ b/MeshLib/Elements/TemplateQuad.h @@ -123,21 +123,6 @@ protected: static const unsigned _edge_nodes[4][2]; }; /* class */ -template <unsigned NNODES, CellType CELLQUADTYPE> -const unsigned TemplateQuad<NNODES, CELLQUADTYPE>::_edge_nodes[4][2] = -{ - {0, 1}, // Edge 0 - {1, 2}, // Edge 1 - {2, 3}, // Edge 2 - {0, 3} // Edge 3 -}; - -template <unsigned NNODES, CellType CELLQUADTYPE> -const unsigned TemplateQuad<NNODES, CELLQUADTYPE>::n_all_nodes = NNODES; - -template <unsigned NNODES, CellType CELLQUADTYPE> -const unsigned TemplateQuad<NNODES, CELLQUADTYPE>::n_base_nodes = 4; - } /* namespace */ #include "TemplateQuad-impl.h" diff --git a/MeshLib/Elements/TemplateTet-impl.h b/MeshLib/Elements/TemplateTet-impl.h index ceb9ffcb372..01425b06d7b 100644 --- a/MeshLib/Elements/TemplateTet-impl.h +++ b/MeshLib/Elements/TemplateTet-impl.h @@ -21,6 +21,12 @@ namespace MeshLib { +template <unsigned NNODES, CellType CELLTETTYPE> +const unsigned TemplateTet<NNODES, CELLTETTYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLTETTYPE> +const unsigned TemplateTet<NNODES, CELLTETTYPE>::n_base_nodes = 4; + template <unsigned NNODES, CellType CELLTETTYPE> const unsigned TemplateTet<NNODES,CELLTETTYPE>::_face_nodes[4][3] = { diff --git a/MeshLib/Elements/TemplateTet.h b/MeshLib/Elements/TemplateTet.h index a1d3c32c507..647003d2551 100644 --- a/MeshLib/Elements/TemplateTet.h +++ b/MeshLib/Elements/TemplateTet.h @@ -45,6 +45,12 @@ template <unsigned NNODES, CellType CELLTETTYPE> class TemplateTet : public Cell { public: + /// Constant: The number of all nodes for this element + static const unsigned n_all_nodes; + + /// Constant: The number of base nodes for this element + static const unsigned n_base_nodes; + /// Constructor with an array of mesh nodes. TemplateTet(Node* nodes[NNODES], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); diff --git a/MeshLib/Elements/TemplateTri-impl.h b/MeshLib/Elements/TemplateTri-impl.h index 736e8195a0e..1993b5b825b 100644 --- a/MeshLib/Elements/TemplateTri-impl.h +++ b/MeshLib/Elements/TemplateTri-impl.h @@ -17,6 +17,19 @@ namespace MeshLib { +template <unsigned NNODES, CellType CELLTRITYPE> +const unsigned TemplateTri<NNODES, CELLTRITYPE>::n_all_nodes = NNODES; + +template <unsigned NNODES, CellType CELLTRITYPE> +const unsigned TemplateTri<NNODES, CELLTRITYPE>::n_base_nodes = 3; + +template <unsigned NNODES, CellType CELLTRITYPE> +const unsigned TemplateTri<NNODES,CELLTRITYPE>::_edge_nodes[3][2] = { + {0, 1}, // Edge 0 + {1, 2}, // Edge 1 + {0, 2} // Edge 2 + }; + template <unsigned NNODES, CellType CELLTRITYPE> TemplateTri<NNODES,CELLTRITYPE>::TemplateTri(Node* nodes[NNODES], unsigned value, std::size_t id) : Face(value, id) diff --git a/MeshLib/Elements/TemplateTri.h b/MeshLib/Elements/TemplateTri.h index e0eee786f5b..39eeec3c1b9 100644 --- a/MeshLib/Elements/TemplateTri.h +++ b/MeshLib/Elements/TemplateTri.h @@ -47,6 +47,12 @@ template <unsigned NNODES, CellType CELLTRITYPE> class TemplateTri : public Face { public: + /// Constant: The number of all nodes for this element + static const unsigned n_all_nodes; + + /// Constant: The number of base nodes for this element + static const unsigned n_base_nodes; + /// Constructor with an array of mesh nodes. TemplateTri(Node* nodes[NNODES], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); @@ -131,13 +137,6 @@ protected: static const unsigned _edge_nodes[3][2]; }; /* class */ -template <unsigned NNODES, CellType CELLTRITYPE> -const unsigned TemplateTri<NNODES,CELLTRITYPE>::_edge_nodes[3][2] = { - {0, 1}, // Edge 0 - {1, 2}, // Edge 1 - {0, 2} // Edge 2 - }; - } /* namespace */ #include "TemplateTri-impl.h" -- GitLab