NAG AD Library
d03pp (dim1_parab_remesh_fd)

Settings help

AD Name Style:


AD Specification Language:

1 Purpose

d03pp is the AD Library version of the primal routine d03ppf. Based (in the C++ interface) on overload resolution, d03pp can be used for primal, tangent and adjoint evaluation. It supports tangents and adjoints of first order.

2 Specification

Fortran Interface
Integer, Intent (In) :: npde, m, npts, nv, nxi, neqn, itol, nxfix, nrmesh, ipminf, lrsave, lisave, itask, itrace
Integer, Intent (Inout) :: isave(lisave), ind, iuser(*), iwsav(505), ifail
ADTYPE, Intent (In) :: tout, xi(nxi), rtol(*), atol(*), algopt(30), xfix(nxfix), dxmesh, trmesh, xratio, con
ADTYPE, Intent (Inout) :: ts, u(neqn), x(npts), rsave(lrsave), ruser(*), rwsav(1100)
Logical, Intent (In) :: remesh
Logical, Intent (Inout) :: lwsav(100)
Character (1), Intent (In) :: norm, laopt
Character (80), Intent (Inout) :: cwsav(10)
Type (c_ptr), Intent (Inout) :: ad_handle
External :: pdedef, bndary, uvinit, odedef, monitf
Corresponding to the overloaded C++ function, the Fortran interface provides five routines with names reflecting the type used for active real arguments. The actual subroutine and type names are formed by replacing AD and ADTYPE in the above as follows:
when ADTYPE is Real(kind=nag_wp) then AD is p0w
when ADTYPE is Type(nagad_a1w_w_rtype) then AD is a1w
when ADTYPE is Type(nagad_t1w_w_rtype) then AD is t1w
C++ Interface
#include <dco.hpp>
#include <nagad.h>
namespace nag {
namespace ad {
template <typename PDEDEF_T, typename BNDARY_T, typename UVINIT_T, typename ODEDEF_T, typename MONITF_T>
void d03pp ( handle_t &ad_handle, const Integer &npde, const Integer &m, ADTYPE &ts, const ADTYPE &tout, PDEDEF_T &&pdedef, BNDARY_T &&bndary, UVINIT_T &&uvinit, ADTYPE u[], const Integer &npts, ADTYPE x[], const Integer &nv, ODEDEF_T &&odedef, const Integer &nxi, const ADTYPE xi[], const Integer &neqn, const ADTYPE rtol[], const ADTYPE atol[], const Integer &itol, const char *norm, const char *laopt, const ADTYPE algopt[], const logical &remesh, const Integer &nxfix, const ADTYPE xfix[], const Integer &nrmesh, const ADTYPE &dxmesh, const ADTYPE &trmesh, const Integer &ipminf, const ADTYPE &xratio, const ADTYPE &con, MONITF_T &&monitf, ADTYPE rsave[], const Integer &lrsave, Integer isave[], const Integer &lisave, const Integer &itask, const Integer &itrace, Integer &ind, char *cwsav[], logical lwsav[], Integer iwsav[], ADTYPE rwsav[], Integer &ifail)
}
}
The function is overloaded on ADTYPE which represents the type of active arguments. ADTYPE may be any of the following types:
double,
dco::ga1s<double>::type,
dco::gt1s<double>::type
Note: this function can be used with AD tools other than dco/c++. For details, please contact NAG.

3 Description

d03pp is the AD Library version of the primal routine d03ppf.
d03ppf integrates a system of linear or nonlinear parabolic partial differential equations (PDEs) in one space variable, with scope for coupled ordinary differential equations (ODEs), and automatic adaptive spatial remeshing. The spatial discretization is performed using finite differences, and the method of lines is employed to reduce the PDEs to a system of ODEs. The resulting system is solved using a Backward Differentiation Formula (BDF) method or a Theta method (switching between Newton's method and functional iteration). For further information see Section 3 in the documentation for d03ppf.

4 References

Berzins M (1990) Developments in the NAG Library software for parabolic equations Scientific Software Systems (eds J C Mason and M G Cox) 59–72 Chapman and Hall
Berzins M, Dew P M and Furzeland R M (1989) Developing software for time-dependent problems using the method of lines and differential-algebraic integrators Appl. Numer. Math. 5 375–397
Berzins M and Furzeland R M (1992) An adaptive theta method for the solution of stiff and nonstiff differential equations Appl. Numer. Math. 9 1–19
Furzeland R M (1984) The construction of adaptive space meshes TNER.85.022 Thornton Research Centre, Chester
Skeel R D and Berzins M (1990) A method for the spatial discretization of parabolic equations in one space variable SIAM J. Sci. Statist. Comput. 11(1) 1–32

5 Arguments

In addition to the arguments present in the interface of the primal routine, d03pp includes some arguments specific to AD.
A brief summary of the AD specific arguments is given below. For the remainder, links are provided to the corresponding argument from the primal routine. A tooltip popup for all arguments can be found by hovering over the argument name in Section 2 and in this section.
1: ad_handlenag::ad::handle_t Input/Output
On entry: a configuration object that holds information on the differentiation strategy. Details on setting the AD strategy are described in AD handle object in the NAG AD Library Introduction.
2: npde – Integer Input
3: m – Integer Input
4: tsADTYPE Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
5: toutADTYPE Input
6: pdedef – Callable Input
pdedef needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
The specification of pdedef is:
Fortran Interface
Subroutine pdedef ( npde, t, x, u, ux, nv, v, vdot, p, q, r, ires, iuser, ruser)
Integer, Intent (In) :: npde, nv
Integer, Intent (Inout) :: ires, iuser(*)
ADTYPE, Intent (In) :: t, x, u(npde), ux(npde), v(nv), vdot(nv)
ADTYPE, Intent (Inout) :: ruser(*)
ADTYPE, Intent (Out) :: p(npde,npde), q(npde), r(npde)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto pdedef = [&]( const handle_t &ad_handle, const Integer &npde, const ADTYPE &t, const ADTYPE &x, const ADTYPE u[], const ADTYPE ux[], const Integer &nv, const ADTYPE v[], const ADTYPE vdot[], ADTYPE p[], ADTYPE q[], ADTYPE r[], Integer &ires)
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: npde – Integer Input
3: tADTYPE Input
4: xADTYPE Input
5: uADTYPE array Input
6: uxADTYPE array Input
7: nv – Integer Input
8: vADTYPE array Input
9: vdotADTYPE array Input
10: pADTYPE array Output
11: qADTYPE array Output
12: rADTYPE array Output
13: ires – Integer Input/Output
*: iuser(*) – Integer array User Workspace
*: ruser(*)ADTYPE array User Workspace
7: bndary – Callable Input
bndary needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
The specification of bndary is:
Fortran Interface
Subroutine bndary ( npde, t, u, ux, nv, v, vdot, ibnd, beta, gamma, ires, iuser, ruser)
Integer, Intent (In) :: npde, nv, ibnd
Integer, Intent (Inout) :: ires, iuser(*)
ADTYPE, Intent (In) :: t, u(npde), ux(npde), v(nv), vdot(nv)
ADTYPE, Intent (Inout) :: ruser(*)
ADTYPE, Intent (Out) :: beta(npde), gamma(npde)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto bndary = [&]( const handle_t &ad_handle, const Integer &npde, const ADTYPE &t, const ADTYPE u[], const ADTYPE ux[], const Integer &nv, const ADTYPE v[], const ADTYPE vdot[], const Integer &ibnd, ADTYPE beta[], ADTYPE gamma[], Integer &ires)
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: npde – Integer Input
3: tADTYPE Input
4: uADTYPE array Input
5: uxADTYPE array Input
6: nv – Integer Input
7: vADTYPE array Input
8: vdotADTYPE array Input
9: ibnd – Integer Input
10: betaADTYPE array Output
11: gammaADTYPE array Output
12: ires – Integer Input/Output
*: iuser(*) – Integer array User Workspace
*: ruser(*)ADTYPE array User Workspace
8: uvinit – Callable Input
uvinit needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
The specification of uvinit is:
Fortran Interface
Subroutine uvinit ( npde, npts, nxi, x, xi, u, nv, v, iuser, ruser)
Integer, Intent (In) :: npde, npts, nxi, nv
Integer, Intent (Inout) :: iuser(*)
ADTYPE, Intent (In) :: x(npts), xi(nxi)
ADTYPE, Intent (Inout) :: ruser(*)
ADTYPE, Intent (Out) :: u(npde,npts), v(nv)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto uvinit = [&]( const handle_t &ad_handle, const Integer &npde, const Integer &npts, const Integer &nxi, const ADTYPE x[], const ADTYPE xi[], ADTYPE u[], const Integer &nv, ADTYPE v[])
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: npde – Integer Input
3: npts – Integer Input
4: nxi – Integer Input
5: xADTYPE array Input
6: xiADTYPE array Input
7: uADTYPE array Output
8: nv – Integer Input
9: vADTYPE array Output
*: iuser(*) – Integer array User Workspace
*: ruser(*)ADTYPE array User Workspace
9: u(neqn) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
10: npts – Integer Input
11: x(npts) – ADTYPE array Input/Output
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
12: nv – Integer Input
13: odedef – Callable Input
odedef needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
If a null pointer is used as the argument, then a NAG supplied routine will be used as the argument for this parameter (C++ only).
For the Fortran interface, the NAG supplied routine d03pc_AD_k may be used as the actual argument for this parameter.
The specification of odedef is:
Fortran Interface
Subroutine odedef ( npde, t, nv, v, vdot, nxi, xi, ucp, ucpx, rcp, ucpt, ucptx, f, ires, iuser, ruser)
Integer, Intent (In) :: npde, nv, nxi
Integer, Intent (Inout) :: ires, iuser(*)
ADTYPE, Intent (In) :: t, v(nv), vdot(nv), xi(nxi), ucp(npde,nxi), ucpx(npde,nxi), rcp(npde,nxi), ucpt(npde,nxi), ucptx(npde,nxi)
ADTYPE, Intent (Inout) :: ruser(*)
ADTYPE, Intent (Out) :: f(nv)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto odedef = [&]( const handle_t &ad_handle, const Integer &npde, const ADTYPE &t, const Integer &nv, const ADTYPE v[], const ADTYPE vdot[], const Integer &nxi, const ADTYPE xi[], const ADTYPE ucp[], const ADTYPE ucpx[], const ADTYPE rcp[], const ADTYPE ucpt[], const ADTYPE ucptx[], ADTYPE f[], Integer &ires)
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: npde – Integer Input
3: tADTYPE Input
4: nv – Integer Input
5: vADTYPE array Input
6: vdotADTYPE array Input
7: nxi – Integer Input
8: xiADTYPE array Input
9: ucpADTYPE array Input
10: ucpxADTYPE array Input
11: rcpADTYPE array Input
12: ucptADTYPE array Input
13: ucptxADTYPE array Input
14: fADTYPE array Output
15: ires – Integer Input/Output
*: iuser(*) – Integer array User Workspace
*: ruser(*)ADTYPE array User Workspace
14: nxi – Integer Input
15: xi(nxi) – ADTYPE array Input
16: neqn – Integer Input
17: rtol(*) – ADTYPE array Input
18: atol(*) – ADTYPE array Input
19: itol – Integer Input
20: norm – character Input
21: laopt – character Input
22: algopt(30) – ADTYPE array Input
23: remesh – logical Input
24: nxfix – Integer Input
25: xfix(nxfix) – ADTYPE array Input
26: nrmesh – Integer Input
27: dxmeshADTYPE Input
28: trmeshADTYPE Input
29: ipminf – Integer Input
30: xratioADTYPE Input
31: conADTYPE Input
32: monitf – Callable Input
monitf needs to be callable with the specification listed below. This can be a C++ lambda, a functor or a (static member) function pointer. If using a lambda, parameters can be captured safely by reference. No copies of the callable are made internally.
If a null pointer is used as the argument, then a NAG supplied routine will be used as the argument for this parameter (C++ only).
For the Fortran interface, the NAG supplied routine d03pc_AD_l may be used as the actual argument for this parameter.
The specification of monitf is:
Fortran Interface
Subroutine monitf ( t, npts, npde, x, u, r, fmon, iuser, ruser)
Integer, Intent (In) :: npts, npde
Integer, Intent (Inout) :: iuser(*)
ADTYPE, Intent (In) :: t, x(npts), u(npde,npts), r(npde,npts)
ADTYPE, Intent (Inout) :: ruser(*)
ADTYPE, Intent (Out) :: fmon(npts)
Type (c_ptr), Intent (Inout) :: ad_handle
C++ Interface
auto monitf = [&]( const handle_t &ad_handle, const ADTYPE &t, const Integer &npts, const Integer &npde, const ADTYPE x[], const ADTYPE u[], const ADTYPE r[], ADTYPE fmon[])
1: ad_handlenag::ad::handle_t Input/Output
On entry: a handle to the AD handle object.
2: tADTYPE Input
3: npts – Integer Input
4: npde – Integer Input
5: xADTYPE array Input
6: uADTYPE array Input
7: rADTYPE array Input
8: fmonADTYPE array Output
*: iuser(*) – Integer array User Workspace
*: ruser(*)ADTYPE array User Workspace
33: rsave(lrsave) – ADTYPE array Communication Array
Please consult Overwriting of Inputs in the NAG AD Library Introduction.
34: lrsave – Integer Input
35: isave(lisave) – Integer array Communication Array
36: lisave – Integer Input
37: itask – Integer Input
38: itrace – Integer Input
39: ind – Integer Input/Output
*: iuser(*) – Integer array User Workspace
User workspace.
*: ruser(*) – ADTYPE array User Workspace
User workspace.
40: cwsav(10) – character array Communication Array
If ind = 0, cwsav, lwsav, iwsav and rwsav need not be set on entry.
41: lwsav(100) – logical array Communication Array
If ind = 0, cwsav, lwsav, iwsav and rwsav need not be set on entry.
42: iwsav(505) – Integer array Communication Array
If ind = 0, cwsav, lwsav, iwsav and rwsav need not be set on entry.
43: rwsav(1100) – ADTYPE array Communication Array
If ind = 0, cwsav, lwsav, iwsav and rwsav need not be set on entry.
44: ifail – Integer Input/Output

6 Error Indicators and Warnings

d03pp preserves all error codes from d03ppf and in addition can return:
ifail=-89
An unexpected AD error has been triggered by this routine. Please contact NAG.
See Error Handling in the NAG AD Library Introduction for further information.
ifail=-199
The routine was called using a strategy that has not yet been implemented.
See AD Strategies in the NAG AD Library Introduction for further information.
ifail=-444
A C++ exception was thrown.
The error message will show the details of the C++ exception text.
ifail=-899
Dynamic memory allocation failed for AD.
See Error Handling in the NAG AD Library Introduction for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

d03pp is not threaded in any implementation.

9 Further Comments

None.

10 Example

The following examples are variants of the example for d03ppf, modified to demonstrate calling the NAG AD Library.
Description of the primal example.
This example uses Burgers Equation, a common test problem for remeshing algorithms, given by
U t =-U U x +E 2U x2 ,  
for x[0,1] and t[0,1], where E is a small constant.
The initial and boundary conditions are given by the exact solution
U(x,t)=0.1exp(-A)+0.5exp(-B)+exp(-C) exp(-A)+exp(-B)+exp(-C) ,  
where
A = 50E(x-0.5+4.95t), B = 250E(x-0.5+0.75t), C = 500E(x-0.375).  

10.1 Adjoint modes

Language Source File Data Results
Fortran d03pp_a1w_fe.f90 d03pp_a1w_fe.d d03pp_a1w_fe.r

10.2 Tangent modes

Language Source File Data Results
Fortran d03pp_t1w_fe.f90 d03pp_t1w_fe.d d03pp_t1w_fe.r

10.3 Passive mode

Language Source File Data Results
Fortran d03pp_p0w_fe.f90 d03pp_p0w_fe.d d03pp_p0w_fe.r