Skip to content
Snippets Groups Projects
Commit 0126cf89 authored by Alexis Girault's avatar Alexis Girault
Browse files

COMP: Add exception handling when reading boundary conditions file

parent ae9d2120
No related branches found
No related tags found
No related merge requests found
......@@ -142,25 +142,38 @@ FEMDeformableBodyModel::loadBoundaryConditions()
{
std::ifstream file(fileName.data());
if (file.peek() == std::ifstream::traits_type::eof())
{
LOG(INFO) << "DeformableBodyModel::loadBoundaryConditions: The external boundary conditions file is empty";
return;
}
if (file.is_open())
{
size_t index;
auto maxAllowed = m_vegaPhysicsMesh->getNumVertices();
while (!file.eof())
{
file >> index;
m_fixedNodeIds.emplace_back(index);
if (index < maxAllowed)
{
m_fixedNodeIds.emplace_back(index);
}
else
{
LOG(WARNING) << "FEMDeformableBodyModel::loadBoundaryConditions(): " <<
"The boundary condition node id provided is greater than number of nodes and hence excluded!!";
}
}
file.close();
std::sort(m_fixedNodeIds.begin(), m_fixedNodeIds.end());// for efficiency
}
else
{
LOG(WARNING) << "DeformableBodyModel::loadBoundaryConditions: Could not open external file with boundary conditions";
return;
LOG(WARNING) << "DeformableBodyModel::loadBoundaryConditions: Could not open boundary conditions file!";
}
file.close();
return;
}
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment