-
Notifications
You must be signed in to change notification settings - Fork 147
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
Handling unexpected command *PART_ADAPTIVE_FAILURE #140
Conversation
@@ -122,6 +122,9 @@ int main | |||
bot.addTriangle(point1, point3, point4); | |||
} | |||
} | |||
if ((it->second).attributes.size() > 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.
You do not need this test here. The behavior stays the same without it.
@@ -39,7 +39,8 @@ enum class KState { | |||
Node, | |||
Element_Shell, | |||
Part, | |||
Section_Shell | |||
Section_Shell, | |||
PART_ADAPTIVE_FAILURE |
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, follow the style of the other states, i.e. write Part_Adaptive_Failure and put it below Part. It doesn't matter, if the states below getting other numbers.
@@ -189,6 +190,9 @@ bool parse_k | |||
partLinesRead = 0; | |||
partTitle = ""; | |||
} | |||
else if ((command.size() == 3)) { |
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.
Test the whole string: else if ((command.size() == 3) && (command[1] == "ADAPTIVE") && (command[2] == "FAILURE")) {
@@ -348,6 +352,22 @@ bool parse_k | |||
++sectionLinesRead; | |||
break; | |||
} | |||
case KState::PART_ADAPTIVE_FAILURE: { | |||
if (tokens.size() == 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.
There are a bit to many tests for tokens.size() here ;) One if (tokens.size() < 2) {
then error is enough. If there are more than 2, the surplus will be ignores, as in the other states.
int pid = stoi(tokens[0]); | ||
|
||
if (tokens.size() == 2) { | ||
data.parts[pid].attributes["ADAPTIVE_FAILURE_STARTING_TIME"]=tokens[1]; |
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.
PART_ADAPTIVE_FAILURE_STARTING_TIME?
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.
the attribute Part_Adaptive_Failure in LS-DYNA refers to the time when the adaptive mesh should start. we could call it ADAPTIVE_FAILURE_MESH_STARTING_TIME. I am open for any other suggestions
const std::string& region_name = it->first; | ||
Region& region = it->second; | ||
Bot& bot = region.bot; | ||
std::map<std::string, std::string> region_attributes = region.attributes; |
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.
Const reference?
|
||
class RegionList { | ||
public: | ||
RegionList(void); | ||
|
||
Bot& addRegion(const std::string& name); | ||
|
||
Bot& getBot(const std::string& name); | ||
Bot& getBot(const std::string& name); | ||
std::map<std::string, std::string>& getAttributes(const std::string& name) ; |
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.
It's nowhere needed, therefore I would recommend to omit this.
void setAttributes(const std::string& name, | ||
const std::map<std::string, std::string>& attributes); | ||
|
||
void writeAttributes(rt_wdb* wdbp, |
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.
I would make this function at least private. But I think, it can be made as a simple static function in region_list.cpp, without mentioning it in the class declaration at all.
this code is written to handle unexpected command *PART_ADAPTIVE_FAILURE by adding it as an attribute to the region.