Commit cf88c51b authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Merge branch 'mem_struct_optimization' into 'master'

Memory structure optimization

See merge request giacomo.mulas/np_tmcode!30
parents 6172baec 08844351
Loading
Loading
Loading
Loading
+334 −933

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@

using namespace std;

extern void cluster(string config_file, string data_file, string output_path);
extern void cluster(const string& config_file, const string& data_file, const string& output_path);

/*! \brief Main program entry point.
 *
+204 −22
Original line number Diff line number Diff line
@@ -99,12 +99,10 @@ public:

  /*! \brief C1 instance constructor.
   *
   * \param ns: `int` Number of spheres.
   * \param l_max: `int` Maximum order of field expansion.
   * \param nshl: `int *` Array of number of layers in spheres.
   * \param iog: `int *` Vector of spherical units ID numbers.
   * \param gconf: `GeometryConfiguration *` Pointer to a geometry configuration object.
   * \param sconf: `ScattererConfiguration *` Pointer to a scatterer configuration object.
   */
  C1(int ns, int l_max, int *nshl, int *iog);
  C1(GeometryConfiguration *gconf, ScattererConfiguration *sconf);

  /*! \brief C1 instance constructor copying all contents from a preexisting template
   *
@@ -142,12 +140,10 @@ public:

  /*! \brief C2 instance constructor.
   *
   * \param ns: `int` Number of spheres.
   * \param nl: `int`
   * \param npnt: `int`
   * \param npntts: `int`
   * \param gconf: `GeometryConfiguration*` Pointer to a GeometryConfiguration instance.
   * \param sconf: `ScattererConfiguration*` Pointer to a ScattererConfiguration instance.
   */
  C2(int ns, int nl, int npnt, int npntts);
  C2(GeometryConfiguration *gconf, ScattererConfiguration *sconf);

  /*! \brief C2 instance constructor copying its contents from preexisting instance.
   *
@@ -193,39 +189,44 @@ public:
 */
class C4 {
public:
  //! \brief QUESTION: definition?
  //! \brief LITPO = 2 * LI + 1.
  int litpo;
  //! \brief QUESTION: definition?
  //! \brief LITPOS = LITPO * LITPO
  int litpos;
  //! \brief Maximum field expansion order plus one. QUESTION: correct?
  //! \brief LMPO = LM + 1.
  int lmpo;
  //! \brief Twice maximum field expansion order plus one. QUESTION: correct?
  //! \brief LMTPO = 2 * LM + 1.
  int lmtpo;
  //! \brief Square of `lmtpo`.
  //! \brief LMTPOS = LMTPO * LMTPO.
  int lmtpos;
  //! \brief QUESTION: definition?
  //! \brief Internal field expansion order.
  int li;
  //! \brief QUESTION: definition?
  int nlim;
  //! \brief QUESTION: definition?
  //! \brief External field expansion order.
  int le;
  //! \brief QUESTION: definition?
  int nlem;
  //! \brief Maximum field expansion order. QUESTION: correct?
  //! \brief Maximum field expansion order.
  int lm;
  //! \brief Number of spheres.
  int nsph;
  //! \brief QUESTION: definition?
  int nv3j;

  /*! \brief C3 instance constructor.
  /*! \brief C4 instance constructor.
   *
   * \param gconf: `GeometryConfiguration*` Pointer to a GeometryConfiguration instance.
   */
  C4(int li, int le, int nsph);
  /*! \brief C3 instance constructor copying its contents from a preexisting object.
  C4(GeometryConfiguration *gconf);
  
  /*! \brief C4 instance constructor copying its contents from a preexisting object.
   *
   * \param rhs: `C4&` Reference of the object to be copied.
   */
  C4(const C4& rhs);

  /*! \brief C3 instance destroyer.
  /*! \brief C4 instance destroyer.
   */
  ~C4();
};
@@ -268,6 +269,8 @@ public:
  //! \brief QUESTION: definition?
  dcomplex **am0m;
  //! \brief QUESTION: definition?
  dcomplex *am0v;
  //! \brief QUESTION: definition?
  dcomplex *vintm;
  //! \brief QUESTION: definition?
  dcomplex *vintt;
@@ -382,4 +385,183 @@ public:
   */
  ~C9();
};

/*! \brief A data structure representing the information used for a single scale
 * of the CLUSTER case.
 */
class ClusterIterationData {
public:
  //! \brief Pointer to a C1 structure.
  C1 *c1;
  //! \brief Pointer to a C1_AddOns structure.
  C1_AddOns *c1ao;
  //! \brief Pointer to a C2 structure.
  C2 *c2;
  //! \brief Pointer to a C3 structure.
  C3 *c3;
  //! brief Pointer to a C4 structure.
  C4 *c4;
  //! \brief Pointer to a C6 structure.
  C6 *c6;
  //! \brief Pointer to a C9 structure.
  C9 *c9;
  //! \brief Pointer to a formatted output file.
  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;
  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 qsfi;
  double sqsfi;
  dcomplex *am_vector;
  dcomplex **am;
  dcomplex arg;
  //! \brief Wave vector.
  double vk;
  //! \brief Wave number.
  double wn;
  double xip;

  ClusterIterationData(GeometryConfiguration *gconf, ScattererConfiguration *sconf);

  ClusterIterationData(const ClusterIterationData& rhs);

  ~ClusterIterationData();
};

/*! \brief A data structure representing the angles to be evaluated in the problem.
 *
 */
class ScatteringAngles {
protected:
  //! \brief Number of incident field azimuth angles.
  int _nth;
  //! \brief Number of scattered field azimuth angles.
  int _nths;
  //! \brief Number of incident field elevation angles.
  int _nph;
  //! \brief Number of scattered field elevation angles.
  int _nphs;
  //! \brief Number of incident field propagation angles.
  int _nk;
  //! \brief Number of scattered field propagation angles.
  int _nks;
  //! \brief Total number of field propagation angles.
  int _nkks;
  //! \brief First incident field azimuth angle.
  double _th;
  //! \brief Incident field azimuth angle increment.
  double _thstp;
  //! \brief Last incident field azimuth angle.
  double _thlst;
  //! \brief First scattered field azimuth angle.
  double _ths;
  //! \brief Scattered field azimuth angle increment.
  double _thsstp;
  //! \brief Last scattered field azimuth angle.
  double _thslst;
  //! \brief First incident field elevation angle.
  double _ph;
  //! \brief Incident field elevation angle increment.
  double _phstp;
  //! \brief Last incident field elevation angle.
  double _phlst;
  //! \brief First scattered field elevation angle.
  double _phs;
  //! \brief Scattered field elevation angle increment.
  double _phsstp;
  //! \brief Last scattered field elevation angle.
  double _phslst;
  //! \brief Azimuth scattering deflection.
  double _thsca;

public:
  //! \brief Read only view of `_nth`.
  const int& nth = _nth;
  //! \brief Read only view of `_nths`.
  const int& nths = _nths;
  //! \brief Read only view of `_nph`.
  const int& nph = _nph;
  //! \brief Read only view of `_nphs`.
  const int& nphs = _nphs;
  //! \brief Read only view of `_nk`.
  const int& nk = _nk;
  //! \brief Read only view of `_nks`.
  const int& nks = _nks;
  //! \brief Read only view of `_nkks`.
  const int& nkks = _nkks;
  //! \brief Read only view of `_th`.
  const double& th = _th;
  //! \brief Read only view of `_thstp`.
  const double& thstp = _thstp;
  //! \brief Read only view of `_thlst`.
  const double& thlst = _thlst;
  //! \brief Read only view of `_ths`.
  const double& ths = _ths;
  //! \brief Read only view of `_thsstp`.
  const double& thsstp = _thsstp;
  //! \brief Read only view of `_thslst`.
  const double& thslst = _thslst;
  //! \brief Read only view of `_ph`.
  const double& ph = _ph;
  //! \brief Read only view of `_phstp`.
  const double& phstp = _phstp;
  //! \brief Read only view of `_phlst`.
  const double& phlst = _phlst;
  //! \brief Read only view of `_phs`.
  const double& phs = _phs;
  //! \brief Read only view of `_phsstp`.
  const double& phsstp = _phsstp;
  //! \brief Read only view of `_phslst`.
  const double& phslst = _phslst;
  //! \brief Read only view of `_thsca`.
  const double& thsca = _thsca;

  /*! \brief ScatteringAngles instance constructor.
   *
   * \param gconf: `GeometryConfiguration*` Pointer to a GeometryConfiguration object.
   */
  ScatteringAngles(GeometryConfiguration *gconf);
  
  /*! \brief ScatteringAngles copy constructor.
   *
   * \param rhs: `ScatteringAngles&` Reference to the ScatteringAngles object to be copied.
   */
  ScatteringAngles(const ScatteringAngles &rhs);
};

#endif
+225 −111

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -32,6 +32,6 @@
 * \return array_lines `string*` An array of strings, one for each input
 * file line.
 */
std::string *load_file(std::string file_name, int *count);
std::string *load_file(const std::string& file_name, int *count);

#endif /* INCLUDE_PARSERS_H_ */
Loading