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

  20. /**
  21.  * Class to hold the data related to an event occurrence that is needed to decide how
  22.  * to modify integration.
  23.  * @param <T> the type of the field elements
  24.  */
  25. public class FieldEventOccurrence<T extends CalculusFieldElement<T>> {

  26.     /** User requested action. */
  27.     private final Action action;
  28.     /** New state for a reset action. */
  29.     private final FieldODEState<T> newState;
  30.     /** The time to stop propagation if the action is a stop event. */
  31.     private final T stopTime;

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

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

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

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

  72. }