femo_alpha.fea.utils_dolfinx
Utility functions for the PETSc and UFL operations
Module Contents
Classes
Functions
|
Compute the determinant of the deformation gradient used in the |
|
Compute the determinant of the deformation gradient used in the |
|
Wrap up the nonlinear solver for the problem F(w)=0 and |
|
https://github.com/FEniCS/dolfinx/blob/main/python/test/unit/nls/test_newton.py#L182-L205 |
|
|
|
|
|
Compute the array representation of the matrix form |
Compute the array representation of the scalar form |
|
|
Compute the array representations of the linear system |
Compute the array representation of the vector form |
|
|
util method for assembling the partial derivative matrices for |
|
Compute y = A.T * R |
|
Compute y = A * x |
|
|
|
Convert a PETSc matrix to scipy.coo Matrix |
|
Convert the PETSc matrix to a dense numpy array |
|
|
|
|
|
Create interval mesh for test purposes |
|
Create rectangle mesh for test purposes |
Create unit square mesh for test purposes |
|
|
Calculate the L2 norm of two functions |
|
Find the indices of the closest nodes, given the node_coordinates |
|
Compute the array representation of the Function |
|
Convert the differential operation from the reference domain |
|
Function importing a dolfinx mesh. |
|
Find the indices of the dofs for setting up the boundary condition |
|
|
|
|
|
|
|
L2 projection of an UFL object (expression) to targeted function. |
|
Reads mesh from input meshFile, optionally display statistics |
|
|
|
Set the fuction based on the array |
Implementation of KSP solution of the linear system Ax=b using MUMPS |
|
|
Wrap up the KSP solver for the linear system Ax=b |
|
Implementation of KSP solution of the linear system Ax=b using MUMPS |
|
|
|
Transpose for matrix of DOLFIN type |
|
Update the nodal values in every dof of the DOLFIN function v |
Attributes
- class femo_alpha.fea.utils_dolfinx.NonlinearSNESProblem(F, u, bcs, J=None)
- F(snes, x, b)
- J(snes, x, J, P)
Assemble Jacobian matrix.
- femo_alpha.fea.utils_dolfinx.F(uhat)
Compute the determinant of the deformation gradient used in the integration measure of the deformed configuration wrt the the reference configuration.
uhat: DOLFINx function for mesh movements
- femo_alpha.fea.utils_dolfinx.J(uhat)
Compute the determinant of the deformation gradient used in the integration measure of the deformed configuration wrt the the reference configuration.
uhat: DOLFINx function for mesh movements
- femo_alpha.fea.utils_dolfinx.NewtonSolver(F, w, bcs=[], abs_tol=1e-50, rel_tol=1e-30, max_it=3, initialize=False, error_on_nonconvergence=False, report=False)
Wrap up the nonlinear solver for the problem F(w)=0 and returns the solution
- femo_alpha.fea.utils_dolfinx.SNESSolver(F, w, bcs=[], abs_tol=1e-13, rel_tol=1e-13, max_it=100, report=False)
https://github.com/FEniCS/dolfinx/blob/main/python/test/unit/nls/test_newton.py#L182-L205
- femo_alpha.fea.utils_dolfinx.applyBC(res, u, bcs)
- femo_alpha.fea.utils_dolfinx.assemble(f, dim=0, bcs=[])
- femo_alpha.fea.utils_dolfinx.assembleMatrix(M, bcs=[])
Compute the array representation of the matrix form
- femo_alpha.fea.utils_dolfinx.assembleScalar(c)
Compute the array representation of the scalar form
- femo_alpha.fea.utils_dolfinx.assembleSystem(J, F, bcs=[])
Compute the array representations of the linear system
- femo_alpha.fea.utils_dolfinx.assembleVector(v)
Compute the array representation of the vector form
- femo_alpha.fea.utils_dolfinx.assemble_partials(of=None, wrt=None, dim=1)
util method for assembling the partial derivative matrices for education or verification.
- femo_alpha.fea.utils_dolfinx.computeMatVecProductBwd(A, R)
Compute y = A.T * R A: PETSc matrix R: ufl function
- femo_alpha.fea.utils_dolfinx.computeMatVecProductFwd(A, x)
Compute y = A * x A: PETSc matrix x: ufl function
- femo_alpha.fea.utils_dolfinx.computePartials(form, function)
- femo_alpha.fea.utils_dolfinx.convertToCOO(A)
Convert a PETSc matrix to scipy.coo Matrix
- femo_alpha.fea.utils_dolfinx.convertToDense(A_petsc)
Convert the PETSc matrix to a dense numpy array (super unefficient, only used for debugging purposes)
- femo_alpha.fea.utils_dolfinx.createCustomMeasure(mesh, dim, SubdomainFunc, measure: str, tag: int)
- femo_alpha.fea.utils_dolfinx.createFunction(function)
- femo_alpha.fea.utils_dolfinx.createIntervalMesh(n, x0, x1)
Create interval mesh for test purposes
- femo_alpha.fea.utils_dolfinx.createRectangleMesh(pt1, pt2, nx, ny)
Create rectangle mesh for test purposes
- femo_alpha.fea.utils_dolfinx.createUnitSquareMesh(n)
Create unit square mesh for test purposes
- femo_alpha.fea.utils_dolfinx.errorNorm(v, v_ex, norm='L2')
Calculate the L2 norm of two functions
- femo_alpha.fea.utils_dolfinx.findNodeIndices(node_coordinates, coordinates)
Find the indices of the closest nodes, given the node_coordinates for a set of nodes and the coordinates for all of the vertices in the mesh, by using scipy.spatial.KDTree
- femo_alpha.fea.utils_dolfinx.getFuncArray(v)
Compute the array representation of the Function
- femo_alpha.fea.utils_dolfinx.gradx(f, uhat)
Convert the differential operation from the reference domain to the measure in the deformed configuration based on the mesh movement of uhat
f: DOLFINx function for the solution of the physical problem uhat: DOLFIN function for mesh movements
- femo_alpha.fea.utils_dolfinx.import_mesh(prefix='mesh', subdomains=False, dim=2, directory='.')
Function importing a dolfinx mesh.
- Arguments:
- prefix (str, optional): mesh files prefix (eg. my_mesh.msh,
my_mesh_domain.xdmf, my_mesh_bondaries.xdmf). Defaults to ‘mesh’.
- subdomains (bool, optional): True if there are subdomains. Defaults to
False.
dim (int, optional): dimension of the domain. Defaults to 2. directory (str, optional): directory of the mesh files. Defaults to ‘.’.
- Output:
dolfinx Mesh object containing the domain;
- dolfinx MeshFunction object containing the physical lines (dim=2) or
surfaces (dim=3) defined in the msh file and the sub-domains;
association table
- femo_alpha.fea.utils_dolfinx.locateDOFs(coords, V, input='polar')
Find the indices of the dofs for setting up the boundary condition in the mesh motion subproblem
- femo_alpha.fea.utils_dolfinx.meshSize(mesh)
- femo_alpha.fea.utils_dolfinx.move(mesh, u)
- femo_alpha.fea.utils_dolfinx.moveBackward(mesh, u)
- femo_alpha.fea.utils_dolfinx.project(v, target_func, bcs=[], lump_mass=False)
L2 projection of an UFL object (expression) to targeted function. Typically used for visualization in post-processing. lump_mass is an optional boolean argument set to be False by default; it’s set to be True when lumping is needed for preventing oscillation when projecting discontinous data.
- femo_alpha.fea.utils_dolfinx.readFEAMesh(meshFile, format='HDF')
Reads mesh from input meshFile, optionally display statistics
- femo_alpha.fea.utils_dolfinx.reconstructFEAMesh(filename, nodes, connectivity)
- femo_alpha.fea.utils_dolfinx.setFuncArray(v, v_array)
Set the fuction based on the array
- femo_alpha.fea.utils_dolfinx.setUpKSP_MUMPS(A)
Implementation of KSP solution of the linear system Ax=b using MUMPS
- femo_alpha.fea.utils_dolfinx.solveKSP(A, b, x)
Wrap up the KSP solver for the linear system Ax=b
- femo_alpha.fea.utils_dolfinx.solveKSP_mumps(A, b, x)
Implementation of KSP solution of the linear system Ax=b using MUMPS
- femo_alpha.fea.utils_dolfinx.solveNonlinear(res, func, bc, solver, report, initialize)
- femo_alpha.fea.utils_dolfinx.transpose(A)
Transpose for matrix of DOLFIN type
- femo_alpha.fea.utils_dolfinx.update(v, v_values)
Update the nodal values in every dof of the DOLFIN function v according to v_values.
v: dolfin function v_values: numpy array
- femo_alpha.fea.utils_dolfinx.DOLFIN_EPS = 3e-16
- femo_alpha.fea.utils_dolfinx.comm