Commit 9ccffa8c authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1399 Ensight6: the code has been rewritten slightly to avoid recomputing at...

#1399 Ensight6: the code has been rewritten slightly to avoid recomputing at each time iteration the match between coords and dofs.
parent 643d6cd0
......@@ -30,6 +30,8 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
namespace // anonymous
{
using DofWithValuesType = std::pair<Data::DofInformation::const_shared_ptr, double>;
class ExtendedDofInformation
{
......@@ -38,6 +40,11 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
const Data::UnknownInformation& GetUnknownInfo() const;
std::vector<std::vector<std::size_t> >&
ComputeOrGetCoordsMatch(const Coords::vector_unique_ptr& coords_list,
const std::vector<DofWithValuesType>& dof_with_values);
private:
const Data::UnknownInformation& unknown_info_;
......@@ -54,7 +61,7 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
const Data::UnknownInformation::vector_const_shared_ptr& unknown_list,
const Data::TimeIteration::vector_const_unique_ptr& time_iteration_list);
void CreateUnknownFile(const ExtendedDofInformation& dof_info,
void CreateUnknownFile(ExtendedDofInformation& dof_info,
const unsigned int numbering_subset_id,
const PostProcessingNS::Data::TimeIteration& time_iteration,
const std::string& data_directory,
......@@ -158,9 +165,9 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
for (auto it = range.first; it != range.second; ++it)
{
const auto& unknown_list_for_numbering_subset = *it;
auto& unknown_list_for_numbering_subset = *it;
decltype(auto) dof_info = unknown_list_for_numbering_subset.second;
auto& dof_info = unknown_list_for_numbering_subset.second;
CreateUnknownFile(dof_info,
unknown_list_for_numbering_subset.first,
......@@ -178,7 +185,6 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
{
void CreateCaseFile(const std::string& output_directory,
const Data::UnknownInformation::vector_const_shared_ptr& unknown_list,
const Data::TimeIteration::vector_const_unique_ptr& time_iteration_list)
......@@ -269,7 +275,7 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
}
void CreateUnknownFile(const ExtendedDofInformation& dof_information,
void CreateUnknownFile(ExtendedDofInformation& dof_information,
const unsigned int numbering_subset_id,
const PostProcessingNS::Data::TimeIteration& time_iteration,
const std::string& output_directory,
......@@ -300,8 +306,6 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
const std::size_t Nprocessor = post_processing.Nprocessor();
using DofWithValuesType = std::pair<Data::DofInformation::const_shared_ptr, double>;
std::vector<DofWithValuesType> dof_with_values;
#ifndef NDEBUG
......@@ -365,57 +369,7 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
decltype(auto) coords_list = mesh.GetProcessorWiseCoordsList();
std::vector<std::vector<std::size_t> > match(coords_list.size());
// The sorting below is required to handle the parallel case; it assumes P1 or Q1.
// That's the reason refined mesh does not work with model run in parallel.
if (is_mesh_refined == RefinedMesh::no)
{
// Reminder:
// - Post-processing runs in sequential;
// - The mesh.geo file was built using that very same order.
auto coords_list_counter = 0u;
--coords_list_counter;
for (const auto& coords_ptr : coords_list)
{
++coords_list_counter;
assert(!(!coords_ptr));
const auto& coords = *coords_ptr;
auto dof_with_values_counter = 0ul;
--dof_with_values_counter;
// Find - if any - the dofs that match these positions.
for (const auto& pair : dof_with_values)
{
++dof_with_values_counter;
decltype(auto) dof_ptr = pair.first;
assert(!(!dof_ptr));
decltype(auto) dof_coords_index_list = dof_ptr->GetInterface().GetVertexCoordsIndexList();
assert(dof_coords_index_list.size() == 1ul
&& "At the moment EnsightOutput deals only "
"with P1 (from both geometric and felt point of view)!");
const unsigned int dof_coords_index = dof_coords_index_list.back();
decltype(auto) dof_coords = mesh.GetCoord(dof_coords_index);
if (NumericNS::AreEqual(coords.x(), dof_coords.x())
&& NumericNS::AreEqual(coords.y(), dof_coords.y())
&& NumericNS::AreEqual(coords.z(), dof_coords.z()))
{
assert(coords_list_counter < match.size());
match[coords_list_counter].push_back(dof_with_values_counter);
}
}
}
}
decltype(auto) match = dof_information.ComputeOrGetCoordsMatch(coords_list, dof_with_values);
unsigned int dof_counter = 0u;
......@@ -465,6 +419,62 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
: unknown_info_(unknown_info)
{ }
std::vector<std::vector<std::size_t> >& ExtendedDofInformation
::ComputeOrGetCoordsMatch(const Coords::vector_unique_ptr& coords_list,
const std::vector<DofWithValuesType>& dof_with_values)
{
if (!coords_match_.empty())
return coords_match_;
// Reminder:
// - Post-processing runs in sequential;
// - The mesh.geo file was built using that very same order.
auto coords_list_counter = 0u;
--coords_list_counter;
coords_match_.resize(coords_list.size());
for (const auto& coords_ptr : coords_list)
{
++coords_list_counter;
assert(!(!coords_ptr));
const auto& coords = *coords_ptr;
auto dof_with_values_counter = 0ul;
--dof_with_values_counter;
// Find - if any - the dofs that match these positions.
for (const auto& pair : dof_with_values)
{
++dof_with_values_counter;
decltype(auto) dof_ptr = pair.first;
assert(!(!dof_ptr));
decltype(auto) dof_coords_index_list = dof_ptr->GetInterface().GetVertexCoordsIndexList();
assert(dof_coords_index_list.size() == 1ul
&& "At the moment EnsightOutput deals only "
"with P1 (from both geometric and felt point of view)!");
const unsigned int dof_coords_index = dof_coords_index_list.back();
assert(dof_coords_index < coords_list.size());
decltype(auto) dof_coords_ptr = coords_list[dof_coords_index];
const auto& dof_coords = *dof_coords_ptr;
if (NumericNS::AreEqual(coords.x(), dof_coords.x())
&& NumericNS::AreEqual(coords.y(), dof_coords.y())
&& NumericNS::AreEqual(coords.z(), dof_coords.z()))
{
assert(coords_list_counter < coords_match_.size());
coords_match_[coords_list_counter].push_back(dof_with_values_counter);
}
}
}
return coords_match_;
}
} // namespace anonymous
......
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