Commit a0da9932 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#754 Following the removal of one assert, we could end up with a call to an...

#754 Following the removal of one assert, we could end up with a call to an unallocated matrix. Asserts have been added and interface has been slightly modified to avoid that mistake.
parent 6861ac04
......@@ -58,8 +58,8 @@ namespace HappyHeart
if (do_allocate_gradient_felt_phi == AllocateGradientFEltPhi::yes)
{
GetNonCstGradientFEltPhi().Resize(deriv_ref_phi_felt.GetM(),
deriv_ref_phi_felt.GetN());
ResizeGradientFEltPhi(deriv_ref_phi_felt.GetM(),
deriv_ref_phi_felt.GetN());
}
Ncomponent_sequence_ =
......@@ -92,6 +92,12 @@ namespace HappyHeart
}
void InformationsAtQuadraturePoint::ResizeGradientFEltPhi(int Nrow, int Ncol)
{
GetLocalMatrix<EnumUnderlyingType(LocalMatrixIndex::deriv_phi_felt)>().Resize(Nrow, Ncol);
}
void InformationsAtQuadraturePoint::InitRefGeometricShapeFunction(const RefGeomElt& ref_geom_elt)
{
......@@ -198,7 +204,7 @@ namespace HappyHeart
const unsigned int geom_elt_dimension = geom_elt.GetDimension();
assert(geometric_mesh_region_dimension > geom_elt_dimension);
assert(!DoAllocateGradientFEltPhi() && "No need at the moment so the formula has not been devised");
//assert(!DoAllocateGradientFEltPhi() && "No need at the moment so the formula has not been devised");
switch(geom_elt_dimension)
{
......@@ -215,6 +221,8 @@ namespace HappyHeart
GetNonCstDeterminant() = std::sqrt(Utilities::Square(cross_product(0))
+ Utilities::Square(cross_product(1))
+ Utilities::Square(cross_product(2)));
std::cout << "Computed determinant = " << GetNonCstDeterminant() << std::endl;
break;
}
case 1u:
......@@ -229,7 +237,7 @@ namespace HappyHeart
}
default:
{
assert(false && "Shound never happen!");
assert(false && "Should never happen!");
break;
}
} // switch
......
......@@ -192,6 +192,9 @@ namespace HappyHeart
*/
LocalMatrix& GetNonCstGradientFEltPhi();
//! Allocate memory for gradient felt phi.
void ResizeGradientFEltPhi(int Nrow, int Ncol);
//! Return the sequence [0, Ncomponent - 1].
const Seldon::Vector<int>& GetComponentSequence() const;
......
......@@ -110,7 +110,9 @@ namespace HappyHeart
inline const LocalMatrix& InformationsAtQuadraturePoint
::GetGradientFEltPhi() const
{
return GetLocalMatrix<EnumUnderlyingType(LocalMatrixIndex::deriv_phi_felt)>();
decltype(auto) ret = GetLocalMatrix<EnumUnderlyingType(LocalMatrixIndex::deriv_phi_felt)>();
assert(ret.GetM() != 0);
return ret;
}
......@@ -146,7 +148,8 @@ namespace HappyHeart
inline bool InformationsAtQuadraturePoint::DoAllocateGradientFEltPhi() const
{
return GetGradientFEltPhi().GetM() != 0;
// Do not use the accessor GetGradientFEltPhi() here, as it asserts number of rows is not null...
return GetLocalMatrix<EnumUnderlyingType(LocalMatrixIndex::deriv_phi_felt)>().GetM() != 0;
}
......
......@@ -525,8 +525,6 @@ namespace HappyHeart
void Vector::SetFromPetscVec(const Vec& petsc_vector,
const char* invoking_file, int invoking_line)
{
std::cout << "SetFromPetscVec 0 " << std::endl;
// In this specific method alone I can't use syntax sugary provided by the class, as I manipulate
// a raw Petsc Vec such as the one provided in arguments of SnesFunction.
const PetscScalar* values;
......@@ -559,8 +557,6 @@ namespace HappyHeart
if (error_code)
throw ExceptionNS::Exception(error_code, "VecRestoreArrayRead", invoking_file, invoking_line);
std::cout << "SetFromPetscVec 100 " << 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