← Back to team overview

fenics team mailing list archive

Re: Documentation; suggestions and questions from SUNY Stony Brook.

 

On 4/1/10 1:21 AM, Nathan Borggren wrote:

> 2.  Despite being decently trained in functional methods I still seem
> to struggle, in particular with boundary conditions or when time is
> involved, to see how the variational problems of the tutorials relate
> back to the original pde being solved.  It would be nice if a few
> lines were devoted to a latexed equation stating abstractly the
> functional problem being solved, if not a whole derivation from a
> pde/ode of such an equation.
> 
> for example let me state some confusion I have with the
> advection-diffusion example.
> 
>  I would expect a term with something like 0.5*k*v*div(velocity)*u as well in
> a = v*u*dx + 0.5*k*(v*dot(velocity, grad(u))*dx + c*dot(grad(v), grad(u))*dx)
> L = v*u0*dx - 0.5*k*(v*dot(velocity, grad(u0))*dx + c*dot(grad(v),
> grad(u0))*dx) + k*v*f*dx

Yes, the term you point out is needed in the general case. It's just
that the velocity field used in this demo arises from a Stokes flow
computation resulting in a divergence-free field.

> if you could pardon some latex, is the underlying pde not (using delta
> for the divergence of a gradient)
> 
> \partial_t u = c*\delta u - \partial_i{(velocity*u)}+f
> 
> ?  what changes f from staying zero in the demo?

The PDE you write is correct, but I don't understand the question. f is
defined to be 0 in this demo, but could be defined to be something else
non-zero if required.

> # Set up boundary condition
> g  = Constant(1.0)
> bc = DirichletBC(Q, g, sub_domains, 1)
> 
> is this setting u = 1 at time zero?

No. It is setting u = 1 at the boundary region marked '1' for all time.
See demo/mesh/subdomains/ for details.

> is it implied then that homogeneous neumann conditions are in place on
> the spatial boundaries?

It is implied that homogeneous Neumann conditions are in place for all
non Dirichlet boundaries. You need to add additional terms to the
variational form to impose non zero Neumann conditions.

> I'm trying to develop an example in which the diffusion, c,  were a
> spatially dependant tensor, but am having trouble finding the right
> objects to do so.  How would one implement a term like dot(grad(v),
> c*grad(u))*dx where c would be a matrix expression of sorts that could
> say rotate and shrink grad(u) before taking the dot product with
> grad(v)? Any suggestions?

You'd first create your spatially-varying tensor like the following like
the following:

C = Expression("1.0/std::max(exp(-pow((x[1] - 0.5 -
0.1*sin(10*x[0]))/0.1, 2.0)), 0.01)")
zero = Expression("0.0")
c = as_matrix(((C, zero), (zero, C)))

Then later on in the form, implement the term like you mentioned using c.

Harish



References