Nektar++
Functions
GeomElements.cpp File Reference
#include <LibUtilities/Python/NekPyConfig.hpp>
#include <SpatialDomains/Python/SpatialDomains.h>
#include <SpatialDomains/HexGeom.h>
#include <SpatialDomains/PointGeom.h>
#include <SpatialDomains/PrismGeom.h>
#include <SpatialDomains/PyrGeom.h>
#include <SpatialDomains/QuadGeom.h>
#include <SpatialDomains/SegGeom.h>
#include <SpatialDomains/TetGeom.h>
#include <SpatialDomains/TriGeom.h>

Go to the source code of this file.

Functions

template<class T , class S >
std::shared_ptr< T > Geometry_Init (int id, py::list &facets)
 
template<class T , class S >
std::shared_ptr< T > Geometry_Init_Curved (int id, py::list &facets, CurveSharedPtr curve)
 
template<class T , class S >
void export_Geom_2d (py::module &m, const char *name)
 
template<class T , class S >
void export_Geom_3d (py::module &m, const char *name)
 
SegGeomSharedPtr SegGeom_Init (int id, int coordim, py::list &points, CurveSharedPtr curve)
 
py::tuple PointGeom_GetCoordinates (const PointGeom &self)
 
void export_GeomElements (py::module &m)
 

Function Documentation

◆ export_Geom_2d()

template<class T , class S >
void export_Geom_2d ( py::module &  m,
const char *  name 
)

Definition at line 77 of file GeomElements.cpp.

78{
79 py::class_<T, Geometry2D, std::shared_ptr<T>>(m, name)
80 .def(py::init<>())
81 .def(py::init<>(&Geometry_Init<T, S>), py::arg("id"),
82 py::arg("segments") = py::list())
83 .def(py::init<>(&Geometry_Init_Curved<T, S>), py::arg("id"),
84 py::arg("segments"), py::arg("curve"));
85}

References CellMLToNektar.pycml::name.

◆ export_Geom_3d()

template<class T , class S >
void export_Geom_3d ( py::module &  m,
const char *  name 
)

Definition at line 87 of file GeomElements.cpp.

88{
89 py::class_<T, Geometry3D, std::shared_ptr<T>>(m, name)
90 .def(py::init<>())
91 .def(py::init<>(&Geometry_Init<T, S>), py::arg("id"),
92 py::arg("segments") = py::list());
93}

References CellMLToNektar.pycml::name.

◆ export_GeomElements()

void export_GeomElements ( py::module &  m)

Definition at line 120 of file GeomElements.cpp.

121{
122 // Geometry dimensioned base classes
123 py::class_<Geometry1D, Geometry, std::shared_ptr<Geometry1D>>(m,
124 "Geometry1D");
125 py::class_<Geometry2D, Geometry, std::shared_ptr<Geometry2D>>(m,
126 "Geometry2D")
127 .def("GetCurve", &Geometry2D::GetCurve);
128 py::class_<Geometry3D, Geometry, std::shared_ptr<Geometry3D>>(m,
129 "Geometry3D");
130
131 // Point geometries
132 py::class_<PointGeom, Geometry, std::shared_ptr<PointGeom>>(m, "PointGeom")
133 .def(py::init<>())
134 .def(py::init<int, int, NekDouble, NekDouble, NekDouble>())
135 .def("GetCoordinates", &PointGeom_GetCoordinates);
136
137 // Segment geometries
138 py::class_<SegGeom, Geometry, std::shared_ptr<SegGeom>>(m, "SegGeom")
139 .def(py::init<>())
140 .def(py::init<>(&SegGeom_Init), py::arg("id"), py::arg("coordim"),
141 py::arg("points") = py::list(),
142 py::arg("curve") = CurveSharedPtr())
143 .def("GetCurve", &SegGeom::GetCurve);
144
145 export_Geom_2d<TriGeom, SegGeom>(m, "TriGeom");
146 export_Geom_2d<QuadGeom, SegGeom>(m, "QuadGeom");
147 export_Geom_3d<TetGeom, TriGeom>(m, "TetGeom");
148 export_Geom_3d<PrismGeom, Geometry2D>(m, "PrismGeom");
149 export_Geom_3d<PyrGeom, Geometry2D>(m, "PyrGeom");
150 export_Geom_3d<HexGeom, QuadGeom>(m, "HexGeom");
151}
py::tuple PointGeom_GetCoordinates(const PointGeom &self)
SegGeomSharedPtr SegGeom_Init(int id, int coordim, py::list &points, CurveSharedPtr curve)
std::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:58

References PointGeom_GetCoordinates(), and SegGeom_Init().

Referenced by PYBIND11_MODULE().

◆ Geometry_Init()

template<class T , class S >
std::shared_ptr< T > Geometry_Init ( int  id,
py::list &  facets 
)

Definition at line 51 of file GeomElements.cpp.

52{
53 std::vector<std::shared_ptr<S>> geomVec;
54
55 for (int i = 0; i < py::len(facets); ++i)
56 {
57 geomVec.push_back(py::cast<std::shared_ptr<S>>(facets[i]));
58 }
59
60 return std::make_shared<T>(id, &geomVec[0]);
61}

◆ Geometry_Init_Curved()

template<class T , class S >
std::shared_ptr< T > Geometry_Init_Curved ( int  id,
py::list &  facets,
CurveSharedPtr  curve 
)

Definition at line 64 of file GeomElements.cpp.

66{
67 std::vector<std::shared_ptr<S>> geomVec;
68
69 for (int i = 0; i < py::len(facets); ++i)
70 {
71 geomVec.push_back(py::cast<std::shared_ptr<S>>(facets[i]));
72 }
73
74 return std::make_shared<T>(id, &geomVec[0], curve);
75}

◆ PointGeom_GetCoordinates()

py::tuple PointGeom_GetCoordinates ( const PointGeom self)

Definition at line 115 of file GeomElements.cpp.

116{
117 return py::make_tuple(self.x(), self.y(), self.z());
118}
boost::call_traits< DataType >::const_reference x() const
Definition: NekPoint.hpp:160
boost::call_traits< DataType >::const_reference z() const
Definition: NekPoint.hpp:172
boost::call_traits< DataType >::const_reference y() const
Definition: NekPoint.hpp:166

References Nektar::NekPoint< data_type >::x(), Nektar::NekPoint< data_type >::y(), and Nektar::NekPoint< data_type >::z().

Referenced by export_GeomElements().

◆ SegGeom_Init()

SegGeomSharedPtr SegGeom_Init ( int  id,
int  coordim,
py::list &  points,
CurveSharedPtr  curve 
)

Definition at line 95 of file GeomElements.cpp.

97{
98 std::vector<PointGeomSharedPtr> geomVec;
99
100 for (int i = 0; i < py::len(points); ++i)
101 {
102 geomVec.push_back(py::cast<PointGeomSharedPtr>(points[i]));
103 }
104
105 if (!curve)
106 {
107 return std::make_shared<SegGeom>(id, coordim, &geomVec[0]);
108 }
109 else
110 {
111 return std::make_shared<SegGeom>(id, coordim, &geomVec[0], curve);
112 }
113}

Referenced by export_GeomElements().