Skip to content

Commit

Permalink
trim whitespace from group names
Browse files Browse the repository at this point in the history
  • Loading branch information
matekelemen committed Mar 5, 2024
1 parent dcf62e1 commit 7bd6cc4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions applications/MedApplication/custom_io/med_model_part_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,26 @@ void MedModelPartIO::ReadModelPart(ModelPart& rThisModelPart)
const int dimension = mpFileHandler->GetDimension();

// read family info => Map from family number to group names aka SubModelPart names
const auto groups_by_fam = GetGroupsByFamily(
auto groups_by_fam = GetGroupsByFamily(
mpFileHandler->GetFileHandle(),
mpFileHandler->GetMeshName());

// create SubModelPart hierarchy
for (const auto& r_map : groups_by_fam) {
for (const auto& r_smp_name : r_map.second) {
for (auto& r_map : groups_by_fam) {
for (auto& r_smp_name : r_map.second) {
// Trim whitespace from group names
// Trime left
r_smp_name.erase(r_smp_name.begin(),
std::find_if(r_smp_name.begin(),
r_smp_name.end(),
[](std::string::value_type c) {return !std::isspace(c);}));

// Trim right
r_smp_name.erase(std::find_if(r_smp_name.rbegin(),
r_smp_name.rend(),
[](std::string::value_type c) {return !std::isspace(c);}).base(),
r_smp_name.end());

if (!rThisModelPart.HasSubModelPart(r_smp_name)) {
rThisModelPart.CreateSubModelPart(r_smp_name);
}
Expand Down

0 comments on commit 7bd6cc4

Please sign in to comment.