pyxfem.core.function_spaces module

Created on Mon Dec 4 23:30:08 2023

@author: nchevaug

class pyxfem.core.function_spaces.DofManagerBase[source]

Bases: ABC

Base class to help manage degree of freedoms

edge2edgeid(e2v, getxy=False)[source]

from edge defined by there vertices id, recover the edgeid as seen by the space

edgeid2dofid(edges)[source]

from edge id recover the associated dofid For FEMSpaceP1, return an empty array

scalar_size()[source]

size (nbdofs) for a scalar space

size()[source]

size (nbdofs) taking into account the vector dim of the field

vertexid2dofid(vids)[source]

return the dofs number associated to the vertices id

class pyxfem.core.function_spaces.FEMSpaceP1(name: str, mesh: SMesh, vecdim: int = 1, tris_map: None | MappingT3 = None)[source]

Bases: object

Classical Linear Finite Element space

static N(uv)[source]

Shape function for the triangle

dNdu = array([[-1.,  1.,  0.],        [-1.,  0.,  1.]])
edge2edgeid(e2v, getxy=False)[source]

from edge defined by there vertices id, recover the edgeid as seen by the space

edgeid2dofid(edges)[source]

from edge id recover the associated dofid For FEMSpaceP1, return an empty array

get_tris_mapping()[source]

return the (linear mapping (see mapping.MappingT3)) of the mesh entities

interpolate(f)[source]

interpolate the function f on to mesh nodes

interpolatoryAt = 'vertex'
lenN = 3
operator_dof2grad_tri(evaltrisuv, rmap=None, frmap=None, only_on=None, raw_data=False, limited=False)[source]

Return operator dNdx that map the dof value to the gradient of field values at each point uv for each triangle

operator_dof2val_edge(eids, evaledge_s=array([0.5]))[source]

Return operator N that map the dof value to the field values at each point s of each edge

operator_dof2val_tri(evaltris_uv, rmap=None, frmap=None, only_on=None, raw_data=False)[source]

Return operator N that map the dof value to the field values at each point uv for each triangle

scalar_size()[source]

size (nbdofs) for a scalar space

size()[source]

size (nbdofs) taking into account the vector dim of the field

vertexid2dofid(vids)[source]

return the dofs number associated to the vertices id

class pyxfem.core.function_spaces.FEMSpaceP1NC(name, mesh: SMesh, vecdim=1, tris_map=None)[source]

Bases: object

Implementation of cruzeix-raviart Element

static N(uv)[source]

Shape function for the triangle

dNdu = array([[ 0.,  2., -2.],        [-2.,  2.,  0.]])
edge2dofid(e2v)[source]

from edge defined by there vertices id, return the associated dofs

edge2edgeid(e2v, getxy=False)[source]

from edge defined by there vertices id, recover the edgeid as seen by the space

edgeid2dofid(eidspace)[source]

from edge id recover the associated dofid

get_tris_mapping()[source]

return the (linear mapping (see mapping.MappingT3)) of the mesh entities

interpolate(f) → NDArray[float64][source]

Compute values of u dofs so that Ni*ui is equal to f at mid edge

interpolatoryAt = 'midEdge'
lenN = 3
operator_dof2grad_tri(evaltrisuv, rmap=None, frmap=None, only_on=None, raw_data=False, limited=False)[source]

Return operator dNdx that map the dof value to the gradient of field values at each point uv for each triangle

operator_dof2val_edge(eids, evaledges=array([0.5]))[source]

Return operator N that map the dof value to the field values at each point s of each edge

operator_dof2val_tri(evaltrisuv, rmap=None, frmap=None, only_on=None, raw_data=False)[source]

Return operator N that map the dof value to the field values at each point uv for each triangle

operator_edgetrace(quad_edges)[source]

return a linear sparse operator N that compute the trace on each edge at points quad_edges from the dof values. t = N@U is an np.array for size nedge*npt*vecdim*2 (it that order) the entries i,j k of t.reshape((nedge, npt, vecdim, 2)) contain the 2 value at edge i, point j, direction k, which correspond to the values at left and right of the edge (we assume here a 2d manifold)

operator_trival2edge(ndata_per_edge=None, data_size=1)[source]

return linear operator that push values at triangles to each edge. useful to compute interelemnt jump for example

scalar_size()[source]

size (nbdofs) for a scalar space

size()[source]

size (nbdofs) taking into account the vector dim of the field

vertexid2dofid(vids)[source]

return the dofs number associated to the vertices id

class pyxfem.core.function_spaces.Heaviside(name, mesh_cut_data, ls_tris, ls_tris_cut)[source]

Bases: object

Heaviside shape function defined on a cut mesh

eval(evaltrisuv, only_on_parents=None, frmap=None)[source]

evaluate the function at each point uv of each element or sub element

class pyxfem.core.function_spaces.LinearScalarField(a=3, b=4)[source]

Bases: object

A linear field in 2d : u(x,y) = a*x + b*y

fun(xy)[source]

eval the function at points xy

grad(xy)[source]

eval the gradient of function at points xy

class pyxfem.core.function_spaces.LinearVectorField[source]

Bases: object

an example of Vector field for test purpose

fun(xy)[source]

eval the function at points xy

grad(xy)[source]

eval the gradient of function at points xy

class pyxfem.core.function_spaces.QuadraticScalarField(hess=array([[1., 0.], [0., 1.]]))[source]

Bases: object

A Quadratic field for example purpose

fun(xy)[source]

eval the function at points xy

grad(xy)[source]

eval the gradient of function at points xy

class pyxfem.core.function_spaces.QuadraticVectorField[source]

Bases: object

an example of Vector field for test purpose

fun(xy)[source]

eval the function at points xy

grad(xy)[source]

eval the gradient of function at points xy

class pyxfem.core.function_spaces.Ridge(name, mesh_cut_data, ls_tris, ls_tris_cut)[source]

Bases: object

Ridge shape function defined on a cut mesh (usefull for discontinuous gradient)

eval(evaltrisuv, only_on_parents=None, frmap=None, raw_data=False)[source]

evaluate the function at each point uv of each element or sub element

evalGrad(evaltrisuv, only_on_parents=None, frmap=None)[source]

evaluate the gradiant of thefunction at each point uv of each element or sub element

class pyxfem.core.function_spaces.SomeScalarField(f=1.0)[source]

Bases: object

an example of scalar field for test purpose

fun(xy)[source]

eval the function at points xy

grad(xy)[source]

eval the gradient of function at points xy

class pyxfem.core.function_spaces.SomeVectorField(f)[source]

Bases: object

an example of vector field for test purpose

fun(xy)[source]

eval the function at points xy

grad(xy)[source]

eval the gradient of function at points xy

class pyxfem.core.function_spaces.SumSpace(list_of_space)[source]

Bases: object

make a space as a sum of different space

operator_dof2grad_tri(evaltrisuv, rmap=None)[source]

Return operator dNdx that map the dof value to the gradient of field values at each point uv for each triangle

operator_dof2val_tri(evaltrisuv, rmap=None)[source]

Return operator N that map the dof value to the field values at each point uv for each triangle

class pyxfem.core.function_spaces.TestSparseOp(methodName='runTest')[source]

Bases: TestCase

Class for unit test of operator on dofs

test_operator_trival2edge()[source]

Test of the operator tha push triangles data to edges

class pyxfem.core.function_spaces.VertexSpaceDofManager(m: SMesh, vecdim=3)[source]

Bases: object

Class to compute the degree of freedom associated to the mesh and the dirichlet BC

size()[source]

Return the total size of the space (number of (scalar) dof in the space )

vertexid2dofid(vids)[source]

return an array A of shape (nv, vecdim) containing such as A[i, j] is the de index of degree of freedom associated to node i in vector direction j

class pyxfem.core.function_spaces.XFEMSpace(name, basespace, enrichment, mesh_cut, ls, ls_cut, rmap=None)[source]

Bases: object

XFEM Function space : input an enrichment function and a base space and a level set on which the enrichment is defined

operator_dof2grad_tri(evaltrisuv, rmap=None)[source]

Return operator dNdx that map the dof value to the gradient of field values at each point uv for each triangle

operator_dof2val_tri(evaltrisuv, rmap=None)[source]

Return operator N that map the dof value to the field values at each point uv for each triangle

scalar_size()[source]

size (nbdofs) for a scalar space

class pyxfem.core.function_spaces.XRidgeSpaceP1(name, mesh_cut, ls, ls_cut, rmap=None, dosvd=False)[source]

Bases: object

A special enrichment space for Ridge enrichment

operator_dof2grad_tri(evaltrisuv, rmap=None)[source]

Return operator dNdx that map the dof value to the gradient of field values at each point uv for each triangle

operator_dof2val_tri(evaltrisuv, rmap=None, raw=False)[source]

Return operator N that map the dof value to the field values at each point uv for each triangle

scalar_size()[source]

size (nbdofs) for a scalar space

pyxfem.core.function_spaces.gradNTri(dNdu, uv, invF)[source]

Compute the gradient with regard to space coordinates xy from gradient with regard to element coordinate uv

pyxfem.core.function_spaces.meshcutdata2remap_helper(mesh_cut, hmin=0.0, alpha=0.1, p=1)[source]

build a RemapHelper Object from mesh_cut data

pyxfem.core.function_spaces.op2sparse(NScalar, nscalar_dofs, a2scalardofs, vecdim, nshapeperelem, nptperelem, ndataperpoint, only_on=None)[source]

Given a N array (shape function values at integration point for each element and numbering of degree of freedom dat, construct the sparse N Operator (Assembly)

pyxfem.core.function_spaces.op2sparse_rmap(NScalar, nscalar_dofs, a2scalardofs, vecdim, nshapeperelem, nptperelem, ndataperpoint, rmap, frmap=None, sort=True)[source]

Given a N array (shape function values at integration point for each element (or sub element)) and numbering of degree of freedom dat, construct the sparse N Operator (Assembly) Specialized version for the case (typically xfem) where element are cut in sub cell

pyxfem.core.function_spaces.operator_dof2grad_tri(space, vecdim, geomdim, scalar_space_size, tri2dofs, trimap, evaltrisuv, rmap=None, frmap=None, only_on=None, raw_data=False, limited=False)[source]

helper function : return operator N that map the dof value to the gradient of field values at each point uv for each triangle

pyxfem.core.function_spaces.operator_dof2value(space, vecdim, scalar_space_size, tri2dofs, evaltrisuv, rmap=None, frmap=None, raw_data=False, only_on=None)[source]

return a linear operator N that map dof value to value at interpolation point of each element

pyxfem.core.function_spaces.operator_trival2edge(nedge, t2e, t2eflip, ndataperedge=None, datasize=1, dtype=<class 'numpy.float64'>)[source]

return linear operator that push values at triangles to each edge. useful to compute interelemnt jump for example