Dear All,
Thanks for creating this wonderful helping group. I am trying to solve a coupled PDE including three scalar variables and one vector variables. I have defined the function spaces for each variable in my code as below:
# Define function spaces
P2v = VectorFunctionSpace(mesh, "Lagrange", 2)
P1 = FunctionSpace(mesh, "CG", 1)
ME = MixedFunctionSpace([P2v, P1, P1, P1])
# Define test and trial functions
(w, q, r, z) = TestFunctions(ME)
dU = TrialFunction(ME)
# Current solution and solution from previous converged step
U, U0 = Function(ME), Function(ME)
# Acceleration and velocity from previous converged step
a0, v0 = Function(P2v), Function(P2v)
# Split mixed functions
u, c, mu, T = split(U)
u0, c0, mu0, T0 = split(U0)
I got an error message about using MixedFuntionSpace, and I know the MixedFunctionSpace is deprecated from version 2016 onward. I also tried to use VectorElement and FiniteElement instead, but I still have problem for defining the space for velocity and acceleration. Follow is my edited version of my previous code:
# Define function spaces
P2v = VectorElement('Lagrange',mesh.ufl_cell(), 2)
P1 = FiniteElement('CG', mesh.ufl_cell(), 1)
mixed = MixedElement([P2v, P1, P1, P1])
ME = FunctionSpace(mesh, mixed)
# Define test and trial functions
(w, q, r, z) = TestFunctions(ME)
dU = TrialFunction(ME)
# Current solution and solution from previous converged step
U, U0 = Function(ME), Function(ME)
# Acceleration and velocity from previous converged step
a0, v0 = Function(P2V), Function(P2V)
# Split mixed functions
u, c, mu, T = split(U)
u0, c0, mu0, T0 = split(U0)
I got the following error messages for the velocity and acceleration. I need to say that they should be defined in a vector function space.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-103-097bff633e5a> in <module>
13
14 # Acceleration and velocity from previous converged step
---> 15 a0, v0 = Function(P2v), Function(P2v)
16
17 # Split mixed functions
~/anaconda3/envs/fenicsproject/lib/python3.8/site-packages/dolfin/function/function.py in __init__(self, *args, **kwargs)
232
233 else:
--> 234 raise TypeError("Expected a FunctionSpace or a Function as argument 1")
235
236 # Set name as given or automatic
TypeError: Expected a FunctionSpace or a Function as argument 1
Any help from you would be highly appreciated.