OGS
MeshLib Namespace Reference

Detailed Description

Author
Karsten Rink
Date
2010-08-25

Contains all functionality concerned with defining and obtaining information about meshes and their components (nodes, elements). Also includes additional algorithms for generating and modifying meshes and elements.

See also
MeshGenerator

Namespaces

 anonymous_namespace{AngleSkewMetric.cpp}
 
 anonymous_namespace{ConvertToLinearMesh.cpp}
 
 BoundaryExtraction
 
 detail
 
 details
 
 IO
 
 MeshGenerator
 
 ProjectPointOnMesh
 
 RasterDataToMesh
 Adding pixel values from a raster onto nodes or cells of a mesh.
 
 views
 MeshLib specific, lazy, non-owning, non-mutating, composable range views.
 

Classes

class  PropertyVector
 
struct  CoordinateSystemType
 Coordinate system type. More...
 
class  CoordinateSystem
 Coordinate systems. More...
 
class  ElementCoordinatesMappingLocal
 
class  CellRule
 
class  NoEdgeReturn
 Returns always null pointer. More...
 
class  LinearEdgeReturn
 Returns linear order edge. More...
 
class  QuadraticEdgeReturn
 Returns quadratic order edge. More...
 
class  EdgeRule
 
class  Element
 
class  FaceRule
 
class  HexRule20
 
class  HexRule8
 
class  LineRule2
 
class  LineRule3
 
class  PointRule1
 A 0d point element. More...
 
class  PrismRule15
 
class  PrismRule6
 
class  PyramidRule13
 
class  PyramidRule5
 
class  QuadRule4
 
class  QuadRule8
 
class  QuadRule9
 
class  TemplateElement
 
class  TetRule10
 
class  TetRule4
 
class  TriRule3
 
class  TriRule6
 
class  VertexRule
 
class  ElementStatus
 
struct  Location
 
class  Mesh
 
class  ElementValueModification
 A set of methods for manipulating mesh element values. More...
 
class  Mesh2MeshPropertyInterpolation
 
class  MeshRevision
 
class  MeshLayerMapper
 Manipulating and adding prism element layers to an existing 2D mesh. More...
 
class  RasterToMesh
 Converts raster data into an OGS mesh. More...
 
class  VtkMeshConverter
 Converter for VtkUnstructured Grids to OGS meshes. More...
 
class  MeshInformation
 A set of tools for extracting information from a mesh. More...
 
struct  AngleSkewMetric
 
struct  EdgeRatioMetric
 
class  ElementQualityInterface
 
class  ElementQualityMetric
 
class  ElementSizeMetric
 
struct  MeshValidation
 A collection of methods for testing mesh quality and correctness. More...
 
struct  RadiusEdgeRatioMetric
 
struct  SizeDifferenceMetric
 
class  ElementSearch
 Element search class. More...
 
class  MeshElementGrid
 
class  NodeSearch
 Node search class. More...
 
class  MeshSubset
 A subset of nodes on a single mesh. More...
 
class  MeshSurfaceExtraction
 A set of tools concerned with extracting nodes and elements from a mesh surface. More...
 
class  Node
 
class  NodeAdjacencyTable
 
class  NodePartitionedMesh
 A subdomain mesh. More...
 
class  Properties
 Property manager on mesh items. Class Properties manages scalar, vector or matrix properties. For instance in groundwater flow porosity is a scalar property and permeabilty can be stored as a tensor property. Properties are assigned to mesh items, i.e. Node or Element objects. The createNewPropertyVector() method first creates a PropertyVector of template type T (scalar, vector or matrix). This class stores the PropertyVector, accessible by a combination of the name and the type of the mesh item (Node or Element). More...
 
class  PropertyVectorBase
 
class  PropertyVector< T * >
 
struct  IntegrationPointWriter
 
struct  IntegrationPointMetaData
 
class  VtkMappedMeshSource
 
class  VtkMeshNodalCoordinatesTemplate
 

Typedefs

using RotationMatrix = Eigen::Matrix< double, 3u, 3u, Eigen::RowMajor >
 
using AllElementTypes = std::tuple< Point, Line, Line3, Quad, Quad8, Quad9, Hex, Hex20, Tri, Tri6, Tet, Tet10, Prism, Prism15, Pyramid, Pyramid13 >
 
using Hex = TemplateElement< MeshLib::HexRule8 >
 
using Hex20 = TemplateElement< MeshLib::HexRule20 >
 
using Line = TemplateElement< MeshLib::LineRule2 >
 
using Line3 = TemplateElement< MeshLib::LineRule3 >
 
using Point = TemplateElement< PointRule1 >
 
using Prism = TemplateElement< MeshLib::PrismRule6 >
 
using Prism15 = TemplateElement< MeshLib::PrismRule15 >
 
using Pyramid = TemplateElement< MeshLib::PyramidRule5 >
 
using Pyramid13 = TemplateElement< MeshLib::PyramidRule13 >
 
using Quad = TemplateElement< MeshLib::QuadRule4 >
 
using Quad8 = TemplateElement< MeshLib::QuadRule8 >
 
using Quad9 = TemplateElement< MeshLib::QuadRule9 >
 
using Tet = TemplateElement< MeshLib::TetRule4 >
 
using Tet10 = TemplateElement< MeshLib::TetRule10 >
 
using Tri = TemplateElement< MeshLib::TriRule3 >
 
using Tri6 = TemplateElement< MeshLib::TriRule6 >
 

Enumerations

enum class  MeshItemType {
  Node , Edge , Face , Cell ,
  IntegrationPoint
}
 
enum class  MeshElemType {
  INVALID = 0 , POINT = 1 , LINE = 3 , QUAD = 9 ,
  HEXAHEDRON = 12 , TRIANGLE = 5 , TETRAHEDRON = 10 , PRISM = 16 ,
  PYRAMID = 14
}
 Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum. More...
 
enum class  CellType {
  INVALID = 0 , POINT1 = 1 , LINE2 = 2 , LINE3 = 3 ,
  TRI3 = 4 , TRI6 = 5 , QUAD4 = 6 , QUAD8 = 7 ,
  QUAD9 = 8 , TET4 = 9 , TET10 = 10 , HEX8 = 11 ,
  HEX20 = 12 , HEX27 = 13 , PRISM6 = 14 , PRISM15 = 15 ,
  PRISM18 = 16 , PYRAMID5 = 17 , PYRAMID13 = 18 , enum_length
}
 Types of mesh elements supported by OpenGeoSys. More...
 
enum class  MeshQualityType {
  INVALID = 0 , ELEMENTSIZE , SIZEDIFFERENCE , EDGERATIO ,
  EQUIANGLESKEW , RADIUSEDGERATIO
}
 Describes a mesh quality metric. More...
 
enum class  UseIntensityAs { ELEVATION , MATERIALS , DATAVECTOR , NONE }
 Selection of possible interpretations for intensities. More...
 

Functions

bool convertMeshToGeo (const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)
 
MeshLib::MeshconvertSurfaceToMesh (const GeoLib::Surface &sfc, const std::string &mesh_name, double eps)
 
std::ostream & operator<< (std::ostream &os, Element const &e)
 
bool areNeighbors (Element const *const element, Element const *const other)
 Returns true if elem is a neighbour of this element and false otherwise. More...
 
bool hasZeroVolume (MeshLib::Element const &element)
 Returns true if the element has zero length/area/volume. More...
 
MathLib::Point3d getCenterOfGravity (MeshLib::Element const &element)
 Calculates the center of gravity for the mesh element. More...
 
std::pair< double, double > computeSqrNodeDistanceRange (MeshLib::Element const &element, bool const check_allnodes=true)
 Compute the minimum and maximum node distances for this element. More...
 
std::pair< double, double > computeSqrEdgeLengthRange (Element const &element)
 Compute the minimum and maximum squared edge length for this element. More...
 
bool isPointInElementXY (MathLib::Point3d const &p, Element const &e)
 
unsigned getNodeIDinElement (Element const &element, const Node *node)
 Returns the position of the given node in the node array of this element. More...
 
std::size_t getNodeIndex (Element const &element, unsigned const idx)
 
MathLib::Point3d getBulkElementPoint (MeshLib::CellType const bulk_element_cell_type, std::size_t const bulk_face_id, MathLib::WeightedPoint const &point_on_face)
 
MathLib::Point3d getBulkElementPoint (MeshLib::Element const &bulk_element, std::size_t const bulk_face_id, MathLib::WeightedPoint const &point_on_face)
 Overload provided for convenience. More...
 
std::vector< Node * > getBaseNodes (std::vector< Element * > const &elements)
 
Eigen::Vector3d calculateNormalizedSurfaceNormal (MeshLib::Element const &surface_element, MeshLib::Element const &bulk_element)
 
std::vector< std::size_t > findElementsWithinRadius (Element const &start_element, double const radius_squared)
 
std::ostream & operator<< (std::ostream &os, MeshItemType const &t)
 
std::ostream & operator<< (std::ostream &os, Location const &l)
 
static constexpr char const * toString (const MeshItemType t)
 Returns a char array for a specific MeshItemType. More...
 
bool operator< (const Location &left, const Location &right)
 Lexicographic order of Location. More...
 
std::vector< std::vector< Element const * > > findElementsConnectedToNodes (Mesh const &mesh)
 
std::pair< double, double > minMaxEdgeLength (std::vector< Element * > const &elements)
 Returns the minimum and maximum edge length for given elements. More...
 
void scaleMeshPropertyVector (MeshLib::Mesh &mesh, std::string const &property_name, double factor)
 
PropertyVector< int > const * materialIDs (Mesh const &mesh)
 
std::unique_ptr< MeshLib::MeshcreateMeshFromElementSelection (std::string mesh_name, std::vector< MeshLib::Element * > const &elements)
 
std::vector< std::vector< Node * > > calculateNodesConnectedByElements (Mesh const &mesh)
 
bool isBaseNode (Node const &node, std::vector< Element const * > const &elements_connected_to_node)
 
bool operator== (Mesh const &a, Mesh const &b)
 Meshes are equal if their id's are equal. More...
 
bool operator!= (Mesh const &a, Mesh const &b)
 
template<typename T >
void addPropertyToMesh (Mesh &mesh, std::string const &name, MeshItemType item_type, std::size_t number_of_components, std::vector< T > const &values)
 
template<typename T >
PropertyVector< T > * getOrCreateMeshProperty (Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
 
std::unique_ptr< MeshcreateMeshFromElementSelection (std::string mesh_name, std::vector< Element * > const &elements)
 
MeshLib::ElementextrudeElement (std::vector< MeshLib::Node * > const &subsfc_nodes, MeshLib::Element const &sfc_elem, MeshLib::PropertyVector< std::size_t > const &sfc_to_subsfc_id_map, std::map< std::size_t, std::size_t > const &subsfc_sfc_id_map)
 
MeshLib::MeshaddLayerToMesh (MeshLib::Mesh const &mesh, double thickness, std::string const &name, bool on_top, bool copy_material_ids)
 
std::unique_ptr< MeshLib::MeshconvertToLinearMesh (MeshLib::Mesh const &org_mesh, std::string const &new_mesh_name)
 
std::vector< Node * > copyNodeVector (const std::vector< Node * > &nodes)
 Creates a deep copy of a Node vector. More...
 
std::vector< Element * > copyElementVector (std::vector< Element * > const &elements, std::vector< Node * > const &new_nodes, std::vector< std::size_t > const *const node_id_map)
 
template<typename E >
ElementcopyElement (Element const *const element, const std::vector< Node * > &nodes, std::vector< std::size_t > const *const id_map)
 
std::vector< Element * > cloneElements (std::vector< Element * > const &elements)
 Clones a vector of elements using the Element::clone() function. More...
 
std::unique_ptr< ElementcreateFlippedElement (Element const &elem, std::vector< Node * > const &nodes)
 
std::unique_ptr< MeshcreateFlippedMesh (Mesh const &mesh)
 
template<typename T >
void fillNodeProperty (std::vector< T > &new_prop, std::vector< T > const &old_prop, std::vector< size_t > node_ids)
 
template<typename T >
void fillElemProperty (std::vector< T > &new_prop, std::vector< T > const &old_prop, std::vector< size_t > elem_ids)
 
template<typename Iterator >
void moveMeshNodes (Iterator begin, Iterator end, Eigen::Vector3d const &displacement)
 
MeshLib::MeshremoveElements (const MeshLib::Mesh &mesh, const std::vector< std::size_t > &removed_element_ids, const std::string &new_mesh_name)
 
std::vector< bool > markUnusedNodes (std::vector< Element * > const &elements, std::vector< Node * > const &nodes)
 Marks nodes not used by any of the elements. More...
 
void removeMarkedNodes (std::vector< bool > const &nodes_to_delete, std::vector< Node * > &nodes)
 Deallocates and removes nodes marked true. More...
 
MeshLib::MeshremoveNodes (const MeshLib::Mesh &mesh, const std::vector< std::size_t > &del_nodes_idx, const std::string &new_mesh_name)
 
std::string MeshElemType2String (const MeshElemType t)
 Given a MeshElemType this returns the appropriate string. More...
 
std::string MeshElemType2StringShort (const MeshElemType t)
 Given a MeshElemType this returns the appropriate string with a short name. More...
 
MeshElemType String2MeshElemType (const std::string &s)
 Given a string of the shortened name of the element type, this returns the corresponding MeshElemType. More...
 
std::vector< MeshElemTypegetMeshElemTypes ()
 Returns a vector of all mesh element types. More...
 
std::vector< std::string > getMeshElemTypeStringsShort ()
 Returns a vector of strings of mesh element types. More...
 
std::string CellType2String (const CellType t)
 Given a MeshElemType this returns the appropriate string. More...
 
std::string MeshQualityType2String (const MeshQualityType t)
 
MeshLib::MeshQualityType String2MeshQualityType (std::string const &s)
 
std::unique_ptr< MeshcreateQuadraticOrderMesh (Mesh const &linear_mesh, bool const add_centre_node)
 
static void trackSurface (MeshLib::Element const *const element, std::vector< unsigned > &sfc_idx, unsigned const current_index)
 
template<typename Container , typename Predicate >
std::vector< std::size_t > filter (Container const &container, Predicate const &p)
 
std::vector< Node * > getUniqueNodes (std::vector< Element * > const &elements)
 Create a vector of unique nodes used by given elements. More...
 
template<typename T >
void processPropertyVector (MeshLib::PropertyVector< T > const &property, std::vector< std::size_t > const &id_map, MeshLib::Mesh &sfc_mesh)
 
bool createSfcMeshProperties (MeshLib::Mesh &sfc_mesh, MeshLib::Properties const &properties, std::vector< std::size_t > const &node_ids_map, std::vector< std::size_t > const &element_ids_map)
 
std::tuple< std::vector< MeshLib::Node * >, std::vector< std::size_t > > createNodesAndIDMapFromElements (std::vector< MeshLib::Element * > const &elements, std::size_t const n_all_nodes)
 
void createSurfaceElementsFromElement (MeshLib::Element const &surface_element, std::vector< MeshLib::Element * > &surface_elements, std::vector< std::size_t > &element_to_bulk_element_id_map, std::vector< std::size_t > &element_to_bulk_face_id_map)
 
std::tuple< std::vector< MeshLib::Element * >, std::vector< std::size_t >, std::vector< std::size_t > > createBoundaryElements (MeshLib::Mesh const &bulk_mesh)
 
void addBulkIDPropertiesToMesh (MeshLib::Mesh &surface_mesh, std::string const &node_to_bulk_node_id_map_name, std::vector< std::size_t > const &node_to_bulk_node_id_map, std::string const &element_to_bulk_element_id_map_name, std::vector< std::size_t > const &element_to_bulk_element_id_map, std::string const &element_to_bulk_face_id_map_name, std::vector< std::size_t > const &element_to_bulk_face_id_map)
 
std::vector< int > getEndNodeIDRanks (std::size_t const n_global_nodes, std::vector< std::size_t > const &n_active_base_nodes_at_rank, std::vector< std::size_t > const &n_active_high_order_nodes_at_rank)
 
template<typename Function >
void applyToPropertyVectors (Properties const &properties, Function f)
 
std::vector< Eigen::MatrixXd > getElementRotationMatrices (int const space_dimension, int const mesh_dimension, std::vector< Element * > const &elements)
 Element rotation matrix computation. More...
 
std::vector< double > getMaxiumElementEdgeLengths (std::vector< Element * > const &elements)
 Returns the maximum lengths of the edges for each element. More...
 
int getSpaceDimension (std::vector< Node * > const &nodes)
 Computes dimension of the embedding space containing the set of given points. More...
 
void addIntegrationPointDataToMesh (MeshLib::Mesh &mesh, std::vector< std::unique_ptr< IntegrationPointWriter >> const &integration_point_writer)
 
IntegrationPointMetaData getIntegrationPointMetaData (MeshLib::Properties const &properties, std::string const &name)
 
bool is2DMeshOnRotatedVerticalPlane (Mesh const &mesh)
 
void setMeshSpaceDimension (std::vector< std::unique_ptr< Mesh >> const &meshes)
 
 vtkStandardNewMacro (VtkMappedMeshSource) void VtkMappedMeshSource
 

Variables

static constexpr char const * mesh_item_type_strings []
 Char array names for all of MeshItemType values. More...
 

Typedef Documentation

◆ AllElementTypes

A list of types listing all mesh element types supported by OGS.

This type alias is intended for template metaprogramming et al., not for direct use/instantiation.

Definition at line 32 of file Elements.h.

◆ Hex

Definition at line 25 of file Hex.h.

◆ Hex20

Definition at line 26 of file Hex.h.

◆ Line

Definition at line 25 of file Line.h.

◆ Line3

Definition at line 26 of file Line.h.

◆ Point

Definition at line 20 of file Point.h.

◆ Prism

Definition at line 25 of file Prism.h.

◆ Prism15

Definition at line 26 of file Prism.h.

◆ Pyramid

Definition at line 25 of file Pyramid.h.

◆ Pyramid13

Definition at line 26 of file Pyramid.h.

◆ Quad

Definition at line 28 of file Quad.h.

◆ Quad8

Definition at line 29 of file Quad.h.

◆ Quad9

Definition at line 30 of file Quad.h.

◆ RotationMatrix

using MeshLib::RotationMatrix = typedef Eigen::Matrix<double, 3u, 3u, Eigen::RowMajor>

Definition at line 24 of file ElementCoordinatesMappingLocal.h.

◆ Tet

Definition at line 25 of file Tet.h.

◆ Tet10

Definition at line 26 of file Tet.h.

◆ Tri

Definition at line 26 of file Tri.h.

◆ Tri6

Definition at line 27 of file Tri.h.

Enumeration Type Documentation

◆ CellType

enum MeshLib::CellType
strong

Types of mesh elements supported by OpenGeoSys.

Enumerator
INVALID 
POINT1 
LINE2 
LINE3 
TRI3 
TRI6 
QUAD4 
QUAD8 
QUAD9 
TET4 
TET10 
HEX8 
HEX20 
HEX27 
PRISM6 
PRISM15 
PRISM18 
PYRAMID5 
PYRAMID13 
enum_length 

Definition at line 42 of file MeshEnums.h.

43 {
44  INVALID = 0,
45  POINT1 = 1,
46  LINE2 = 2,
47  LINE3 = 3,
48  TRI3 = 4,
49  TRI6 = 5,
50  QUAD4 = 6,
51  QUAD8 = 7,
52  QUAD9 = 8,
53  TET4 = 9,
54  TET10 = 10,
55  HEX8 = 11,
56  HEX20 = 12,
57  HEX27 = 13,
58  PRISM6 = 14,
59  PRISM15 = 15,
60  PRISM18 = 16,
61  PYRAMID5 = 17,
62  PYRAMID13 = 18,
64 };

◆ MeshElemType

enum MeshLib::MeshElemType
strong

Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.

Enumerator
INVALID 
POINT 
LINE 
QUAD 
HEXAHEDRON 
TRIANGLE 
TETRAHEDRON 
PRISM 
PYRAMID 

Definition at line 26 of file MeshEnums.h.

◆ MeshItemType

enum MeshLib::MeshItemType
strong
Enumerator
Node 
Edge 
Face 
Cell 
IntegrationPoint 

Definition at line 21 of file Location.h.

◆ MeshQualityType

Describes a mesh quality metric.

Enumerator
INVALID 
ELEMENTSIZE 
SIZEDIFFERENCE 
EDGERATIO 
EQUIANGLESKEW 
RADIUSEDGERATIO 

Definition at line 69 of file MeshEnums.h.

◆ UseIntensityAs

Selection of possible interpretations for intensities.

Enumerator
ELEVATION 
MATERIALS 
DATAVECTOR 
NONE 

Definition at line 82 of file MeshEnums.h.

Function Documentation

◆ addBulkIDPropertiesToMesh()

void MeshLib::addBulkIDPropertiesToMesh ( MeshLib::Mesh surface_mesh,
std::string const &  node_to_bulk_node_id_map_name,
std::vector< std::size_t > const &  node_to_bulk_node_id_map,
std::string const &  element_to_bulk_element_id_map_name,
std::vector< std::size_t > const &  element_to_bulk_element_id_map,
std::string const &  element_to_bulk_face_id_map_name,
std::vector< std::size_t > const &  element_to_bulk_face_id_map 
)

Definition at line 513 of file MeshSurfaceExtraction.cpp.

521 {
522  // transmit the original node ids of the bulk mesh as a property
523  if (!node_to_bulk_node_id_map_name.empty())
524  {
525  MeshLib::addPropertyToMesh(surface_mesh, node_to_bulk_node_id_map_name,
527  node_to_bulk_node_id_map);
528  }
529 
530  // transmit the original bulk element ids as a property
531  if (!element_to_bulk_element_id_map_name.empty())
532  {
534  surface_mesh, element_to_bulk_element_id_map_name,
535  MeshLib::MeshItemType::Cell, 1, element_to_bulk_element_id_map);
536  }
537 
538  // transmit the face id of the original bulk element as a property
539  if (!element_to_bulk_face_id_map_name.empty())
540  {
542  surface_mesh, element_to_bulk_face_id_map_name,
543  MeshLib::MeshItemType::Cell, 1, element_to_bulk_face_id_map);
544  }
545 }
void addPropertyToMesh(Mesh &mesh, std::string const &name, MeshItemType item_type, std::size_t number_of_components, std::vector< T > const &values)
Definition: Mesh.h:195

References addPropertyToMesh(), Cell, and Node.

Referenced by MeshLib::BoundaryExtraction::getBoundaryElementsAsMesh(), and MeshLib::MeshSurfaceExtraction::getMeshSurface().

◆ addIntegrationPointDataToMesh()

void MeshLib::addIntegrationPointDataToMesh ( MeshLib::Mesh mesh,
std::vector< std::unique_ptr< IntegrationPointWriter >> const &  integration_point_writer 
)

Add integration point data the the mesh's properties.

Adds all integration point data arrays given by the input vector and the corresponding meta data as VTK's field data. Integration point data stored as field data (contrary to point or cell data), as plain double arrays. The data is supplemented with information in JSON format, which is stored as array of characters.

Definition at line 91 of file IntegrationPointWriter.cpp.

95 {
96  std::vector<IntegrationPointMetaData> meta_data;
97  meta_data.reserve(size(integration_point_writer));
98  transform(cbegin(integration_point_writer), cend(integration_point_writer),
99  back_inserter(meta_data),
100  [&](auto const& ip_writer)
101  { return addIntegrationPointData(mesh, *ip_writer); });
102  if (!meta_data.empty())
103  {
104  addIntegrationPointMetaData(mesh, meta_data);
105  }
106 }
static MeshLib::IntegrationPointMetaData addIntegrationPointData(MeshLib::Mesh &mesh, MeshLib::IntegrationPointWriter const &writer)
static void addIntegrationPointMetaData(MeshLib::Mesh &mesh, std::vector< MeshLib::IntegrationPointMetaData > const &meta_data)

References addIntegrationPointData(), and addIntegrationPointMetaData().

Referenced by ProcessLib::addProcessDataToMesh().

◆ addLayerToMesh()

MeshLib::Mesh * MeshLib::addLayerToMesh ( MeshLib::Mesh const &  mesh,
double  thickness,
std::string const &  name,
bool  on_top,
bool  copy_material_ids 
)

Adds a layer to the mesh. If on_top is true, the layer is added on top, if it is false, the layer is added at the bottom.

Definition at line 84 of file AddLayerToMesh.cpp.

87 {
88  INFO("Extracting top surface of mesh '{:s}' ... ", mesh.getName());
89  double const flag = on_top ? -1.0 : 1.0;
90  Eigen::Vector3d const dir({0, 0, flag});
91  double const angle(90);
92  std::unique_ptr<MeshLib::Mesh> sfc_mesh(nullptr);
93 
94  std::string const prop_name("bulk_node_ids");
95 
96  if (mesh.getDimension() == 3)
97  {
99  mesh, dir, angle, prop_name));
100  }
101  else
102  {
103  sfc_mesh = (on_top) ? std::make_unique<MeshLib::Mesh>(mesh)
104  : std::unique_ptr<MeshLib::Mesh>(
106  // add property storing node ids
107  auto* const pv =
108  sfc_mesh->getProperties().createNewPropertyVector<std::size_t>(
109  prop_name, MeshLib::MeshItemType::Node, 1);
110  if (pv)
111  {
112  pv->resize(sfc_mesh->getNumberOfNodes());
113  std::iota(pv->begin(), pv->end(), 0);
114  }
115  else
116  {
117  ERR("Could not create and initialize property '{}'.", prop_name);
118  return nullptr;
119  }
120  }
121  INFO("done.");
122 
123  // *** add new surface nodes
124  std::vector<MeshLib::Node*> subsfc_nodes =
125  MeshLib::copyNodeVector(mesh.getNodes());
126  std::vector<MeshLib::Element*> subsfc_elements =
127  MeshLib::copyElementVector(mesh.getElements(), subsfc_nodes);
128 
129  std::size_t const n_subsfc_nodes(subsfc_nodes.size());
130 
131  std::vector<MeshLib::Node*> const& sfc_nodes(sfc_mesh->getNodes());
132  std::size_t const n_sfc_nodes(sfc_nodes.size());
133 
134  if (!sfc_mesh->getProperties().existsPropertyVector<std::size_t>(prop_name))
135  {
136  ERR("Need subsurface node ids, but the property '{:s}' is not "
137  "available.",
138  prop_name);
139  return nullptr;
140  }
141  // fetch subsurface node ids PropertyVector
142  auto const* const node_id_pv =
143  sfc_mesh->getProperties().getPropertyVector<std::size_t>(prop_name);
144 
145  // *** copy sfc nodes to subsfc mesh node
146  std::map<std::size_t, std::size_t> subsfc_sfc_id_map;
147  for (std::size_t k(0); k < n_sfc_nodes; ++k)
148  {
149  std::size_t const subsfc_id((*node_id_pv)[k]);
150  std::size_t const sfc_id(k + n_subsfc_nodes);
151  subsfc_sfc_id_map.insert(std::make_pair(subsfc_id, sfc_id));
152  MeshLib::Node const& node(*sfc_nodes[k]);
153  subsfc_nodes.push_back(new MeshLib::Node(
154  node[0], node[1], node[2] - (flag * thickness), sfc_id));
155  }
156 
157  // *** insert new layer elements into subsfc_mesh
158  std::vector<MeshLib::Element*> const& sfc_elements(sfc_mesh->getElements());
159  std::size_t const n_sfc_elements(sfc_elements.size());
160  for (std::size_t k(0); k < n_sfc_elements; ++k)
161  {
162  subsfc_elements.push_back(extrudeElement(
163  subsfc_nodes, *sfc_elements[k], *node_id_pv, subsfc_sfc_id_map));
164  }
165 
166  auto new_mesh = new MeshLib::Mesh(name, subsfc_nodes, subsfc_elements);
167 
168  if (!mesh.getProperties().existsPropertyVector<int>("MaterialIDs"))
169  {
170  ERR("Could not copy the property 'MaterialIDs' since the original mesh "
171  "does not contain such a property.");
172  return new_mesh;
173  }
174  auto const* const materials =
175  mesh.getProperties().getPropertyVector<int>("MaterialIDs");
176 
177  auto* const new_materials =
178  new_mesh->getProperties().createNewPropertyVector<int>(
179  "MaterialIDs", MeshLib::MeshItemType::Cell, 1);
180  if (!new_materials)
181  {
182  ERR("Can not set material properties for new layer");
183  return new_mesh;
184  }
185 
186  new_materials->reserve(subsfc_elements.size());
187  std::copy(materials->cbegin(), materials->cend(),
188  std::back_inserter(*new_materials));
189 
190  if (copy_material_ids &&
191  sfc_mesh->getProperties().existsPropertyVector<int>("MaterialIDs"))
192  {
193  auto const& sfc_material_ids =
194  *sfc_mesh->getProperties().getPropertyVector<int>("MaterialIDs");
195  std::copy(sfc_material_ids.cbegin(), sfc_material_ids.cend(),
196  std::back_inserter(*new_materials));
197  }
198  else
199  {
200  int const new_layer_id(
201  *(std::max_element(materials->cbegin(), materials->cend())) + 1);
202  auto const n_new_props(subsfc_elements.size() -
203  mesh.getNumberOfElements());
204  std::fill_n(std::back_inserter(*new_materials), n_new_props,
205  new_layer_id);
206  }
207 
208  return new_mesh;
209 }
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:34
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:44
static MeshLib::Mesh * getMeshSurface(const MeshLib::Mesh &subsfc_mesh, Eigen::Vector3d const &dir, double angle, std::string const &subsfc_node_id_prop_name="", std::string const &subsfc_element_id_prop_name="", std::string const &face_id_prop_name="")
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37
std::vector< Node * > copyNodeVector(const std::vector< Node * > &nodes)
Creates a deep copy of a Node vector.
MeshLib::Element * extrudeElement(std::vector< MeshLib::Node * > const &subsfc_nodes, MeshLib::Element const &sfc_elem, MeshLib::PropertyVector< std::size_t > const &sfc_to_subsfc_id_map, std::map< std::size_t, std::size_t > const &subsfc_sfc_id_map)
std::unique_ptr< Mesh > createFlippedMesh(Mesh const &mesh)
std::vector< Element * > copyElementVector(std::vector< Element * > const &elements, std::vector< Node * > const &new_nodes, std::vector< std::size_t > const *const node_id_map)

References Cell, MathLib::LinAlg::copy(), copyElementVector(), copyNodeVector(), createFlippedMesh(), ERR(), MeshLib::Properties::existsPropertyVector(), extrudeElement(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElements(), MeshLib::MeshSurfaceExtraction::getMeshSurface(), MeshLib::Mesh::getName(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getProperties(), MeshLib::Properties::getPropertyVector(), INFO(), MaterialPropertyLib::name, and Node.

Referenced by MeshLib::MeshGenerator::generateRegularPrismMesh(), main(), and MeshView::openAddLayerDialog().

◆ addPropertyToMesh()

template<typename T >
void MeshLib::addPropertyToMesh ( Mesh mesh,
std::string const &  name,
MeshItemType  item_type,
std::size_t  number_of_components,
std::vector< T > const &  values 
)

Creates a new PropertyVector in the given mesh and initializes it with the given data. A PropertyVector with the same name must not exist.

Parameters
meshA Mesh the new ProperyVector will be created in.
nameA string that contains the name of the new PropertyVector.
item_typeOne of the values MeshLib::MeshItemType::Cell or MeshLib::MeshItemType::Node that shows the association of the property values either to Element's / cells or Node's
number_of_componentsthe number of components of a property
valuesA vector containing the values that are used for initialization.

Definition at line 195 of file Mesh.h.

198 {
199  if (item_type == MeshItemType::Node)
200  {
201  if (mesh.getNumberOfNodes() != values.size() / number_of_components)
202  {
203  OGS_FATAL(
204  "Error number of nodes ({:d}) does not match the number of "
205  "tuples ({:d}).",
206  mesh.getNumberOfNodes(), values.size() / number_of_components);
207  }
208  }
209  if (item_type == MeshItemType::Cell)
210  {
211  if (mesh.getNumberOfElements() != values.size() / number_of_components)
212  {
213  OGS_FATAL(
214  "Error number of elements ({:d}) does not match the number of "
215  "tuples ({:d}).",
216  mesh.getNumberOfElements(),
217  values.size() / number_of_components);
218  }
219  }
220 
221  auto* const property = mesh.getProperties().createNewPropertyVector<T>(
222  name, item_type, number_of_components);
223  if (!property)
224  {
225  OGS_FATAL("Error while creating PropertyVector '{:s}'.", name);
226  }
227  property->reserve(values.size());
228  std::copy(values.cbegin(), values.cend(), std::back_inserter(*property));
229 }
#define OGS_FATAL(...)
Definition: Error.h:26

References Cell, MathLib::LinAlg::copy(), MeshLib::Properties::createNewPropertyVector(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), MeshLib::Mesh::getProperties(), ApplicationUtils::NodeWiseMeshPartitioner::mesh(), MaterialPropertyLib::name, Node, and OGS_FATAL.

Referenced by addBulkIDPropertiesToMesh(), createMeshFromElementSelection(), ParameterLib::createRandomFieldMeshElementParameter(), main(), and anonymous_namespace{IdentifySubdomainMesh.cpp}::updateOrCheckExistingSubdomainProperty().

◆ applyToPropertyVectors()

template<typename Function >
void MeshLib::applyToPropertyVectors ( Properties const &  properties,
Function  f 
)

Applies a function of the form f(type, name) -> bool for each of the properties names. The type argument is used to call f<decltype(type)>(name). At least one of the functions must return the 'true' value, but at most one is executed.

◆ areNeighbors()

bool MeshLib::areNeighbors ( Element const *const  element,
Element const *const  other 
)

Returns true if elem is a neighbour of this element and false otherwise.

Definition at line 106 of file Element.cpp.

107 {
108  unsigned nNeighbors(element->getNumberOfNeighbors());
109  for (unsigned i = 0; i < nNeighbors; i++)
110  {
111  if (element->getNeighbor(i) == other)
112  {
113  return true;
114  }
115  }
116  return false;
117 }

References MeshLib::Element::getNeighbor(), and MeshLib::Element::getNumberOfNeighbors().

Referenced by MeshLib::Element::addNeighbor().

◆ calculateNodesConnectedByElements()

std::vector< std::vector< Node * > > MeshLib::calculateNodesConnectedByElements ( Mesh const &  mesh)

Computes the element-connectivity of nodes. Two nodes i and j are connected if they are shared by an element.

Definition at line 332 of file Mesh.cpp.

334 {
335  auto const elements_connected_to_nodes = findElementsConnectedToNodes(mesh);
336 
337  std::vector<std::vector<Node*>> nodes_connected_by_elements;
338  auto const& nodes = mesh.getNodes();
339  nodes_connected_by_elements.resize(nodes.size());
340  for (std::size_t i = 0; i < nodes.size(); ++i)
341  {
342  auto& adjacent_nodes = nodes_connected_by_elements[i];
343  auto const node_id = nodes[i]->getID();
344 
345  // Get all elements, to which this node is connected.
346  auto const& connected_elements = elements_connected_to_nodes[node_id];
347 
348  // And collect all elements' nodes.
349  for (Element const* const element : connected_elements)
350  {
351  Node* const* const single_elem_nodes = element->getNodes();
352  std::size_t const nnodes = element->getNumberOfNodes();
353  for (std::size_t n = 0; n < nnodes; n++)
354  {
355  adjacent_nodes.push_back(single_elem_nodes[n]);
356  }
357  }
358 
359  // Make nodes unique and sorted by their ids.
360  // This relies on the node's id being equivalent to it's address.
361  std::sort(adjacent_nodes.begin(), adjacent_nodes.end(),
362  [](Node* a, Node* b) { return a->getID() < b->getID(); });
363  auto const last =
364  std::unique(adjacent_nodes.begin(), adjacent_nodes.end());
365  adjacent_nodes.erase(last, adjacent_nodes.end());
366  }
367  return nodes_connected_by_elements;
368 }
std::vector< std::vector< Element const * > > findElementsConnectedToNodes(Mesh const &mesh)
Definition: Mesh.cpp:42

References findElementsConnectedToNodes(), and MeshLib::Mesh::getNodes().

Referenced by MeshLib::NodeAdjacencyTable::createTable(), MeshLib::NodePartitionedMesh::getMaximumNConnectedNodesToNode(), and main().

◆ calculateNormalizedSurfaceNormal()

Eigen::Vector3d MeshLib::calculateNormalizedSurfaceNormal ( MeshLib::Element const &  surface_element,
MeshLib::Element const &  bulk_element 
)
inline

Definition at line 44 of file Utils.h.

47 {
48  Eigen::Vector3d surface_element_normal;
49 
50  switch (surface_element.getDimension())
51  {
52  case 2:
53  surface_element_normal =
54  MeshLib::FaceRule::getSurfaceNormal(surface_element);
55  break;
56  case 1:
57  {
58  auto const bulk_element_normal =
60  auto const& v0 = surface_element.getNode(0)->asEigenVector3d();
61  auto const& v1 = surface_element.getNode(1)->asEigenVector3d();
62  Eigen::Vector3d const edge_vector = v1 - v0;
63  surface_element_normal = -bulk_element_normal.cross(edge_vector);
64  break;
65  }
66  case 0:
67  {
68  assert(surface_element.getCellType() == CellType::POINT1);
69  assert(bulk_element.getCellType() == CellType::LINE2 ||
70  bulk_element.getCellType() == CellType::LINE3);
71 
72  auto const& x = surface_element.getNode(0)->asEigenVector3d();
73 
74  // The start of the line element.
75  auto const& a = bulk_element.getNode(0)->asEigenVector3d();
76 
77  // The end of the line element is the 2nd base node of the line,
78  // which is the 2nd node.
79  auto const& b = bulk_element.getNode(1)->asEigenVector3d();
80 
81  // x coincides either with the start or with the end of the line.
82  // a + b - 2 * x evaluates to a - b or to b - a, respectively.
83  // The formula assumes that the line is perfectly straight, even in
84  // the LINE3 case.
85  surface_element_normal = a + b - 2 * x;
86  }
87  }
88 
89  surface_element_normal.normalize();
90  // At the moment (2018-04-26) the surface normal is not oriented
91  // according to the right hand rule
92  // for correct results it is necessary to multiply the normal with
93  // -1
94  surface_element_normal *= -1;
95 
96  return surface_element_normal;
97 }
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:40

References MathLib::Point3d::asEigenVector3d(), MeshLib::Element::getCellType(), MeshLib::Element::getDimension(), MeshLib::Element::getNode(), MeshLib::FaceRule::getSurfaceNormal(), LINE2, LINE3, and POINT1.

◆ CellType2String()

std::string MeshLib::CellType2String ( const CellType  t)

Given a MeshElemType this returns the appropriate string.

Definition at line 157 of file MeshEnums.cpp.

158 {
159 #define RETURN_CELL_TYPE_STR(t, type) \
160  if ((t) == CellType::type) \
161  return #type;
162 
163  RETURN_CELL_TYPE_STR(t, POINT1);
164  RETURN_CELL_TYPE_STR(t, LINE2);
165  RETURN_CELL_TYPE_STR(t, LINE3);
166  RETURN_CELL_TYPE_STR(t, QUAD4);
167  RETURN_CELL_TYPE_STR(t, QUAD8);
168  RETURN_CELL_TYPE_STR(t, QUAD9);
169  RETURN_CELL_TYPE_STR(t, HEX8);
170  RETURN_CELL_TYPE_STR(t, HEX20);
171  RETURN_CELL_TYPE_STR(t, HEX27);
172  RETURN_CELL_TYPE_STR(t, TRI3);
173  RETURN_CELL_TYPE_STR(t, TRI6);
174  RETURN_CELL_TYPE_STR(t, TET4);
175  RETURN_CELL_TYPE_STR(t, TET10);
176  RETURN_CELL_TYPE_STR(t, PRISM6);
177  RETURN_CELL_TYPE_STR(t, PRISM15);
178  RETURN_CELL_TYPE_STR(t, PYRAMID5);
179  RETURN_CELL_TYPE_STR(t, PYRAMID13);
180 
181  return "none";
182 
183 #undef RETURN_CELL_TYPE_STR
184 }
#define RETURN_CELL_TYPE_STR(t, type)
static const double t

References HEX20, HEX27, HEX8, LINE2, LINE3, POINT1, PRISM15, PRISM6, PYRAMID13, PYRAMID5, QUAD4, QUAD8, QUAD9, RETURN_CELL_TYPE_STR, MathLib::t, TET10, TET4, TRI3, and TRI6.

Referenced by computePointCloudNodes(), convertToLinearMesh(), createElementCoordInterpolatorsForAllElementTypes(), createQuadraticElement(), getBulkElementPoint(), ApplicationUtils::getNumberOfElementIntegrationPoints(), and main().

◆ cloneElements()

std::vector< Element * > MeshLib::cloneElements ( std::vector< Element * > const &  elements)

Clones a vector of elements using the Element::clone() function.

Definition at line 118 of file DuplicateMeshComponents.cpp.

119 {
120  std::vector<Element*> cloned_elements;
121  cloned_elements.reserve(elements.size());
122  std::transform(begin(elements), end(elements),
123  std::back_inserter(cloned_elements),
124  [](Element* const e) { return e->clone(); });
125  return cloned_elements;
126 }

References MeshLib::Element::clone().

Referenced by MeshGeoToolsLib::constructAdditionalMeshesFromGeometries(), and ProcessLib::createDeactivatedSubdomainMesh().

◆ computeSqrEdgeLengthRange()

std::pair< double, double > MeshLib::computeSqrEdgeLengthRange ( Element const &  element)

Compute the minimum and maximum squared edge length for this element.

Definition at line 156 of file Element.cpp.

157 {
158  double min = std::numeric_limits<double>::max();
159  double max = 0;
160  const unsigned nEdges(element.getNumberOfEdges());
161  for (unsigned i = 0; i < nEdges; i++)
162  {
163  const double dist(MathLib::sqrDist(*element.getEdgeNode(i, 0),
164  *element.getEdgeNode(i, 1)));
165  min = std::min(dist, min);
166  max = std::max(dist, max);
167  }
168  return {min, max};
169 }
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.cpp:26

References MeshLib::Element::getEdgeNode(), MeshLib::Element::getNumberOfEdges(), and MathLib::sqrDist().

Referenced by MeshLib::RadiusEdgeRatioMetric::calculateQuality(), getMaxiumElementEdgeLengths(), and minMaxEdgeLength().

◆ computeSqrNodeDistanceRange()

std::pair< double, double > MeshLib::computeSqrNodeDistanceRange ( MeshLib::Element const &  element,
bool const  check_allnodes 
)

Compute the minimum and maximum node distances for this element.

Definition at line 136 of file Element.cpp.

138 {
139  double min = std::numeric_limits<double>::max();
140  double max = 0;
141  const unsigned nnodes = check_allnodes ? element.getNumberOfNodes()
142  : element.getNumberOfBaseNodes();
143  for (unsigned i = 0; i < nnodes; i++)
144  {
145  for (unsigned j = i + 1; j < nnodes; j++)
146  {
147  const double dist(
148  MathLib::sqrDist(*element.getNode(i), *element.getNode(j)));
149  min = std::min(dist, min);
150  max = std::max(dist, max);
151  }
152  }
153  return {min, max};
154 }

References MeshLib::Element::getNode(), MeshLib::Element::getNumberOfBaseNodes(), MeshLib::Element::getNumberOfNodes(), and MathLib::sqrDist().

Referenced by MeshGeoToolsLib::HeuristicSearchLength::HeuristicSearchLength(), and MeshGeoToolsLib::snapPointToElementNode().

◆ convertMeshToGeo()

bool MeshLib::convertMeshToGeo ( const MeshLib::Mesh mesh,
GeoLib::GEOObjects geo_objects,
double  eps = std::numeric_limits< double >::epsilon() 
)

Converts a 2D mesh into a geometry. A new geometry with the name of the mesh will be inserted into geo_objects, consisting of points identical with mesh nodes and one surface representing the mesh. Triangles are converted to geometric triangles, quads are split into two triangles, all other elements are ignored.

Definition at line 77 of file convertMeshToGeo.cpp.

80 {
81  if (mesh.getDimension() != 2)
82  {
83  ERR("Mesh to geometry conversion is only working for 2D meshes.");
84  return false;
85  }
86 
87  // Special handling of the bounds in case there are no materialIDs present.
88  auto get_material_ids_and_bounds = [&]()
89  -> std::tuple<MeshLib::PropertyVector<int> const*, std::pair<int, int>>
90  {
91  auto const materialIds = materialIDs(mesh);
92  if (!materialIds)
93  {
94  return std::make_tuple(nullptr, std::make_pair(0, 0));
95  }
96 
97  auto const bounds = MeshInformation::getValueBounds(*materialIds);
98  if (!bounds)
99  {
100  OGS_FATAL(
101  "Could not get minimum/maximum ranges values for the "
102  "MaterialIDs property in the mesh '{:s}'.",
103  mesh.getName());
104  }
105  return std::make_tuple(materialIds, *bounds);
106  };
107 
108  auto const [materialIds, bounds] = get_material_ids_and_bounds();
109  // elements to surface triangles conversion
110  const unsigned nMatGroups(bounds.second - bounds.first + 1);
111  std::vector<GeoLib::Surface*> sfcs;
112  sfcs.reserve(nMatGroups);
113  std::string const geoobject_name =
114  convertMeshNodesToGeoPoints(mesh, eps, geo_objects);
115  auto const& points = *geo_objects.getPointVec(geoobject_name);
116  for (unsigned i = 0; i < nMatGroups; ++i)
117  {
118  sfcs.push_back(new GeoLib::Surface(points));
119  }
120 
121  const std::vector<std::size_t>& id_map(
122  geo_objects.getPointVecObj(geoobject_name)->getIDMap());
123  const std::vector<MeshLib::Element*>& elements = mesh.getElements();
124  const std::size_t nElems(mesh.getNumberOfElements());
125 
126  for (unsigned i = 0; i < nElems; ++i)
127  {
128  auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first);
129  addElementToSurface(*elements[i], id_map, *sfcs[surfaceId]);
130  }
131 
132  std::for_each(sfcs.begin(), sfcs.end(),
133  [](GeoLib::Surface*& sfc)
134  {
135  if (sfc->getNumberOfTriangles() == 0)
136  {
137  delete sfc;
138  sfc = nullptr;
139  }
140  });
141  auto sfcs_end = std::remove(sfcs.begin(), sfcs.end(), nullptr);
142  sfcs.erase(sfcs_end, sfcs.end());
143 
144  geo_objects.addSurfaceVec(std::move(sfcs), geoobject_name,
146  return true;
147 }
const std::vector< Point * > * getPointVec(const std::string &name) const
Definition: GEOObjects.cpp:72
const PointVec * getPointVecObj(const std::string &name) const
Definition: GEOObjects.cpp:85
void addSurfaceVec(std::vector< Surface * > &&sfc, const std::string &name, SurfaceVec::NameIdMap &&sfc_names)
Definition: GEOObjects.cpp:240
const std::vector< std::size_t > & getIDMap() const
Definition: PointVec.h:96
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
Definition: Surface.h:34
std::map< std::string, std::size_t > NameIdMap
Definition: TemplateVec.h:44
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:83
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:104
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:98
std::size_t getNumberOfElements() const
Get the number of elements.
Definition: Mesh.h:92
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:269
void addElementToSurface(MeshLib::Element const &e, std::vector< std::size_t > const &id_map, GeoLib::Surface &surface)
std::string convertMeshNodesToGeoPoints(MeshLib::Mesh const &mesh, double const eps, GeoLib::GEOObjects &geo_objects)

References anonymous_namespace{convertMeshToGeo.cpp}::addElementToSurface(), anonymous_namespace{convertMeshToGeo.cpp}::convertMeshNodesToGeoPoints(), ERR(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElements(), GeoLib::PointVec::getIDMap(), MeshLib::Mesh::getName(), MeshLib::Mesh::getNumberOfElements(), GeoLib::GEOObjects::getPointVec(), GeoLib::GEOObjects::getPointVecObj(), MeshLib::MeshInformation::getValueBounds(), materialIDs(), and OGS_FATAL.

Referenced by MainWindow::convertMeshToGeometry(), FileIO::createSurface(), and main().

◆ convertSurfaceToMesh()

MeshLib::Mesh * MeshLib::convertSurfaceToMesh ( const GeoLib::Surface sfc,
const std::string &  mesh_name,
double  eps = std::numeric_limits< double >::epsilon() 
)

Converts a surface into a triangular mesh

Parameters
sfcSurface object
mesh_nameNew mesh name
epsMinimum distance for nodes not to be collapsed
Returns
a pointer to a converted mesh object. nullptr is returned if the conversion fails.

Definition at line 149 of file convertMeshToGeo.cpp.

152 {
153  // convert to a mesh including duplicated nodes
154  std::vector<MeshLib::Node*> nodes;
155  std::vector<MeshLib::Element*> elements;
156  std::size_t nodeId = 0;
157  for (std::size_t i = 0; i < sfc.getNumberOfTriangles(); i++)
158  {
159  auto* tri = sfc[i];
160  auto** tri_nodes = new MeshLib::Node*[3];
161  for (unsigned j = 0; j < 3; j++)
162  {
163  tri_nodes[j] =
164  new MeshLib::Node(tri->getPoint(j)->data(), nodeId++);
165  }
166  elements.push_back(new MeshLib::Tri(tri_nodes, i));
167  for (unsigned j = 0; j < 3; j++)
168  {
169  nodes.push_back(tri_nodes[j]);
170  }
171  }
172  MeshLib::Mesh mesh_with_duplicated_nodes(mesh_name, nodes, elements);
173 
174  // remove duplicated nodes
175  MeshLib::MeshRevision rev(mesh_with_duplicated_nodes);
176  return rev.simplifyMesh(mesh_with_duplicated_nodes.getName(), eps);
177 }
std::size_t getNumberOfTriangles() const
Definition: Surface.cpp:82

References MeshLib::Mesh::getName(), GeoLib::Surface::getNumberOfTriangles(), and MeshLib::MeshRevision::simplifyMesh().

Referenced by main().

◆ convertToLinearMesh()

std::unique_ptr< MeshLib::Mesh > MeshLib::convertToLinearMesh ( const MeshLib::Mesh mesh,
const std::string &  new_mesh_name 
)

Converts a non-linear mesh to a linear mesh. All the mesh properties will be copied except for entries for non-linear nodes.

Definition at line 59 of file ConvertToLinearMesh.cpp.

61 {
62  std::vector<MeshLib::Node*> vec_new_nodes =
63  MeshLib::copyNodeVector(MeshLib::getBaseNodes(org_mesh.getElements()));
64 
65  // create new elements with the quadratic nodes
66  std::vector<MeshLib::Element*> vec_new_eles;
67  for (MeshLib::Element const* e : org_mesh.getElements())
68  {
69  if (e->getCellType() == MeshLib::CellType::LINE3)
70  {
71  vec_new_eles.push_back(
72  createLinearElement<MeshLib::Line>(e, vec_new_nodes));
73  }
74  else if (e->getCellType() == MeshLib::CellType::QUAD8)
75  {
76  vec_new_eles.push_back(
77  createLinearElement<MeshLib::Quad>(e, vec_new_nodes));
78  }
79  else if (e->getCellType() == MeshLib::CellType::TRI6)
80  {
81  vec_new_eles.push_back(
82  createLinearElement<MeshLib::Tri>(e, vec_new_nodes));
83  }
84  else if (e->getCellType() == MeshLib::CellType::HEX20)
85  {
86  vec_new_eles.push_back(
87  createLinearElement<MeshLib::Hex>(e, vec_new_nodes));
88  }
89  else if (e->getCellType() == MeshLib::CellType::TET10)
90  {
91  vec_new_eles.push_back(
92  createLinearElement<MeshLib::Tet>(e, vec_new_nodes));
93  }
94  else
95  {
96  OGS_FATAL("Mesh element type {:s} is not supported",
97  MeshLib::CellType2String(e->getCellType()));
98  }
99  }
100 
101  auto new_mesh = std::make_unique<MeshLib::Mesh>(
102  new_mesh_name, vec_new_nodes, vec_new_eles,
103  org_mesh.getProperties().excludeCopyProperties(
104  std::vector<MeshLib::MeshItemType>(1,
106 
107  // copy property vectors for nodes
108  for (auto [name, property] : org_mesh.getProperties())
109  {
110  if (property->getMeshItemType() != MeshLib::MeshItemType::Node)
111  {
112  continue;
113  }
114  auto double_property = dynamic_cast<PropertyVector<double>*>(property);
115  if (double_property == nullptr)
116  {
117  continue;
118  }
119  auto const n_src_comp = double_property->getNumberOfGlobalComponents();
120  auto new_prop =
121  new_mesh->getProperties().createNewPropertyVector<double>(
122  name, MeshLib::MeshItemType::Node, n_src_comp);
123  new_prop->resize(new_mesh->getNumberOfNodes() * n_src_comp);
124 
125  // copy only base node values
126  for (unsigned i = 0; i < org_mesh.getNumberOfBaseNodes(); i++)
127  {
128  for (int j = 0; j < n_src_comp; j++)
129  {
130  (*new_prop)[i * n_src_comp + j] =
131  (*double_property)[i * n_src_comp + j];
132  }
133  }
134  }
135 
136  return new_mesh;
137 }
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
Definition: MeshEnums.cpp:157
std::vector< Node * > getBaseNodes(std::vector< Element * > const &elements)
Definition: Utils.h:26

References CellType2String(), copyNodeVector(), MeshLib::Properties::excludeCopyProperties(), getBaseNodes(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getNumberOfBaseNodes(), MeshLib::PropertyVectorBase::getNumberOfGlobalComponents(), MeshLib::Mesh::getProperties(), HEX20, LINE3, MaterialPropertyLib::name, Node, OGS_FATAL, QUAD8, TET10, and TRI6.

Referenced by main(), and anonymous_namespace{postLIE.cpp}::postVTU().

◆ copyElement()

template<typename E >
Element * MeshLib::copyElement ( Element const *const  element,
const std::vector< Node * > &  nodes,
std::vector< std::size_t > const *const  id_map 
)

Copies an element without change, using the nodes vector from the result mesh.

Copies an element without change, using the nodes vector from the result mesh and an optional mapping from the nodes the 'old' elements.

Definition at line 51 of file DuplicateMeshComponents.cpp.

54 {
55  unsigned const number_of_element_nodes(element->getNumberOfNodes());
56  auto** new_nodes = new Node*[number_of_element_nodes];
57  if (id_map)
58  {
59  for (unsigned i = 0; i < number_of_element_nodes; ++i)
60  {
61  new_nodes[i] = nodes[(*id_map)[element->getNode(i)->getID()]];
62  }
63  }
64  else
65  {
66  for (unsigned i = 0; i < number_of_element_nodes; ++i)
67  {
68  new_nodes[i] = nodes[element->getNode(i)->getID()];
69  }
70  }
71  return new E(new_nodes);
72 }

References MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfNodes().

Referenced by MeshLib::MeshRevision::simplifyMesh().

◆ copyElementVector()

std::vector< Element * > MeshLib::copyElementVector ( std::vector< Element * > const &  elements,
std::vector< Node * > const &  new_nodes,
std::vector< std::size_t > const *const  node_id_map = nullptr 
)

Creates a deep copy of an element vector using the given Node vector.

Parameters
elementsThe element vector that should be duplicated.
new_nodesThe new node vector used for the duplicated element vector.
node_id_mapAn optional mapping from the nodes the 'old' elements based on to the new nodes. This should be consistent with the original node vector.
Returns
A deep copy of the elements vector using the new nodes vector.

Definition at line 34 of file DuplicateMeshComponents.cpp.

38 {
39  std::vector<Element*> new_elements;
40  new_elements.reserve(elements.size());
41  std::transform(elements.begin(), elements.end(),
42  std::back_inserter(new_elements),
43  [&new_nodes, &node_id_map](auto const& element)
44  { return copyElement(element, new_nodes, node_id_map); });
45  return new_elements;
46 }

Referenced by ProcessLib::LIE::PostProcessTool::PostProcessTool(), addLayerToMesh(), MeshGeoToolsLib::appendLinesAlongPolylines(), createMeshFromElements(), LayeredVolume::createRasterLayers(), MeshLib::BoundaryExtraction::getBoundaryElementsAsMesh(), MeshLib::MeshSurfaceExtraction::getMeshSurface(), main(), removeElements(), and removeNodes().

◆ copyNodeVector()

std::vector< Node * > MeshLib::copyNodeVector ( const std::vector< Node * > &  nodes)

Creates a deep copy of a Node vector.

Definition at line 22 of file DuplicateMeshComponents.cpp.

23 {
24  const std::size_t nNodes(nodes.size());
25  std::vector<Node*> new_nodes;
26  new_nodes.reserve(nNodes);
27  for (std::size_t k = 0; k < nNodes; ++k)
28  {
29  new_nodes.push_back(new Node(nodes[k]->data(), new_nodes.size()));
30  }
31  return new_nodes;
32 }

Referenced by ProcessLib::LIE::PostProcessTool::PostProcessTool(), addLayerToMesh(), MeshGeoToolsLib::appendLinesAlongPolylines(), convertToLinearMesh(), createFlippedMesh(), createMeshFromElements(), createQuadraticOrderMesh(), LayeredVolume::createRasterLayers(), main(), removeElements(), and removeNodes().

◆ createBoundaryElements()

std::tuple<std::vector<MeshLib::Element*>, std::vector<std::size_t>, std::vector<std::size_t> > MeshLib::createBoundaryElements ( MeshLib::Mesh const &  bulk_mesh)

Definition at line 428 of file MeshSurfaceExtraction.cpp.

429 {
430  std::vector<std::size_t> element_to_bulk_element_id_map;
431  std::vector<std::size_t> element_to_bulk_face_id_map;
432  std::vector<MeshLib::Element*> surface_elements;
433 
434  auto const& bulk_elements = bulk_mesh.getElements();
435  auto const mesh_dimension = bulk_mesh.getDimension();
436 
437  for (auto const* elem : bulk_elements)
438  {
439  const unsigned element_dimension(elem->getDimension());
440  if (element_dimension < mesh_dimension)
441  {
442  continue;
443  }
444 
445  if (!elem->isBoundaryElement())
446  {
447  continue;
448  }
449  createSurfaceElementsFromElement(*elem, surface_elements,
450  element_to_bulk_element_id_map,
451  element_to_bulk_face_id_map);
452  }
453  return {surface_elements, element_to_bulk_element_id_map,
454  element_to_bulk_face_id_map};
455 }
void createSurfaceElementsFromElement(MeshLib::Element const &surface_element, std::vector< MeshLib::Element * > &surface_elements, std::vector< std::size_t > &element_to_bulk_element_id_map, std::vector< std::size_t > &element_to_bulk_face_id_map)

References createSurfaceElementsFromElement(), MeshLib::Mesh::getDimension(), and MeshLib::Mesh::getElements().

Referenced by MeshLib::BoundaryExtraction::getBoundaryElementsAsMesh().

◆ createFlippedElement()

std::unique_ptr< Element > MeshLib::createFlippedElement ( Element const &  elem,
std::vector< Node * > const &  nodes 
)

Creates a copy of an 1d / 2d element where the node order is reversed, such that the direction of a line changes and normals of 2D elements changes its sign.

Parameters
elemoriginal element
nodesnode vector used for the copy of the element
Returns
a flipped copy of the element

Definition at line 22 of file FlipElements.cpp.

24 {
25  if (elem.getDimension() > 2)
26  {
27  return nullptr;
28  }
29 
30  unsigned const n_nodes(elem.getNumberOfNodes());
31  auto elem_nodes = std::make_unique<Node*[]>(n_nodes);
32  for (unsigned i = 0; i < n_nodes; ++i)
33  {
34  elem_nodes[i] = nodes[elem.getNode(i)->getID()];
35  }
36  std::swap(elem_nodes[0], elem_nodes[1]);
37 
38  if (elem.getGeomType() == MeshElemType::LINE)
39  {
40  return std::make_unique<Line>(elem_nodes.release(), elem.getID());
41  }
42  if (elem.getGeomType() == MeshElemType::TRIANGLE)
43  {
44  return std::make_unique<Tri>(elem_nodes.release(), elem.getID());
45  }
46  if (elem.getGeomType() == MeshElemType::QUAD)
47  {
48  std::swap(elem_nodes[2], elem_nodes[3]);
49  return std::make_unique<Quad>(elem_nodes.release(), elem.getID());
50  }
51  return nullptr;
52 }

References MeshLib::Element::getDimension(), MeshLib::Element::getGeomType(), MathLib::Point3dWithID::getID(), MeshLib::Element::getID(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfNodes(), LINE, QUAD, and TRIANGLE.

Referenced by createFlippedMesh().

◆ createFlippedMesh()

std::unique_ptr< Mesh > MeshLib::createFlippedMesh ( Mesh const &  mesh)

Creates a copy of a 1d / 2d mesh where the node order of all elements is reversed such that the direction of lines changes and normals of 2D elements changes their sign.

Parameters
meshinput mesh
Returns
a flipped copy of the input mesh

Definition at line 54 of file FlipElements.cpp.

55 {
56  if (mesh.getDimension() > 2)
57  {
58  return nullptr;
59  }
60 
61  std::vector<Node*> new_nodes(copyNodeVector(mesh.getNodes()));
62  std::vector<Element*> const& elems(mesh.getElements());
63  std::vector<Element*> new_elems;
64  std::size_t n_elems(mesh.getNumberOfElements());
65  new_elems.reserve(n_elems);
66 
67  for (std::size_t i = 0; i < n_elems; ++i)
68  {
69  new_elems.push_back(
70  createFlippedElement(*elems[i], new_nodes).release());
71  }
72 
73  return std::make_unique<Mesh>("FlippedElementMesh", new_nodes, new_elems,
74  mesh.getProperties());
75 }
std::unique_ptr< Element > createFlippedElement(Element const &elem, std::vector< Node * > const &nodes)

References copyNodeVector(), createFlippedElement(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfElements(), and MeshLib::Mesh::getProperties().

Referenced by addLayerToMesh().

◆ createMeshFromElementSelection() [1/2]

std::unique_ptr<Mesh> MeshLib::createMeshFromElementSelection ( std::string  mesh_name,
std::vector< Element * > const &  elements 
)

Creates a new mesh from a vector of elements.

Note
The elements are owned by the returned mesh object as well as the nodes and will be destructed together with the mesh.

Definition at line 279 of file Mesh.cpp.

281 {
282  auto ids_vector = views::ids | to<std::vector>();
283 
284  DBUG("Found {:d} elements in the mesh", elements.size());
285 
286  // Store bulk element ids for each of the new elements.
287  auto bulk_element_ids = elements | ids_vector;
288 
289  // original node pointers to newly created nodes.
290  std::unordered_map<const MeshLib::Node*, MeshLib::Node*> nodes_map;
291  nodes_map.reserve(
292  elements.size()); // There will be at least one node per element.
293 
294  for (auto& e : elements)
295  {
296  // For each node find a cloned node in map or create if there is none.
297  unsigned const n_nodes = e->getNumberOfNodes();
298  for (unsigned i = 0; i < n_nodes; ++i)
299  {
300  const MeshLib::Node* n = e->getNode(i);
301  auto const it = nodes_map.find(n);
302  if (it == nodes_map.end())
303  {
304  auto new_node_in_map = nodes_map[n] = new MeshLib::Node(*n);
305  e->setNode(i, new_node_in_map);
306  }
307  else
308  {
309  e->setNode(i, it->second);
310  }
311  }
312  }
313 
314  // Copy the unique nodes pointers.
315  auto element_nodes = nodes_map | ranges::views::values | to<std::vector>;
316 
317  // Store bulk node ids for each of the new nodes.
318  auto bulk_node_ids = nodes_map | ranges::views::keys | ids_vector;
319 
320  auto mesh = std::make_unique<MeshLib::Mesh>(
321  std::move(mesh_name), std::move(element_nodes), std::move(elements));
322  assert(mesh != nullptr);
323 
324  addPropertyToMesh(*mesh, "bulk_element_ids", MeshLib::MeshItemType::Cell, 1,
325  bulk_element_ids);
326  addPropertyToMesh(*mesh, "bulk_node_ids", MeshLib::MeshItemType::Node, 1,
327  bulk_node_ids);
328 
329  return mesh;
330 }
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:29
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition: Mesh.h:314

References addPropertyToMesh(), Cell, DBUG(), MeshLib::views::ids, and Node.

Referenced by MeshGeoToolsLib::constructAdditionalMeshesFromGeometries(), and ProcessLib::createDeactivatedSubdomainMesh().

◆ createMeshFromElementSelection() [2/2]

std::unique_ptr<MeshLib::Mesh> MeshLib::createMeshFromElementSelection ( std::string  mesh_name,
std::vector< Element * > const &  elements 
)

Creates a new mesh from a vector of elements.

Note
The elements are owned by the returned mesh object as well as the nodes and will be destructed together with the mesh.

Definition at line 279 of file Mesh.cpp.

281 {
282  auto ids_vector = views::ids | to<std::vector>();
283 
284  DBUG("Found {:d} elements in the mesh", elements.size());
285 
286  // Store bulk element ids for each of the new elements.
287  auto bulk_element_ids = elements | ids_vector;
288 
289  // original node pointers to newly created nodes.
290  std::unordered_map<const MeshLib::Node*, MeshLib::Node*> nodes_map;
291  nodes_map.reserve(
292  elements.size()); // There will be at least one node per element.
293 
294  for (auto& e : elements)
295  {
296  // For each node find a cloned node in map or create if there is none.
297  unsigned const n_nodes = e->getNumberOfNodes();
298  for (unsigned i = 0; i < n_nodes; ++i)
299  {
300  const MeshLib::Node* n = e->getNode(i);
301  auto const it = nodes_map.find(n);
302  if (it == nodes_map.end())
303  {
304  auto new_node_in_map = nodes_map[n] = new MeshLib::Node(*n);
305  e->setNode(i, new_node_in_map);
306  }
307  else
308  {
309  e->setNode(i, it->second);
310  }
311  }
312  }
313 
314  // Copy the unique nodes pointers.
315  auto element_nodes = nodes_map | ranges::views::values | to<std::vector>;
316 
317  // Store bulk node ids for each of the new nodes.
318  auto bulk_node_ids = nodes_map | ranges::views::keys | ids_vector;
319 
320  auto mesh = std::make_unique<MeshLib::Mesh>(
321  std::move(mesh_name), std::move(element_nodes), std::move(elements));
322  assert(mesh != nullptr);
323 
324  addPropertyToMesh(*mesh, "bulk_element_ids", MeshLib::MeshItemType::Cell, 1,
325  bulk_element_ids);
326  addPropertyToMesh(*mesh, "bulk_node_ids", MeshLib::MeshItemType::Node, 1,
327  bulk_node_ids);
328 
329  return mesh;
330 }

References addPropertyToMesh(), Cell, DBUG(), MeshLib::views::ids, and Node.

Referenced by MeshGeoToolsLib::constructAdditionalMeshesFromGeometries(), and ProcessLib::createDeactivatedSubdomainMesh().

◆ createNodesAndIDMapFromElements()

std::tuple<std::vector<MeshLib::Node*>, std::vector<std::size_t> > MeshLib::createNodesAndIDMapFromElements ( std::vector< MeshLib::Element * > const &  elements,
std::size_t const  n_all_nodes 
)

Definition at line 161 of file MeshSurfaceExtraction.cpp.

163 {
164  std::vector<MeshLib::Node const*> tmp_nodes(n_all_nodes, nullptr);
165  for (auto const* elem : elements)
166  {
167  auto const n_nodes = elem->getNumberOfNodes();
168  for (unsigned j = 0; j < n_nodes; ++j)
169  {
170  const MeshLib::Node* node(elem->getNode(j));
171  tmp_nodes[node->getID()] = node;
172  }
173  }
174 
175  std::vector<MeshLib::Node*> nodes;
176  std::vector<std::size_t> node_id_map(n_all_nodes);
177  for (unsigned i = 0; i < n_all_nodes; ++i)
178  {
179  if (tmp_nodes[i])
180  {
181  node_id_map[i] = nodes.size();
182  nodes.push_back(new MeshLib::Node(*tmp_nodes[i]));
183  }
184  }
185  return {nodes, node_id_map};
186 }

References MathLib::Point3dWithID::getID().

Referenced by MeshLib::BoundaryExtraction::getBoundaryElementsAsMesh(), MeshLib::MeshSurfaceExtraction::getMeshSurface(), and MeshLib::MeshSurfaceExtraction::getSurfaceNodes().

◆ createQuadraticOrderMesh()

std::unique_ptr< Mesh > MeshLib::createQuadraticOrderMesh ( Mesh const &  linear_mesh,
bool const  add_centre_node 
)

Create a quadratic order mesh from the linear order mesh. For some element types like Quad-4, a centre node might be added if the add_centre_node flag is set, yielding a Quad-9.

Definition at line 195 of file QuadraticMeshGenerator.cpp.

197 {
198  // Clone the linear mesh nodes.
199  auto quadratic_mesh_nodes = MeshLib::copyNodeVector(linear_mesh.getNodes());
200 
201  // Temporary container for unique quadratic nodes with O(log(n)) search.
202  std::set<MeshLib::Node*, nodeByCoordinatesComparator> unique_nodes;
203 
204  // Create new elements with the quadratic nodes
205  std::vector<MeshLib::Element*> quadratic_elements;
206  auto const& linear_mesh_elements = linear_mesh.getElements();
207  for (MeshLib::Element const* e : linear_mesh_elements)
208  {
209  auto quadratic_element = createQuadraticElement(*e, add_centre_node);
210 
211  // Replace the base nodes with cloned linear nodes.
212  int const number_base_nodes = quadratic_element->getNumberOfBaseNodes();
213  for (int i = 0; i < number_base_nodes; ++i)
214  {
215  quadratic_element->setNode(
216  i, quadratic_mesh_nodes[getNodeIndex(*quadratic_element, i)]);
217  }
218 
219  // Make the new (middle-edge) nodes unique.
220  int const number_all_nodes = quadratic_element->getNumberOfNodes();
221  for (int i = number_base_nodes; i < number_all_nodes; ++i)
222  {
223  Node* original_node =
224  const_cast<Node*>(quadratic_element->getNode(i));
225 
226  auto it = unique_nodes.insert(original_node);
227  if (!it.second) // same node was already inserted before, no
228  // insertion
229  {
230  // Replace the element's node with the unique node.
231  quadratic_element->setNode(i, *it.first);
232  // And delete the original node
233  delete original_node;
234  }
235  }
236 
237  quadratic_elements.push_back(quadratic_element.release());
238  }
239 
240  // Add the unique quadratic nodes to the cloned linear nodes.
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));
245 
246  return std::make_unique<MeshLib::Mesh>(
247  linear_mesh.getName(), quadratic_mesh_nodes, quadratic_elements,
248  linear_mesh.getProperties().excludeCopyProperties(
249  std::vector<MeshLib::MeshItemType>(1,
251 }
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::size_t getNodeIndex(Element const &element, unsigned const idx)
Definition: Element.cpp:219

References MathLib::LinAlg::copy(), copyNodeVector(), createQuadraticElement(), MeshLib::Properties::excludeCopyProperties(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getName(), getNodeIndex(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getProperties(), and Node.

Referenced by main().

◆ createSfcMeshProperties()

bool MeshLib::createSfcMeshProperties ( MeshLib::Mesh sfc_mesh,
MeshLib::Properties const &  properties,
std::vector< std::size_t > const &  node_ids_map,
std::vector< std::size_t > const &  element_ids_map 
)

Definition at line 52 of file MeshSurfaceExtraction.cpp.

56 {
57  std::size_t const n_elems(sfc_mesh.getNumberOfElements());
58  std::size_t const n_nodes(sfc_mesh.getNumberOfNodes());
59  if (node_ids_map.size() != n_nodes)
60  {
61  ERR("createSfcMeshProperties() - Incorrect number of node IDs ({:d}) "
62  "compared to actual number of surface nodes ({:d}).",
63  node_ids_map.size(), n_nodes);
64  return false;
65  }
66 
67  if (element_ids_map.size() != n_elems)
68  {
69  ERR("createSfcMeshProperties() - Incorrect number of element IDs "
70  "({:d}) compared to actual number of surface elements ({:d}).",
71  element_ids_map.size(), n_elems);
72  return false;
73  }
74  std::map<MeshLib::MeshItemType, std::vector<std::size_t> const*> const
75  id_maps = {{MeshItemType::Cell, &element_ids_map},
76  {MeshItemType::Node, &node_ids_map}};
77 
78  std::size_t vectors_copied(0);
79  std::size_t vectors_skipped(0);
80  for (auto [name, property] : properties)
81  {
82  if (property->getMeshItemType() != MeshItemType::Cell &&
83  property->getMeshItemType() != MeshItemType::Node)
84  {
85  WARN(
86  "Skipping property vector '{:s}' - not defined on cells or "
87  "nodes.",
88  name);
89  vectors_skipped++;
90  continue;
91  }
92 
93  auto const& id_map = *id_maps.at(property->getMeshItemType());
94  if (auto p = dynamic_cast<PropertyVector<double>*>(property))
95  {
96  processPropertyVector(*p, id_map, sfc_mesh);
97  vectors_copied++;
98  }
99  else if (auto p = dynamic_cast<PropertyVector<float>*>(property))
100  {
101  processPropertyVector(*p, id_map, sfc_mesh);
102  vectors_copied++;
103  }
104  else if (auto p = dynamic_cast<PropertyVector<int>*>(property))
105  {
106  processPropertyVector(*p, id_map, sfc_mesh);
107  vectors_copied++;
108  }
109  else if (auto p = dynamic_cast<PropertyVector<unsigned>*>(property))
110  {
111  processPropertyVector(*p, id_map, sfc_mesh);
112  vectors_copied++;
113  }
114  else if (auto p = dynamic_cast<PropertyVector<long>*>(property))
115  {
116  processPropertyVector(*p, id_map, sfc_mesh);
117  vectors_copied++;
118  }
119  else if (auto p = dynamic_cast<PropertyVector<long long>*>(property))
120  {
121  processPropertyVector(*p, id_map, sfc_mesh);
122  vectors_copied++;
123  }
124  else if (auto p =
125  dynamic_cast<PropertyVector<unsigned long>*>(property))
126  {
127  processPropertyVector(*p, id_map, sfc_mesh);
128  vectors_copied++;
129  }
130  else if (auto p = dynamic_cast<PropertyVector<unsigned long long>*>(
131  property))
132  {
133  processPropertyVector(*p, id_map, sfc_mesh);
134  vectors_copied++;
135  }
136  else if (auto p = dynamic_cast<PropertyVector<std::size_t>*>(property))
137  {
138  processPropertyVector(*p, id_map, sfc_mesh);
139  vectors_copied++;
140  }
141  else if (auto p = dynamic_cast<PropertyVector<char>*>(property))
142  {
143  processPropertyVector(*p, id_map, sfc_mesh);
144  vectors_copied++;
145  }
146  else
147  {
148  WARN(
149  "Skipping property vector '{:s}' - no matching data type "
150  "'{:s}' found.",
151  name, typeid(*property).name());
152  vectors_skipped++;
153  }
154  }
155  INFO("{:d} property vectors copied, {:d} vectors skipped.", vectors_copied,
156  vectors_skipped);
157  return true;
158 }
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:39
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition: Mesh.h:95
static const double p
void processPropertyVector(MeshLib::PropertyVector< T > const &property, std::vector< std::size_t > const &id_map, MeshLib::Mesh &sfc_mesh)

References Cell, ERR(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), INFO(), MaterialPropertyLib::name, Node, processPropertyVector(), and WARN().

Referenced by MeshLib::BoundaryExtraction::getBoundaryElementsAsMesh(), and MeshLib::MeshSurfaceExtraction::getMeshSurface().

◆ createSurfaceElementsFromElement()

void MeshLib::createSurfaceElementsFromElement ( MeshLib::Element const &  surface_element,
std::vector< MeshLib::Element * > &  surface_elements,
std::vector< std::size_t > &  element_to_bulk_element_id_map,
std::vector< std::size_t > &  element_to_bulk_face_id_map 
)

Definition at line 405 of file MeshSurfaceExtraction.cpp.

410 {
411  const unsigned n_faces(surface_element.getNumberOfBoundaries());
412  for (unsigned j = 0; j < n_faces; ++j)
413  {
414  if (surface_element.getNeighbor(j) != nullptr)
415  {
416  continue;
417  }
418 
419  surface_elements.push_back(
420  const_cast<MeshLib::Element*>(surface_element.getBoundary(j)));
421  element_to_bulk_face_id_map.push_back(j);
422  element_to_bulk_element_id_map.push_back(surface_element.getID());
423  }
424 }

References MeshLib::Element::getBoundary(), MeshLib::Element::getID(), MeshLib::Element::getNeighbor(), and MeshLib::Element::getNumberOfBoundaries().

Referenced by createBoundaryElements().

◆ extrudeElement()

MeshLib::Element* MeshLib::extrudeElement ( std::vector< MeshLib::Node * > const &  subsfc_nodes,
MeshLib::Element const &  sfc_elem,
MeshLib::PropertyVector< std::size_t > const &  sfc_to_subsfc_id_map,
std::map< std::size_t, std::size_t > const &  subsfc_sfc_id_map 
)

Extrudes point, line, triangle or quad elements to its higher dimensional versions, i.e. line, quad, prism, hexahedron.

Parameters
subsfc_nodesthe nodes the elements are based on
sfc_elemthe element of the surface that will be extruded
sfc_to_subsfc_id_maprelation between the surface nodes of the surface element and the ids of the nodes of the subsurface mesh
subsfc_sfc_id_mapmapping of the surface nodes of the current mesh to the surface nodes of the extruded mesh
Returns
extruded element (point -> line, line -> quad, tri -> prism, quad -> hexahedron)

Definition at line 44 of file AddLayerToMesh.cpp.

49 {
50  if (sfc_elem.getDimension() > 2)
51  {
52  return nullptr;
53  }
54 
55  const unsigned nElemNodes(sfc_elem.getNumberOfBaseNodes());
56  auto new_nodes = std::unique_ptr<MeshLib::Node* []>
57  { new MeshLib::Node*[2 * nElemNodes] };
58 
59  for (unsigned j = 0; j < nElemNodes; ++j)
60  {
61  std::size_t const subsfc_id(
62  sfc_to_subsfc_id_map[sfc_elem.getNode(j)->getID()]);
63  new_nodes[j] = subsfc_nodes[subsfc_id];
64  std::size_t new_idx = (nElemNodes == 2) ? (3 - j) : (nElemNodes + j);
65  new_nodes[new_idx] = subsfc_nodes[subsfc_sfc_id_map.at(subsfc_id)];
66  }
67 
68  if (sfc_elem.getGeomType() == MeshLib::MeshElemType::LINE)
69  {
70  return new MeshLib::Quad(new_nodes.release());
71  }
72  if (sfc_elem.getGeomType() == MeshLib::MeshElemType::TRIANGLE)
73  {
74  return new MeshLib::Prism(new_nodes.release());
75  }
76  if (sfc_elem.getGeomType() == MeshLib::MeshElemType::QUAD)
77  {
78  return new MeshLib::Hex(new_nodes.release());
79  }
80 
81  return nullptr;
82 }
TemplateElement< MeshLib::PrismRule6 > Prism
Definition: Prism.h:25
TemplateElement< MeshLib::HexRule8 > Hex
Definition: Hex.h:25
TemplateElement< MeshLib::QuadRule4 > Quad
Definition: Quad.h:28

References MeshLib::Element::getDimension(), MeshLib::Element::getGeomType(), MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfBaseNodes(), LINE, QUAD, and TRIANGLE.

Referenced by addLayerToMesh().

◆ fillElemProperty()

template<typename T >
void MeshLib::fillElemProperty ( std::vector< T > &  new_prop,
std::vector< T > const &  old_prop,
std::vector< size_t >  elem_ids 
)

Definition at line 242 of file MeshRevision.cpp.

246 {
247  std::transform(elem_ids.cbegin(), elem_ids.cend(),
248  std::back_inserter(new_prop),
249  [&](std::size_t const i) { return old_prop[i]; });
250 }

Referenced by MeshLib::MeshRevision::copyProperties().

◆ fillNodeProperty()

template<typename T >
void MeshLib::fillNodeProperty ( std::vector< T > &  new_prop,
std::vector< T > const &  old_prop,
std::vector< size_t >  node_ids 
)

Definition at line 225 of file MeshRevision.cpp.

229 {
230  std::size_t const n_nodes = node_ids.size();
231  for (std::size_t i = 0; i < n_nodes; ++i)
232  {
233  if (node_ids[i] != i)
234  {
235  continue;
236  }
237  new_prop.push_back(old_prop[i]);
238  }
239 }

Referenced by MeshLib::MeshRevision::copyProperties().

◆ filter()

template<typename Container , typename Predicate >
std::vector<std::size_t> MeshLib::filter ( Container const &  container,
Predicate const &  p 
)

Definition at line 22 of file ElementSearch.cpp.

23 {
24  std::vector<std::size_t> matchedIDs;
25  std::size_t i = 0;
26  for (auto value : container)
27  {
28  if (p(value))
29  {
30  matchedIDs.push_back(i);
31  }
32  i++;
33  }
34  return matchedIDs;
35 }

Referenced by MeshLib::ElementSearch::searchByBoundingBox(), MeshLib::ElementSearch::searchByContent(), and MeshLib::ElementSearch::searchByElementType().

◆ findElementsConnectedToNodes()

std::vector<std::vector<Element const*> > MeshLib::findElementsConnectedToNodes ( Mesh const &  mesh)

Definition at line 42 of file Mesh.cpp.

44 {
45  std::vector<std::vector<Element const*>> elements_connected_to_nodes;
46  auto const& nodes = mesh.getNodes();
47  elements_connected_to_nodes.resize(nodes.size());
48 
49  for (auto const* element : mesh.getElements())
50  {
51  for (auto const node_id : element->nodes() | views::ids)
52  {
53  elements_connected_to_nodes[node_id].push_back(element);
54  }
55  }
56  return elements_connected_to_nodes;
57 }

References MeshLib::Mesh::getElements(), MeshLib::Mesh::getNodes(), and MeshLib::views::ids.

Referenced by MeshLib::Mesh::Mesh(), and calculateNodesConnectedByElements().

◆ findElementsWithinRadius()

std::vector< std::size_t > MeshLib::findElementsWithinRadius ( Element const &  start_element,
double const  radius_squared 
)

Find neighbor elements in given radius of the element.

Returns
ids of elements for which at least one node lies inside the radius of any node of the given element.
Note
There are corner-cases not correctly handled by this algorithm: Elements where an edge, but not the edge' nodes, fall inside the search radius are not included. The algorithm is only considering node to node distances and does not take into account if there is a part of an element (an edge or a face) but not the nodes falls inside the search radius.
For radius 0 only the given element's id is returned.

Definition at line 23 of file findElementsWithinRadius.cpp.

25 {
26  // Special case for 0 radius. All other radii will include at least one
27  // neighbor of the start element.
28  if (radius_squared == 0.)
29  {
30  return {start_element.getID()};
31  }
32 
33  // Collect start element node coordinates into local contigiuos memory.
34  std::vector<MathLib::Point3d> start_element_nodes;
35  {
36  auto const start_element_n_nodes = start_element.getNumberOfNodes();
37  start_element_nodes.reserve(start_element_n_nodes);
38  for (unsigned n = 0; n < start_element_n_nodes; ++n)
39  {
40  start_element_nodes.push_back(*start_element.getNode(n));
41  }
42  }
43 
44  // Returns true if the test node is inside the radius of any of the
45  // element's nodes.
46  auto node_inside_radius =
47  [&start_element_nodes, radius_squared](Node const* test_node)
48  {
49  return std::any_of(
50  start_element_nodes.begin(), start_element_nodes.end(),
51  [test_node, &radius_squared](auto const node)
52  { return MathLib::sqrDist(*test_node, node) <= radius_squared; });
53  };
54 
55  // Returns true if any of the test element's nodes is inside the start
56  // element's radius.
57  auto element_in_radius = [&node_inside_radius](Element const& element)
58  {
59  auto const n_nodes = element.getNumberOfNodes();
60  for (unsigned i = 0; i < n_nodes; ++i)
61  {
62  if (node_inside_radius(element.getNode(i)))
63  {
64  return true;
65  }
66  }
67  return false;
68  };
69 
70  std::set<std::size_t> found_elements;
71  std::vector<Element const*> neighbors_to_visit;
72  std::unordered_set<std::size_t> visited_elements;
73 
74  auto mark_visited_and_add_neighbors =
75  [&found_elements, &neighbors_to_visit, &visited_elements](
76  Element const& element)
77  {
78  found_elements.insert(element.getID());
79  visited_elements.insert(element.getID());
80  auto const n_neighbors = element.getNumberOfNeighbors();
81  for (unsigned n = 0; n < n_neighbors; ++n)
82  {
83  auto neighbor = element.getNeighbor(n);
84  if (neighbor == nullptr)
85  {
86  continue;
87  }
88  auto x = visited_elements.find(neighbor->getID());
89  if (x != visited_elements.end())
90  {
91  continue;
92  }
93 
94  neighbors_to_visit.push_back(neighbor);
95 
96  visited_elements.insert(neighbor->getID());
97  }
98  };
99 
100  // The result always contains the starting element.
101  mark_visited_and_add_neighbors(start_element);
102 
103  while (!neighbors_to_visit.empty())
104  {
105  auto const& current_element = *neighbors_to_visit.back();
106  neighbors_to_visit.pop_back();
107 
108  // If any node is inside the radius, all neighbors are visited.
109  if (element_in_radius(current_element))
110  {
111  mark_visited_and_add_neighbors(current_element);
112  }
113  }
114 
115  return {std::begin(found_elements), std::end(found_elements)};
116 }
constexpr bool any_of(List const &values)
Checks if any of the elements in the given list is true.
Definition: Algorithm.h:325

References BaseLib::any_of(), MeshLib::Element::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfNodes().

Referenced by ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalLocalAssembler< ShapeFunction, DisplacementDim >::nonlocal().

◆ getBaseNodes()

std::vector<Node*> MeshLib::getBaseNodes ( std::vector< Element * > const &  elements)
inline

Returns a vector of node pointers containing the base nodes of the elements input vector.

Definition at line 26 of file Utils.h.

27 {
28  std::vector<Node*> base_nodes;
29  base_nodes.reserve(elements.size() * 2); // Save some of the realloctions.
30 
31  for (auto* const e : elements)
32  {
33  std::copy(e->getNodes(), e->getNodes() + e->getNumberOfBaseNodes(),
34  std::back_inserter(base_nodes));
35  }
36 
37  BaseLib::makeVectorUnique(base_nodes, [](Node const* a, Node* b) {
38  return a->getID() < b->getID();
39  });
40 
41  return base_nodes;
42 }
void makeVectorUnique(std::vector< T > &v)
Definition: Algorithm.h:209

References MathLib::LinAlg::copy(), MathLib::Point3dWithID::getID(), and BaseLib::makeVectorUnique().

Referenced by ProcessLib::HydroMechanics::HydroMechanicsProcess< DisplacementDim >::constructDofTable(), ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< GlobalDim >::constructDofTable(), ProcessLib::RichardsMechanics::RichardsMechanicsProcess< DisplacementDim >::constructDofTable(), ProcessLib::StokesFlow::StokesFlowProcess< GlobalDim >::constructDofTable(), ProcessLib::TH2M::TH2MProcess< DisplacementDim >::constructDofTable(), ProcessLib::ThermoHydroMechanics::ThermoHydroMechanicsProcess< DisplacementDim >::constructDofTable(), ProcessLib::ThermoRichardsMechanics::ThermoRichardsMechanicsProcess< DisplacementDim, ConstitutiveTraits >::constructDofTable(), and convertToLinearMesh().

◆ getBulkElementPoint() [1/2]

MathLib::Point3d MeshLib::getBulkElementPoint ( MeshLib::CellType const  bulk_element_cell_type,
std::size_t const  bulk_face_id,
MathLib::WeightedPoint const &  point_on_face 
)

Maps the given point_on_face on the face a bulk element of type bulk_element_cell_type to the given point in the bulk element.

The input and output coordinates are natural coordinates of the surface and bulk element, respectively. I.e., the output point has one coordinate more than the input point.

Definition at line 219 of file MapBulkElementPoint.cpp.

223 {
224  if (point_on_face.getDimension() == 3)
225  {
226  // TODO disable the 3d elements in the local assembler creator
227  return MathLib::ORIGIN;
228  }
229 
230  switch (bulk_element_cell_type)
231  {
232  // 3D bulk elements
233  case CellType::HEX8:
234  return getBulkElementPointHex(bulk_face_id, point_on_face);
235  case CellType::PRISM6:
236  return getBulkElementPointPrism(bulk_face_id, point_on_face);
237  case CellType::PYRAMID5:
238  return getBulkElementPointPyramid(bulk_face_id, point_on_face);
239  case CellType::TET4:
240  return getBulkElementPointTet(bulk_face_id, point_on_face);
241  // 2D bulk elements
242  case CellType::QUAD4:
243  return getBulkElementPointQuad(bulk_face_id, point_on_face);
244  case CellType::TRI3:
245  return getBulkElementPointTri(bulk_face_id, point_on_face);
246  // 1D bulk elements
247  case CellType::LINE2:
248  return getBulkElementPointLine(bulk_face_id);
249  default:
250  OGS_FATAL(
251  "Wrong cell type '{:s}' or functionality not yet implemented.",
252  CellType2String(bulk_element_cell_type));
253  }
254 }
const Point3d ORIGIN
Definition: Point3d.h:101
MathLib::Point3d getBulkElementPointLine(std::size_t const face_id)
MathLib::Point3d getBulkElementPointTri(std::size_t const face_id, MathLib::WeightedPoint const &wp)
MathLib::Point3d getBulkElementPointTet(std::size_t const face_id, MathLib::WeightedPoint const &wp)
MathLib::Point3d getBulkElementPointQuad(std::size_t const face_id, MathLib::WeightedPoint const &wp)
MathLib::Point3d getBulkElementPointPrism(std::size_t const face_id, MathLib::WeightedPoint const &wp)
MathLib::Point3d getBulkElementPointHex(std::size_t const face_id, MathLib::WeightedPoint const &wp)
MathLib::Point3d getBulkElementPointPyramid(std::size_t const face_id, MathLib::WeightedPoint const &wp)

References CellType2String(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointHex(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointLine(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointPrism(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointPyramid(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointQuad(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointTet(), anonymous_namespace{MapBulkElementPoint.cpp}::getBulkElementPointTri(), MathLib::WeightedPoint::getDimension(), HEX8, LINE2, OGS_FATAL, MathLib::ORIGIN, PRISM6, PYRAMID5, QUAD4, TET4, and TRI3.

Referenced by ProcessLib::ConstraintDirichletBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::ConstraintDirichletBoundaryConditionLocalAssembler(), ProcessLib::HCNonAdvectiveFreeComponentFlowBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), getBulkElementPoint(), and ProcessLib::SurfaceFluxLocalAssembler< ShapeFunction, GlobalDim >::integrate().

◆ getBulkElementPoint() [2/2]

MathLib::Point3d MeshLib::getBulkElementPoint ( MeshLib::Element const &  bulk_element,
std::size_t const  bulk_face_id,
MathLib::WeightedPoint const &  point_on_face 
)
inline

Overload provided for convenience.

Definition at line 36 of file MapBulkElementPoint.h.

40 {
41  return getBulkElementPoint(
42  bulk_element.getCellType(), bulk_face_id, point_on_face);
43 }
MathLib::Point3d getBulkElementPoint(MeshLib::Element const &bulk_element, std::size_t const bulk_face_id, MathLib::WeightedPoint const &point_on_face)
Overload provided for convenience.

References getBulkElementPoint(), and MeshLib::Element::getCellType().

◆ getCenterOfGravity()

MathLib::Point3d MeshLib::getCenterOfGravity ( Element const &  element)

Calculates the center of gravity for the mesh element.

Definition at line 124 of file Element.cpp.

125 {
126  const unsigned nNodes(element.getNumberOfBaseNodes());
127  MathLib::Point3d center{{0, 0, 0}};
128  for (unsigned i = 0; i < nNodes; ++i)
129  {
130  center.asEigenVector3d() += element.getNode(i)->asEigenVector3d();
131  }
132  center.asEigenVector3d() /= nNodes;
133  return center;
134 }
Eigen::Vector3d const & asEigenVector3d() const
Definition: Point3d.h:67

References MathLib::Point3d::asEigenVector3d(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfBaseNodes().

Referenced by ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< GlobalDim >::initializeConcreteProcess(), ProcessLib::LIE::SmallDeformation::SmallDeformationProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::DeactivatedSubdomain::isDeactivated(), main(), markFaults(), LayeredVolume::removeCongruentElements(), ProcessLib::LIE::setFractureProperty(), FileIO::FEFLOWMeshInterface::setMaterialIDs(), setMaterialIDs(), MeshLib::CellRule::testElementNodeOrder(), and FileIO::TetGenInterface::write3dElements().

◆ getElementRotationMatrices()

std::vector< Eigen::MatrixXd > MeshLib::getElementRotationMatrices ( int const  space_dimension,
int const  mesh_dimension,
std::vector< Element * > const &  elements 
)

Element rotation matrix computation.

This function returns a vector containing the rotation matrices of given elements. The rotation matrix of an element is used to map the local vector to the global coordinate system. If an element is not inclined, the identity matrix is used as its rotation matrix.

Parameters
space_dimensionThe space dimension.
mesh_dimensionThe mesh dimension.
elementsThe mesh elements.
Returns
A vector of rotation matrices of given elements.

Definition at line 21 of file GetElementRotationMatrices.cpp.

24 {
25  std::vector<Eigen::MatrixXd> element_rotation_matrices;
26  element_rotation_matrices.reserve(elements.size());
27  for (auto const& element : elements)
28  {
29  int const element_dimension = static_cast<int>(element->getDimension());
30  if (element_dimension == space_dimension)
31  {
32  element_rotation_matrices.emplace_back(Eigen::MatrixXd::Identity(
33  element_dimension, element_dimension));
34  }
35  else
36  {
37  MeshLib::ElementCoordinatesMappingLocal coordinates_mapping(
38  *element, mesh_dimension);
39 
40  element_rotation_matrices.emplace_back(
41  coordinates_mapping.getRotationMatrixToGlobal().topLeftCorner(
42  space_dimension, element_dimension));
43  }
44  }
45 
46  return element_rotation_matrices;
47 }

References MeshLib::ElementCoordinatesMappingLocal::getRotationMatrixToGlobal().

Referenced by ProcessLib::LiquidFlow::createLiquidFlowProcess().

◆ getEndNodeIDRanks()

std::vector<int> MeshLib::getEndNodeIDRanks ( std::size_t const  n_global_nodes,
std::vector< std::size_t > const &  n_active_base_nodes_at_rank,
std::vector< std::size_t > const &  n_active_high_order_nodes_at_rank 
)

Definition at line 16 of file NodePartitionedMesh.cpp.

20 {
21  std::vector<int> data;
22 
23  std::transform(n_active_base_nodes_at_rank.begin() + 1,
24  n_active_base_nodes_at_rank.end(),
25  n_active_high_order_nodes_at_rank.begin() + 1,
26  std::back_inserter(data), std::plus<int>());
27 
28  data.push_back(n_global_nodes);
29 
30  return data;
31 }

◆ getIntegrationPointMetaData()

IntegrationPointMetaData MeshLib::getIntegrationPointMetaData ( MeshLib::Properties const &  properties,
std::string const &  name 
)

Returns integration point meta data for the given field name.

The data is read from a JSON encoded string stored in field data array.

Definition at line 108 of file IntegrationPointWriter.cpp.

110 {
111  if (!properties.existsPropertyVector<char>("IntegrationPointMetaData"))
112  {
113  OGS_FATAL(
114  "Integration point data '{:s}' is present in the vtk field data "
115  "but the required 'IntegrationPointMetaData' array is not "
116  "available.",
117  name);
118  }
119  auto const& mesh_property_ip_meta_data =
120  *properties.template getPropertyVector<char>(
121  "IntegrationPointMetaData");
122 
123  if (mesh_property_ip_meta_data.getMeshItemType() !=
125  {
126  OGS_FATAL("IntegrationPointMetaData array must be field data.");
127  }
128 
129  // Find the current integration point data entry and extract the
130  // meta data.
131  auto const ip_meta_data = extractIntegrationPointMetaData(
132  json::parse(mesh_property_ip_meta_data.begin(),
133  mesh_property_ip_meta_data.end()),
134  name);
135 
136  return ip_meta_data;
137 }
static MeshLib::IntegrationPointMetaData extractIntegrationPointMetaData(json const &meta_data, std::string const &name)

References MeshLib::Properties::existsPropertyVector(), extractIntegrationPointMetaData(), IntegrationPoint, MaterialPropertyLib::name, and OGS_FATAL.

Referenced by ApplicationUtils::checkFieldPropertyVectorSize(), ApplicationUtils::copyFieldPropertyDataToPartitions(), createPropertyVector(), determineIntegrationOrder(), ApplicationUtils::getIntegrationPointDataOffsetsOfMeshElements(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalProcess< DisplacementDim >::initializeConcreteProcess(), ApplicationUtils::setIntegrationPointNumberOfPartition(), and ProcessLib::setIPDataInitialConditions().

◆ getMaxiumElementEdgeLengths()

std::vector< double > MeshLib::getMaxiumElementEdgeLengths ( std::vector< Element * > const &  elements)

Returns the maximum lengths of the edges for each element.

Definition at line 19 of file getMaxiumElementEdgeLengths.cpp.

21 {
22  std::vector<double> element_edge_lengths(elements.size());
23  for (auto const element : elements)
24  {
25  assert(element->getGeomType() != MeshElemType::POINT);
26 
27  auto const& [min_edge_length, max_edge_length] =
29  (void)min_edge_length;
30 
31  element_edge_lengths[element->getID()] = std::sqrt(max_edge_length);
32  }
33 
34  return element_edge_lengths;
35 }
std::pair< double, double > computeSqrEdgeLengthRange(Element const &element)
Compute the minimum and maximum squared edge length for this element.
Definition: Element.cpp:156

References computeSqrEdgeLengthRange(), and POINT.

Referenced by NumLib::createNumericalStabilization().

◆ getMeshElemTypes()

std::vector< MeshElemType > MeshLib::getMeshElemTypes ( )

Returns a vector of all mesh element types.

Definition at line 132 of file MeshEnums.cpp.

133 {
134  std::vector<MeshElemType> vec;
135  vec.push_back(MeshElemType::POINT);
136  vec.push_back(MeshElemType::LINE);
137  vec.push_back(MeshElemType::QUAD);
138  vec.push_back(MeshElemType::HEXAHEDRON);
139  vec.push_back(MeshElemType::TRIANGLE);
140  vec.push_back(MeshElemType::TETRAHEDRON);
141  vec.push_back(MeshElemType::PRISM);
142  vec.push_back(MeshElemType::PYRAMID);
143  return vec;
144 }

References HEXAHEDRON, LINE, POINT, PRISM, PYRAMID, QUAD, TETRAHEDRON, and TRIANGLE.

Referenced by MeshModel::createMeshElemTypeMap(), and getMeshElemTypeStringsShort().

◆ getMeshElemTypeStringsShort()

std::vector< std::string > MeshLib::getMeshElemTypeStringsShort ( )

Returns a vector of strings of mesh element types.

Definition at line 146 of file MeshEnums.cpp.

147 {
148  std::vector<std::string> vec;
149  auto const& mesh_elem_types = getMeshElemTypes();
150  std::transform(mesh_elem_types.begin(), mesh_elem_types.end(),
151  std::back_inserter(vec),
152  [](auto const& element_type)
153  { return MeshElemType2StringShort(element_type); });
154  return vec;
155 }
std::vector< MeshElemType > getMeshElemTypes()
Returns a vector of all mesh element types.
Definition: MeshEnums.cpp:132

References getMeshElemTypes().

Referenced by main().

◆ getNodeIDinElement()

unsigned MeshLib::getNodeIDinElement ( Element const &  element,
const MeshLib::Node node 
)

Returns the position of the given node in the node array of this element.

Definition at line 206 of file Element.cpp.

207 {
208  const unsigned nNodes(element.getNumberOfNodes());
209  for (unsigned i(0); i < nNodes; i++)
210  {
211  if (node == element.getNode(i))
212  {
213  return i;
214  }
215  }
216  return std::numeric_limits<unsigned>::max();
217 }

References MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfNodes().

Referenced by ProcessLib::PythonBoundaryCondition::interpolateToHigherOrderNode(), isBaseNode(), and MeshLib::MeshRevision::reduceHex().

◆ getNodeIndex()

std::size_t MeshLib::getNodeIndex ( Element const &  element,
unsigned  idx 
)

Get the global node index of the node with the local index idx within the element. The index should be at most the number of nodes of the element.

Parameters
elementThe element object that will be searched for the index.
idxLocal index of Node, at most the number of nodes of the element that you can obtain with Element::getNumberOfBaseNodes().
Returns
the global index if idx < Element::getNumberOfBaseNodes. Otherwise in debug mode the value std::numeric_limits<unsigned>::max(). In release mode the behaviour is undefined.
See also
Element::getNode()

Definition at line 219 of file Element.cpp.

220 {
221 #ifndef NDEBUG
222  if (idx >= element.getNumberOfNodes())
223  {
224  ERR("Error in MeshLib::getNodeIndex() - Index does not "
225  "exist.");
226  return std::numeric_limits<std::size_t>::max();
227  }
228 #endif
229  return element.getNode(idx)->getID();
230 }

References ERR(), MathLib::Point3dWithID::getID(), MeshLib::Element::getNode(), and MeshLib::Element::getNumberOfNodes().

Referenced by MeshGeoToolsLib::BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline(), MeshGeoToolsLib::BoundaryElementsOnSurface::BoundaryElementsOnSurface(), ProcessLib::LIE::PostProcessTool::PostProcessTool(), anonymous_namespace{convertMeshToGeo.cpp}::addElementToSurface(), LayeredVolume::addLayerBoundaries(), LayeredVolume::addLayerToMesh(), MeshLib::MeshLayerMapper::addLayerToMesh(), ProcessLib::LIE::PostProcessTool::calculateTotalDisplacement(), MeshLib::RasterToMesh::convert(), createQuadraticOrderMesh(), FileIO::SwmmInterface::getLinkPointIds(), anonymous_namespace{IdentifySubdomainMesh.cpp}::identifySubdomainMeshElements(), MeshGeoToolsLib::BoundaryElementsAlongPolyline::includesAllEdgeNodeIDs(), NumLib::interpolateToHigherOrderNodes(), markUnusedNodes(), ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::operator()(), ProcessLib::LIE::SmallDeformation::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::operator()(), LayeredVolume::removeCongruentElements(), MeshLib::NodeSearch::searchNodesConnectedToOnlyGivenElements(), FileIO::FEFLOWMeshInterface::setMaterialIDs(), ProcessLib::LIE::HydroMechanics::HydroMechanicsLocalAssemblerMatrix< ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim >::setPressureOfInactiveNodes(), FileIO::TetGenInterface::writeElementToFacets(), and ApplicationUtils::writeMETIS().

◆ getOrCreateMeshProperty()

template<typename T >
PropertyVector<T>* MeshLib::getOrCreateMeshProperty ( Mesh mesh,
std::string const &  property_name,
MeshItemType const  item_type,
int const  number_of_components 
)
Returns
a PropertyVector of the corresponding type, name on nodes, or cells, or integration points if such exists, or creates a new one.
Attention
For the integration points the result's size is zero.
See also
MeshLib::addPropertyToMesh()

Definition at line 236 of file Mesh.h.

240 {
241  if (property_name.empty())
242  {
243  OGS_FATAL(
244  "Trying to get or to create a mesh property with empty name.");
245  }
246 
247  auto numberOfMeshItems = [&mesh, &item_type]() -> std::size_t {
248  switch (item_type)
249  {
250  case MeshItemType::Cell:
251  return mesh.getNumberOfElements();
252  case MeshItemType::Node:
253  return mesh.getNumberOfNodes();
254  case MeshItemType::IntegrationPoint:
255  return 0; // For the integration point data the size is
256  // variable
257  default:
258  OGS_FATAL(
259  "getOrCreateMeshProperty cannot handle other "
260  "types than Node, Cell, or IntegrationPoint.");
261  }
262  return 0;
263  };
264 
265  if (mesh.getProperties().existsPropertyVector<T>(property_name))
266  {
267  auto result =
268  mesh.getProperties().template getPropertyVector<T>(property_name);
269  assert(result);
270  if (item_type != MeshItemType::IntegrationPoint)
271  {
272  // Test the size if number of mesh items is known, which is not the
273  // case for the integration point data.
274  assert(result->size() ==
275  numberOfMeshItems() * number_of_components);
276  }
277  return result;
278  }
279 
280  auto result = mesh.getProperties().template createNewPropertyVector<T>(
281  property_name, item_type, number_of_components);
282  assert(result);
283  result->resize(numberOfMeshItems() * number_of_components);
284  return result;
285 }

References Cell, MeshLib::Properties::existsPropertyVector(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), MeshLib::Mesh::getProperties(), IntegrationPoint, ApplicationUtils::NodeWiseMeshPartitioner::mesh(), Node, and OGS_FATAL.

◆ getSpaceDimension()

int MeshLib::getSpaceDimension ( std::vector< Node * > const &  nodes)

Computes dimension of the embedding space containing the set of given points.

The space dimension is computed by accounting the non-zero norms of \(\mathbf x\), \(\mathbf y\), \(\mathbf z\), which are the coordinates of all nodes of the mesh. With this concept, the space dimension is:

  • 1, if all nodes are on a line that is parallel to \(x\) axis.
  • 2, if all nodes are on a line that is parallel to \(y\) axis.
  • 3, if all nodes are on a line that is parallel to \(z\) axis.
  • 2, if all nodes are distributed on a plane that is parallel to the origin coordinate plane of \(x-y\) (including the case of mesh with 1D inclined elements).
  • 3, if all nodes are distributed on a plane that is parallel to the origin coordinate plane of \(y-z\) or \(x-z\) (including the case of mesh with 1D inclined elements)..
  • 3, if all nodes are scattered in 3D space (e.g. mesh with inclined 1D, 2D elements, 3D elements).

Definition at line 23 of file GetSpaceDimension.cpp.

24 {
25  std::array x_magnitude = {0.0, 0.0, 0.0};
26 
27  double const* const x_ref = nodes[0]->data();
28  for (auto const& node : nodes)
29  {
30  auto const x = node->data();
31  for (int i = 0; i < 3; i++)
32  {
33  x_magnitude[i] += std::fabs(x[i] - x_ref[i]);
34  }
35  }
36 
37  // Z coordinate norm is not zero whichever 1D, 2D or 3D mesh:
38  if (x_magnitude[2] > 0)
39  {
40  return 3;
41  }
42 
43  const auto computed_dimension = std::count_if(
44  x_magnitude.begin(), x_magnitude.end(),
45  [](const double x_i_magnitude)
46  { return x_i_magnitude > std::numeric_limits<double>::epsilon(); });
47 
48  // 1D mesh in y direction:
49  if (computed_dimension == 1 && x_magnitude[1] > 0)
50  {
51  return 2;
52  }
53 
54  return static_cast<int>(computed_dimension);
55 }

Referenced by ProcessLib::HeatConduction::createHeatConductionProcess(), ProcessLib::LiquidFlow::createLiquidFlowProcess(), and setMeshSpaceDimension().

◆ getUniqueNodes()

std::vector< Node * > MeshLib::getUniqueNodes ( std::vector< Element * > const &  elements)

Create a vector of unique nodes used by given elements.

Definition at line 163 of file NodeSearch.cpp.

164 {
165  std::set<Node*> nodes_set;
166  for (auto e : elements)
167  {
168  Node* const* nodes = e->getNodes();
169  unsigned const nnodes = e->getNumberOfNodes();
170  nodes_set.insert(nodes, nodes + nnodes);
171  }
172 
173  std::vector<Node*> nodes;
174  nodes.reserve(nodes_set.size());
175 
176  std::move(nodes_set.cbegin(), nodes_set.cend(), std::back_inserter(nodes));
177 
178  return nodes;
179 }

◆ hasZeroVolume()

bool MeshLib::hasZeroVolume ( MeshLib::Element const &  element)

Returns true if the element has zero length/area/volume.

Definition at line 119 of file Element.cpp.

120 {
121  return element.getContent() < std::numeric_limits<double>::epsilon();
122 }

References MeshLib::Element::getContent().

Referenced by MeshLib::HexRule8::validate(), MeshLib::LineRule2::validate(), MeshLib::PointRule1::validate(), MeshLib::PrismRule6::validate(), MeshLib::PyramidRule5::validate(), MeshLib::QuadRule4::validate(), MeshLib::TetRule4::validate(), and MeshLib::TriRule3::validate().

◆ is2DMeshOnRotatedVerticalPlane()

bool MeshLib::is2DMeshOnRotatedVerticalPlane ( Mesh const &  mesh)

Definition at line 24 of file Is2DMeshOnRotatedVerticalPlane.cpp.

25 {
26  auto const mesh_dimension = mesh.getDimension();
27  if (mesh_dimension != 2)
28  {
29  OGS_FATAL(
30  "A 2D mesh is required for this computation but the provided mesh, "
31  "mesh {:s}, has {:d}D elements.",
32  mesh.getName(), mesh_dimension);
33  }
34 
35  auto const& elements = mesh.getElements();
36 
37  bool const has_inclined_element =
38  std::any_of(elements.begin(), elements.end(),
39  [&mesh_dimension](auto const& element)
40  { return element->space_dimension_ != mesh_dimension; });
41 
42  if (!has_inclined_element)
43  {
44  return false;
45  }
46 
47  const bool is_rotated_around_y_axis = std::all_of(
48  elements.cbegin(), elements.cend(),
49  [](auto const& element)
50  {
51  // 3 nodes are enough to make up a plane.
52  auto const x1 = element->getNode(0)->data();
53  auto const x2 = element->getNode(1)->data();
54  auto const x3 = element->getNode(2)->data();
55 
56  double const a0 = x2[0] - x1[0];
57  double const a2 = x2[2] - x1[2];
58 
59  double const b0 = x3[0] - x1[0];
60  double const b2 = x3[2] - x1[2];
61 
62  double const e_n_1 = -a0 * b2 + a2 * b0;
63  return std::fabs(e_n_1) < std::numeric_limits<double>::epsilon();
64  });
65 
66  const bool is_rotated_around_z_axis = std::all_of(
67  elements.cbegin(), elements.cend(),
68  [](auto const& element)
69  {
70  // 3 nodes are enough to make up a plane.
71  auto const x1 = element->getNode(0)->data();
72  auto const x2 = element->getNode(1)->data();
73  auto const x3 = element->getNode(2)->data();
74 
75  double const a0 = x2[0] - x1[0];
76  double const a1 = x2[1] - x1[1];
77 
78  double const b0 = x3[0] - x1[0];
79  double const b1 = x3[1] - x1[1];
80 
81  double const e_n_2 = a0 * b1 - a1 * b0;
82  return std::fabs(e_n_2) < std::numeric_limits<double>::epsilon();
83  });
84 
85  if (!(is_rotated_around_y_axis || is_rotated_around_z_axis))
86  {
87  OGS_FATAL(
88  "2D Mesh {:s} is on an inclined plane, which is neither a vertical "
89  "nor horizontal plane that is required for the present "
90  "computation.",
91  mesh.getName());
92  }
93 
94  return true;
95 }
constexpr bool all_of(List const &values)
Checks if all of the elements in the given list are true.
Definition: Algorithm.h:341

References BaseLib::all_of(), BaseLib::any_of(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getName(), and OGS_FATAL.

Referenced by ProcessLib::HydroMechanics::createHydroMechanicsProcess().

◆ isBaseNode()

bool MeshLib::isBaseNode ( Node const &  node,
std::vector< Element const * > const &  elements_connected_to_node 
)

Returns true if the given node is a base node of a (first) element, or if it is not connected to any element i.e. an unconnected node.

Definition at line 370 of file Mesh.cpp.

372 {
373  // Check if node is connected.
374  if (elements_connected_to_node.empty())
375  {
376  return true;
377  }
378 
379  // In a mesh a node always belongs to at least one element.
380  auto const e = elements_connected_to_node[0];
381 
382  auto const n_base_nodes = e->getNumberOfBaseNodes();
383  auto const local_index = getNodeIDinElement(*e, &node);
384  return local_index < n_base_nodes;
385 }
unsigned getNodeIDinElement(Element const &element, const MeshLib::Node *node)
Returns the position of the given node in the node array of this element.
Definition: Element.cpp:206

References getNodeIDinElement().

Referenced by MeshGeoToolsLib::MeshNodesOnPoint::MeshNodesOnPoint(), NumLib::MeshComponentMap::createParallelMeshComponentMap(), ApplicationUtils::findGhostNodesInPartition(), ApplicationUtils::findRegularNodesInPartition(), MeshLib::Mesh::getNumberOfBaseNodes(), NumLib::MeshComponentMap::getSubset(), and ProcessLib::LIE::anonymous_namespace{MeshUtils.cpp}::IsCrackTip::operator()().

◆ isPointInElementXY()

bool MeshLib::isPointInElementXY ( MathLib::Point3d const &  p,
Element const &  e 
)

Let \(p'\) the orthogonal projection to the \(x\)- \(y\) plane of the point p and \(e'\) the orthogonal projection to the \(x\)- \(y\) plane of the element e. The method checks if \(p'\) is located in \(e'\).

Todo:
At the moment the test works only for triangle and quad elements.
Parameters
pMathLib::Point3d is the test point
ethe element that is used for the request
Returns
true if the \(p' \in e'\) and false if \(p' \notin e'\)

Definition at line 171 of file Element.cpp.

172 {
173  for (std::size_t i(0); i < e.getNumberOfBaseNodes(); ++i)
174  {
175  if (MathLib::sqrDist2d(p, *e.getNode(i)) <
176  std::numeric_limits<double>::epsilon())
177  {
178  return true;
179  }
180  }
181 
182  if (e.getGeomType() == MeshElemType::TRIANGLE)
183  {
184  MathLib::Point3d const& n0(*e.getNode(0));
185  MathLib::Point3d const& n1(*e.getNode(1));
186  MathLib::Point3d const& n2(*e.getNode(2));
187 
188  return MathLib::isPointInTriangleXY(p, n0, n1, n2);
189  }
190  if (e.getGeomType() == MeshElemType::QUAD)
191  {
192  MathLib::Point3d const& n0(*e.getNode(0));
193  MathLib::Point3d const& n1(*e.getNode(1));
194  MathLib::Point3d const& n2(*e.getNode(2));
195  MathLib::Point3d const& n3(*e.getNode(3));
196 
197  return MathLib::isPointInTriangleXY(p, n0, n1, n2) ||
198  MathLib::isPointInTriangleXY(p, n0, n2, n3);
199  }
200 
201  WARN("isPointInElementXY: element type '{:s}' is not supported.",
202  MeshLib::MeshElemType2String(e.getGeomType()));
203  return false;
204 }
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.h:126
bool isPointInTriangleXY(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
Definition: MeshEnums.cpp:21

References MeshLib::Element::getGeomType(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfBaseNodes(), MathLib::isPointInTriangleXY(), MeshElemType2String(), QUAD, MathLib::sqrDist2d(), TRIANGLE, and WARN().

Referenced by MeshLib::Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh().

◆ markUnusedNodes()

std::vector< bool > MeshLib::markUnusedNodes ( std::vector< Element * > const &  elements,
std::vector< Node * > const &  nodes 
)

Marks nodes not used by any of the elements.

Definition at line 100 of file RemoveMeshComponents.cpp.

102 {
103  std::vector<bool> unused_nodes(nodes.size(), true);
104  for (auto e : elements)
105  {
106  for (unsigned i = 0; i < e->getNumberOfNodes(); i++)
107  {
108  unused_nodes[getNodeIndex(*e, i)] = false;
109  }
110  }
111 
112  return unused_nodes;
113 }

References getNodeIndex().

Referenced by createMeshFromElements(), and removeNodes().

◆ materialIDs()

PropertyVector< int > const * MeshLib::materialIDs ( Mesh const &  mesh)

Returns the material ids property vector defined on the mesh.

The material ids are always an int property named "MaterialIDs". If the property does not exists (or is of different type), a nullptr is returned.

Definition at line 269 of file Mesh.cpp.

270 {
271  auto const& properties = mesh.getProperties();
272  return properties.existsPropertyVector<int>("MaterialIDs",
274  ? properties.getPropertyVector<int>(
275  "MaterialIDs", MeshLib::MeshItemType::Cell, 1)
276  : nullptr;
277 }

References Cell, MeshLib::Properties::existsPropertyVector(), and MeshLib::Mesh::getProperties().

Referenced by ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::HeatTransportBHEProcess(), ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< GlobalDim >::HydroMechanicsProcess(), MeshGeoToolsLib::appendLinesAlongPolylines(), convertMeshToGeo(), ProcessLib::createDeactivatedSubdomain(), ProcessLib::createDeactivatedSubdomainMesh(), ProcessLib::LIE::HydroMechanics::createHydroMechanicsProcess(), ProcessLib::HydroMechanics::createHydroMechanicsProcess(), MaterialPropertyLib::createMaterialSpatialDistributionMap(), ProcessLib::PhaseField::createPhaseFieldProcess(), MaterialLib::PorousMedium::createPorousMediaProperties(), ProcessLib::RichardsMechanics::createRichardsMechanicsProcess(), ProcessLib::SmallDeformationNonlocal::createSmallDeformationNonlocalProcess(), ProcessLib::LIE::SmallDeformation::createSmallDeformationProcess(), ProcessLib::SmallDeformation::createSmallDeformationProcess(), ProcessLib::TH2M::createTH2MProcess(), ProcessLib::ThermoHydroMechanics::createThermoHydroMechanicsProcess(), ProcessLib::ThermoMechanicalPhaseField::createThermoMechanicalPhaseFieldProcess(), ProcessLib::ThermoMechanics::createThermoMechanicsProcess(), ProcessLib::ThermoRichardsMechanics::createThermoRichardsMechanicsProcessStage2(), ProcessLib::TwoPhaseFlowWithPP::createTwoPhaseFlowWithPPProcess(), ProcessLib::TwoPhaseFlowWithPrho::createTwoPhaseFlowWithPrhoProcess(), extractBoundaryMeshes(), ProcessLib::LIE::anonymous_namespace{MeshUtils.cpp}::findFracutreIntersections(), ProcessLib::HeatTransportBHE::getBHEDataInMesh(), ProcessLib::LIE::getFractureMatrixDataInMesh(), ProcessLib::LIE::HydroMechanics::HydroMechanicsProcess< GlobalDim >::initializeConcreteProcess(), main(), removeUnusedElements(), and ElementTreeModel::setElement().

◆ MeshElemType2String()

std::string MeshLib::MeshElemType2String ( const MeshElemType  t)

Given a MeshElemType this returns the appropriate string.

Definition at line 21 of file MeshEnums.cpp.

22 {
23  if (t == MeshElemType::POINT)
24  {
25  return "Point";
26  }
27  if (t == MeshElemType::LINE)
28  {
29  return "Line";
30  }
31  if (t == MeshElemType::QUAD)
32  {
33  return "Quad";
34  }
35  if (t == MeshElemType::HEXAHEDRON)
36  {
37  return "Hexahedron";
38  }
39  if (t == MeshElemType::TRIANGLE)
40  {
41  return "Triangle";
42  }
43  if (t == MeshElemType::TETRAHEDRON)
44  {
45  return "Tetrahedron";
46  }
47  if (t == MeshElemType::PRISM)
48  {
49  return "Prism";
50  }
51  if (t == MeshElemType::PYRAMID)
52  {
53  return "Pyramid";
54  }
55  return "none";
56 }

References HEXAHEDRON, LINE, POINT, PRISM, PYRAMID, QUAD, MathLib::t, TETRAHEDRON, and TRIANGLE.

Referenced by MeshModel::createMeshElemTypeMap(), MeshLib::TemplateElement< ELEMENT_RULE >::getNode(), isPointInElementXY(), ElementTreeModel::setElement(), ElementTreeModel::setMesh(), and MeshLib::MeshInformation::writeAllNumbersOfElementTypes().

◆ MeshElemType2StringShort()

std::string MeshLib::MeshElemType2StringShort ( const MeshElemType  t)

Given a MeshElemType this returns the appropriate string with a short name.

Definition at line 58 of file MeshEnums.cpp.

59 {
60  if (t == MeshElemType::POINT)
61  {
62  return "point";
63  }
64  if (t == MeshElemType::LINE)
65  {
66  return "line";
67  }
68  if (t == MeshElemType::QUAD)
69  {
70  return "quad";
71  }
72  if (t == MeshElemType::HEXAHEDRON)
73  {
74  return "hex";
75  }
76  if (t == MeshElemType::TRIANGLE)
77  {
78  return "tri";
79  }
80  if (t == MeshElemType::TETRAHEDRON)
81  {
82  return "tet";
83  }
84  if (t == MeshElemType::PRISM)
85  {
86  return "pris";
87  }
88  if (t == MeshElemType::PYRAMID)
89  {
90  return "pyra";
91  }
92  return "none";
93 }

References HEXAHEDRON, LINE, POINT, PRISM, PYRAMID, QUAD, MathLib::t, TETRAHEDRON, and TRIANGLE.

◆ MeshQualityType2String()

std::string MeshLib::MeshQualityType2String ( const MeshQualityType  t)

Definition at line 186 of file MeshEnums.cpp.

187 {
188  if (t == MeshQualityType::ELEMENTSIZE)
189  {
190  return "ElementSize";
191  }
192  if (t == MeshQualityType::EDGERATIO)
193  {
194  return "EdgeRatio";
195  }
196  if (t == MeshQualityType::EQUIANGLESKEW)
197  {
198  return "EquiAngleSkew";
199  }
200  if (t == MeshQualityType::RADIUSEDGERATIO)
201  {
202  return "RadiusEdgeRatio";
203  }
204  if (t == MeshQualityType::SIZEDIFFERENCE)
205  {
206  return "SizeDifference";
207  }
208  return "none";
209 }

References EDGERATIO, ELEMENTSIZE, EQUIANGLESKEW, RADIUSEDGERATIO, SIZEDIFFERENCE, and MathLib::t.

Referenced by VtkVisPipeline::showMeshElementQuality(), and MeshLib::ElementQualityInterface::writeHistogram().

◆ minMaxEdgeLength()

std::pair< double, double > MeshLib::minMaxEdgeLength ( std::vector< Element * > const &  elements)

Returns the minimum and maximum edge length for given elements.

Definition at line 176 of file Mesh.cpp.

178 {
179  auto min_max = [](auto const a, auto const b) -> std::pair<double, double> {
180  return {std::min(a.first, b.first), std::max(a.second, b.second)};
181  };
182 
183  using limits = std::numeric_limits<double>;
184  auto const bounds = ranges::accumulate(
185  elements, std::pair{limits::infinity(), -limits::infinity()}, min_max,
186  [](Element* const e) { return computeSqrEdgeLengthRange(*e); });
187 
188  return {std::sqrt(bounds.first), std::sqrt(bounds.second)};
189 }

References computeSqrEdgeLengthRange().

Referenced by MeshGeoToolsLib::appendLinesAlongPolylines(), extractBoundaries(), main(), setMaterialIDs(), and ElementTreeModel::setMesh().

◆ moveMeshNodes()

template<typename Iterator >
void MeshLib::moveMeshNodes ( Iterator  begin,
Iterator  end,
Eigen::Vector3d const &  displacement 
)

Function that moves mesh nodes.

The function iterates over all mesh nodes between the begin and the end iterator and moves them using the given displacement.

Parameters
beginbegin iterator
endend iterator
displacementthe displacement to use

Definition at line 34 of file moveMeshNodes.h.

37 {
38  std::for_each(begin, end,
39  [&displacement](MathLib::Point3d* node)
40  { node->asEigenVector3d() += displacement; });
41 };

References MathLib::Point3d::asEigenVector3d().

Referenced by main().

◆ operator!=()

bool MeshLib::operator!= ( Mesh const &  a,
Mesh const &  b 
)
inline

Definition at line 173 of file Mesh.h.

174 {
175  return !(a == b);
176 }

◆ operator<()

bool MeshLib::operator< ( const Location left,
const Location right 
)
inline

Lexicographic order of Location.

Definition at line 51 of file Location.h.

52 {
53  if (left.mesh_id != right.mesh_id)
54  {
55  return left.mesh_id < right.mesh_id;
56  }
57  if (left.item_type != right.item_type)
58  {
59  return left.item_type < right.item_type;
60  }
61  return left.item_id < right.item_id;
62 }

References MeshLib::Location::item_id, MeshLib::Location::item_type, and MeshLib::Location::mesh_id.

◆ operator<<() [1/3]

std::ostream& MeshLib::operator<< ( std::ostream &  os,
Element const &  e 
)

Definition at line 88 of file Element.cpp.

89 {
90  os << "Element #" << e._id << " @ " << &e << " with "
91  << e.getNumberOfNeighbors() << " neighbours\n";
92 
93  unsigned const nnodes = e.getNumberOfNodes();
94  MeshLib::Node* const* const nodes = e.getNodes();
95  os << "MeshElemType: "
96  << static_cast<std::underlying_type<MeshElemType>::type>(e.getGeomType())
97  << " with " << nnodes << " nodes: {\n";
98  for (unsigned n = 0; n < nnodes; ++n)
99  {
100  os << " #" << nodes[n]->getID() << " @ " << nodes[n] << " coords ["
101  << *nodes[n] << "]\n";
102  }
103  return os << '}';
104 }
std::size_t getID() const
Definition: Point3dWithID.h:62

◆ operator<<() [2/3]

std::ostream & MeshLib::operator<< ( std::ostream &  os,
Location const &  l 
)

Definition at line 35 of file Location.cpp.

36 {
37  return os << "(" << l.mesh_id << ", " << l.item_type << ", " << l.item_id
38  << ")";
39 }

References MeshLib::Location::item_id, MeshLib::Location::item_type, and MeshLib::Location::mesh_id.

◆ operator<<() [3/3]

std::ostream & MeshLib::operator<< ( std::ostream &  os,
MeshItemType const &  t 
)

Definition at line 17 of file Location.cpp.

18 {
19  switch (t)
20  {
21  case MeshItemType::Node:
22  return os << "N";
23  case MeshItemType::Edge:
24  return os << "E";
25  case MeshItemType::Face:
26  return os << "F";
27  case MeshItemType::Cell:
28  return os << "C";
29  case MeshItemType::IntegrationPoint:
30  return os << "I";
31  };
32  return os;
33 }

References Cell, Edge, Face, IntegrationPoint, Node, and MathLib::t.

◆ operator==()

bool MeshLib::operator== ( Mesh const &  a,
Mesh const &  b 
)
inline

Meshes are equal if their id's are equal.

Definition at line 168 of file Mesh.h.

169 {
170  return a.getID() == b.getID();
171 }

References MeshLib::Mesh::getID().

◆ processPropertyVector()

template<typename T >
void MeshLib::processPropertyVector ( MeshLib::PropertyVector< T > const &  property,
std::vector< std::size_t > const &  id_map,
MeshLib::Mesh sfc_mesh 
)

Definition at line 33 of file MeshSurfaceExtraction.cpp.

36 {
37  auto const number_of_components = property.getNumberOfGlobalComponents();
38 
39  auto sfc_prop = getOrCreateMeshProperty<T>(
40  sfc_mesh, property.getPropertyName(), property.getMeshItemType(),
41  number_of_components);
42  sfc_prop->clear();
43  sfc_prop->reserve(id_map.size());
44 
45  for (auto bulk_id : id_map)
46  {
47  std::copy_n(&property.getComponent(bulk_id, 0 /*component_id*/),
48  number_of_components, back_inserter(*sfc_prop));
49  }
50 }
std::string const & getPropertyName() const
MeshItemType getMeshItemType() const
PROP_VAL_TYPE & getComponent(std::size_t tuple_index, int component)
Returns the value for the given component stored in the given tuple.

References MeshLib::PropertyVector< PROP_VAL_TYPE >::getComponent(), MeshLib::PropertyVectorBase::getMeshItemType(), and MeshLib::PropertyVectorBase::getPropertyName().

Referenced by createSfcMeshProperties().

◆ removeElements()

MeshLib::Mesh * MeshLib::removeElements ( const MeshLib::Mesh mesh,
const std::vector< std::size_t > &  removed_element_ids,
const std::string &  new_mesh_name 
)

Removes mesh elements and returns a new mesh object. The original mesh is kept unchanged.

Parameters
meshan original mesh whose elements are removed
removed_element_idsa vector of element indices to be removed
new_mesh_namea new mesh name
Returns
a new mesh object

Definition at line 52 of file RemoveMeshComponents.cpp.

56 {
57  if (removed_element_ids.empty())
58  {
59  INFO("No elements to remove");
60  return nullptr;
61  }
62 
63  INFO("Removing total {:d} elements...", removed_element_ids.size());
64  std::vector<MeshLib::Element*> tmp_elems =
65  details::excludeElementCopy(mesh.getElements(), removed_element_ids);
66  INFO("{:d} elements remain in mesh.", tmp_elems.size());
67 
68  // copy node and element objects
69  std::vector<MeshLib::Node*> new_nodes =
71  std::vector<MeshLib::Element*> new_elems =
72  MeshLib::copyElementVector(tmp_elems, new_nodes);
73 
74  // delete unused nodes
75  NodeSearch ns(mesh);
76  ns.searchNodesConnectedToOnlyGivenElements(removed_element_ids);
77  auto& removed_node_ids(ns.getSearchedNodeIDs());
78  INFO("Removing total {:d} nodes...", removed_node_ids.size());
79  for (auto nodeid : removed_node_ids)
80  {
81  delete new_nodes[nodeid];
82  new_nodes[nodeid] = nullptr;
83  }
84  new_nodes.erase(std::remove(new_nodes.begin(), new_nodes.end(), nullptr),
85  new_nodes.end());
86 
87  if (!new_elems.empty())
88  {
89  MeshLib::Mesh* new_mesh =
90  new MeshLib::Mesh(new_mesh_name, new_nodes, new_elems,
92  removed_element_ids, removed_node_ids));
93  return new_mesh;
94  }
95 
96  INFO("Current selection removes all elements.");
97  return nullptr;
98 }
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:101
Properties & getProperties()
Definition: Mesh.h:129
Properties excludeCopyProperties(std::vector< std::size_t > const &exclude_elem_ids, std::vector< std::size_t > const &exclude_node_ids) const
Definition: Properties.cpp:58
std::vector< MeshLib::Element * > excludeElementCopy(std::vector< MeshLib::Element * > const &vec_src_eles, std::vector< std::size_t > const &vec_removed)

References copyElementVector(), copyNodeVector(), MeshLib::Properties::excludeCopyProperties(), MeshLib::details::excludeElementCopy(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getProperties(), MeshLib::NodeSearch::getSearchedNodeIDs(), INFO(), and MeshLib::NodeSearch::searchNodesConnectedToOnlyGivenElements().

Referenced by MeshElementRemovalDialog::accept(), MeshLib::RasterToMesh::convert(), LayeredVolume::createRasterLayers(), extractMatGroup(), MeshLib::MeshGenerator::generateRegularPrismMesh(), main(), removeUnusedElements(), removeUnusedGridCells(), and writeBoundary().

◆ removeMarkedNodes()

void MeshLib::removeMarkedNodes ( std::vector< bool > const &  nodes_to_delete,
std::vector< Node * > &  nodes 
)

Deallocates and removes nodes marked true.

Definition at line 115 of file RemoveMeshComponents.cpp.

117 {
118  assert(nodes_to_delete.size() == nodes.size());
119 
120  for (std::size_t i = 0; i < nodes.size(); i++)
121  {
122  if (nodes_to_delete[i])
123  {
124  delete nodes[i];
125  nodes[i] = nullptr;
126  }
127  }
128  nodes.erase(remove(begin(nodes), end(nodes), nullptr), end(nodes));
129 }

Referenced by createMeshFromElements(), and removeNodes().

◆ removeNodes()

MeshLib::Mesh * MeshLib::removeNodes ( const MeshLib::Mesh mesh,
const std::vector< std::size_t > &  del_nodes_idx,
const std::string &  new_mesh_name 
)

Removes the mesh nodes (and connected elements) given in the nodes-list from the mesh.

Parameters
meshan original mesh whose elements are removed
del_nodes_idxa vector of node indices to be removed
new_mesh_namea new mesh name
Returns
a new mesh object

Definition at line 131 of file RemoveMeshComponents.cpp.

134 {
135  if (del_nodes_idx.empty())
136  {
137  return nullptr;
138  }
139 
140  // copy node and element objects
141  std::vector<MeshLib::Node*> new_nodes =
143  std::vector<MeshLib::Element*> new_elems =
144  MeshLib::copyElementVector(mesh.getElements(), new_nodes);
145 
146  // delete elements
147  MeshLib::ElementSearch es(mesh);
148  es.searchByNodeIDs(del_nodes_idx);
149  auto& removed_element_ids = es.getSearchedElementIDs();
150  for (auto eid : removed_element_ids)
151  {
152  delete new_elems[eid];
153  new_elems[eid] = nullptr;
154  }
155  new_elems.erase(std::remove(new_elems.begin(), new_elems.end(), nullptr),
156  new_elems.end());
157 
158  // check unused nodes due to element deletion
159  std::vector<bool> const node_delete_flag =
160  markUnusedNodes(new_elems, new_nodes);
161 
162  // delete unused nodes
163  removeMarkedNodes(node_delete_flag, new_nodes);
164 
165  if (!new_elems.empty())
166  {
167  MeshLib::Mesh* new_mesh =
168  new MeshLib::Mesh(new_mesh_name, new_nodes, new_elems,
170  removed_element_ids, del_nodes_idx));
171  return new_mesh;
172  }
173 
174  return nullptr;
175 }
Element search class.
Definition: ElementSearch.h:28
std::vector< bool > markUnusedNodes(std::vector< Element * > const &elements, std::vector< Node * > const &nodes)
Marks nodes not used by any of the elements.
void removeMarkedNodes(std::vector< bool > const &nodes_to_delete, std::vector< Node * > &nodes)
Deallocates and removes nodes marked true.

References copyElementVector(), copyNodeVector(), MeshLib::Properties::excludeCopyProperties(), MeshLib::Mesh::getElements(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getProperties(), MeshLib::ElementSearch::getSearchedElementIDs(), markUnusedNodes(), removeMarkedNodes(), and MeshLib::ElementSearch::searchByNodeIDs().

Referenced by LayeredMeshGenerator::getMesh().

◆ scaleMeshPropertyVector()

void MeshLib::scaleMeshPropertyVector ( Mesh mesh,
std::string const &  property_name,
double  factor 
)

Scales the mesh property with name property_name by given factor.

Note
The property must be a "double" property.

Definition at line 255 of file Mesh.cpp.

258 {
259  if (!mesh.getProperties().existsPropertyVector<double>(property_name))
260  {
261  WARN("Did not find PropertyVector '{:s}' for scaling.", property_name);
262  return;
263  }
264  auto& pv = *mesh.getProperties().getPropertyVector<double>(property_name);
265  std::transform(pv.begin(), pv.end(), pv.begin(),
266  [factor](auto const& v) { return v * factor; });
267 }
PropertyVector< T > const * getPropertyVector(std::string const &name) const
bool existsPropertyVector(std::string const &name) const
static const double v

References MeshLib::Properties::existsPropertyVector(), MeshLib::Mesh::getProperties(), MeshLib::Properties::getPropertyVector(), MathLib::v, and WARN().

Referenced by main().

◆ setMeshSpaceDimension()

void MeshLib::setMeshSpaceDimension ( std::vector< std::unique_ptr< Mesh >> const &  meshes)

In this function, the dimension of the space, which contains all nodes of the bulk mesh, is computed, and it is then set as a member of the elements of all meshes.

The space dimension is needed for the numerical simulations with a bulk mesh with elements with different dimensions. For example, in a bulk mesh for the numerical simulation of the liquid flow in the fractured porous media, the 1D or 2D elements can be used to represent the fractures, while the elements with higher dimension can be used to discretise the porous medium matrix domain.

Parameters
meshesAll meshes include the bulk mesh and the meshes for boundary conditions.

Definition at line 20 of file SetMeshSpaceDimension.cpp.

21 {
22  // Get the space dimension from the bulk mesh:
23  auto const space_dimension = getSpaceDimension(meshes[0]->getNodes());
24  for (auto& mesh : meshes)
25  {
26  auto elements = mesh->getElements();
27  for (auto element : elements)
28  {
29  element->space_dimension_ = space_dimension;
30  }
31  }
32 }
std::vector< std::size_t > getNodes(GeoLib::Point const &pnt, std::vector< MeshLib::Node * > const &nodes, MeshLib::PropertyVector< int > const &mat_ids, std::pair< int, int > const &mat_limits, std::pair< double, double > const &elevation_limits, MeshLib::Mesh const &mesh)
int getSpaceDimension(std::vector< Node * > const &nodes)
Computes dimension of the embedding space containing the set of given points.

References getNodes(), and getSpaceDimension().

Referenced by anonymous_namespace{ProjectData.cpp}::readMeshes().

◆ String2MeshElemType()

MeshElemType MeshLib::String2MeshElemType ( const std::string &  s)

Given a string of the shortened name of the element type, this returns the corresponding MeshElemType.

Definition at line 95 of file MeshEnums.cpp.

96 {
97  if (boost::iequals(s, "point"))
98  {
99  return MeshElemType::POINT;
100  }
101  if (boost::iequals(s, "line"))
102  {
103  return MeshElemType::LINE;
104  }
105  if (boost::iequals(s, "quad") || boost::iequals(s, "Quadrilateral"))
106  {
107  return MeshElemType::QUAD;
108  }
109  if (boost::iequals(s, "hex") || boost::iequals(s, "Hexahedron"))
110  {
111  return MeshElemType::HEXAHEDRON;
112  }
113  if (boost::iequals(s, "tri") || boost::iequals(s, "Triangle"))
114  {
115  return MeshElemType::TRIANGLE;
116  }
117  if (boost::iequals(s, "tet") || boost::iequals(s, "Tetrahedron"))
118  {
119  return MeshElemType::TETRAHEDRON;
120  }
121  if (boost::iequals(s, "pris") || boost::iequals(s, "Prism"))
122  {
123  return MeshElemType::PRISM;
124  }
125  if (boost::iequals(s, "pyra") || boost::iequals(s, "Pyramid"))
126  {
127  return MeshElemType::PYRAMID;
128  }
129  return MeshElemType::INVALID;
130 }
static const double s

References HEXAHEDRON, INVALID, LINE, POINT, PRISM, PYRAMID, QUAD, MathLib::s, TETRAHEDRON, and TRIANGLE.

Referenced by MeshElementRemovalDialog::accept(), main(), and MeshLib::IO::Legacy::MeshIO::readElement().

◆ String2MeshQualityType()

MeshLib::MeshQualityType MeshLib::String2MeshQualityType ( std::string const &  s)

Definition at line 211 of file MeshEnums.cpp.

212 {
213  if (boost::iequals(s, "ElementSize"))
214  {
215  return MeshQualityType::ELEMENTSIZE;
216  }
217  if (boost::iequals(s, "EdgeRatio"))
218  {
219  return MeshQualityType::EDGERATIO;
220  }
221  if (boost::iequals(s, "EquiAngleSkew"))
222  {
223  return MeshQualityType::EQUIANGLESKEW;
224  }
225  if (boost::iequals(s, "RadiusEdgeRatio"))
226  {
227  return MeshQualityType::RADIUSEDGERATIO;
228  }
229  if (boost::iequals(s, "SizeDifference"))
230  {
231  return MeshQualityType::SIZEDIFFERENCE;
232  }
233  return MeshQualityType::INVALID;
234 }

References EDGERATIO, ELEMENTSIZE, EQUIANGLESKEW, INVALID, RADIUSEDGERATIO, MathLib::s, and SIZEDIFFERENCE.

Referenced by main().

◆ toString()

static constexpr char const* MeshLib::toString ( const MeshItemType  t)
staticconstexpr

Returns a char array for a specific MeshItemType.

Definition at line 28 of file Location.h.

29 {
30  return mesh_item_type_strings[static_cast<int>(t)];
31 }
static constexpr char const * mesh_item_type_strings[]
Char array names for all of MeshItemType values.
Definition: Location.h:24

References mesh_item_type_strings, and MathLib::t.

Referenced by MeshLib::IO::NodePartitionedMeshReader::readProperties().

◆ trackSurface()

static void MeshLib::trackSurface ( MeshLib::Element const *const  element,
std::vector< unsigned > &  sfc_idx,
unsigned const  current_index 
)
static

Finds all surface elements that can be reached from element. All elements that are found in this way are marked in the global sfc_idx vector using the current_index.

Parameters
elementThe mesh element from which the search is started
sfc_idxThe global index vector notifying to which surface elements belong
current_indexThe index that all elements reachable from element will be assigned in sfc_idx

Definition at line 40 of file MeshValidation.cpp.

43 {
44  std::stack<MeshLib::Element const*> elem_stack;
45  elem_stack.push(element);
46  while (!elem_stack.empty())
47  {
48  MeshLib::Element const* const elem = elem_stack.top();
49  elem_stack.pop();
50  sfc_idx[elem->getID()] = current_index;
51  std::size_t const n_neighbors(elem->getNumberOfNeighbors());
52  for (std::size_t i = 0; i < n_neighbors; ++i)
53  {
54  MeshLib::Element const* neighbor(elem->getNeighbor(i));
55  if (neighbor != nullptr && sfc_idx[neighbor->getID()] ==
56  std::numeric_limits<unsigned>::max())
57  {
58  elem_stack.push(neighbor);
59  }
60  }
61  }
62 }
virtual const Element * getNeighbor(unsigned i) const =0
Get the specified neighbor.
virtual unsigned getNumberOfNeighbors() const =0
Get the number of neighbors for this element.
virtual std::size_t getID() const final
Returns the ID of the element.
Definition: Element.h:89

References MeshLib::Element::getID(), MeshLib::Element::getNeighbor(), and MeshLib::Element::getNumberOfNeighbors().

Referenced by MeshLib::MeshValidation::detectHoles().

◆ vtkStandardNewMacro()

MeshLib::vtkStandardNewMacro ( VtkMappedMeshSource  )

Definition at line 32 of file VtkMappedMeshSource.cpp.

35 {
36  this->Superclass::PrintSelf(os, indent);
37  os << indent << "Mesh: " << (_mesh ? _mesh->getName() : "(none)") << endl;
38 }

References MeshLib::VtkMappedMeshSource::_mesh, and MeshLib::Mesh::getName().

Variable Documentation

◆ mesh_item_type_strings

constexpr char const* MeshLib::mesh_item_type_strings[]
staticconstexpr
Initial value:
= {
"node", "edge", "face", "cell", "integration_point"}

Char array names for all of MeshItemType values.

Definition at line 24 of file Location.h.

Referenced by toString().