346 {
348
353
354 const size_t nb_gauss_pts = getGaussPts().size2();
355
356#ifndef NDEBUG
359 "Wrong number of integration pts %ld != %ld",
361 }
362#endif
363
364 auto &nf = locF;
365 locF.clear();
366
367 auto t_w = getFTensor0IntegrationWeight();
368 auto t_coords = getFTensor1CoordsAtGaussPts();
369 auto t_disp = getFTensor1FromMat<3>(
commonDataPtr->contactDisp);
370 auto t_traction = getFTensor1FromMat<3>(
commonDataPtr->contactTraction);
371
372
373
374
375 auto [block_id, m_normals_at_pts, v_sdf, m_grad_sdf, m_hess_sdf] =
378
379 auto t_sdf_v = getFTensor0FromVec(v_sdf);
380 auto t_grad_sdf_v = getFTensor1FromMat<3>(m_grad_sdf);
381 auto t_normalize_normal = getFTensor1FromMat<3>(m_normals_at_pts);
382
383 auto next = [&]() {
384 ++t_w;
385 ++t_coords;
386 ++t_disp;
387 ++t_traction;
388 ++t_normalize_normal;
389 ++t_sdf_v;
390 ++t_grad_sdf_v;
391 };
392
393 auto face_data_vec_ptr =
395 auto face_gauss_pts_it = face_data_vec_ptr->begin();
396
397 auto nb_base_functions = data.getN().size2();
398 auto t_base = data.getFTensor0N();
399 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
400
402 auto face_data_ptr =
contactTreePtr->getFaceDataPtr(face_gauss_pts_it, gg,
403 face_data_vec_ptr);
404
405 auto check_face_contact = [&]() {
406
408 return false;
409
410 if (face_data_ptr) {
411 return true;
412 }
413 return false;
414 };
415
416#ifdef ENABLE_PYTHON_BINDING
418 if (ContactOps::sdfPythonWeakPtr.lock()) {
419 auto tn = t_traction(
i) * t_grad_sdf_v(
i);
421 }
422#else
423 constexpr double c = 0;
424#endif
425
426 if (!
c && check_face_contact()) {
428 t_spatial_coords(
i) = t_coords(
i) + t_disp(
i);
429 auto t_rhs_tmp =
430 multiPointRhs(face_data_ptr, t_coords, t_spatial_coords, t_traction,
432 t_rhs(
i) = t_rhs_tmp(
i);
433
434 } else {
435
436#ifdef ENABLE_PYTHON_BINDING
438
439 if (ContactOps::sdfPythonWeakPtr.lock()) {
441 t_cP(
i,
j) = (
c * t_grad_sdf_v(
i)) * t_grad_sdf_v(
j);
443 t_rhs(
i) = t_cQ(
i,
j) * t_traction(
j) +
444 (
c * inv_cn * t_sdf_v) * t_grad_sdf_v(
i);
445 } else {
446 t_rhs(
i) = t_traction(
i);
447 }
448#else
449 t_rhs(
i) = t_traction(
i);
450#endif
451 }
452
453 auto t_nf = getFTensor1FromPtr<3>(&nf[0]);
454 const double alpha = t_w * getMeasure();
455
456 size_t bb = 0;
457 for (; bb != nbRows / 3; ++bb) {
458 const double beta = alpha * t_base;
459 t_nf(
i) -= beta * t_rhs(
i);
460 ++t_nf;
461 ++t_base;
462 }
463 for (; bb < nb_base_functions; ++bb)
464 ++t_base;
465
466 next();
467 }
468
470}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
auto checkSdf(EntityHandle fe_ent, std::map< int, Range > &sdf_map_range)
auto multiPointRhs(ContactTree::FaceData *face_data_ptr, FTensor::Tensor1< T1, 3 > &t_coords, FTensor::Tensor1< T2, 3 > &t_spatial_coords, FTensor::Tensor1< T3, 3 > &t_master_traction, MultiPointRhsType type, bool debug=false)
auto getSdf(OP_PTR op_ptr, MatrixDouble &contact_disp, int block_id, bool eval_hessian)
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > kronecker_delta(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
Rank 2.