795 {
797
799
803
806
807 auto &locMat = AssemblyBoundaryEleOp::locMat;
808 locMat.resize(nb_rows, nb_cols, false);
809 locMat.clear();
810
811 if (nb_cols && nb_rows) {
812
813 auto nb_gauss_pts = getGaussPts().size2();
814 auto t_w = getFTensor0IntegrationWeight();
815 auto t_coords = getFTensor1CoordsAtGaussPts();
816 auto t_disp = getFTensor1FromMat<3>(
commonDataPtr->contactDisp);
817 auto t_traction = getFTensor1FromMat<3>(
commonDataPtr->contactTraction);
818
819
820 auto [block_id, m_normals_at_pts, v_sdf, m_grad_sdf, m_hess_sdf] =
823
825 auto t_grad_sdf_v = getFTensor1FromMat<3>(m_grad_sdf);
826 auto t_hess_sdf_v = getFTensor2SymmetricFromMat<3>(m_hess_sdf);
827 auto t_normalized_normal = getFTensor1FromMat<3>(m_normals_at_pts);
828
829 auto next = [&]() {
830 ++t_w;
831 ++t_coords;
832 ++t_disp;
833 ++t_traction;
834 ++t_sdf_v;
835 ++t_grad_sdf_v;
836 ++t_hess_sdf_v;
837 ++t_normalized_normal;
838 };
839
840 auto face_data_vec_ptr =
842 auto face_gauss_pts_it = face_data_vec_ptr->begin();
843
845 auto nb_face_functions = row_data.
getN().size2() / 3;
847
848 for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
849
850 auto face_data_ptr =
contactTreePtr->getFaceDataPtr(face_gauss_pts_it, gg,
851 face_data_vec_ptr);
852
853 auto check_face_contact = [&]() {
855 return false;
856
857 if (face_data_ptr) {
858 return true;
859 }
860 return false;
861 };
862
864
865#ifdef ENABLE_PYTHON_BINDING
867 if (ContactOps::sdfPythonWeakPtr.lock()) {
868 auto tn = t_traction(
i) * t_grad_sdf_v(
i);
870 }
871#else
872 constexpr double c = 0;
873#endif
874
875 if (!
c && check_face_contact()) {
877 t_spatial_coords(
i) = t_coords(
i) + t_disp(
i);
878 constexpr double eps = std::numeric_limits<float>::epsilon();
879 for (auto ii = 0; ii < 3; ++ii) {
881 t_spatial_coords(0), t_spatial_coords(1), t_spatial_coords(2)};
882 t_spatial_coords_cx(ii) +=
eps * 1
i;
883 auto t_rhs_tmp =
886 for (int jj = 0; jj != 3; ++jj) {
887 auto v = t_rhs_tmp(jj).imag();
888 t_res_dU(jj, ii) =
v /
eps;
889 }
890 }
891
892 } else {
893
894#ifdef ENABLE_PYTHON_BINDING
895
896 if (ContactOps::sdfPythonWeakPtr.lock()) {
899
900 (-
c) * (t_hess_sdf_v(
i,
j) * t_grad_sdf_v(
k) * t_traction(
k) +
901 t_grad_sdf_v(
i) * t_hess_sdf_v(
k,
j) * t_traction(
k))
902
903 + (
c * inv_cn) * (t_sdf_v * t_hess_sdf_v(
i,
j) +
904
905 t_grad_sdf_v(
j) * t_grad_sdf_v(
i));
906 } else {
908 }
909#else
911#endif
912 }
913
914 auto alpha = t_w * getMeasure();
915
916 size_t rr = 0;
917 for (; rr != nb_rows / 3; ++rr) {
918
919 auto t_mat = getFTensor2FromArray<3, 3, 3>(locMat, 3 * rr);
921
922 for (size_t cc = 0; cc != nb_cols / 3; ++cc) {
923 auto beta = alpha * t_row_base * t_col_base;
924 t_mat(
i,
j) -= beta * t_res_dU(
i,
j);
925 ++t_col_base;
926 ++t_mat;
927 }
928
929 ++t_row_base;
930 }
931 for (; rr < nb_face_functions; ++rr)
932 ++t_row_base;
933
934 next();
935 }
936 }
937
939}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#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)
const double v
phase velocity of light in medium (cm/ns)
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)
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorInt & getIndices() const
Get global indices of degrees of freedom on entity.