22template <
typename QuadraticElement>
26 int const n_all_nodes = QuadraticElement::n_all_nodes;
27 int const n_base_nodes = QuadraticElement::n_base_nodes;
31 std::array<MeshLib::Node*, n_all_nodes> nodes{};
32 for (
int i = 0; i < n_base_nodes; i++)
39 for (
int i = 0; i < number_of_edges; i++)
45 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
48 return std::make_unique<QuadraticElement>(nodes, e.
getID());
61 std::array<MeshLib::Node*, n_all_nodes> nodes{};
62 for (
int i = 0; i < n_base_nodes; i++)
69 for (
int i = 0; i < number_of_edges; i++)
75 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
80 for (
int i = 0; i < n_base_nodes; i++)
82 for (
int d = 0; d < 3; d++)
84 (*centre_node)[d] += (*nodes[i])[d] / n_base_nodes;
87 nodes[n_all_nodes - 1] = centre_node;
89 return std::make_unique<MeshLib::Quad9>(nodes, e.
getID());
102 std::array<MeshLib::Node*, n_all_nodes> nodes{};
103 for (
int i = 0; i < n_base_nodes; i++)
110 for (
int i = 0; i < 3; i++)
116 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
118 for (
int i = 3; i < 6; i++)
124 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
126 for (
int i = 6; i < number_of_edges; i++)
132 (a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2);
135 return std::make_unique<MeshLib::Prism15>(nodes, e.
getID());
175 OGS_FATAL(
"Mesh element type {:s} is not supported",
190 MeshLib::Mesh const& linear_mesh,
bool const add_centre_node)
196 std::set<MeshLib::Node*, nodeByCoordinatesComparator> unique_nodes;
199 std::vector<MeshLib::Element*> quadratic_elements;
200 auto const& linear_mesh_elements = linear_mesh.
getElements();
206 int const number_base_nodes = quadratic_element->getNumberOfBaseNodes();
207 for (
int i = 0; i < number_base_nodes; ++i)
209 quadratic_element->setNode(
210 i, quadratic_mesh_nodes[getNodeIndex(*quadratic_element, i)]);
214 int const number_all_nodes = quadratic_element->getNumberOfNodes();
215 for (
int i = number_base_nodes; i < number_all_nodes; ++i)
220 auto it = unique_nodes.insert(original_node);
225 quadratic_element->setNode(i, *it.first);
227 delete original_node;
231 quadratic_elements.push_back(quadratic_element.release());
235 quadratic_mesh_nodes.reserve(linear_mesh.
getNodes().size() +
236 unique_nodes.size());
237 std::copy(unique_nodes.begin(), unique_nodes.end(),
238 std::back_inserter(quadratic_mesh_nodes));
240 return std::make_unique<MeshLib::Mesh>(
241 linear_mesh.
getName(), quadratic_mesh_nodes, quadratic_elements,
244 std::vector<MeshLib::MeshItemType>(1,
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.
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
static const unsigned n_base_nodes
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