shell-generator.hpp 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef SRC_SHELL_GENERATOR_H_
  2. #define SRC_SHELL_GENERATOR_H_
  3. //**********************************************************************************//
  4. // Copyright (C) 2009-2018 Ovidio Pena <ovidio@bytesfall.com> //
  5. // Copyright (C) 2013-2018 Konstantin Ladutenko <kostyfisik@gmail.com> //
  6. // //
  7. // This file is part of scattnlay //
  8. // //
  9. // This program is free software: you can redistribute it and/or modify //
  10. // it under the terms of the GNU General Public License as published by //
  11. // the Free Software Foundation, either version 3 of the License, or //
  12. // (at your option) any later version. //
  13. // //
  14. // This program is distributed in the hope that it will be useful, //
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  17. // GNU General Public License for more details. //
  18. // //
  19. // The only additional remark is that we expect that all publications //
  20. // describing work using this software, or all commercial products //
  21. // using it, cite at least one of the following references: //
  22. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  23. // a multilayered sphere," Computer Physics Communications, //
  24. // vol. 180, Nov. 2009, pp. 2348-2354. //
  25. // [2] K. Ladutenko, U. Pal, A. Rivera, and O. Pena-Rodriguez, "Mie //
  26. // calculation of electromagnetic near-field for a multilayered //
  27. // sphere," Computer Physics Communications, vol. 214, May 2017, //
  28. // pp. 225-230. //
  29. // //
  30. // You should have received a copy of the GNU General Public License //
  31. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  32. //**********************************************************************************//
  33. // @brief Generates points for integration on sphere surface
  34. #include <complex>
  35. #include <string>
  36. #include <utility>
  37. #include <vector>
  38. namespace shell_generator {
  39. class ShellGenerator { // will throw for any error
  40. public:
  41. /* ShellGenerator& ReadFromFile(std::string filename); */
  42. /* ShellGenerator& ResizeToComplex(double from_wl, double to_wl, int samples); */
  43. /* ShellGenerator& ToIndex(); */
  44. double dist(std::vector<double> a, std::vector<double> b);
  45. double norm(std::vector<double> a);
  46. std::vector< std::vector<double> > GetVertices(){return vertices_;};
  47. std::vector< std::vector<double> > GetVerticesT();
  48. std::vector< std::vector<double> > GetFaceCentersT();
  49. std::vector< std::vector<long unsigned int> > GetEdges(){return edges_;};
  50. std::vector< std::vector<long unsigned int> > GetFaces(){return faces_;};
  51. void EvalEdgeLength();
  52. void EvalFaces();
  53. void GenerateEdgesInit();
  54. void GenerateFacesInit();
  55. void Init();
  56. std::vector<double> Integrate();
  57. std::vector<double> IntegrateByFaces();
  58. std::vector<double> IntegrateByComp();
  59. double IntegrateGauss(double charge, double dist);
  60. double IntegrateGaussSimple(double charge, double dist);
  61. void PrintVerts();
  62. void Refine();
  63. void Rescale(double scale);
  64. void RotateX(double angle);
  65. void RotateY(double angle);
  66. void RotateZ(double angle);
  67. void MoveX(double delta_x);
  68. void MoveY(double delta_y);
  69. void MoveZ(double delta_z);
  70. void SetField(std::vector<std::vector< std::complex<double> > > &E,
  71. std::vector<std::vector< std::complex<double> > > &H) {E_ = E; H_=H;};
  72. void SetFieldSph(std::vector<std::vector< std::complex<double> > > &E,
  73. std::vector<std::vector< std::complex<double> > > &H) {Es_ = E; Hs_=H;};
  74. void SetInitialVerticesIcosahedron();
  75. void SetInitialVerticesTetrahedron();
  76. private:
  77. std::vector<std::vector< std::complex<double> > > E_, H_, Es_, Hs_;
  78. double edge_length_ = 0.0;
  79. double face_area_ = 0.0;
  80. std::vector<double> per_face_area_;
  81. double per_vertice_area_ = 0.0;
  82. std::vector< std::vector<double> > vertices_, face_centers_;
  83. std::vector< double > face_surface_;
  84. std::vector< std::vector<long unsigned int> > edges_, refined_edges_;
  85. std::vector< std::vector<long unsigned int> > faces_, refined_faces_;
  86. // std::vector< std::pair< double, std::complex<double> > > data_complex_;
  87. // std::vector< std::pair< double, std::complex<double> > > data_complex_index_;
  88. // void PermittivityToIndex();
  89. }; // end of class ShellGenerator
  90. } // end of namespase read_spectra
  91. #endif // SRC_SHELL_GENERATOR_H_