Commit 31f6bb9a authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Introduce the trapping configuration class

parent 257c3885
Loading
Loading
Loading
Loading

src/include/tfrfme.h

0 → 100644
+115 −0
Original line number Diff line number Diff line
/*! \file tfrfme.h
 *
 * \brief Representation of the trapping configuration objects.
 */

#ifndef INCLUDE_TFRFME_H_
#define INCLUDE_TFRFME_H_

/*! \brief Class to represent the trapping configuration.
 */
class TFRFME {
 private:
  //! NLMMT = 2 * LM * (LM + 2)
  int nlmmt;
  //! NRVC = NXV * NYV * NZV
  int nrvc;
  
 protected:
  //! Field expansion mode identifier.
  int lmode;
  //! Maximim field expansion order;
  int lm;
  //! QUESTION: definition?
  int nkv;
  //! Number of computed X coordinates.
  int nxv;
  //! Number of computed Y coordinates.
  int nyv;
  //! Number of computed Z coordinates.
  int nzv;
  //! Wave number in scale units
  double vk;
  //! External medium refractive index
  double exri;
  //! QUESTION: definition?
  double an;
  //! QUESTION: definition?
  double ff;
  //! QUESTION: definition?
  double tra;
  //! QUESTION: definition?
  double spd;
  //! QUESTION: definition?
  double frsh;
  //! QUESTION: definition?
  double exril;
  //! Vector of computed x positions
  double *xv;
  //! Vector of computed y positions
  double *yv;
  //! Vector of computed z positions
  double *zv;
  //! QUESTION: definition?
  complex<double> **wsum;

 public:
  /*! \briesf Trapping configuration instance constructor.
   */
  TFRFME(
	 int _lmode, int _lm, int _nkv, int _nxv, int _nyv, int _nzv
);
  
  /*! \briesf Trapping configuration instance destroyer.
   */
  ~TFRFME();

  /*! \briesf Load a trapping configuration instance from binary file.
   *
   * \param file_name: `string` Name of the file.
   * \param format: `string` Format of the file (can be either "HDF5"
   * or "LGEACY". Default is "LEGACY").
   * \return instance: `TFRFME *` Pointer to anewly created configuration
   * instance.
   */
  TFRFME* from_binary(std::string file_name, std::string format="LEGACY");

  /*! \brief Get an element from the WSUM matrix.
   *
   * \param row: `int` Row index of the element to be read.
   * \param col: `int` Column index of the element to be read.
   * \return value: `complex<double>` The value of the requested element.
   */
  std::complex<double> get_matrix_element(int row, int col);

  /*! \brief Get a configuration parameter.
   *
   * \param param_name: `string` Name of the parameter.
   * \return value: `double` The value of the requested parameter.
   */
  double get_param(std::string param_name);

  /*! \brief Set an element in the WSUM matrix.
   *
   * \param row: `int` Row index of the element to be read.
   * \param col: `int` Column index of the element to be read.
   * \param value: `complex<double>` The value to be placed in the matrix.
   */
  void set_matrix_element(int row, int col, std::complex<double> value);
  
  /*! \brief Set a configuration parameter.
   *
   * \param param_name: `string` Name of the parameter.
   * \param value: `double` Value to be stored as parameter.
   */
  void set_param(std::string param_name, double value);

  /*! \briesf Write a trapping configuration instance to binary file.
   *
   * \param file_name: `string` Name of the file.
   * \param format: `string` Format of the file (can be either "HDF5"
   * or "LGEACY". Default is "LEGACY").
   */
  void write_binary(std::string file_name, std::string format="LEGACY");
};
#endif

src/libnptm/tfrfme.cpp

0 → 100644
+69 −0
Original line number Diff line number Diff line
/*! \file tfrfme.cpp
 *
 * \brief Implementation of the trapping configuration objects.
 */

#include<complex>
#include<string>

#ifndef INCLUDE_TFRFME_H_
#include "../include/tfrfme.cpp"
#endif

using namespace std;

TFRFME::TFRFME(int _lmode, int _lm, int _nkv, int _nxv, int _nyv, int _nzv) {
  lmode = _lmode;
  lm = _lm;
  nkv = _nkv;
  nxv = _nxv;
  nyv = _nyv;
  nzv = _nzv;
  vk = 0.0;
  exri = 0.0;
  an = 0.0;
  ff = 0.0;
  tra = 0.0;
  spd = 0.0;
  frsh = 0.0;
  exril = 0.0;

  // Array initialization
  xv = new double[nxv]();
  yv = new double[nyv]();
  zv = new double[nzv]();
  nlmmt = lm * (lm + 2) * 2;
  nrvc = nxv * nyv * nzv;
  wsum = new complex<double>*[nlmmt];
  for (int wi = 0; wi < nlmmt; wi++) wsum[wi] = new complex<double>[nrvc]();
}

TFRFME::~TFRFME() {
  delete[] xv;
  delete[] yv;
  delete[] zv;
  for (int wi = nlmmt - 1; wi > -1; wi--) delete[] wsum[wi];
  delete[] wsum;
}

TFRFME::TFRFME* from_binary(string file_name, string format) {
  TFRFME *instance = NULL;
  return instance;
}

TFRFME::double get_param(string param_name) {
  double value;
  if (param_name.compare("exri") == 0) value = exri;
  else if (param_name.compare("an") == 0) value = an;
  else if (param_name.compare("ff") == 0) value = ff;
  else if (param_name.compare("tra") == 0) value = tra;
  else if (param_name.compare("spd") == 0) value = spd;
  else if (param_name.compare("frsh") == 0) value = frsh;
  else if (param_name.compare("exril") == 0) value = exril;
  //TODO: add else clause with exception.
  return value;
}

TFRFME::void write_binary(string file_name, string format) {
  return;
}
+1 −1

File changed.

Contains only whitespace changes.