All documentation

#Errors and warnings

The library raises one of three error classes, all in errors.js and exported from the package. A malformed mesh, a non-finite value or a point outside the mesh is always one of them, never a silent wrong answer. Catch them by class:

import { ValidateError, ProjectError, SingularError } from 'traceprojector';

try {
  projector.project(u, point, tIdx, 0);
} catch (error) {
  if (error instanceof ValidateError) { /* the input mesh or arguments are wrong */ }
  else if (error instanceof ProjectError) { /* the call cannot be answered */ }
  else if (error instanceof SingularError) { /* a local problem has no solution */ }
  else throw error;
}

#ValidateError

The input is invalid: the mesh, or an argument that describes a mesh or an element.

ConditionMessage pattern
no vertices, or no tetrahedravertices must be a non-empty array, tetrahedra must be a non-empty array
a coordinate that is not a finite numberVertex ... must be an array of 3 finite numbers
a tetrahedron repeats a vertexTetrahedron ... contains duplicate vertex indices
a vertex index that does not existTetrahedron ... contains out-of-bounds vertex index ...
zero volume, or negative orientationTetrahedron ... has non-positive or degenerate volume (signedVol=..., relative volume ...)
a mesh that is not conforminginconsistent meshes
generateUnitCubeMesh with a bad sizen must be a positive integer
a bad polynomial degreedegree must be a nonnegative integer
a projector that needs the derivative of the field was not given itthe derivative of u is needed

Recovery: fix the input. For a flipped tetrahedron, swap two of its vertex numbers.

#ProjectError

The arguments are well formed but the call cannot be answered.

ConditionMessage pattern
tIdx is not an integer, or is out of rangetIdx must be an integer, got ..., tIdx=... out of range [0, ...]
a point that is not three finite numberspoint must be an array of 3 finite numbers, got ...
a point outside the meshPoint [...] not found in any tetrahedron
the field returns NaN or Infinity at a degree of freedom... produced a non-finite value ..., a degree of freedom is not finite, coefficient of degree ... entity ... is not finite
a form degree that does not existInvalid form degree l=...
Projector.projectHp for l = 1, 2 with p > 0Higher-order projections for l=..., p=... not yet implemented (use CanonicalProjector)

Recovery: check the field at the reported point; locate the point with Locator before projecting; use CanonicalProjector or HigherOrderProjector for higher degrees.

#SingularError

A local linear problem has no solution or the matrix is not definite.

ConditionMessage pattern
a 3x3 matrix with zero determinantSingular 3x3 matrix, Singular or near-singular matrix
a local mass or stiffness matrix that is not positive definitematrix is not positive definite
an extended star that is not a topological ballthe extended star of the vertex is not contractible, ... of the edge ...
no field with the required derivative in a starno field with the required differential in the star of entity ..., no flux field with the required divergence
a boundary weight that reaches outside its stara boundary weight leaves the star

Recovery: the mesh is too coarse near the reported entity for the local problem to exist, or it has a degenerate element. Refine it, or repair the element.

#Weight Warnings

Weight logs warnings via an injected warn function rather than throwing, because per-vertex failures should not halt the entire computation. Construct with { strict: true } to opt into fail-fast behaviour: in that mode the same per-simplex failure path re-throws a ProjectError instead of emitting a warning.

CodeMessageMeaning
BWC_EDGE_FAILUREWeight: failed to compute edge weight for edge ${eIdx}: ${err.message}See traceprojector/weight.js for the call site.
BWC_EDGE_NO_STARWeight: edge ${eIdx} has no boundary-face star; skipping.See traceprojector/weight.js for the call site.
BWC_FACE_FAILUREWeight: failed to compute face weight for face ${fIdx}: ${err.message}See traceprojector/weight.js for the call site.
BWC_FACE_NO_STARWeight: face ${fIdx} has no extended star; skipping.See traceprojector/weight.js for the call site.
BWC_VERTEX_BWEIGHT_FAILUREWeight: failed to compute vertex weight for vertex ${vIdx}: ${err.message}See traceprojector/weight.js for the call site.
BWC_VERTEX_NO_STARWeight: vertex ${vIdx} has no boundary-face star; skipping.See traceprojector/weight.js for the call site.

Recovery: Inspect the mesh near the reported simplex for degenerate or inverted elements.

#Bubble Warnings

Bubble also warns rather than throwing for singular mass matrices.

CodeMessageMeaning
HOP_BUBBLE_SOLVE_FAILEDBubble: bubble solve failed for tet ${tIdx}, p=${p}: ${e.message}See traceprojector/bubble.js for the call site.
HOP_L2_SOLVE_FAILEDBubble: L2 solve failed for tet ${tIdx}, p=${p}: ${e.message}See traceprojector/bubble.js for the call site.

Recovery: Ensure the tetrahedron has strictly positive volume.

#Solver Warnings

Solver warns on ill-conditioned local solves rather than throwing.

CodeMessageMeaning
LOCAL_SOLVER_ILL_CONDITIONEDSolver: matrix is ill-conditioned (norm=...). Results may be inaccurate.The local stiffness matrix is numerically ill-conditioned; the solve may be inaccurate.

Recovery: Inspect the local star geometry for inverted or degenerate

  • elements.

#Projector Warnings

Projector warns at construction if the mesh contains degenerate or near-degenerate tetrahedra.

CodeMessageMeaning
TRACEPROJECTOR_DEGENERATE_MESHProjector: mesh contains N degenerate or near-degenerate tetrahedra. Projections may fail.The mesh has tetrahedra whose volume relative to their longest edge cubed is below 1e-10 (see MIN_RELATIVE_VOLUME).

Recovery: Re-mesh or repair the input mesh before computing projections.