OGS
OGSMesh.cpp
Go to the documentation of this file.
1
13#include "OGSMesh.h"
14
15#include <pybind11/eigen.h>
16#include <pybind11/pybind11.h>
17#include <pybind11/stl.h>
18#include <spdlog/spdlog.h>
19
20#include <range/v3/view/join.hpp>
21#include <vector>
22
24#include "BaseLib/Logging.h"
25#include "InfoLib/GitInfo.h"
27#include "MeshLib/Node.h"
28#include "MeshLib/VtkOGSEnum.h"
29
30OGSMesh::OGSMesh(MeshLib::Mesh& mesh) : _mesh(mesh) {}
31
32std::vector<double> OGSMesh::getPointCoordinates() const
33{
34 return ranges::to<std::vector>(_mesh.getNodes() | MeshLib::views::coords |
35 ranges::views::join);
36}
37
38std::pair<std::vector<int>, std::vector<int>> OGSMesh::getCells() const
39{
40 auto const& elements = _mesh.getElements();
41 std::vector<int> cells;
42 std::vector<int> cell_types;
43 for (auto const* element : elements)
44 {
45 ranges::copy(element->nodes() | MeshLib::views::ids,
46 std::back_inserter(cells));
47 cell_types.push_back(OGSToVtkCellType(element->getCellType()));
48 }
49 return {cells, cell_types};
50}
51
52std::vector<std::string> OGSMesh::getDataArrayNames() const
53{
55}
56
57MeshLib::MeshItemType OGSMesh::meshItemType(std::string_view const name) const
58{
59 auto const& properties = _mesh.getProperties();
60
61 auto const& found = BaseLib::findElementOrError(
62 properties,
63 [&name](auto const& p) { return p.first == name; },
64 [&name]()
65 {
66 OGS_FATAL("A property with the name '{}' doesn't exist in the mesh",
67 name);
68 });
69 return found.second->getMeshItemType();
70}
Definition of the Element class.
#define OGS_FATAL(...)
Definition Error.h:26
Git information.
Definition of the Node class.
int OGSToVtkCellType(MeshLib::CellType ogs)
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:108
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:111
Properties & getProperties()
Definition Mesh.h:136
std::vector< std::string > getPropertyVectorNames() const
MeshLib::MeshItemType meshItemType(std::string_view const name) const
Definition OGSMesh.cpp:57
MeshLib::Mesh & _mesh
Definition OGSMesh.h:149
std::vector< double > getPointCoordinates() const
Definition OGSMesh.cpp:32
std::vector< std::string > getDataArrayNames() const
Definition OGSMesh.cpp:52
OGSMesh(MeshLib::Mesh &mesh)
Definition OGSMesh.cpp:30
std::pair< std::vector< int >, std::vector< int > > getCells() const
Definition OGSMesh.cpp:38
ranges::range_reference_t< Range > findElementOrError(Range &range, std::predicate< ranges::range_reference_t< Range > > auto &&predicate, std::invocable auto error_callback)
Definition Algorithm.h:81
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:227
constexpr ranges::views::view_closure coords
Definition Mesh.h:234