v0.14.0
Public Member Functions | Private Attributes | List of all members
SimpleContactProblem::ConvectSlaveIntegrationPts Struct Reference

Class used to convect integration points on slave and master, and to calculate directional direvatives of change integration position point as variation os spatial positions on contact surfaces. More...

#include <users_modules/mortar_contact/src/SimpleContact.hpp>

Inheritance diagram for SimpleContactProblem::ConvectSlaveIntegrationPts:
[legend]
Collaboration diagram for SimpleContactProblem::ConvectSlaveIntegrationPts:
[legend]

Public Member Functions

 ConvectSlaveIntegrationPts (SimpleContactElement *const fe_ptr, string spat_pos, string mat_pos)
 
template<bool CONVECT_MASTER>
MoFEMErrorCode convectSlaveIntegrationPts ()
 
boost::shared_ptr< MatrixDouble > getDiffKsiSpatialMaster ()
 
boost::shared_ptr< MatrixDouble > getDiffKsiSpatialSlave ()
 

Private Attributes

SimpleContactElement *const fePtr
 
const string sparialPositionsField
 
const string materialPositionsField
 
VectorDouble spatialCoords
 
VectorDouble materialCoords
 
MatrixDouble slaveSpatialCoords
 
MatrixDouble slaveMaterialCoords
 
MatrixDouble masterSpatialCoords
 
MatrixDouble masterMaterialCoords
 
MatrixDouble slaveN
 
MatrixDouble masterN
 
MatrixDouble diffKsiMaster
 
MatrixDouble diffKsiSlave
 

Detailed Description

Class used to convect integration points on slave and master, and to calculate directional direvatives of change integration position point as variation os spatial positions on contact surfaces.

Definition at line 137 of file SimpleContact.hpp.

Constructor & Destructor Documentation

◆ ConvectSlaveIntegrationPts()

SimpleContactProblem::ConvectSlaveIntegrationPts::ConvectSlaveIntegrationPts ( SimpleContactElement *const  fe_ptr,
string  spat_pos,
string  mat_pos 
)
inline

Definition at line 140 of file SimpleContact.hpp.

142  : fePtr(fe_ptr), sparialPositionsField(spat_pos),
143  materialPositionsField(mat_pos) {}

Member Function Documentation

◆ convectSlaveIntegrationPts()

template<bool CONVECT_MASTER>
MoFEMErrorCode SimpleContactProblem::ConvectSlaveIntegrationPts::convectSlaveIntegrationPts ( )

Definition at line 56 of file SimpleContact.cpp.

56  {
58 
59  auto get_material_dofs_from_coords = [&]() {
61  materialCoords.resize(18, false);
62  int num_nodes;
63  const EntityHandle *conn;
64  CHKERR fePtr->mField.get_moab().get_connectivity(fePtr->getFEEntityHandle(),
65  conn, num_nodes, true);
66  CHKERR fePtr->mField.get_moab().get_coords(conn, 6,
67  &*materialCoords.data().begin());
68  CHKERR fePtr->getNodeData(materialPositionsField, materialCoords, false);
70  };
71 
72  auto get_dofs_data_for_slave_and_master = [&] {
73  slaveSpatialCoords.resize(3, 3, false);
74  slaveMaterialCoords.resize(3, 3, false);
75  masterSpatialCoords.resize(3, 3, false);
76  masterMaterialCoords.resize(3, 3, false);
77  for (size_t n = 0; n != 3; ++n) {
78  for (size_t d = 0; d != 3; ++d) {
80  slaveSpatialCoords(n, d) = spatialCoords(3 * (n + 3) + d);
82  slaveMaterialCoords(n, d) = materialCoords(3 * (n + 3) + d);
83  }
84  }
85  };
86 
87  auto calculate_shape_base_functions = [&](const int nb_gauss_pts) {
89  if (nb_gauss_pts != fePtr->gaussPtsMaster.size2())
90  SETERRQ2(
91  PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
92  "Inconsistent size of slave and master integration points (%d != %d)",
93  nb_gauss_pts, fePtr->gaussPtsMaster.size2());
94  slaveN.resize(nb_gauss_pts, 3, false);
95  masterN.resize(nb_gauss_pts, 3, false);
96  CHKERR Tools::shapeFunMBTRI(&slaveN(0, 0), &fePtr->gaussPtsSlave(0, 0),
97  &fePtr->gaussPtsSlave(1, 0), nb_gauss_pts);
98  CHKERR Tools::shapeFunMBTRI(&masterN(0, 0), &fePtr->gaussPtsMaster(0, 0),
99  &fePtr->gaussPtsMaster(1, 0), nb_gauss_pts);
101  };
102 
103  auto get_diff_ksi_master = [&]() -> MatrixDouble & {
104  if (CONVECT_MASTER)
105  return diffKsiMaster;
106  else
107  return diffKsiSlave;
108  };
109 
110  auto get_diff_ksi_slave = [&]() -> MatrixDouble & {
111  if (CONVECT_MASTER)
112  return diffKsiSlave;
113  else
114  return diffKsiMaster;
115  };
116 
117  auto get_slave_material_coords = [&]() -> MatrixDouble & {
118  if (CONVECT_MASTER)
119  return slaveMaterialCoords;
120  else
121  return masterMaterialCoords;
122  };
123 
124  auto get_master_gauss_pts = [&]() -> MatrixDouble & {
125  if (CONVECT_MASTER)
126  return fePtr->gaussPtsMaster;
127  else
128  return fePtr->gaussPtsSlave;
129  };
130 
131  auto get_slave_spatial_coords = [&]() -> MatrixDouble & {
132  if (CONVECT_MASTER)
133  return slaveSpatialCoords;
134  else
135  return masterSpatialCoords;
136  };
137 
138  auto get_master_spatial_coords = [&]() -> MatrixDouble & {
139  if (CONVECT_MASTER)
140  return masterSpatialCoords;
141  else
142  return slaveSpatialCoords;
143  };
144 
145  auto get_slave_n = [&]() -> MatrixDouble & {
146  if (CONVECT_MASTER)
147  return slaveN;
148  else
149  return masterN;
150  };
151 
152  auto get_master_n = [&]() -> MatrixDouble & {
153  if (CONVECT_MASTER)
154  return masterN;
155  else
156  return slaveN;
157  };
158 
159  auto convect_points = [get_diff_ksi_master, get_diff_ksi_slave,
160  get_slave_material_coords, get_master_gauss_pts,
161  get_slave_spatial_coords, get_master_spatial_coords,
162  get_slave_n, get_master_n](const int nb_gauss_pts) {
163  MatrixDouble3by3 A(2, 2);
164  MatrixDouble3by3 invA(2, 2);
165  VectorDouble3 F(2);
166  MatrixDouble3by3 inv_matA(2, 2);
167  VectorDouble3 copy_F(2);
168  FTensor::Tensor1<FTensor::PackPtr<double *, 0>, 2> t_copy_F(&copy_F[0],
169  &copy_F[1]);
171  &inv_matA(0, 0), &inv_matA(0, 1), &inv_matA(1, 0), &inv_matA(1, 1));
172 
173  auto get_t_coords = [](auto &m) {
175  &m(0, 0), &m(0, 1), &m(0, 2)};
176  };
177 
178  auto get_t_xi = [](auto &m) {
180  &m(1, 0)};
181  };
182 
183  auto get_t_diff = []() {
185  &Tools::diffShapeFunMBTRI[0], &Tools::diffShapeFunMBTRI[1]};
186  };
187 
188  auto get_t_tau = []() {
190  return t_tau;
191  };
192 
193  auto get_t_x = []() {
195  return t_x;
196  };
197 
198  auto get_t_F = [&]() {
200  };
201 
202  auto get_t_A = [&](auto &m) {
204  &m(0, 0), &m(0, 1), &m(1, 0), &m(1, 1)};
205  };
206 
207  auto get_diff_ksi = [](auto &m, const int gg) {
209  &m(0, gg), &m(1, gg), &m(2, gg), &m(3, gg), &m(4, gg), &m(5, gg));
210  };
211 
217 
218  get_diff_ksi_master().resize(6, 3 * nb_gauss_pts, false);
219  get_diff_ksi_slave().resize(6, 3 * nb_gauss_pts, false);
220 
221  auto t_xi_master = get_t_xi(get_master_gauss_pts());
222  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
223 
224  auto t_tau = get_t_tau();
225  auto t_x_slave = get_t_x();
226  auto t_x_master = get_t_x();
227  auto t_mat = get_t_A(A);
228  auto t_f = get_t_F();
229 
230  auto newton_solver = [&]() {
231  auto get_values = [&]() {
232  t_tau(i, I) = 0;
233  t_x_slave(i) = 0;
234  t_x_master(i) = 0;
235 
236  auto t_slave_material_coords =
237  get_t_coords(get_slave_material_coords());
238  auto t_slave_spatial_coords =
239  get_t_coords(get_slave_spatial_coords());
240  auto t_master_spatial_coords =
241  get_t_coords(get_master_spatial_coords());
242  double *slave_base = &get_slave_n()(gg, 0);
243  double *master_base = &get_master_n()(gg, 0);
244  auto t_diff = get_t_diff();
245  for (size_t n = 0; n != 3; ++n) {
246 
247  t_tau(i, J) += t_diff(J) * t_slave_material_coords(i);
248  t_x_slave(i) += (*slave_base) * t_slave_spatial_coords(i);
249  t_x_master(i) += (*master_base) * t_master_spatial_coords(i);
250 
251  ++t_diff;
252  ++t_slave_material_coords;
253  ++t_slave_spatial_coords;
254  ++t_master_spatial_coords;
255  ++slave_base;
256  ++master_base;
257  }
258  };
259 
260  auto assemble = [&]() {
261  t_mat(I, J) = 0;
262  auto t_master_spatial_coords =
263  get_t_coords(get_master_spatial_coords());
264  auto t_diff = get_t_diff();
265  for (size_t n = 0; n != 3; ++n) {
266  t_mat(I, J) += t_diff(J) * t_tau(i, I) * t_master_spatial_coords(i);
267  ++t_diff;
268  ++t_master_spatial_coords;
269  };
270  t_f(I) = t_tau(i, I) * (t_x_slave(i) - t_x_master(i));
271  };
272 
273  auto update = [&]() {
274  t_xi_master(I) += t_f(I);
275  get_master_n()(gg, 0) =
276  Tools::shapeFunMBTRI0(t_xi_master(0), t_xi_master(1));
277  get_master_n()(gg, 1) =
278  Tools::shapeFunMBTRI1(t_xi_master(0), t_xi_master(1));
279  get_master_n()(gg, 2) =
280  Tools::shapeFunMBTRI2(t_xi_master(0), t_xi_master(1));
281  };
282 
283  auto invert_2_by_2 = [&](MatrixDouble3by3 &inv_mat_A,
284  MatrixDouble3by3 &mat_A) {
285  double det_A;
286  CHKERR determinantTensor2by2(mat_A, det_A);
287  CHKERR invertTensor2by2(mat_A, det_A, inv_mat_A);
288  };
289 
290  auto linear_solver = [&]() {
291  invert_2_by_2(inv_matA, A);
292  t_copy_F(J) = t_f(J);
293  t_f(I) = t_inv_matA(I, J) * t_copy_F(J);
294  };
295 
296  auto invert_A = [&]() { invert_2_by_2(invA, A); };
297 
298  auto nonlinear_solve = [&]() {
299  constexpr double tol = 1e-12;
300  constexpr int max_it = 10;
301  int it = 0;
302  double eps;
303 
304  do {
305 
306  get_values();
307  assemble();
308  linear_solver();
309  update();
310 
311  eps = norm_2(F);
312 
313  } while (eps > tol && (it++) < max_it);
314  };
315 
316  nonlinear_solve();
317  get_values();
318  assemble();
319  invert_A();
320 
321  auto get_diff_slave = [&]() {
322  auto t_inv_A = get_t_A(invA);
323  auto t_diff_xi_slave = get_diff_ksi(get_diff_ksi_slave(), 3 * gg);
324  double *slave_base = &get_slave_n()(gg, 0);
325  for (size_t n = 0; n != 3; ++n) {
326  t_diff_xi_slave(I, i) = t_inv_A(I, J) * t_tau(i, J) * (*slave_base);
327  ++t_diff_xi_slave;
328  ++slave_base;
329  }
330  };
331 
332  auto get_diff_master = [&]() {
333  auto t_inv_A = get_t_A(invA);
334  auto t_diff_xi_master = get_diff_ksi(get_diff_ksi_master(), 3 * gg);
335  auto t_diff = get_t_diff();
336  double *master_base = &get_master_n()(gg, 0);
338  t_diff_A(I, J, K, L) = -t_inv_A(I, K) * t_inv_A(L, J);
339  for (size_t n = 0; n != 3; ++n) {
340  t_diff_xi_master(I, i) =
341  (t_diff_A(I, J, K, L) * (t_f(J) * t_diff(L))) * t_tau(i, K) -
342  t_inv_A(I, J) * t_tau(i, J) * (*master_base);
343  ++t_diff_xi_master;
344  ++master_base;
345  ++t_diff;
346  }
347  };
348 
349  get_diff_master();
350  get_diff_slave();
351  };
352 
353  newton_solver();
354 
355  ++t_xi_master;
356  }
357  };
358 
359  const int nb_gauss_pts = fePtr->gaussPtsSlave.size2();
361  CHKERR get_material_dofs_from_coords();
362  get_dofs_data_for_slave_and_master();
363  CHKERR calculate_shape_base_functions(nb_gauss_pts);
364  convect_points(nb_gauss_pts);
365 
367 }

◆ getDiffKsiSpatialMaster()

boost::shared_ptr<MatrixDouble> SimpleContactProblem::ConvectSlaveIntegrationPts::getDiffKsiSpatialMaster ( )
inline

Definition at line 147 of file SimpleContact.hpp.

147  {
148  return boost::shared_ptr<MatrixDouble>(shared_from_this(),
149  &diffKsiMaster);
150  }

◆ getDiffKsiSpatialSlave()

boost::shared_ptr<MatrixDouble> SimpleContactProblem::ConvectSlaveIntegrationPts::getDiffKsiSpatialSlave ( )
inline

Definition at line 152 of file SimpleContact.hpp.

152  {
153  return boost::shared_ptr<MatrixDouble>(shared_from_this(), &diffKsiSlave);
154  }

Member Data Documentation

◆ diffKsiMaster

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::diffKsiMaster
private

Definition at line 171 of file SimpleContact.hpp.

◆ diffKsiSlave

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::diffKsiSlave
private

Definition at line 172 of file SimpleContact.hpp.

◆ fePtr

SimpleContactElement* const SimpleContactProblem::ConvectSlaveIntegrationPts::fePtr
private

Definition at line 157 of file SimpleContact.hpp.

◆ masterMaterialCoords

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::masterMaterialCoords
private

Definition at line 167 of file SimpleContact.hpp.

◆ masterN

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::masterN
private

Definition at line 169 of file SimpleContact.hpp.

◆ masterSpatialCoords

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::masterSpatialCoords
private

Definition at line 166 of file SimpleContact.hpp.

◆ materialCoords

VectorDouble SimpleContactProblem::ConvectSlaveIntegrationPts::materialCoords
private

Definition at line 163 of file SimpleContact.hpp.

◆ materialPositionsField

const string SimpleContactProblem::ConvectSlaveIntegrationPts::materialPositionsField
private

Definition at line 160 of file SimpleContact.hpp.

◆ slaveMaterialCoords

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::slaveMaterialCoords
private

Definition at line 165 of file SimpleContact.hpp.

◆ slaveN

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::slaveN
private

Definition at line 168 of file SimpleContact.hpp.

◆ slaveSpatialCoords

MatrixDouble SimpleContactProblem::ConvectSlaveIntegrationPts::slaveSpatialCoords
private

Definition at line 164 of file SimpleContact.hpp.

◆ sparialPositionsField

const string SimpleContactProblem::ConvectSlaveIntegrationPts::sparialPositionsField
private

Definition at line 159 of file SimpleContact.hpp.

◆ spatialCoords

VectorDouble SimpleContactProblem::ConvectSlaveIntegrationPts::spatialCoords
private

Definition at line 162 of file SimpleContact.hpp.


The documentation for this struct was generated from the following files:
MoFEM::K
VectorDouble K
Definition: Projection10NodeCoordsOnField.cpp:125
SimpleContactProblem::ConvectSlaveIntegrationPts::slaveMaterialCoords
MatrixDouble slaveMaterialCoords
Definition: SimpleContact.hpp:165
MoFEM::Types::VectorDouble3
VectorBoundedArray< double, 3 > VectorDouble3
Definition: Types.hpp:92
sdf_hertz.d
float d
Definition: sdf_hertz.py:5
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
EntityHandle
SimpleContactProblem::ConvectSlaveIntegrationPts::diffKsiMaster
MatrixDouble diffKsiMaster
Definition: SimpleContact.hpp:171
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
SimpleContactProblem::ConvectSlaveIntegrationPts::sparialPositionsField
const string sparialPositionsField
Definition: SimpleContact.hpp:159
SimpleContactProblem::ConvectSlaveIntegrationPts::masterN
MatrixDouble masterN
Definition: SimpleContact.hpp:169
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
J
FTensor::Index< 'J', DIM1 > J
Definition: level_set.cpp:30
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
I
constexpr IntegrationType I
Definition: operators_tests.cpp:31
MoFEM::determinantTensor2by2
static auto determinantTensor2by2(T &t)
Calculate the determinant of a 2x2 matrix or a tensor of rank 2.
Definition: Templates.hpp:1524
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::invertTensor2by2
MoFEMErrorCode invertTensor2by2(T1 &t, T2 &det, T3 &inv_t)
Calculate matrix inverse 2 by 2.
Definition: Templates.hpp:1620
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
SimpleContactProblem::ConvectSlaveIntegrationPts::diffKsiSlave
MatrixDouble diffKsiSlave
Definition: SimpleContact.hpp:172
SimpleContactProblem::ConvectSlaveIntegrationPts::slaveSpatialCoords
MatrixDouble slaveSpatialCoords
Definition: SimpleContact.hpp:164
SimpleContactProblem::ConvectSlaveIntegrationPts::slaveN
MatrixDouble slaveN
Definition: SimpleContact.hpp:168
SimpleContactProblem::ConvectSlaveIntegrationPts::spatialCoords
VectorDouble spatialCoords
Definition: SimpleContact.hpp:162
MoFEM::L
VectorDouble L
Definition: Projection10NodeCoordsOnField.cpp:124
FTensor::Tensor4
Definition: Tensor4_value.hpp:18
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
convert.n
n
Definition: convert.py:82
SimpleContactProblem::SimpleContactElement::mField
MoFEM::Interface & mField
Definition: SimpleContact.hpp:78
SimpleContactProblem::ConvectSlaveIntegrationPts::masterMaterialCoords
MatrixDouble masterMaterialCoords
Definition: SimpleContact.hpp:167
SimpleContactProblem::ConvectSlaveIntegrationPts::masterSpatialCoords
MatrixDouble masterSpatialCoords
Definition: SimpleContact.hpp:166
eps
static const double eps
Definition: check_base_functions_derivatives_on_tet.cpp:11
SimpleContactProblem::ConvectSlaveIntegrationPts::fePtr
SimpleContactElement *const fePtr
Definition: SimpleContact.hpp:157
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::Types::MatrixDouble3by3
MatrixBoundedArray< double, 9 > MatrixDouble3by3
Definition: Types.hpp:105
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
SimpleContactProblem::ConvectSlaveIntegrationPts::materialPositionsField
const string materialPositionsField
Definition: SimpleContact.hpp:160
SimpleContactProblem::ConvectSlaveIntegrationPts::materialCoords
VectorDouble materialCoords
Definition: SimpleContact.hpp:163
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
tol
double tol
Definition: mesh_smoothing.cpp:27
F
@ F
Definition: free_surface.cpp:394