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 116 of file OGSMesh.cpp.

118{
120 _mesh, name, MeshLib::MeshItemType::Cell, number_of_components);
121 if (pv == nullptr)
122 {
123 OGS_FATAL("Couldn't access cell/element property '{}'.", name);
124 }
125 return ranges::to<std::vector>(std::span(pv->data(), pv->size()));
126}
#define OGS_FATAL(...)
Definition Error.h:26
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)

References _mesh, MeshLib::Cell, MeshLib::getOrCreateMeshProperty(), 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 ranges::copy(element->nodes() | MeshLib::views::ids,
58 std::back_inserter(cells));
59 cell_types.push_back(OGSToVtkCellType(element->getCellType()));
60 }
61 return {cells, cell_types};
62}
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 84 of file OGSMesh.cpp.

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

References _mesh, MeshLib::getOrCreateMeshProperty(), 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 96 of file OGSMesh.cpp.

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

References _mesh, MeshLib::Cell, MeshLib::getOrCreateMeshProperty(), 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 64 of file OGSMesh.cpp.

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

References _mesh, MeshLib::getOrCreateMeshProperty(), 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: