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
020import org.apache.commons.math3.RealFieldElement;
021import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
022
023/**
024 * This interface represents a handler that should be called after
025 * each successful fixed step.
026
027 * <p>This interface should be implemented by anyone who is interested
028 * in getting the solution of an ordinary differential equation at
029 * fixed time steps. Objects implementing this interface should be
030 * wrapped within an instance of {@link FieldStepNormalizer} that itself
031 * is used as the general {@link FieldStepHandler} by the integrator. The
032 * {@link FieldStepNormalizer} object is called according to the integrator
033 * internal algorithms and it calls objects implementing this
034 * interface as necessary at fixed time steps.</p>
035 *
036 * @see FieldStepHandler
037 * @see FieldStepNormalizer
038 * @see FieldStepInterpolator
039 * @param <T> the type of the field elements
040 * @since 3.6
041 */
042
043public interface FieldFixedStepHandler<T extends RealFieldElement<T>> {
044
045    /** Initialize step handler at the start of an ODE integration.
046     * <p>
047     * This method is called once at the start of the integration. It
048     * may be used by the step handler to initialize some internal data
049     * if needed.
050     * </p>
051     * @param initialState initial time, state vector and derivative
052     * @param finalTime target time for the integration
053     */
054    void init(FieldODEStateAndDerivative<T> initialState, T finalTime);
055
056    /**
057     * Handle the last accepted step
058     * @param state current value of the independent <i>time</i> variable,
059     * state vector and derivative
060     * For efficiency purposes, the {@link FieldStepNormalizer} class reuses
061     * the same array on each call, so if
062     * the instance wants to keep it across all calls (for example to
063     * provide at the end of the integration a complete array of all
064     * steps), it should build a local copy store this copy.
065     * @param isLast true if the step is the last one
066     */
067    void handleStep(FieldODEStateAndDerivative<T> state, boolean isLast);
068
069}