# [petsc-users] KSPBuildSolution

Barry Smith bsmith at mcs.anl.gov
Thu Feb 17 15:41:57 CST 2011

```  On boundary points where you want your mathematical solution x*| at that point  = a you need to use for your coded function f(x) = x -  a. Its derivative is f'(x) = 1 which is nonzero is fine. If the derivative at other points is order K you can use f(x) = K*(x - a)  so the derivate at that point is K.

Barry

On Feb 17, 2011, at 3:21 PM, Juha Jäykkä wrote:

>> Yes, if your BC do not give at least a locally unique solution, then your
>> Jacobian will
>> be rank deficient and Newton breaks down. You can still try Picard, but I
>> recommend
>> understanding what you mean by a solution first.
>
> Thanks for confirming. And for the suggestion to try Picard, but it simply
> shoots out to somewhere in the direction of Alpha Centauri or some such:
> reaches function values in excess of 1.e+34 in less than ten SNES
> iterations... Perhaps there is such a solution, but that is certainly not what
> I want.
>
> Especially since I think I figured out an alternative boundary condition. But
> I do not know how to implement that in PETSc.
>
> How do I require
>
> f'(xmax) = constant_A
> f(xmax) = constant_B
>
> and no condition (I could require f(xmin)=0, but that is exactly the non-
> condition I discovered) at xmin?
>
> I did not find any examples of how to do this and it does not seem to be
> straightforward. Do I need to convert from f, f', f'' to f, g, g' with g=f' to
> change the f'(xmax) condition to a Dirichlet one for g? But that does not seem
> to be feasible since I can not think of what equation g (or f') should obey in
> the interior - recall that I just have a single equation, F(f, f', f'') = 0.
>
> Cheers,
> -Juha
>
> --
> 		 -----------------------------------------------
> 		| Juha Jäykkä, juhaj at iki.fi			|
> 		| http://www.maths.leeds.ac.uk/~juhaj		|
> 		 -----------------------------------------------

```