Commit 586bae19 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1435 Update the Lua description for parameters.

parent b10d66d1
......@@ -7411,11 +7411,11 @@
BE4D0CAE21A2E4F900E0D4E7 /* Impl */,
BE4D0CB221A2E4F900E0D4E7 /* Pressure.hpp */,
BE4D0CB321A2E4F900E0D4E7 /* ScalarTransientSource.hpp */,
BE4D0CB421A2E4F900E0D4E7 /* RectangularSourceTimeParameter.hpp */,
BE4D0CB521A2E4F900E0D4E7 /* VectorialTransientSource.hxx */,
BE4D0CB821A2E4F900E0D4E7 /* ScalarTransientSource.hxx */,
BE4D0CB621A2E4F900E0D4E7 /* VectorialTransientSource.hpp */,
BE4D0CB521A2E4F900E0D4E7 /* VectorialTransientSource.hxx */,
BE4D0CB421A2E4F900E0D4E7 /* RectangularSourceTimeParameter.hpp */,
BE4D0CB721A2E4F900E0D4E7 /* RectangularSourceTimeParameter.hxx */,
BE4D0CB821A2E4F900E0D4E7 /* ScalarTransientSource.hxx */,
BE4D0CB921A2E4F900E0D4E7 /* Pressure.cpp */,
BE4D0CBA21A2E4F900E0D4E7 /* Pressure.hxx */,
);
......@@ -53,40 +53,9 @@ namespace MoReFEM
return Utilities::EmptyString();
}
namespace Impl
{
std::string SelectorDescription()
{
std::ostringstream oconv;
decltype(auto) empty_str = Utilities::EmptyString();
oconv << "The value for the parameter, which type depends directly on the nature chosen:";
oconv << "\n If nature is 'constant', expected format is "
<< Internal::InputDataNS::Traits::Format<double>::Print(empty_str);
oconv << "\n If nature is 'piecewise_constant_by_domain', expected format is "
<< Internal::InputDataNS::Traits::Format<std::map<unsigned int, double>>::Print(empty_str);
oconv << "\n If nature is 'lua_function', expected format is a Lua function with prototype "
"function(x, y, z) \n"
<< "return x + y - z\n"
<< "end\n"
<< "where x, y and z are global coordinates. "
<< "sin, cos, tan, exp and so forth require a 'math.' preffix.\n";
std::string ret(oconv.str());
return ret;
}
} // namespace Impl
} // namespace Advanced::InputDataNS::ParamNS
} // namespace MoReFEM
......
......@@ -40,7 +40,7 @@ namespace MoReFEM
/*!
* \brief Choose how is described the \a Parameter (through a scalar, a function, etc...)
*
* \tparam ComponentT 'none' if the parameter is scalar, 'X', 'Y'or 'Z' otherwise.
* \tparam IsVectorialT Whether the parameter is scalar or vectorial
*/
template<IsVectorial IsVectorialT = IsVectorial::no>
struct Nature
......@@ -249,14 +249,14 @@ namespace MoReFEM
/*!
* \brief Returns the description of the Selector class.
*
* \tparam IsVectorialT Whether the parameter is scalar or vectorial
*
* \return The description as a new std::string.
*/
template <IsVectorial IsVectorialT>
std::string SelectorDescription();
} // namespace Impl
......
......@@ -35,10 +35,21 @@ namespace MoReFEM
template<IsVectorial IsVectorialT>
const std::string& Nature<IsVectorialT>::Description()
{
static std::string ret("How is given the parameter (as a constant, as a Lua function, per "
"quadrature point, etc...). Choose \"ignore\" if you do not want this "
"parameter (in this case it will stay at nullptr).");
return ret;
if constexpr (IsVectorialT == IsVectorial::yes)
{
static std::string ret("How is given each component of the parameter (as a constant, as a Lua function"
", per quadrature point, etc...). Choose \"ignore\" if you do not want this "
"parameter (in this case it will stay at nullptr).");
return ret;
}
else
{
static std::string ret("How is given the parameter (as a constant, as a Lua function, per "
"quadrature point, etc...). Choose \"ignore\" if you do not want this "
"parameter (in this case it will stay at nullptr).");
return ret;
}
}
......@@ -131,7 +142,7 @@ namespace MoReFEM
template <class NatureT, IsVectorial IsVectorialT>
const std::string& Value<NatureT, IsVectorialT>::Description()
{
static std::string ret = Impl::SelectorDescription();
static std::string ret = Impl::SelectorDescription<IsVectorialT>();
return ret;
}
......@@ -146,11 +157,56 @@ namespace MoReFEM
template <class NatureT, IsVectorial IsVectorialT>
const std::string& Value<NatureT, IsVectorialT>::DefaultValue()
{
static std::string ret("{}");
return ret;
if constexpr(IsVectorialT == IsVectorial::yes)
{
static std::string ret("{}");
return ret;
}
else
return Utilities::EmptyString();
}
namespace Impl
{
template<IsVectorial IsVectorialT>
std::string SelectorDescription()
{
std::ostringstream oconv;
decltype(auto) empty_str = Utilities::EmptyString();
if constexpr(IsVectorialT == IsVectorial::yes)
oconv << "The values of the vectorial parameter; expected format is a table (opening = '{', "
"closing = '} and separator = ',') and each item depends on the nature specified at the "
"namesake field:\n";
else
oconv << "The value for the parameter, which type depends directly on the nature chosen in the "
"namesake field:\n";
oconv << "\n If nature is 'constant', expected format is "
<< Internal::InputDataNS::Traits::Format<double>::Print(empty_str);
oconv << "\n If nature is 'piecewise_constant_by_domain', expected format is "
<< Internal::InputDataNS::Traits::Format<std::map<unsigned int, double>>::Print(empty_str);
oconv << "\n If nature is 'lua_function', expected format is a Lua function inside a '[[' ']]' block:\n"
"[[\n"
"function(x, y, z) \n"
"return x + y - z\n"
"end\n"
"]]\n"
"where x, y and z are global coordinates. "
"sin, cos, tan, exp and so forth require a 'math.' preffix.\n";
std::string ret(oconv.str());
return ret;
}
} // namespace Impl
} // namespace Advanced::InputDataNS::ParamNS
......
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