View Javadoc

1   package org.catacomb.be;
2   
3   
4   
5   
6   public final class TimePoint {
7   
8       int istep;
9   
10      double dt;
11      double time;
12      double previousTime;
13      double runtime;
14      Timestep timestep;
15  
16  
17  
18      public TimePoint() {
19          time = 0.;
20          dt = 1.;
21          runtime = 100.;
22          timestep = new BasicTimestep(dt);
23      }
24  
25      public TimePoint(double dt, double t0) {
26          istep = 0;
27          this.dt = dt;
28          this.time = t0;
29          this.previousTime = t0 - dt;
30      }
31  
32  
33      public void setDt(double d) {
34          dt = d;
35          timestep = new BasicTimestep(dt);
36      }
37  
38      public void setRuntime(double d) {
39          runtime = d;
40      }
41  
42  
43      public boolean isFinished() {
44          return (time >= runtime);
45      }
46  
47      public double getProgressFraction() {
48          if (runtime <= 0) {
49              runtime = 1.;
50          }
51          return time / runtime;
52      }
53  
54      public String getProgressDescription() {
55          Long ns = new Long(Math.round(runtime / dt));
56          Integer iso = new Integer(istep > 0 ? istep-1 : 0);
57          String ret = String.format("step %d of %d (t=%.4g)", iso, ns, new Double(time));
58  //      return "step " + istep + " of " + ns + " t=" + time;
59          return ret;
60      }
61  
62      public double getTime() {
63          return time;
64      }
65  
66      public double getPreviousTime() {
67          return previousTime;
68      }
69  
70  
71      public double getDt() {
72          return dt;
73      }
74  
75      public int getStep() {
76          return istep;
77      }
78  
79      public void increment() {
80          previousTime = time;
81          time += dt;
82          istep += 1;
83      }
84  
85      public Timestep getTimestep() {
86          return timestep;
87      }
88  
89  
90  
91  }