EventOccurrence.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.events;

  18. import org.hipparchus.ode.ODEState;

  19. /**
  20.  * Class to hold the data related to an event occurrence that is needed to decide how
  21.  * to modify integration.
  22.  * @since 3.O
  23.  */
  24. public class EventOccurrence {

  25.     /** User requested action. */
  26.     private final Action action;
  27.     /** New state for a reset action. */
  28.     private final ODEState newState;
  29.     /** The time to stop propagation if the action is a stop event. */
  30.     private final double stopTime;

  31.     /**
  32.      * Create a new occurrence of an event.
  33.      *
  34.      * @param action   the user requested action.
  35.      * @param newState for a reset event. Should be the current state unless the
  36.      *                 action is {@link Action#RESET_STATE}.
  37.      * @param stopTime to stop propagation if the action is {@link Action#STOP}. Used
  38.      *                 to move the stop time to just after the root.
  39.      */
  40.     public EventOccurrence(final Action action,
  41.                            final ODEState newState,
  42.                            final double stopTime) {
  43.         this.action = action;
  44.         this.newState = newState;
  45.         this.stopTime = stopTime;
  46.     }

  47.     /**
  48.      * Get the user requested action.
  49.      *
  50.      * @return the action.
  51.      */
  52.     public Action getAction() {
  53.         return action;
  54.     }

  55.     /**
  56.      * Get the new state for a reset action.
  57.      *
  58.      * @return the new state.
  59.      */
  60.     public ODEState getNewState() {
  61.         return newState;
  62.     }

  63.     /**
  64.      * Get the new time for a stop action.
  65.      *
  66.      * @return when to stop propagation.
  67.      */
  68.     public double getStopTime() {
  69.         return stopTime;
  70.     }

  71. }