Nektar++
Python/StdMatrixKey.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: StdMatrixKey.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 StdMatrixKey.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #include <vector>
39 
40 #include <boost/python/suite/indexing/map_indexing_suite.hpp>
41 
42 using namespace Nektar;
43 using namespace Nektar::StdRegions;
44 
46  const LibUtilities::ShapeType shapeType,
47  const StdExpansionSharedPtr exp,
48  const py::object &constFactorMap,
49  const py::object &varCoeffMap)
50 {
53 
54  if (!constFactorMap.is_none())
55  {
56  tmp = py::extract<ConstFactorMap>(constFactorMap);
57  }
58 
59  if (!varCoeffMap.is_none())
60  {
61  tmp2 = py::extract<VarCoeffMap>(varCoeffMap);
62  }
63 
64  return new StdMatrixKey(matType, shapeType, *exp, tmp, tmp2);
65 }
66 
67 /**
68  * @brief Export for StdMatrixKey enumeration.
69  */
71 {
75 
76  // Wrapper for constant factor map.
77  py::class_<ConstFactorMap>("ConstFactorMap")
78  .def(py::map_indexing_suite<ConstFactorMap>());
79 
80  // Wrapper for variable coefficients map.
81  py::class_<VarCoeffMap>("VarCoeffMap")
82  .def(py::map_indexing_suite<VarCoeffMap>());
83 
84  py::class_<StdMatrixKey>("StdMatrixKey", py::no_init)
85  .def("__init__", py::make_constructor(
86  &StdMatrixKey_Init, py::default_call_policies(),
87  (py::arg("matType"), py::arg("shapeType"), py::arg("exp"),
88  py::arg("constFactorMap") = py::object(),
89  py::arg("varCoeffMap") = py::object())))
90 
91  .def("GetMatrixType", &StdMatrixKey::GetMatrixType)
92  .def("GetShapeType", &StdMatrixKey::GetShapeType)
93  .def("GetNcoeffs", &StdMatrixKey::GetNcoeffs)
94  .def("GetBasis", &StdMatrixKey::GetBasis)
95  ;
96 }
#define NEKPY_WRAP_ENUM(ENUMNAME, MAPNAME)
Definition: NekPyConfig.hpp:66
StdMatrixKey * StdMatrixKey_Init(const MatrixType matType, const LibUtilities::ShapeType shapeType, const StdExpansionSharedPtr exp, const py::object &constFactorMap, const py::object &varCoeffMap)
void export_StdMatrixKey()
Export for StdMatrixKey enumeration.
LibUtilities::ShapeType GetShapeType() const
Definition: StdMatrixKey.h:86
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:81
const LibUtilities::BasisSharedPtr GetBasis(int dir) const
Definition: StdMatrixKey.h:111
The namespace associated with the the StdRegions library (StdRegions introduction)
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:272
const char *const VarCoeffTypeMap[]
Definition: StdRegions.hpp:240
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:296
const char *const MatrixTypeMap[]
Definition: StdRegions.hpp:153
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:314
static ConstFactorMap NullConstFactorMap
Definition: StdRegions.hpp:315
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:273
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1