I’m new to FEniCSx and have been learning by solving some scalar-valued PDEs, which I managed to do successfully using the provided documentation. However, I’m currently facing issues when working with vector PDEs,
specifically in creating 3D vector elements.Below is the code snippet
domain = mesh.create_interval(MPI.COMM_WORLD, num_elements, [0, L])
typeelement = element("Lagrange", domain.basix_cell(), 1,shape = (3,) ,dtype=default_real_type)
V = fem.functionspace(domain, typeelement)
# Define trial and test functions
r = fem.Function(V) # Solution function (trial function)
r_prime = ufl.grad(r)
norm_r_prime = ufl.sqrt(ufl.dot(r_prime, r_prime))
when i run the above code,the error is shown as following.
norm_r_prime = ufl.sqrt(ufl.dot(r_prime, r_prime))
return Dot(a, b)
raise ValueError("Dimension mismatch in dot product.")
can you please help me with resolving this issue and it.
Thank you it worked.But i got another two problems:
first,
the shape of r_prime is (3,1,1). whereas ‘r’ and testfunction ’ w’ is of (3,1),.which is same as defined.The problem is that i am not able to do ufl.inner(w,r_prime) because of shape difference.Can please help me to convert r_prime to 3x1 vector.
and second question is unrelated to this, which is defining constant (3x1) vector.
example snippet is