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

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 , class PARENT >
void export_Geom (const char *name)
 
SegGeomSharedPtr SegGeom_Init (int id, int coordim, py::list &points, py::object &curve)
 
void export_GeomElements ()
 

Function Documentation

◆ export_Geom()

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

Definition at line 62 of file GeomElements.cpp.

References CellMLToNektar.pycml::name, and NEKPY_SHPTR_FIX.

63 {
64  py::class_<T, py::bases<PARENT>, std::shared_ptr<T> >(name, py::init<>())
65  .def("__init__", py::make_constructor(
66  &Geometry_Init<T, S>, py::default_call_policies(), (
67  py::arg("id"), py::arg("segments")=py::list())));
68 
69  NEKPY_SHPTR_FIX(T, PARENT);
71 }
Base class for shape geometry information.
Definition: Geometry.h:83
#define NEKPY_SHPTR_FIX(SOURCE, TARGET)

◆ export_GeomElements()

void export_GeomElements ( )

Definition at line 94 of file GeomElements.cpp.

References Nektar::SpatialDomains::SegGeom::GetCurve(), NEKPY_SHPTR_FIX, and SegGeom_Init().

Referenced by BOOST_PYTHON_MODULE().

95 {
96  // Geometry dimensioned base classes
97  py::class_<Geometry1D, py::bases<Geometry>, std::shared_ptr<Geometry1D>,
98  boost::noncopyable>(
99  "Geometry1D", py::no_init);
100  py::class_<Geometry2D, py::bases<Geometry>, std::shared_ptr<Geometry2D>,
101  boost::noncopyable>(
102  "Geometry2D", py::no_init);
103  py::class_<Geometry3D, py::bases<Geometry>, std::shared_ptr<Geometry3D>,
104  boost::noncopyable>(
105  "Geometry3D", py::no_init);
106 
107  // Point geometries
108  py::class_<PointGeom, py::bases<Geometry>, std::shared_ptr<PointGeom> >(
109  "PointGeom", py::init<>())
110  .def(py::init<int, int, NekDouble, NekDouble, NekDouble>());
111 
112  // Segment geometries
113  py::class_<SegGeom, py::bases<Geometry>, std::shared_ptr<SegGeom> >(
114  "SegGeom", py::init<>())
115  .def("__init__", py::make_constructor(
116  &SegGeom_Init, py::default_call_policies(), (
117  py::arg("id"), py::arg("coordim"),
118  py::arg("points")=py::list(),
119  py::arg("curve")=py::object())))
120  .def("GetCurve", &SegGeom::GetCurve);
121 
122  export_Geom<TriGeom, SegGeom, Geometry2D>("TriGeom");
123  export_Geom<QuadGeom, SegGeom, Geometry2D>("QuadGeom");
124  export_Geom<TetGeom, TriGeom, Geometry3D>("TetGeom");
125  export_Geom<PrismGeom, Geometry2D, Geometry3D>("PrismGeom");
126  export_Geom<PyrGeom, Geometry2D, Geometry3D>("PyrGeom");
127  export_Geom<HexGeom, QuadGeom, Geometry3D>("HexGeom");
128 
134 }
Base class for shape geometry information.
Definition: Geometry.h:83
#define NEKPY_SHPTR_FIX(SOURCE, TARGET)
SegGeomSharedPtr SegGeom_Init(int id, int coordim, py::list &points, py::object &curve)
3D geometry information
Definition: Geometry3D.h:67
1D geometry information
Definition: Geometry1D.h:54
2D geometry information
Definition: Geometry2D.h:68

◆ 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.

References CellMLToNektar.pycml::extract().

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

◆ SegGeom_Init()

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

Definition at line 73 of file GeomElements.cpp.

Referenced by export_GeomElements().

75 {
76  std::vector<PointGeomSharedPtr> geomVec;
77 
78  for (int i = 0; i < py::len(points); ++i)
79  {
80  geomVec.push_back(py::extract<PointGeomSharedPtr>(points[i]));
81  }
82 
83  if (curve.is_none())
84  {
85  return std::make_shared<SegGeom>(id, coordim, &geomVec[0]);
86  }
87  else
88  {
89  return std::make_shared<SegGeom>(id, coordim, &geomVec[0],
90  py::extract<CurveSharedPtr>(curve));
91  }
92 }