|
22 | 22 | #include <variant> |
23 | 23 | #include <optional> |
24 | 24 | #include <string_view> |
| 25 | +#ifdef MGIS_HAVE_HDF5 |
| 26 | +#include "MGIS/Utilities/HDF5Forward.hxx" |
| 27 | +#endif /* MGIS_HAVE_HDF5 */ |
| 28 | + |
25 | 29 | #include "MGIS/Config.hxx" |
26 | 30 | #include "MGIS/StorageMode.hxx" |
27 | 31 |
|
@@ -240,6 +244,37 @@ namespace mgis::behaviour { |
240 | 244 | const MaterialStateManager::StorageMode = |
241 | 245 | MaterialStateManager::LOCAL_STORAGE, |
242 | 246 | const MaterialStateManager::UpdatePolicy = MaterialStateManager::UPDATE); |
| 247 | + /*! |
| 248 | + * \brief set the given material property |
| 249 | + * \param[out] m: material data manager |
| 250 | + * \param[in] n: name |
| 251 | + * \param[in] v: value |
| 252 | + * \param[in] p: update policy |
| 253 | + */ |
| 254 | + MGIS_EXPORT [[nodiscard]] bool setMaterialProperty( |
| 255 | + Context&, |
| 256 | + MaterialStateManager&, |
| 257 | + const std::string_view&, |
| 258 | + const real, |
| 259 | + const MaterialStateManager::UpdatePolicy = |
| 260 | + MaterialStateManager::UPDATE) noexcept; |
| 261 | + /*! |
| 262 | + * \brief set the given material property |
| 263 | + * \param[out] m: material data manager |
| 264 | + * \param[in] n: name |
| 265 | + * \param[in] v: values |
| 266 | + * \param[in] s: storage mode |
| 267 | + * \param[in] p: update policy |
| 268 | + */ |
| 269 | + MGIS_EXPORT [[nodiscard]] bool setMaterialProperty( |
| 270 | + Context&, |
| 271 | + MaterialStateManager&, |
| 272 | + const std::string_view&, |
| 273 | + const std::span<mgis::real>&, |
| 274 | + const MaterialStateManager::StorageMode = |
| 275 | + MaterialStateManager::LOCAL_STORAGE, |
| 276 | + const MaterialStateManager::UpdatePolicy = |
| 277 | + MaterialStateManager::UPDATE) noexcept; |
243 | 278 | /*! |
244 | 279 | * \return true if the given external state variable is defined. |
245 | 280 | * \param[out] m: material data manager |
@@ -354,6 +389,93 @@ namespace mgis::behaviour { |
354 | 389 | const mgis::behaviour::MaterialStateManager&, |
355 | 390 | const std::string_view); |
356 | 391 |
|
| 392 | +#ifdef MGIS_HAVE_HDF5 |
| 393 | + |
| 394 | + /*! |
| 395 | + * \brief structure used to customize the saving of a `MaterialStateManager` |
| 396 | + */ |
| 397 | + struct MaterialStateManagerSavingOptions { |
| 398 | + const bool allow_overwrite = true; |
| 399 | + const bool save_gradients = true; |
| 400 | + const bool save_thermodynamic_forces = true; |
| 401 | + const bool save_stored_energies = true; |
| 402 | + const bool save_dissipated_energies = true; |
| 403 | + const bool save_mass_densities = true; |
| 404 | + const bool save_material_properties = true; |
| 405 | + const bool save_external_state_variables = true; |
| 406 | + }; |
| 407 | + |
| 408 | + /*! |
| 409 | + * \brief save a `MaterialStateManager` to an HDF5 group |
| 410 | + * \param[in] ctx: execution context |
| 411 | + * \param[in] g: group |
| 412 | + * \param[in] s: material state manager |
| 413 | + * \param[in] opts: options |
| 414 | + */ |
| 415 | + MGIS_EXPORT [[nodiscard]] bool save( |
| 416 | + Context&, |
| 417 | + H5::Group&, |
| 418 | + const MaterialStateManager&, |
| 419 | + const MaterialStateManagerSavingOptions& = {}) noexcept; |
| 420 | + |
| 421 | + /*! |
| 422 | + * \brief structure used to customize how to restore a `MaterialStateManager` |
| 423 | + */ |
| 424 | + struct MaterialStateManagerRestoreOptions { |
| 425 | + const bool restore_gradients = true; |
| 426 | + const bool restore_thermodynamic_forces = true; |
| 427 | + /*! |
| 428 | + * \brief flag stating if the stored energies shall be read |
| 429 | + * |
| 430 | + * \note this flag is ignored if the behaviour does not compute the |
| 431 | + * stored energy |
| 432 | + */ |
| 433 | + const bool restore_stored_energies = true; |
| 434 | + /*! |
| 435 | + * \brief flag stating if the dissipated energies shall be read |
| 436 | + * |
| 437 | + * \note this flag is ignored if the behaviour does not compute the |
| 438 | + * dissipated energy |
| 439 | + */ |
| 440 | + const bool restore_dissipated_energies = true; |
| 441 | + const bool restore_internal_state_variables = true; |
| 442 | + const bool restore_mass_densities = true; |
| 443 | + const bool restore_material_properties = true; |
| 444 | + //! \brief list of material properties that shall not be restored |
| 445 | + const std::vector<std::string> ignored_material_properties = {}; |
| 446 | + const bool restore_external_state_variables = true; |
| 447 | + //! \brief list of external state variables that shall not be restored |
| 448 | + const std::vector<std::string> ignored_external_state_variables = {}; |
| 449 | + }; // end of MaterialStateManagerRestoreOptions |
| 450 | + /*! |
| 451 | + * \brief return restore options selecting all that can be read in the given |
| 452 | + * group. |
| 453 | + * |
| 454 | + * \param[in] ctx: execution context |
| 455 | + * \param[in] g: group |
| 456 | + */ |
| 457 | + MGIS_EXPORT [[nodiscard]] std::optional<MaterialStateManagerRestoreOptions> |
| 458 | + getGreedyMaterialStateManagerRestoreOptions(Context&, |
| 459 | + const H5::Group&) noexcept; |
| 460 | + /*! |
| 461 | + * \brief restore a `MaterialStateManager` from a HDF5 group |
| 462 | + * |
| 463 | + * \param[in] ctx: execution context |
| 464 | + * \param[in] g: group |
| 465 | + * \param[in] s: material state manager |
| 466 | + * \param[in] opts: options |
| 467 | + * |
| 468 | + * \note update policies are set to their values for material properties and |
| 469 | + * external state variables created during the restoration |
| 470 | + */ |
| 471 | + MGIS_EXPORT [[nodiscard]] bool restore( |
| 472 | + Context&, |
| 473 | + MaterialStateManager&, |
| 474 | + const H5::Group&, |
| 475 | + const MaterialStateManagerRestoreOptions&) noexcept; |
| 476 | + |
| 477 | +#endif /* MGIS_HAVE_HDF5 */ |
| 478 | + |
357 | 479 | } // end of namespace mgis::behaviour |
358 | 480 |
|
359 | 481 | #endif /* LIB_MGIS_BEHAVIOUR_MATERIALSTATEMANAGER_HXX */ |
0 commit comments