Apply boundary conditions using the method of lines

80 views
Skip to first unread message

bob bill

unread,
Sep 30, 2021, 8:43:47 AM9/30/21
to deal.II User Group
Hello,

I'm trying to solve the 2D heat equation with the method of lines, instead of Rothe's method as explained in the tutorials, as I'd like to use ARKODE to march in time. Assuming that the boundary data is 0 and the initial data is x*y*(1-x)*(1-y), after writing the weak formulation, I have a large system of ODEs:

Mu' +Au=F
u(0)=u_0

I started with modifying step-4 so that I assembled correctly the mass matrix. Before writing the lambdas that ARKODE needs, I need a way to enforce those Dirichlet boundary conditions for my system, since so far I am only using

MatrixTools::apply_boundary_values

applied to the stiffness matrix.

I searched for a solution in several steps, but apparently I can't find a way. How can I impose them taking into account also the presence of the mass matrix?

With kind regards,
Bob 


Wolfgang Bangerth

unread,
Oct 5, 2021, 8:30:05 PM10/5/21
to dea...@googlegroups.com
On 9/30/21 6:43 AM, bob bill wrote:
>
> I searched for a solution in several steps, but apparently I can't find a way.
> How can I impose them taking into account also the presence of the mass matrix?

I don't actually know the answer, but you should see whether the ARKODE
examples have sample code that shows how to do that. For example, it is
possible that ARKODE allows specifying that certain solution vector entries
have certain values (namely, the corresponding boundary values). I don't know
off the top of my head whether the deal.II interfaces to ARKODE allow setting
such constraints, but think that I have seen this before.

If you want to understand what needs to be done *in principle* for time
steppers, you might want to take a look at how step-26 deals with this problem
(using its own simplistic time stepper, not using ARKODE).

Best
W>

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

bob bill

unread,
Oct 7, 2021, 6:01:19 PM10/7/21
to deal.II User Group
Thanks prof. Bangerth.

>  For example, it is possible that ARKODE allows specifying that certain solution vector entries 
have certain values (namely, the corresponding boundary values).

Are you referring to this one, where a solution vector sol is passed by reference https://www.dealii.org/current/doxygen/deal.II/classSUNDIALS_1_1ARKode.html#a9d3bd452bc13970e9af93810d3d3beff
?
I am honestly a bit puzzled as I don't know how to use properly the interface in this particular case, even if I know what should be done, like in step-26. For instance, how can I set the solution vector sol in that function to the boundary values? 

Best

Wolfgang Bangerth

unread,
Oct 7, 2021, 7:36:55 PM10/7/21
to dea...@googlegroups.com
On 10/7/21 4:01 PM, bob bill wrote:
>
> >  For example, it is possible that ARKODE allows specifying that
> certain solution vector entries
> have certain values (namely, the corresponding boundary values).
>
> Are you referring to this one, where a solution vector /sol /is passed
No, I think this function has nothing to do with it.


> I am honestly a bit puzzled as I don't know how to use properly the
> interface in this particular case, even if I know what should be done,
> like in step-26. For instance, how can I set the solution vector /sol
> /in that function to the boundary values?

You might want to take a look at how step-77 deals with boundary values.
There, we do this as part of the function that solves the linear system
in each Newton step. For ARKODE, you *can* but don't *have to* write
such a function, but if you do as shown in the documentation of the IDA
integrator (and likely applicable to the ARKODE integrator as well),
then you have the opportunity to apply boundary values to where you are
solving the linear system.

I can't seem to find the examples I have in mind. It is likely that I
read this in the SUNDIALS manual and that we simply do not implement
interfaces to all parts of SUNDIALS' sub-packages. But if you look
through the SUNDIALS manuals, there are options for time integrators to
*require* that certain components of the solution vector have certain
values at each time step, or that they satisfy inequalities. You might
want to check the SUNDIALS manual and then think about whether that's
something that would be relatively easy to add to our interfaces.

Best
W.
Reply all
Reply to author
Forward
0 new messages