ODEStepHandler.java

  1. /*
  2.  * Licensed to the Hipparchus project 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 Hipparchus project 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. package org.hipparchus.ode.sampling;

  18. import org.hipparchus.ode.ODEStateAndDerivative;


  19. /**
  20.  * This interface represents a handler that should be called after
  21.  * each successful step.
  22.  *
  23.  * <p>The ODE integrators compute the evolution of the state vector at
  24.  * some grid points that depend on their own internal algorithm. Once
  25.  * they have found a new grid point (possibly after having computed
  26.  * several evaluation of the derivative at intermediate points), they
  27.  * provide it to objects implementing this interface. These objects
  28.  * typically either ignore the intermediate steps and wait for the
  29.  * last one, store the points in an ephemeris, or forward them to
  30.  * specialized processing or output methods.</p>
  31.  *
  32.  * @see org.hipparchus.ode.ODEIntegrator
  33.  * @see ODEStateInterpolator
  34.  */

  35. public interface ODEStepHandler {

  36.     /** Initialize step handler at the start of an ODE integration.
  37.      * <p>
  38.      * This method is called once at the start of the integration. It
  39.      * may be used by the step handler to initialize some internal data
  40.      * if needed.
  41.      * </p>
  42.      * <p>
  43.      * The default implementation does nothing
  44.      * </p>
  45.      * @param initialState initial time, state vector and derivative
  46.      * @param finalTime target time for the integration
  47.      */
  48.     default void init(ODEStateAndDerivative initialState, double finalTime) {
  49.         // nothing by default
  50.     }

  51.     /**
  52.      * Handle the last accepted step.
  53.      * @param interpolator interpolator for the last accepted step
  54.      */
  55.     void handleStep(ODEStateInterpolator interpolator);

  56.     /**
  57.      * Finalize integration.
  58.      * @param finalState state at integration end
  59.      * @since 2.0
  60.      */
  61.     default void finish(ODEStateAndDerivative finalState) {
  62.         // nothing by default
  63.     }

  64. }