dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #17157
Re: [Question #96571]: Quasi-nonllinear Time-dependent Problem
On Thursday 07 January 2010 09:18:00 Ted Kord wrote:
> New question #96571 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/96571
>
> Hi
>
> I'm attempting to solve the following problem (using the C++ interface):
>
> du/dt - div grad u = f(u)
>
> Due to the non-linearity associated with f(u), I am using the parameters at
> time t to calculate it thus avoiding the use of a nonlinear root-finding
> algorithm.
>
> The problem I have is how to define f(u).
>
> Say, f(u) is:
> 0.1/(1 + exp(u - 2) )
>
> How do obtain the scalar value 'u' to pass as the argument to f(u) at every
> time step.
Have you tried to just define a scalar Function or Coefficient (new name) in
ufl for f(). Then you subclass Expression in C++, something like:
class F: public Expression
{
Function * _u;
public:
F:Expression(Function& u):Expression(),_u(&u){}
void eval(Array<double>& values, const Array<const double>& x) const
{
double val;
_u->eval(val, x);
values[0] = 0.1/(1+exp(val-2));
}
};
...
Function u_0(V);
F f(u_0);
You should then have the values of the previous function available.
Johan
> Thanks.
>
> Ted
>
Follow ups
References