QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
scuffgen.h File Reference

External scuff-em T-matrix generator. More...

#include "tmatrices.h"
#include "groups.h"
Include dependency graph for scuffgen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  qpms_scuffgen_shape_t
 Shape dimensions for the scuff generator, as parsed from the scatspec. More...
 
struct  qpms_scuffgen_params_t
 Configuration of the external scuff-em T-matrix generator. More...
 

Macros

#define QPMS_SCUFFGEN_UM   1e-6
 
#define QPMS_SCUFFGEN_VERSION   "1"
 

Typedefs

typedef struct qpms_scuffgen_shape_t qpms_scuffgen_shape_t
 Shape dimensions for the scuff generator, as parsed from the scatspec.
 
typedef struct qpms_scuffgen_params_t qpms_scuffgen_params_t
 Configuration of the external scuff-em T-matrix generator.
 

Functions

char * qpms_scuffgen_resolve_tool (const char *envvar, const char *default_name)
 Resolves an external tool executable.
 
qpms_errno_t qpms_tmatrix_generator_scuffgen (qpms_tmatrix_t *t, _Complex double omega, const void *params)
 The scuff-em T-matrix generator for qpms_tmatrix_generator_t.
 
qpms_errno_t qpms_scuffgen_emit_geo (const qpms_scuffgen_shape_t *shape, double lc, FILE *f)
 Emits the gmsh .geo file content for the given shape (in microns).
 
double qpms_scuffgen_max_extent (const qpms_scuffgen_shape_t *s)
 Largest particle dimension of the shape (metres).
 
qpms_errno_t qpms_scuffgen_sym_check_group (const qpms_scuffgen_shape_t *shape, const qpms_finite_group_t *G, char *errbuf, size_t errlen)
 
qpms_errno_t qpms_scuffgen_chamber_mirrors (const qpms_scuffgen_shape_t *shape, const qpms_finite_group_t *G, double(**normals_out)[3], int *nn_out)
 
qpms_errno_t qpms_scuffgen_emit_chamber_geo (const qpms_scuffgen_shape_t *shape, double lc, const double(*normals)[3], int nnormals, FILE *f)
 
qpms_errno_t qpms_scuffgen_symmetrise_mesh (const char *chamber_path, const char *out_path, const qpms_finite_group_t *G, const double center[3], double snap_tol, double merge_tol, int expected_euler, int star_shaped, FILE *report)
 
qpms_errno_t qpms_scuffgen_emit_scuffgeo (const char *meshfile, _Complex double eps, _Complex double mu, FILE *f)
 

Detailed Description

External scuff-em T-matrix generator.

Implements the generator: scuff option of the scatspec particle kinds: for shapes without a native qpms semi-analytic generator (and, optionally, as an override for the ones that have it), the T-matrix is computed by the external scuff-tmatrix program (https://github.com/homerreid/scuff-em) acting on a gmsh-generated surface mesh of the particle.

The pipeline is executed lazily, once per requested angular frequency: the mesh is generated once per shape (content-addressed on-disk cache), and each frequency triggers one scuff-tmatrix run whose .TMatrix output is parsed with qpms_load_scuff_tmatrix() (which converts from the SCUFF normalisation to the qpms default).

Executable resolution (per tool): the environment variable QPMS_GMSH_BIN / QPMS_SCUFF_TMATRIX_BIN if set, otherwise the plain program name looked up in $PATH. The cache root is $QPMS_SCUFFGEN_CACHE, else $XDG_CACHE_HOME/qpms/scuffgen, else $HOME/.cache/qpms/scuffgen.

Note
The current Waterman-type algebra inside scuff-em shares the usual EBCM limitations; unlike qpms' axialsym implementation, the scuff-em surface-integral formulation handles hole-containing surfaces (torus, ring) as well.

Macro Definition Documentation

◆ QPMS_SCUFFGEN_UM

#define QPMS_SCUFFGEN_UM   1e-6

Metres per scuff-em length unit (1 um; the length unit of the emitted .geo/.msh files and of scuff-em itself).

◆ QPMS_SCUFFGEN_VERSION

#define QPMS_SCUFFGEN_VERSION   "1"

Bump when the emitted files or the invocation change semantics, so that old cache entries are not reused.

Typedef Documentation

◆ qpms_scuffgen_shape_t

Shape dimensions for the scuff generator, as parsed from the scatspec.

Unused dimensions are zero. The meanings follow Table 2 of the T-matrix community format specification (cf. scatspec.md); the length unit is metres, the expansion centre is the origin, the z axis is the symmetry axis where applicable.

Function Documentation

◆ qpms_scuffgen_chamber_mirrors()

qpms_errno_t qpms_scuffgen_chamber_mirrors ( const qpms_scuffgen_shape_t *  shape,
const qpms_finite_group_t *  G,
double(**)  normals_out[3],
int *  nn_out 
)

Chooses the mirror half-space normals of the fundamental chamber of the target point group G acting on the shape. Validates that G preserves the shape (subgroup of the shape's own point symmetry, with the canonical axis = z and centre = origin) and is generated by its mirror reflections; aborts with a clear error otherwise. Writes a freshly allocated array of 1-3 inward-pointing unit normals (free with free(); *normals_out) and their count.

◆ qpms_scuffgen_emit_chamber_geo()

qpms_errno_t qpms_scuffgen_emit_chamber_geo ( const qpms_scuffgen_shape_t *  shape,
double  lc,
const double(*)  normals[3],
int  nnormals,
FILE *  f 
)

Emits the fundamental-chamber .geo file content for the given shape (in microns): the shape cut by the mirror half-space boxes of normals (cone-first booleans), finished with a "chamber" physical surface. The normals come from qpms_scuffgen_chamber_mirrors(). Exposed for testing.

◆ qpms_scuffgen_emit_geo()

qpms_errno_t qpms_scuffgen_emit_geo ( const qpms_scuffgen_shape_t *  shape,
double  lc,
FILE *  f 
)

Emits the gmsh .geo file content for the given shape (in microns).

Exposed for testing; returns 0 on success. lc is the characteristic edge length in microns.

◆ qpms_scuffgen_emit_scuffgeo()

qpms_errno_t qpms_scuffgen_emit_scuffgeo ( const char *  meshfile,
_Complex double  eps,
_Complex double  mu,
FILE *  f 
)

Emits the .scuffgeo file content with an inline constant parsed material. Exposed for testing.

◆ qpms_scuffgen_max_extent()

double qpms_scuffgen_max_extent ( const qpms_scuffgen_shape_t *  s)

Largest particle dimension of the shape (metres).

Used for the default mesh size and the chamber half-space boxes.

Largest particle dimension of the shape (metres).

◆ qpms_scuffgen_resolve_tool()

char * qpms_scuffgen_resolve_tool ( const char *  envvar,
const char *  default_name 
)

Resolves an external tool executable.

Returns a freshly allocated absolute-or-plain path of the tool: the value of the environment variable envvar if set (and executable), otherwise default_name searched in $PATH. Returns NULL (without side effects) if not found.

◆ qpms_scuffgen_sym_check_group()

qpms_errno_t qpms_scuffgen_sym_check_group ( const qpms_scuffgen_shape_t *  shape,
const qpms_finite_group_t *  G,
char *  errbuf,
size_t  errlen 
)

Checks that a (shape, group) pair is usable for the scuffgen mesh symmetrisation, without aborting. The group must preserve the shape (subgroup of the shape's own point symmetry about the origin, canonical z axis) and be generated by its mirror reflections. Returns QPMS_SUCCESS, or QPMS_ERROR with a human-readable diagnosis written to errbuf (if non-NULL).

◆ qpms_scuffgen_symmetrise_mesh()

qpms_errno_t qpms_scuffgen_symmetrise_mesh ( const char *  chamber_path,
const char *  out_path,
const qpms_finite_group_t *  G,
const double  center[3],
double  snap_tol,
double  merge_tol,
int  expected_euler,
int  star_shaped,
FILE *  report 
)

Symmetrises a meshed fundamental chamber into an exactly group-invariant closed surface mesh (MSH 2.2 ASCII -> MSH 2.2 ASCII). Drops the internal mirror walls of the chamber mesh chamber_path, unrolls the kept triangles along the orbit of G (about center), merges the coincident wall vertices (within merge_tol; nodes within snap_tol of a mirror plane are snapped onto it first), verifies the result (node and triangle orbit closure, closed orientable manifold, Euler characteristic expected_euler – 0 for torus/ring, 2 for sphere-topology shapes –, global orientation from the signed volume, and, when star_shaped is nonzero, outward normals about center) and writes out_path only if all the checks pass. Diagnostics are written to report (if non-NULL); failures abort the program.

◆ qpms_tmatrix_generator_scuffgen()

qpms_errno_t qpms_tmatrix_generator_scuffgen ( qpms_tmatrix_t *  t,
_Complex double  omega,
const void *  params 
)

The scuff-em T-matrix generator for qpms_tmatrix_generator_t.

params points to qpms_scuffgen_params_t. Runs (or takes from the cache) the gmsh + scuff-tmatrix pipeline and fills t with the T-matrix at angular frequency omega (which may be complex).