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

[MedApp] Trim Whitespace in Group Names #12147

Merged
merged 6 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions applications/MedApplication/custom_io/med_model_part_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "utilities/builtin_timer.h"
#include "utilities/parallel_utilities.h"
#include "utilities/variable_utils.h"
#include "utilities/string_utilities.h"

namespace Kratos {

Expand Down Expand Up @@ -67,13 +68,6 @@ void CheckMEDErrorCode(const int ierr, const std::string& MEDCallName)
KRATOS_ERROR_IF(ierr < 0) << MEDCallName << " failed with error code " << ierr << "." << std::endl;
}

// The names in the MED-file often have trailing null-chars, which need to be removed
// this can otherwise make debugging very tricky
void RemoveTrailingNullChars(std::string& rInput)
{
rInput.erase(std::find(rInput.begin(), rInput.end(), '\0'), rInput.end());
}

template<typename T>
void CheckConnectivitiesSize(
const std::size_t ExpectedSize,
Expand Down Expand Up @@ -329,8 +323,7 @@ auto GetGroupsByFamily(
std::vector<std::string> group_names(num_groups);
// split the goup names
for (int i = 0; i < num_groups; i++) {
group_names[i] = c_group_names.substr(i * MED_LNAME_SIZE, MED_LNAME_SIZE);
RemoveTrailingNullChars(group_names[i]);
group_names[i] = StringUtilities::Trim(c_group_names.substr(i * MED_LNAME_SIZE, MED_LNAME_SIZE), /*RemoveNullChar=*/true);
}

groups_by_family[family_number] = std::move(group_names);
Expand Down Expand Up @@ -424,7 +417,7 @@ class MedModelPartIO::MedFileHandler
axis_unit.data());
CheckMEDErrorCode(err, "MEDmeshInfo");

RemoveTrailingNullChars(mMeshName);
mMeshName = StringUtilities::Trim(mMeshName, /*RemoveNullChar=*/true);
mDimension = space_dim;
}

Expand Down
Loading