• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 14178603755

31 Mar 2025 06:24PM UTC coverage: 55.95%. First build
14178603755

Pull #1844

github

web-flow
Merge cbb0f3534 into 957682f68
Pull Request #1844: Integrated MultiDtInteg classes into Trick build.

0 of 5 new or added lines in 2 files covered. (0.0%)

12328 of 22034 relevant lines covered (55.95%)

81206.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/include/trick/MultiDtIntegLoopScheduler.hh
1
/*
2
PURPOSE:
3
    ( Multi-Dt Integrator "Sim object" )
4
PROGRAMMERS:
5
    (((Thomas Brain) (METECS)  (2025)))
6
*/
7

8
#ifndef MULTIDTINTEGLOOPSCHEDULER_HH
9
#define MULTIDTINTEGLOOPSCHEDULER_HH
10

11
// Local includes
12
#include "trick/IntegLoopScheduler.hh"
13

14
// System includes
15
#include <math.h>
16

17
#ifdef SWIG
18
// We want SWIG to ignore add_sim_object(Trick::SimObject *)
19
// so only add_sim_object(Trick::SimObject &) can be called in input file.
20
%ignore Trick::MultiDtIntegLoopScheduler::add_sim_object(Trick::SimObject *) ;
21
#endif
22

23
namespace Trick
24
{
25

26
/**
27
 * This class is a Scheduler that provides the ability to integrate a
28
 * collection of sim object instances over time at multiple integration
29
 * rates similar to the IntegLoopScheduler class. The
30
 * MutliDtIntegLoopScheduler class integrates the same class of jobs
31
 * as IntegLoopScheduler. The primary difference is that this class may
32
 * have multiple integration rates specified for executing the integration
33
 * loop up to each point in time. For instance, if the user specifies
34
 * a 0.01 integration rate and a 0.015 integration rate, the scheduler will integrate
35
 * using a dt for each step and reschedules itself so that each rate is satisfied
36
 * i.e. it will integrate at:
37
 *  - 0.000->0.010
38
 *  - 0.010->0.015
39
 *  - 0.015->0.020
40
 *  - 0.020->0.030
41
 *  - 0.030->0.040
42
 *  - 0.040->0.045
43
 *
44
 * Because it acts as a self-scheduler that updates its job
45
 * rate with the Trick::Executive, this class complies with the standard Trick job
46
 * scheduling scheme.
47
 */
48
class MultiDtIntegLoopScheduler : public Trick::IntegLoopScheduler
49
{
50
public:
51
    /**
52
     * Non-default constructor.
53
     * @param in_cycle   The time interval at which the loop's integrate
54
     *                   function will be called. At least one is required.
55
     * @param parent_so  The Trick simulation object that contains this
56
     *                   IntegLoopScheduler object.
57
     */
58
    MultiDtIntegLoopScheduler(double in_cycle, Trick::SimObject * parent_so);
59

60
    /**
61
     * Default constructor.
62
     * @note This exists for checkpoint/restart. Other users should
63
     * not call this function.
64
     */
65
    MultiDtIntegLoopScheduler();
66

67
    /**
68
     * Destructor.
69
     */
NEW
70
    virtual ~MultiDtIntegLoopScheduler() {}
×
71

72
    /**
73
     * Compute the cycle tics and next tics values for each user-specified rate
74
     * @return Zero = success, non-zero = failure.
75
     */
76
    int initialize_rates();
77

78
    /**
79
     * Integrate state to the current simulation time.
80
     * Simulation time is advanced prior to calling this function.
81
     * Calculate the next cycle tic from the required rates and
82
     * tell the Executive scheduler so that the next current simulation time
83
     * is the next integ rate.
84
     */
85
    int integrate();
86

87
    /**
88
     * Add an integration rate to this loop scheduler
89
     * @param integRateIn  New integration rate in seconds
90
     * @return vector index of the added rate
91
     */
92
    size_t add_rate(const double integRateIn);
93

94
    /**
95
     * Get the total number of rates for this IntegLoop instance
96
     * @return total number of rates
97
     */
98
    size_t get_num_rates();
99

100
    /**
101
     * Get the integration rate according to rate index
102
     * @return cycle in seconds or -1.0 if error
103
     */
104
    double get_rate(const size_t rateIdx = 0);
105

106
    /**
107
     * Change the interval between calls to the integ_loop job.
108
     * @param cycle  New integration cycle time, in Trick seconds.
109
     */
110
    virtual int set_integ_cycle (double cycle);
111

112
    /**
113
     * Updates an integration rate by index and cycle. Calling with 0
114
     * index is equivalent to set_integ_cycle
115
     * @param rateIdx  New integration rate in seconds
116
     * @param integRateIn index of the added rate
117
     * @return Zero = success, non-zero = failure (rateIdx is invalid).
118
     */
119
    virtual int set_integ_rate(const size_t rateIdx, const double integRateIn);
120

121
protected:
122
    /**
123
     * Time in tics of the next required integration time.
124
     */
125
    long long next_tic;
126

127
    /**
128
     * Vector of integration rates in seconds.
129
     */
130
    std::vector<double> integ_rates;
131

132
    /**
133
     * Loop through the required integration rates and calculate the
134
     * next integration time in tics.
135
     * @return Next integration time in tics,
136
     */
137
    long long calculate_next_integ_tic();
138

139
    /**
140
     * Loop through the required integration rates and calculate the
141
     * next integration time in seconds.
142
     * @return Next integration time in seconds,
143
     */
144
    double calculate_next_integ_time();
145

146
    /**
147
     * Vector of next integration time in tics for each rate in the integRates vector
148
     */
149
    std::vector<long long> integ_next_tics;
150

151
    /**
152
     * Vector of integration rate in tics for each rate in the integRates vector
153
     */
154
    std::vector<long long> integ_cycle_tics;
155

156
    /**
157
     * Run-time vector of integration rate indices that will be processed this integration frame
158
     */
159
    std::vector<size_t> indices_to_process;
160

161
    /**
162
     * Find the associated integ_loop job from this object's
163
     * parnet_sim object
164
     * @return Pointer to integ_loop kob
165
     */
166
    JobData * find_integ_loop_job();
167

168
    /**
169
     * Vector of next integration time in tics for each rate in the integRates vector
170
     */
171
    std::vector<long long> integNextTics;
172
    /**
173
     * Vector of integration rate in tics for each rate in the integRates vector
174
     */
175
    std::vector<long long> integCycleTics;
176
};
177

178
} // namespace Trick
179

180
#endif /* MULTIDTINTEGLOOPSCHEDULER_HH */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc