View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  
23  package org.hipparchus.migration.ode.sampling;
24  
25  import org.hipparchus.exception.MathIllegalStateException;
26  import org.hipparchus.ode.ODEStateAndDerivative;
27  import org.hipparchus.ode.sampling.ODEStateInterpolator;
28  import org.hipparchus.ode.sampling.ODEStepHandler;
29  
30  
31  /**
32   * This interface represents a handler that should be called after
33   * each successful step.
34   *
35   * <p>The ODE integrators compute the evolution of the state vector at
36   * some grid points that depend on their own internal algorithm. Once
37   * they have found a new grid point (possibly after having computed
38   * several evaluation of the derivative at intermediate points), they
39   * provide it to objects implementing this interface. These objects
40   * typically either ignore the intermediate steps and wait for the
41   * last one, store the points in an ephemeris, or forward them to
42   * specialized processing or output methods.</p>
43   *
44   * @see org.hipparchus.ode.ODEIntegrator
45   * @see ODEStateInterpolator
46   * @deprecated as of 1.0, replaced with {@link ODEStepHandler}
47   */
48  @Deprecated
49  public interface StepHandler extends ODEStepHandler {
50  
51      /** {@inheritDoc}} */
52      @Override
53      default void init(final ODEStateAndDerivative initialState, final double finalTime) {
54          init(initialState.getTime(), initialState.getPrimaryState(), finalTime);
55      }
56  
57      /** {@inheritDoc}} */
58      @Override
59      default void handleStep(final ODEStateInterpolator interpolator)
60          throws MathIllegalStateException {
61          handleStep(new MigrationStepInterpolator(interpolator), false);
62      }
63  
64      /** Initialize step handler at the start of an ODE integration.
65       * <p>
66       * This method is called once at the start of the integration. It
67       * may be used by the step handler to initialize some internal data
68       * if needed.
69       * </p>
70       * @param t0 start value of the independent <i>time</i> variable
71       * @param y0 array containing the start value of the state vector
72       * @param t target time for the integration
73       */
74      void init(double t0, double[] y0, double t);
75  
76      /**
77       * Handle the last accepted step
78       * @param interpolator interpolator for the last accepted step. For
79       * efficiency purposes, the various integrators reuse the same
80       * object on each call, so if the instance wants to keep it across
81       * all calls (for example to provide at the end of the integration a
82       * continuous model valid throughout the integration range, as the
83       * {@link org.hipparchus.migration.ode.ContinuousOutputModel
84       * ContinuousOutputModel} class does), it should build a local copy
85       * using the clone method of the interpolator and store this copy.
86       * Keeping only a reference to the interpolator and reusing it will
87       * result in unpredictable behavior (potentially crashing the application).
88       * @param isLast true if the step is the last one
89       * @exception MathIllegalStateException if the interpolator throws one because
90       * the number of functions evaluations is exceeded
91       */
92      void handleStep(MigrationStepInterpolator interpolator, boolean isLast)
93          throws MathIllegalStateException;
94  
95  }