001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.math3.ode.sampling;
019
020
021/**
022 * This interface represents a handler that should be called after
023 * each successful fixed step.
024
025 * <p>This interface should be implemented by anyone who is interested
026 * in getting the solution of an ordinary differential equation at
027 * fixed time steps. Objects implementing this interface should be
028 * wrapped within an instance of {@link StepNormalizer} that itself
029 * is used as the general {@link StepHandler} by the integrator. The
030 * {@link StepNormalizer} object is called according to the integrator
031 * internal algorithms and it calls objects implementing this
032 * interface as necessary at fixed time steps.</p>
033 *
034 * @see StepHandler
035 * @see StepNormalizer
036 * @since 1.2
037 */
038
039public interface FixedStepHandler  {
040
041  /** Initialize step handler at the start of an ODE integration.
042   * <p>
043   * This method is called once at the start of the integration. It
044   * may be used by the step handler to initialize some internal data
045   * if needed.
046   * </p>
047   * @param t0 start value of the independent <i>time</i> variable
048   * @param y0 array containing the start value of the state vector
049   * @param t target time for the integration
050   */
051  void init(double t0, double[] y0, double t);
052
053  /**
054   * Handle the last accepted step
055   * @param t time of the current step
056   * @param y state vector at t. For efficiency purposes, the {@link
057   * StepNormalizer} class reuses the same array on each call, so if
058   * the instance wants to keep it across all calls (for example to
059   * provide at the end of the integration a complete array of all
060   * steps), it should build a local copy store this copy.
061   * @param yDot derivatives of the state vector state vector at t.
062   * For efficiency purposes, the {@link StepNormalizer} class reuses
063   * the same array on each call, so if
064   * the instance wants to keep it across all calls (for example to
065   * provide at the end of the integration a complete array of all
066   * steps), it should build a local copy store this copy.
067   * @param isLast true if the step is the last one
068   */
069  void handleStep(double t, double[] y, double[] yDot, boolean isLast);
070
071}