-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add range to sine function #595
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #595 +/- ##
========================================
Coverage 96.82% 96.82%
========================================
Files 116 116
Lines 24846 24860 +14
========================================
+ Hits 24055 24069 +14
Misses 791 791
Continue to review full report at Codecov.
|
I have the following questions:
|
src/functions/sin_function.cc
Outdated
@@ -4,9 +4,17 @@ mpm::SinFunction::SinFunction(unsigned id, const Json& properties) | |||
: mpm::FunctionBase(id, properties) { | |||
x0_ = properties.at("x0"); | |||
a_ = properties.at("a"); | |||
if (properties.at("xrange").is_array() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this an optional argument?
src/functions/sin_function.cc
Outdated
if (properties.at("xrange").is_array() && | ||
properties.at("xrange").size() == 2) { | ||
for (unsigned index = 0; index < 2; ++index) | ||
xrange_[index] = properties.at("xrange").at(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xrange_[index] = properties.at("xrange").at(index); | |
xrange_.at(index) = properties.at("xrange").at(index); |
src/functions/sin_function.cc
Outdated
} else | ||
throw std::runtime_error( | ||
"Cannot initialise sine function; x range is invalid"); | ||
if (properties.contains("xrange")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add { } to define range of the if-condition
src/functions/sin_function.cc
Outdated
} | ||
|
||
// Return f(x) for a given x | ||
double mpm::SinFunction::value(double x_input) const { | ||
if ((x_input < xrange_[0]) || (x_input > xrange_[1])) return 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use .at()
Add range to the definition of a sine function thus allowing for the function to be specified only within this range. The value of the function is equal to zero at times that are outside of this range.