Nektar++
Loading...
Searching...
No Matches
Typedefs | Functions
GeomElements.cpp File Reference
#include <LibUtilities/Python/NekPyConfig.hpp>
#include <SpatialDomains/Python/SpatialDomains.h>
#include <SpatialDomains/HexGeom.h>
#include <SpatialDomains/MeshGraph.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.

Typedefs

using NekError = Nektar::ErrorUtil::NekError
 

Functions

template<class T , class S >
unique_ptr_objpool< T > Geometry_Init (int id, py::list &facets)
 
template<class T , class S >
unique_ptr_objpool< T > Geometry_Init_Curved (int id, py::list &facets, Curve *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)
 
unique_ptr_objpool< SegGeomSegGeom_Init (int id, int coordim, py::list &points, Curve *curve)
 
unique_ptr_objpool< PointGeomPointGeom_Init (int coordim, int id, NekDouble x, NekDouble y, NekDouble z)
 
py::tuple PointGeom_GetCoordinates (const PointGeom &self)
 
void export_GeomElements (py::module &m)
 

Typedef Documentation

◆ NekError

Definition at line 51 of file GeomElements.cpp.

Function Documentation

◆ export_Geom_2d()

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

Definition at line 90 of file GeomElements.cpp.

91{
92 py::classh<T, Geometry2D>(m, name)
93 .def(py::init<>(&Geometry_Init<T, S>), py::arg("id"),
94 py::arg("segments") = py::list())
95 .def(py::init<>(&Geometry_Init_Curved<T, S>), py::arg("id"),
96 py::arg("segments"), py::arg("curve"));
97}

◆ export_Geom_3d()

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

Definition at line 99 of file GeomElements.cpp.

100{
101 py::classh<T, Geometry3D>(m, name).def(py::init<>(&Geometry_Init<T, S>),
102 py::arg("id"),
103 py::arg("segments") = py::list());
104}

◆ export_GeomElements()

void export_GeomElements ( py::module &  m)

Definition at line 143 of file GeomElements.cpp.

144{
145 // Geometry dimensioned base classes
146 py::classh<Geometry1D, Geometry>(m, "Geometry1D");
147 py::classh<Geometry2D, Geometry>(m, "Geometry2D")
148 .def("GetCurve", &Geometry2D::GetCurve,
149 py::return_value_policy::reference);
150 py::classh<Geometry3D, Geometry>(m, "Geometry3D");
151
152 // Point geometries
153 py::classh<PointGeom, Geometry>(m, "PointGeom")
154 .def(py::init<>(&PointGeom_Init), py::arg("coordim"), py::arg("id"),
155 py::arg("x"), py::arg("y"), py::arg("z"))
156 .def("GetCoordinates", &PointGeom_GetCoordinates);
157
158 // Segment geometries
159 py::classh<SegGeom, Geometry>(m, "SegGeom")
160 .def(py::init<>(&SegGeom_Init), py::arg("id"), py::arg("coordim"),
161 py::arg("points") = py::list(), py::arg("curve") = nullptr)
162 .def("GetCurve", &SegGeom::GetCurve,
163 py::return_value_policy::reference);
164
165 export_Geom_2d<TriGeom, SegGeom>(m, "TriGeom");
166 export_Geom_2d<QuadGeom, SegGeom>(m, "QuadGeom");
167 export_Geom_3d<TetGeom, TriGeom>(m, "TetGeom");
168 export_Geom_3d<PrismGeom, Geometry2D>(m, "PrismGeom");
169 export_Geom_3d<PyrGeom, Geometry2D>(m, "PyrGeom");
170 export_Geom_3d<HexGeom, QuadGeom>(m, "HexGeom");
171}
py::tuple PointGeom_GetCoordinates(const PointGeom &self)
unique_ptr_objpool< SegGeom > SegGeom_Init(int id, int coordim, py::list &points, Curve *curve)
unique_ptr_objpool< PointGeom > PointGeom_Init(int coordim, int id, NekDouble x, NekDouble y, NekDouble z)

References Nektar::SpatialDomains::Geometry2D::GetCurve(), Nektar::SpatialDomains::SegGeom::GetCurve(), PointGeom_GetCoordinates(), PointGeom_Init(), and SegGeom_Init().

Referenced by PYBIND11_MODULE().

◆ Geometry_Init()

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

Definition at line 54 of file GeomElements.cpp.

55{
56 std::array<S *, T::kNfacets> geomArr;
57
58 if (py::len(facets) != T::kNfacets)
59 {
60 throw new NekError("Incorrect number of facets for this geometry");
61 }
62
63 for (int i = 0; i < T::kNfacets; ++i)
64 {
65 geomArr[i] = py::cast<S *>(facets[i]);
66 }
67
68 return ObjPoolManager<T>::AllocateUniquePtr(id, geomArr);
69}
Nektar::ErrorUtil::NekError NekError
static std::unique_ptr< DataType, UniquePtrDeleter > AllocateUniquePtr(const Args &...args)

References Nektar::ObjPoolManager< DataType >::AllocateUniquePtr().

◆ Geometry_Init_Curved()

template<class T , class S >
unique_ptr_objpool< T > Geometry_Init_Curved ( int  id,
py::list &  facets,
Curve curve 
)

Definition at line 72 of file GeomElements.cpp.

74{
75 std::array<S *, T::kNfacets> geomArr;
76
77 if (py::len(facets) != T::kNfacets)
78 {
79 throw new NekError("Incorrect number of facets for this geometry");
80 }
81
82 for (int i = 0; i < T::kNfacets; ++i)
83 {
84 geomArr[i] = py::cast<S *>(facets[i]);
85 }
86
87 return ObjPoolManager<T>::AllocateUniquePtr(id, geomArr, curve);
88}

References Nektar::ObjPoolManager< DataType >::AllocateUniquePtr().

◆ PointGeom_GetCoordinates()

py::tuple PointGeom_GetCoordinates ( const PointGeom self)

Definition at line 138 of file GeomElements.cpp.

139{
140 return py::make_tuple(self.x(), self.y(), self.z());
141}
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().

◆ PointGeom_Init()

unique_ptr_objpool< PointGeom > PointGeom_Init ( int  coordim,
int  id,
NekDouble  x,
NekDouble  y,
NekDouble  z 
)

Definition at line 132 of file GeomElements.cpp.

134{
135 return ObjPoolManager<PointGeom>::AllocateUniquePtr(coordim, id, x, y, z);
136}

References Nektar::ObjPoolManager< DataType >::AllocateUniquePtr().

Referenced by export_GeomElements().

◆ SegGeom_Init()

unique_ptr_objpool< SegGeom > SegGeom_Init ( int  id,
int  coordim,
py::list &  points,
Curve curve 
)

Definition at line 106 of file GeomElements.cpp.

108{
109 std::array<PointGeom *, 2> geomArr;
110
111 if (py::len(points) != 2)
112 {
113 throw new NekError("Incorrect number of facets for this geometry");
114 }
115
116 for (int i = 0; i < 2; ++i)
117 {
118 geomArr[i] = py::cast<PointGeom *>(points[i]);
119 }
120
121 if (!curve)
122 {
123 return ObjPoolManager<SegGeom>::AllocateUniquePtr(id, coordim, geomArr);
124 }
125 else
126 {
127 return ObjPoolManager<SegGeom>::AllocateUniquePtr(id, coordim, geomArr,
128 curve);
129 }
130}

References Nektar::ObjPoolManager< DataType >::AllocateUniquePtr().

Referenced by export_GeomElements().