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 * http://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 18package org.apache.commons.math.ode.sampling; 19 20import org.apache.commons.math.ode.DerivativeException; 21 22/** 23 * This interface represents a handler that should be called after 24 * each successful step. 25 * 26 * <p>The ODE integrators compute the evolution of the state vector at 27 * some grid points that depend on their own internal algorithm. Once 28 * they have found a new grid point (possibly after having computed 29 * several evaluation of the derivative at intermediate points), they 30 * provide it to objects implementing this interface. These objects 31 * typically either ignore the intermediate steps and wait for the 32 * last one, store the points in an ephemeris, or forward them to 33 * specialized processing or output methods.</p> 34 * 35 * @see org.apache.commons.math.ode.FirstOrderIntegrator 36 * @see org.apache.commons.math.ode.SecondOrderIntegrator 37 * @see StepInterpolator 38 * @version $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $ 39 * @since 1.2 40 */ 41 42public interface StepHandler { 43 44 /** Determines whether this handler needs dense output. 45 * <p>This method allows the integrator to avoid performing extra 46 * computation if the handler does not need dense output. If this 47 * method returns false, the integrator will call the {@link 48 * #handleStep} method with a {@link DummyStepInterpolator} rather 49 * than a custom interpolator.</p> 50 * @return true if the handler needs dense output 51 */ 52 boolean requiresDenseOutput(); 53 54 /** Reset the step handler. 55 * Initialize the internal data as required before the first step is 56 * handled. 57 */ 58 void reset(); 59 60 /** 61 * Handle the last accepted step 62 * @param interpolator interpolator for the last accepted step. For 63 * efficiency purposes, the various integrators reuse the same 64 * object on each call, so if the instance wants to keep it across 65 * all calls (for example to provide at the end of the integration a 66 * continuous model valid throughout the integration range, as the 67 * {@link org.apache.commons.math.ode.ContinuousOutputModel 68 * ContinuousOutputModel} class does), it should build a local copy 69 * using the clone method of the interpolator and store this copy. 70 * Keeping only a reference to the interpolator and reusing it will 71 * result in unpredictable behavior (potentially crashing the application). 72 * @param isLast true if the step is the last one 73 * @exception DerivativeException if user code called from step interpolator 74 * finalization triggers one 75 */ 76 void handleStep(StepInterpolator interpolator, boolean isLast) throws DerivativeException; 77 78} 79