InitParameterFromInputData.hpp 4.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
///
////// \file
///
///
/// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Wed, 12 Oct 2016 13:41:06 +0200
/// Copyright (c) Inria. All rights reserved.
///
/// \ingroup ParametersGroup
/// \addtogroup ParametersGroup
/// \{
11

12 13
#ifndef MOREFEM_x_PARAMETERS_x_INIT_PARAMETER_FROM_INPUT_DATA_x_INTERNAL_x_INIT_PARAMETER_FROM_INPUT_DATA_HPP_
# define MOREFEM_x_PARAMETERS_x_INIT_PARAMETER_FROM_INPUT_DATA_x_INTERNAL_x_INIT_PARAMETER_FROM_INPUT_DATA_HPP_
14

15
# include "Parameters/ParameterType.hpp"
16

17 18 19 20 21 22
# include "Parameters/Parameter.hpp"
# include "Parameters/Internal/ParameterInstance.hpp"
# include "Parameters/Policy/Constant/Constant.hpp"
# include "Parameters/Policy/OpsFunction/OpsFunction.hpp"
# include "Parameters/Policy/AtQuadraturePoint/AtQuadraturePoint.hpp"
# include "Parameters/Policy/PiecewiseConstantByDomain/PiecewiseConstantByDomain.hpp"
23

24
# include "Parameters/Internal/Alias.hpp"
25 26


27
namespace MoReFEM
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
{


    namespace Internal
    {


        namespace ParameterNS
        {


            /*!
             * \brief Initialize properly a scalar Parameter from the informations given in the input file.
             *
             * \attention This function is in the Internal namespace and should not be called directly unless you know
43
             * exactly what you're doing! Usually the namesake function in MoReFEM namespace is what you're looking for.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
             *
             * Current function in the Internal namespace has been introduced as there are currently two different cases
             * in which we want to instantiate a scalar parameter:
             * . When it is actually a scalar parameter we want to build.
             *
             * Typically, such a parameter is defined like:
             * \code
             * YoungModulus = {
             * nature = "lua_function",
             * scalar_value = 10.,
             * lua_function = function (x, y, z)
             * return x + y * 10 + z * 100
             *  end
             * }
             * \endcode
             * . When we want to build a vectorial parameter. Under the hood each component is built as a scalar parameter;
             * but nature and scalar_value are given within vectors in Ops file. Lua function can't be given in a vector,
             * hence the asymmetry between some parameters given as template arguments and other as plain arguments.
             *
             *
             * \tparam InputParameterDataT Type of the input parameter file for the considered model instance.
             * \tparam LuaFieldT Input parameter structure from the input file that will be used to build the OpsFunction
             * object. For instance InputParameter::YoungModulus::LuaFunction.
             *
             * \copydoc doxygen_hide_input_parameter_data_arg
69
             * \param[in] name Name of the parameter (for outputs only).
70
             * \copydoc doxygen_hide_parameter_domain_arg
71 72
             * \param[in] nature Nature of the scalar parameter as read in the input file ('constant', 'lua_function', etc..)
             * Ops is supposed to check the given values are legit.
73
             * \param[in] nature Nature of the parameter (scalar, vectorial or matricial).
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
             * \param[in] scalar_value Scalar value to use in the case a constant parameter is built. Irrelevant for other
             * natures.
             * \param[in] domain_id_list List of \a Domain unique identifiers in the case of a piecewise constant by
             * domain parameter. Irrelevant for other natures.
             * \param[in] value_per_domain Scalar value to attribute to each domain in the case of a piecewise constant by
             * domain parameter. Must be the same size as \a domain_id_list, as the value for the \a i -th domain is found at
             * the \a i -th position in this container. Irrelevant for other natures.

             * \return Parameter considered.
             */
            template
            <
                class LuaFieldT,
                template<ParameterNS::Type> class TimeDependencyT,
                class StringT,
                class InputParameterDataT
            >
            typename ScalarParameter<TimeDependencyT>::unique_ptr
            InitScalarParameterFromInputData(StringT&& name,
93
                                             const Domain& domain,
94 95 96 97 98 99 100 101 102 103 104 105 106
                                             const InputParameterDataT& input_parameter_data,
                                             const std::string& nature,
                                             double scalar_value,
                                             const std::vector<unsigned int>& domain_id_list,
                                             const std::vector<double>& value_per_domain);


        } // namespace ParameterNS


    } // namespace Internal


107
} // namespace MoReFEM
108 109


110 111 112
/// @} // addtogroup ParametersGroup


113
# include "Parameters/InitParameterFromInputData/Internal/InitParameterFromInputData.hxx"
114 115


116
#endif // MOREFEM_x_PARAMETERS_x_INIT_PARAMETER_FROM_INPUT_DATA_x_INTERNAL_x_INIT_PARAMETER_FROM_INPUT_DATA_HPP_