projection_trace.py¶
An implementation of the projection for the trace spaces on a 3D surface . The projection can be divided into two processes, reduction and reconstruction.
The reduction process will use the given scalar or vector to obtain the coefficients of its projection in the discrete space.
The reconstruction process first assembles the coefficients with the correct basis functions and evaluates the discrete variable at given points.
⭕ To access the source code, click on the [source] button at the right
side or click on
[projection_trace.py]
.
Dependence may exist. In case of error, check import and install required
packages or download required scripts. © mathischeap.com
- class projection_trace.ReconstructionTrace(bf, ct)[source]¶
A wrapper of reconstruction functions.
- Parameters:
bf (MimeticBasisPolynomials2D) – The basis functions in .
ct (CoordinateTransformationSurface) –
The coordinate transformation representing the mapping ,
- Example:
>>> def p(x,y,z): return np.sin(np.pi*x) * np.sin(np.pi*y) * np.sin(np.pi*z) >>> from mimetic_basis_polynomials_2d import MimeticBasisPolynomials2D >>> from coordinate_transformation_surface import CoordinateTransformationSurface >>> from coordinate_transformation_surface import Psi, d_Psi >>> bf = MimeticBasisPolynomials2D('Lobatto-20', 'Lobatto-20') >>> ct = CoordinateTransformationSurface(Psi, d_Psi) >>> Rd = ReductionTrace(bf, ct) >>> dofs = Rd.TF(p) >>> Rc = ReconstructionTrace(bf, ct) >>> rho = np.linspace(-1,1,5) >>> tau = np.linspace(-1,1,5) >>> xyz, v = Rc.TF(dofs, rho, tau) >>> np.max(np.abs(p(*xyz) - v)) # the max error from the exact function 0.0002989...
- TE(loc_dofs, rho, tau, ravel=False)[source]¶
Reconstruct a discrete trace polynomial in evaluated at .
- Parameters:
loc_dofs (np.array) – A 1d np.array containing the coefficients of the discrete variable in .
rho (1d np.array) – .
tau (1d np.array) – . The reconstruction will be evaluated at .
ravel – (default:
False
) Ifravel
isTrue
, we will flat the outputs (as a 1d array) according to local numbering. Otherwise, you get 2d outputs corresponding to the indexing.
- Returns:
A tuple of two outputs:
- : The reconstruction is evaluated at
.
values: The values of the reconstructed variable at .
- TF(loc_dofs, rho, tau, ravel=False)[source]¶
Reconstruct a discrete trace polynomial in evaluated at .
- Parameters:
loc_dofs (np.array) – A 1d np.array containing the coefficients of the discrete variable in .
rho (1d np.array) – .
tau (1d np.array) – . The reconstruction will be evaluated at .
ravel – (default:
False
) Ifravel
isTrue
, we will flat the outputs (as a 1d array) according to local numbering. Otherwise, you get 2d outputs corresponding to the indexing.
- Returns:
A tuple of two outputs:
- : The reconstruction is evaluated at
.
values: The values of the reconstructed variable at .
- TN(loc_dofs, rho, tau, ravel=False)[source]¶
Reconstruct a discrete trace polynomial in evaluated at .
- Parameters:
loc_dofs (np.array) – A 1d np.array containing the coefficients of the discrete variable in .
rho (1d np.array) – .
tau (1d np.array) – . The reconstruction will be evaluated at .
ravel – (default:
False
) Ifravel
isTrue
, we will flat the outputs (as a 1d array) according to local numbering. Otherwise, you get 2d outputs corresponding to the indexing.
- Returns:
A tuple of two outputs:
- : The reconstruction is evaluated at
.
values: The values of the reconstructed variable at .
- class projection_trace.ReductionTrace(bf, ct, quad_degree=None)[source]¶
A wrapper of reduction functions.
- Parameters:
bf (MimeticBasisPolynomials2D) – The basis functions in .
ct (CoordinateTransformationSurface) –
The coordinate transformation representing the mapping ,
quad_degree (list, tuple) – (default:
None
) The degree used for the numerical integral. It should be a list or tuple of two positive integers. If it isNone
, a suitable degree will be obtained frombf
.
- Example:
>>> def p(x,y,z): return np.sin(np.pi*x) * np.sin(np.pi*y) * np.sin(np.pi*z) >>> from mimetic_basis_polynomials_2d import MimeticBasisPolynomials2D >>> from coordinate_transformation_surface import CoordinateTransformationSurface >>> from coordinate_transformation_surface import Psi, d_Psi >>> bf = MimeticBasisPolynomials2D('Lobatto-3', 'Lobatto-3') >>> ct = CoordinateTransformationSurface(Psi, d_Psi) >>> Rd = ReductionTrace(bf, ct) >>> Rd.TF(p) array([0.03873144, 0.02717954, 0.02752846, 0.02717954, 0.04952738, 0.04752636, 0.02752846, 0.04752636, 0.01838736])
- TE(vector)[source]¶
Reduce a vector on to .
- Parameters:
vector
- Returns:
A 1d np.array representing the local coefficients/dofs of the discrete vector.
↩️ Back to Ph.D. thesis complements (ptc).