Options
All
  • Public
  • Public/Protected
  • All
Menu
note

WARNING: This class is still a work in progress and some available solvers might not work as expected...

Create a special solver that can be reused any time if the remote, the boundary values of the surface discontinuities, the young modulus or the density are changed.

Available solvers are seidel (default), jacobi, gmres and cgns.



Basically, it avoids to rebuild the system matrix each time the remote stresses change, which is time consuming.

This class is meant to be used for superposition, for teaching purpose, or for investigating new ideas.

Usage

example
const solver = arch.Forward(model)

remote.setFunction( (x,y,z) => [1, 0, 0, 0, 0, 0] )
solver.run()

const solution = new arch.Solution(model)
const U1 = solution.displ(positions)

// Since the remote changed, the solution will be
// recomputed automatically without rebuilding the
// system matrix
remote.setFunction( (x,y,z) => [0, 1, 0, 0, 0, 0] )
solver.run()
const U2 = solution.displ(pos)

// ... etc

Hierarchy

  • Forward

Index

Constructors

  • Default values are:

    • solver: seidel
    • tol: 1e-9
    • maxIter: 2000
    • cores: 1

    Parameters

    Returns Forward

  • Default values are:

    • solver: seidel
    • maxIter: 2000
    • cores: 1

    Parameters

    Returns Forward

  • Default solver is seidel

    Parameters

    • model: Model
    • tol: number
    • maxIter: number

    Returns Forward

  • Default values are:

    • solver: seidel
    • tol: 1e-9
    • maxIter: 2000
    • cores: 1
    brief

    Construct a solver for the model which allows to call multiple time run() without rebuilding the system each time if and only if:

    • the number of triangles in the model does not change
    • the geometry of the surfaces changed
    • the bc type of each triangle does not change
    • we do not change the poisson's ratio

    On the other hand, it is possible to

    • change the remote
    • add new remotes
    • add pressure in discontinuities if traction was prescribed along the normal direction

    If a changed is detected in the model (the number of triangles changed, the bc type of at least one triangle changed, the geometry of surfaces changed), then the system matrix is rebuild automatically.



    However, we cannot detect (yet?) when the geometry of a surface changes, and therefore we provide the [[dirty]] property to set to true.

    Parameters

    • model: Model

      The model

    • solverName: string

      The name of the solver to use for the computation (seidel, jacobi, gmres, cgns). Default is seidel (if solverName is unknown).

    • tol: number

      The tolerence of the solver (usually 1e-9)

    • maxIter: number

      The maximum nulber of iterations (usually around 1000, but depens on the model)

    Returns Forward

Methods

  • onEnd(cb: Function): void
  • Call when the solver end either when the computation if done or when the user stop the solver.

    Parameters

    • cb: Function

      Signature is cb(): void

    Returns void

  • onError(cb: Function): void
  • Notification when an error is sent by the solver

    Parameters

    • cb: Function

      Signature is cb(msg: string): void

    Returns void

  • onMessage(cb: Function): void
  • Notification when a message is sent by the solver

    Parameters

    • cb: Function

      Signature is cb(msg: string): void

    Returns void

  • Set the callback function to call to notify (i) the progress on the matrix allocation and construction, and (ii) the convergence of the solver.

    example
    const solver = new arch.Forward(model, 'seidel', 1e-9, 2000)
    solver.onMessage( c => console.log(c) )
    solver.onProgress( (i, c, context) => {
    if (context === 1) {
    console.log(`building system: ${c.toFixed(0)}%`)
    }
    else {
    console.log(`iter ${i}: residual ${c}`)
    }
    })

    Parameters

    Returns void

  • onWarning(cb: Function): void
  • Notification when a warning is sent by the solver

    Parameters

    • cb: Function

      Signature is cb(msg: string): void

    Returns void

  • releaseMemory(): void
  • Force the memory to be release

    Returns void

  • run(): void
  • brief

    Compute the solution by running the solver. To access the Solution, use the following code

    solver.run()
    const solution = new arch.Solution(model)
    see

    Solution

    Returns void

  • select(name: string): any
  • brief

    Set the name of the solver to use. Possible values are seidel, jacobi, gmres, cgns and parallel.

    default

    seidel

    note

    If the lib was compiled in mono thread, then the "parallel" solver is irrelevant.

    Parameters

    • name: string

    Returns any

  • setAutoReleaseMemory(b: boolean): void
  • Set the memory of the system to be released after each run or not (default is true)

    Parameters

    • b: boolean

    Returns void

  • setDirty(b: boolean): any
  • brief

    Set the solver as dirty meaning that the underlaying system matrix will be rebuild. This happens, for example, when:

    • the number of triangles in the model changed (automatically detected)
    • the bc type of at least one triangle changed (automatically detected)
    • the poisson's ratio changed (automatically detected)
    • the geometry of at least one surface changed (not detected for now!!!)

    For instance, if you change the geometry of a surface (deformation, translation, scale, rotation...), then as it is not detected, you will have to make sure to call solver.dirty = true.

    note

    The solver.dirty = false will never work.

    Parameters

    • b: boolean

    Returns any

  • setEps(v: number): any
  • brief

    Represent the tolerence of the solver. Default value is set to 1e-9. The solver continue to run until its current tolerence is greater than [[eps]] or the current number of iterations is less than [[maxIter]]

    default

    1e-9

    Parameters

    • v: number

    Returns any

  • setMaxIter(v: number): any
  • brief

    Represent the maximum number of iteration of the solver. Default value is set to 2000. The solver continue to run until its current tolerence is greater than [[eps]] or the current number of iterations is less than [[maxIter]]

    default

    2000

    Parameters

    • v: number

    Returns any

  • setNbCores(n: number): any
  • brief

    Set the number of threads to use by the solver.

    default

    1

    note

    If the lib was compiled in mono thread, then this number is irrelevant and you will be notified

    Parameters

    • n: number

    Returns any

  • stopRequested(cb: Function): void
  • Set the callback function to call to khnow if the user want to stop the computation.

    example
    let stop = false

    const solver = new Forward(model)
    solver.stopRequested( () => stop ) // assume multithreaded

    ...

    // later on while the solver is performing a long run
    // in a web-worker...
    stop = true

    Parameters

    • cb: Function

      The callback to pass with signature cb(): boolean

    Returns void