Skip to content
Snippets Groups Projects
Commit 90ee07a0 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Implement InclusionOutputInfo class

parent 420521bd
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
#ifndef INCLUDE_OUTPUTS_H_
#define INCLUDE_OUTPUTS_H_
// >>> OUTPUT FOR CLUSTER <<<
/*! \brief Class to collect output information for scattering from clusters.
*
* The results of the calculation can be saved in different formats.
......@@ -54,12 +55,7 @@ protected:
*
* 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 appended to the old
* one, without overwriting. This is useful for a simpler handling
* of multi-process output combination, provided that only one process
* writes to the output file at any given time. Simultaneous write
* operations by different processes is not supported by the legacy
* ASCII format.
* is created. If it exists, the new content overwritten.
*
* \param output: `const string &` Path to the output to be written.
* \return result: `int` Exit code (0 if successful).
......@@ -500,7 +496,7 @@ public:
/*! \brief Insert in the current output data the data of another block.
*
* \param rhs: `const ClusterOutputData &` Reference to the source data block.
* \param rhs: `const ClusterOutputInfo &` Reference to the source data block.
* \return result: `int` Exit code (0 if successful).
*/
int insert(const ClusterOutputInfo &rhs);
......@@ -541,4 +537,436 @@ public:
int mpisend(const mixMPI *mpidata);
#endif // MPI_VERSION
};
// >>> END OF OUTPUT FOR CLUSTER <<<
// >>> OUTPUT FOR INCLUSION <<<
/*! \brief Class to collect output information for scattering from particle with inclusions.
*
* The results of the calculation can be saved in different formats.
* It is therefore convenient to have a proper memory structure that
* allows for storing the results and flushing them in any of the
* permitted formats with just one operation. The purpose of the
* `InclusionOutputInfo` class is to provide a wrapper for the output
* of the particle with inclusions scattering solver.
*/
class InclusionOutputInfo {
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 Number of spheres in the aggregate.
int nsph;
//! \brief Maximum internal field expansion order.
int li;
//! \brief Maximum external field expansion order.
int le;
//! \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 Vector of spherical components X Cartesian coordinates.
double *vec_x_coords;
//! \brief Vector of spherical components Y Cartesian coordinates.
double *vec_y_coords;
//! \brief Vector of spherical components Z Cartesian coordinates.
double *vec_z_coords;
//! \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 Number of sphere configurations.
int configurations;
//! \brief Vector of sphere sizes (all configurations for every scale).
double *vec_sphere_sizes;
//! \brief Vector of sphere refractive indices (all configurations for every scale).
dcomplex *vec_sphere_ref_indices;
//! \brief Vector of particle scattering cross-sections (parallel polarization).
double *vec_scs1;
//! \brief Vector of particle scattering cross-sections (perpendicular polarization).
double *vec_scs2;
//! \brief Vector of particle absorption cross-sections (parallel polarization).
double *vec_abs1;
//! \brief Vector of particle absorption cross-sections (perpendicular polarization).
double *vec_abs2;
//! \brief Vector of particle extinction cross-sections (parallel polarization).
double *vec_exs1;
//! \brief Vector of particle extinction cross-sections (perpendicular polarization).
double *vec_exs2;
//! \brief Vector of particle albedos (parallel polarization).
double *vec_albeds1;
//! \brief Vector of particle albedos (perpendicular polarization).
double *vec_albeds2;
//! \brief Vector of particle scattering-to-geometric cross-sections (parallel polarization).
double *vec_scsrt1;
//! \brief Vector of particle scattering-to-geometric cross-sections (perpendicular polarization).
double *vec_scsrt2;
//! \brief Vector of particle absorption-to-geometric cross-sections (parallel polarization).
double *vec_absrt1;
//! \brief Vector of particle absorption-to-geometric cross-sections (perpendicular polarization).
double *vec_absrt2;
//! \brief Vector of particle extinction-to-geometric cross-sections (parallel polarization).
double *vec_exsrt1;
//! \brief Vector of particle extinction-to-geometric cross-sections (perpendicular polarization).
double *vec_exsrt2;
//! \brief Vector of particle QSCHU (parallel polarization).
double *vec_qschu1;
//! \brief Vector of particle QSCHU (perpendicular polarization).
double *vec_qschu2;
//! \brief Vector of particle PSCHU (parallel polarization).
double *vec_pschu1;
//! \brief Vector of particle PSCHU (perpendicular polarization).
double *vec_pschu2;
//! \brief Vector of particle S0MAG (parallel polarization).
double *vec_s0mag1;
//! \brief Vector of particle S0MAG (perpendicular polarization).
double *vec_s0mag2;
//! \brief Vector of particle average asymmetry parameter (parallel polarization).
double *vec_cosav1;
//! \brief Vector of particle average asymmetry parameter (perpendicular polarization).
double *vec_cosav2;
//! \brief Vector of particle average radiation pressure force (N - parallel polarization).
double *vec_raprs1;
//! \brief Vector of particle average radiation pressure force (N - perpendicular polarization).
double *vec_raprs2;
//! \brief Vector of particle average radiation force along incidence direction (N - parallel polarization).
double *vec_fk1;
//! \brief Vector of particle average radiation force along incidence direction (N - perpendicular polarization).
double *vec_fk2;
//! \brief Vector of forward scattering amplitudes for polarization parallel to incidence (one per scale).
dcomplex *vec_fsas11;
//! \brief Vector of forward scattering amplitudes for polarization perpendicular to incidence (one per scale).
dcomplex *vec_fsas21;
//! \brief Vector of forward scattering amplitudes for polarization parallel to incidence (one per scale).
dcomplex *vec_fsas22;
//! \brief Vector of forward scattering amplitudes for polarization perpendicular to incidence (one per scale).
dcomplex *vec_fsas12;
//! \brief Vector of incidence azimuth directions (one per incidence azimuth).
double *vec_dir_tidg;
//! \brief Vector of incidence elevation directions (one per incidence elevation).
double *vec_dir_pidg;
//! \brief Vector of scattering azimuth directions (one per scattering azimuth).
double *vec_dir_tsdg;
//! \brief Vector of scattering elevation directions (one per scattering elevation).
double *vec_dir_psdg;
//! \brief Vector of scattering angles (one per direction).
double *vec_dir_scand;
//! \brief Control parameter for incidence plane referred to meridional plane (one per direction).
double *vec_dir_cfmp;
//! \brief Control parameter for scattering plane referred to meridional plane (one per direction).
double *vec_dir_sfmp;
//! \brief Control parameter for incidence plane referred to scattering plane (one per direction).
double *vec_dir_cfsp;
//! \brief Control parameter for scattering plane referred to scattering plane (one per direction).
double *vec_dir_sfsp;
//! \brief Components of the unitary vector perpendicular to incidence plane (three per direction).
double *vec_dir_un;
//! \brief Components of the unitary vector perpendicular to scattering plane (three per direction).
double *vec_dir_uns;
//! \brief Vector of particle differential scattering cross-sections (parallel polarization).
double *vec_dir_scs1;
//! \brief Vector of particle differential scattering cross-sections (perpendicular polarization).
double *vec_dir_scs2;
//! \brief Vector of particle differential absorption cross-sections (parallel polarization).
double *vec_dir_abs1;
//! \brief Vector of particle differential absorption cross-sections (perpendicular polarization).
double *vec_dir_abs2;
//! \brief Vector of particle differential extinction cross-sections (parallel polarization).
double *vec_dir_exs1;
//! \brief Vector of particle differential extinction cross-sections (perpendicular polarization).
double *vec_dir_exs2;
//! \brief Vector of particle differential albedos (parallel polarization).
double *vec_dir_albeds1;
//! \brief Vector of particle differential albedos (perpendicular polarization).
double *vec_dir_albeds2;
//! \brief Vector of particle differential scattering-to-geometric cross-sections (parallel polarization).
double *vec_dir_scsrt1;
//! \brief Vector of particle differential scattering-to-geometric cross-sections (perpendicular polarization).
double *vec_dir_scsrt2;
//! \brief Vector of particle differential absorption-to-geometric cross-sections (parallel polarization).
double *vec_dir_absrt1;
//! \brief Vector of particle differential absorption-to-geometric cross-sections (perpendicular polarization).
double *vec_dir_absrt2;
//! \brief Vector of particle differential extinction-to-geometric cross-sections (parallel polarization).
double *vec_dir_exsrt1;
//! \brief Vector of particle differential extinction-to-geometric cross-sections (perpendicular polarization).
double *vec_dir_exsrt2;
//! \brief Vector of particle differential forward scattering amplitude with polarization parallel to parallel incidence field.
dcomplex *vec_dir_fsas11;
//! \brief Vector of particle differential forward scattering amplitude with polarization perpendicular to the parallel incidence field.
dcomplex *vec_dir_fsas21;
//! \brief Vector of particle differential forward scattering amplitude with polarization perpendicular to perpendicular incidence field.
dcomplex *vec_dir_fsas12;
//! \brief Vector of particle differential forward scattering amplitude with polarization parallel the perpendicular incidence field.
dcomplex *vec_dir_fsas22;
//! \brief Vector of particle differential scattering amplitude with polarization parallel to parallel incidence field.
dcomplex *vec_dir_sas11;
//! \brief Vector of particle differential scattering amplitude with polarization perpendicular to the parallel incidence field.
dcomplex *vec_dir_sas21;
//! \brief Vector of particle differential scattering amplitude with polarization perpendicular to perpendicular incidence field.
dcomplex *vec_dir_sas12;
//! \brief Vector of particle differential scattering amplitude with polarization parallel the perpendicular incidence field.
dcomplex *vec_dir_sas22;
//! \brief Vector of differential particle QSCHU (parallel polarization).
double *vec_dir_qschu1;
//! \brief Vector of differential particle QSCHU (perpendicular polarization).
double *vec_dir_qschu2;
//! \brief Vector of differential particle PSCHU (parallel polarization).
double *vec_dir_pschu1;
//! \brief Vector of differential particle PSCHU (perpendicular polarization).
double *vec_dir_pschu2;
//! \brief Vector of particle differential S0MAG (parallel polarization).
double *vec_dir_s0mag1;
//! \brief Vector of particle differential S0MAG (perpendicular polarization).
double *vec_dir_s0mag2;
//! \brief Vector of differential particle asymmetry parameters (parallel polarization).
double *vec_dir_cosav1;
//! \brief Vector of differential particle asymmetry parameters (perpendicular polarization).
double *vec_dir_cosav2;
//! \brief Vector of differential particle radiation pressure forces (1).
double *vec_dir_rapr1;
//! \brief Vector of differential particle radiation pressure forces (1).
double *vec_dir_rapr2;
//! \brief Vector of differential radiation pressure force components along the polarization direction (parallel polarization).
double *vec_dir_fl1;
//! \brief Vector of differential radiation pressure force components along the polarization direction (perpendicular polarization).
double *vec_dir_fl2;
//! \brief Vector of differential radiation pressure force components perpendicular to the polarization direction (parallel polarization).
double *vec_dir_fr1;
//! \brief Vector of differential radiation pressure force components perpendicular to the polarization direction (perpendicular polarization).
double *vec_dir_fr2;
//! \brief Vector of differential radiation pressure force components along the incidence direction (parallel polarization).
double *vec_dir_fk1;
//! \brief Vector of differential radiation pressure force components along the incidence direction (perpendicular polarization).
double *vec_dir_fk2;
//! \brief Vector of differential radiation pressure force components along the X axis (parallel polarization).
double *vec_dir_fx1;
//! \brief Vector of differential radiation pressure force components along the X axis (perpendicular polarization).
double *vec_dir_fx2;
//! \brief Vector of differential radiation pressure force components along the Y axis (parallel polarization).
double *vec_dir_fy1;
//! \brief Vector of differential radiation pressure force components along the Y axis (perpendicular polarization).
double *vec_dir_fy2;
//! \brief Vector of differential radiation pressure force components along the Z axis (parallel polarization).
double *vec_dir_fz1;
//! \brief Vector of differential radiation pressure force components along the Z axis (perpendicular polarization).
double *vec_dir_fz2;
//! \brief Vector of differential extinction contribution to radiation torque components along the polarization direction (parallel polarization).
double *vec_dir_tqel1;
//! \brief Vector of differential extinction contribution to radiation torque components along the polarization direction (perpendicular polarization).
double *vec_dir_tqel2;
//! \brief Vector of differential extinction contribution to radiation torque components perpendicular to the polarization direction (parallel polarization).
double *vec_dir_tqer1;
//! \brief Vector of differential extinction contribution to radiation torque components perpendicular to the polarization direction (perpendicular polarization).
double *vec_dir_tqer2;
//! \brief Vector of differential extinction contribution to radiation torque components along the incidence direction (parallel polarization).
double *vec_dir_tqek1;
//! \brief Vector of differential extinction contribution to radiation torque components along the incidence direction (perpendicular polarization).
double *vec_dir_tqek2;
//! \brief Vector of differential extinction contribution to radiation torque components along the X axis (parallel polarization).
double *vec_dir_tqex1;
//! \brief Vector of differential extinction contribution to radiation torque components along the X axis (perpendicular polarization).
double *vec_dir_tqex2;
//! \brief Vector of differential extinction contribution to radiation torque components along the Y axis (parallel polarization).
double *vec_dir_tqey1;
//! \brief Vector of differential extinction contribution to radiation torque components along the Y axis (perpendicular polarization).
double *vec_dir_tqey2;
//! \brief Vector of differential extinction contribution to radiation torque components along the Z axis (parallel polarization).
double *vec_dir_tqez1;
//! \brief Vector of differential extinction contribution to radiation torque components along the Z axis (perpendicular polarization).
double *vec_dir_tqez2;
//! \brief Vector of differential scattering contribution to radiation torque components along the polarization direction (parallel polarization).
double *vec_dir_tqsl1;
//! \brief Vector of differential scattering contribution to radiation torque components along the polarization direction (perpendicular polarization).
double *vec_dir_tqsl2;
//! \brief Vector of differential scattering contribution to radiation torque components perpendicular to the polarization direction (parallel polarization).
double *vec_dir_tqsr1;
//! \brief Vector of differential scattering contribution to radiation torque components perpendicular to the polarization direction (perpendicular polarization).
double *vec_dir_tqsr2;
//! \brief Vector of differential scattering contribution to radiation torque components along the incidence direction (parallel polarization).
double *vec_dir_tqsk1;
//! \brief Vector of differential scattering contribution to radiation torque components along the incidence direction (perpendicular polarization).
double *vec_dir_tqsk2;
//! \brief Vector of differential scattering contribution to radiation torque components along X axis (parallel polarization).
double *vec_dir_tqsx1;
//! \brief Vector of differential scattering contribution to radiation torque components along X axis (perpendicular polarization).
double *vec_dir_tqsx2;
//! \brief Vector of differential scattering contribution to radiation torque components along Y axis (parallel polarization).
double *vec_dir_tqsy1;
//! \brief Vector of differential scattering contribution to radiation torque components along Y axis (perpendicular polarization).
double *vec_dir_tqsy2;
//! \brief Vector of differential scattering contribution to radiation torque components along Z axis (parallel polarization).
double *vec_dir_tqsz1;
//! \brief Vector of differential scattering contribution to radiation torque components along Z axis (perpendicular polarization).
double *vec_dir_tqsz2;
//! \brief Vector of cluster Mueller transormation matrices referred to meridional plane (16 per direction per scale).
double *vec_dir_mull;
//! \brief Vector of cluster Mueller transormation matrices referred to scattering plane (16 per direction per scale).
double *vec_dir_mulllr;
/*! \brief `InclusionOutputInfo` 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).
*/
InclusionOutputInfo(
ScattererConfiguration *sc, GeometryConfiguration *gc,
const mixMPI *mpidata, int first_xi = 1, int xi_length = 0
);
/*! \brief `InclusionOutputInfo` constructor from HDF5 input.
*
* \param hdf5_file_name: `const string &` Path to the HDF5 file to be read.
*/
InclusionOutputInfo(const std::string &hdf5_file_name);
/*! \brief `InclusionOutputInfo` instance destroyer.
*/
~InclusionOutputInfo();
/*! \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 InclusionOutputInfo &` Reference to the source data block.
* \return result: `int` Exit code (0 if successful).
*/
int insert(const InclusionOutputInfo &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 INCLUSION <<<
#endif // INCLUDE_OUTPUTS_H_
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment