Lemma is an Electromagnetics API
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 22/04/19 14:06:32
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@utah.edu
  14. * @copyright Copyright (c) 2019, University of Utah
  15. * @copyright Copyright (c) 2019, Lemma Software, LLC
  16. */
  17. #include <pybind11/pybind11.h>
  18. #include <pybind11/iostream.h>
  19. #include <pybind11/eigen.h>
  20. #include "FDEM1D"
  21. namespace py = pybind11;
  22. PYBIND11_MODULE(FDEM1D, m) {
  23. py::add_ostream_redirect(m, "ostream_redirect");
  24. m.doc() = "Python binding of Lemma::FDEM1D, additional details can be found at https://lemmasoftware.org";
  25. py::class_<Lemma::WireAntenna, std::shared_ptr<Lemma::WireAntenna> > WireAntenna(m, "WireAntenna");
  26. // lifecycle
  27. WireAntenna.def(py::init(&Lemma::WireAntenna::NewSP))
  28. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::WireAntenna::DeSerialize), "Construct object from yaml representation")
  29. // print
  30. .def("Serialize", &Lemma::WireAntenna::Print, "YAML representation of the class")
  31. .def("__repr__", &Lemma::WireAntenna::Print)
  32. // modifiers
  33. .def("SetNumberOfPoints", &Lemma::WireAntenna::SetNumberOfPoints, "Sets the number of points comprising the antenna")
  34. .def("SetPoint", py::overload_cast<const int&, const Lemma::Real&, const Lemma::Real&, const Lemma::Real&>(&Lemma::WireAntenna::SetPoint), "Sets a point in the antenna")
  35. .def("SetPoint", py::overload_cast<const int&, const Lemma::Vector3r&>(&Lemma::WireAntenna::SetPoint),
  36. "Sets a point in the antenna")
  37. .def("SetNumberOfTurns", &Lemma::WireAntenna::SetNumberOfTurns, "Sets the number of turns of the antenna")
  38. .def("SetNumberOfFrequencies", &Lemma::WireAntenna::SetNumberOfFrequencies,
  39. "Sets the number of frequencies of the transmitter")
  40. .def("SetFrequency", &Lemma::WireAntenna::SetFrequency, "Sets a single frequency of the transmitter")
  41. .def("SetCurrent", &Lemma::WireAntenna::SetCurrent, "Sets the current of the transmitter in amps")
  42. // accessors
  43. .def("GetCurrent", &Lemma::WireAntenna::GetCurrent, "Returns the current of the transmitter in amps")
  44. .def("GetPoints", &Lemma::WireAntenna::GetPoints, "Returns the points defining the transmitter")
  45. .def("GetNumberOfDipoles", &Lemma::WireAntenna::GetNumberOfDipoles, "Returns the number of dipoles defining the transmitter")
  46. .def("GetNumberOfFrequencies", &Lemma::WireAntenna::GetNumberOfFrequencies,
  47. "Returns the number of frequencies for the transmitter")
  48. .def("IsHorizontallyPlanar", &Lemma::WireAntenna::IsHorizontallyPlanar, "Returns true if the transmitter is flat")
  49. .def("GetName", &Lemma::WireAntenna::GetName, "Returns the class name of the object")
  50. // operations
  51. .def("ApproximateWithElectricDipoles", &Lemma::WireAntenna::ApproximateWithElectricDipoles,
  52. "Approximates loop with electric dipoles")
  53. ;
  54. py::class_<Lemma::PolygonalWireAntenna, std::shared_ptr<Lemma::PolygonalWireAntenna> > PolygonalWireAntenna(m,
  55. "PolygonalWireAntenna", WireAntenna);
  56. // lifecycle
  57. PolygonalWireAntenna.def(py::init(&Lemma::PolygonalWireAntenna::NewSP))
  58. .def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::PolygonalWireAntenna::DeSerialize),
  59. "Construct object from yaml representation")
  60. // print
  61. .def("__repr__", &Lemma::PolygonalWireAntenna::Print)
  62. .def("Serialize", &Lemma::PolygonalWireAntenna::Print, "YAML representation of the class")
  63. // accessors
  64. .def("GetName", &Lemma::PolygonalWireAntenna::GetName, "Returns the name of the class")
  65. // operations
  66. .def("ApproximateWithElectricDipoles", &Lemma::PolygonalWireAntenna::ApproximateWithElectricDipoles,
  67. "Approximates loop with series of electric dipoles around loop")
  68. ;
  69. py::class_<Lemma::DipoleSource, std::shared_ptr<Lemma::DipoleSource> > DipoleSource(m, "DipoleSource");
  70. // lifecycle
  71. DipoleSource.def(py::init(&Lemma::DipoleSource::NewSP))
  72. //.def_static("DeSerialize", py::overload_cast<const std::string&>(&Lemma::DipoleSource::DeSerialize), "Construct object from yaml representation")
  73. // print
  74. .def("Serialize", &Lemma::DipoleSource::Print, "YAML representation of the class")
  75. .def("__repr__", &Lemma::DipoleSource::Print)
  76. ;
  77. }
  78. /*
  79. BOOST_PYTHON_MODULE(pyLemmaCore)
  80. {
  81. Py_Initialize();
  82. np::initialize();
  83. bp::class_<Lemma::PolygonalWireAntenna, boost::noncopyable> ("PolygonalWireAntenna", boost::python::no_init)
  84. // print
  85. .def(boost::python::self_ns::str(bp::self))
  86. // Lifecycle
  87. .def("__init__", boost::python::make_constructor(&Lemma::PolygonalWireAntenna::NewSP))
  88. //.def("Serialize", &Lemma::PolygonalWireAntenna::Serialize)
  89. //.def("DeSerialize", &Lemma::PolygonalWireAntenna::DeSerialize)
  90. // Accessors
  91. ;
  92. }
  93. */