← Back to team overview

dolfin team mailing list archive

Re: [Question #145492]: solving problem with vector valued function

 

Question #145492 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/145492

    Status: Open => Answered

Johan Hake proposed the following answer:
Melanie!

You can use a MixedFunctionSpace.

  from dolfin import *
  mesh = UnitCube(10,10,10)

  dt = 1.0
  N  = 4 # Number of diffusive ligands
  Ds = range(1, N+2) # Diffusion constants
  V  = MixedFunctionSpace([FunctionSpace(mesh, "CG", 1)]*N)
  u  = Function(V); u0  = Function(V)
  v  = TestFunction(V)
  
  F = reduce(lambda x, y:x+y, \
      (((u[i]-u0[i])*v[i]/dt+\
      Ds[i]*inner(grad(u[i]), grad(v[i])))*dx for i in xrange(N)))

  dF = derivative(F, u)

  problem = VariationalProblem(F, dF)

- This is pretty compact and should for clarity be expanded
- I have not added any Neumann conditions, neither the advective term
- Also note that eventhough F is linear I have stated the problem as
  a nonlinear one

Johan

On Tuesday February 15 2011 08:37:28 Melanie Jahny wrote:
> New question #145492 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/145492
> 
> I'd like to solve the convection-equation for  different kinds of
> (independent) concentration functions. I'd like to solve the
> concection-diffusion problem for several concentrations. I'd like to set
> the number of different concentration function as a variable m. How do I
> have to define the concentration functions conc[i] (i <= m) ? Can I define
> them as a vector?
> 
> For one concentration I defined
> Q = FunctionSpace(mesh, "CG", 1)
> conc = TrialFunction(Q)
> 
> I tried VectorFunctionSpace, but it sets the size of the vector equal the
> mesh-dimension. Further, how do I have to change the bilinarform for
> several concentrations? F = eta*(conc-conc_prev)*dx +
> dt*(eta*dot(velocity, grad(conc))*dx + Diff_const*dot(grad(eta),
> grad(conc)*dx)
> 
> with eta = TestFunction(Q) and conc_prev the concentration from previous
> time step.
> 
> Is it possible to solve this problem by a for-loop over the number of
> concentration functions? How will the boundary value definition change? (I
> have Neumann-boundary values on a small part of the mesh)?
> 
> I hope anyone can help me! Thanks!

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.