diff --git a/ExtraTypes.cpp b/ExtraTypes.cpp new file mode 100644 index 0000000000000000000000000000000000000000..572ef20366678d7e5e419047203781ab9947b607 --- /dev/null +++ b/ExtraTypes.cpp @@ -0,0 +1,99 @@ +#include "SupportTypes.h" + +#include + +bool Node::operator==(const Node& right_node) const { + return (id == right_node.id && cords[0] == right_node.cords[0] && cords[1] == right_node.cords[1] && cords[2] == right_node.cords[2] && isApex == right_node.isApex); +}; + +std::ostream& operator<<(std::ostream& out_stream, const Node& node_) { + out_stream << std::setw(4) << node_.id << " |" + << std::right << std::setw(11) << node_.cords[0] << std::setw(11) << node_.cords[1] << std::setw(11) << node_.cords[2] + << " | " << node_.isApex << "\n"; // STD::ENDL + return out_stream; +} + +std::ostream& operator<<(std::ostream& out_stream, const FiniteElement& element_) { + out_stream << std::setw(4) << element_.id << " |" + << std::setw(11) << element_.id_material << " |"; + for (const auto& nodes_it : element_.nodes_id) + out_stream << std::right << std::setw(4) << nodes_it; + out_stream << "\n"; + return out_stream; +} + +std::ostream& operator<<(std::ostream& out_stream, const BoundaryFiniteElement& b) { + out_stream << std::setw(9) << b.id<< " |" + << std::setw(9) << b.border_id << " |"; + for (const auto& nodes_it : b.nodes_id) + out_stream << std::right << std::setw(4) << nodes_it; + out_stream << "\n"; + return out_stream; +} + +std::ostream& operator<<(std::ostream& out_stream, const std::vector& nodes_) { + out_stream << nodes_.size() << (nodes_.size() > 1 ? " Nodes:\n" : " Node:\n") << " ID" + << std::setw(10) << "X" << std::setw(11) << "Y" << std::setw(11) << "Z" << std::setw(14) << "isApex\n"; + for (const auto& it : nodes_) + out_stream << it; + return out_stream; +} + +Node::Node() +{ + id = 0; + cords[0] = 0; + cords[1] = 0; + cords[2] = 0; + isApex = 0; +} + +Node::Node(int ID_, int x_, int y_, int z_, bool apex_) +{ + id = ID_; + cords[0] = x_; + cords[1] = y_; + cords[2] = z_; + isApex = apex_; +} + +bool Node::operator<(const Node& right_node) const { + return id < right_node.id; +} + +std::ostream& operator<<(std::ostream& out_stream, const std::vector& elements_) { + int elements_size = elements_.size(); + out_stream << elements_size << (elements_size > 1 ? "Finite Elements:\n" : "Finite Element:\n") + << " ID" << std::setw(15) << "Material_ID" << std::setw(15) << "Nodes ID\n"; + for (const auto& it : elements_) + out_stream << it; + return out_stream; +} + +std::ostream& operator<<(std::ostream& out_stream, const std::vector& b) { + int b_size = b.size(); + out_stream << b_size << (b_size > 1 ? " Surfaces:\n" : " Surface:\n") + << "Surface_ID" << std::setw(11) << "Border_ID" << std::setw(14) << "Nodes ID\n"; + for (const auto& it : b) + out_stream << it; + return out_stream; +} + +Edge::Edge(int id1, int id2, int id3) : + f_id(id1), l_id(id2), c_id(id3) {} + +void Edge::update(int id) { + c_id = id; +} + +bool Edge::operator==(const Edge& right_edge) const { + if (right_edge.f_id == f_id && right_edge.l_id == l_id) + return true; + else if (right_edge.f_id == l_id && right_edge.l_id == f_id) + return true; + else return false; +} + +bool Edge::operator<(const Edge& right_edge) const { + return c_id < right_edge.c_id; +}