19#include <range/v3/view/transform.hpp>
29 class NodeWiseMeshPartitioner;
44 const std::vector<std::size_t>& nodes);
54 Mesh(std::string name,
125 std::size_t node_id)
const;
127 Node const& node)
const;
181 std::string
const& property_name,
196 MeshItemType item_type, std::size_t number_of_components,
197 std::vector<T>
const& values)
204 "Error number of nodes ({:d}) does not match the number of "
214 "Error number of elements ({:d}) does not match the number of "
217 values.size() / number_of_components);
222 name, item_type, number_of_components);
225 OGS_FATAL(
"Error while creating PropertyVector '{:s}'.", name);
227 property->reserve(values.size());
228 std::copy(values.cbegin(), values.cend(), std::back_inserter(*property));
237 std::string
const& property_name,
239 int const number_of_components)
241 if (property_name.empty())
244 "Trying to get or to create a mesh property with empty name.");
247 auto numberOfMeshItems = [&mesh, &item_type]() -> std::size_t {
259 "getOrCreateMeshProperty cannot handle other "
260 "types than Node, Cell, or IntegrationPoint.");
268 mesh.
getProperties().template getPropertyVector<T>(property_name);
274 assert(result->size() ==
275 numberOfMeshItems() * number_of_components);
280 auto result = mesh.
getProperties().template createNewPropertyVector<T>(
281 property_name, item_type, number_of_components);
283 result->resize(numberOfMeshItems() * number_of_components);
292PropertyVector<int>
const*
materialIDs(Mesh
const& mesh);
299 std::string mesh_name, std::vector<Element*>
const& elements);
304 std::vector<Element const*>
const& elements_connected_to_node);
308 std::vector<Element*>
const& elements);
314inline constexpr ranges::views::view_closure
ids =
315 ranges::views::transform([](
auto const& a) {
return a->getID(); });
318inline constexpr ranges::views::view_closure
names =
319 ranges::views::transform([](
auto const& a) {
return a->getName(); });
Definition of mesh-related Enumerations.
Definition of the class Properties that implements a container of properties.
bool isAxiallySymmetric() const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
void calcEdgeLengthRange()
Set the minimum and maximum length over the edges of the mesh.
std::vector< std::vector< Element const * > > _elements_connected_to_nodes
void setName(const std::string &name)
Changes the name of the mesh.
void addElement(Element *elem)
Add an element to the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
std::size_t computeNumberOfBaseNodes() const
Get the number of base nodes.
friend void removeMeshNodes(Mesh &mesh, const std::vector< std::size_t > &nodes)
Mesh & operator=(Mesh &&mesh)=delete
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::size_t getID() const
Get id of the mesh.
void resetNodeIDs()
Resets the IDs of all mesh-nodes to their position in the node vector.
const Node * getNode(std::size_t idx) const
Get the node with the given index.
Properties & getProperties()
const Element * getElement(std::size_t idx) const
Get the element with the given index.
std::vector< Element * > _elements
void setDimension()
Sets the dimension of the mesh.
const std::string getName() const
Get name of the mesh.
void resetElementIDs()
Resets the IDs of all mesh-elements to their position in the element vector.
void setElementNeighbors()
virtual ~Mesh()
Destructor.
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
void setAxiallySymmetric(bool is_axial_symmetric)
std::pair< double, double > _node_distance
The minimal and maximal distance of nodes within an element over all elements in the mesh.
Mesh & operator=(const Mesh &mesh)=delete
Properties const & getProperties() const
bool hasNonlinearElement() const
Check if the mesh contains any nonlinear element.
std::size_t getNumberOfElements() const
Get the number of elements.
std::vector< Node * > _nodes
bool _is_axially_symmetric
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
constexpr ranges::views::view_closure names
For an element of a range view return its name.
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
std::unique_ptr< MeshLib::Mesh > createMeshFromElementSelection(std::string mesh_name, std::vector< MeshLib::Element * > const &elements)
std::vector< std::vector< Node * > > calculateNodesConnectedByElements(Mesh const &mesh)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
std::pair< double, double > minMaxEdgeLength(std::vector< Element * > const &elements)
Returns the minimum and maximum edge length for given elements.
bool operator==(Mesh const &a, Mesh const &b)
Meshes are equal if their id's are equal.
bool operator!=(Mesh const &a, Mesh const &b)
bool isBaseNode(Node const &node, std::vector< Element const * > const &elements_connected_to_node)
void scaleMeshPropertyVector(MeshLib::Mesh &mesh, std::string const &property_name, double factor)
void addPropertyToMesh(Mesh &mesh, std::string_view name, MeshItemType item_type, std::size_t number_of_components, std::vector< T > const &values)