Nektar++
Python/MeshGraph.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: MeshGraph.cpp
4//
5// For more information, please see: http://www.nektar.info/
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Python wrapper for MeshGraph.
32//
33////////////////////////////////////////////////////////////////////////////////
34
39#include <boost/python/suite/indexing/map_indexing_suite.hpp>
40#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
41
42using namespace Nektar;
43using namespace Nektar::SpatialDomains;
44
45/*
46 * @brief Simple wrapper to build Composite objects from lists of
47 * Geometry objects.
48 */
50{
51 CompositeSharedPtr composite = std::make_shared<Composite>();
52 composite->m_geomVec.clear();
53 for (int i = 0; i < py::len(geometries); i++)
54 {
55 composite->m_geomVec.emplace_back(
56 py::extract<GeometrySharedPtr>(geometries[i]));
57 }
58 return composite;
59}
60
61/**
62 * @brief MeshGraph exports.
63 */
65{
66 py::class_<LibUtilities::FieldMetaDataMap>("FieldMetaDataMap")
67 .def(py::map_indexing_suite<LibUtilities::FieldMetaDataMap, true>());
68
69 py::class_<std::vector<GeometrySharedPtr>>("GeometryList")
70 .def(py::vector_indexing_suite<std::vector<GeometrySharedPtr>, true>());
71 py::class_<Composite, std::shared_ptr<Composite>>("Composite", py::init<>())
72 .def("__init__", py::make_constructor(&Composite_Init))
73 .def_readwrite("geometries", &Composite::m_geomVec);
74
75 py::class_<PointGeomMap>("PointGeomMap")
76 .def(py::map_indexing_suite<PointGeomMap, true>());
77 py::class_<SegGeomMap>("SegGeomMap")
78 .def(py::map_indexing_suite<SegGeomMap, true>());
79 py::class_<QuadGeomMap>("QuadGeomMap")
80 .def(py::map_indexing_suite<QuadGeomMap, true>());
81 py::class_<TriGeomMap>("TriGeomMap")
82 .def(py::map_indexing_suite<TriGeomMap, true>());
83 py::class_<TetGeomMap>("TetGeomMap")
84 .def(py::map_indexing_suite<TetGeomMap, true>());
85 py::class_<PrismGeomMap>("PrismGeomMap")
86 .def(py::map_indexing_suite<PrismGeomMap, true>());
87 py::class_<PyrGeomMap>("PyrGeomMap")
88 .def(py::map_indexing_suite<PyrGeomMap, true>());
89 py::class_<HexGeomMap>("HexGeomMap")
90 .def(py::map_indexing_suite<HexGeomMap, true>());
91 py::class_<CurveMap>("CurveMap")
92 .def(py::map_indexing_suite<CurveMap, true>());
93 py::class_<CompositeMap>("CompositeMap")
94 .def(py::map_indexing_suite<CompositeMap, true>());
95 py::class_<std::map<int, CompositeMap>>("DomainMap")
96 .def(py::map_indexing_suite<std::map<int, CompositeMap>, true>());
97
98 py::class_<MeshGraph, std::shared_ptr<MeshGraph>, boost::noncopyable>(
99 "MeshGraph", py::init<>())
100
101 .def("Empty", &MeshGraph::Empty)
102
103 .def("GetMeshDimension", &MeshGraph::GetMeshDimension)
104 .def("GetSpaceDimension", &MeshGraph::GetSpaceDimension)
105
106 .def("SetMeshDimension", &MeshGraph::SetMeshDimension)
107 .def("SetSpaceDimension", &MeshGraph::SetSpaceDimension)
108
109 .def("GetAllPointGeoms", &MeshGraph::GetAllPointGeoms,
110 py::return_internal_reference<>())
111 .def("GetAllSegGeoms", &MeshGraph::GetAllSegGeoms,
112 py::return_internal_reference<>())
113 .def("GetAllQuadGeoms", &MeshGraph::GetAllQuadGeoms,
114 py::return_internal_reference<>())
115 .def("GetAllTriGeoms", &MeshGraph::GetAllTriGeoms,
116 py::return_internal_reference<>())
117 .def("GetAllTetGeoms", &MeshGraph::GetAllTetGeoms,
118 py::return_internal_reference<>())
119 .def("GetAllPrismGeoms", &MeshGraph::GetAllPrismGeoms,
120 py::return_internal_reference<>())
121 .def("GetAllPyrGeoms", &MeshGraph::GetAllPyrGeoms,
122 py::return_internal_reference<>())
123 .def("GetAllHexGeoms", &MeshGraph::GetAllHexGeoms,
124 py::return_internal_reference<>())
125 .def("GetCurvedEdges", &MeshGraph::GetCurvedEdges,
126 py::return_internal_reference<>())
127 .def("GetCurvedFaces", &MeshGraph::GetCurvedFaces,
128 py::return_internal_reference<>())
129 .def("GetComposites", &MeshGraph::GetComposites,
130 py::return_internal_reference<>())
131 .def<std::map<int, CompositeMap> &(MeshGraph::*)()>(
132 "GetDomain", &MeshGraph::GetDomain,
133 py::return_internal_reference<>())
134
135 .def("GetMovement", &MeshGraph::GetMovement,
136 py::return_value_policy<py::return_by_value>())
137
138 .def("GetNumElements", &MeshGraph::GetNumElements)
139
140 .def("SetExpansionInfosToEvenlySpacedPoints",
141 &MeshGraph::SetExpansionInfoToEvenlySpacedPoints)
142 .def("SetExpansionInfosToPolyOrder",
143 &MeshGraph::SetExpansionInfoToNumModes)
144 .def("SetExpansionInfosToPointOrder",
145 &MeshGraph::SetExpansionInfoToPointOrder);
146}
void export_MeshGraph()
MeshGraph exports.
CompositeSharedPtr Composite_Init(py::list geometries)
Base class for a spectral/hp element mesh.
Definition: MeshGraph.h:181
std::shared_ptr< Composite > CompositeSharedPtr
Definition: MeshGraph.h:135