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
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.Field;
21 import org.hipparchus.ode.nonstiff.AdaptiveStepsizeFieldIntegrator;
22 import org.orekit.orbits.Orbit;
23 import org.orekit.orbits.OrbitType;
24 import org.orekit.orbits.PositionAngleType;
25 import org.orekit.propagation.ToleranceProvider;
26 import org.orekit.utils.FieldAbsolutePVCoordinates;
27
28 /**
29 * Abstract class for integrator builder using variable step size.
30 *
31 * @param <T> type of the field elements
32 *
33 * @author Vincent Cucchietti
34 */
35 public abstract class AbstractVariableStepFieldIntegratorBuilder<T extends CalculusFieldElement<T>, W extends AdaptiveStepsizeFieldIntegrator<T>>
36 extends FieldAbstractIntegratorBuilder<T, W> {
37
38 /** Minimum step size (s). */
39 private final double minStep;
40
41 /** Maximum step size (s). */
42 private final double maxStep;
43
44 /** Integration tolerance provider. */
45 private final ToleranceProvider toleranceProvider;
46
47 /**
48 * Constructor with expected velocity error.
49 *
50 * @param minStep minimum step size (s)
51 * @param maxStep maximum step size (s)
52 * @param toleranceProvider integration tolerance provider
53 * @since 13.0
54 */
55 protected AbstractVariableStepFieldIntegratorBuilder(final double minStep, final double maxStep,
56 final ToleranceProvider toleranceProvider) {
57 this.minStep = minStep;
58 this.maxStep = maxStep;
59 this.toleranceProvider = toleranceProvider;
60 }
61
62 /**
63 * Getter for the maximum step.
64 * @return max stepsize
65 * @since 13.0
66 */
67 public double getMaxStep() {
68 return maxStep;
69 }
70
71 /**
72 * Getter for the minimum step.
73 * @return min stepsize
74 * @since 13.0
75 */
76 public double getMinStep() {
77 return minStep;
78 }
79
80 /**
81 * Getter for the integration tolerance provider.
82 * @return tolerance provider
83 * @since 13.0
84 */
85 public ToleranceProvider getToleranceProvider() {
86 return toleranceProvider;
87 }
88
89 /**
90 * Computes tolerances.
91 * @param orbit initial orbit
92 * @param orbitType orbit type to use
93 * @param angleType position angle type to use
94 * @return integrator tolerances
95 * @since 13.0
96 */
97 protected double[][] getTolerances(final Orbit orbit, final OrbitType orbitType, final PositionAngleType angleType) {
98 return toleranceProvider.getTolerances(orbit, orbitType, angleType);
99 }
100
101 /**
102 * Computes tolerances.
103 * @param fieldAbsolutePVCoordinates position-velocity vector
104 * @return integrator tolerances
105 * @since 13.0
106 */
107 protected double[][] getTolerances(final FieldAbsolutePVCoordinates<T> fieldAbsolutePVCoordinates) {
108 return toleranceProvider.getTolerances(fieldAbsolutePVCoordinates);
109 }
110
111 /** {@inheritDoc} */
112 @Override
113 public W buildIntegrator(final Field<T> field, final Orbit orbit,
114 final OrbitType orbitType, final PositionAngleType angleType) {
115 return buildIntegrator(field, getTolerances(orbit, orbitType, angleType));
116 }
117
118 /** {@inheritDoc} */
119 @Override
120 public W buildIntegrator(final FieldAbsolutePVCoordinates<T> fieldAbsolutePVCoordinates) {
121 return buildIntegrator(fieldAbsolutePVCoordinates.getDate().getField(), getTolerances(fieldAbsolutePVCoordinates));
122 }
123
124 /**
125 * Build integrator from absolute and relative tolerances.
126 * @param field field
127 * @param tolerances array of tolerances
128 * @return integrator
129 * @since 13.0
130 */
131 protected abstract W buildIntegrator(Field<T> field, double[][] tolerances);
132
133 /**
134 * Get a default tolerance provider.
135 * @param dP expected position error (m)
136 * @return tolerance provider
137 * @since 13.0
138 */
139 protected static ToleranceProvider getDefaultToleranceProvider(final double dP) {
140 return ToleranceProvider.getDefaultToleranceProvider(dP);
141 }
142 }