ROL
src
function
dynamic
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
24
namespace
ROL
{
25
26
27
template
<
typename
>
struct
TimeStamp;
28
29
// Alias for pointer vector of TimeStamp objects
30
template
<
typename
Real>
31
using
TimeStampsPtr
= Ptr<std::vector<TimeStamp<Real>>>;
32
33
34
template
<
typename
Real>
35
struct
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
42
TimeStamp
&
operator=
(
const
TimeStamp
& ts ) {
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
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::TimeStampsPtr
Ptr< std::vector< TimeStamp< Real > > > TimeStampsPtr
Definition
ROL_TimeStamp.hpp:31
ROL::TimeStamp
Contains local time step information.
Definition
ROL_TimeStamp.hpp:35
ROL::TimeStamp::size_type
typename std::vector< Real >::size_type size_type
Definition
ROL_TimeStamp.hpp:37
ROL::TimeStamp::operator=
TimeStamp & operator=(const TimeStamp &ts)
Definition
ROL_TimeStamp.hpp:42
ROL::TimeStamp::k
size_type k
Definition
ROL_TimeStamp.hpp:39
ROL::TimeStamp::t
std::vector< Real > t
Definition
ROL_TimeStamp.hpp:40
ROL::TimeStamp::make_uniform
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...
Definition
ROL_TimeStamp.hpp:50
Generated by
1.9.8