svZeroDSolver
Loading...
Searching...
No Matches
Parameter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
3/**
4 * @file Parameter.h
5 * @brief model::Parameter source file
6 */
7#ifndef SVZERODSOLVER_MODEL_PARAMETER_HPP_
8#define SVZERODSOLVER_MODEL_PARAMETER_HPP_
9
10#include <algorithm>
11#include <cmath>
12#include <iostream>
13#include <numeric>
14#include <vector>
15
16#include "DOFHandler.h"
17
18/**
19 * @brief Model Parameter.
20 *
21 * This class handles constant parameters and time-dependent parameters that
22 * need to be interpolated and periodically applied.
23 *
24 */
25class Parameter {
26 public:
27 /**
28 * @brief Construct a new Parameter object
29 *
30 * @param id Global ID of the parameter
31 * @param value The value of the parameter
32 */
33 Parameter(int id, double value);
34
35 /**
36 * @brief Construct a new Parameter object
37 *
38 * @param id Global ID of the parameter
39 * @param times Time steps corresponding to the time-dependent values
40 * @param values Values corresponding to the time steps
41 * @param periodic Is this parameter periodic with a cardiac cycle?
42 */
43 Parameter(int id, const std::vector<double>& times,
44 const std::vector<double>& values, bool periodic = true);
45
46 int id; ///< Global ID of the parameter
47 std::vector<double> times; ///< Time steps if parameter is time-dependent
48 std::vector<double> values; ///< Values if parameter is time-dependent
49 double value; ///< Value if parameter is constant
50 double cycle_period; ///< Cardiac cycle period corresponding to the time
51 ///< sequence
52 int size; ///< Size of the time series if parameter is time-dependent
53 bool is_constant; ///< Bool value indicating if the parameter is constant
54 bool is_periodic; ///< Bool value indicating if the parameter is periodic
55 ///< with the cardiac cycle
56
57 /**
58 * @brief Update the parameter
59 *
60 * @param value Value of the parameter
61 */
62 void update(double value);
63
64 /**
65 * @brief Update the parameter
66 *
67 * @param times Time steps corresponding to the values
68 * @param values Values correspondong to the time steps
69 */
70 void update(const std::vector<double>& times,
71 const std::vector<double>& values);
72
73 /**
74 * @brief Get the parameter value at the specified time.
75 *
76 * @param time Current time
77 * @return Value at the time
78 */
79 double get(double time);
80
81 /**
82 * @brief Convert the parameter into a steady mean state.
83 *
84 */
85 void to_steady();
86
87 /**
88 * @brief Convert the parameter back into an unsteady mean state.
89 *
90 */
91 void to_unsteady();
92
93 private:
94 bool steady_converted = false;
95};
96
97/**
98 * @brief Handles the properties of input parameters
99 */
101 bool is_optional; ///< Is this parameter optional?
102 bool is_array; ///< Is this parameter an array?
103 bool is_number; ///< Is this parameter a number?
104 double default_val; ///< Default value (if parameter is optional)
105
106 /**
107 * @brief Handles input parameters
108 *
109 * @param is_optional Is this parameter optional?
110 * @param is_array Is this parameter an array?
111 * @param is_number Is this parameter a number?
112 * @param default_val Default value (if parameter is optional)
113 */
114 InputParameter(bool is_optional = false, bool is_array = false,
115 bool is_number = true, double default_val = 0.0)
120};
121
122#endif // SVZERODSOLVER_MODEL_PARAMETER_HPP_
model::DOFHandler source file
int id
Global ID of the parameter.
Definition Parameter.h:46
std::vector< double > values
Values if parameter is time-dependent.
Definition Parameter.h:48
int size
Size of the time series if parameter is time-dependent.
Definition Parameter.h:52
std::vector< double > times
Time steps if parameter is time-dependent.
Definition Parameter.h:47
double value
Value if parameter is constant.
Definition Parameter.h:49
Parameter(int id, double value)
Construct a new Parameter object.
Definition Parameter.cpp:5
bool is_periodic
Definition Parameter.h:54
double get(double time)
Get the parameter value at the specified time.
Definition Parameter.cpp:38
void to_unsteady()
Convert the parameter back into an unsteady mean state.
Definition Parameter.cpp:81
bool is_constant
Bool value indicating if the parameter is constant.
Definition Parameter.h:53
void to_steady()
Convert the parameter into a steady mean state.
Definition Parameter.cpp:71
void update(double value)
Update the parameter.
Definition Parameter.cpp:17
double cycle_period
Definition Parameter.h:50
bool is_array
Is this parameter an array?
Definition Parameter.h:102
double default_val
Default value (if parameter is optional)
Definition Parameter.h:104
InputParameter(bool is_optional=false, bool is_array=false, bool is_number=true, double default_val=0.0)
Handles input parameters.
Definition Parameter.h:114
bool is_number
Is this parameter a number?
Definition Parameter.h:103
bool is_optional
Is this parameter optional?
Definition Parameter.h:101