Commit a232bd6e authored by GILLES Sebastien's avatar GILLES Sebastien

#1444 More Ensight6 refactoring... and yet not done. In previous version I in...

#1444 More Ensight6 refactoring... and yet not done. In previous version I in fact wrote several times the same file... A proof that streamlining the code to better understand how it works is necessary and will be appreciated the day EnsightOutput will be revisited next (or as an inspiration when another output format is to be written).
parent 68db987b
......@@ -74,10 +74,34 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
};
// The purpose of this class is to store for a given time iteration the values of the dofs relayted to a
// specific unknown in the right order.
class EnsightSolution
{
public:
EnsightSolution(const Data::TimeIteration& time_iteration,
std::vector<double> content);
const Data::TimeIteration& GetTimeIteration() const noexcept;
const std::vector<double>& GetContent() const noexcept;
std::vector<double>& GetNonCstContent() noexcept;
private:
const Data::TimeIteration& time_iteration_;
std::vector<double> content_;
};
void CreateUnknownFile(const Data::TimeIteration& time_iteration,
const std::string& output_directory,
const std::string& unknown_name,
const std::vector<double>& content);
const std::string& output_directory,
const std::string& unknown_name,
const std::vector<double>& content);
std::vector<const Data::TimeIteration*>
......@@ -149,8 +173,6 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
const auto& time_iteration_list = post_processing.GetTimeIterationList();
// Create the case file.
Data::UnknownInformation::vector_const_shared_ptr selected_unknown_list
= GenerateUnknownInformationList(post_processing, unknown_list);
......@@ -193,14 +215,19 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
std::vector<double> ensight_file_content(NprogramWiseCoord, 0.);
std::vector<std::vector<double>> ensight_file_content_per_time_step(relevant_time_iteration_file_list.size(),
ensight_file_content);
std::vector<EnsightSolution> ensight_solution_per_time_step;
ensight_solution_per_time_step.reserve(relevant_time_iteration_file_list.size());
for (const auto& time_iteration_ptr : time_iteration_list)
{
assert(!(!time_iteration_ptr));
EnsightSolution content(*time_iteration_ptr,
ensight_file_content);
ensight_solution_per_time_step.emplace_back(content);
}
for (auto rank = 0u; rank < Nprocessor; ++rank)
{
const std::vector<IndexMatcher> index_matcher_list =
GenerateIndexMatcherList(post_processing,
interface_data,
......@@ -210,17 +237,13 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
const auto Nprocessor_wise_dof = index_matcher_list.size();
auto iterator_ensight_sol = ensight_file_content_per_time_step.begin();
for (const auto& time_iteration_ptr : time_iteration_list)
for (auto& ensight_solution_holder : ensight_solution_per_time_step)
{
assert(iterator_ensight_sol != ensight_file_content_per_time_step.end());
assert(!(!time_iteration_ptr));
const auto& time_iteration = *time_iteration_ptr;
const auto& time_iteration = ensight_solution_holder.GetTimeIteration();
const auto solution = LoadVectorForTimeIteration(time_iteration, rank);
auto& ensight_solution = *iterator_ensight_sol;
auto& ensight_solution = ensight_solution_holder.GetNonCstContent();
assert(NprogramWiseCoord == ensight_solution.size());
assert(solution.size() >= Nprocessor_wise_dof); // solution might include dofs not considered here
......@@ -233,16 +256,20 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
assert(ensight_sol_index < ensight_solution.size());
ensight_solution[ensight_sol_index] = solution[index_matcher.GetProcessorWiseIndex()];
}
}
CreateUnknownFile(time_iteration,
ensight_directory,
unknown.GetName(),
ensight_solution);
++iterator_ensight_sol;
}
} // for (auto rank = 0u; rank < Nprocessor; ++rank)
// Finally create the unknown file in Ensight format for each time step.
for (const auto& ensight_solution_holder : ensight_solution_per_time_step)
{
const auto& time_iteration = ensight_solution_holder.GetTimeIteration();
CreateUnknownFile(time_iteration,
ensight_directory,
unknown.GetName(),
ensight_solution_holder.GetContent());
}
}
......@@ -539,6 +566,31 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
}
EnsightSolution::EnsightSolution(const Data::TimeIteration& time_iteration,
std::vector<double> content)
: time_iteration_(time_iteration),
content_(content)
{ }
const Data::TimeIteration& EnsightSolution::GetTimeIteration() const noexcept
{
return time_iteration_;
}
const std::vector<double>& EnsightSolution::GetContent() const noexcept
{
return content_;
}
std::vector<double>& EnsightSolution::GetNonCstContent() noexcept
{
return const_cast<std::vector<double>&>(GetContent());
}
} // 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