Hi Community,

I am solving a nonlinear elasticity problem and I’m going to show stress on the deformed configuration.

For this aim I am getting a VTK file for my deformation as follows:

#generating 2D mesh

domain_vertices = [Point(0.0, 0.0),

Point(48.0, 44.0),

Point(48.0, 60.0),

Point(0.0, 44.0)]

domain = Polygon(domain_vertices)

mesh = generate_mesh(domain,5)

CGG = FiniteElement(“CG”, mesh.ufl_cell(), 1)

Curll = FiniteElement(“N2curl”, mesh.ufl_cell(), 1) # N1curl and N2curl

Divv = FiniteElement(“BDM”, mesh.ufl_cell(), 1) # RT and BDM

ZZ= FunctionSpace(mesh, MixedElement([CGG, CGG, Curll, Curll, Divv, Divv]))

Build space for vector functions

vFE = VectorElement(‘Lagrange’, mesh.ufl_cell(),1)

W = FunctionSpace(mesh, vFE)

parameters[‘allow_extrapolation’] = True

UU_array = as_vector([U1, U2])

UU = project(UU_array, W)

vtkfile = File(‘deformation.pvd’)

vtkfile << UU

But I am confused on how can I get my stress as a VTK file to be able to show both of them on one figure in paraview.

I have tried to get scalar values of stress as follows:

PP = np.sqrt(norm(P1, norm_type=“L2”)**2

+ norm(P2, norm_type=“L2”)**2)

# which P1 and P2 are row vector components of the stress , FYI; P1 = (P1[0], P1[1]) and P2 = (P2[0], P2[1])

and they try to project them into the FunvtionSpace:

Stress = project(PP, W)

But It is not working.

The Error:

ufl.log.UFLException: Shapes do not match: and FloatValue d=139818763805864>.

I think the problem with my projection arises from FunctionSpace.

I appreciate any hint or comment to resolved this issue.

Thanks.