From b07fdabdd054b378a45ad3b300e3e1c6d2c21541 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Mon, 29 Apr 2024 13:09:07 +0200 Subject: [PATCH] Replace get_param configuration functions with read-only parameter views --- src/cluster/cluster.cpp | 64 ++-- src/include/Configuration.h | 230 +++++++------ src/libnptm/Commons.cpp | 50 +-- src/libnptm/Configuration.cpp | 623 ++++++++++++++++------------------ src/sphere/sphere.cpp | 50 +-- src/trapping/cfrfme.cpp | 12 +- 6 files changed, 512 insertions(+), 517 deletions(-) diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp index 7b0e4a08..1654fc2f 100644 --- a/src/cluster/cluster.cpp +++ b/src/cluster/cluster.cpp @@ -93,12 +93,12 @@ void cluster(const string& config_file, const string& data_file, const string& o exit(1); } logger->log(" done.\n", LOG_INFO); - int s_nsph = sconf->get_param("nsph"); - int nsph = gconf->get_param("nsph"); + int s_nsph = sconf->number_of_spheres; + int nsph = gconf->number_of_spheres; if (s_nsph == nsph) { // Shortcuts to variables stored in configuration objects ScatteringAngles *p_scattering_angles = new ScatteringAngles(gconf); - double wp = sconf->get_param("wp"); + double wp = sconf->wp; // Global variables for CLU C1 *c1 = new C1(gconf, sconf); C3 *c3 = new C3(); @@ -115,7 +115,7 @@ void cluster(const string& config_file, const string& data_file, const string& o logger->log("INFO: Size of matrices to invert: " + to_string((int64_t)ndit) + " x " + to_string((int64_t)ndit) +".\n"); time_logger->log("INFO: Size of matrices to invert: " + to_string((int64_t)ndit) + " x " + to_string((int64_t)ndit) +".\n"); C9 *c9 = new C9(ndi, c4->nlem, 2 * ndi, 2 * c4->nlem); - double *gaps = new double[(int)gconf->get_param("nsph")](); + double *gaps = new double[gconf->number_of_spheres](); double *tqev = new double[3](); double *tqsv = new double[3](); double **tqse, **tqss, **tqce, **tqcs; @@ -129,10 +129,10 @@ void cluster(const string& config_file, const string& data_file, const string& o tqcs = new double*[2]; tqcps = new dcomplex*[2]; for (int ti = 0; ti < 2; ti++) { - tqse[ti] = new double[(int)gconf->get_param("nsph")](); - tqspe[ti] = new dcomplex[(int)gconf->get_param("nsph")](); - tqss[ti] = new double[(int)gconf->get_param("nsph")](); - tqsps[ti] = new dcomplex[(int)gconf->get_param("nsph")](); + tqse[ti] = new double[gconf->number_of_spheres](); + tqspe[ti] = new dcomplex[gconf->number_of_spheres](); + tqss[ti] = new double[gconf->number_of_spheres](); + tqsps[ti] = new dcomplex[gconf->number_of_spheres](); tqce[ti] = new double[3](); tqcpe[ti] = new dcomplex[3](); tqcs[ti] = new double[3](); @@ -180,10 +180,8 @@ void cluster(const string& config_file, const string& data_file, const string& o // End of global variables for CLU fprintf(output, " READ(IR,*)NSPH,LI,LE,MXNDM,INPOL,NPNT,NPNTTS,IAVM,ISAM\n"); fprintf(output, " %5d%5d%5d%5ld%5d%5d%5d%5d%5d\n", - nsph, c4->li, c4->le, (np_int)gconf->get_param("mxndm"), - (int)gconf->get_param("in_pol"), (int)gconf->get_param("npnt"), - (int)gconf->get_param("npntts"), (int)gconf->get_param("iavm"), - (int)gconf->get_param("meridional_type") + nsph, c4->li, c4->le, gconf->mxndm, gconf->in_pol, gconf->npnt, + gconf->npntts, gconf->iavm, gconf->iavm ); fprintf(output, " READ(IR,*)RXX(I),RYY(I),RZZ(I)\n"); for (int ri = 0; ri < nsph; ri++) fprintf(output, "%17.8lE%17.8lE%17.8lE\n", @@ -204,7 +202,7 @@ void cluster(const string& config_file, const string& data_file, const string& o p_scattering_angles->phsstp, p_scattering_angles->phslst ); fprintf(output, " READ(IR,*)JWTM\n"); - fprintf(output, " %5d\n", (int)gconf->get_param("jwtm")); + fprintf(output, " %5d\n", gconf->jwtm); fprintf(output, " READ(ITIN)NSPHT\n"); fprintf(output, " READ(ITIN)(IOG(I),I=1,NSPH)\n"); fprintf(output, " READ(ITIN)EXDC,WP,XIP,IDFC,NXI\n"); @@ -224,7 +222,7 @@ void cluster(const string& config_file, const string& data_file, const string& o } } thdps(c4->lm, zpv); - double exdc = sconf->get_param("exdc"); + double exdc = sconf->exdc; double exri = sqrt(exdc); double vk = 0.0; fprintf(output, " REFR. INDEX OF EXTERNAL MEDIUM=%15.7lE\n", exri); @@ -238,10 +236,10 @@ void cluster(const string& config_file, const string& data_file, const string& o #else logger->log("INFO: using fall-back lucin() calls.\n", LOG_INFO); #endif - int iavm = (int)gconf->get_param("iavm"); - int isam = (int)gconf->get_param("meridional_type"); - int inpol = (int)gconf->get_param("in_pol"); - int nxi = (int)sconf->get_param("nxi"); + int iavm = gconf->iavm; + int isam = gconf->isam; + int inpol = gconf->in_pol; + int nxi = sconf->number_of_scales; int nth = p_scattering_angles->nth; int nths = p_scattering_angles->nths; int nph = p_scattering_angles->nph; @@ -255,9 +253,9 @@ void cluster(const string& config_file, const string& data_file, const string& o tppoan.write(reinterpret_cast<char *>(&nths), sizeof(int)); tppoan.write(reinterpret_cast<char *>(&nphs), sizeof(int)); double wn = wp / 3.0e8; - double xip = sconf->get_param("xip"); + double xip = sconf->xip; double sqsfi = 1.0; - if (sconf->get_param("idfc") < 0.0) { + if (sconf->idfc < 0) { vk = xip * wn; fprintf(output, " VK=%15.7lE, XI IS SCALE FACTOR FOR LENGTHS\n", vk); fprintf(output, " \n"); @@ -737,32 +735,32 @@ void cluster(const string& config_file, const string& data_file, const string& o int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConfiguration *gconf, ScatteringAngles *sa, C1 *c1, C1_AddOns *c1ao, C2 *c2, C3 *c3, C4 *c4, C6 *c6, C9 *c9, FILE *output, string output_path, double *gaps, double **tqse, dcomplex **tqspe, double **tqss, dcomplex **tqsps, double ****zpv, double **gapm, dcomplex **gappm, double *argi, double *args, double **gap, dcomplex **gapp, double **tqce, dcomplex **tqcpe, double **tqcs, dcomplex **tqcps, double *duk, fstream &tppoan, double **cextlr, double **cext, double **cmullr, double **cmul, double *gapv, double *tqev, double *tqsv, double *u, double *us, double *un, double *uns, double *up, double *ups, double *unmp, double *unsmp, double *upmp, double *upsmp, double &scan, double &cfmp, double &sfmp, double &cfsp, double &sfsp, double sqsfi, dcomplex arg, double wn, double vk, Logger *logger) { - int nxi = (int)sconf->get_param("nxi"); + int nxi = sconf->number_of_scales; logger->log("INFO: running scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n"); int jer = 0; int lcalc = 0; int jaw = 1; - int li = (int)gconf->get_param("li"); - int le = (int)gconf->get_param("le"); + int li = gconf->li; + int le = gconf->le; int lm = 0; if (le > lm) lm = le; if (li > lm) lm = li; - int nsph = gconf->get_param("nsph"); - int mxndm = gconf->get_param("mxndm"); - int iavm = gconf->get_param("iavm"); - int inpol = gconf->get_param("in_pol"); - int npnt = gconf->get_param("npnt"); - int npntts = gconf->get_param("npntts"); - int isam = gconf->get_param("meridional_type"); - int jwtm = (int)gconf->get_param("jwtm"); + int nsph = gconf->number_of_spheres; + np_int mxndm = gconf->mxndm; + int iavm = gconf->iavm; + int inpol = gconf->in_pol; + int npnt = gconf->npnt; + int npntts = gconf->npntts; + int isam = gconf->iavm; + int jwtm = gconf->jwtm; np_int ndit = 2 * nsph * c4->nlim; int isq, ibf; fprintf(output, "========== JXI =%3d ====================\n", jxi488); double xi = sconf->get_scale(jxi488 - 1); - double exdc = sconf->get_param("exdc"); + double exdc = sconf->exdc; double exri = sqrt(exdc); - int idfc = (int)sconf->get_param("idfc"); + int idfc = (int)sconf->idfc; double vkarg = 0.0; if (idfc >= 0) { vk = xi * wn; diff --git a/src/include/Configuration.h b/src/include/Configuration.h index b90c0a93..1c131e92 100644 --- a/src/include/Configuration.h +++ b/src/include/Configuration.h @@ -42,59 +42,114 @@ class GeometryConfiguration { protected: //! \brief Number of spherical components. - int number_of_spheres; + int _number_of_spheres; //! \brief Maximum field expansion order. - int l_max; + int _l_max; //! \brief Maximum internal field expansion order. - int li; + int _li; //! \brief Maximum external field expansion order. - int le; + int _le; //! \brief Maximum dimension of allocated matrix allowance (deprecated). - int mxndm; + np_int _mxndm; //! \brief QUESTION: definition? - int iavm; + int _iavm; //! \brief Incident field polarization status (0 - linear, 1 - circular). - int in_pol; + int _in_pol; //! \brief Number of transition points. QUESTION: correct? - int npnt; + int _npnt; //! \brief Transition smoothness. QUESTION: correct? - int npntts; + int _npntts; //! \brief Type of meridional plane definition. - int meridional_type; + int _isam; //! \brief Transition matrix layer ID. QUESTION: correct? - int jwtm; + int _jwtm; //! \brief Incident field initial azimuth. - double in_theta_start; + double _in_theta_start; //! \brief Incident field azimuth step. - double in_theta_step; + double _in_theta_step; //! \brief Incident field final azimuth. - double in_theta_end; + double _in_theta_end; //! \brief Scattered field initial azimuth. - double sc_theta_start; + double _sc_theta_start; //! \brief Scattered field azimuth step. - double sc_theta_step; + double _sc_theta_step; //! \brief Scattered field final azimuth. - double sc_theta_end; + double _sc_theta_end; //! \brief Incident field initial elevation. - double in_phi_start; + double _in_phi_start; //! \brief Incident field elevation step. - double in_phi_step; + double _in_phi_step; //! \brief Incident field final elevation. - double in_phi_end; + double _in_phi_end; //! \brief Scattered field initial elevation. - double sc_phi_start; + double _sc_phi_start; //! \brief Scattered field elevation step. - double sc_phi_step; + double _sc_phi_step; //! \brief Scattered field final elevation. - double sc_phi_end; + double _sc_phi_end; //! \brief Vector of spherical components X coordinates. - double *sph_x; + double *_sph_x; //! \brief Vector of spherical components Y coordinates. - double *sph_y; + double *_sph_y; //! \brief Vector of spherical components Z coordinates. - double *sph_z; + double *_sph_z; public: + //! \brief Read only view on number of spherical components. + const int& number_of_spheres = _number_of_spheres; + //! \brief Read only view on maximum field expansion order. + const int& l_max = _l_max; + //! \brief Read only view on maximum internal field expansion order. + const int& li = _li; + //! \brief Read only view on maximum external field expansion order. + const int& le = _le; + //! \brief Read only view on maximum dimension of allocated matrix allowance (deprecated). + const np_int& mxndm = _mxndm; + //! \brief QUESTION: definition? + const int& iavm = _iavm; + //! \brief Read only view on incident field polarization status (0 - linear, 1 - circular). + const int& in_pol = _in_pol; + //! \brief Read only view on number of transition points. QUESTION: correct? + const int& npnt = _npnt; + //! \brief Read only view on transition smoothness. QUESTION: correct? + const int& npntts = _npntts; + //! \brief Read only view on type of meridional plane definition. + const int& isam = _isam; + //! \brief Read only view on transition matrix layer ID. QUESTION: correct? + const int& jwtm = _jwtm; + //! \brief Read only view on incident field initial azimuth. + const double& in_theta_start = _in_theta_start; + //! \brief Read only view on incident field azimuth step. + const double& in_theta_step = _in_theta_step; + //! \brief Read only view on incident field final azimuth. + const double& in_theta_end = _in_theta_end; + //! \brief Read only view on scattered field initial azimuth. + const double& sc_theta_start = _sc_theta_start; + //! \brief Read only view on scattered field azimuth step. + const double& sc_theta_step = _sc_theta_step; + //! \brief Read only view on scattered field final azimuth. + const double& sc_theta_end = _sc_theta_end; + //! \brief Read only view on incident field initial elevation. + const double& in_phi_start = _in_phi_start; + //! \brief Read only view on incident field elevation step. + const double& in_phi_step = _in_phi_step; + //! \brief Read only view on incident field final elevation. + const double& in_phi_end = _in_phi_end; + //! \brief Read only view on scattered field initial elevation. + const double& sc_phi_start = _sc_phi_start; + //! \brief Read only view on scattered field elevation step. + const double& sc_phi_step = _sc_phi_step; + //! \brief Read only view on scattered field final elevation. + const double& sc_phi_end = _sc_phi_end; + /* + //! \brief Read only view on vector of spherical components X coordinates. + const double *sph_x = _sph_x; + //! \brief Read only view on vector of spherical components Y coordinates. + const double *sph_y = _sph_y; + //! \brief Read only view on vector of spherical components Z coordinates. + const double *sph_z = _sph_z; + */ + /*! \brief Build a scattering geometry configuration structure. * * \param nsph: `int` Number of spheres to be used in calculation. @@ -129,7 +184,7 @@ public: */ GeometryConfiguration( int nsph, int lm, int in_pol, int npnt, int npntts, int meridional_type, - int li, int le, int mxndm, int iavm, + int li, int le, np_int mxndm, int iavm, double *x, double *y, double *z, double in_th_start, double in_th_step, double in_th_end, double sc_th_start, double sc_th_step, double sc_th_end, @@ -137,6 +192,7 @@ public: double sc_ph_start, double sc_ph_step, double sc_ph_end, int jwtm ); + /*! \brief Build a scattering geometry configuration structure copying it from an existing one. * * \param rhs: `GeometryConfiguration` preexisting object to copy from. @@ -159,20 +215,6 @@ public: * configuration data. */ static GeometryConfiguration *from_legacy(const std::string& file_name); - - /*! \brief Get the value of a parameter by name. - * - * The proper way to access read-only parameters from outside a class is to define - * public methods that return their values. For configuration operations, whose - * optimization is not critical, it is possible to define a single function that - * returns simple scalar values called by name. Access to more complicated data - * structures, on the other hand, require specialized methods which avoid the - * burden of searching the necessary value across the whole array every time. - * - * \param param_name: `string` Name of the parameter to be retrieved. - * \return value: `double` Value of the requested parameter. - */ - double get_param(const std::string& param_name); /*! \brief Get the X coordinate of a sphere by its index. * @@ -182,7 +224,7 @@ public: * \param index: `int` Index of the scale to be retrieved. * \return scale: `double` The X coordinate of the requested sphere. */ - double get_sph_x(int index) { return sph_x[index]; } + double get_sph_x(int index) { return _sph_x[index]; } /*! \brief Get the Y coordinate of a sphere by its index. * @@ -192,7 +234,7 @@ public: * \param index: `int` Index of the scale to be retrieved. * \return scale: `double` The Y coordinate of the requested sphere. */ - double get_sph_y(int index) { return sph_y[index]; } + double get_sph_y(int index) { return _sph_y[index]; } /*! \brief Get the Z coordinate of a sphere by its index. * @@ -202,7 +244,7 @@ public: * \param index: `int` Index of the scale to be retrieved. * \return scale: `double` The Z coordinate of the requested sphere. */ - double get_sph_z(int index) { return sph_z[index]; } + double get_sph_z(int index) { return _sph_z[index]; } }; /** @@ -215,35 +257,35 @@ class ScattererConfiguration { protected: //! \brief Matrix of dielectric parameters with size [NON_TRANS_LAYERS x N_SPHERES x N_SCALES]. - dcomplex ***dc0_matrix; + dcomplex ***_dc0_matrix; //! \brief Vector of sphere radii expressed in m, with size [N_SPHERES]. - double *radii_of_spheres; + double *_radii_of_spheres; //! \brief Matrix of fractional transition radii with size [N_SPHERES x LAYERS]. - double **rcf; + double **_rcf; //! \brief Vector of sphere ID numbers, with size [N_SPHERES]. - int *iog_vec; + int *_iog_vec; //! \brief Vector of layer numbers for every sphere, with size [N_SPHERES]. - int *nshl_vec; + int *_nshl_vec; //! \brief Vector of scale parameters, with size [N_SCALES]. - double *scale_vec; + double *_scale_vec; //! \brief Name of the reference variable type (one of XIV, WNS, WLS, PUS, EVS). - std::string reference_variable_name; + std::string _reference_variable_name; //! \brief Number of spherical components. - int number_of_spheres; + int _number_of_spheres; //! \brief Number of configurations. - int configurations; + int _configurations; //! \brief Number of scales to use in calculation. - int number_of_scales; + int _number_of_scales; //! \brief Type of dielectric functions (<0 at XIP, =0 as function of XI, >0 constants). - int idfc; + int _idfc; //! \brief External medium dielectric constant. QUESTION: correct? - double exdc; + double _exdc; //! \brief WP. QUESTION: better definition? - double wp; + double _wp; //! \brief Peak XI. QUESTION: correct? - double xip; + double _xip; //! \brief Flag to control whether to add an external layer. - bool use_external_sphere; + bool _use_external_sphere; /*! \brief Build configuration from a HDF5 binary input file. * @@ -291,6 +333,25 @@ protected: */ void write_legacy(const std::string& file_name); public: + //! \brief Read only view on name of the reference variable type. + const std::string& reference_variable_name = _reference_variable_name; + //! \brief Read only view on number of spherical components. + const int& number_of_spheres = _number_of_spheres; + //! \brief Read only view on number of configurations. + const int& configurations = _configurations; + //! \brief Read only view on number of scales to use in calculation. + const int& number_of_scales = _number_of_scales; + //! \brief Read only view on type of dielectric functions. + const int& idfc = _idfc; + //! \brief Read only view on external medium dielectric constant. + const double& exdc = _exdc; + //! \brief Read only view on WP. + const double& wp = _wp; + //! \brief Read only view on peak XI. + const double& xip = _xip; + //! \brief Read only view on flag to control whether to add an external layer. + const bool& use_external_sphere = _use_external_sphere; + /*! \brief Build a scatterer configuration structure. * * Prepare a default configuration structure by allocating the necessary @@ -330,29 +391,16 @@ public: double wp, double xip ); + /*! \brief Build a scatterer configuration structure copying its contents from a preexisting one. * * Prepare a default configuration structure by allocating the necessary * memory structures. * - * \param nsph: `int` The number of spheres in the simulation. - * \param scale_vector: `double*` The radiation-particle scale vector. - * \param nxi: `int` The number of radiation-particle scalings. - * \param variable_name: `string` The name of the radiation-particle scaling type. - * \param iog_vector: `int*` Array of sphere identification numbers. QUESTION: correct? - * \param ros_vector: `double*` Sphere radius array. - * \param nshl_vector: `int*` Array of layer numbers. - * \param rcf_vector: `double**` Array of fractional break radii. QUESTION: correct? - * \param dielectric_func_type: `int` Type of dielectric function definition (=0 for constant, - * \>0 as function of scale parameter, <0 for functions at XIP value and XI is scale factor - * for dimensions). - * \param dc_matrix: `complex double ***` Matrix of reference dielectric constants. - * \param has_external: `bool` Flag to set whether to add an external spherical layer. - * \param exdc: `double` External medium dielectric constant. - * \param wp: `double` wp - * \param xip: `double` xip + * \param rhs: `ScattererConfiguration&` Reference to the ScattereConfiguration + * object to be copied. */ - ScattererConfiguration(const ScattererConfiguration& rhs); + ScattererConfiguration(const ScattererConfiguration& rhs); /*! \brief Destroy a scatterer configuration instance. */ @@ -399,7 +447,7 @@ public: * \param k: `int` Index of the current scale. * \return radius: `dcomplex` The requested dielectric constant. */ - dcomplex get_dielectric_constant(int i, int j, int k) { return dc0_matrix[i][j][k]; } + dcomplex get_dielectric_constant(int i, int j, int k) { return _dc0_matrix[i][j][k]; } /*! \brief Get the ID of a configuration from the index of the sphere. * @@ -409,7 +457,7 @@ public: * \param index: `int` Index of the sphere. * \return ID: `int` ID of the configuration to be applied. */ - int get_iog(int index) { return iog_vec[index]; } + int get_iog(int index) { return _iog_vec[index]; } /*! \brief Get the number of layers for a given configuration. * @@ -419,8 +467,9 @@ public: * \param index: `int` Index of the configuration. * \return nl: `int` The number of layers for the given configuration. */ - int get_nshl(int index) { return nshl_vec[index]; } - + int get_nshl(int index) { return _nshl_vec[index]; } + + /* /*! \brief Get the value of a parameter by name. * * The proper way to access read-only parameters from outside a class is to define @@ -432,8 +481,9 @@ public: * * \param param_name: `string` Name of the parameter to be retrieved. * \return value: `double` Value of the requested parameter. - */ + double get_param(const std::string& param_name); + */ /*! \brief Get the radius of a sphere by its index. * @@ -443,7 +493,7 @@ public: * \param index: `int` Index of the ID to be retrieved. * \return radius: `double` The requested sphere radius. */ - double get_radius(int index) { return radii_of_spheres[index]; } + double get_radius(int index) { return _radii_of_spheres[index]; } /*! \brief Get the value of a scale by its index. * @@ -453,18 +503,8 @@ public: * \param index: `int` Index of the scale to be retrieved. * \return scale: `double` The desired scale. */ - double get_rcf(int row, int column) { return rcf[row][column]; } - - /*! \brief Get the reference variable name. - * - * This is a specialized function to get the name of the reference variable as a - * string. - * - * \return name: `string` The name of the variable used to calculate wavelength / - * size scaling. - */ - std::string get_reference() { return reference_variable_name; } - + double get_rcf(int row, int column) { return _rcf[row][column]; } + /*! \brief Get the value of a scale by its index. * * This is a specialized function to access a scale (generally a wavelength), @@ -473,7 +513,7 @@ public: * \param index: `int` Index of the scale to be retrieved. * \return scale: `double` The desired scale. */ - double get_scale(int index) { return scale_vec[index]; } + double get_scale(int index) { return _scale_vec[index]; } /*! \brief Print the contents of the configuration object to terminal. * diff --git a/src/libnptm/Commons.cpp b/src/libnptm/Commons.cpp index df0bbee9..b3ee9bdd 100644 --- a/src/libnptm/Commons.cpp +++ b/src/libnptm/Commons.cpp @@ -17,13 +17,13 @@ #endif C1::C1(GeometryConfiguration *gconf, ScattererConfiguration *sconf) { - lm = (int)gconf->get_param("l_max"); - int li = (int)gconf->get_param("li"); - int le = (int)gconf->get_param("le"); + lm = gconf->l_max; + int li = gconf->li; + int le = gconf->le; if (lm == 0) { lm = (li > le) ? li : le; } - nsph = (int)gconf->get_param("nsph"); + nsph = gconf->number_of_spheres; nlmmt = 2 * (lm * (lm + 2)); vec_rmi = new dcomplex[nsph * lm](); @@ -37,7 +37,7 @@ C1::C1(GeometryConfiguration *gconf, ScattererConfiguration *sconf) { vec_w = new dcomplex[4 * nlmmt](); w = new dcomplex*[nlmmt]; for (int wi = 0; wi < nlmmt; wi++) w[wi] = &(vec_w[4 * wi]); - configurations = (int)sconf->get_param("configurations"); + configurations = sconf->configurations; vint = new dcomplex[16](); vec_vints = new dcomplex[nsph * 16](); vints = new dcomplex*[nsph]; @@ -359,12 +359,12 @@ C1_AddOns::~C1_AddOns() { } C2::C2(GeometryConfiguration *gconf, ScattererConfiguration *sconf) { - nsph = (int)gconf->get_param("nsph"); - int npnt = (int)gconf->get_param("npnt"); - int npntts = (int)gconf->get_param("npntts"); + nsph = gconf->number_of_spheres; + int npnt = gconf->npnt; + int npntts = gconf->npntts; int max_n = (npnt > npntts) ? npnt : npntts; nhspo = 2 * max_n - 1; - nl = (int)sconf->get_param("configurations"); + nl = sconf->configurations; if (nsph == 1 && nl == 1) nl = 5; ris = new dcomplex[nhspo](); dlri = new dcomplex[nhspo](); @@ -432,11 +432,11 @@ C3::~C3() { } C4::C4(GeometryConfiguration *gconf) { - li = (int)gconf->get_param("li"); - le = (int)gconf->get_param("le"); + li = gconf->li; + le = gconf->le; lm = (li > le) ? li : le; nv3j = (lm * (lm + 1) * (2 * lm + 7)) / 6; - nsph = (int)gconf->get_param("nsph"); + nsph = gconf->number_of_spheres; // The following is needed to initialize C1_AddOns litpo = li + li + 1; litpos = litpo * litpo; @@ -530,19 +530,19 @@ C9::~C9() { } ScatteringAngles::ScatteringAngles(GeometryConfiguration *gconf) { - int isam = (int)gconf->get_param("meridional_type"); - _th = gconf->get_param("in_theta_start"); - _thstp = gconf->get_param("in_theta_step"); - _thlst = gconf->get_param("in_theta_end"); - _ths = gconf->get_param("sc_theta_start"); - _thsstp = gconf->get_param("sc_theta_step"); - _thslst = gconf->get_param("sc_theta_end"); - _ph = gconf->get_param("in_phi_start"); - _phstp = gconf->get_param("in_phi_step"); - _phlst = gconf->get_param("in_phi_end"); - _phs = gconf->get_param("sc_phi_start"); - _phsstp = gconf->get_param("sc_phi_step"); - _phslst = gconf->get_param("sc_phi_end"); + int isam = gconf->isam; + _th = gconf->in_theta_start; + _thstp = gconf->in_theta_step; + _thlst = gconf->in_theta_end; + _ths = gconf->sc_theta_start; + _thsstp = gconf->sc_theta_step; + _thslst = gconf->sc_theta_end; + _ph = gconf->in_phi_start; + _phstp = gconf->in_phi_step; + _phlst = gconf->in_phi_end; + _phs = gconf->sc_phi_start; + _phsstp = gconf->sc_phi_step; + _phslst = gconf->sc_phi_end; double small = 1.0e-3; _nth = 0; _nph = 0; diff --git a/src/libnptm/Configuration.cpp b/src/libnptm/Configuration.cpp index 23e38885..704d4eca 100644 --- a/src/libnptm/Configuration.cpp +++ b/src/libnptm/Configuration.cpp @@ -40,82 +40,82 @@ using namespace std; GeometryConfiguration::GeometryConfiguration( - int _nsph, int _lm, int _in_pol, int _npnt, int _npntts, int _isam, - int _li, int _le, int _mxndm, int _iavm, + int nsph, int lm, int in_pol, int npnt, int npntts, int isam, + int li, int le, np_int mxndm, int iavm, double *x, double *y, double *z, double in_th_start, double in_th_step, double in_th_end, double sc_th_start, double sc_th_step, double sc_th_end, double in_ph_start, double in_ph_step, double in_ph_end, double sc_ph_start, double sc_ph_step, double sc_ph_end, - int _jwtm + int jwtm ) { - number_of_spheres = _nsph; - l_max = _lm; - in_pol = _in_pol; - npnt = _npnt; - npntts = _npntts; - meridional_type = _isam; - li = _li; - le = _le; - mxndm = _mxndm; - iavm = _iavm; - in_theta_start = in_th_start; - in_theta_step = in_th_step; - in_theta_end = in_th_end; - in_phi_start = in_ph_start; - in_phi_step = in_ph_step; - in_phi_end = in_ph_end; - sc_theta_start = sc_th_start; - sc_theta_step = sc_th_step; - sc_theta_end = sc_th_end; - sc_phi_start = sc_ph_start; - sc_phi_step = sc_ph_step; - sc_phi_end = sc_ph_end; - jwtm = _jwtm; - sph_x = x; - sph_y = y; - sph_z = z; + _number_of_spheres = nsph; + _l_max = lm; + _in_pol = in_pol; + _npnt = npnt; + _npntts = npntts; + _isam = isam; + _li = li; + _le = le; + _mxndm = mxndm; + _iavm = iavm; + _in_theta_start = in_th_start; + _in_theta_step = in_th_step; + _in_theta_end = in_th_end; + _in_phi_start = in_ph_start; + _in_phi_step = in_ph_step; + _in_phi_end = in_ph_end; + _sc_theta_start = sc_th_start; + _sc_theta_step = sc_th_step; + _sc_theta_end = sc_th_end; + _sc_phi_start = sc_ph_start; + _sc_phi_step = sc_ph_step; + _sc_phi_end = sc_ph_end; + _jwtm = jwtm; + _sph_x = x; + _sph_y = y; + _sph_z = z; } GeometryConfiguration::GeometryConfiguration(const GeometryConfiguration& rhs) { - number_of_spheres = rhs.number_of_spheres; - l_max = rhs.l_max; - in_pol = rhs.in_pol; - npnt = rhs.npnt; - npntts = rhs.npntts; - meridional_type = rhs.meridional_type; - li = rhs.li; - le = rhs.le; - mxndm = rhs.mxndm; - iavm = rhs.iavm; - in_theta_start = rhs.in_theta_start; - in_theta_step = rhs.in_theta_step; - in_theta_end = rhs.in_theta_end; - in_phi_start = rhs.in_phi_start; - in_phi_step = rhs.in_phi_step ; - in_phi_end = rhs.in_phi_end; - sc_theta_start = rhs.sc_theta_start; - sc_theta_step = rhs.sc_theta_step; - sc_theta_end = rhs.sc_theta_end; - sc_phi_start = rhs.sc_phi_start; - sc_phi_step = rhs.sc_phi_step; - sc_phi_end = rhs.sc_phi_end; - jwtm = rhs.jwtm; - sph_x = new double[number_of_spheres](); - sph_y = new double[number_of_spheres](); - sph_z = new double[number_of_spheres](); - for (int ni=0; ni<number_of_spheres; ni++) { - sph_x[ni] = rhs.sph_x[ni]; - sph_y[ni] = rhs.sph_y[ni]; - sph_z[ni] = rhs.sph_z[ni]; + _number_of_spheres = rhs._number_of_spheres; + _l_max = rhs._l_max; + _in_pol = rhs._in_pol; + _npnt = rhs._npnt; + _npntts = rhs._npntts; + _isam = rhs._isam; + _li = rhs._li; + _le = rhs._le; + _mxndm = rhs._mxndm; + _iavm = rhs._iavm; + _in_theta_start = rhs._in_theta_start; + _in_theta_step = rhs._in_theta_step; + _in_theta_end = rhs._in_theta_end; + _in_phi_start = rhs._in_phi_start; + _in_phi_step = rhs._in_phi_step; + _in_phi_end = rhs._in_phi_end; + _sc_theta_start = rhs._sc_theta_start; + _sc_theta_step = rhs._sc_theta_step; + _sc_theta_end = rhs._sc_theta_end; + _sc_phi_start = rhs._sc_phi_start; + _sc_phi_step = rhs._sc_phi_step; + _sc_phi_end = rhs._sc_phi_end; + _jwtm = rhs._jwtm; + _sph_x = new double[_number_of_spheres](); + _sph_y = new double[_number_of_spheres](); + _sph_z = new double[_number_of_spheres](); + for (int ni=0; ni < _number_of_spheres; ni++) { + _sph_x[ni] = rhs._sph_x[ni]; + _sph_y[ni] = rhs._sph_y[ni]; + _sph_z[ni] = rhs._sph_z[ni]; } } GeometryConfiguration::~GeometryConfiguration() { - delete[] sph_x; - delete[] sph_y; - delete[] sph_z; + delete[] _sph_x; + delete[] _sph_y; + delete[] _sph_z; } GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& file_name) { @@ -131,7 +131,8 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil throw ex; } int _nsph = 0, _lm = 0, _in_pol = 0, _npnt = 0, _npntts = 0, _isam = 0; - int _li = 0, _le = 0, _mxndm = 0, _iavm = 0; + int _li = 0, _le = 0, _iavm = 0; + np_int _mxndm = 0; regex re = regex("-?[0-9]+"); str_target = file_lines[last_read_line++]; regex_search(str_target, m, re); @@ -214,11 +215,11 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil str_target = m.suffix().str(); } - int _jwtm; + int fjwtm; re = regex("[0-9]+"); str_target = file_lines[last_read_line++]; regex_search(str_target, m, re); - _jwtm = stoi(m.str()); + fjwtm = stoi(m.str()); GeometryConfiguration *conf = new GeometryConfiguration( _nsph, _lm, _in_pol, _npnt, _npntts, _isam, _li, _le, _mxndm, _iavm, @@ -227,45 +228,12 @@ GeometryConfiguration* GeometryConfiguration::from_legacy(const std::string& fil sc_th_start, sc_th_step, sc_th_end, in_ph_start, in_ph_step, in_ph_end, sc_ph_start, sc_ph_step, sc_ph_end, - _jwtm + fjwtm ); delete[] file_lines; return conf; } -double GeometryConfiguration::get_param(const std::string& param_name) { - double value; - if (param_name.compare("number_of_spheres") == 0) value = (double)number_of_spheres; - else if (param_name.compare("nsph") == 0) value = (double)number_of_spheres; - else if (param_name.compare("l_max") == 0) value = (double)l_max; - else if (param_name.compare("li") == 0) value = (double)li; - else if (param_name.compare("le") == 0) value = (double)le; - else if (param_name.compare("mxndm") == 0) value = (double)mxndm; - else if (param_name.compare("iavm") == 0) value = (double)iavm; - else if (param_name.compare("in_pol") == 0) value = (double)in_pol; - else if (param_name.compare("npnt") == 0) value = (double)npnt; - else if (param_name.compare("npntts") == 0) value = (double)npntts; - else if (param_name.compare("meridional_type") == 0) value = (double)meridional_type; - else if (param_name.compare("jwtm") == 0) value = (double)jwtm; - else if (param_name.compare("in_theta_start") == 0) value = in_theta_start; - else if (param_name.compare("in_theta_step") == 0) value = in_theta_step; - else if (param_name.compare("in_theta_end") == 0) value = in_theta_end; - else if (param_name.compare("sc_theta_start") == 0) value = sc_theta_start; - else if (param_name.compare("sc_theta_step") == 0) value = sc_theta_step; - else if (param_name.compare("sc_theta_end") == 0) value = sc_theta_end; - else if (param_name.compare("in_phi_start") == 0) value = in_phi_start; - else if (param_name.compare("in_phi_step") == 0) value = in_phi_step; - else if (param_name.compare("in_phi_end") == 0) value = in_phi_end; - else if (param_name.compare("sc_phi_start") == 0) value = sc_phi_start; - else if (param_name.compare("sc_phi_step") == 0) value = sc_phi_step; - else if (param_name.compare("sc_phi_end") == 0) value = sc_phi_end; - else { - string message = "unrecognized parameter \"" + param_name + "\""; - throw UnrecognizedParameterException(message); - } - return value; -} - ScattererConfiguration::ScattererConfiguration( int nsph, int configs, @@ -283,23 +251,23 @@ ScattererConfiguration::ScattererConfiguration( double w, double x ) { - number_of_spheres = nsph; - configurations = configs; - number_of_scales = nxi; - reference_variable_name = variable_name; - iog_vec = iog_vector; - radii_of_spheres = ros_vector; - nshl_vec = nshl_vector; - rcf = rcf_vector; - idfc = dielectric_func_type; - dc0_matrix = dc_matrix; - use_external_sphere = is_external; - exdc = ex; - wp = w; - xip = x; - scale_vec = new double[number_of_scales](); + _number_of_spheres = nsph; + _configurations = configs; + _number_of_scales = nxi; + _reference_variable_name = variable_name; + _iog_vec = iog_vector; + _radii_of_spheres = ros_vector; + _nshl_vec = nshl_vector; + _rcf = rcf_vector; + _idfc = dielectric_func_type; + _dc0_matrix = dc_matrix; + _use_external_sphere = is_external; + _exdc = ex; + _wp = w; + _xip = x; + _scale_vec = new double[_number_of_scales](); if (variable_name == "XIV") { - for (int xi = 0; xi < nxi; xi++) scale_vec[xi] = scale_vector[xi]; + for (int xi = 0; xi < nxi; xi++) _scale_vec[xi] = scale_vector[xi]; } else { const double pi2 = 2.0 * acos(-1.0); const double evc = 6.5821188e-16; @@ -309,67 +277,62 @@ ScattererConfiguration::ScattererConfiguration( else if (variable_name.compare("WLS") == 0) value = pi2 / value * 3.0e8 / wp; else if (variable_name.compare("PUS") == 0) value /= wp; else if (variable_name.compare("EVS") == 0) value /= (evc * wp); - scale_vec[si] = value; + _scale_vec[si] = value; } } } ScattererConfiguration::ScattererConfiguration(const ScattererConfiguration& rhs) { - number_of_spheres = rhs.number_of_spheres; - configurations = rhs.configurations; - number_of_scales = rhs.number_of_scales; - reference_variable_name = rhs.reference_variable_name; - idfc = rhs.idfc; - use_external_sphere = rhs.use_external_sphere; - exdc = rhs.exdc; - wp = rhs.wp; - xip = rhs.xip; - iog_vec = new int[number_of_spheres](); - radii_of_spheres = new double[number_of_spheres](); - nshl_vec = new int[number_of_spheres](); - rcf = new double*[number_of_spheres]; - scale_vec = new double[number_of_scales](); - dc0_matrix = new dcomplex**[configurations]; - for (int si = 0; si < number_of_scales; si++) scale_vec[si] = rhs.scale_vec[si]; - for (int si=0; si<number_of_spheres; si++) { - iog_vec[si] = rhs.iog_vec[si]; + _number_of_spheres = rhs._number_of_spheres; + _configurations = rhs._configurations; + _number_of_scales = rhs._number_of_scales; + _reference_variable_name = rhs._reference_variable_name; + _idfc = rhs._idfc; + _use_external_sphere = rhs._use_external_sphere; + _exdc = rhs._exdc; + _wp = rhs._wp; + _xip = rhs._xip; + _iog_vec = new int[_number_of_spheres](); + _radii_of_spheres = new double[_number_of_spheres](); + _nshl_vec = new int[_configurations](); + _rcf = new double*[_configurations]; + _scale_vec = new double[_number_of_scales](); + _dc0_matrix = new dcomplex**[_configurations]; + for (int si = 0; si < _number_of_scales; si++) _scale_vec[si] = rhs._scale_vec[si]; + for (int si = 0; si < _number_of_spheres; si++) { + _iog_vec[si] = rhs._iog_vec[si]; } - int dim3 = (idfc == 0) ? number_of_scales : 1; - for (int si=0; si<configurations; si++) { - radii_of_spheres[si] = rhs.radii_of_spheres[si]; - nshl_vec[si] = rhs.nshl_vec[si]; - rcf[si] = new double[nshl_vec[si]](); - dc0_matrix[si] = new dcomplex*[number_of_spheres]; - for (int sj=0; sj<nshl_vec[si]; sj++) rcf[si][sj] = rhs.rcf[si][sj]; - for (int sj=0; sj<number_of_spheres; sj++) { - dc0_matrix[si][sj] = new dcomplex[dim3](); - for (int sk=0; sk<dim3; sk++) dc0_matrix[si][sj][sk] = rhs.dc0_matrix[si][sj][sk]; + int dim3 = (_idfc == 0) ? _number_of_scales : 1; + for (int si = 0; si < _configurations; si++) { + _radii_of_spheres[si] = rhs._radii_of_spheres[si]; + _nshl_vec[si] = rhs._nshl_vec[si]; + _rcf[si] = new double[_nshl_vec[si]](); + _dc0_matrix[si] = new dcomplex*[_number_of_spheres]; + for (int sj = 0; sj < _nshl_vec[si]; sj++) _rcf[si][sj] = rhs._rcf[si][sj]; + for (int sj = 0; sj < _number_of_spheres; sj++) { + _dc0_matrix[si][sj] = new dcomplex[dim3](); + for (int sk = 0; sk < dim3; sk++) _dc0_matrix[si][sj][sk] = rhs._dc0_matrix[si][sj][sk]; } } } ScattererConfiguration::~ScattererConfiguration() { - int configurations = 0; - for (int i = 1; i <= number_of_spheres; i++) { - if (iog_vec[i - 1] < i) continue; - configurations++; - } - for (int i = 0; i < configurations; i++) { - for (int j = 0; j < number_of_spheres; j++) { - delete[] dc0_matrix[i][j]; + for (int i = 0; i < _configurations; i++) { + for (int j = 0; j < _number_of_spheres; j++) { + delete[] _dc0_matrix[i][j]; } - delete[] dc0_matrix[i]; + delete[] _dc0_matrix[i]; } - delete[] dc0_matrix; - for (int i = 0; i < configurations; i++) { - delete[] rcf[i]; + delete[] _dc0_matrix; + for (int i = 0; i < _configurations; i++) { + delete[] _rcf[i]; } - delete[] rcf; - delete[] nshl_vec; - delete[] radii_of_spheres; - delete[] iog_vec; - delete[] scale_vec; + delete[] _rcf; + delete[] _nshl_vec; + delete[] _radii_of_spheres; + delete[] _iog_vec; + delete[] _scale_vec; } ScattererConfiguration* ScattererConfiguration::from_binary(const std::string& file_name, const std::string& mode) { @@ -397,17 +360,17 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de OpenConfigurationFileException ex(dedfb_file_name); throw ex; } - int nsph, ies; + int fnsph, fies; re = regex("[0-9]+"); string str_target = file_lines[last_read_line]; for (int ri = 0; ri < 2; ri++) { regex_search(str_target, m, re); - if (ri == 0) nsph = stoi(m.str()); - if (ri == 1) ies = stoi(m.str()); + if (ri == 0) fnsph = stoi(m.str()); + if (ri == 1) fies = stoi(m.str()); str_target = m.suffix().str(); } - if (ies != 0) ies = 1; - double _exdc, _wp, _xip; + if (fies != 0) fies = 1; + double fexdc, fwp, fxip; str_target = file_lines[++last_read_line]; re = regex("-?[0-9]+\\.[0-9]+([eEdD][-+]?[0-9]+)?"); for (int ri = 0; ri < 3; ri++) { @@ -415,28 +378,28 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de string str_number = m.str(); str_number = regex_replace(str_number, regex("D"), "e"); str_number = regex_replace(str_number, regex("d"), "e"); - if (ri == 0) _exdc = stod(str_number); - if (ri == 1) _wp = stod(str_number); - if (ri == 2) _xip = stod(str_number); + if (ri == 0) fexdc = stod(str_number); + if (ri == 1) fwp = stod(str_number); + if (ri == 2) fxip = stod(str_number); str_target = m.suffix().str(); } - int _idfc, nxi, instpc, insn; + int fidfc, fnxi, finstpc, finsn; re = regex("-?[0-9]+"); for (int ri = 0; ri < 4; ri++) { regex_search(str_target, m, re); - if (ri == 0) _idfc = stoi(m.str()); - if (ri == 1) nxi = stoi(m.str()); - if (ri == 2) instpc = stoi(m.str()); - if (ri == 3) insn = stoi(m.str()); + if (ri == 0) fidfc = stoi(m.str()); + if (ri == 1) fnxi = stoi(m.str()); + if (ri == 2) finstpc = stoi(m.str()); + if (ri == 3) finsn = stoi(m.str()); str_target = m.suffix().str(); } double *variable_vector; string variable_name; - if (_idfc < 0) { // Diel. functions at XIP value and XI is scale factor + if (fidfc < 0) { // Diel. functions at XIP value and XI is scale factor variable_name = "XIV"; - if (instpc < 1) { // The variable vector is explicitly defined. + if (finstpc < 1) { // The variable vector is explicitly defined. double xi; List<double> *xi_vector = new List<double>(1); str_target = file_lines[++last_read_line]; @@ -447,7 +410,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de str_number = regex_replace(str_number, regex("d"), "e"); xi = stod(str_number); xi_vector->set(0, xi); - for (int jxi310 = 1; jxi310 < nxi; jxi310++) { + for (int jxi310 = 1; jxi310 < fnxi; jxi310++) { str_target = file_lines[++last_read_line]; regex_search(str_target, m, re); str_number = m.str(); @@ -472,17 +435,17 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de if (ri == 1) xi_step = stod(str_number); str_target = m.suffix().str(); } - variable_vector = new double[nxi](); - for (int jxi320 = 0; jxi320 < nxi; jxi320++) { + variable_vector = new double[fnxi](); + for (int jxi320 = 0; jxi320 < fnxi; jxi320++) { variable_vector[jxi320] = xi; xi += xi_step; } } } else { // idfc >= 0 - variable_vector = new double[nxi](); - if (instpc == 0) { // The variable vector is explicitly defined + variable_vector = new double[fnxi](); + if (finstpc == 0) { // The variable vector is explicitly defined double vs; - for (int jxi_r = 0; jxi_r < nxi; jxi_r++) { + for (int jxi_r = 0; jxi_r < fnxi; jxi_r++) { str_target = file_lines[++last_read_line]; re = regex("-?[0-9]+\\.[0-9]+([eEdD][-+]?[0-9]+)?"); regex_search(str_target, m, re); @@ -492,7 +455,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de vs = stod(str_number); variable_vector[jxi_r] = vs; } - switch (insn) { + switch (finsn) { case 1: //xi vector definition variable_name = "XIV"; break; @@ -523,11 +486,11 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de if (ri == 1) vs_step = stod(str_number); str_target = m.suffix().str(); } - for (int jxi110w = 0; jxi110w < nxi; jxi110w++) { + for (int jxi110w = 0; jxi110w < fnxi; jxi110w++) { variable_vector[jxi110w] = vs; vs += vs_step; } - switch (insn) { + switch (finsn) { case 1: //xi vector definition variable_name = "XIV"; break; @@ -546,11 +509,11 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de } } } - int *iog_vector = new int[nsph](); + int *iog_vector = new int[fnsph](); str_target = file_lines[++last_read_line]; re = regex("[0-9]+"); int configurations = 0; - for (int i = 1; i <= nsph; i++) { + for (int i = 1; i <= fnsph; i++) { bool success = regex_search(str_target, m, re); if (success) { iog_vector[i - 1] = stoi(m.str()); @@ -562,10 +525,10 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de } } int index = 0; - double *ros_vector = new double[nsph](); - int *nshl_vector = new int[nsph](); - double **rcf_vector = new double*[nsph]; - for (int i113 = 1; i113 <= nsph; i113++) { + double *ros_vector = new double[fnsph](); + int *nshl_vector = new int[fnsph](); + double **rcf_vector = new double*[fnsph]; + for (int i113 = 1; i113 <= fnsph; i113++) { if (iog_vector[i113 - 1] < i113) continue; str_target = file_lines[++last_read_line]; re = regex("[0-9]+"); @@ -579,7 +542,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de str_number = regex_replace(str_number, regex("d"), "e"); ros_vector[i113 - 1] = stod(str_number); int nsh = nshl_vector[i113 - 1]; - if (i113 == 1) nsh += ies; + if (i113 == 1) nsh += fies; rcf_vector[i113 - 1] = new double[nsh](); for (int ns112 = 0; ns112 < nsh; ns112++) { str_target = file_lines[++last_read_line]; @@ -593,18 +556,18 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de dcomplex ***dc0m = new dcomplex**[configurations]; dcomplex *dc0 = new dcomplex[configurations](); - int dim3 = (_idfc == 0) ? nxi : 1; + int dim3 = (fidfc == 0) ? fnxi : 1; for (int di = 0; di < configurations; di++) { - dc0m[di] = new dcomplex*[nsph]; - for (int dj = 0; dj < nsph; dj++) dc0m[di][dj] = new dcomplex[dim3](); + dc0m[di] = new dcomplex*[fnsph]; + for (int dj = 0; dj < fnsph; dj++) dc0m[di][dj] = new dcomplex[dim3](); } // di loop - for (int jxi468 = 1; jxi468 <= nxi; jxi468++) { - if (_idfc != 0 && jxi468 > 1) continue; // jxi468 loop - for (int i162 = 1; i162 <= nsph; i162++) { + for (int jxi468 = 1; jxi468 <= fnxi; jxi468++) { + if (fidfc != 0 && jxi468 > 1) continue; // jxi468 loop + for (int i162 = 1; i162 <= fnsph; i162++) { if (iog_vector[i162 - 1] >= i162) { int nsh = nshl_vector[i162 - 1]; int ici = (nsh + 1) / 2; - if (i162 == 1) ici += ies; + if (i162 == 1) ici += fies; for (int ic157 = 0; ic157 < ici; ic157++) { str_target = file_lines[++last_read_line]; regex_search(str_target, m, re); @@ -627,21 +590,21 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(const std::string& de delete[] dc0; ScattererConfiguration *config = new ScattererConfiguration( - nsph, + fnsph, configurations, variable_vector, - nxi, + fnxi, variable_name, iog_vector, ros_vector, nshl_vector, rcf_vector, - _idfc, + fidfc, dc0m, - (ies > 0), - _exdc, - _wp, - _xip + (fies > 0), + fexdc, + fwp, + fxip ); delete[] file_lines; delete[] variable_vector; @@ -832,6 +795,7 @@ ScattererConfiguration* ScattererConfiguration::from_legacy(const std::string& f return conf; } +/* double ScattererConfiguration::get_param(const std::string& param_name) { double value; if (param_name.compare("number_of_spheres") == 0) value = (double)number_of_spheres; @@ -849,48 +813,45 @@ double ScattererConfiguration::get_param(const std::string& param_name) { } return value; } +*/ void ScattererConfiguration::print() { - int ies = (use_external_sphere)? 1 : 0; - int configurations = 0; - for (int ci = 1; ci <= number_of_spheres; ci++) { - if (iog_vec[ci - 1] >= ci) configurations++; - } + int ies = (_use_external_sphere)? 1 : 0; printf("### CONFIGURATION DATA ###\n"); - printf("NSPH = %d\n", number_of_spheres); + printf("NSPH = %d\n", _number_of_spheres); printf("ROS = ["); - for (int i = 0; i < configurations; i++) printf("\t%lg", radii_of_spheres[i]); + for (int i = 0; i < _configurations; i++) printf("\t%lg", _radii_of_spheres[i]); printf("\t]\n"); printf("IOG = ["); - for (int i = 0; i < number_of_spheres; i++) printf("\t%d", iog_vec[i]); + for (int i = 0; i < _number_of_spheres; i++) printf("\t%d", _iog_vec[i]); printf("\t]\n"); printf("NSHL = ["); - for (int i = 0; i < configurations; i++) printf("\t%d", nshl_vec[i]); + for (int i = 0; i < _configurations; i++) printf("\t%d", _nshl_vec[i]); printf("\t]\n"); printf("RCF = [\n"); - for (int i = 1; i <= configurations; i++) { - int nsh = nshl_vec[i - 1]; + for (int i = 1; i <= _configurations; i++) { + int nsh = _nshl_vec[i - 1]; if (i == 1) nsh += ies; printf(" ["); for (int ns = 0; ns < nsh; ns++) { - printf("\t%lg", rcf[i - 1][ns]); + printf("\t%lg", _rcf[i - 1][ns]); } printf("\t]\n"); } printf(" ]\n"); - printf("SCALE = %s\n", reference_variable_name.c_str()); - printf("NXI = %d\n", number_of_scales); + printf("SCALE = %s\n", _reference_variable_name.c_str()); + printf("NXI = %d\n", _number_of_scales); printf("VEC = ["); - for (int i = 0; i < number_of_scales; i++) printf("\t%lg", scale_vec[i]); + for (int i = 0; i < _number_of_scales; i++) printf("\t%lg", _scale_vec[i]); printf("\t]\n"); printf("DC0M = [\n"); - for (int i = 0; i < configurations; i++) { + for (int i = 0; i < _configurations; i++) { printf(" [\n"); - for (int j = 0; j < number_of_spheres; j++) { + for (int j = 0; j < _number_of_spheres; j++) { printf(" ["); - for (int k = 0; k < number_of_scales; k++) { + for (int k = 0; k < _number_of_scales; k++) { if (idfc != 0 and k > 0) continue; - printf("\t%lg + i(%lg)", real(dc0_matrix[i][j][k]), imag(dc0_matrix[i][j][k])); + printf("\t%lg + i(%lg)", real(_dc0_matrix[i][j][k]), imag(_dc0_matrix[i][j][k])); } printf("\t]\n"); } @@ -916,73 +877,69 @@ void ScattererConfiguration::write_hdf5(const std::string& file_name) { List<string> *rec_type_list = new List<string>(1); List<void *> *rec_ptr_list = new List<void *>(1); string str_type, str_name; - int configurations = 0; - for (int ci = 1; ci <= number_of_spheres; ci++) { - if(iog_vec[ci - 1] >= ci) configurations++; - } rec_name_list->set(0, "NSPH"); rec_type_list->set(0, "INT32_(1)"); - rec_ptr_list->set(0, &number_of_spheres); + rec_ptr_list->set(0, &_number_of_spheres); rec_name_list->append("IES"); rec_type_list->append("INT32_(1)"); rec_ptr_list->append(&ies); rec_name_list->append("IOGVEC"); - str_type = "INT32_(" + to_string(number_of_spheres) + ")"; + str_type = "INT32_(" + to_string(_number_of_spheres) + ")"; rec_type_list->append(str_type); - rec_ptr_list->append(iog_vec); + rec_ptr_list->append(_iog_vec); rec_name_list->append("EXDC"); rec_type_list->append("FLOAT64_(1)"); - rec_ptr_list->append(&exdc); + rec_ptr_list->append(&_exdc); rec_name_list->append("WP"); rec_type_list->append("FLOAT64_(1)"); - rec_ptr_list->append(&wp); + rec_ptr_list->append(&_wp); rec_name_list->append("XIP"); rec_type_list->append("FLOAT64_(1)"); - rec_ptr_list->append(&xip); + rec_ptr_list->append(&_xip); rec_name_list->append("IDFC"); rec_type_list->append("INT32_(1)"); - rec_ptr_list->append(&idfc); + rec_ptr_list->append(&_idfc); rec_name_list->append("NXI"); rec_type_list->append("INT32_(1)"); - rec_ptr_list->append(&number_of_scales); + rec_ptr_list->append(&_number_of_scales); rec_name_list->append("XIVEC"); str_type = "FLOAT64_(" + to_string(number_of_scales) + ")"; rec_type_list->append(str_type); - rec_ptr_list->append(scale_vec); - for (int i115 = 1; i115 <= number_of_spheres; i115++) { - if (iog_vec[i115 - 1] < i115) continue; + rec_ptr_list->append(_scale_vec); + for (int i115 = 1; i115 <= _number_of_spheres; i115++) { + if (_iog_vec[i115 - 1] < i115) continue; str_name = "NSHL_" + to_string(i115); rec_name_list->append(str_name); rec_type_list->append("INT32_(1)"); - rec_ptr_list->append(&(nshl_vec[i115 - 1])); // was not from IOG + rec_ptr_list->append(&(_nshl_vec[i115 - 1])); // was not from IOG str_name = "ROS_" + to_string(i115); rec_name_list->append(str_name); rec_type_list->append("FLOAT64_(1)"); - rec_ptr_list->append(&(radii_of_spheres[i115 - 1])); // was not from IOG - int nsh = nshl_vec[i115 - 1]; // was not from IOG + rec_ptr_list->append(&(_radii_of_spheres[i115 - 1])); // was not from IOG + int nsh = _nshl_vec[i115 - 1]; // was not from IOG if (i115 == 1) nsh += ies; str_name = "RCF_" + to_string(i115); // was not from IOG str_type = "FLOAT64_(" + to_string(nsh) + ")"; rec_name_list->append(str_name); rec_type_list->append(str_type); - rec_ptr_list->append(&(rcf[i115 - 1][0])); // was not from IOG + rec_ptr_list->append(&(_rcf[i115 - 1][0])); // was not from IOG } - int dim3 = (idfc == 0) ? number_of_scales : 1; - int dc0m_size = 2 * dim3 * number_of_spheres * configurations; + int dim3 = (idfc == 0) ? _number_of_scales : 1; + int dc0m_size = 2 * dim3 * _number_of_spheres * _configurations; double *dc0m = new double[dc0m_size](); int dc0_index = 0; - for (int jxi468 = 1; jxi468 <= number_of_scales; jxi468++) { - if (idfc != 0 && jxi468 > 1) continue; - for (int i162 = 1; i162 <= number_of_spheres; i162++) { - if (iog_vec[i162 - 1] < i162) continue; - int nsh = nshl_vec[i162 - 1]; // was not from IOG + for (int jxi468 = 1; jxi468 <= _number_of_scales; jxi468++) { + if (_idfc != 0 && jxi468 > 1) continue; + for (int i162 = 1; i162 <= _number_of_spheres; i162++) { + if (_iog_vec[i162 - 1] < i162) continue; + int nsh = _nshl_vec[i162 - 1]; // was not from IOG int ici = (nsh + 1) / 2; if (i162 == 1) ici = ici + ies; for (int i157 = 0; i157 < ici; i157++) { double dc0_real, dc0_imag; - dc0_real = real(dc0_matrix[i157][i162 - 1][jxi468 - 1]); - dc0_imag = imag(dc0_matrix[i157][i162 - 1][jxi468 - 1]); + dc0_real = real(_dc0_matrix[i157][i162 - 1][jxi468 - 1]); + dc0_imag = imag(_dc0_matrix[i157][i162 - 1][jxi468 - 1]); dc0m[2 * dc0_index] = dc0_real; dc0m[2 * dc0_index + 1] = dc0_imag; dc0_index++; @@ -1018,39 +975,39 @@ void ScattererConfiguration::write_hdf5(const std::string& file_name) { void ScattererConfiguration::write_legacy(const std::string& file_name) { fstream output; - int ies = (use_external_sphere)? 1 : 0; + int ies = (_use_external_sphere)? 1 : 0; output.open(file_name.c_str(), ios::out | ios::binary); - output.write(reinterpret_cast<char *>(&number_of_spheres), sizeof(int)); + output.write(reinterpret_cast<char *>(&_number_of_spheres), sizeof(int)); output.write(reinterpret_cast<char *>(&ies), sizeof(int)); - for (int i = 0; i < number_of_spheres; i++) - output.write(reinterpret_cast<char *>(&(iog_vec[i])), sizeof(int)); - output.write(reinterpret_cast<char *>(&exdc), sizeof(double)); - output.write(reinterpret_cast<char *>(&wp), sizeof(double)); - output.write(reinterpret_cast<char *>(&xip), sizeof(double)); - output.write(reinterpret_cast<char *>(&idfc), sizeof(int)); - output.write(reinterpret_cast<char *>(&number_of_scales), sizeof(int)); - for (int i = 0; i < number_of_scales; i++) - output.write(reinterpret_cast<char *>(&(scale_vec[i])), sizeof(double)); - for (int i115 = 1; i115 <= number_of_spheres; i115++) { - if (iog_vec[i115 - 1] < i115) continue; - output.write(reinterpret_cast<char *>(&(nshl_vec[i115 - 1])), sizeof(int)); // was not from IOG - output.write(reinterpret_cast<char *>(&(radii_of_spheres[i115 - 1])), sizeof(double)); // was not from IOG - int nsh = nshl_vec[i115 - 1]; // was not from IOG + for (int i = 0; i < _number_of_spheres; i++) + output.write(reinterpret_cast<char *>(&(_iog_vec[i])), sizeof(int)); + output.write(reinterpret_cast<char *>(&_exdc), sizeof(double)); + output.write(reinterpret_cast<char *>(&_wp), sizeof(double)); + output.write(reinterpret_cast<char *>(&_xip), sizeof(double)); + output.write(reinterpret_cast<char *>(&_idfc), sizeof(int)); + output.write(reinterpret_cast<char *>(&_number_of_scales), sizeof(int)); + for (int i = 0; i < _number_of_scales; i++) + output.write(reinterpret_cast<char *>(&(_scale_vec[i])), sizeof(double)); + for (int i115 = 1; i115 <= _number_of_spheres; i115++) { + if (_iog_vec[i115 - 1] < i115) continue; + output.write(reinterpret_cast<char *>(&(_nshl_vec[i115 - 1])), sizeof(int)); // was not from IOG + output.write(reinterpret_cast<char *>(&(_radii_of_spheres[i115 - 1])), sizeof(double)); // was not from IOG + int nsh = _nshl_vec[i115 - 1]; // was not from IOG if (i115 == 1) nsh += ies; for (int nsi = 0; nsi < nsh; nsi++) - output.write(reinterpret_cast<char *>(&(rcf[i115 - 1][nsi])), sizeof(double)); // was not from IOG + output.write(reinterpret_cast<char *>(&(_rcf[i115 - 1][nsi])), sizeof(double)); // was not from IOG } - for (int jxi468 = 1; jxi468 <= number_of_scales; jxi468++) { + for (int jxi468 = 1; jxi468 <= _number_of_scales; jxi468++) { if (idfc != 0 && jxi468 > 1) continue; - for (int i162 = 1; i162 <= number_of_spheres; i162++) { - if (iog_vec[i162 - 1] < i162) continue; - int nsh = nshl_vec[i162 - 1]; // was not from IOG + for (int i162 = 1; i162 <= _number_of_spheres; i162++) { + if (_iog_vec[i162 - 1] < i162) continue; + int nsh = _nshl_vec[i162 - 1]; // was not from IOG int ici = (nsh + 1) / 2; // QUESTION: is integer division really intended here? if (i162 == 1) ici = ici + ies; for (int i157 = 0; i157 < ici; i157++) { double dc0_real, dc0_img; - dc0_real = real(dc0_matrix[i157][i162 - 1][jxi468 - 1]); - dc0_img = imag(dc0_matrix[i157][i162 - 1][jxi468 - 1]); + dc0_real = real(_dc0_matrix[i157][i162 - 1][jxi468 - 1]); + dc0_img = imag(_dc0_matrix[i157][i162 - 1][jxi468 - 1]); // The FORTRAN code writes the complex numbers as a 16-byte long binary stream. // Here we assume that the 16 bytes are equally split in 8 bytes to represent the // real part and 8 bytes to represent the imaginary one. @@ -1070,23 +1027,23 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { int ies = (use_external_sphere)? 1: 0; FILE *output = fopen(file_name.c_str(), "w"); int scale_type = -1; - if (reference_variable_name.compare("XIV") == 0) scale_type = 0; - else if (reference_variable_name.compare("WNS") == 0) scale_type = 1; - else if (reference_variable_name.compare("WLS") == 0) scale_type = 2; - else if (reference_variable_name.compare("PUS") == 0) scale_type = 3; - else if (reference_variable_name.compare("EVS") == 0) scale_type = 4; - if (idfc >= 0) { // Dielectric functions are constant or they depend on XI + if (_reference_variable_name.compare("XIV") == 0) scale_type = 0; + else if (_reference_variable_name.compare("WNS") == 0) scale_type = 1; + else if (_reference_variable_name.compare("WLS") == 0) scale_type = 2; + else if (_reference_variable_name.compare("PUS") == 0) scale_type = 3; + else if (_reference_variable_name.compare("EVS") == 0) scale_type = 4; + if (_idfc >= 0) { // Dielectric functions are constant or they depend on XI double *pu_vec, *ev_vec, *wn_vec, *wl_vec; - xi_vec = new double[number_of_scales]; - pu_vec = new double[number_of_scales]; - ev_vec = new double[number_of_scales]; - wn_vec = new double[number_of_scales]; - wl_vec = new double[number_of_scales]; + xi_vec = new double[_number_of_scales]; + pu_vec = new double[_number_of_scales]; + ev_vec = new double[_number_of_scales]; + wn_vec = new double[_number_of_scales]; + wl_vec = new double[_number_of_scales]; switch (scale_type) { case 0: fprintf(output, " JXI XIV WNS WLS PUS EVS\n"); - for (int i = 0; i < number_of_scales; i++) { - xi_vec[i] = scale_vec[i]; + for (int i = 0; i < _number_of_scales; i++) { + xi_vec[i] = _scale_vec[i]; pu_vec[i] = xi_vec[i] * wp; ev_vec[i] = pu_vec[i] * evc; wn_vec[i] = pu_vec[i] / 3.0e8; @@ -1105,8 +1062,8 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { break; case 1: fprintf(output, " JXI WNS WLS PUS EVS XIV\n"); - for (int i = 0; i < number_of_scales; i++) { - xi_vec[i] = scale_vec[i]; + for (int i = 0; i < _number_of_scales; i++) { + xi_vec[i] = _scale_vec[i]; pu_vec[i] = xi_vec[i] * wp; wn_vec[i] = pu_vec[i] / 3.0e8; wl_vec[i] = two_pi / wn_vec[i]; @@ -1125,8 +1082,8 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { break; case 2: fprintf(output, " JXI WLS WNS PUS EVS XIV\n"); - for (int i = 0; i < number_of_scales; i++) { - xi_vec[i] = scale_vec[i]; + for (int i = 0; i < _number_of_scales; i++) { + xi_vec[i] = _scale_vec[i]; pu_vec[i] = xi_vec[i] * wp; wn_vec[i] = pu_vec[i] / 3.0e8; wl_vec[i] = two_pi / wn_vec[i]; @@ -1145,8 +1102,8 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { break; case 3: fprintf(output, " JXI PUS WNS WLS EVS XIV\n"); - for (int i = 0; i < number_of_scales; i++) { - xi_vec[i] = scale_vec[i]; + for (int i = 0; i < _number_of_scales; i++) { + xi_vec[i] = _scale_vec[i]; pu_vec[i] = xi_vec[i] * wp; wn_vec[i] = pu_vec[i] / 3.0e8; wl_vec[i] = two_pi / wn_vec[i]; @@ -1165,8 +1122,8 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { break; case 4: fprintf(output, " JXI EVS WNS WLS PUS XIV\n"); - for (int i = 0; i < number_of_scales; i++) { - xi_vec[i] = scale_vec[i]; + for (int i = 0; i < _number_of_scales; i++) { + xi_vec[i] = _scale_vec[i]; pu_vec[i] = xi_vec[i] * wp; wn_vec[i] = pu_vec[i] / 3.0e8; wl_vec[i] = two_pi / wn_vec[i]; @@ -1198,7 +1155,7 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { delete[] wl_vec; } else { // idfc < 0, Dielectric functions are at XIP and XI is scale for dimensions double pu, wn; - xi_vec = scale_vec; + xi_vec = _scale_vec; pu = xip * wp; wn = pu / 3.0e8; fprintf(output, " XIP WN WL PU EV\n"); @@ -1208,34 +1165,34 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { fprintf(output, "%13.4lE", pu); fprintf(output, "%13.4lE\n", pu * evc); fprintf(output, " SCALE FACTORS XI\n"); - for (int i = 0; i < number_of_scales; i++) + for (int i = 0; i < _number_of_scales; i++) fprintf(output, "%5d%13.4lE\n", (i + 1), xi_vec[i]); } - if (idfc != 0) { + if (_idfc != 0) { fprintf(output, " DIELECTRIC CONSTANTS\n"); - for (int i473 = 1; i473 <= number_of_spheres; i473++) { - if (iog_vec[i473 - 1] != i473) continue; - ici = (nshl_vec[i473 - 1] + 1) / 2; + for (int i473 = 1; i473 <= _number_of_spheres; i473++) { + if (_iog_vec[i473 - 1] != i473) continue; + ici = (_nshl_vec[i473 - 1] + 1) / 2; if (i473 == 1) ici += ies; fprintf(output, " SPHERE N.%4d\n", i473); for (int ic472 = 0; ic472 < ici; ic472++) { - double dc0_real = real(dc0_matrix[ic472][i473 - 1][0]); - double dc0_img = imag(dc0_matrix[ic472][i473 - 1][0]); + double dc0_real = real(_dc0_matrix[ic472][i473 - 1][0]); + double dc0_img = imag(_dc0_matrix[ic472][i473 - 1][0]); fprintf(output, "%5d %12.4lE%12.4lE\n", (ic472 + 1), dc0_real, dc0_img); } } } else { fprintf(output, " DIELECTRIC FUNCTIONS\n"); - for (int i478 = 1; i478 <= number_of_spheres; i478++) { - if (iog_vec[i478 - 1] != i478) continue; - ici = (nshl_vec[i478 - 1] + 1) / 2; + for (int i478 = 1; i478 <= _number_of_spheres; i478++) { + if (_iog_vec[i478 - 1] != i478) continue; + ici = (_nshl_vec[i478 - 1] + 1) / 2; if (i478 == 1) ici += ies; fprintf(output, " SPHERE N.%4d\n", i478); for (int ic477 = 1; ic477 <= ici; ic477++) { - fprintf(output, " NONTRANSITION LAYER N.%2d, SCALE = %3s\n", ic477, reference_variable_name.c_str()); - for (int jxi476 = 0; jxi476 < number_of_scales; jxi476++) { - double dc0_real = real(dc0_matrix[ic477 - 1][i478 - 1][jxi476]); - double dc0_img = imag(dc0_matrix[ic477 - 1][i478 - 1][jxi476]); + fprintf(output, " NONTRANSITION LAYER N.%2d, SCALE = %3s\n", ic477, _reference_variable_name.c_str()); + for (int jxi476 = 0; jxi476 < _number_of_scales; jxi476++) { + double dc0_real = real(_dc0_matrix[ic477 - 1][i478 - 1][jxi476]); + double dc0_img = imag(_dc0_matrix[ic477 - 1][i478 - 1][jxi476]); fprintf(output, "%5d %12.4lE%12.4lE\n", (jxi476 + 1), dc0_real, dc0_img); } } @@ -1245,53 +1202,53 @@ void ScattererConfiguration::write_formatted(const std::string& file_name) { } bool ScattererConfiguration::operator ==(const ScattererConfiguration &other) { - if (number_of_spheres != other.number_of_spheres) { + if (_number_of_spheres != other._number_of_spheres) { return false; } - if (number_of_scales != other.number_of_scales) { + if (_number_of_scales != other._number_of_scales) { return false; } - if (idfc != other.idfc) { + if (_idfc != other._idfc) { return false; } - if (exdc != other.exdc) { + if (_exdc != other._exdc) { return false; } - if (wp != other.wp) { + if (_wp != other._wp) { return false; } - if (xip != other.xip) { + if (_xip != other._xip) { return false; } //if (use_external_sphere != other.use_external_sphere) return false; - for (int svi = 0; svi < number_of_scales; svi++) - if (scale_vec[svi] != other.scale_vec[svi]) { + for (int svi = 0; svi < _number_of_scales; svi++) + if (_scale_vec[svi] != other._scale_vec[svi]) { return false; } - int configurations = 0; - int dim3 = (idfc == 0) ? number_of_scales : 1; - for (int ci = 1; ci <= number_of_spheres; ci++) { - if (iog_vec[ci - 1] != other.iog_vec[ci - 1]) { + if (_configurations != other._configurations) { + return false; + } + int dim3 = (idfc == 0) ? _number_of_scales : 1; + for (int ci = 1; ci <= _number_of_spheres; ci++) { + if (_iog_vec[ci - 1] != other._iog_vec[ci - 1]) { return false; } - if (iog_vec[ci - 1] < ci) continue; - configurations++; } - for (int ri = 0; ri < configurations; ri++) { - if (radii_of_spheres[ri] != other.radii_of_spheres[ri]) { + for (int ri = 0; ri < _configurations; ri++) { + if (_radii_of_spheres[ri] != other._radii_of_spheres[ri]) { return false; } - if (nshl_vec[ri] != other.nshl_vec[ri]) { + if (_nshl_vec[ri] != other._nshl_vec[ri]) { return false; } - for (int rj = 0; rj < nshl_vec[ri]; rj++) { - if (rcf[ri][rj] != other.rcf[ri][rj]) { + for (int rj = 0; rj < _nshl_vec[ri]; rj++) { + if (_rcf[ri][rj] != other._rcf[ri][rj]) { return false; } } // rj loop - for (int dj = 0; dj < number_of_spheres; dj++) { + for (int dj = 0; dj < _number_of_spheres; dj++) { for (int dk = 0; dk < dim3; dk++) { - if (dc0_matrix[ri][dj][dk] != other.dc0_matrix[ri][dj][dk]) { + if (_dc0_matrix[ri][dj][dk] != other._dc0_matrix[ri][dj][dk]) { return false; } } // dk loop diff --git a/src/sphere/sphere.cpp b/src/sphere/sphere.cpp index 5e5c5e65..2c0dd6fd 100644 --- a/src/sphere/sphere.cpp +++ b/src/sphere/sphere.cpp @@ -74,8 +74,8 @@ void sphere(const string& config_file, const string& data_file, const string& ou delete logger; exit(1); } - int s_nsph = (int)sconf->get_param("nsph"); - int nsph = (int)gconf->get_param("nsph"); + int s_nsph = sconf->number_of_spheres; + int nsph = gconf->number_of_spheres; if (s_nsph == nsph) { int isq, ibf; double *argi, *args, *gaps; @@ -114,25 +114,25 @@ void sphere(const string& config_file, const string& data_file, const string& ou double frx = 0.0, fry = 0.0, frz = 0.0; double cfmp, cfsp, sfmp, sfsp; int jw; - int l_max = gconf->get_param("l_max"); + int l_max = gconf->l_max; C1 *c1 = new C1(gconf, sconf); - int npnt = (int)gconf->get_param("npnt"); - int npntts = (int)gconf->get_param("npntts"); - int in_pol = (int)gconf->get_param("in_pol"); - int meridional_type = (int)gconf->get_param("meridional_type"); - int jwtm = (int)gconf->get_param("jwtm"); - double in_theta_start = gconf->get_param("in_theta_start"); - double in_theta_step = gconf->get_param("in_theta_step"); - double in_theta_end = gconf->get_param("in_theta_end"); - double sc_theta_start = gconf->get_param("sc_theta_start"); - double sc_theta_step = gconf->get_param("sc_theta_step"); - double sc_theta_end = gconf->get_param("sc_theta_end"); - double in_phi_start = gconf->get_param("in_phi_start"); - double in_phi_step = gconf->get_param("in_phi_step"); - double in_phi_end = gconf->get_param("in_phi_end"); - double sc_phi_start = gconf->get_param("sc_phi_start"); - double sc_phi_step = gconf->get_param("sc_phi_step"); - double sc_phi_end = gconf->get_param("sc_phi_end"); + int npnt = gconf->npnt; + int npntts = gconf->npntts; + int in_pol = gconf->in_pol; + int meridional_type = gconf->iavm; + int jwtm = gconf->jwtm; + double in_theta_start = gconf->in_theta_start; + double in_theta_step = gconf->in_theta_step; + double in_theta_end = gconf->in_theta_end; + double sc_theta_start = gconf->sc_theta_start; + double sc_theta_step = gconf->sc_theta_step; + double sc_theta_end = gconf->sc_theta_end; + double in_phi_start = gconf->in_phi_start; + double in_phi_step = gconf->in_phi_step; + double in_phi_end = gconf->in_phi_end; + double sc_phi_start = gconf->sc_phi_start; + double sc_phi_step = gconf->sc_phi_step; + double sc_phi_end = gconf->sc_phi_end; C2 *c2 = new C2(gconf, sconf); argi = new double[1]; args = new double[1]; @@ -238,7 +238,7 @@ void sphere(const string& config_file, const string& data_file, const string& ou } } thdps(l_max, zpv); - double exdc = sconf->get_param("exdc"); + double exdc = sconf->exdc; double exri = sqrt(exdc); fprintf(output, " REFR. INDEX OF EXTERNAL MEDIUM=%15.7lE\n", exri); fstream tppoan; @@ -261,13 +261,13 @@ void sphere(const string& config_file, const string& data_file, const string& ou if (in_pol == 0) fprintf(output, " LIN\n"); else fprintf(output, " CIRC\n"); fprintf(output, " \n"); - double wp = sconf->get_param("wp"); - double xip = sconf->get_param("xip"); + double wp = sconf->wp; + double xip = sconf->xip; double wn = wp / 3.0e8; double sqsfi = 1.0; double vk, vkarg; - int idfc = (int)sconf->get_param("idfc"); - int nxi = (int)sconf->get_param("number_of_scales"); + int idfc = sconf->idfc; + int nxi = sconf->number_of_scales; if (idfc < 0) { vk = xip * wn; fprintf(output, " VK=%15.7lE, XI IS SCALE FACTOR FOR LENGTHS\n", vk); diff --git a/src/trapping/cfrfme.cpp b/src/trapping/cfrfme.cpp index a9e82e6c..2a66e7d8 100644 --- a/src/trapping/cfrfme.cpp +++ b/src/trapping/cfrfme.cpp @@ -176,13 +176,13 @@ void frfme(string data_file, string output_path) { ScattererConfiguration *tedf = ScattererConfiguration::from_binary(tedf_name, "HDF5"); if (tedf != NULL) { int iduml, idum; - iduml = (int)tedf->get_param("nsph"); + iduml = tedf->number_of_spheres; idum = tedf->get_iog(iduml - 1); - exdc = tedf->get_param("exdc"); - wp = tedf->get_param("wp"); - xip = tedf->get_param("xip"); - idfc = (int)tedf->get_param("idfc"); - nxi = (int)tedf->get_param("nxi"); + exdc = tedf->exdc; + wp = tedf->wp; + xip = tedf->xip; + idfc = tedf->idfc; + nxi = tedf->number_of_scales; if (idfc >= 0) { if (ixi <= nxi) { xi = tedf->get_scale(ixi - 1); -- GitLab