28template <
typename QuadraticElement>
32 int const n_all_nodes = QuadraticElement::n_all_nodes;
33 int const n_base_nodes = QuadraticElement::n_base_nodes;
37 std::array<MeshLib::Node*, n_all_nodes> nodes{};
38 for (
int i = 0; i < n_base_nodes; i++)
45 for (
int i = 0; i < number_of_edges; i++)
51 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
54 return std::make_unique<QuadraticElement>(nodes, e.
getID());
67 std::array<MeshLib::Node*, n_all_nodes> nodes{};
68 for (
int i = 0; i < n_base_nodes; i++)
75 for (
int i = 0; i < number_of_edges; i++)
81 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
86 for (
int i = 0; i < n_base_nodes; i++)
88 for (
int d = 0; d < 3; d++)
90 (*centre_node)[d] += (*nodes[i])[d] / n_base_nodes;
93 nodes[n_all_nodes - 1] = centre_node;
95 return std::make_unique<MeshLib::Quad9>(nodes, e.
getID());
108 std::array<MeshLib::Node*, n_all_nodes> nodes{};
109 for (
int i = 0; i < n_base_nodes; i++)
116 for (
int i = 0; i < 3; i++)
122 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
124 for (
int i = 3; i < 6; i++)
130 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
132 for (
int i = 6; i < number_of_edges; i++)
138 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
141 return std::make_unique<MeshLib::Prism15>(nodes, e.
getID());
181 OGS_FATAL(
"Mesh element type {:s} is not supported",
196 MeshLib::Mesh const& linear_mesh,
bool const add_centre_node)
202 std::set<MeshLib::Node*, nodeByCoordinatesComparator> unique_nodes;
205 std::vector<MeshLib::Element*> quadratic_elements;
206 auto const& linear_mesh_elements = linear_mesh.
getElements();
212 int const number_base_nodes = quadratic_element->getNumberOfBaseNodes();
213 for (
int i = 0; i < number_base_nodes; ++i)
215 quadratic_element->setNode(
216 i, quadratic_mesh_nodes[getNodeIndex(*quadratic_element, i)]);
220 int const number_all_nodes = quadratic_element->getNumberOfNodes();
221 for (
int i = number_base_nodes; i < number_all_nodes; ++i)
226 auto it = unique_nodes.insert(original_node);
231 quadratic_element->setNode(i, *it.first);
233 delete original_node;
237 quadratic_elements.push_back(quadratic_element.release());
241 quadratic_mesh_nodes.reserve(linear_mesh.
getNodes().size() +
242 unique_nodes.size());
243 std::copy(unique_nodes.begin(), unique_nodes.end(),
244 std::back_inserter(quadratic_mesh_nodes));
246 return std::make_unique<MeshLib::Mesh>(
247 linear_mesh.
getName(), quadratic_mesh_nodes, quadratic_elements,
250 std::vector<MeshLib::MeshItemType>(1,
Definition of Duplicate functions.
Definition of the Element class.
Definition of the Hex class.
Definition of the Line class.
Definition of the Mesh class.
Definition of the Node class.
Definition of the Prism class.
Definition of the Pyramid class.
Definition of the Quad class.
std::unique_ptr< MeshLib::Element > createQuadraticElement(MeshLib::Element const &e, bool const add_centre_node)
Return a new quadratic element corresponding to the linear element's type.
std::unique_ptr< MeshLib::Prism15 > convertLinearToQuadratic< MeshLib::Prism15 >(MeshLib::Element const &e)
Special case for Prism15.
std::unique_ptr< QuadraticElement > convertLinearToQuadratic(MeshLib::Element const &e)
std::unique_ptr< MeshLib::Quad9 > convertLinearToQuadratic< MeshLib::Quad9 >(MeshLib::Element const &e)
Special case for Quad-9 adding a centre node too.
Definition of the Tet class.
Definition of the Tri class.
virtual CellType getCellType() const =0
virtual unsigned getNumberOfBaseNodes() const =0
virtual const Node * getNode(unsigned idx) const =0
virtual unsigned getNumberOfEdges() const =0
Get the number of edges for this element.
std::size_t getID() const
Returns the ID of the element.
virtual Node * getEdgeNode(unsigned edge_id, unsigned node_id) const =0
Return a specific edge node.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Properties & getProperties()
const std::string getName() const
Get name of the mesh.
Properties excludeCopyProperties(std::vector< std::size_t > const &exclude_elem_ids, std::vector< std::size_t > const &exclude_node_ids) const
static const unsigned n_all_nodes
Constant: The number of all nodes for this element.
static const unsigned n_base_nodes
Constant: The number of base nodes for this element.
std::vector< Node * > copyNodeVector(const std::vector< Node * > &nodes)
Creates a deep copy of a Node vector.
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
bool operator()(MeshLib::Node const *a, MeshLib::Node const *b) const