|
Toast++
1.0.2 (r.539)
Forward and inverse modelling in optical tomography
|
Templated forward solver class. More...
#include <fwdsolver.h>
Public Member Functions | |
| TFwdSolver (const QMMesh *mesh, LSOLVER linsolver, double tol=1e-10) | |
| Constructor. Creates a forward solver instance. More... | |
| TFwdSolver (const QMMesh *mesh, const char *solver, double tol=1e-10) | |
| Constructor. Creates a forward solver instance. More... | |
| TFwdSolver (const QMMesh *mesh, ParamParser &pp) | |
| Constructor. Creates a forward solver instance. More... | |
| ~TFwdSolver () | |
| Destructor. Destroys the forward solver instance. | |
| void | SetDataScaling (DataScale scl) |
| Set the default scaling for data returned by the projection methods. More... | |
| DataScale | GetDataScaling () const |
| Returns the current default setting for data scaling. More... | |
| void | SetPrecon (PreconType type) |
| Set the preconditioning method. More... | |
| void | SetPhaseUnwrap (bool unwrap) |
| void | ReadParams (ParamParser &pp) |
| Read solver parameters from a parameter file. More... | |
| void | WriteParams (ParamParser &pp) |
| Write the current solver settings to a parameter file. More... | |
| void | SetLinSolver (const char *solver, double tol=1e-10) |
| Set the solver type and tolerance. More... | |
| LSOLVER | LinSolver () const |
| Returns the current solver type. More... | |
| double | GetLinSolverTol () const |
| Returns the solver tolerance. More... | |
| void | SetLinSolverMaxit (int maxit) |
| Set max iteration count for iterative solver. More... | |
| const QMMesh * | MeshPtr () const |
| Returns a pointer to the FEM mesh associated with the forward solver instance. More... | |
| void | Allocate () |
| Evaluates fill structure of system matrices and allocates dynamic memory for them. More... | |
| void | AssembleSystemMatrix (const Solution &sol, double omega=0, bool elbasis=false) |
| Construct the FEM system matrix from a set of parameter distributions for a given modulation frequency. More... | |
| void | AssembleSystemMatrixComponent (const RVector &prm, int type) |
| void | AssembleMassMatrix (const Mesh *mesh=0) |
| Construct the FEM mass matrix for time-dependent problems. More... | |
| void | Reset (const Solution &sol, double omega=0, bool elbasis=false) |
| Reset the forward solver by re-building the system matrices from a new set of parameters. More... | |
| void | CalcField (const TVector< T > &qvec, TVector< T > &phi, IterativeSolverResult *res=0) const |
| Calculate photon density field for a given source vector. More... | |
| void | CalcFields (const TCompRowMatrix< T > &qvec, TVector< T > *phi, IterativeSolverResult *res=0) const |
| Calculate photon density fields for all sources. More... | |
| void | CalcFields (int q0, int q1, const TCompRowMatrix< T > &qvec, TVector< T > *phi, IterativeSolverResult *res=0) const |
| Calculate photon density fields for a range of sources. More... | |
| TVector< T > | ProjectSingle (int q, const TCompRowMatrix< T > &mvec, const TVector< T > &phi, DataScale scl=DATA_DEFAULT) const |
| Return boundary data for a single source, given the corresponding photon density field. More... | |
| TVector< T > | ProjectAll (const TCompRowMatrix< T > &mvec, const TVector< T > *dphi, DataScale scl=DATA_DEFAULT) |
| Return boundary data for all sources and all detectors, given photon density fields for all sources. More... | |
| TVector< T > | ProjectAll (const TCompRowMatrix< T > &qvec, const TCompRowMatrix< T > &mvec, const Solution &sol, double omega, DataScale scl=DATA_DEFAULT) |
| Return boundary data for all sources and all detectors, given parameter distributions. More... | |
| RVector | ProjectAll_real (const TCompRowMatrix< T > &mvec, const TVector< T > *dphi, DataScale scl=DATA_DEFAULT) |
| Return boundary data for the complex case in a real vector. More... | |
| FVector | ProjectAll_singlereal (const TCompRowMatrix< T > &mvec, const TVector< T > *dphi, DataScale scl=DATA_DEFAULT) |
| RVector | ProjectAll_real (const TCompRowMatrix< T > &qvec, const TCompRowMatrix< T > &mvec, const Solution &sol, double omega, DataScale scl=DATA_DEFAULT) |
| Return boundary data for all sources and all detectors, given parameters defined via a Solution instance. More... | |
| FVector | ProjectAll_singlereal (const TCompRowMatrix< T > &qvec, const TCompRowMatrix< T > &mvec, const Solution &sol, double omega, DataScale scl=DATA_DEFAULT) |
Public Attributes | |
| const QMMesh * | meshptr |
| pointer to the associated FEM mesh | |
| LSOLVER | solvertp |
| linear solver type | |
| IterativeMethod | method |
| iterative solver method, if applicable | |
| TCompRowMatrix< T > * | F |
| FEM system matrix. | |
| TCompRowMatrix< T > * | FL |
| lower triangle of system matrix decomposition | |
| TVector< T > * | Fd |
| diagonal of Cholesky factorisation | |
| TPreconditioner< T > * | precon |
| preconditioner instance | |
| TCompRowMatrix< T > * | B |
| mass matrix; only used for time-domain problems | |
| void * | SuperLU |
| SuperLU solver engine. | |
| double | iterative_tol |
| iterative solver tolerance | |
| int | iterative_maxit |
| iterative solver max iterations (0 for auto) | |
| PreconType | precontp |
| preconditioner | |
Protected Member Functions | |
| void | Setup () |
| void | SetupType () |
| void | DeleteType () |
| RVector | UnfoldComplex (const TVector< T > &vec) const |
| Unfold real and imaginary parts of a complex vector. More... | |
| FVector | UnfoldSComplex (const TVector< T > &vec) const |
Protected Attributes | |
| DataScale | dscale |
| default data scaling: DATA_LIN or DATA_LOG | |
| TVector< T > * | pphi |
| work buffer for field calculation | |
| bool | unwrap_phase |
| use phase unwrapping? | |
Templated forward solver class.
TFwdSolver is a template class which encapsulates the FEM diffusion forward solver. It can be instantiated either as TFwdSolver<double> (or RFwdSolver for short) to describe real-valued problems (continuous-wave measurements), or as TFwdSolver<complex> (or CFwdSolver) for complex-valued problems (frequency domain problems).
The TFwdSolver class has an associated linear solver (defined in the constructor) for solving the linear FEM system. This can be either a direct solver (Cholesky for TFwdSolver<double> and LU for TFwdSolver<complex>), or an iterative method (CG, BiCG, BiCGSTAB, GMRES). For iterative methods, a tolerance limit is also required.
Each TFwdSolver instance has an FEM mesh associated with it. The mesh is defined by a call to Allocate, which also constructs the sparse system matrix structure based on the mesh connectivity graph.
The system matrix is built with a call to Reset for a given set of nodal optical coefficients. Subsequently, the photon density field (given a source vector) can be evaluated with CalcField and CalcFields, and the measurement values on the boundary can be obtained with Project and ProjectAll.
| TFwdSolver< T >::TFwdSolver | ( | const QMMesh * | mesh, |
| LSOLVER | linsolver, | ||
| double | tol = 1e-10 |
||
| ) |
Constructor. Creates a forward solver instance.
| mesh | pointer to associated QMMesh object |
| linsolver | linear solver type (see Linear solver methods) |
| tol | linear solver tolerance (only used for iterative methods) |
| TFwdSolver< T >::TFwdSolver | ( | const QMMesh * | mesh, |
| const char * | solver, | ||
| double | tol = 1e-10 |
||
| ) |
Constructor. Creates a forward solver instance.
| mesh | pointer to associated QMMesh object |
| solver | linear solver type, provided as a string (see notes) |
| tol | linear solver tolerance (only used for iterative methods) |
| TFwdSolver< T >::TFwdSolver | ( | const QMMesh * | mesh, |
| ParamParser & | pp | ||
| ) |
Constructor. Creates a forward solver instance.
| mesh | pointer to associated QMMesh object |
| pp | parser to read solver options from. |
| void TFwdSolver< T >::Allocate | ( | ) |
Evaluates fill structure of system matrices and allocates dynamic memory for them.
| void TFwdSolver< T >::AssembleMassMatrix | ( | const Mesh * | mesh = 0 | ) |
Construct the FEM mass matrix for time-dependent problems.
| mesh | mesh pointer |
| void TFwdSolver< T >::AssembleSystemMatrix | ( | const Solution & | sol, |
| double | omega = 0, |
||
| bool | elbasis = false |
||
| ) |
Construct the FEM system matrix from a set of parameter distributions for a given modulation frequency.
| sol | Solution instance containing parameter vectors |
| omega | modulation frequency (cycles/ps) |
| void TFwdSolver< T >::CalcField | ( | const TVector< T > & | qvec, |
| TVector< T > & | phi, | ||
| IterativeSolverResult * | res = 0 |
||
| ) | const |
Calculate photon density field for a given source vector.
| [in] | qvec | source vector (h-basis) |
| [out] | phi | photon density field (h-basis) |
| [out] | res | optional; if used, and if an iterative solver is used, the structure is filled with iteration count and relative error. |
| void TFwdSolver< T >::CalcFields | ( | const TCompRowMatrix< T > & | qvec, |
| TVector< T > * | phi, | ||
| IterativeSolverResult * | res = 0 |
||
| ) | const |
Calculate photon density fields for all sources.
| [in] | qvec | array of column source vectors |
| [out] | phi | array of photon density fields |
| [out] | res | optional; if used, and if an iterative solver is used, the structure is filled with the maximum iteration count and the maximum relative error for any source |
| void TFwdSolver< T >::CalcFields | ( | int | q0, |
| int | q1, | ||
| const TCompRowMatrix< T > & | qvec, | ||
| TVector< T > * | phi, | ||
| IterativeSolverResult * | res = 0 |
||
| ) | const |
Calculate photon density fields for a range of sources.
| q0 | min source index | |
| q1 | max source index + 1 | |
| qvec | complete array of column source vectors | |
| [out] | phi | array of photon density fields |
| [out] | res | optional; if used, and if an iterative solver is used, the structure is filled with the maximum iteration count and the maximum relative error for any source |
| DataScale TFwdSolver< T >::GetDataScaling | ( | ) | const |
Returns the current default setting for data scaling.
|
inline |
Returns the solver tolerance.
References TFwdSolver< T >::iterative_tol.
|
inline |
Returns the current solver type.
References TFwdSolver< T >::solvertp.
|
inline |
Returns a pointer to the FEM mesh associated with the forward solver instance.
References TFwdSolver< T >::meshptr.
| TVector<T> TFwdSolver< T >::ProjectAll | ( | const TCompRowMatrix< T > & | mvec, |
| const TVector< T > * | dphi, | ||
| DataScale | scl = DATA_DEFAULT |
||
| ) |
Return boundary data for all sources and all detectors, given photon density fields for all sources.
| mvec | array of measurement column vectors |
| dphi | array of photon density fields for all sources (h-basis representation) |
| scl | output data scaling: linear or logarithmic |
| TVector<T> TFwdSolver< T >::ProjectAll | ( | const TCompRowMatrix< T > & | qvec, |
| const TCompRowMatrix< T > & | mvec, | ||
| const Solution & | sol, | ||
| double | omega, | ||
| DataScale | scl = DATA_DEFAULT |
||
| ) |
Return boundary data for all sources and all detectors, given parameter distributions.
| qvec | array of source column vectors |
| mvec | array of measurement column vectors |
| sol | solution containing optical parameters in h-basis |
| omega | modulation frequency (cycles/ps) |
| scl | output data scaling (linear or logarithmic) |
| RVector TFwdSolver< T >::ProjectAll_real | ( | const TCompRowMatrix< T > & | mvec, |
| const TVector< T > * | dphi, | ||
| DataScale | scl = DATA_DEFAULT |
||
| ) |
Return boundary data for the complex case in a real vector.
| mvec | array of measurement column vectors |
| dphi | array of photon density fields for all sources (h-basis representation) |
| scl | output data scaling: linear or logarithmic |
| RVector TFwdSolver< T >::ProjectAll_real | ( | const TCompRowMatrix< T > & | qvec, |
| const TCompRowMatrix< T > & | mvec, | ||
| const Solution & | sol, | ||
| double | omega, | ||
| DataScale | scl = DATA_DEFAULT |
||
| ) |
Return boundary data for all sources and all detectors, given parameters defined via a Solution instance.
| qvec | array of source column vectors |
| mvec | array of measurement column vectors |
| sol | solution instance (h-basis representation) |
| omega | modulation frequency (cycles/ps) |
| scl | output data scaling: linear or logarithmic |
| TVector<T> TFwdSolver< T >::ProjectSingle | ( | int | q, |
| const TCompRowMatrix< T > & | mvec, | ||
| const TVector< T > & | phi, | ||
| DataScale | scl = DATA_DEFAULT |
||
| ) | const |
Return boundary data for a single source, given the corresponding photon density field.
| q | source index (>= 0) |
| mvec | array of measurement column vectors |
| phi | photon density field for source q (h-basis representation) |
| void TFwdSolver< T >::ReadParams | ( | ParamParser & | pp | ) |
Read solver parameters from a parameter file.
| pp | parser instance |
| LINSOLVER | string | Linear solver method. The following choices are available: DIRECT (LU solver) CG, (conjugate gradient solver) BICG (biconjugate gradient solver), BICGSTAB (biconjugate gradient stabilised solver), GMRES (generalised minimum residual solver), GAUSSSEIDEL (Gauss-Seidel solver) |
| LINSOLVER_TOL | real | Tolerance value for iterative solvers |
| void TFwdSolver< T >::Reset | ( | const Solution & | sol, |
| double | omega = 0, |
||
| bool | elbasis = false |
||
| ) |
Reset the forward solver by re-building the system matrices from a new set of parameters.
| sol | Solution instance containing the parameter vectors |
| omega | modulation frequency (cycles/ps) |
| elbasis | parameter vectors in sol are provided in piecewise constant element basis rather than nodal basis |
| void TFwdSolver< T >::SetDataScaling | ( | DataScale | scl | ) |
Set the default scaling for data returned by the projection methods.
| scl | scaling method (DATA_LIN or DATA_LOG) |
| The | default scaling defined by this method is used by projection methods whenever they use a scaling parameter of DATA_DEFAULT. |
| void TFwdSolver< T >::SetLinSolver | ( | const char * | solver, |
| double | tol = 1e-10 |
||
| ) |
Set the solver type and tolerance.
| solver | linear solver type, provided as a string (see notes) |
| tol | linear solver tolerance (only used for iterative methods) |
| DIRECT | Direct solver (LU) |
| CG | Conjugate gradient solver |
| BICG | Bi-conjugate gradient solver |
| BICGSTAB | Bi-conjugate gradient stabilised solver |
| GMRES | Generalised minimum residual solver |
|
inline |
Set max iteration count for iterative solver.
| maxit | max number of iterations (0 for auto) |
References TFwdSolver< T >::iterative_maxit.
| void TFwdSolver< T >::SetPrecon | ( | PreconType | type | ) |
Set the preconditioning method.
| type | Preconditioner type. |
|
protected |
Unfold real and imaginary parts of a complex vector.
| vec | Input vector argument of template type |
| void TFwdSolver< T >::WriteParams | ( | ParamParser & | pp | ) |
Write the current solver settings to a parameter file.
| pp | parser instance |
1.8.6