FieldODEFixedStepHandler.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.CalculusFieldElement;
  19. import org.hipparchus.ode.FieldODEStateAndDerivative;

  20. /**
  21.  * This interface represents a handler that should be called after
  22.  * each successful fixed step.

  23.  * <p>This interface should be implemented by anyone who is interested
  24.  * in getting the solution of an ordinary differential equation at
  25.  * fixed time steps. Objects implementing this interface should be
  26.  * wrapped within an instance of {@link FieldStepNormalizer} that itself
  27.  * is used as the general {@link FieldODEStepHandler} by the integrator. The
  28.  * {@link FieldStepNormalizer} object is called according to the integrator
  29.  * internal algorithms and it calls objects implementing this
  30.  * interface as necessary at fixed time steps.</p>
  31.  *
  32.  * @see FieldODEStepHandler
  33.  * @see FieldStepNormalizer
  34.  * @see FieldODEStateInterpolator
  35.  * @param <T> the type of the field elements
  36.  */

  37. public interface FieldODEFixedStepHandler<T extends CalculusFieldElement<T>> {

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

  53.     /**
  54.      * Handle the last accepted step
  55.      * @param state current value of the independent <i>time</i> variable,
  56.      * state vector and derivative
  57.      * For efficiency purposes, the {@link FieldStepNormalizer} class reuses
  58.      * the same array on each call, so if
  59.      * the instance wants to keep it across all calls (for example to
  60.      * provide at the end of the integration a complete array of all
  61.      * steps), it should build a local copy store this copy.
  62.      * @param isLast true if the step is the last one
  63.      */
  64.     void handleStep(FieldODEStateAndDerivative<T> state, boolean isLast);

  65. }