ROL
ROL_TimeStamp.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#pragma once
11#ifndef ROL_TIMESTAMP_HPP
12#define ROL_TIMESTAMP_HPP
13
14
15#include <vector>
16
17#include "ROL_Ptr.hpp"
18
24namespace ROL {
25
26
27template<typename> struct TimeStamp;
28
29// Alias for pointer vector of TimeStamp objects
30template<typename Real>
31using TimeStampsPtr = Ptr<std::vector<TimeStamp<Real>>>;
32
33
34template<typename Real>
35struct TimeStamp {
36
37 using size_type = typename std::vector<Real>::size_type;
38
39 size_type k; // Time-step number
40 std::vector<Real> t; // Time points for this time step
41
43 k = ts.k; t = ts.t;
44 return *this;
45 }
46
50 static TimeStampsPtr<Real> make_uniform( Real t_initial,
51 Real t_final,
52 const std::vector<Real>& t_ref,
53 size_type num_steps ) {
54
55 auto timeStamp = ROL::makePtr<std::vector<ROL::TimeStamp<Real>>>(num_steps);
56
57 Real dt = (t_final-t_initial)/num_steps; // size of each time step
58 size_type nt = t_ref.size(); // number of time points per step
59
60 for( size_type k=0; k<num_steps; ++k ) {
61 (*timeStamp)[k].t.resize(nt);
62 for( size_type l=0; l<nt; ++l ) (*timeStamp)[k].t[l] = dt*(k+t_ref[l]);
63 (*timeStamp)[k].k = k;
64 }
65 return timeStamp;
66 }
67};
68
69} // namespace ROL
70
71
72#endif // ROL_TIMESTAMP_HPP
73
Ptr< std::vector< TimeStamp< Real > > > TimeStampsPtr
Contains local time step information.
typename std::vector< Real >::size_type size_type
TimeStamp & operator=(const TimeStamp &ts)
std::vector< Real > t
static TimeStampsPtr< Real > make_uniform(Real t_initial, Real t_final, const std::vector< Real > &t_ref, size_type num_steps)
Create a vector of uniform TimeStamp objects for the interval [t_initial,t_final] where each step has...