Commit 2643561d authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1332 Solid: in accessors, add an exception check which tells whether the...

#1332 Solid: in accessors, add an exception check which tells whether the quantity is properly defined, thus giving a much more helpful guideline than just saying a pointer is null (the issue could arise with improper Lua data, hence the need to address it through an exception).
parent b6cd4107
......@@ -1454,6 +1454,9 @@
BEDEB9541C3C0A4F00B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEDEB9481C3C0A4700B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.cpp */; };
BEDEB9551C3C0A4F00B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BEDEB9491C3C0A4700B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.hpp */; };
BEDEB9561C3C0A4F00B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BEDEB94A1C3C0A4700B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.hxx */; };
BEDEDE07212FFB4C0060F00E /* Solid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEDEDE04212FFB4C0060F00E /* Solid.cpp */; };
BEDEDE08212FFB4C0060F00E /* Solid.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BEDEDE05212FFB4C0060F00E /* Solid.hxx */; };
BEDEDE09212FFB4C0060F00E /* Solid.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BEDEDE06212FFB4C0060F00E /* Solid.hpp */; };
BEDFFB53204EE3E200A52F86 /* catch.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BEDFFB52204EE3E200A52F86 /* catch.hpp */; };
BEE072A01FE177E2002D6EF1 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEE072961FE177E2002D6EF1 /* main.cpp */; };
BEE072A21FE177E2002D6EF1 /* Model.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEE072981FE177E2002D6EF1 /* Model.cpp */; };
......@@ -4749,6 +4752,9 @@
BEDEB9481C3C0A4700B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DofProgramWiseIndexListPerVertexCoordIndexListManager.cpp; sourceTree = "<group>"; };
BEDEB9491C3C0A4700B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DofProgramWiseIndexListPerVertexCoordIndexListManager.hpp; sourceTree = "<group>"; };
BEDEB94A1C3C0A4700B1C71B /* DofProgramWiseIndexListPerVertexCoordIndexListManager.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DofProgramWiseIndexListPerVertexCoordIndexListManager.hxx; sourceTree = "<group>"; };
BEDEDE04212FFB4C0060F00E /* Solid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Solid.cpp; sourceTree = "<group>"; };
BEDEDE05212FFB4C0060F00E /* Solid.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Solid.hxx; sourceTree = "<group>"; };
BEDEDE06212FFB4C0060F00E /* Solid.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Solid.hpp; sourceTree = "<group>"; };
BEDFFB52204EE3E200A52F86 /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch.hpp; sourceTree = "<group>"; };
BEDFFB7C204EE4F400A52F86 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BEDFFB7D204EE4F400A52F86 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
......@@ -7344,6 +7350,7 @@
BE451E841DAF795B00807035 /* Solid.cpp */,
BE451E851DAF795B00807035 /* Solid.hpp */,
BE451E861DAF795B00807035 /* Solid.hxx */,
BEDEDDFC212FFAE80060F00E /* Exceptions */,
);
path = Solid;
sourceTree = "<group>";
......@@ -10292,6 +10299,16 @@
path = Solver;
sourceTree = "<group>";
};
BEDEDDFC212FFAE80060F00E /* Exceptions */ = {
isa = PBXGroup;
children = (
BEDEDE04212FFB4C0060F00E /* Solid.cpp */,
BEDEDE06212FFB4C0060F00E /* Solid.hpp */,
BEDEDE05212FFB4C0060F00E /* Solid.hxx */,
);
path = Exceptions;
sourceTree = "<group>";
};
BEDFFB51204EE3E200A52F86 /* Catch */ = {
isa = PBXGroup;
children = (
......@@ -10852,6 +10869,7 @@
BE2EEA491DB4DB5300AF0D62 /* CopyValues.hpp in Headers */,
13D6A6731EA9F4CF0050363A /* ScalarParameterFromFile.hpp in Headers */,
BE451E891DAF795B00807035 /* Solid.hxx in Headers */,
BEDEDE08212FFB4C0060F00E /* Solid.hxx in Headers */,
BE451E6C1DAF78F100807035 /* Configuration.hpp in Headers */,
BE451E811DAF78F100807035 /* ThreeDimensionalParameter.hxx in Headers */,
BE451E671DAF78F100807035 /* ReadFiberFile.hpp in Headers */,
......@@ -10871,6 +10889,7 @@
BE451E621DAF78F100807035 /* FiberList.hxx in Headers */,
BE451E631DAF78F100807035 /* FiberListManager.hpp in Headers */,
BE451E661DAF78F100807035 /* FillGlobalVector.hxx in Headers */,
BEDEDE09212FFB4C0060F00E /* Solid.hpp in Headers */,
BE451E801DAF78F100807035 /* ThreeDimensionalParameter.hpp in Headers */,
BE099ED71DAFEAAA00A54392 /* FromAtDofToAtQuadPt.hpp in Headers */,
BE451E721DAF78F100807035 /* ComputeGradientBasedElasticityTensor.hxx in Headers */,
......@@ -12492,6 +12511,7 @@
BE451E871DAF795B00807035 /* Solid.cpp in Sources */,
BE2EEA481DB4DB5300AF0D62 /* CopyValues.cpp in Sources */,
13D6A6721EA9F4CF0050363A /* ScalarParameterFromFile.cpp in Sources */,
BEDEDE07212FFB4C0060F00E /* Solid.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
//! \file
//
//
// Solid.cpp
// MoReFEM
//
// Created by sebastien on 24/08/2018.
//Copyright © 2018 Inria. All rights reserved.
//
#include <sstream>
#include "ParameterInstances/Compound/Solid/Exceptions/Solid.hpp"
namespace // anonymous
{
std::string UndefinedDataMsg(const std::string& data_name);
} // namespace anonymous
namespace MoReFEM
{
namespace SolidNS
{
UndefinedData::UndefinedData(const std::string& data, const char* invoking_file, int invoking_line)
: ::MoReFEM::Exception(UndefinedDataMsg(data), invoking_file, invoking_line)
{ }
UndefinedData::~UndefinedData() = default;
} // namespace SolidNS
} // namespace MoReFEM
namespace // anonymous
{
std::string UndefinedDataMsg(const std::string& data_name)
{
std::ostringstream oconv;
oconv << "Data '" << data_name << "' is undefined: in all likelihood either the model is ill-formed and the "
"data is not in the InputData, or it is but in the Lua file the chosen nature was 'ignore'.";
std::string ret = oconv.str();
return ret;
}
} // namespace anonymous
//! \file
//
//
// Solid.hpp
// MoReFEM
//
// Created by sebastien on 24/08/2018.
//Copyright © 2018 Inria. All rights reserved.
//
#ifndef MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_EXCEPTIONS_x_SOLID_HPP_
# define MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_EXCEPTIONS_x_SOLID_HPP_
# include <string>
# include "Utilities/Exceptions/Exception.hpp"
namespace MoReFEM
{
namespace SolidNS
{
//! Exception thrown when access to an undefined data is attempted.
class UndefinedData : public ::MoReFEM::Exception
{
public:
/*!
* \brief Constructor with simple message
*
* \param[in] data Name of the data concerned, e.g. 'volumic mass'.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
explicit UndefinedData(const std::string& data, const char* invoking_file, int invoking_line);
//! Destructor
virtual ~UndefinedData() override;
//! Copy constructor.
UndefinedData(const UndefinedData&) = default;
//! Move constructor.
UndefinedData(UndefinedData&&) = default;
//! Copy affectation.
UndefinedData& operator=(const UndefinedData&) = default;
//! Move affectation.
UndefinedData& operator=(UndefinedData&&) = default;
};
} // namespace SolidNS
} // namespace MoReFEM
# include "ParameterInstances/Compound/Solid/Exceptions/Solid.hxx"
#endif // MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_EXCEPTIONS_x_SOLID_HPP_
//! \file
//
//
// Solid.hxx
// MoReFEM
//
// Created by sebastien on 24/08/2018.
//Copyright © 2018 Inria. All rights reserved.
//
#ifndef MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_EXCEPTIONS_x_SOLID_HXX_
# define MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_EXCEPTIONS_x_SOLID_HXX_
namespace MoReFEM
{
namespace SolidNS
{
} // namespace SolidNS
} // namespace MoReFEM
#endif // MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_EXCEPTIONS_x_SOLID_HXX_
target_sources(${MOREFEM_PARAM_INSTANCES}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Solid.cpp"
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Solid.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Solid.hxx"
)
......@@ -22,6 +22,7 @@
# include "Parameters/Parameter.hpp"
# include "Parameters/InitParameterFromInputData/InitParameterFromInputData.hpp"
# include "ParameterInstances/Compound/Solid/Exceptions/Solid.hpp"
namespace MoReFEM
......@@ -151,98 +152,98 @@ namespace MoReFEM
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetHyperelasticBulk() const noexcept;
const scalar_parameter& GetHyperelasticBulk() const;
/*!
* \brief Constant accessor to Kappa1.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetKappa1() const noexcept;
const scalar_parameter& GetKappa1() const;
/*!
* \brief Constant accessor to Kappa2.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetKappa2() const noexcept;
const scalar_parameter& GetKappa2() const;
/*!
* \brief Constant accessor to the Young modulus.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetYoungModulus() const noexcept;
const scalar_parameter& GetYoungModulus() const;
/*!
* \brief Constant accessor to the Poisson ratio.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetPoissonRatio() const noexcept;
const scalar_parameter& GetPoissonRatio() const;
/*!
* \brief Constant accessor to Lame lambda.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetLameLambda() const noexcept;
const scalar_parameter& GetLameLambda() const;
/*!
* \brief Constant accessor to Lame mu.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetLameMu() const noexcept;
const scalar_parameter& GetLameMu() const;
/*!
* \brief Constant accessor to mu1.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetMu1() const noexcept;
const scalar_parameter& GetMu1() const;
/*!
* \brief Constant accessor to mu2.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetMu2() const noexcept;
const scalar_parameter& GetMu2() const;
/*!
* \brief Constant accessor to C0.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC0() const noexcept;
const scalar_parameter& GetC0() const;
/*!
* \brief Constant accessor to C1.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC1() const noexcept;
const scalar_parameter& GetC1() const;
/*!
* \brief Constant accessor to C2.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC2() const noexcept;
const scalar_parameter& GetC2() const;
/*!
* \brief Constant accessor to C3.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC3() const noexcept;
const scalar_parameter& GetC3() const;
/*!
* \brief Constant accessor to the viscosity.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetViscosity() const noexcept;
const scalar_parameter& GetViscosity() const;
public:
......
......@@ -189,100 +189,148 @@ namespace MoReFEM
return *volumic_mass_;
}
inline const Solid::scalar_parameter& Solid::GetHyperelasticBulk() const noexcept
inline const Solid::scalar_parameter& Solid::GetHyperelasticBulk() const
{
if (!IsHyperelasticBulk())
throw SolidNS::UndefinedData("Hyperelastic bulk", __FILE__, __LINE__);
assert(!(!hyperelastic_bulk_));
return *hyperelastic_bulk_;
}
inline const Solid::scalar_parameter& Solid::GetKappa1() const noexcept
inline const Solid::scalar_parameter& Solid::GetKappa1() const
{
if (!IsKappa1())
throw SolidNS::UndefinedData("Kappa1", __FILE__, __LINE__);
decltype(auto) ptr = std::get<0>(kappa_list_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetKappa2() const noexcept
inline const Solid::scalar_parameter& Solid::GetKappa2() const
{
if (!IsKappa2())
throw SolidNS::UndefinedData("Kappa2", __FILE__, __LINE__);
decltype(auto) ptr = std::get<1>(kappa_list_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetYoungModulus() const noexcept
inline const Solid::scalar_parameter& Solid::GetYoungModulus() const
{
if (!IsYoungModulus())
throw SolidNS::UndefinedData("YoungModulus", __FILE__, __LINE__);
decltype(auto) ptr = std::get<0>(young_poisson_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetPoissonRatio() const noexcept
inline const Solid::scalar_parameter& Solid::GetPoissonRatio() const
{
if (!IsPoissonRatio())
throw SolidNS::UndefinedData("PoissonRatio", __FILE__, __LINE__);
decltype(auto) ptr = std::get<1>(young_poisson_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetLameLambda() const noexcept
inline const Solid::scalar_parameter& Solid::GetLameLambda() const
{
if (!IsLameLambda())
throw SolidNS::UndefinedData("Lame lambda", __FILE__, __LINE__);
decltype(auto) ptr = std::get<0>(lame_coeff_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetLameMu() const noexcept
inline const Solid::scalar_parameter& Solid::GetLameMu() const
{
if (!IsLameMu())
throw SolidNS::UndefinedData("Lame mu", __FILE__, __LINE__);
decltype(auto) ptr = std::get<1>(lame_coeff_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetMu1() const noexcept
inline const Solid::scalar_parameter& Solid::GetMu1() const
{
if (!IsMu1())
throw SolidNS::UndefinedData("Mu1", __FILE__, __LINE__);
decltype(auto) ptr = std::get<0>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetMu2() const noexcept
inline const Solid::scalar_parameter& Solid::GetMu2() const
{
if (!IsMu2())
throw SolidNS::UndefinedData("Mu2", __FILE__, __LINE__);
decltype(auto) ptr = std::get<1>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC0() const noexcept
inline const Solid::scalar_parameter& Solid::GetC0() const
{
if (!IsC0())
throw SolidNS::UndefinedData("C0", __FILE__, __LINE__);
decltype(auto) ptr = std::get<2>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC1() const noexcept
inline const Solid::scalar_parameter& Solid::GetC1() const
{
if (!IsC1())
throw SolidNS::UndefinedData("C1", __FILE__, __LINE__);
decltype(auto) ptr = std::get<3>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC2() const noexcept
inline const Solid::scalar_parameter& Solid::GetC2() const
{
if (!IsC2())
throw SolidNS::UndefinedData("C2", __FILE__, __LINE__);
decltype(auto) ptr = std::get<4>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC3() const noexcept
inline const Solid::scalar_parameter& Solid::GetC3() const
{
if (!IsC3())
throw SolidNS::UndefinedData("C3", __FILE__, __LINE__);
decltype(auto) ptr = std::get<5>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetViscosity() const noexcept
inline const Solid::scalar_parameter& Solid::GetViscosity() const
{
if (!IsViscosity())
throw SolidNS::UndefinedData("Viscosity", __FILE__, __LINE__);
assert(!(!viscosity_));
return *viscosity_;
}
......
......@@ -8,3 +8,4 @@ target_sources(${MOREFEM_PARAM_INSTANCES}
"${CMAKE_CURRENT_LIST_DIR}/Solid.hxx"
)
include(${CMAKE_CURRENT_LIST_DIR}/Exceptions/SourceList.cmake)
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