Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

AliHaider93
Copy link
Contributor

this code is written to handle unexpected command *PART_ADAPTIVE_FAILURE by adding it as an attribute to the region.

@@ -122,6 +122,9 @@ int main
bot.addTriangle(point1, point3, point4);
}
}
if ((it->second).attributes.size() > 0) {
Copy link
Member

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
Copy link
Member

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)) {
Copy link
Member

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) {
Copy link
Member

@drossberg drossberg Jun 6, 2024

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];
Copy link
Member

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?

Copy link
Contributor Author

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;
Copy link
Member

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) ;
Copy link
Member

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,
Copy link
Member

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.

@AliHaider93 AliHaider93 deleted the branch BRL-CAD:devel_k-g June 6, 2024 19:22
@AliHaider93 AliHaider93 closed this Jun 6, 2024
@AliHaider93 AliHaider93 deleted the devel_k-g branch June 6, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants