How i can write this form

How i can write this form?
\int \nabla(\rho f u)* fi* dx
Where f - unknown variable, (trialFunction), u - vector velocity, fi - TestFunction for f, \rho - know variable.

How do you suppose the dimensions of this inner product should work?
Lets say \rho, f being scalar functions, then \rho f u is a vector, and \nabla (\rho f u) a matrix. How should that be multiplied with a scalar valued function fi?

Well, I can solve mixing incompressible fluid streams.
I use incompressible equation Navie-Stocs:
\nabla \cdot u = 0
\rho (\frac{\partial u}{\partial t} + u \cdot \nabla u) = \nabla \cdot \sigma (u,p) + f
This task i was reading in tutorial.

I want adding equation evolution of mass concentrations, the viscosity and density of the mixture are determined through the mass fraction of the components of the mixture f and molecular viscosities \mu_1 \mu_2 and partial densities \rho_1 \rho_2 pure components.
\frac{\partial \rho f}{\partial t} + \nabla (\rho f \overrightarrow{u}) = \nabla(\rho D \nabla f)
I solve u and p, then solve f, and then \rho

I create FunctionSpace:
F = FunctionSpace(mesh, 'P', 1)
Then:

f = TrialFunction(F) 
fi = TestFunction(F)

I create functions for solve \mu, \rho

def mu_(f):
    return f*mu_1 + (1 - f)*mu_2

def rho(f):
    return rho_1*rho_2/(f*rho_2 + (1*f)*rho_1)

And i define variation problem:
\int \rho(f_n) (\frac{f -f_n}{dt}) \cdot fi \,dx \;+ \;\int \nabla (\rho f \overrightarrow{u}) \cdot fi \, dx \; = \; \int (\rho D \nabla f) \cdot \nabla(fi) \, dx

I use
\frac{df}{dn} = 0 on a wall.
What’s wrong? Thanks vey match!

So f is a vector of dim n (Same as the domain you are solving on)?
Could you please give the dimensions of each of your variables?
Assuming f is a vector, you have the following dimensions of each term:

  • \frac{\delta \rho f}{\delta t} is a vector of the dimension n
  • \nabla (\rho f \cdot \overrightarrow{u}) is a vector of dimension n.
  • \nabla \cdot (\rho D \nabla f) is a vector of dimension n (assuming D is a n\times n matrix).

You need to be very careful when you set up your problem using dot products/inner products, such that you can do integration by parts correctly. With the notation above, it is clear to see that you can write \nabla(rho f\cdot \overrightarrow{u}) as grad(rho * dot(f, u)) in UFL syntax

My dim is 2. Okey, thanks, but in my functions

def mu_(f):
    return f*mu_1 + (1 - f)*mu_2

def rho(f):
    return rho_1*rho_2/(f*rho_2 + (1*f)*rho_1)

I must get norm about f_n.

V = VectorFunctionSpace(mesh, 'P', 2)
Q = FunctionSpace(mesh, 'P', 1)
F = VectorFunctionSpace(mesh, 'P', 2)

Mesh is triangles.

f_n = Function(F)

How i can get lenght my VectorElement?

I am not sure what you are asking for right now.
The default dimension of the vector function space is the same as the geometrical dimension of your mesh. If you want to use any other dimension, you can encode it using VectorElement, i.e.

v_el = VectorElement("CG", mesh.ufl_cell(), 2, dim=2)

Sorry, I didn’t mean it.
My problem now about functions. I have this code:

def rho(f):
    return rho_1*rho_2/(f*rho_2 + (1*f)*rho_1)

The argument that I pass to the function:

F = VectorFunctionSpace(mesh, 'P', 2)
f_n = Function(F)

# Define variational problem for example
F1 = rho(f_n)*dot((u - u_n) / k, v)*dx \
   + rho(f_n)*dot(dot(u_n, nabla_grad(u_n)), v)*dx \
   + inner(sigma(U, p_n, f_n), epsilon(v))*dx \
   + dot(p_n*n, v)*ds - dot(mu_(f_n)*nabla_grad(U)*n, v)*ds \
   - dot(f_, v)*dx
a1 = lhs(F1)
L1 = rhs(F1)

I have a problem for division by vector. I want to get the length of a vector and divide by it.

if you by length mean the number of components in the vector space, see the following.

from dolfin import *
mesh = UnitSquareMesh(10,10)
V = VectorFunctionSpace(mesh, "CG", 2)
u = TrialFunction(V)
print(len(u))
u = Function(V)
print(len(u))