v0.14.0
PlasticOpsSmallStrains.hpp
Go to the documentation of this file.
1 
2 
3 /** \file PlasticOpsSmallStrains.hpp
4  * \example PlasticOpsSmallStrains.hpp
5  */
6 
7 namespace PlasticOps {
8 
9 template <int DIM, typename AssemblyDomainEleOp>
12  : public AssemblyDomainEleOp {
14  const std::string row_field_name, const std::string col_field_name,
15  boost::shared_ptr<CommonData> common_data_ptr,
16  boost::shared_ptr<MatrixDouble> m_D_ptr);
17  MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
18  EntitiesFieldData::EntData &col_data);
19 
20 private:
21  boost::shared_ptr<CommonData> commonDataPtr;
22  boost::shared_ptr<MatrixDouble> mDPtr;
23 };
24 
25 template <int DIM, typename AssemblyDomainEleOp>
28  const std::string row_field_name, const std::string col_field_name,
29  boost::shared_ptr<CommonData> common_data_ptr,
30  boost::shared_ptr<MatrixDouble> m_D_ptr)
31  : AssemblyDomainEleOp(row_field_name, col_field_name,
32  AssemblyDomainEleOp::OPROWCOL),
33  commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
34  AssemblyDomainEleOp::sYmm = false;
35 }
36 
40  &mat(2 * rr + 0, 0), &mat(2 * rr + 0, 1), &mat(2 * rr + 0, 2),
41  &mat(2 * rr + 1, 0), &mat(2 * rr + 1, 1), &mat(2 * rr + 1, 2)};
42 }
43 
47  &mat(3 * rr + 0, 0), &mat(3 * rr + 0, 1), &mat(3 * rr + 0, 2),
48  &mat(3 * rr + 0, 3), &mat(3 * rr + 0, 4), &mat(3 * rr + 0, 5),
49 
50  &mat(3 * rr + 1, 0), &mat(3 * rr + 1, 1), &mat(3 * rr + 1, 2),
51  &mat(3 * rr + 1, 3), &mat(3 * rr + 1, 4), &mat(3 * rr + 1, 5),
52 
53  &mat(3 * rr + 2, 0), &mat(3 * rr + 2, 1), &mat(3 * rr + 2, 2),
54  &mat(3 * rr + 2, 3), &mat(3 * rr + 2, 4), &mat(3 * rr + 2, 5)};
55 }
56 
57 template <int DIM, typename AssemblyDomainEleOp>
59 OpCalculatePlasticInternalForceLhs_dEPImpl<DIM, GAUSS, AssemblyDomainEleOp>::
60  iNtegrate(EntitiesFieldData::EntData &row_data,
61  EntitiesFieldData::EntData &col_data) {
63 
68  constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
70 
71  auto &locMat = AssemblyDomainEleOp::locMat;
72 
73  const size_t nb_integration_pts = row_data.getN().size1();
74  const size_t nb_row_base_functions = row_data.getN().size2();
75 
76  auto t_D = getFTensor4DdgFromMat<DIM, DIM, 0>(*mDPtr);
77  auto t_L = symm_L_tensor(FTensor::Number<DIM>());
78 
80  t_DL(i, j, L) = t_D(i, j, k, l) * t_L(k, l, L);
81 
82  auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
83  auto t_row_diff_base = row_data.getFTensor1DiffN<DIM>();
84  for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
85  double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
86  ++t_w;
87 
88  size_t rr = 0;
89  for (; rr != AssemblyDomainEleOp::nbRows / DIM; ++rr) {
90 
91  auto t_mat =
93 
95  t_tmp(i, L) = (t_DL(i, j, L)) * (alpha * t_row_diff_base(j));
96 
97  auto t_col_base = col_data.getFTensor0N(gg, 0);
98  for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / size_symm; ++cc) {
99 
100  t_mat(i, L) -= (t_col_base * t_tmp(i, L));
101 
102  ++t_mat;
103  ++t_col_base;
104  }
105 
106  ++t_row_diff_base;
107  }
108 
109  for (; rr < nb_row_base_functions; ++rr)
110  ++t_row_diff_base;
111  }
112 
114 }
115 
116 template <int DIM, typename AssemblyDomainEleOp>
118  : public AssemblyDomainEleOp {
120  const std::string row_field_name, const std::string col_field_name,
121  boost::shared_ptr<CommonData> common_data_ptr,
122  boost::shared_ptr<MatrixDouble> m_D_ptr);
123  MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data,
124  EntitiesFieldData::EntData &col_data);
125 
126 private:
127  boost::shared_ptr<CommonData> commonDataPtr;
128  boost::shared_ptr<MatrixDouble> mDPtr;
129 };
130 
131 template <int DIM, typename AssemblyDomainEleOp>
134  const std::string row_field_name, const std::string col_field_name,
135  boost::shared_ptr<CommonData> common_data_ptr,
136  boost::shared_ptr<MatrixDouble> m_D_ptr)
137  : AssemblyDomainEleOp(row_field_name, col_field_name,
138  AssemblyDomainEleOp::OPROWCOL),
139  commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
140  AssemblyDomainEleOp::sYmm = false;
141 }
142 
143 template <int DIM, typename AssemblyDomainEleOp>
146  EntitiesFieldData::EntData &row_data,
147  EntitiesFieldData::EntData &col_data) {
149 
156 
157  constexpr auto size_symm = (DIM * (DIM + 1)) / 2;
159 
160  auto &locMat = AssemblyDomainEleOp::locMat;
161 
162  const size_t nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
163  const size_t nb_row_base_functions = row_data.getN().size2();
164 
165  auto t_res_flow_dstrain =
166  getFTensor4DdgFromMat<DIM, DIM>(commonDataPtr->resFlowDstrain);
167 
168  auto next = [&]() { ++t_res_flow_dstrain; };
169 
170  auto t_L = symm_L_tensor(FTensor::Number<DIM>());
171  constexpr auto t_kd = FTensor::Kronecker_Delta<int>();
173  t_diff_grad(i, j, k, l) = t_kd(i, k) * t_kd(j, l);
174 
175  auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
176  auto t_row_base = row_data.getFTensor0N();
177  for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
178 
179  double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
180  ++t_w;
182  t_res_tens(L, i, j) =
183  alpha * ((t_L(m, n, L) * (t_res_flow_dstrain(m, n, k, l))) *
184  t_diff_grad(k, l, i, j));
185  next();
186 
187  size_t rr = 0;
188  for (; rr != AssemblyDomainEleOp::nbRows / size_symm; ++rr) {
189  auto t_mat =
191  auto t_col_diff_base = col_data.getFTensor1DiffN<DIM>(gg, 0);
192  for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / DIM; ++cc) {
193  t_mat(L, l) += t_row_base * (t_res_tens(L, l, k) * t_col_diff_base(k));
194  ++t_mat;
195  ++t_col_diff_base;
196  }
197  ++t_row_base;
198  }
199 
200  for (; rr < nb_row_base_functions; ++rr)
201  ++t_row_base;
202  }
203 
205 }
206 
207 template <int DIM, typename AssemblyDomainEleOp>
210  const std::string row_field_name, const std::string col_field_name,
211  boost::shared_ptr<CommonData> common_data_ptr,
212  boost::shared_ptr<MatrixDouble> m_D_ptr)
213  : AssemblyDomainEleOp(row_field_name, col_field_name,
214  DomainEleOp::OPROWCOL),
215  commonDataPtr(common_data_ptr), mDPtr(m_D_ptr) {
216  AssemblyDomainEleOp::sYmm = false;
217 }
218 
219 template <int DIM, typename AssemblyDomainEleOp>
222  EntitiesFieldData::EntData &row_data,
223  EntitiesFieldData::EntData &col_data) {
225 
230 
231  auto &locMat = AssemblyDomainEleOp::locMat;
232 
233  const auto nb_integration_pts = AssemblyDomainEleOp::getGaussPts().size2();
234  const auto nb_row_base_functions = row_data.getN().size2();
235 
236  auto t_c_dstrain =
237  getFTensor2SymmetricFromMat<DIM>(commonDataPtr->resCdStrain);
238  auto t_diff_grad_symmetrise = diff_symmetrize(FTensor::Number<DIM>());
239 
240  auto next = [&]() { ++t_c_dstrain; };
241 
242  auto get_mat_scalar_dvector = [&]() {
243  if constexpr (DIM == 2)
244  return FTensor::Tensor1<FTensor::PackPtr<double *, 2>, 2>{&locMat(0, 0),
245  &locMat(0, 1)};
246  else
248  &locMat(0, 0), &locMat(0, 1), &locMat(0, 2)};
249  };
250 
251  auto t_w = AssemblyDomainEleOp::getFTensor0IntegrationWeight();
252  auto t_row_base = row_data.getFTensor0N();
253  for (auto gg = 0; gg != nb_integration_pts; ++gg) {
254  double alpha = AssemblyDomainEleOp::getMeasure() * t_w;
255  ++t_w;
256 
258  t_res_mat(i, j) =
259  ((t_c_dstrain(k, l)) * t_diff_grad_symmetrise(k, l, i, j));
260  next();
261 
262  auto t_mat = get_mat_scalar_dvector();
263  size_t rr = 0;
264  for (; rr != AssemblyDomainEleOp::nbRows; ++rr) {
265  const double row_base = alpha * t_row_base;
266  auto t_col_diff_base = col_data.getFTensor1DiffN<DIM>(gg, 0);
267  for (size_t cc = 0; cc != AssemblyDomainEleOp::nbCols / DIM; cc++) {
268  t_mat(i) += row_base * (t_res_mat(i, j) * t_col_diff_base(j));
269  ++t_mat;
270  ++t_col_diff_base;
271  }
272  ++t_row_base;
273  }
274  for (; rr != nb_row_base_functions; ++rr)
275  ++t_row_base;
276  }
277 
279 }
280 
281 }; // namespace PlasticOps
PlasticOps::OpCalculatePlasticFlowLhs_dUImpl< DIM, GAUSS, AssemblyDomainEleOp >::mDPtr
boost::shared_ptr< MatrixDouble > mDPtr
Definition: PlasticOpsSmallStrains.hpp:128
MoFEM::OpBaseImpl::locMat
MatrixDouble locMat
local entity block matrix
Definition: FormsIntegrators.hpp:249
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
PlasticOps::OpCalculatePlasticFlowLhs_dUImpl< DIM, GAUSS, AssemblyDomainEleOp >::commonDataPtr
boost::shared_ptr< CommonData > commonDataPtr
Definition: PlasticOpsSmallStrains.hpp:127
PlasticOps::OpCalculatePlasticInternalForceLhs_dEPImpl< DIM, GAUSS, AssemblyDomainEleOp >::mDPtr
boost::shared_ptr< MatrixDouble > mDPtr
Definition: PlasticOpsSmallStrains.hpp:22
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
FTensor::Kronecker_Delta
Kronecker Delta class.
Definition: Kronecker_Delta.hpp:15
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
MoFEM::OpBaseImpl
Definition: FormsIntegrators.hpp:178
FTensor::Number< 2 >
FTensor::Tensor3
Definition: Tensor3_value.hpp:12
PlasticOps::OpCalculatePlasticInternalForceLhs_dEPImpl< DIM, GAUSS, AssemblyDomainEleOp >::commonDataPtr
boost::shared_ptr< CommonData > commonDataPtr
Definition: PlasticOpsSmallStrains.hpp:21
MoFEM::GAUSS
@ GAUSS
Definition: FormsIntegrators.hpp:136
PlasticOps::OpCalculatePlasticFlowLhs_dUImpl
Definition: PlasticOps.hpp:142
MoFEM::L
VectorDouble L
Definition: Projection10NodeCoordsOnField.cpp:124
PlasticOps::get_mat_tensor_sym_dvector
static auto get_mat_tensor_sym_dvector(size_t rr, MatrixDouble &mat, FTensor::Number< 2 >)
[Lambda functions]
Definition: PlasticOpsGeneric.hpp:366
FTensor::Tensor4
Definition: Tensor4_value.hpp:18
size_symm
constexpr auto size_symm
Definition: plastic.cpp:42
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
t_kd
constexpr auto t_kd
Definition: free_surface.cpp:137
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
FTensor::Index< 'i', DIM >
convert.n
n
Definition: convert.py:82
MoFEM::OpBaseImpl::nbCols
int nbCols
number if dof on column
Definition: FormsIntegrators.hpp:237
DomainEleOp
PlasticOps
Definition: PlasticNaturalBCs.hpp:13
MoFEM::OpBaseImpl::nbRows
int nbRows
number of dofs on rows
Definition: FormsIntegrators.hpp:236
FTensor::Dg
Definition: Dg_value.hpp:9
PlasticOps::symm_L_tensor
auto symm_L_tensor(FTensor::Number< DIM >)
Definition: PlasticOpsGeneric.hpp:21
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
PlasticOps::diff_symmetrize
auto diff_symmetrize(FTensor::Number< DIM >)
Definition: PlasticOpsGeneric.hpp:43
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
PlasticOps::get_mat_vector_dtensor_sym
static FTensor::Tensor2< FTensor::PackPtr< double *, 3 >, 2, 3 > get_mat_vector_dtensor_sym(size_t rr, MatrixDouble &mat, FTensor::Number< 2 >)
Definition: PlasticOpsSmallStrains.hpp:38
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
PlasticOps::OpCalculatePlasticInternalForceLhs_dEPImpl
Definition: PlasticOps.hpp:136
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
PlasticOps::OpCalculateConstraintsLhs_dUImpl
Definition: PlasticOps.hpp:154