-
Notifications
You must be signed in to change notification settings - Fork 95
[Feature] State variable vtk output for different phases #683
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
Changes from 1 commit
a33d835
83e57fb
b15ab96
d9a2a10
0d04e0b
fb25629
8926472
6b6c735
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -96,10 +96,44 @@ mpm::MPMBase<Tdim>::MPMBase(const std::shared_ptr<IO>& io) : mpm::MPM(io) { | |||||||||||||||
| try { | ||||||||||||||||
| if (post_process_.at("vtk_statevars").is_array() && | ||||||||||||||||
| post_process_.at("vtk_statevars").size() > 0) { | ||||||||||||||||
| for (unsigned i = 0; i < post_process_.at("vtk_statevars").size(); ++i) { | ||||||||||||||||
| std::string attribute = | ||||||||||||||||
| post_process_["vtk_statevars"][i].template get<std::string>(); | ||||||||||||||||
| vtk_statevars_.emplace_back(attribute); | ||||||||||||||||
| // Iterate over state_vars | ||||||||||||||||
| for (const auto& svars : post_process_["vtk_statevars"]) { | ||||||||||||||||
| // Initial phase id and state vars | ||||||||||||||||
| unsigned phase_id = 0; | ||||||||||||||||
| std::vector<std::string> state_var; | ||||||||||||||||
|
|
||||||||||||||||
| // If state variables are arranged as string | ||||||||||||||||
bodhinandach marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||
| if (svars.is_string()) { | ||||||||||||||||
| std::string attribute = svars.template get<std::string>(); | ||||||||||||||||
| state_var.emplace_back(attribute); | ||||||||||||||||
| } | ||||||||||||||||
| // If state variables are arranged as json object | ||||||||||||||||
| else if (svars.is_object()) { | ||||||||||||||||
| // Phase id | ||||||||||||||||
| if (svars.contains("phase_id")) | ||||||||||||||||
| phase_id = svars.at("phase_id").template get<unsigned>(); | ||||||||||||||||
|
|
||||||||||||||||
|
||||||||||||||||
| double state_variable( | |
| const std::string& var, | |
| unsigned phase = mpm::ParticlePhase::Solid) const override { | |
| return (state_variables_[phase].find(var) != state_variables_[phase].end()) | |
| ? state_variables_[phase].at(var) | |
| : std::numeric_limits<double>::quiet_NaN(); | |
| } |
Maybe we can use
state_variables_.at(phase) instead of state_variables_[phase] for all the above to assert if the given phase is not allocated. Just that it will be a slower call. What do you think @kks32?
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.
Any further thoughts on this?
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.
Doesn't this guarantee that the variable is available: state_variables_[phase].find(var) != state_variables_[phase].end()
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.
Yes, if the state_variables_ have the appropriate phase. If the passed phase is equal or larger than state_variables_.size(), then it will cause a segmentation fault. For instance, if I am accessing index phase=1 in single-phase particle, it will be seg-fault
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.
@kks32 Are we good with this? The current implementation has no phase_id check. So if input phase_id is not available, we will have seg fault.
Uh oh!
There was an error while loading. Please reload this page.