AbstractVariableStepFieldIntegratorBuilder.java

  1. /* Copyright 2002-2025 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS 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. package org.orekit.propagation.conversion;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.hipparchus.ode.nonstiff.AdaptiveStepsizeFieldIntegrator;
  21. import org.orekit.orbits.Orbit;
  22. import org.orekit.orbits.OrbitType;
  23. import org.orekit.orbits.PositionAngleType;
  24. import org.orekit.propagation.ToleranceProvider;
  25. import org.orekit.utils.FieldAbsolutePVCoordinates;

  26. /**
  27.  * Abstract class for integrator builder using variable step size.
  28.  *
  29.  * @param <T> type of the field elements
  30.  *
  31.  * @author Vincent Cucchietti
  32.  */
  33. public abstract class AbstractVariableStepFieldIntegratorBuilder<T extends CalculusFieldElement<T>, W extends AdaptiveStepsizeFieldIntegrator<T>>
  34.         extends FieldAbstractIntegratorBuilder<T, W> {

  35.     /** Minimum step size (s). */
  36.     private final double minStep;

  37.     /** Maximum step size (s). */
  38.     private final double maxStep;

  39.     /** Integration tolerance provider. */
  40.     private final ToleranceProvider toleranceProvider;

  41.     /**
  42.      * Constructor with expected velocity error.
  43.      *
  44.      * @param minStep minimum step size (s)
  45.      * @param maxStep maximum step size (s)
  46.      * @param toleranceProvider integration tolerance provider
  47.      * @since 13.0
  48.      */
  49.     protected AbstractVariableStepFieldIntegratorBuilder(final double minStep, final double maxStep,
  50.                                                          final ToleranceProvider toleranceProvider) {
  51.         this.minStep = minStep;
  52.         this.maxStep = maxStep;
  53.         this.toleranceProvider = toleranceProvider;
  54.     }

  55.     /**
  56.      * Getter for the maximum step.
  57.      * @return max stepsize
  58.      * @since 13.0
  59.      */
  60.     public double getMaxStep() {
  61.         return maxStep;
  62.     }

  63.     /**
  64.      * Getter for the minimum step.
  65.      * @return min stepsize
  66.      * @since 13.0
  67.      */
  68.     public double getMinStep() {
  69.         return minStep;
  70.     }

  71.     /**
  72.      * Getter for the integration tolerance provider.
  73.      * @return tolerance provider
  74.      * @since 13.0
  75.      */
  76.     public ToleranceProvider getToleranceProvider() {
  77.         return toleranceProvider;
  78.     }

  79.     /**
  80.      * Computes tolerances.
  81.      * @param orbit initial orbit
  82.      * @param orbitType orbit type to use
  83.      * @param angleType position angle type to use
  84.      * @return integrator tolerances
  85.      * @since 13.0
  86.      */
  87.     protected double[][] getTolerances(final Orbit orbit, final OrbitType orbitType, final PositionAngleType angleType) {
  88.         return toleranceProvider.getTolerances(orbit, orbitType, angleType);
  89.     }

  90.     /**
  91.      * Computes tolerances.
  92.      * @param fieldAbsolutePVCoordinates position-velocity vector
  93.      * @return integrator tolerances
  94.      * @since 13.0
  95.      */
  96.     protected double[][] getTolerances(final FieldAbsolutePVCoordinates<T> fieldAbsolutePVCoordinates) {
  97.         return toleranceProvider.getTolerances(fieldAbsolutePVCoordinates);
  98.     }

  99.     /** {@inheritDoc} */
  100.     @Override
  101.     public W buildIntegrator(final Field<T> field, final Orbit orbit,
  102.                              final OrbitType orbitType, final PositionAngleType angleType) {
  103.         return buildIntegrator(field, getTolerances(orbit, orbitType, angleType));
  104.     }

  105.     /** {@inheritDoc} */
  106.     @Override
  107.     public W buildIntegrator(final FieldAbsolutePVCoordinates<T> fieldAbsolutePVCoordinates) {
  108.         return buildIntegrator(fieldAbsolutePVCoordinates.getDate().getField(), getTolerances(fieldAbsolutePVCoordinates));
  109.     }

  110.     /**
  111.      * Build integrator from absolute and relative tolerances.
  112.      * @param field field
  113.      * @param tolerances array of tolerances
  114.      * @return integrator
  115.      * @since 13.0
  116.      */
  117.     protected abstract W buildIntegrator(Field<T> field, double[][] tolerances);

  118.     /**
  119.      * Get a default tolerance provider.
  120.      * @param dP expected position error (m)
  121.      * @return tolerance provider
  122.      * @since 13.0
  123.      */
  124.     protected static ToleranceProvider getDefaultToleranceProvider(final double dP) {
  125.         return ToleranceProvider.getDefaultToleranceProvider(dP);
  126.     }
  127. }