svZeroDSolver
Loading...
Searching...
No Matches
Parameter.h
Go to the documentation of this file.
1// Copyright (c) Stanford University, The Regents of the University of
2// California, and others.
3//
4// All Rights Reserved.
5//
6// See Copyright-SimVascular.txt for additional details.
7//
8// Permission is hereby granted, free of charge, to any person obtaining
9// a copy of this software and associated documentation files (the
10// "Software"), to deal in the Software without restriction, including
11// without limitation the rights to use, copy, modify, merge, publish,
12// distribute, sublicense, and/or sell copies of the Software, and to
13// permit persons to whom the Software is furnished to do so, subject
14// to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included
17// in all copies or substantial portions of the Software.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30/**
31 * @file Parameter.h
32 * @brief model::Parameter source file
33 */
34#ifndef SVZERODSOLVER_MODEL_PARAMETER_HPP_
35#define SVZERODSOLVER_MODEL_PARAMETER_HPP_
36
37#include <math.h>
38
39#include <iostream>
40#include <numeric>
41#include <vector>
42
43#include "DOFHandler.h"
44
45/**
46 * @brief Model Parameter.
47 *
48 * This class handles constant parameters and time-dependent parameters that
49 * need to be interpolated and periodically applied.
50 *
51 */
52class Parameter {
53 public:
54 /**
55 * @brief Construct a new Parameter object
56 *
57 * @param id Global ID of the parameter
58 * @param value The value of the parameter
59 */
60 Parameter(int id, double value);
61
62 /**
63 * @brief Construct a new Parameter object
64 *
65 * @param id Global ID of the parameter
66 * @param times Time steps corresponding to the time-dependent values
67 * @param values Values corresponding to the time steps
68 * @param periodic Is this parameter periodic with a cardiac cycle?
69 */
70 Parameter(int id, const std::vector<double>& times,
71 const std::vector<double>& values, bool periodic = true);
72
73 int id; ///< Global ID of the parameter
74 std::vector<double> times; ///< Time steps if parameter is time-dependent
75 std::vector<double> values; ///< Values if parameter is time-dependent
76 double value; ///< Value if parameter is constant
77 double cycle_period; ///< Cardiac cycle period corresponding to the time
78 ///< sequence
79 int size; ///< Size of the time series if parameter is time-dependent
80 bool is_constant; ///< Bool value indicating if the parameter is constant
81 bool is_periodic; ///< Bool value indicating if the parameter is periodic
82 ///< with the cardiac cycle
83
84 /**
85 * @brief Update the parameter
86 *
87 * @param value Value of the parameter
88 */
89 void update(double value);
90
91 /**
92 * @brief Update the parameter
93 *
94 * @param times Time steps corresponding to the values
95 * @param values Values correspondong to the time steps
96 */
97 void update(const std::vector<double>& times,
98 const std::vector<double>& values);
99
100 /**
101 * @brief Get the parameter value at the specified time.
102 *
103 * @param time Current time
104 * @return Value at the time
105 */
106 double get(double time);
107
108 /**
109 * @brief Convert the parameter into a steady mean state.
110 *
111 */
112 void to_steady();
113
114 /**
115 * @brief Convert the parameter back into an unsteady mean state.
116 *
117 */
118 void to_unsteady();
119
120 private:
121 bool steady_converted = false;
122};
123
124/**
125 * @brief Handles the properties of input parameters
126 */
128 bool is_optional; ///< Is this parameter optional?
129 bool is_array; ///< Is this parameter an array?
130 bool is_number; ///< Is this parameter a number?
131 double default_val; ///< Default value (if parameter is optional)
132
133 /**
134 * @brief Handles input parameters
135 *
136 * @param is_optional Is this parameter optional?
137 * @param is_array Is this parameter an array?
138 * @param is_number Is this parameter a number?
139 * @param default_val Default value (if parameter is optional)
140 */
141 InputParameter(bool is_optional = false, bool is_array = false,
142 bool is_number = true, double default_val = 0.0)
147};
148
149#endif // SVZERODSOLVER_MODEL_PARAMETER_HPP_
model::DOFHandler source file
Model Parameter.
Definition Parameter.h:52
int id
Global ID of the parameter.
Definition Parameter.h:73
std::vector< double > values
Values if parameter is time-dependent.
Definition Parameter.h:75
int size
Size of the time series if parameter is time-dependent.
Definition Parameter.h:79
std::vector< double > times
Time steps if parameter is time-dependent.
Definition Parameter.h:74
double value
Value if parameter is constant.
Definition Parameter.h:76
Parameter(int id, double value)
Construct a new Parameter object.
Definition Parameter.cpp:33
bool is_periodic
Definition Parameter.h:81
double get(double time)
Get the parameter value at the specified time.
Definition Parameter.cpp:66
void to_unsteady()
Convert the parameter back into an unsteady mean state.
Definition Parameter.cpp:109
bool is_constant
Bool value indicating if the parameter is constant.
Definition Parameter.h:80
void to_steady()
Convert the parameter into a steady mean state.
Definition Parameter.cpp:99
void update(double value)
Update the parameter.
Definition Parameter.cpp:45
double cycle_period
Definition Parameter.h:77
Handles the properties of input parameters.
Definition Parameter.h:127
bool is_array
Is this parameter an array?
Definition Parameter.h:129
double default_val
Default value (if parameter is optional)
Definition Parameter.h:131
InputParameter(bool is_optional=false, bool is_array=false, bool is_number=true, double default_val=0.0)
Handles input parameters.
Definition Parameter.h:141
bool is_number
Is this parameter a number?
Definition Parameter.h:130
bool is_optional
Is this parameter optional?
Definition Parameter.h:128