Hello,
Let’s say I have a function u
that represents a 3D CG1
displacement field. What I would like to do is to extract the rigid body component of u
, e.g. break down u = u_0 + u_rigid
.
I know how to construct the nullspace for 3D elasticity :
def nullspace_elasticity_3D(V):
"""Function to build null space for 3D elasticity"""
# Create list of vectors for null space
index_map = V.dofmap.index_map
nullspace_basis = [dolfinx.cpp.la.create_vector(index_map, V.dofmap.index_map_bs) for i in range(6)]
with ExitStack() as stack:
vec_local = [stack.enter_context(x.localForm()) for x in nullspace_basis]
basis = [np.asarray(x) for x in vec_local]
# Dof indices for each subspace (x, y and z dofs)
dofs = [V.sub(i).dofmap.list.array for i in range(3)]
# Build translational null space basis
for i in range(3):
basis[i][dofs[i]] = 1.0
# Build rotational null space basis
x = V.tabulate_dof_coordinates()
dofs_block = V.dofmap.list.array
x0, x1, x2 = x[dofs_block, 0], x[dofs_block, 1], x[dofs_block, 2]
basis[3][dofs[0]] = -x1
basis[3][dofs[1]] = x0
basis[4][dofs[0]] = x2
basis[4][dofs[2]] = -x0
basis[5][dofs[2]] = x1
basis[5][dofs[1]] = -x2
# Create vector space basis and orthogonalize
basis = dolfinx.cpp.la.VectorSpaceBasis(nullspace_basis)
basis.orthonormalize()
_x = [basis[i] for i in range(6)]
nsp = PETSc.NullSpace().create(vectors=_x)
return nsp
So what I wanted to do, is take the VectorSpaceBasis
defined in this function, create a VectorFunctionSpace
from it, and then project u
on this space to get what I want.
However I don’t know if it is possible to create a VectorFunctionSpace
from a VectorSpaceBasis
?
If not what would be the prefered way of doing what I want ?
Thanks!