Commit 44c49a21 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#839 Utilities/Numeric: use a dedicated namespace for the free functions defined there.

parent 9b924116
......@@ -43,14 +43,14 @@ namespace HappyHeart
inline double ConstantTimeStep::GetTimeStep() const
{
assert(!Utilities::AreEqual(time_step_, std::numeric_limits<double>::lowest()));
assert(!NumericNS::AreEqual(time_step_, std::numeric_limits<double>::lowest()));
return time_step_;
}
inline double ConstantTimeStep::GetMaximumTime() const
{
assert(!Utilities::AreEqual(maximum_time_, std::numeric_limits<double>::lowest()));
assert(!NumericNS::AreEqual(maximum_time_, std::numeric_limits<double>::lowest()));
return maximum_time_;
}
......@@ -58,7 +58,7 @@ namespace HappyHeart
inline bool ConstantTimeStep::HasFinished(const double time) const
{
return time + Utilities::DefaultEpsilon<double>() >= GetMaximumTime();
return time + NumericNS::DefaultEpsilon<double>() >= GetMaximumTime();
}
......
......@@ -427,7 +427,7 @@ namespace HappyHeart
Private::FEltSpaceNS::Storage::const_unique_ptr felt_storage_ = nullptr;
//! Dimension considered within the FEltSpace.
unsigned int dimension_ = Utilities::UninitializedIndex<unsigned int>();
unsigned int dimension_ = NumericNS::UninitializedIndex<unsigned int>();
//! Weak pointer to the enclosing God of dof.
std::weak_ptr<const GodOfDof> god_of_dof_;
......
......@@ -94,7 +94,7 @@ namespace HappyHeart
const unsigned int size = static_cast<unsigned int>(Nnode_bearer_on_each_processor.size());
unsigned int ret = Utilities::UninitializedIndex<unsigned int>();
unsigned int ret = NumericNS::UninitializedIndex<unsigned int>();
// Is the maximum unique or not?
if (std::count(Nnode_bearer_on_each_processor.cbegin(), Nnode_bearer_on_each_processor.cend(), max_value) == 1)
......
......@@ -70,7 +70,7 @@ namespace HappyHeart
void Dof::SetInternalProcessorWiseOrGhostIndex(unsigned int index)
{
assert(internal_processor_wise_or_ghost_index_ == Utilities::UninitializedIndex<unsigned int>()
assert(internal_processor_wise_or_ghost_index_ == NumericNS::UninitializedIndex<unsigned int>()
&& "Should be allocated only once!");
internal_processor_wise_or_ghost_index_ = index;
}
......
......@@ -164,7 +164,7 @@ namespace HappyHeart
*
* Hence this index which covers all the dofs on a same processor, regardless of their numbering subset.
*/
unsigned int internal_processor_wise_or_ghost_index_ = Utilities::UninitializedIndex<unsigned int>();
unsigned int internal_processor_wise_or_ghost_index_ = NumericNS::UninitializedIndex<unsigned int>();
/*!
......
......@@ -16,7 +16,7 @@ namespace HappyHeart
inline unsigned int Dof::GetInternalProcessorWiseOrGhostIndex() const
{
assert(internal_processor_wise_or_ghost_index_ != Utilities::UninitializedIndex<unsigned int>());
assert(internal_processor_wise_or_ghost_index_ != NumericNS::UninitializedIndex<unsigned int>());
return internal_processor_wise_or_ghost_index_;
}
......
......@@ -22,7 +22,7 @@ namespace HappyHeart
inline unsigned int LocalNode::GetIndex() const noexcept
{
assert(index_ != Utilities::UninitializedIndex<unsigned int>());
assert(index_ != NumericNS::UninitializedIndex<unsigned int>());
return index_;
}
......
......@@ -17,8 +17,8 @@ namespace HappyHeart
NodeBearer::NodeBearer(const Interface::shared_ptr& interface)
: index_(Utilities::UninitializedIndex<decltype(index_)>()),
processor_(Utilities::UninitializedIndex<decltype(processor_)>()),
: index_(NumericNS::UninitializedIndex<decltype(index_)>()),
processor_(NumericNS::UninitializedIndex<decltype(processor_)>()),
interface_(interface)
{
assert(!(!interface));
......
......@@ -9,7 +9,7 @@ namespace HappyHeart
inline unsigned int NodeBearer::GetIndex() const noexcept
{
assert(index_ != Utilities::UninitializedIndex<decltype(index_)>());
assert(index_ != NumericNS::UninitializedIndex<decltype(index_)>());
return index_;
}
......
......@@ -154,7 +154,7 @@ namespace HappyHeart
dcor = pb / dpb;
sgnd = 1.0;
if (!Utilities::IsZero(dcor))
if (!NumericNS::IsZero(dcor))
sgnd = dcor/std::fabs(dcor);
// we don't move the point further than 0.2*delta_theta
......@@ -179,15 +179,15 @@ namespace HappyHeart
{
double tmp = pb - dcor * dpb + 0.5 * dcor * dcor * ddpb;
tmp *= tmp;
assert(!Utilities::IsZero(tmp));
assert(!NumericNS::IsZero(tmp));
weights[nix-1] = 1.0 / tmp;
}
else
{
assert(!Utilities::IsZero(std::sin(zlast)));
assert(!NumericNS::IsZero(std::sin(zlast)));
double tmp = dpb + pb * std::cos(zlast) / std::sin(zlast);
tmp*=tmp;
assert(!Utilities::IsZero(tmp));
assert(!NumericNS::IsZero(tmp));
weights[nix-1] = static_cast<double>(2u * Nquadrature_point + 1u) / tmp;
}
......@@ -210,9 +210,9 @@ namespace HappyHeart
Private::ComputeLegendrePolAndDerivative(Nquadrature_point, half_pi, cz, coef,deriv_coef,
second_deriv_coef, pb, dpb, ddpb);
assert(!Utilities::IsZero(dpb));
assert(!NumericNS::IsZero(dpb));
weights[Nhalf - 1] = static_cast<double>(2u * Nquadrature_point + 1u) / Utilities::Square(dpb);
weights[Nhalf - 1] = static_cast<double>(2u * Nquadrature_point + 1u) / NumericNS::Square(dpb);
}
if ((QuadratureFormulaT == QuadratureFormula::Gauss_Lobatto) && (Nparity_points == 0))
......@@ -220,8 +220,8 @@ namespace HappyHeart
theta[Nhalf - 1] = half_pi;
Private::ComputeLegendrePolAndDerivative(Nquadrature_point, half_pi, cz, coef,deriv_coef,
second_deriv_coef,pb, dpb, ddpb);
assert(!Utilities::IsZero(pb));
weights[Nhalf - 1] = 1. / Utilities::Square(pb);
assert(!NumericNS::IsZero(pb));
weights[Nhalf - 1] = 1. / NumericNS::Square(pb);
}
// DISP(Nhalf); DISP(theta);DISP(weights);
......@@ -258,7 +258,7 @@ namespace HappyHeart
sum += weights[i];
}
assert(!Utilities::IsZero(sum));
assert(!NumericNS::IsZero(sum));
for (unsigned int i = 0; i < Ngauss_points; i++)
{
......
......@@ -107,8 +107,8 @@ namespace HappyHeart
t2 += -1.;
t3 += 1.;
t4 += -2.;
assert(!Utilities::IsZero(t3));
assert(!Utilities::IsZero(t4));
assert(!NumericNS::IsZero(t3));
assert(!NumericNS::IsZero(t4));
cp[j - 1] = (t1 * t2) / (t3 * t4) * cp[j];
}
......@@ -117,8 +117,8 @@ namespace HappyHeart
t3 = t3 + 1.;
t4 = t4 - 2.;
assert(!Utilities::IsZero(t3));
assert(!Utilities::IsZero(t4));
assert(!NumericNS::IsZero(t3));
assert(!NumericNS::IsZero(t4));
cz = (t1 * t2) / (t3 * t4) * cp[1];
for (unsigned int j = 1; j <= ncp; j++)
......@@ -137,8 +137,8 @@ namespace HappyHeart
t3 = t3 + 1.;
t4 = t4 - 2.;
assert(!Utilities::IsZero(t3));
assert(!Utilities::IsZero(t4));
assert(!NumericNS::IsZero(t3));
assert(!NumericNS::IsZero(t4));
cp[j] = (t1 * t2) / (t3 * t4) * cp[j+1];
}
for (unsigned int j = 1; j <= ncp; j++)
......
......@@ -159,7 +159,7 @@ namespace HappyHeart
assert(!Yuni::Math::Equals(min, std::numeric_limits<double>::max()));
assert(!Yuni::Math::Equals(max, std::numeric_limits<double>::lowest()));
if (!Utilities::IsZero(min))
if (!NumericNS::IsZero(min))
{
const double range = max - min;
......
......@@ -27,7 +27,7 @@ namespace HappyHeart
BasicRefFElt::BasicRefFElt()
: topology_dimension_(Utilities::UninitializedIndex<decltype(topology_dimension_)>())
: topology_dimension_(NumericNS::UninitializedIndex<decltype(topology_dimension_)>())
{ }
......
......@@ -49,7 +49,7 @@ namespace HappyHeart
}
assert(false);
return Utilities::UninitializedIndex<unsigned int>();
return NumericNS::UninitializedIndex<unsigned int>();
}
......@@ -66,7 +66,7 @@ namespace HappyHeart
}
assert(false);
return Utilities::UninitializedIndex<unsigned int>();
return NumericNS::UninitializedIndex<unsigned int>();
}
......
......@@ -261,7 +261,7 @@ namespace HappyHeart
double norm = 0.;
for (unsigned int i = 0; i < Nelt; ++i)
norm += Utilities::Square(content.GetValue(i));
norm += NumericNS::Square(content.GetValue(i));
const auto& mpi = this->MpiHappyHeart();
......
......@@ -92,7 +92,7 @@ namespace HappyHeart
double sum = 0.;
for (auto i = 0u; i < 3u; ++i)
sum += Utilities::Square(point1[i] - point2[i]);
sum += NumericNS::Square(point1[i] - point2[i]);
return std::sqrt(sum);
}
......@@ -100,7 +100,7 @@ namespace HappyHeart
unsigned int Coords::GetPositionInCoordsListInMesh() const noexcept
{
assert(position_in_coords_list_in_mesh_ != Utilities::UninitializedIndex<decltype(position_in_coords_list_in_mesh_)>());
assert(position_in_coords_list_in_mesh_ != NumericNS::UninitializedIndex<decltype(position_in_coords_list_in_mesh_)>());
return position_in_coords_list_in_mesh_;
}
......
......@@ -212,14 +212,14 @@ namespace HappyHeart
*
* This index depends on the format used and might not be contiguous (contrary to position_in_coords_list_in_mesh_).
*/
unsigned int index_ = Utilities::UninitializedIndex<unsigned int>();
unsigned int index_ = NumericNS::UninitializedIndex<unsigned int>();
/*!
* \brief Position of the Coords in the list of the mesh that includes it.
*
*/
unsigned int position_in_coords_list_in_mesh_ = Utilities::UninitializedIndex<unsigned int>();
unsigned int position_in_coords_list_in_mesh_ = NumericNS::UninitializedIndex<unsigned int>();
......
......@@ -56,7 +56,7 @@ namespace HappyHeart
inline unsigned int Coords::GetIndex() const
{
assert(index_ != Utilities::UninitializedIndex<decltype(index_)>());
assert(index_ != NumericNS::UninitializedIndex<decltype(index_)>());
return index_;
}
......
......@@ -120,7 +120,7 @@ namespace HappyHeart
"(currently either only one or no mesh restriction at all are accepted).",
__FILE__, __LINE__);
assert(geometric_mesh_region_identifier_ == Utilities::UninitializedIndex<unsigned int>()
assert(geometric_mesh_region_identifier_ == NumericNS::UninitializedIndex<unsigned int>()
&& "This private method should be called only once in the constructor!");
SetConditionType(DomainNS::Criterion::geometric_mesh_region);
geometric_mesh_region_identifier_ = mesh_index_list.back();
......
......@@ -301,7 +301,7 @@ namespace HappyHeart
*
* Relevant only if DomainNS::Criterion::geometric_mesh_region is enforced.
*/
unsigned int geometric_mesh_region_identifier_ = Utilities::UninitializedIndex<unsigned int>();
unsigned int geometric_mesh_region_identifier_ = NumericNS::UninitializedIndex<unsigned int>();
/*!
* \brief Dimensions consider inside the domain.
......
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