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

Build COMMON objects from configuration structures

parent 88866a20
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -61,8 +61,11 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
 *  \param data_file: `string` Name of the input data file.
 *  \param output_path: `string` Directory to write the output files in.
 */
void cluster(string config_file, string data_file, string output_path) {
void cluster(const string& config_file, const string& data_file, const string& output_path) {
  chrono::time_point<chrono::high_resolution_clock> t_start = chrono::high_resolution_clock::now();
  string timing_name = output_path + "/c_timing.log";
  FILE *timing_file = fopen(timing_name.c_str(), "w");
  Logger *time_logger = new Logger(LOG_DEBG, timing_file);
  Logger *logger = new Logger(LOG_INFO);
  logger->log("INFO: making legacy configuration...", LOG_INFO);
  ScattererConfiguration *sconf = NULL;
@@ -121,7 +124,7 @@ void cluster(string config_file, string data_file, string output_path) {
    if (le > lm) lm = le;
    C1 *c1 = new C1(gconf, sconf);
    C3 *c3 = new C3();
    C4 *c4 = new C4(li, le, nsph);
    C4 *c4 = new C4(gconf);
    C1_AddOns *c1ao = new C1_AddOns(c4);
    // End of add-ons initialization
    C6 *c6 = new C6(c4->lmtpo);
@@ -131,9 +134,10 @@ void cluster(string config_file, string data_file, string output_path) {
    dcomplex arg = 0.0 + 0.0 * I;
    dcomplex ccsam = 0.0 + 0.0 * I;
    int configurations = (int)sconf->get_param("configurations");
    C2 *c2 = new C2(nsph, configurations, npnt, npntts);
    C2 *c2 = new C2(gconf, sconf);
    np_int ndit = 2 * nsph * c4->nlim;
    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");
    const int ndi = c4->nsph * c4->nlim;
    C9 *c9 = new C9(ndi, c4->nlem, 2 * ndi, 2 * c4->nlem);
    double *gaps = new double[nsph]();
@@ -802,6 +806,9 @@ void cluster(string config_file, string data_file, string output_path) {
  string message = "Calculation lasted " + to_string(elapsed.count()) + ".\n";
  logger->log(message);
  logger->log("Finished: output written to " + output_path + "/c_OCLU\n");
  time_logger->log(message);
  fclose(timing_file);
  delete time_logger;
  delete logger;
}

+12 −9
Original line number Diff line number Diff line
@@ -140,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.
   *
@@ -216,14 +214,19 @@ public:
  //! \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();
};
+20 −17
Original line number Diff line number Diff line
@@ -366,11 +366,14 @@ C1_AddOns::~C1_AddOns() {
  delete[] ecsc;
}

C2::C2(int ns, int _nl, int npnt, int npntts) {
  nsph = ns;
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");
  int max_n = (npnt > npntts) ? npnt : npntts;
  nhspo = 2 * max_n - 1;
  nl = _nl;
  nl = (int)sconf->get_param("configurations");
  if (nsph == 1 && nl == 1) nl = 5;
  ris = new dcomplex[nhspo]();
  dlri = new dcomplex[nhspo]();
  vkt = new dcomplex[nsph]();
@@ -436,12 +439,12 @@ C3::~C3() {
  delete[] tsas;
}

C4::C4(int _li, int _le, int _nsph) {
    li = _li;
    le = _le;
C4::C4(GeometryConfiguration *gconf) {
  li = (int)gconf->get_param("li");
  le = (int)gconf->get_param("le");
  lm = (li > le) ? li : le;
  nv3j = (lm * (lm  + 1) * (2 * lm + 7)) / 6;
    nsph = _nsph;
  nsph = (int)gconf->get_param("nsph");
  // The following is needed to initialize C1_AddOns
  litpo = li + li + 1;
  litpos = litpo * litpo;
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ using namespace std;
 *  \param data_file: `string` Name of the input data file.
 *  \param output_path: `string` Directory to write the output files in.
 */
void sphere(string config_file, string data_file, string output_path) {
void sphere(const string& config_file, const string& data_file, const string& output_path) {
  Logger *logger = new Logger(LOG_INFO);
  dcomplex arg, s0, tfsas;
  double th, ph;
@@ -133,7 +133,7 @@ void sphere(string config_file, string data_file, string output_path) {
    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");
    C2 *c2 = new C2(nsph, 5, npnt, npntts);
    C2 *c2 = new C2(gconf, sconf);
    argi = new double[1];
    args = new double[1];
    gaps = new double[2];