Hi Sophie,

TSSetPostEventIntervalStep() was designed to reset the step size after an event 
interval. For example, suppose there is an event at 0.16, TS may identify it 
when integrating over a time step from 0.1 to 0.2. After the event, the next 
step size would be 0.04 to reach the end of this event interval ([0.1,0.2]). 
After the event interval, the step size would be set to the value you specified 
with TSSetPostEventIntervalStep(). However, TSSetPostEventIntervalStep() will 
take no effect if the event occurs at exactly 0.2 instead of somewhere inside 
the interval. I am not sure about the original intention of this design. But I 
have added an option -ts_event_post_event_step for you to hard reset the step 
size immediately after an event. Please try the latest main branch to see if it 
helps.

Hong (Mr.)

On Jan 19, 2021, at 10:13 AM, Blondel, Sophie via petsc-users 
<[email protected]> wrote:

Hi Barry and Matt and happy new year,

I wanted to check again if there was anything new with the TSSetEventHandler 
and TSSetPostEventIntervalStep. If you think there could be an alternative way 
to obtain the behavior I want in PETSc I'd be happy to try it.

Cheers,

Sophie
From: Blondel, Sophie <[email protected]>
Sent: Tuesday, December 1, 2020 16:14
To: Barry Smith <[email protected]>; Matthew Knepley <[email protected]>
Cc: [email protected] <[email protected]>; 
[email protected] 
<[email protected]>
Subject: Re: [petsc-users] TSSetEventHandler and TSSetPostEventIntervalStep
 
Hi again Barry and Matt,

Just wanted to check the status for the TSSetEventHandler. Let me know if I can 
help in any way.

Cheers,

Sophie
From: Blondel, Sophie <[email protected]>
Sent: Monday, November 16, 2020 11:38
To: Barry Smith <[email protected]>; Matthew Knepley <[email protected]>
Cc: [email protected] <[email protected]>; 
[email protected] 
<[email protected]>
Subject: Re: [petsc-users] TSSetEventHandler and TSSetPostEventIntervalStep
 
Hi Matt and Barry,

I wanted to check if you wanted me to test anything with the branch from Barry, 
it was not clear from the previous emails.

Cheers,

Sophie
From: Barry Smith <[email protected]>
Sent: Tuesday, October 27, 2020 17:01
To: Matthew Knepley <[email protected]>
Cc: Blondel, Sophie <[email protected]>; [email protected] 
<[email protected]>; [email protected] 
<[email protected]>
Subject: Re: [petsc-users] TSSetEventHandler and TSSetPostEventIntervalStep
 

  Pushed

On Oct 27, 2020, at 3:41 PM, Matthew Knepley <[email protected]> wrote:

On Tue, Oct 27, 2020 at 4:24 PM Barry Smith <[email protected]> wrote:

  I'm sorry the code is still fundamentally broken, I know I promised a long 
time ago to fix it all up but it is actually pretty hard to get right.

  It detects the zero by finding a small value when it should detect it by find 
a small region where it changes sign but surprising it is so hardwired
to the size test that fixing it and testing the new code has been very 
difficult to me.  My branch is barry/2019-08-18/fix-tsevent-posteventdt

Barry, I do not see this branch on gitlab. Can you give a URL?

  Thanks,

     Matt
 
  Barry



On Oct 27, 2020, at 3:02 PM, Blondel, Sophie via petsc-users 
<[email protected]> wrote:

Hi Matt,

With the ex40 I attached in my previous email here is what I get printed on 
screen when running "./ex40 -ts_monitor -ts_event_monitor":
0 TS dt 0.1 time 0.
1 TS dt 0.5 time 0.1
2 TS dt 0.5 time 0.6
3 TS dt 0.5 time 1.1
4 TS dt 0.5 time 1.6
5 TS dt 0.5 time 2.1
6 TS dt 0.5 time 2.6
7 TS dt 0.5 time 3.1
8 TS dt 0.5 time 3.6
9 TS dt 0.5 time 4.1
10 TS dt 0.5 time 4.6
11 TS dt 0.5 time 5.1
12 TS dt 0.5 time 5.6
13 TS dt 0.5 time 6.1
14 TS dt 0.5 time 6.6
15 TS dt 0.5 time 7.1
TSEvent: Event 0 zero crossing at time 7.6 located in 0 iterations
Ball hit the ground at t =  7.60 seconds
16 TS dt 0.5 time 7.6
17 TS dt 0.5 time 8.1
18 TS dt 0.5 time 8.6
19 TS dt 0.5 time 9.1
20 TS dt 0.5 time 9.6
21 TS dt 0.5 time 10.1
22 TS dt 0.5 time 10.6
23 TS dt 0.5 time 11.1
24 TS dt 0.5 time 11.6
25 TS dt 0.5 time 12.1
26 TS dt 0.5 time 12.6
27 TS dt 0.5 time 13.1
28 TS dt 0.5 time 13.6
29 TS dt 0.5 time 14.1
30 TS dt 0.5 time 14.6
31 TS dt 0.5 time 15.1
32 TS dt 0.5 time 15.6
33 TS dt 0.5 time 16.1
34 TS dt 0.5 time 16.6
35 TS dt 0.5 time 17.1
36 TS dt 0.5 time 17.6
37 TS dt 0.5 time 18.1
38 TS dt 0.5 time 18.6
39 TS dt 0.5 time 19.1
40 TS dt 0.5 time 19.6
41 TS dt 0.5 time 20.1
42 TS dt 0.5 time 20.6
43 TS dt 0.5 time 21.1
44 TS dt 0.5 time 21.6
45 TS dt 0.5 time 22.1
46 TS dt 0.5 time 22.6
47 TS dt 0.5 time 23.1
48 TS dt 0.5 time 23.6
49 TS dt 0.5 time 24.1
50 TS dt 0.5 time 24.6
51 TS dt 0.5 time 25.1
TSEvent: Event 0 zero crossing at time 25.6 located in 0 iterations
Ball hit the ground at t = 25.60 seconds
52 TS dt 0.5 time 25.6
53 TS dt 0.5 time 26.1
54 TS dt 0.5 time 26.6
55 TS dt 0.5 time 27.1
56 TS dt 0.5 time 27.6
57 TS dt 0.5 time 28.1
58 TS dt 0.5 time 28.6
59 TS dt 0.5 time 29.1
60 TS dt 0.5 time 29.6
61 TS dt 0.5 time 30.1
0 TS dt 0.1 time 0.
1 TS dt 0.5 time 0.1
2 TS dt 0.5 time 0.6
3 TS dt 0.5 time 1.1
4 TS dt 0.5 time 1.6
5 TS dt 0.5 time 2.1
6 TS dt 0.5 time 2.6
7 TS dt 0.5 time 3.1
8 TS dt 0.5 time 3.6
9 TS dt 0.5 time 4.1
10 TS dt 0.5 time 4.6
11 TS dt 0.5 time 5.1
12 TS dt 0.5 time 5.6
13 TS dt 0.5 time 6.1
14 TS dt 0.5 time 6.6
15 TS dt 0.5 time 7.1
16 TS dt 0.5 time 7.6
17 TS dt 0.5 time 8.1
18 TS dt 0.5 time 8.6
19 TS dt 0.5 time 9.1
20 TS dt 0.5 time 9.6
21 TS dt 0.5 time 10.1
22 TS dt 0.5 time 10.6
23 TS dt 0.5 time 11.1
24 TS dt 0.5 time 11.6
25 TS dt 0.5 time 12.1
26 TS dt 0.5 time 12.6
TSEvent: Event 0 zero crossing at time 13.1 located in 0 iterations
Ball hit the ground at t = 13.10 seconds
27 TS dt 0.5 time 13.1
28 TS dt 0.5 time 13.6
29 TS dt 0.5 time 14.1
30 TS dt 0.5 time 14.6
31 TS dt 0.5 time 15.1
32 TS dt 0.5 time 15.6
33 TS dt 0.5 time 16.1
34 TS dt 0.5 time 16.6
35 TS dt 0.5 time 17.1
36 TS dt 0.5 time 17.6
37 TS dt 0.5 time 18.1
38 TS dt 0.5 time 18.6
39 TS dt 0.5 time 19.1
40 TS dt 0.5 time 19.6
41 TS dt 0.5 time 20.1
42 TS dt 0.5 time 20.6
43 TS dt 0.5 time 21.1
44 TS dt 0.5 time 21.6
45 TS dt 0.5 time 22.1
46 TS dt 0.5 time 22.6
47 TS dt 0.5 time 23.1
TSEvent: Event 0 zero crossing at time 23.6 located in 0 iterations
Ball hit the ground at t = 23.60 seconds
48 TS dt 0.5 time 23.6
49 TS dt 0.5 time 24.1
50 TS dt 0.5 time 24.6
51 TS dt 0.5 time 25.1
52 TS dt 0.5 time 25.6
53 TS dt 0.5 time 26.1
TSEvent: Event 0 zero crossing at time 26.6 located in 0 iterations
Ball hit the ground at t = 26.60 seconds
54 TS dt 0.5 time 26.6
55 TS dt 0.5 time 27.1
56 TS dt 0.5 time 27.6
57 TS dt 0.5 time 28.1
58 TS dt 0.5 time 28.6
59 TS dt 0.5 time 29.1
60 TS dt 0.5 time 29.6
61 TS dt 0. time 30.1

I don't see the 0.001 timestep here, do you get a different behavior?

Thank you,

Sophie
From: Matthew Knepley <[email protected]>
Sent: Tuesday, October 27, 2020 15:34
To: Blondel, Sophie <[email protected]>
Cc: [email protected] <[email protected]>; 
[email protected] 
<[email protected]>
Subject: Re: [petsc-users] TSSetEventHandler and TSSetPostEventIntervalStep
 
[External Email]
On Tue, Oct 27, 2020 at 3:09 PM Blondel, Sophie via petsc-users 
<[email protected]> wrote:
Hi,

I am currently using TSSetEventHandler in my code to detect a random event 
where the solution vector gets modified during the event. Ideally, after the 
event happens I want the solver to use a much smaller timestep using 
TSSetPostEventIntervalStep. However, when I use TSSetPostEventIntervalStep the 
solver doesn't use the set value. I managed to reproduce the behavior by 
modifying ex40.c as attached.

 I stepped through ex40, and it does indeed change the timestep to 0.001. Can 
you be more specific, perhaps with monitors, about what you think is wrong?

  Thanks,

     Matt
 
I think the issue is related to the fact that the fvalue is not technically 
"approaching" 0 with a random event, it is more of a step function instead. Do 
you have any recommendation on how to implement the behavior I'm looking for? 
Let me know if I can provide additional information.

Best,

Sophie


-- 
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

https://www.cse.buffalo.edu/~knepley/



-- 
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

https://www.cse.buffalo.edu/~knepley/

Reply via email to