Nektar++
Functions
GeomElements.cpp File Reference
#include <LibUtilities/Python/NekPyConfig.hpp>
#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 (const char *name)
 
template<class T , class S >
void export_Geom_3d (const char *name)
 
SegGeomSharedPtr SegGeom_Init (int id, int coordim, py::list &points, py::object &curve)
 
py::tuple PointGeom_GetCoordinates (const PointGeom &self)
 
void export_GeomElements ()
 

Function Documentation

◆ export_Geom_2d()

template<class T , class S >
void export_Geom_2d ( const char *  name)

Definition at line 75 of file GeomElements.cpp.

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

References CellMLToNektar.pycml::name.

◆ export_Geom_3d()

template<class T , class S >
void export_Geom_3d ( const char *  name)

Definition at line 87 of file GeomElements.cpp.

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

References CellMLToNektar.pycml::name.

◆ export_GeomElements()

void export_GeomElements ( )

Definition at line 122 of file GeomElements.cpp.

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

References PointGeom_GetCoordinates(), and SegGeom_Init().

Referenced by BOOST_PYTHON_MODULE().

◆ Geometry_Init()

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

Definition at line 49 of file GeomElements.cpp.

50{
51 std::vector<std::shared_ptr<S>> geomVec;
52
53 for (int i = 0; i < py::len(facets); ++i)
54 {
55 geomVec.push_back(py::extract<std::shared_ptr<S>>(facets[i]));
56 }
57
58 return std::make_shared<T>(id, &geomVec[0]);
59}
def extract(self, check_equality=False)
Definition: pycml.py:2657

References CellMLToNektar.pycml::extract().

◆ 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 62 of file GeomElements.cpp.

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

References CellMLToNektar.pycml::extract().

◆ PointGeom_GetCoordinates()

py::tuple PointGeom_GetCoordinates ( const PointGeom self)

Definition at line 117 of file GeomElements.cpp.

118{
119 return py::make_tuple(self.x(), self.y(), self.z());
120}
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,
py::object &  curve 
)

Definition at line 96 of file GeomElements.cpp.

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

Referenced by export_GeomElements().