diff --git a/qpms/scatsystem.h b/qpms/scatsystem.h index 9cca6f1..9706aac 100644 --- a/qpms/scatsystem.h +++ b/qpms/scatsystem.h @@ -11,6 +11,7 @@ #ifndef QPMS_SCATSYSTEM_H #define QPMS_SCATSYSTEM_H #include "qpms_types.h" +#include "vswf.h" #include @@ -319,6 +320,33 @@ complex double *qpms_orbit_irrep_basis( /// The index of the irreducible representation of sym. const qpms_iri_t iri); + +/// Creates an incident field vector in the full basis, given a function that evaluates the field expansions at points. +/** TODO detailed doc! + * \returns target_full if target_full was not NULL, otherwise the newly allocated array. */ +complex double *qpms_scatsys_incident_field_vector_full( + /// Target array. If NULL, a new one is allocated. + /** The length of the array is ss->fecv_size. */ + complex double *target_full, + const qpms_scatsys_t *ss, + qpms_incfield_t field_at_point, + const void *args, ///< Pointer passed as the last argument to (*field_at_point)() + bool add ///< If true, add to target_full; rewrite target_full if false. + ); + +/// Creates a (partial) incident field vector in the symmetry-adapted basis, given a function that evaluates the field expansions at points. +/** TODO detailed doc! */ +complex double *qpms_scatsys_incident_field_vector_irrep_packed( + /// Target array. If NULL, a new one is allocated. + /** The length of the array is ss->fecv_size. */ + complex double *target_full, + const qpms_scatsys_t *ss, + const qpms_iri_t iri, ///< The index of given irreducible representation of ss->sym. + qpms_incfield_t field_at_point, + const void *args, ///< Pointer passed as the last argument to (*field_at_point)() + bool add ///< If true, add to target_full; rewrite target_full if false. + ); + /// Evaluates scattered fields (corresponding to a given excitation vector) at a given point. /** * By scattered field, one assumes a linear combination of positive-Hankel-type @@ -327,7 +355,7 @@ complex double *qpms_orbit_irrep_basis( * \return Complex electric field at the point defined by \a where. */ ccart3_t qpms_scatsys_eval_E(const qpms_scatsys_t *ss, - const complex double *coeff_vector, ///< A full-length excitation vector. + const complex double *coeff_vector, ///< A full-length excitation vector (outgoing wave coefficients). cart3_t where, ///< Evaluation point. complex double k ///< Wave number. ); diff --git a/qpms/vswf.h b/qpms/vswf.h index 23d1224..f6aff45 100644 --- a/qpms/vswf.h +++ b/qpms/vswf.h @@ -11,6 +11,18 @@ #include "qpms_types.h" #include +// -------------- Typedefs (function prototypes) for qpms_vswf_spec_t ---------------------- + +/// Calculates the (regular VSWF) expansion coefficients of an external incident field. +typedef qpms_errno_t (*qpms_incfield_t)( + /// Target non-NULL array of the regular VSWF expansion coefficients of length bspec->n. + complex double *target, + const qpms_vswf_set_spec_t *bspec, + const cart3_t evalpoint, ///< Point at which the VSWF expansion is made. + const void *args, ///< Pointer to additional function-specific arguments. + bool add ///< If true, add to target; rewrite target if false. +); + // ---------------Methods for qpms_vswf_spec_t----------------------- // /// Creates a qpms_vswf_set_spec_t structure with an empty list of wave indices. @@ -61,6 +73,33 @@ csphvec_t qpms_eval_uvswf(const qpms_vswf_set_spec_t *setspec, csph_t kr, ///< Evaluation point. qpms_bessel_t btyp); + +// --- qpms_incfield_t instances and their arguments + +typedef struct qpms_incfield_planewane_params_t { + bool use_cartesian; ///< If true, wave direction k and amplitude E are specified in cartesian coordinates (via k.cart, E.cart). If false, k is specified in spherical coordinates and E are specified in the corresponding geographical coordinates (via k.sph, E.sph). + bool allow_longitudinal; ///< Whether to include longitudinal part or not (if k and E are not orthogonal). Usually false makes sense. + union { + ccart3_t cart; + csph_t sph; + } k; ///< Wave vector. + union { + ccart3_t cart; + csphvec_t sph; + } E; ///< Electric field amplitude at origin. +} qpms_incfield_planewave_params_t; + + +/// Calculates the (regular VSWF) expansion coefficients of a plane wave. +qpms_errno_t qpms_incfield_planewave( + /// Target non-NULL array of the regular VSWF expansion coefficients of length bspec->n. + complex double *target, + const qpms_vswf_set_spec_t *bspec, + const cart3_t evalpoint, ///< Point at which the VSWF expansion is made. + const void *args, ///< Pointer to additional function-specific arguments. + bool add ///< If true, add to target; rewrite target if false. +); + // ----------------------------------------------------------------------- /// Electric wave N.