OGS
SetOrGetIntegrationPointData.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <Eigen/Eigen>
15#include <vector>
16
17#include "BaseLib/DynamicSpan.h"
21
22namespace ProcessLib
23{
24template <int DisplacementDim, typename IntegrationPointDataVector,
25 typename IpData, typename MemberType>
26std::vector<double> const& getIntegrationPointKelvinVectorData(
27 IntegrationPointDataVector const& ip_data, MemberType IpData::*const member,
28 std::vector<double>& cache)
29{
30 constexpr int kelvin_vector_size =
32 auto const n_integration_points = ip_data.size();
33
34 cache.clear();
35 auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix<
36 double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>(
37 cache, kelvin_vector_size, n_integration_points);
38
39 for (unsigned ip = 0; ip < n_integration_points; ++ip)
40 {
41 auto const& kelvin_vector = ip_data[ip].*member;
42 cache_mat.col(ip) =
44 }
45
46 return cache;
47}
48
49template <int DisplacementDim, typename IntegrationPointDataVector,
50 typename Accessor>
51std::vector<double> const& getIntegrationPointKelvinVectorData(
52 IntegrationPointDataVector const& ip_data, Accessor&& accessor,
53 std::vector<double>& cache)
54{
55 constexpr int kelvin_vector_size =
57 auto const n_integration_points = ip_data.size();
58
59 cache.clear();
60 auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix<
61 double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>(
62 cache, kelvin_vector_size, n_integration_points);
63
64 for (unsigned ip = 0; ip < n_integration_points; ++ip)
65 {
66 auto const& kelvin_vector = accessor(ip_data[ip]);
67 cache_mat.col(ip) =
69 }
70
71 return cache;
72}
73
74template <int DisplacementDim, typename IntegrationPointData,
75 typename MemberType>
77 std::vector<IntegrationPointData,
78 Eigen::aligned_allocator<IntegrationPointData>> const& ip_data,
79 MemberType member)
80{
81 constexpr int kelvin_vector_size =
83 auto const n_integration_points = ip_data.size();
84
85 std::vector<double> ip_kelvin_vector_values;
86 auto cache_mat = MathLib::createZeroedMatrix<Eigen::Matrix<
87 double, Eigen::Dynamic, kelvin_vector_size, Eigen::RowMajor>>(
88 ip_kelvin_vector_values, n_integration_points, kelvin_vector_size);
89
90 for (unsigned ip = 0; ip < n_integration_points; ++ip)
91 {
92 auto const& ip_member = ip_data[ip].*member;
93 cache_mat.row(ip) =
95 }
96
97 return ip_kelvin_vector_values;
98}
99
100template <int DisplacementDim, typename IntegrationPointDataVector,
101 typename IpData, typename MemberType>
103 double const* values,
104 IntegrationPointDataVector& ip_data,
105 MemberType IpData::*const member)
106{
107 constexpr int kelvin_vector_size =
109 auto const n_integration_points = ip_data.size();
110
111 auto kelvin_vector_values =
112 Eigen::Map<Eigen::Matrix<double, kelvin_vector_size, Eigen::Dynamic,
113 Eigen::ColMajor> const>(
114 values, kelvin_vector_size, n_integration_points);
115
116 for (unsigned ip = 0; ip < n_integration_points; ++ip)
117 {
118 ip_data[ip].*member =
120 kelvin_vector_values.col(ip));
121 }
122
123 return n_integration_points;
124}
125
126template <int DisplacementDim, typename IntegrationPointDataVector,
127 typename Accessor>
129 double const* values,
130 IntegrationPointDataVector& ip_data,
131 Accessor&& accessor)
132{
133 constexpr int kelvin_vector_size =
135 auto const n_integration_points = ip_data.size();
136
137 auto kelvin_vector_values =
138 Eigen::Map<Eigen::Matrix<double, kelvin_vector_size, Eigen::Dynamic,
139 Eigen::ColMajor> const>(
140 values, kelvin_vector_size, n_integration_points);
141
142 for (unsigned ip = 0; ip < n_integration_points; ++ip)
143 {
144 accessor(ip_data[ip]) =
146 kelvin_vector_values.col(ip));
147 }
148
149 return n_integration_points;
150}
151
152template <typename IntegrationPointDataVector, typename MemberType>
153std::vector<double> const& getIntegrationPointScalarData(
154 IntegrationPointDataVector const& ip_data, MemberType member,
155 std::vector<double>& cache)
156{
157 auto const n_integration_points = ip_data.size();
158
159 cache.clear();
160 auto cache_mat = MathLib::createZeroedMatrix<
161 Eigen::Matrix<double, 1, Eigen::Dynamic, Eigen::RowMajor>>(
162 cache, 1, n_integration_points);
163
164 for (unsigned ip = 0; ip < n_integration_points; ++ip)
165 {
166 cache_mat[ip] = ip_data[ip].*member;
167 }
168
169 return cache;
170}
171
172template <typename IntegrationPointDataVector, typename MemberType>
173std::size_t setIntegrationPointScalarData(double const* values,
174 IntegrationPointDataVector& ip_data,
175 MemberType member)
176{
177 auto const n_integration_points = ip_data.size();
178
179 for (unsigned ip = 0; ip < n_integration_points; ++ip)
180 {
181 ip_data[ip].*member = values[ip];
182 }
183 return n_integration_points;
184}
185
186template <typename IntegrationPointDataVector, typename MemberType,
187 typename MaterialStateVariables>
189 IntegrationPointDataVector const& ip_data_vector,
190 MemberType member,
191 std::function<BaseLib::DynamicSpan<double>(MaterialStateVariables&)>
192 get_values_span,
193 int const n_components)
194{
195 std::vector<double> result;
196 result.reserve(ip_data_vector.size() * n_components);
197
198 for (auto& ip_data : ip_data_vector)
199 {
200 auto const values_span = get_values_span(*(ip_data.*member));
201 assert(values_span.size() == static_cast<std::size_t>(n_components));
202
203 result.insert(end(result), values_span.begin(), values_span.end());
204 }
205
206 return result;
207}
208
209template <typename IntegrationPointDataVector, typename MemberType,
210 typename MaterialStateVariables>
212 double const* values,
213 IntegrationPointDataVector& ip_data_vector,
214 MemberType member,
215 std::function<BaseLib::DynamicSpan<double>(MaterialStateVariables&)>
216 get_values_span)
217{
218 auto const n_integration_points = ip_data_vector.size();
219
220 std::size_t position = 0;
221 for (auto& ip_data : ip_data_vector)
222 {
223 auto const values_span = get_values_span(*(ip_data.*member));
224 std::copy_n(values + position, values_span.size(), values_span.begin());
225 position += values_span.size();
226 }
227 return n_integration_points;
228}
229} // namespace ProcessLib
Eigen::Matrix< double, 4, 1 > kelvinVectorToSymmetricTensor(Eigen::Matrix< double, 4, 1, Eigen::ColMajor, 4, 1 > const &v)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
Eigen::Matrix< double, Eigen::MatrixBase< Derived >::RowsAtCompileTime, 1 > symmetricTensorToKelvinVector(Eigen::MatrixBase< Derived > const &v)
Definition: KelvinVector.h:170
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
Definition: EigenMapTools.h:32
std::size_t setIntegrationPointScalarData(double const *values, IntegrationPointDataVector &ip_data, MemberType member)
std::vector< double > getIntegrationPointDataMaterialStateVariables(IntegrationPointDataVector const &ip_data_vector, MemberType member, std::function< BaseLib::DynamicSpan< double >(MaterialStateVariables &)> get_values_span, int const n_components)
std::vector< double > const & getIntegrationPointKelvinVectorData(IntegrationPointDataVector const &ip_data, MemberType IpData::*const member, std::vector< double > &cache)
std::vector< double > const & getIntegrationPointScalarData(IntegrationPointDataVector const &ip_data, MemberType member, std::vector< double > &cache)
std::size_t setIntegrationPointKelvinVectorData(double const *values, IntegrationPointDataVector &ip_data, MemberType IpData::*const member)
std::size_t setIntegrationPointDataMaterialStateVariables(double const *values, IntegrationPointDataVector &ip_data_vector, MemberType member, std::function< BaseLib::DynamicSpan< double >(MaterialStateVariables &)> get_values_span)