FieldODEStepHandler.java

  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.  * This is not the original file distributed by the Apache Software Foundation
  19.  * It has been modified by the Hipparchus project
  20.  */

  21. package org.hipparchus.ode.sampling;

  22. import org.hipparchus.CalculusFieldElement;
  23. import org.hipparchus.ode.FieldODEStateAndDerivative;

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

  41. public interface FieldODEStepHandler<T extends CalculusFieldElement<T>> {

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

  57.     /**
  58.      * Handle the last accepted step.
  59.      * @param interpolator interpolator for the last accepted step
  60.      */
  61.     void handleStep(FieldODEStateInterpolator<T> interpolator);

  62.     /**
  63.      * Finalize integration.
  64.      * @param finalState state at integration end
  65.      * @since 2.0
  66.      */
  67.     default void finish(FieldODEStateAndDerivative<T> finalState) {
  68.         // nothing by default
  69.     }

  70. }