How to apply a spatially variable non-zero initial condition in step-52?

53 views
Skip to first unread message

Krishnakumar Gopalakrishnan

unread,
Apr 13, 2020, 8:00:42 PM4/13/20
to deal.II User Group
I am currently working on Step-52, which solves the diffusion equation.

I now want to disable the Method of Manufactured Solutions (MMS) i.e. get rid of the forcing function which produces an expected analytical solution, in the direction towards solving my real-world problem.  I also have set the absorption coefficient to zero, so that the diffusion equation reduces to a form analogous to the heat-equation.

Currently, the initial condition is set to be the zero vector.

As a first step, I'd like to set my initial solution to be sin(b*x) * sin(b*y).

I am currently interested in using only the embedded explicit method driver function. Within this, I suspect that the lines of interest are the following:

solution = 0.;
constraint_matrix.distribute(solution);


But I am not quite sure how can this initial condition be imposed. Any help will be much appreciated.

Wolfgang Bangerth

unread,
Apr 13, 2020, 8:24:50 PM4/13/20
to dea...@googlegroups.com
You will want to take a look at step-25. That program uses
VectorTools::project(), but you can also use VectorTools::interpolate() instead.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Krishnakumar Gopalakrishnan

unread,
Jun 7, 2020, 8:28:49 PM6/7/20
to Deal. II Googlegroup
Dear Dr Bangerth,

I tried using the VectorTools::project idea from step-25. However, my code fails to compile, and I could not decipher the errors and do not know how to fix this problem (have been stuck for a while).

The attached code tries to implement Step-52 (but for 1D), with homogenous dirichelet BC  at the left edge and homogenous Neumann BC at the right edge, with an initial value of 4/5*x*(1 - x/5) (a simple quadratic function). I am also attaching the CMakeLists.txt (adapted from Step-52 suitably).

I'd appreciate help (from you and others here on the forum) to solve this issue.

Krishna



--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/l-aX46O2McY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/462c6c7a-341d-1657-559e-d7a2a3164771%40colostate.edu.
CMakeLists.txt
solid_diffusion.cc

Wolfgang Bangerth

unread,
Jun 8, 2020, 4:56:41 PM6/8/20
to dea...@googlegroups.com, Krishnakumar Gopalakrishnan

Krishna,

> I tried using the VectorTools::project idea from step-25. However, my code
> fails to compile, and I could not decipher the errors and do not know how to
> fix this problem (have been stuck for a while).
>
> The attached code tries to implement Step-52 (but for 1D), with homogenous
> dirichelet BC  at the left edge and homogenous Neumann BC at the right edge,
> with an initial value of 4/5*x*(1 - x/5) (a simple quadratic function). I am
> also attaching the CMakeLists.txt (adapted from Step-52 suitably).
>
> I'd appreciate help (from you and others here on the forum) to solve this issue.

You really need to learn how to read error messages because this is really a
rather simple case. The error you get is this:

/home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc:362:26: error:
‘Step52::InitialValues’ is not a template
InitialValues<1>(1, time),
^~~~~~~~~~~~~
/home/bangerth/p/deal.II/1/install/examples/step-1/step-1.cc:362:50: error: no
matching function for call to ‘Step52::InitialValues::InitialValues(int,
time_t (&)(time_t*) throw ())’
InitialValues<1>(1, time),
^

So you already know exactly what the line in question may be. There aren't all
that many possibilities for what could be wrong. The issue in your case is
that the 'time' variable doesn't exist in the function where you have the code
in question. The obscurity of the actual error message comes from the fact
that there is a global time() function. But in the end, this is a case where
you could have found the solution yourself.

So just replace time->0 if you want the initial values and everything should work.
Reply all
Reply to author
Forward
0 new messages