← Back to team overview

dolfin team mailing list archive

Re: Functions for applying boundary conditions to the RHS vector only now accept the solution vector x. Where Dirichlet boundary conditions are applied, b = x - bc.The is useful for applying boundary conditions within Newton iterations. [...]

 

Quoting Anders Logg <logg@xxxxxxxxx>:

> This looks strange to me, but maybe I don't understand it.
> 
> What if you don't even have a vector x? What vector should x should
> you then give as an argument?

If you don't have a vector x, you don't want to use this function :-). It's
basically returning the Dirichlet boundary condition "residual".

> 
> Maybe it is better to just call the standard version of applyBC()
> without x and then do
> 
> b *= -1.0;
> b += x;

This would add x to all elements of b, not just to elements where Dirichlet
boundary conditions are applied. I originally used the old applyBC for a vector
to use an analogous procedure to the above, but this required two temporary
vectors to be created, initialised and have boundary conditions applied at each
Newton iteration (in addtion to the usual assemble of b) - not very nice.

> 
> This would be two lines of code extra (one if you put them on the same
> line... :-). It's probably better to put this in the Newton solver
> since the Newton solver knows why this operation should be performed.

The Newton solver knows nothing about the boundary coniditons. The BC's need to
be applied by the user in the resdiudal vector b. This is done in the class
NonlinearFunction.

A possibility is a function that inserts components of x into b (rather than the
BC value), where Dirichlet BCs are applied. PETSc has a function to the set the
vector R, where F(u) = R is being solved, so R would contain the Dirichlet BCs.


Garth

> 
> /Anders
> 
> 
> On Thu, Dec 01, 2005 at 02:16:12PM +0100, dolfin@xxxxxxxxxx wrote:
> > Commit from garth (2005-12-01 14:16 CET)
> > -----------------
> > 
> > Functions for applying boundary conditions to the RHS vector only
> now accept the solution vector x. Where Dirichlet boundary conditions
> are applied, b = x - bc.The is useful for applying boundary conditions
> within Newton iterations.
> > 
> > This is not consistent with the other applyBC functions which return b = bc
> (no minus sign). This is due to the definition of the nonlinear function
> F(u)=0.
> > For Poisson's equation, I've been using the format F(u) = (grad v,grad u) -
> (v,f), hence the need for the minus. Is there a preference as to how we
> set-up nonlinear problems?
> > 
> > Would it be better to use a different name for funtions that return the
> difference between the current approximate solution and the Dirichlet BC?
> > 
> >   dolfin  src/kernel/fem/FEM.cpp       1.43
> >   dolfin  src/kernel/fem/dolfin/FEM.h  1.23
> > 
> > _______________________________________________
> > DOLFIN-dev mailing list
> > DOLFIN-dev@xxxxxxxxxx
> > http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> > 
> 
> -- 
> Anders Logg
> Research Assistant Professor
> Toyota Technological Institute at Chicago
> http://www.tti-c.org/logg/
> 
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> 



Follow ups