OGS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
SetIPDataInitialConditions.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <string_view>
14
15#include "BaseLib/Error.h"
16#include "MeshLib/Properties.h"
18
19namespace ProcessLib
20{
22inline std::string_view removeIPFieldDataNameSuffix(std::string_view const name)
23{
24 if (!name.ends_with("_ip"))
25 {
27 "The name of integration point data must end with '_ip'. '{}' "
28 "does not.",
29 name);
30 }
31
32 return {name.data(), name.size() - 3};
33}
34
35template <typename LocalAssemblersVector>
37 std::vector<std::unique_ptr<MeshLib::IntegrationPointWriter>> const&
38 _integration_point_writer,
39 MeshLib::Properties const& mesh_properties,
40 LocalAssemblersVector& local_assemblers)
41{
42 auto const& opt_ip_meta_data_all =
44
45 for (auto const& ip_writer : _integration_point_writer)
46 {
47 // Find the mesh property with integration point writer's name.
48 auto const& name = ip_writer->name();
49 if (!mesh_properties.existsPropertyVector<double>(name))
50 {
51 continue;
52 }
53 auto const& mesh_property =
54 *mesh_properties.template getPropertyVector<double>(name);
55
56 // The mesh property must be defined on integration points.
57 if (mesh_property.getMeshItemType() !=
59 {
60 continue;
61 }
62
63 auto const ip_meta_data =
64 getIntegrationPointMetaDataSingleField(opt_ip_meta_data_all, name);
65
66 // Check the number of components.
67 if (ip_meta_data.n_components !=
68 mesh_property.getNumberOfGlobalComponents())
69 {
71 "Different number of components in meta data ({:d}) than in "
72 "the integration point field data for '{:s}': {:d}.",
73 ip_meta_data.n_components, name,
74 mesh_property.getNumberOfGlobalComponents());
75 }
76
77 INFO("Setting initial integration point data for '{}'", name);
78
79 auto const name_transformed = removeIPFieldDataNameSuffix(name);
80
81 // Now we have a properly named vtk's field data array and the
82 // corresponding meta data.
83 std::size_t position = 0;
84 for (auto& local_asm : local_assemblers)
85 {
86 std::size_t const integration_points_read =
87 local_asm->setIPDataInitialConditions(
88 name_transformed, &mesh_property[position],
89 ip_meta_data.integration_order);
90 // The number of read integration points could be zero in case there
91 // are e.g. multiple materials with different sets of internal state
92 // variables.
93
94 position += integration_points_read * ip_meta_data.n_components;
95 }
96 }
97}
98} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
Definition of the class Properties that implements a container of properties.
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition Properties.h:33
bool existsPropertyVector(std::string_view name) const
Definition Properties.h:74
std::optional< IntegrationPointMetaData > getIntegrationPointMetaData(MeshLib::Properties const &properties)
std::string_view removeIPFieldDataNameSuffix(std::string_view const name)
Removes the suffix '_ip' from the passed field name.
void setIPDataInitialConditions(std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > const &_integration_point_writer, MeshLib::Properties const &mesh_properties, LocalAssemblersVector &local_assemblers)