OGS
OGSMesh Class Reference

Detailed Description

Definition at line 26 of file OGSMesh.h.

#include <OGSMesh.h>

Collaboration diagram for OGSMesh:
[legend]

Public Member Functions

 OGSMesh (MeshLib::Mesh &mesh)
 
std::vector< double > getPointCoordinates () const
 
void setPointDataArray (std::string const &name, std::vector< double > const &values, std::size_t const number_of_components)
 
std::vector< double > getPointDataArray (std::string const &name, std::size_t const number_of_components=1) const
 
std::pair< std::vector< int >, std::vector< int > > getCells () const
 
void setCellDataArray (std::string const &name, std::vector< double > const &values, std::size_t const number_of_components)
 
std::vector< double > getCellDataArray (std::string const &name, std::size_t const number_of_components) const
 

Private Attributes

MeshLib::Mesh_mesh
 

Constructor & Destructor Documentation

◆ OGSMesh()

OGSMesh::OGSMesh ( MeshLib::Mesh & mesh)
explicit

Definition at line 42 of file OGSMesh.cpp.

42: _mesh(mesh) {}
MeshLib::Mesh & _mesh
Definition OGSMesh.h:46

Member Function Documentation

◆ getCellDataArray()

std::vector< double > OGSMesh::getCellDataArray ( std::string const & name,
std::size_t const number_of_components ) const

Definition at line 117 of file OGSMesh.cpp.

119{
120 auto const* pv = MeshLib::getOrCreateMeshProperty<double>(
121 _mesh, name, MeshLib::MeshItemType::Cell, number_of_components);
122 if (pv == nullptr)
123 {
124 OGS_FATAL("Couldn't access cell/element property '{}'.", name);
125 }
126 return ranges::to<std::vector>(std::span(pv->data(), pv->size()));
127}
#define OGS_FATAL(...)
Definition Error.h:26

References _mesh, MeshLib::Cell, and OGS_FATAL.

Referenced by PYBIND11_MODULE().

◆ getCells()

std::pair< std::vector< int >, std::vector< int > > OGSMesh::getCells ( ) const

Definition at line 50 of file OGSMesh.cpp.

51{
52 auto const& elements = _mesh.getElements();
53 std::vector<int> cells;
54 std::vector<int> cell_types;
55 for (auto const* element : elements)
56 {
57 cells.push_back(static_cast<int>(element->getNumberOfNodes()));
58 ranges::copy(element->nodes() | MeshLib::views::ids,
59 std::back_inserter(cells));
60 cell_types.push_back(OGSToVtkCellType(element->getCellType()));
61 }
62 return {cells, cell_types};
63}
int OGSToVtkCellType(MeshLib::CellType ogs)
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:225

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

Referenced by PYBIND11_MODULE().

◆ getPointCoordinates()

std::vector< double > OGSMesh::getPointCoordinates ( ) const

Definition at line 44 of file OGSMesh.cpp.

45{
46 return ranges::to<std::vector>(_mesh.getNodes() | MeshLib::views::coords |
47 ranges::views::join);
48}
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
constexpr ranges::views::view_closure coords
Definition Mesh.h:232

References _mesh, MeshLib::views::coords, and MeshLib::Mesh::getNodes().

Referenced by PYBIND11_MODULE().

◆ getPointDataArray()

std::vector< double > OGSMesh::getPointDataArray ( std::string const & name,
std::size_t const number_of_components = 1 ) const

Definition at line 85 of file OGSMesh.cpp.

87{
88 auto const* pv = MeshLib::getOrCreateMeshProperty<double>(
89 _mesh, name, MeshLib::MeshItemType::Node, number_of_components);
90 if (pv == nullptr)
91 {
92 OGS_FATAL("Couldn't access point/node property '{}'.", name);
93 }
94 return ranges::to<std::vector>(std::span(pv->data(), pv->size()));
95}

References _mesh, MeshLib::Node, and OGS_FATAL.

Referenced by PYBIND11_MODULE().

◆ setCellDataArray()

void OGSMesh::setCellDataArray ( std::string const & name,
std::vector< double > const & values,
std::size_t const number_of_components )

Definition at line 97 of file OGSMesh.cpp.

100{
101 auto* pv = MeshLib::getOrCreateMeshProperty<double>(
102 _mesh, name, MeshLib::MeshItemType::Cell, number_of_components);
103 if (pv == nullptr)
104 {
105 OGS_FATAL("Couldn't access cell/element property '{}'.", name);
106 }
107 if (pv->size() != values.size())
108 {
109 OGS_FATAL(
110 "OGSMesh::setCellDataArray: size mismatch: property vector has "
111 "size '{}', while the number of values is '{}'.",
112 pv->size(), values.size());
113 }
114 std::copy(values.begin(), values.end(), pv->data());
115}

References _mesh, MeshLib::Cell, and OGS_FATAL.

Referenced by PYBIND11_MODULE().

◆ setPointDataArray()

void OGSMesh::setPointDataArray ( std::string const & name,
std::vector< double > const & values,
std::size_t const number_of_components )

Definition at line 65 of file OGSMesh.cpp.

68{
69 auto* pv = MeshLib::getOrCreateMeshProperty<double>(
70 _mesh, name, MeshLib::MeshItemType::Node, number_of_components);
71 if (pv == nullptr)
72 {
73 OGS_FATAL("Couldn't access cell/element property '{}'.", name);
74 }
75 if (pv->size() != values.size())
76 {
78 "OGSMesh::setPointDataArray: size mismatch: property vector has "
79 "size '{}', while the number of values is '{}'.",
80 pv->size(), values.size());
81 }
82 std::copy(values.begin(), values.end(), pv->data());
83}

References _mesh, MeshLib::Node, and OGS_FATAL.

Referenced by PYBIND11_MODULE().

Member Data Documentation

◆ _mesh

MeshLib::Mesh& OGSMesh::_mesh
private

The documentation for this class was generated from the following files: