[Dune] question about initial condition
Rana Abdul Rauf
ranaabdulrauf2015 at gmail.com
Wed Sep 2 07:18:52 CEST 2020
Dear Chirstian, thanks a lot for your reply. I have applied a random number
as an initial condition but can't get the required results. Basically, I
want to see the spinodal decomposition of the Cahn Hilliard equation. For
this I have used u0=0.02rand(x,y) where rand(x,y) is the random number
between -1 and 1 as an initial condition. For this following initial
profile is required. Kindly help me about coding.
On Mon, Aug 24, 2020 at 3:31 PM Christian Engwer <
christian.engwer at uni-muenster.de> wrote:
> Dear Rana,
>
> On Mon, Aug 24, 2020 at 11:31:41AM +0500, Rana Abdul Rauf wrote:
> > Hello DUNE developers, I am working on phase field modeling. For the
> > numerical simulations, I am using Dune PEDlab. Now I am solving the
> > Cahn-Hilliard equation to see the spinodal decomposition. For this I want
> > to generate random numbers between -1 to 1. Kindly help me how to put
> > rand(x,y) as a initial condition, where rand(x,y) is random number
> between
> > -1 to 1.
>
> you can cast any lambda into a discrete function in
> PDELab. Interpolation aloows then to use this function as an initial
> value.
>
> - use your favorite random number generator, depending on your needs.
> - for simpliity I assume a uniform distribution between -1 and 1 is OK
> and I'll use std::uniform_real_distribution (
> https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution
> )
> - you can now create a random scalar function using, working in global
> coordinates:
> ```
> std::random_device rd; //Will be used to obtain a seed for the random
> number engine
> std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with
> rd()
> std::uniform_real_distribution<> dis(-1.0, 1.0);
> auto r = [dis&,gen&](const auto & x){ return dis(gen); };
> ```
> and cast it into a grid function, using infrastruture from dune-functions
> ```
> auto f = Dune::makeAnalyticGridViewFunction(r, gridView);
> ```
> - this function `f` an now interpolated into your stating vector using
> PDELab's `interplate`.
>
> If you know how to interprate your coeffiients you can further
> simplify this approach and perhas even use these random values
> directly as coefficients.
>
> Ciao
> Christian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20200902/b51be0d8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Spinodal.png
Type: image/png
Size: 114500 bytes
Desc: not available
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20200902/b51be0d8/attachment.png>
More information about the Dune
mailing list