Solid.hxx 15.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
///
////// \file
///
///
/// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Tue, 23 Feb 2016 14:47:05 +0100
/// Copyright (c) Inria. All rights reserved.
///
/// \ingroup ParameterInstancesGroup
/// \addtogroup ParameterInstancesGroup
/// \{
11

12 13
#ifndef MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_SOLID_HXX_
# define MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_SOLID_HXX_
14 15


16
namespace MoReFEM
17
{
18 19


20
    namespace Internal
21
    {
22 23


24
        namespace SolidNS
25
        {
26

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

            template<class InputParameterDataT, class T>
            constexpr bool IsDefined()
            {
                if (Utilities::Tuple::IndexOf<T, typename InputParameterDataT::Tuple>::value
                    != NumericNS::UninitializedIndex<unsigned int>())
                    return true;

                // If InputParameter::Solid is defined, ALL parameters are defined and true should be returned!
                return (Utilities::Tuple::IndexOf
                        <
                            ::MoReFEM::InputParameter::Solid,
                            typename InputParameterDataT::Tuple
                        >::value != NumericNS::UninitializedIndex<unsigned int>());
            }


44
        }
45 46


47
    } // namespace Internal
48

49

50
    template<class InputParameterDataT>
51
    Solid::Solid(const InputParameterDataT& input_data,
52
                 const Domain& domain,
53
                 const QuadratureRulePerTopology& quadrature_rule_per_topology,
54
                 const double relative_tolerance)
55
    : domain_(domain),
56
    quadrature_rule_per_topology_(quadrature_rule_per_topology)
57
    {
58

59
        using SolidIP = InputParameter::Solid;
60

61
        volumic_mass_ =
62
            InitScalarParameterFromInputData<InputParameter::Solid::VolumicMass>("Volumic mass",
63
                                                                                 domain,
64
                                                                                 input_data);
65

66 67
        if constexpr ((Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::LameLambda>())
            || (Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::LameMu>()))
68
        {
69 70 71
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::LameLambda>(),
                          "It makes no sense to define one and not the other");

72
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::LameMu>(),
73
                          "It makes no sense to define one and not the other");
74

75 76 77
            std::get<0>(lame_coeff_) =
                InitScalarParameterFromInputData<InputParameter::Solid::LameLambda>("Lame lambda",
                                                                                    domain,
78
                                                                                    input_data);
79 80
            std::get<1>(lame_coeff_) =
                InitScalarParameterFromInputData<InputParameter::Solid::LameMu>("Lame mu",
81
                                                                                domain,
82
                                                                                input_data);
83
        }
84

85 86
        if constexpr ((Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::YoungModulus>())
                      || (Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::PoissonRatio>()))
87
        {
88
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::PoissonRatio>(),
89
                          "It makes no sense to define one and not the other");
90

91 92 93
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::YoungModulus>(),
                          "It makes no sense to define one and not the other");

94 95 96
            std::get<0>(young_poisson_) =
                InitScalarParameterFromInputData<InputParameter::Solid::YoungModulus>("Young modulus",
                                                                                      domain,
97
                                                                                      input_data);
98

99

100 101 102
            std::get<1>(young_poisson_) =
                InitScalarParameterFromInputData<InputParameter::Solid::PoissonRatio>("Poisson ratio",
                                                                                      domain,
103
                                                                                      input_data);
104
        }
105

106 107
        if constexpr ((Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Kappa1>())
                      || (Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Kappa2>()))
108
        {
109 110 111
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Kappa1>(),
                          "It makes no sense to define one and not the other");

112
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Kappa2>(),
113
                          "It makes no sense to define one and not the other");
114

115 116 117
            std::get<0>(kappa_list_) =
                InitScalarParameterFromInputData<InputParameter::Solid::Kappa1>("Kappa_1",
                                                                                domain,
118
                                                                                input_data);
119

120 121 122
            std::get<1>(kappa_list_) =
                InitScalarParameterFromInputData<InputParameter::Solid::Kappa2>("Kappa_2",
                                                                                domain,
123
                                                                                input_data);
124
        }
125

126
        if constexpr (Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::HyperelasticBulk>())
127 128 129 130
        {
            hyperelastic_bulk_ =
                InitScalarParameterFromInputData<InputParameter::Solid::HyperelasticBulk>("Hyperelastic bulk",
                                                                                          domain,
131
                                                                                          input_data);
132
        }
133

134
        if constexpr (Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Viscosity>())
135 136 137 138
        {
            viscosity_ =
                InitScalarParameterFromInputData<InputParameter::Solid::Viscosity>("Viscosity",
                                                                                   domain,
139
                                                                                   input_data);
140
        }
141

142 143 144 145 146 147 148
        if constexpr (Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Mu1>()
            || Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C0>()
            || Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C1>()
            || Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C2>()
            || Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C3>()
            || Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Mu2>())
        { 
149 150 151 152
            static_assert(Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Mu2>()
                          && Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C0>()
                          && Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C1>()
                          && Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C2>()
153 154
                          && Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::C3>()
                          && Internal::SolidNS::IsDefined<InputParameterDataT, SolidIP::Mu1>(),
155
                          "It makes no sense to define one and not the others");
156

157 158 159
            std::get<0>(mu_i_C_i_) =
                InitScalarParameterFromInputData<InputParameter::Solid::Mu1>("Mu1",
                                                                             domain,
160
                                                                             input_data);
161 162 163
            std::get<1>(mu_i_C_i_) =
                InitScalarParameterFromInputData<InputParameter::Solid::Mu2>("Mu2",
                                                                             domain,
164
                                                                             input_data);
165 166 167
            std::get<2>(mu_i_C_i_) =
                InitScalarParameterFromInputData<InputParameter::Solid::C0>("C0",
                                                                            domain,
168
                                                                            input_data);
169

170
            std::get<3>(mu_i_C_i_) =
171 172
                InitScalarParameterFromInputData<InputParameter::Solid::C1>("C1",
                                                                            domain,
173
                                                                            input_data);
174

175
            std::get<4>(mu_i_C_i_) =
176 177
                InitScalarParameterFromInputData<InputParameter::Solid::C2>("C2",
                                                                            domain,
178
                                                                            input_data);
179

180
            std::get<5>(mu_i_C_i_) =
181 182
                InitScalarParameterFromInputData<InputParameter::Solid::C3>("C3",
                                                                            domain,
183
                                                                            input_data);
184
        }
185

186 187
        if (relative_tolerance >= 0.)
            CheckConsistency(relative_tolerance);
188
    }
189 190


191

192 193 194
    inline const Domain& Solid::GetDomain() const noexcept
    {
        return domain_;
195
    }
196 197


198
    inline const QuadratureRulePerTopology& Solid::GetQuadratureRulePerTopology() const noexcept
199
    {
200
        return quadrature_rule_per_topology_;
201
    }
202

203

204
    inline const Solid::scalar_parameter& Solid::GetVolumicMass() const
205
    {
206 207 208
        if (!volumic_mass_)
            throw SolidNS::UndefinedData("Volumic mass", __FILE__, __LINE__);

209
        return *volumic_mass_;
210
    }
211

212 213
    
    inline const Solid::scalar_parameter& Solid::GetHyperelasticBulk() const
214
    {
215 216 217
        if (!IsHyperelasticBulk())
            throw SolidNS::UndefinedData("Hyperelastic bulk", __FILE__, __LINE__);

218 219
        assert(!(!hyperelastic_bulk_));
        return *hyperelastic_bulk_;
220
    }
221

222
    inline const Solid::scalar_parameter& Solid::GetKappa1() const
223
    {
224 225 226
        if (!IsKappa1())
            throw SolidNS::UndefinedData("Kappa1", __FILE__, __LINE__);

227 228 229
        decltype(auto) ptr = std::get<0>(kappa_list_);
        assert(!(!ptr));
        return *ptr;
230
    }
231 232


233
    inline const Solid::scalar_parameter& Solid::GetKappa2() const
234
    {
235 236 237
        if (!IsKappa2())
            throw SolidNS::UndefinedData("Kappa2", __FILE__, __LINE__);

238 239 240 241
        decltype(auto) ptr = std::get<1>(kappa_list_);
        assert(!(!ptr));
        return *ptr;
    }
242

243

244
    inline const Solid::scalar_parameter& Solid::GetYoungModulus() const
245
    {
246 247 248
        if (!IsYoungModulus())
            throw SolidNS::UndefinedData("YoungModulus", __FILE__, __LINE__);

249 250 251
        decltype(auto) ptr = std::get<0>(young_poisson_);
        assert(!(!ptr));
        return *ptr;
252

253
    }
254

255

256
    inline const Solid::scalar_parameter& Solid::GetPoissonRatio() const
257
    {
258 259 260
        if (!IsPoissonRatio())
            throw SolidNS::UndefinedData("PoissonRatio", __FILE__, __LINE__);

261 262 263 264
        decltype(auto) ptr = std::get<1>(young_poisson_);
        assert(!(!ptr));
        return *ptr;
    }
265

266
    inline const Solid::scalar_parameter& Solid::GetLameLambda() const
267
    {
268 269 270
        if (!IsLameLambda())
            throw SolidNS::UndefinedData("Lame lambda", __FILE__, __LINE__);

271 272 273 274
        decltype(auto) ptr = std::get<0>(lame_coeff_);
        assert(!(!ptr));
        return *ptr;
    }
275

276
    inline const Solid::scalar_parameter& Solid::GetLameMu() const
277
    {
278 279 280
        if (!IsLameMu())
            throw SolidNS::UndefinedData("Lame mu", __FILE__, __LINE__);

281 282 283 284
        decltype(auto) ptr = std::get<1>(lame_coeff_);
        assert(!(!ptr));
        return *ptr;
    }
285

286
    inline const Solid::scalar_parameter& Solid::GetMu1() const
287
    {
288 289 290
        if (!IsMu1())
            throw SolidNS::UndefinedData("Mu1", __FILE__, __LINE__);

291 292 293 294
        decltype(auto) ptr = std::get<0>(mu_i_C_i_);
        assert(!(!ptr));
        return *ptr;
    }
295

296

297
    inline const Solid::scalar_parameter& Solid::GetMu2() const
298
    {
299 300 301
        if (!IsMu2())
            throw SolidNS::UndefinedData("Mu2", __FILE__, __LINE__);

302 303 304 305
        decltype(auto) ptr = std::get<1>(mu_i_C_i_);
        assert(!(!ptr));
        return *ptr;
    }
306

307 308

    inline const Solid::scalar_parameter& Solid::GetC0() const
309
    {
310 311 312
        if (!IsC0())
            throw SolidNS::UndefinedData("C0", __FILE__, __LINE__);

313 314 315 316
        decltype(auto) ptr = std::get<2>(mu_i_C_i_);
        assert(!(!ptr));
        return *ptr;
    }
317

318 319

    inline const Solid::scalar_parameter& Solid::GetC1() const
320
    {
321 322 323
        if (!IsC1())
            throw SolidNS::UndefinedData("C1", __FILE__, __LINE__);

324 325 326 327
        decltype(auto) ptr = std::get<3>(mu_i_C_i_);
        assert(!(!ptr));
        return *ptr;
    }
328

329 330

    inline const Solid::scalar_parameter& Solid::GetC2() const
331
    {
332 333 334
        if (!IsC2())
            throw SolidNS::UndefinedData("C2", __FILE__, __LINE__);

335 336 337 338
        decltype(auto) ptr = std::get<4>(mu_i_C_i_);
        assert(!(!ptr));
        return *ptr;
    }
339

340 341

    inline const Solid::scalar_parameter& Solid::GetC3() const
342
    {
343 344 345
        if (!IsC3())
            throw SolidNS::UndefinedData("C3", __FILE__, __LINE__);

346 347 348 349
        decltype(auto) ptr = std::get<5>(mu_i_C_i_);
        assert(!(!ptr));
        return *ptr;
    }
350

351
    
352
    inline const Solid::scalar_parameter& Solid::GetViscosity() const
353
    {
354 355 356
        if (!IsViscosity())
            throw SolidNS::UndefinedData("Viscosity", __FILE__, __LINE__);

357 358 359
        assert(!(!viscosity_));
        return *viscosity_;
    }
360 361


362 363 364 365
    inline bool Solid::IsHyperelasticBulk() const noexcept
    {
        return hyperelastic_bulk_ != nullptr;
    }
366 367


368 369 370 371
    inline bool Solid::IsKappa1() const noexcept
    {
        return std::get<0>(kappa_list_) != nullptr;
    }
372 373


374 375 376 377
    inline bool Solid::IsKappa2() const noexcept
    {
        return std::get<1>(kappa_list_) != nullptr;
    }
378 379


380 381 382 383
    inline bool Solid::IsYoungModulus() const noexcept
    {
        return std::get<0>(young_poisson_) != nullptr;
    }
384 385


386 387 388 389
    inline bool Solid::IsPoissonRatio() const noexcept
    {
        return std::get<1>(young_poisson_) != nullptr;
    }
390 391


392 393 394 395
    inline bool Solid::IsLameLambda() const noexcept
    {
        return std::get<0>(lame_coeff_) != nullptr;
    }
396 397


398 399 400 401
    inline bool Solid::IsLameMu() const noexcept
    {
        return std::get<1>(lame_coeff_) != nullptr;
    }
402 403


404 405 406 407
    inline bool Solid::IsMu1() const noexcept
    {
        return std::get<0>(mu_i_C_i_) != nullptr;
    }
408 409


410 411 412 413
    inline bool Solid::IsMu2() const noexcept
    {
        return std::get<1>(mu_i_C_i_) != nullptr;
    }
414 415


416 417 418 419
    inline bool Solid::IsC0() const noexcept
    {
        return std::get<2>(mu_i_C_i_) != nullptr;
    }
420 421


422 423 424 425
    inline bool Solid::IsC1() const noexcept
    {
        return std::get<3>(mu_i_C_i_) != nullptr;
    }
426 427


428 429 430 431
    inline bool Solid::IsC2() const noexcept
    {
        return std::get<4>(mu_i_C_i_) != nullptr;
    }
432 433


434 435 436 437
    inline bool Solid::IsC3() const noexcept
    {
        return std::get<5>(mu_i_C_i_) != nullptr;
    }
438 439


440 441 442 443
    inline bool Solid::IsViscosity() const noexcept
    {
        return viscosity_ != nullptr;
    }
444

445

446
} // namespace MoReFEM
447 448


449 450 451
/// @} // addtogroup ParameterInstancesGroup


452
#endif // MOREFEM_x_PARAMETER_INSTANCES_x_COMPOUND_x_SOLID_x_SOLID_HXX_