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

nasa / trick / 14071469245

25 Mar 2025 10:40PM UTC coverage: 55.95% (+0.06%) from 55.886%
14071469245

Pull #1844

github

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

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

14 existing lines in 3 files now uncovered.

12328 of 22034 relevant lines covered (55.95%)

86796.13 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
     */
75
    void initialize_rates();
76

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

177
} // namespace Trick
178

179
#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