Commit abcbe5f9 authored by GILLES Sebastien's avatar GILLES Sebastien

#1444 Ensight6 has been fully rewritten.

parent a232bd6e
......@@ -98,10 +98,9 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
};
void CreateUnknownFile(const Data::TimeIteration& time_iteration,
void CreateUnknownFile(const EnsightSolution& ensight_solution_holder,
const std::string& output_directory,
const std::string& unknown_name,
const std::vector<double>& content);
const std::string& unknown_name);
std::vector<const Data::TimeIteration*>
......@@ -126,11 +125,18 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
std::vector<IndexMatcher> GenerateIndexMatcherList(const PostProcessing& post_processing,
const InterfaceFile& interface_data,
const unsigned int numbering_subset_id,
const unsigned int rank,
unsigned int numbering_subset_id,
unsigned int rank,
const Data::UnknownInformation& unknown);
void ComputeEnsightSolutions(const PostProcessing& post_processing,
const InterfaceFile& interface_data,
const unsigned int numbering_subset_id,
const Data::UnknownInformation& unknown,
std::vector<EnsightSolution>& ensight_solution_per_time_step);
} // namespace anonymous
......@@ -211,8 +217,6 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
// is the number of program-wise coords that are also vertices (#248) but as EnsightOutput is run sequentially
// by reading the full mesh the method called here yields the expected value.
const std::size_t Nprocessor = post_processing.Nprocessor();
std::vector<double> ensight_file_content(NprogramWiseCoord, 0.);
std::vector<EnsightSolution> ensight_solution_per_time_step;
......@@ -226,50 +230,20 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
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,
numbering_subset_id,
rank,
unknown);
const auto Nprocessor_wise_dof = index_matcher_list.size();
for (auto& ensight_solution_holder : ensight_solution_per_time_step)
{
const auto& time_iteration = ensight_solution_holder.GetTimeIteration();
const auto solution = LoadVectorForTimeIteration(time_iteration, rank);
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
// (not on vertex, related to a different unknown, etc...)
for (auto i = 0ul; i < Nprocessor_wise_dof; ++i)
{
const auto& index_matcher = index_matcher_list[i];
const auto ensight_sol_index = index_matcher.GetEnsightPosition();
assert(ensight_sol_index < ensight_solution.size());
ensight_solution[ensight_sol_index] = solution[index_matcher.GetProcessorWiseIndex()];
}
}
} // for (auto rank = 0u; rank < Nprocessor; ++rank)
// Compute Ensight solutions for each time step and each rank; in output ensight_solution_per_time_step
// will include the data required to write the solution files in the format expected in Ensight.
ComputeEnsightSolutions(post_processing,
interface_data,
numbering_subset_id,
unknown,
ensight_solution_per_time_step);
// 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,
CreateUnknownFile(ensight_solution_holder,
ensight_directory,
unknown.GetName(),
ensight_solution_holder.GetContent());
unknown.GetName());
}
}
......@@ -385,15 +359,14 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
}
void CreateUnknownFile(const Data::TimeIteration& time_iteration,
void CreateUnknownFile(const EnsightSolution& ensight_solution_holder,
const std::string& output_directory,
const std::string& unknown_name,
const std::vector<double>& content)
const std::string& unknown_name)
{
std::ostringstream oconv;
oconv << output_directory;
oconv << '/' << unknown_name << '.' << std::setfill('0') << std::setw(5)
<< time_iteration.GetIteration() << ".scl";
<< ensight_solution_holder.GetTimeIteration().GetIteration() << ".scl";
std::string ensight_output_file(oconv.str());
......@@ -404,6 +377,7 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
WriteDofValue write_dof_value_helper(ensight_output_stream);
const auto& content = ensight_solution_holder.GetContent();
for (const auto& item : content)
write_dof_value_helper.NewValue(item);
}
......@@ -591,6 +565,48 @@ namespace MoReFEM::PostProcessingNS::OutputFormat
}
void ComputeEnsightSolutions(const PostProcessing& post_processing,
const InterfaceFile& interface_data,
const unsigned int numbering_subset_id,
const Data::UnknownInformation& unknown,
std::vector<EnsightSolution>& ensight_solution_per_time_step)
{
const auto Nprocessor = post_processing.Nprocessor();
for (auto rank = 0u; rank < Nprocessor; ++rank)
{
const std::vector<IndexMatcher> index_matcher_list =
GenerateIndexMatcherList(post_processing,
interface_data,
numbering_subset_id,
rank,
unknown);
const auto Nprocessor_wise_dof = index_matcher_list.size();
for (auto& ensight_solution_holder : ensight_solution_per_time_step)
{
const auto& time_iteration = ensight_solution_holder.GetTimeIteration();
const auto solution = LoadVectorForTimeIteration(time_iteration, rank);
auto& ensight_solution = ensight_solution_holder.GetNonCstContent();
assert(solution.size() >= Nprocessor_wise_dof); // solution might include dofs not considered here
// (not on vertex, related to a different unknown, etc...)
for (auto i = 0ul; i < Nprocessor_wise_dof; ++i)
{
const auto& index_matcher = index_matcher_list[i];
const auto ensight_sol_index = index_matcher.GetEnsightPosition();
assert(ensight_sol_index < ensight_solution.size());
ensight_solution[ensight_sol_index] = solution[index_matcher.GetProcessorWiseIndex()];
}
}
}
}
} // 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