Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
f2d8e51a
Commit
f2d8e51a
authored
6 months ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[MPL] Report media/material ids mismatch
instead of crash triggered by map::at std::out_of_range exception.
parent
ba42ee8f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MaterialLib/MPL/MaterialSpatialDistributionMap.cpp
+35
-1
35 additions, 1 deletion
MaterialLib/MPL/MaterialSpatialDistributionMap.cpp
with
35 additions
and
1 deletion
MaterialLib/MPL/MaterialSpatialDistributionMap.cpp
+
35
−
1
View file @
f2d8e51a
...
@@ -11,6 +11,11 @@
...
@@ -11,6 +11,11 @@
*/
*/
#include
"MaterialSpatialDistributionMap.h"
#include
"MaterialSpatialDistributionMap.h"
#include
<spdlog/fmt/bundled/core.h>
#include
<spdlog/fmt/bundled/ranges.h>
#include
<range/v3/view/map.hpp>
#include
"MeshLib/Mesh.h"
#include
"MeshLib/Mesh.h"
namespace
MaterialPropertyLib
namespace
MaterialPropertyLib
...
@@ -28,7 +33,36 @@ Medium const* MaterialSpatialDistributionMap::getMedium(
...
@@ -28,7 +33,36 @@ Medium const* MaterialSpatialDistributionMap::getMedium(
auto
const
material_id
=
auto
const
material_id
=
material_ids_
==
nullptr
?
0
:
(
*
material_ids_
)[
element_id
];
material_ids_
==
nullptr
?
0
:
(
*
material_ids_
)[
element_id
];
return
media_
.
at
(
material_id
).
get
();
assert
(
!
media_
.
empty
());
if
(
auto
const
it
=
media_
.
find
(
material_id
);
it
!=
media_
.
end
())
{
return
it
->
second
.
get
();
}
//
// Error handling until end of the function.
//
if
(
material_ids_
==
nullptr
)
{
assert
(
material_id
==
0
);
ERR
(
"No MaterialIDs given in the mesh therefore default material id = "
"0 is used."
);
}
auto
keys
=
media_
|
ranges
::
views
::
keys
;
if
(
media_
.
size
()
==
1
)
{
ERR
(
"Single medium for material id {} is defined."
,
fmt
::
join
(
keys
,
", "
));
}
else
{
ERR
(
"Media for material ids {} are defined."
,
fmt
::
join
(
keys
,
", "
));
}
OGS_FATAL
(
"No medium for material id {} found for element {}."
,
material_id
,
element_id
);
}
}
void
MaterialSpatialDistributionMap
::
checkElementHasMedium
(
void
MaterialSpatialDistributionMap
::
checkElementHasMedium
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment