Commit 885329ca authored by DIAZ Jerome's avatar DIAZ Jerome Committed by GILLES Sebastien

#1520 Slight improvement on the formating and performance of the...

#1520 Slight improvement on the formating and performance of the WriteFromPolicy for AtQuadraturePoint types.
parent 471190dd
......@@ -16,6 +16,7 @@
# define MOREFEM_x_PARAMETERS_x_POLICY_x_AT_QUADRATURE_POINT_x_AT_QUADRATURE_POINT_HPP_
# include "Utilities/Containers/UnorderedMap.hpp"
# include "Utilities/String/EmptyString.hpp"
# include "Core/TimeManager/TimeManager.hpp"
......
......@@ -171,7 +171,7 @@ namespace MoReFEM
AtQuadraturePoint<TypeT>::GetConstantValueFromPolicy() const
{
assert(false && "Should yield IsConstant() = false!");
exit(-1);
exit(EXIT_FAILURE);
}
......@@ -187,7 +187,6 @@ namespace MoReFEM
{
decltype(auto) domain = this->GetDomain();
const auto& mesh = domain.GetMesh();
const auto& ref_geom_elt_list = mesh.BagOfEltType();
const auto& storage = GetStorage();
......@@ -195,7 +194,6 @@ namespace MoReFEM
# ifndef NDEBUG
const auto end_storage = storage.cend();
# endif // NDEBUG
out << "# Geometric element index; quadrature point; TimeManager::NtimesModified() at last update; value" << std::endl;
for (const auto& ref_geom_elt_ptr : ref_geom_elt_list)
......@@ -203,12 +201,21 @@ namespace MoReFEM
assert(!(!ref_geom_elt_ptr));
const auto& ref_geom_elt = *ref_geom_elt_ptr;
if (!domain.DoRefGeomEltMatchCriteria(ref_geom_elt))
continue;
const auto& quadrature_rule = GetQuadratureRule(ref_geom_elt.GetTopologyIdentifier());
decltype(auto) iterator_range = mesh.GetSubsetGeometricEltList(ref_geom_elt);
const auto quadrature_rule_name = quadrature_rule.GetName();
const auto Nquadrature_point = quadrature_rule.NquadraturePoint();
const auto Ngeo_elt = std::distance(iterator_range.first, iterator_range.second);
const auto Nvalues = Ngeo_elt * Nquadrature_point;
out << "# Nvalues" << std::endl;
out << Nvalues << std::endl;
for (auto it_geom_elt = iterator_range.first; it_geom_elt != iterator_range.second; ++it_geom_elt)
{
......@@ -228,8 +235,23 @@ namespace MoReFEM
for (unsigned int i = 0u; i < Nquadrature_point; ++i)
{
out << geom_elt_index << ';' << quadrature_rule_name << '_'
<< i << ';' << value_per_quad_pt[i].last_update_index << ';' << std::scientific << std::setprecision(16) <<value_per_quad_pt[i].value
<< std::endl;
<< i << ';' << value_per_quad_pt[i].last_update_index << ';';
if constexpr (TypeT == ParameterNS::Type::scalar)
out << std::setw(12) << std::scientific << std::setprecision(5) << value_per_quad_pt[i].value;
// To get rid of the braces "{ }" of the xtensor output and have more control over the precision.
if constexpr (TypeT == ParameterNS::Type::vector)
{
auto separator = Utilities::EmptyString();
for (const auto vector_value : value_per_quad_pt[i].value)
{
out << separator << std::setw(12) << std::scientific << std::setprecision(5) << vector_value;
separator = ',';
}
}
out << std::endl;
}
}
}
......
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