[petsc-users] Adaptive controllers in TS

2014-10-19 Thread Miguel Angel Salazar de Troya
Hi all

I'm trying to find out what is the adaptive controller scheme used in the
Runge-Kutta time stepping algorithm. Basically I want to know the function
that determines the next time step. I see that the next time step is set
with the function TSAdaptChoose(), which calls the pointer function
(*choose)() within the structure _TSAdaptOps, but where is this set?

I need to know this for an adjoint analysis to calculate gradients. I was
wondering if there is an example of such analysis with the TS structure.
I've seen that the RK source file includes a funciton to interpolate the
solution, something that is necessary in an adjoint analysis, hence my
question about the example.

Thanks
Miguel
-- 
*Miguel Angel Salazar de Troya*
Graduate Research Assistant
Department of Mechanical Science and Engineering
University of Illinois at Urbana-Champaign
(217) 550-2360
salaz...@illinois.edu


Re: [petsc-users] Adaptive controllers in TS

2014-10-19 Thread Jed Brown
Miguel Angel Salazar de Troya salazardetr...@gmail.com writes:

 Hi all

 I'm trying to find out what is the adaptive controller scheme used in the
 Runge-Kutta time stepping algorithm. Basically I want to know the function
 that determines the next time step. I see that the next time step is set
 with the function TSAdaptChoose(), which calls the pointer function
 (*choose)() within the structure _TSAdaptOps, but where is this set?

via TSAdaptSetType.  The default will be TSAdaptChoose_Basic
(adaptbasic.c).  You can find this information easily by running in a
debugger.

 I need to know this for an adjoint analysis to calculate gradients. I was
 wondering if there is an example of such analysis with the TS structure.
 I've seen that the RK source file includes a funciton to interpolate the
 solution, something that is necessary in an adjoint analysis, hence my
 question about the example.

Interpolation arises for continuous adjoints.  Be aware that if you
want consistent gradients, you'll want a discrete adjoint, which
integrates backward in time using the adjoint RK method.  The stages of
the adjoint RK method coincide with the forward method, so no
interpolation is needed.

Hong (Cc'd) is developing an example that can integrate discrete adjoint
equations and we intend to eventually incorporate that functionality
into the library.


pgp9KxFGrhL_8.pgp
Description: PGP signature


[petsc-users] Check Array and String Bounds in PETSc

2014-10-19 Thread Danyang Su

Hi All,

How can I avoid array bounds error when using PETSc. I have to debug 
my codes so I compiled the codes with option Check Array and String 
Bounds. But  this results into array bounds error when I need to use 
ltog, as shown below.

call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
call ISLocalToGlobalMappingGetIndices(ltogm,ltog,idltog,ierr)
Exactly the aforementioned two lines work fine and the bug is in 
somewhere else. But the debug process just stops at the codes when ltog 
is used. How can avoid this?


Thanks,

Danyang


Re: [petsc-users] Check Array and String Bounds in PETSc

2014-10-19 Thread Matthew Knepley
On Sun, Oct 19, 2014 at 6:38 PM, Danyang Su danyang...@gmail.com wrote:

 Hi All,

 How can I avoid array bounds error when using PETSc. I have to debug my
 codes so I compiled the codes with option Check Array and String Bounds.
 But  this results into array bounds error when I need to use ltog, as shown
 below.
 call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
 call ISLocalToGlobalMappingGetIndices(ltogm,ltog,idltog,ierr)
 Exactly the aforementioned two lines work fine and the bug is in somewhere
 else. But the debug process just stops at the codes when ltog is used. How
 can avoid this?


Something else is wrong with the code. Neither of those routines does array
lookup.

  Matt


 Thanks,

 Danyang




-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener


Re: [petsc-users] Check Array and String Bounds in PETSc

2014-10-19 Thread Barry Smith

  Use ISLocalToGlobalMappingGetIndicesF90()


 On Oct 19, 2014, at 6:38 PM, Danyang Su danyang...@gmail.com wrote:
 
 Hi All,
 
 How can I avoid array bounds error when using PETSc. I have to debug my 
 codes so I compiled the codes with option Check Array and String Bounds. 
 But  this results into array bounds error when I need to use ltog, as shown 
 below.
call DMGetLocalToGlobalMapping(dmda_flow%da,ltogm,ierr)
call ISLocalToGlobalMappingGetIndices(ltogm,ltog,idltog,ierr)
 Exactly the aforementioned two lines work fine and the bug is in somewhere 
 else. But the debug process just stops at the codes when ltog is used. How 
 can avoid this?
 
 Thanks,
 
 Danyang



Re: [petsc-users] Adaptive controllers in TS

2014-10-19 Thread Miguel Angel Salazar de Troya
Thanks for your response

I'm struggling with this problem because the literature is not clear for me
on how to calculate the discrete adjoint with adaptive time stepping
algorithms. They cover the details when automatic differentiation tools are
used. They mention that because the time step depend on the solution, it
also depends on the parameter. Hence, there are terms that represent the
derivative of the time step w.r.t. the parameters. What it is confusing is
that they mention these terms must be removed. I don't understand this. I'm
planning to hard-code the discrete adjoint problem (and use the TS if
possible).

I know this might not be the place to ask this. Maybe Hong can help me here.

Miguel

On Sun, Oct 19, 2014 at 1:41 PM, Jed Brown j...@jedbrown.org wrote:

 Miguel Angel Salazar de Troya salazardetr...@gmail.com writes:

  Hi all
 
  I'm trying to find out what is the adaptive controller scheme used in the
  Runge-Kutta time stepping algorithm. Basically I want to know the
 function
  that determines the next time step. I see that the next time step is set
  with the function TSAdaptChoose(), which calls the pointer function
  (*choose)() within the structure _TSAdaptOps, but where is this set?

 via TSAdaptSetType.  The default will be TSAdaptChoose_Basic
 (adaptbasic.c).  You can find this information easily by running in a
 debugger.

  I need to know this for an adjoint analysis to calculate gradients. I was
  wondering if there is an example of such analysis with the TS structure.
  I've seen that the RK source file includes a funciton to interpolate the
  solution, something that is necessary in an adjoint analysis, hence my
  question about the example.

 Interpolation arises for continuous adjoints.  Be aware that if you
 want consistent gradients, you'll want a discrete adjoint, which
 integrates backward in time using the adjoint RK method.  The stages of
 the adjoint RK method coincide with the forward method, so no
 interpolation is needed.

 Hong (Cc'd) is developing an example that can integrate discrete adjoint
 equations and we intend to eventually incorporate that functionality
 into the library.




-- 
*Miguel Angel Salazar de Troya*
Graduate Research Assistant
Department of Mechanical Science and Engineering
University of Illinois at Urbana-Champaign
(217) 550-2360
salaz...@illinois.edu