Commit 56db0411 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1345 Fix bug in a local variable initialization. Add several asserts that...

#1345 Fix bug in a local variable initialization. Add several asserts that were used to find it, and stop using directly [] operator for a map.
parent 5ef50174
......@@ -84,11 +84,10 @@ namespace MoReFEM
std::vector<unsigned int> element_index_list_new_to_old;
std::map<unsigned int, unsigned int> element_index_list_old_to_new;
Coords::vector_unique_ptr initial_coords_list;
unsigned int number_of_elements = static_cast<unsigned int>(output_mesh_geom_elemts.size());
Coords::vector_unique_ptr coords_list;
unsigned int number_of_elements = static_cast<unsigned int>(output_mesh_geom_elemts.size());
unsigned int Nnodes_new = 0;
const double mesh_space_unit = mesh.GetSpaceUnit();
......@@ -127,8 +126,8 @@ namespace MoReFEM
coords_init_ptr->SetIndex(Nnodes_new);
coords_list.emplace_back(std::move(coords_ptr));
initial_coords_list.emplace_back(std::move(coords_ptr));
initial_coords_list.emplace_back(std::move(coords_init_ptr));
++Nnodes_new;
}
}
......@@ -234,7 +233,7 @@ namespace MoReFEM
do_build_edge,
do_build_face,
do_build_volume);
const auto& new_mesh = mesh_manager.GetMesh(unique_id_output_mesh);
if (output_format == "Medit")
......@@ -269,7 +268,7 @@ namespace MoReFEM
decltype(auto) complete_unknown_list = post_processing.GetExtendedUnknownList();
Data::UnknownInformation::vector_const_shared_ptr selected_unknown_list;
// Associate the more complete unknown object from the name given in input.
{
for (const auto& unknown_name : unknown_list)
......@@ -290,7 +289,7 @@ namespace MoReFEM
selected_unknown_list.push_back(*it);
}
}
assert(selected_unknown_list.size() == 1 && "Limited to one unknown from the start.");
const auto& unknown = *selected_unknown_list[0];
......@@ -300,7 +299,7 @@ namespace MoReFEM
//===============================================================================================
//===============================================================================================
//===============================================================================================
// Iterate over time:
for (const auto& time_iteration_ptr : time_iteration_list)
{
......@@ -308,7 +307,7 @@ namespace MoReFEM
const auto& time_iteration = *time_iteration_ptr;
unsigned int iteration = time_iteration.GetIteration();
if (iteration >= output_offset && (iteration-output_offset) % output_frequence == 0)
{
if (time_iteration.GetNumberingSubsetId() == numbering_subset_id)
......@@ -352,7 +351,7 @@ namespace MoReFEM
}
const auto dof_with_values_type_size = dof_with_values_type.size();
for (unsigned int i = 0 ; i < dof_with_values_type_size ; ++i)
{
const auto& dof_information = *dof_with_values_type[i].first;
......@@ -367,26 +366,30 @@ namespace MoReFEM
const auto vertex_index = vertex_index_list[0];
auto it = std::find(coords_index_list_new_to_old.begin(), coords_index_list_new_to_old.end(), vertex_index);
if (it != coords_index_list_new_to_old.end())
{
unsigned int coord_index_new = coords_index_list_old_to_new[vertex_index];
const auto it_coord_index_new = coords_index_list_old_to_new.find(vertex_index);
assert(it_coord_index_new != coords_index_list_old_to_new.cend());
const auto coord_index_new = it_coord_index_new->second;
assert(coord_index_new <= output_mesh_coords_list.size());
auto& coord = *output_mesh_coords_list[coord_index_new - 1];
const auto& initial_coord = *initial_coords_list[coord_index_new - 1];
assert(coord_index_new <= initial_coords_list.size());
const auto& initial_coord_ptr = initial_coords_list[coord_index_new - 1];
const Coords& initial_coord = *initial_coord_ptr;
assert(i < dof_with_values_type.size());
double disp = dof_with_values_type[i].second;
const auto component_index = dof_information.GetUnknownComponent();
// divide by space unit to put it in mm for visualization.
assert(component_index < initial_coord.Nobjects());
coord.GetNonCstValue(component_index) = initial_coord[component_index] + disp * (output_space_unit / mesh_space_unit);
}
}
}
if (output_format == "Medit")
{
new_mesh.Write<MeshNS::Format::Medit>(output_mesh_directory + output_name + "_" + std::to_string(iteration) + ".mesh");
......@@ -406,7 +409,6 @@ namespace MoReFEM
}
} // namespace PostProcessingNS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment