Commit 098577ec authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Define SphereOutputInfo headers

parent ba8afd35
Loading
Loading
Loading
Loading
+185 −0
Original line number Original line Diff line number Diff line
@@ -969,4 +969,189 @@ public:
};
};
// >>> END OF OUTPUT FOR INCLUSION <<<
// >>> END OF OUTPUT FOR INCLUSION <<<


// >>> OUTPUT FOR SPHERE <<<
class SphereOutputInfo {
protected:
  //! \brief Number of incident azimuth calculations.
  int _num_theta;
  //! \brief Number of scattered azimuth calculations.
  int _num_thetas;
  //! \brief Number of incident elevation calculations.
  int _num_phi;
  //! \brief Number of scattered elevation calculations.
  int _num_phis;
  //! \brief ID of the first computed wavelength
  int _first_xi;
  
  /*! \brief Write the output to a HDF5 file.
   *
   * \param file_name: `const string &` Path to the output to be written.
   * \return result: `int` Exit code (0 if successful).
   */
  int write_hdf5(const std::string &file_name);
  
  /*! \brief Write the output to a legacy text file.
   *
   * This function takes care of writing the output using the legacy
   * formatted ASCII structure. If the output file does not exist, it
   * is created. If it exists, the new content is overwritten.
   *
   * \param output: `const string &` Path to the output to be written.
   * \return result: `int` Exit code (0 if successful).
   */
  int write_legacy(const std::string &output);
  
public:
  //! \brief Read-only view on the ID of the first scale
  const int &first_xi = _first_xi;
  //! \brief Maximum field expansion order.
  int lm;
  //! \brief Maximum coefficient matrix dimension.
  np_int mxndm;
  //! \brief Incident polarization flag.
  int inpol;
  //! \brief Number of points for transition layer integration.
  int npnt;
  //! \brief Number of points for non-transition layer integration.
  int npntts;
  //! \brief Flag for intensity.
  int iavm;
  //! \brief Flag for reference to meridional plane.
  int isam;
  //! \brief Flag for dielectric function definition.
  int idfc;
  //! \brief First incident radiation azimuth angle.
  double th;
  //! \brief Incident radiation azimuth angle step.
  double thstp;
  //! \brief Last incident radiation azimuth angle.
  double thlst;
  //! \brief First scattered radiation azimuth angle.
  double ths;
  //! \brief Scattered radiation azimuth angle step.
  double thsstp;
  //! \brief Last scattered radiation azimuth angle.
  double thslst;
  //! \brief First incident radiation elevation angle.
  double ph;
  //! \brief Incident radiation elevation angle step.
  double phstp;
  //! \brief Last incident radiation elevation angle.
  double phlst;
  //! \brief First scattered radiation elevation angle.
  double phs;
  //! \brief Scattered radiation elevation angle step.
  double phsstp;
  //! \brief Last scattered radiation elevation angle.
  double phslst;
  //! \brief Number of directions to be explicitly solved.
  int ndirs;
  //! \brief Refractive index of external medium.
  double exri;
  //! \brief Number of scales (wavelengths)
  int nxi;
  //! \brief Number of scales handled by the current process.
  int xi_block_size;
  //! \brief Index of the wavelength for T-matrix output.
  int jwtm;
  //! \brief Vector of scale (wavelength) indices.
  int *vec_jxi;
  //! \brief Vector of error severities (0 - success, 1 - HJV, 2 - DME).
  short *vec_ier;
  //! \brief Vector of vacuum wave numbers.
  double *vec_vk;
  //! \brief Vector of computed scales.
  double *vec_xi;
  //! \brief Vector of sphere sizes (one for every scale).
  double *vec_sphere_sizes;
  //! \brief Vector of sphere refractive indices  (one for every scale).
  dcomplex *vec_sphere_ref_indices;
  
  /*! \brief `SphereOutputInfo` default instance constructor.
   *
   * \param sc: `ScattererConfiguration *` Pointer to a `ScattererConfiguration` instance.
   * \param gc: `GeometryConfiguration *` Pointer to a `GeometryConfiguration` instance.
   * \param mpidata: `const mixMPI*` Pointer to a mixMPI instance.
   * \param first_xi: `int` Index of the first scale in output (optional, default is 1).
   * \param xi_length: `int` Number of scales tobe included in output (optional, default is 0, meaning all).
   */   
  SphereOutputInfo(
    ScattererConfiguration *sc, GeometryConfiguration *gc,
    const mixMPI *mpidata, int first_xi = 1, int xi_length = 0
  );

  /*! \brief `SphereOutputInfo` constructor from HDF5 input.
   *
   * \param hdf5_file_name: `const string &` Path to the HDF5 file to be read.
   */   
  SphereOutputInfo(const std::string &hdf5_file_name);

  /*! \brief `InclusionOutputInfo` instance destroyer.
   */
  ~SphereOutputInfo();

  /*! \brief Estimate the size of the structure that would be built for given input.
   *
   * \param sc: `ScattererConfiguration *` Pointer to a `ScattererConfiguration` instance.
   * \param gc: `GeometryConfiguration *` Pointer to a `GeometryConfiguration` instance.
   * \param first_xi: `int` Index of the first scale in output (optional, default is 0).
   * \param xi_length: `int` Number of scales tobe included in output (optional, default is all).
   * \return size: `long` Estimated instance size in bytes.
   */
  static long compute_size(
    ScattererConfiguration *sc, GeometryConfiguration *gc,
    int first_xi = 0, int xi_length = 0
  );
  
  /*! \brief Get the size of a `ClusterOutputInfo` instance in bytes.
   *
   * \return size: `long` Estimated instance size in bytes.
   */
  long compute_size();

  /*! \brief Insert in the current output data the data of another block.
   *
   * \param rhs: `const SphereOutputInfo &` Reference to the source data block.
   * \return result: `int` Exit code (0 if successful).
   */
  int insert(const SphereOutputInfo &rhs);

  /*! \brief Write the output to a file.
   *
   * \param output: `const string &` Path to the output to be written.
   * \param format: `const string &` Output format (one of LEGACY or HDF5).
   * \return result: `int` Exit code (0 if successful).
   */
  int write(const std::string &output, const std::string &format);

#ifdef MPI_VERSION
  /*! \brief Receive output data from worker processes.
   *
   * This function is invoked by the MPI rank-0 process to fetch the
   * output data produced by higher rank processes. When calling this
   * function, process 0 halts until a valid data chunk is transmitted
   * by the queried process.
   *
   * \param mpidata: `const mixMPI*` Pointer to a `mixMPI` instance.
   * \param pid: `int` Rank of the process that is transmitting data.
   * \return result: `int` An exit code (0 for success).
   */
  int mpireceive(const mixMPI* mpidata, int pid);

  /*! \brief Send output data to process 0.
   *
   * This function is invoked by non-zero ranked MPI processes when
   * they are ready to send back the output data. When a process meets
   * this function call, it halts until MPI process 0 asks for the
   * data transmission.
   *
   * \param mpidata: `const mixMPI*` Pointer to a `mixMPI` instance.
   * \param pid: `int` Rank of the process that is transmitting data.
   * \return result: `int` An exit code (0 for success).
   */
  int mpisend(const mixMPI *mpidata);
#endif // MPI_VERSION
};
// >>> END OF OUTPUT FOR SPHERE <<<

#endif // INCLUDE_OUTPUTS_H_
#endif // INCLUDE_OUTPUTS_H_