9 #include <MethodForForceScaling.hpp>
16 double *N_face,
double *N_edge[],
17 double *
t,
double *t_edge[],
18 double *t_face,
double *traction,
int gg);
20 int order,
int *order_edge,
double *
N,
double *N_face,
double *N_edge[],
21 double *diffN,
double *diffN_face,
double *diffN_edge[],
double *
t,
22 double *t_edge[],
double *t_face,
double *dofs_x,
double *dofs_x_edge[],
23 double *dofs_x_face,
double *idofs_x,
double *idofs_x_edge[],
24 double *idofs_x_face,
double *Fext,
double *Fext_egde[],
double *Fext_face,
25 double *iFext,
double *iFext_egde[],
double *iFext_face,
int g_dim,
28 double eps,
int order,
int *order_edge,
double *
N,
double *N_face,
29 double *N_edge[],
double *diffN,
double *diffN_face,
double *diffN_edge[],
30 double *
t,
double *t_edge[],
double *t_face,
double *dofs_x,
31 double *dofs_x_edge[],
double *dofs_x_face,
double *KExt_hh,
32 double *KExt_egdeh[3],
double *KExt_faceh,
int g_dim,
const double *g_w);
34 double eps,
int order,
int *order_edge,
double *
N,
double *N_face,
35 double *N_edge[],
double *diffN,
double *diffN_face,
double *diffN_edge[],
36 double *
t,
double *t_edge[],
double *t_face,
double *dofs_x,
37 double *dofs_x_edge[],
double *dofs_x_face,
double *Khext_edge[3],
38 double *KExt_edgeegde[3][3],
double *KExt_faceedge[3],
int g_dim,
42 double *N_face,
double *N_edge[],
double *diffN,
43 double *diffN_face,
double *diffN_edge[],
double *
t,
44 double *t_edge[],
double *t_face,
double *dofs_x,
45 double *dofs_x_edge[],
double *dofs_x_face,
46 double *KExt_hface,
double *KExt_egdeface[3],
47 double *KExt_faceface,
int g_dim,
const double *g_w);
50 double circumcenter[3],
double *xi,
double *
eta,
53 double circumcenter[3],
double *xi,
double *
eta);
73 SETERRQ2(PETSC_COMM_SELF, 1,
74 "it should be 9 dofs on vertices but is %d of field < %s >",
77 myPtr->N = &*data.
getN().data().begin();
78 myPtr->diffN = &*data.
getDiffN().data().begin();
81 myPtr->dofs_x = &*myPtr->dOfs_x.data().begin();
82 myPtr->dOfs_x_indices.resize(data.
getIndices().size());
83 ublas::noalias(myPtr->dOfs_x_indices) = data.
getIndices();
84 myPtr->dofs_x_indices = &*myPtr->dOfs_x_indices.data().begin();
87 myPtr->order_edge[side] = data.
getOrder();
88 myPtr->N_edge[side] = &*data.
getN().data().begin();
89 myPtr->diffN_edge[side] = &*data.
getDiffN().data().begin();
90 myPtr->dOfs_x_edge.resize(3);
91 myPtr->dOfs_x_edge[side].resize(data.
getFieldData().size());
92 myPtr->dofs_x_edge[side] = &*myPtr->dOfs_x_edge[side].data().begin();
93 myPtr->dOfs_x_edge_indices.resize(3);
94 myPtr->dOfs_x_edge_indices[side].resize(data.
getIndices().size());
95 ublas::noalias(myPtr->dOfs_x_edge_indices[side]) = data.
getIndices();
96 myPtr->dofs_x_edge_indices[side] =
97 &*myPtr->dOfs_x_edge_indices[side].data().begin();
100 myPtr->order_face = data.
getOrder();
101 myPtr->N_face = &*data.
getN().data().begin();
102 myPtr->diffN_face = &*data.
getDiffN().data().begin();
104 ublas::noalias(myPtr->dOfs_x_face) = data.
getFieldData();
105 myPtr->dofs_x_face = &*myPtr->dOfs_x_face.data().begin();
106 myPtr->dOfs_x_face_indices.resize(data.
getIndices().size());
107 ublas::noalias(myPtr->dOfs_x_face_indices) = data.
getIndices();
108 myPtr->dofs_x_face_indices = &*myPtr->dOfs_x_face_indices.data().begin();
111 SETERRQ(PETSC_COMM_SELF, 1,
"unknown entity type");
125 "it should be 9 dofs on vertices but is %d",
128 if (data.
getN().size2() != 3) {
130 "it should 3 shape functions for 3 nodes");
132 myPtr->N = &*data.
getN().data().begin();
133 myPtr->diffN = &*data.
getDiffN().data().begin();
134 myPtr->dOfs_X_indices.resize(data.
getIndices().size());
135 ublas::noalias(myPtr->dOfs_X_indices) = data.
getIndices();
136 myPtr->dofs_X_indices = &*myPtr->dOfs_X_indices.data().begin();
139 myPtr->dofs_X = &*myPtr->dOfs_X.data().begin();
142 myPtr->order_edge_material[side] = data.
getOrder();
143 myPtr->dOfs_X_edge.resize(3);
144 myPtr->dOfs_X_edge[side].resize(data.
getFieldData().size());
145 ublas::noalias(myPtr->dOfs_X_edge[side]) = data.
getFieldData();
146 myPtr->dofs_X_edge[side] = &*myPtr->dOfs_X_edge[side].data().begin();
149 myPtr->order_face_material = data.
getOrder();
151 ublas::noalias(myPtr->dOfs_X_face) = data.
getFieldData();
152 myPtr->dofs_X_face = &*myPtr->dOfs_X_face.data().begin();
155 SETERRQ(PETSC_COMM_SELF, 1,
"unknown entity type");
163 double *scale_rhs, std::string spatial_field_name,
164 std::string mat_field_name)
166 sCaleRhs(scale_rhs), typeOfForces(CONSERVATIVE),
eps(1e-8), uSeF(false) {
179 mat_field_name,
this, ForcesAndSourcesCore::UserDataOperator::OPROW));
182 spatial_field_name,
this, ForcesAndSourcesCore::UserDataOperator::OPROW));
188 auto &dataH1 = *dataOnElement[
H1];
191 fExtFace.resize(dataH1.dataOnEntities[MBTRI][0].getFieldData().size());
193 for (
int ee = 0; ee < 3; ee++) {
194 int nb_edge_dofs = dOfs_x_edge_indices[ee].size();
195 if (nb_edge_dofs > 0) {
196 fExtEdge[ee].resize(nb_edge_dofs);
197 Fext_edge[ee] = &*fExtEdge[ee].data().begin();
199 Fext_edge[ee] = NULL;
203 switch (typeOfForces) {
206 order_face, order_edge,
207 N, N_face, N_edge, diffN, diffN_face, diffN_edge,
209 dofs_x, dofs_x_edge, dofs_x_face,
211 &*fExtNode.data().begin(), Fext_edge, &*fExtFace.data().begin(),
213 gaussPts.size2(), &gaussPts(2, 0));
215 case NONCONSERVATIVE:
216 for (
int ee = 0; ee < 3; ee++) {
217 dOfs_X_edge.resize(3);
218 unsigned int s = dOfs_X_edge[ee].size();
219 dOfs_X_edge[ee].resize(dOfs_x_edge[ee].size(),
true);
220 for (; s < dOfs_X_edge[ee].size(); s++) {
221 dOfs_X_edge[ee][s] = 0;
223 dofs_X_edge[ee] = &*dOfs_X_edge[ee].data().begin();
225 unsigned int s = dOfs_X_face.size();
226 dOfs_X_face.resize(dOfs_x_face.size(),
true);
227 for (; s < dOfs_X_face.size(); s++) {
230 dofs_X_face = &*dOfs_X_face.data().begin();
233 order_face, order_edge,
234 N, N_face, N_edge, diffN, diffN_face, diffN_edge,
236 dofs_X, dofs_X_edge, dofs_X_face,
238 &*fExtNode.data().begin(), Fext_edge, &*fExtFace.data().begin(),
240 gaussPts.size2(), &gaussPts(2, 0));
250 if (dOfs_x_face_indices.size() > 0) {
252 &*fExtFace.data().begin(), ADD_VALUES);
254 for (
int ee = 0; ee < 3; ee++) {
255 if (dOfs_x_edge_indices[ee].size() > 0) {
257 dofs_x_edge_indices[ee], Fext_edge[ee], ADD_VALUES);
267 if (typeOfForces == NONCONSERVATIVE) {
271 auto &dataH1 = *dataOnElement[
H1];
276 cblas_daxpy(3, -1, &coords.data()[0], 1, center, 1);
277 double r = cblas_dnrm2(3, center, 1);
279 kExtNodeNode.resize(9, 9);
280 kExtEdgeNode.resize(3);
281 for (
int ee = 0; ee < 3; ee++) {
282 kExtEdgeNode[ee].resize(dOfs_x_edge_indices[ee].size(), 9);
283 Kext_edge_node[ee] = &*kExtEdgeNode[ee].data().begin();
285 kExtFaceNode.resize(dOfs_x_face_indices.size(), 9);
287 r *
eps, order_face, order_edge,
N, N_face, N_edge, diffN, diffN_face,
288 diffN_edge, t_loc, NULL, NULL, dofs_x, dofs_x_edge, dofs_x_face,
289 &*kExtNodeNode.data().begin(), Kext_edge_node,
290 &*kExtFaceNode.data().begin(), gaussPts.size2(), &gaussPts(2, 0));
293 &*kExtNodeNode.data().begin(), ADD_VALUES);
295 dofs_x_indices, &*kExtFaceNode.data().begin(),
298 for (
int ee = 0; ee < 3; ee++) {
301 dofs_x_edge_indices[ee], 9, dofs_x_indices,
302 Kext_edge_node[ee], ADD_VALUES);
305 kExtNodeFace.resize(9, dOfs_x_face_indices.size());
306 kExtEdgeFace.resize(3);
307 for (
int ee = 0; ee < 3; ee++) {
308 kExtEdgeFace[ee].resize(
309 dOfs_x_edge_indices[ee].size(),
310 dataH1.dataOnEntities[MBTRI][0].getIndices().size());
311 Kext_edge_face[ee] = &*kExtEdgeFace[ee].data().begin();
313 kExtFaceFace.resize(dOfs_x_face_indices.size(), dOfs_x_face_indices.size());
315 r *
eps, order_face, order_edge,
N, N_face, N_edge, diffN, diffN_face,
316 diffN_edge, t_loc, NULL, NULL, dofs_x, dofs_x_edge, dofs_x_face,
317 &*kExtNodeFace.data().begin(), Kext_edge_face,
318 &*kExtFaceFace.data().begin(), gaussPts.size2(), &gaussPts(2, 0));
322 dofs_x_face_indices, &*kExtNodeFace.data().begin(),
325 kExtFaceFace.size2(), dofs_x_face_indices,
326 &*kExtFaceFace.data().begin(), ADD_VALUES);
327 for (
int ee = 0; ee < 3; ee++) {
330 dofs_x_edge_indices[ee], kExtFaceFace.size2(),
331 dofs_x_face_indices, Kext_edge_face[ee], ADD_VALUES);
334 kExtFaceEdge.resize(3);
335 kExtNodeEdge.resize(3);
336 kExtEdgeEdge.resize(3, 3);
337 for (
int ee = 0; ee < 3; ee++) {
338 if (dOfs_x_edge_indices[ee].size() !=
339 (
unsigned int)(3 *
NBEDGE_H1(order_edge[ee]))) {
340 SETERRQ(PETSC_COMM_SELF, 1,
"data inconsistency");
342 kExtFaceEdge[ee].resize(dOfs_x_face_indices.size(),
343 dOfs_x_edge_indices[ee].size());
344 kExtNodeEdge[ee].resize(9, dOfs_x_edge_indices[ee].size());
345 Kext_node_edge[ee] = &*kExtNodeEdge[ee].data().begin();
346 Kext_face_edge[ee] = &*kExtFaceEdge[ee].data().begin();
347 for (
int EE = 0; EE < 3; EE++) {
348 kExtEdgeEdge(EE, ee).resize(dOfs_x_edge_indices[EE].size(),
349 dOfs_x_edge_indices[ee].size());
350 Kext_edge_edge[EE][ee] = &*kExtEdgeEdge(EE, ee).data().begin();
354 r *
eps, order_face, order_edge,
N, N_face, N_edge, diffN, diffN_face,
355 diffN_edge, t_loc, NULL, NULL, dofs_x, dofs_x_edge, dofs_x_face,
356 Kext_node_edge, Kext_edge_edge, Kext_face_edge, gaussPts.size2(),
358 for (
int ee = 0; ee < 3; ee++) {
360 kExtFaceEdge[ee].size2(), dofs_x_edge_indices[ee],
361 &*kExtFaceEdge[ee].data().begin(), ADD_VALUES);
363 dofs_x_edge_indices[ee],
364 &*kExtNodeEdge[ee].data().begin(), ADD_VALUES);
365 for (
int EE = 0; EE < 3; EE++) {
367 dofs_x_edge_indices[EE], kExtEdgeEdge(EE, ee).size2(),
368 dofs_x_edge_indices[ee], Kext_edge_edge[EE][ee],
379 double s1[3], s2[3], normal[3], q[9];
381 double nrm2_normal = cblas_dnrm2(3, normal, 1);
382 cblas_dscal(3, 1. / nrm2_normal, normal, 1);
383 cblas_dcopy(3, s1, 1, &q[0], 1);
384 cblas_dcopy(3, s2, 1, &q[3], 1);
385 cblas_dcopy(3, normal, 1, &q[6], 1);
388 info =
lapack_dgesv(3, 3, q, 3, ipiv, &*t_glob_nodal.data().begin(), 3);
390 SETERRQ1(PETSC_COMM_SELF, 1,
"error solve dgesv info = %d", info);
398 EntityHandle ent = numeredEntFiniteElementPtr->getEnt();
399 map<int, bCPressure>::iterator mip = mapPressure.begin();
401 tLoc[0] = tLoc[1] = tLoc[2] = 0;
402 for (; mip != mapPressure.end(); mip++) {
403 if (mip->second.tRis.find(ent) != mip->second.tRis.end()) {
404 tLoc[2] -= mip->second.data.data.value1;
407 tLocNodal.resize(3, 3);
408 for (
int nn = 0; nn < 3; nn++) {
409 for (
int dd = 0;
dd < 3;
dd++) {
410 tLocNodal(nn,
dd) = tLoc[
dd];
414 map<int, bCForce>::iterator mif = mapForce.begin();
415 for (; mif != mapForce.end(); mif++) {
416 if (mif->second.tRis.find(ent) != mif->second.tRis.end()) {
418 tGlob[0] = mif->second.data.data.value3;
419 tGlob[1] = mif->second.data.data.value4;
420 tGlob[2] = mif->second.data.data.value5;
421 tGlob *= mif->second.data.data.value1;
422 tGlobNodal.resize(3, 3);
423 for (
int nn = 0; nn < 3; nn++) {
424 for (
int dd = 0;
dd < 3;
dd++) {
425 tGlobNodal(nn,
dd) = tGlob[
dd];
428 CHKERR reBaseToFaceLoocalCoordSystem(tGlobNodal);
429 tLocNodal += tGlobNodal;
435 tLocNodal *=
scale[0];
437 t_loc = &*tLocNodal.data().begin();
447 "Surface Pressure (complex for lazy)",
"none");
448 PetscBool is_conservative = PETSC_TRUE;
449 CHKERR PetscOptionsBool(
"-is_conservative_force",
"is conservative force",
"",
450 PETSC_TRUE, &is_conservative, PETSC_NULL);
451 if (is_conservative == PETSC_FALSE) {
452 typeOfForces = NONCONSERVATIVE;
454 ierr = PetscOptionsEnd();
468 dofs_X = &*coords.data().begin();
469 for (
int ee = 0; ee < 3; ee++) {
470 dofs_X_edge[ee] = NULL;
471 idofs_X_edge[ee] = NULL;
472 order_edge_material[ee] = 0;
476 order_face_material = 0;
478 dofs_x = &*coords.data().begin();
480 for (
int ee = 0; ee < 3; ee++) {
483 diffN_edge[ee] = NULL;
484 dofs_x_edge[ee] = NULL;
485 idofs_x_edge[ee] = NULL;
494 CHKERR FaceElementForcesAndSourcesCore::operator()();
499 case CTX_SNESSETFUNCTION: {
500 tLocNodal *= *sCaleRhs;
505 case CTX_SNESSETJACOBIAN: {
506 tLocNodal *= *sCaleLhs;
526 cubit_meshset_ptr->
meshset, MBTRI, mapForce[ms_id].tRis,
true);
542 cubit_meshset_ptr->
meshset, MBTRI, mapPressure[ms_id].tRis,
true);
548 std::string material_field_name)
550 spatial_field_name, material_field_name),
553 double def_scale = 1.;
556 "_LoadFactor_Scale_", 1, MB_TYPE_DOUBLE,
thScale,
557 MB_TAG_CREAT | MB_TAG_EXCL | MB_TAG_MESH, &def_scale);
558 if (
rval == MB_ALREADY_ALLOCATED) {
560 (
const void **)&
sCale);
568 (
const void **)&
sCale);
578 double *scale_rhs, std::string spatial_field_name,
579 std::string material_field_name)
580 : mField(m_field), feSpatial(m_field, _Aij,
_F, scale_lhs, scale_rhs,
581 spatial_field_name, material_field_name),
582 spatialField(spatial_field_name), materialField(material_field_name) {}
588 double *N_face,
double *N_edge[],
589 double *
t,
double *t_edge[],
590 double *t_face,
double *traction,
int gg) {
593 for (
dd = 0;
dd < 3;
dd++)
594 traction[
dd] = cblas_ddot(3, &
N[gg * 3], 1, &
t[
dd], 3);
595 if (t_face != NULL) {
597 if (nb_dofs_face > 0) {
598 for (
dd = 0;
dd < 3;
dd++)
599 traction[
dd] += cblas_ddot(nb_dofs_face, &N_face[gg * nb_dofs_face], 1,
603 if (t_edge != NULL) {
605 for (; ee < 3; ee++) {
606 if (t_edge[ee] == NULL)
608 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
609 if (nb_dofs_edge > 0) {
610 for (
dd = 0;
dd < 3;
dd++) {
612 cblas_ddot(nb_dofs_edge, &(N_edge[ee][gg * nb_dofs_edge]), 1,
613 &(t_edge[ee][
dd]), 3);
621 int order,
int *order_edge,
double *
N,
double *N_face,
double *N_edge[],
622 double *diffN,
double *diffN_face,
double *diffN_edge[],
double *
t,
623 double *t_edge[],
double *t_face,
double *dofs_x,
double *dofs_x_edge[],
624 double *dofs_x_face,
double *idofs_x,
double *idofs_x_edge[],
625 double *idofs_x_face,
double *Fext,
double *Fext_edge[],
double *Fext_face,
626 double *iFext,
double *iFext_edge[],
double *iFext_face,
int g_dim,
631 bzero(Fext, 9 *
sizeof(
double));
633 bzero(iFext, 9 *
sizeof(
double));
635 for (; ee < 3; ee++) {
636 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
637 if (nb_dofs_edge == 0)
639 if (Fext_edge != NULL)
640 bzero(Fext_edge[ee], 3 * nb_dofs_edge *
sizeof(
double));
641 if (iFext_edge != NULL)
642 bzero(iFext_edge[ee], 3 * nb_dofs_edge *
sizeof(
double));
645 if (nb_dofs_face != 0) {
646 if (Fext_face != NULL)
647 bzero(Fext_face, 3 * nb_dofs_face *
sizeof(
double));
648 if (iFext_face != NULL)
649 bzero(iFext_face, 3 * nb_dofs_face *
sizeof(
double));
652 for (; gg < g_dim; gg++) {
653 double traction[3] = {0, 0, 0};
655 t_edge, t_face, traction, gg);
660 order, order_edge,
order, order_edge, diffN, diffN_face, diffN_edge,
661 dofs_x, dofs_x_edge, dofs_x_face, idofs_x, idofs_x_edge, idofs_x_face,
662 xnormal, xs1, xs2, gg);
664 double normal_real[3], s1_real[3], s2_real[3];
665 double normal_imag[3], s1_imag[3], s2_imag[3];
666 for (
dd = 0;
dd < 3;
dd++) {
667 normal_real[
dd] = 0.5 * xnormal[
dd].
r;
668 normal_imag[
dd] = 0.5 * xnormal[
dd].
i;
669 s1_real[
dd] = 0.5 * xs1[
dd].
r;
670 s1_imag[
dd] = 0.5 * xs1[
dd].
i;
671 s2_real[
dd] = 0.5 * xs2[
dd].
r;
672 s2_imag[
dd] = 0.5 * xs2[
dd].
i;
675 for (; nn < 3; nn++) {
677 for (
dd = 0;
dd < 3;
dd++) {
682 g_w[gg] *
N[3 * gg + nn] * normal_real[
dd] * traction[2];
684 g_w[gg] *
N[3 * gg + nn] * s1_real[
dd] * traction[0];
686 g_w[gg] *
N[3 * gg + nn] * s2_real[
dd] * traction[1];
689 for (
dd = 0;
dd < 3;
dd++) {
690 iFext[3 * nn +
dd] +=
691 g_w[gg] *
N[3 * gg + nn] * normal_imag[
dd] * traction[2];
692 iFext[3 * nn +
dd] +=
693 g_w[gg] *
N[3 * gg + nn] * s1_imag[
dd] * traction[0];
694 iFext[3 * nn +
dd] +=
695 g_w[gg] *
N[3 * gg + nn] * s2_imag[
dd] * traction[1];
699 for (; ee < 3; ee++) {
700 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
701 if (nb_dofs_edge == 0)
704 for (; nn < nb_dofs_edge; nn++) {
705 if (Fext_edge != NULL)
706 for (
dd = 0;
dd < 3;
dd++) {
707 Fext_edge[ee][3 * nn +
dd] += g_w[gg] *
708 N_edge[ee][gg * nb_dofs_edge + nn] *
709 normal_real[
dd] * traction[2];
710 Fext_edge[ee][3 * nn +
dd] += g_w[gg] *
711 N_edge[ee][gg * nb_dofs_edge + nn] *
712 s1_real[
dd] * traction[0];
713 Fext_edge[ee][3 * nn +
dd] += g_w[gg] *
714 N_edge[ee][gg * nb_dofs_edge + nn] *
715 s2_real[
dd] * traction[1];
717 if (iFext_edge != NULL) {
718 for (
dd = 0;
dd < 3;
dd++) {
719 iFext_edge[ee][3 * nn +
dd] += g_w[gg] *
720 N_edge[ee][gg * nb_dofs_edge + nn] *
721 normal_imag[
dd] * traction[2];
722 iFext_edge[ee][3 * nn +
dd] += g_w[gg] *
723 N_edge[ee][gg * nb_dofs_edge + nn] *
724 s1_imag[
dd] * traction[0];
725 iFext_edge[ee][3 * nn +
dd] += g_w[gg] *
726 N_edge[ee][gg * nb_dofs_edge + nn] *
727 s2_imag[
dd] * traction[1];
732 if (nb_dofs_face != 0) {
734 for (; nn < nb_dofs_face; nn++) {
735 if (Fext_face != NULL)
736 for (
dd = 0;
dd < 3;
dd++) {
737 Fext_face[3 * nn +
dd] += g_w[gg] * N_face[gg * nb_dofs_face + nn] *
738 normal_real[
dd] * traction[2];
739 Fext_face[3 * nn +
dd] += g_w[gg] * N_face[gg * nb_dofs_face + nn] *
740 s1_real[
dd] * traction[0];
741 Fext_face[3 * nn +
dd] += g_w[gg] * N_face[gg * nb_dofs_face + nn] *
742 s2_real[
dd] * traction[1];
744 if (iFext_face != NULL)
745 for (
dd = 0;
dd < 3;
dd++) {
746 iFext_face[3 * nn +
dd] += g_w[gg] *
747 N_face[gg * nb_dofs_face + nn] *
748 normal_imag[
dd] * traction[2];
749 iFext_face[3 * nn +
dd] += g_w[gg] *
750 N_face[gg * nb_dofs_face + nn] *
751 s1_imag[
dd] * traction[0];
752 iFext_face[3 * nn +
dd] += g_w[gg] *
753 N_face[gg * nb_dofs_face + nn] *
754 s2_imag[
dd] * traction[1];
762 double eps,
int order,
int *order_edge,
double *
N,
double *N_face,
763 double *N_edge[],
double *diffN,
double *diffN_face,
double *diffN_edge[],
764 double *
t,
double *t_edge[],
double *t_face,
double *dofs_x,
765 double *dofs_x_edge[],
double *dofs_x_face,
double *KExt_hh,
766 double *KExt_edgeh[],
double *KExt_faceh,
int g_dim,
const double *g_w) {
768 int gg,
dd, ii, nn, ee;
769 bzero(KExt_hh, 9 * 9 *
sizeof(
double));
770 if (KExt_edgeh != NULL) {
771 for (ee = 0; ee < 3; ee++) {
772 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
773 bzero(KExt_edgeh[ee], 9 * 3 * nb_dofs_edge *
sizeof(
double));
777 if (KExt_faceh != NULL) {
778 bzero(KExt_faceh, 9 * 3 * nb_dofs_face *
sizeof(
double));
780 for (gg = 0; gg < g_dim; gg++) {
781 double traction[3] = {0, 0, 0};
783 t_edge, t_face, traction, gg);
787 for (ii = 0; ii < 9; ii++) {
788 bzero(idofs_x, 9 *
sizeof(
double));
791 order, order_edge, diffN, diffN_face,
792 diffN_edge, dofs_x, dofs_x_edge, dofs_x_face,
793 idofs_x, NULL, NULL, xnormal, xs1, xs2, gg);
795 double normal_imag[3], s1_imag[3], s2_imag[3];
796 for (
dd = 0;
dd < 3;
dd++) {
797 normal_imag[
dd] = 0.5 * xnormal[
dd].
i /
eps;
798 s1_imag[
dd] = 0.5 * xs1[
dd].
i /
eps;
799 s2_imag[
dd] = 0.5 * xs2[
dd].
i /
eps;
802 for (; nn < 3; nn++) {
803 for (
dd = 0;
dd < 3;
dd++) {
804 KExt_hh[ii + 9 * 3 * nn + 9 *
dd] +=
805 g_w[gg] *
N[3 * gg + nn] * normal_imag[
dd] * traction[2];
806 KExt_hh[ii + 9 * 3 * nn + 9 *
dd] +=
807 g_w[gg] *
N[3 * gg + nn] * s1_imag[
dd] * traction[0];
808 KExt_hh[ii + 9 * 3 * nn + 9 *
dd] +=
809 g_w[gg] *
N[3 * gg + nn] * s2_imag[
dd] * traction[1];
812 if (KExt_edgeh != NULL) {
813 for (ee = 0; ee < 3; ee++) {
814 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
815 for (nn = 0; nn < nb_dofs_edge; nn++) {
816 for (
dd = 0;
dd < 3;
dd++) {
817 KExt_edgeh[ee][ii + 9 * 3 * nn + 9 *
dd] +=
818 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] *
819 normal_imag[
dd] * traction[2];
820 KExt_edgeh[ee][ii + 9 * 3 * nn + 9 *
dd] +=
821 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] * s1_imag[
dd] *
823 KExt_edgeh[ee][ii + 9 * 3 * nn + 9 *
dd] +=
824 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] * s2_imag[
dd] *
830 if (KExt_faceh != NULL) {
831 for (nn = 0; nn < nb_dofs_face; nn++) {
832 for (
dd = 0;
dd < 3;
dd++) {
833 KExt_faceh[ii + 3 * 9 * nn + 9 *
dd] +=
834 g_w[gg] * N_face[nb_dofs_face * gg + nn] * normal_imag[
dd] *
836 KExt_faceh[ii + 3 * 9 * nn + 9 *
dd] +=
837 g_w[gg] * N_face[nb_dofs_face * gg + nn] * s1_imag[
dd] *
839 KExt_faceh[ii + 3 * 9 * nn + 9 *
dd] +=
840 g_w[gg] * N_face[nb_dofs_face * gg + nn] * s2_imag[
dd] *
850 double eps,
int order,
int *order_edge,
double *
N,
double *N_face,
851 double *N_edge[],
double *diffN,
double *diffN_face,
double *diffN_edge[],
852 double *
t,
double *t_edge[],
double *t_face,
double *dofs_x,
853 double *dofs_x_edge[],
double *dofs_x_face,
double *KExt_hedge[3],
854 double *KExt_edgeedge[3][3],
double *KExt_faceedge[3],
int g_dim,
857 int gg,
dd, ii, nn, ee, EE;
859 for (EE = 0; EE < 3; EE++) {
860 int nb_dofs_edge_EE =
NBEDGE_H1(order_edge[EE]);
861 bzero(KExt_hedge[EE], 9 * 3 * nb_dofs_edge_EE *
sizeof(
double));
862 if (KExt_edgeedge != NULL) {
863 for (ee = 0; ee < 3; ee++) {
864 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
865 bzero(KExt_edgeedge[EE][ee],
866 3 * nb_dofs_edge_EE * 3 * nb_dofs_edge *
sizeof(
double));
869 if (KExt_faceedge != NULL) {
870 bzero(KExt_faceedge[EE],
871 3 * nb_dofs_edge_EE * 3 * nb_dofs_face *
sizeof(
double));
874 for (gg = 0; gg < g_dim; gg++) {
875 double traction[3] = {0, 0, 0};
877 t_edge, t_face, traction, gg);
878 for (EE = 0; EE < 3; EE++) {
879 int nb_dofs_edge_EE =
NBEDGE_H1(order_edge[EE]);
880 double *idofs_x_edge[3] = {NULL, NULL, NULL};
881 double idofs_x_edge_EE[3 * nb_dofs_edge_EE];
882 idofs_x_edge[EE] = idofs_x_edge_EE;
883 for (ii = 0; ii < 3 * nb_dofs_edge_EE; ii++) {
884 bzero(idofs_x_edge_EE, 3 * nb_dofs_edge_EE *
sizeof(
double));
885 idofs_x_edge_EE[ii] =
eps;
888 order, order_edge, diffN, diffN_face,
889 diffN_edge, dofs_x, dofs_x_edge, dofs_x_face,
890 NULL, idofs_x_edge, NULL, xnormal, xs1, xs2,
893 double normal_imag[3], s1_imag[3], s2_imag[3];
894 for (
dd = 0;
dd < 3;
dd++) {
895 normal_imag[
dd] = 0.5 * xnormal[
dd].
i /
eps;
896 s1_imag[
dd] = 0.5 * xs1[
dd].
i /
eps;
897 s2_imag[
dd] = 0.5 * xs2[
dd].
i /
eps;
899 for (nn = 0; nn < 3; nn++) {
900 for (
dd = 0;
dd < 3;
dd++) {
901 KExt_hedge[EE][ii + 3 * nb_dofs_edge_EE * 3 * nn +
902 3 * nb_dofs_edge_EE *
dd] +=
903 g_w[gg] *
N[3 * gg + nn] * normal_imag[
dd] * traction[2];
904 KExt_hedge[EE][ii + 3 * nb_dofs_edge_EE * 3 * nn +
905 3 * nb_dofs_edge_EE *
dd] +=
906 g_w[gg] *
N[3 * gg + nn] * s1_imag[
dd] * traction[0];
907 KExt_hedge[EE][ii + 3 * nb_dofs_edge_EE * 3 * nn +
908 3 * nb_dofs_edge_EE *
dd] +=
909 g_w[gg] *
N[3 * gg + nn] * s2_imag[
dd] * traction[1];
912 if (KExt_edgeedge != NULL) {
913 for (ee = 0; ee < 3; ee++) {
914 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
915 for (nn = 0; nn < nb_dofs_edge; nn++) {
916 for (
dd = 0;
dd < 3;
dd++) {
917 KExt_edgeedge[EE][ee][ii + 3 * nb_dofs_edge_EE * 3 * nn +
918 3 * nb_dofs_edge_EE *
dd] +=
919 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] *
920 normal_imag[
dd] * traction[2];
921 KExt_edgeedge[EE][ee][ii + 3 * nb_dofs_edge_EE * 3 * nn +
922 3 * nb_dofs_edge_EE *
dd] +=
923 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] * s1_imag[
dd] *
925 KExt_edgeedge[EE][ee][ii + 3 * nb_dofs_edge_EE * 3 * nn +
926 3 * nb_dofs_edge_EE *
dd] +=
927 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] * s2_imag[
dd] *
933 if (KExt_faceedge != NULL) {
934 for (nn = 0; nn < nb_dofs_face; nn++) {
935 for (
dd = 0;
dd < 3;
dd++) {
936 KExt_faceedge[EE][ii + 3 * nb_dofs_edge_EE * 3 * nn +
937 3 * nb_dofs_edge_EE *
dd] +=
938 g_w[gg] * N_face[nb_dofs_face * gg + nn] * normal_imag[
dd] *
940 KExt_faceedge[EE][ii + 3 * nb_dofs_edge_EE * 3 * nn +
941 3 * nb_dofs_edge_EE *
dd] +=
942 g_w[gg] * N_face[nb_dofs_face * gg + nn] * s1_imag[
dd] *
944 KExt_faceedge[EE][ii + 3 * nb_dofs_edge_EE * 3 * nn +
945 3 * nb_dofs_edge_EE *
dd] +=
946 g_w[gg] * N_face[nb_dofs_face * gg + nn] * s2_imag[
dd] *
958 double *N_face,
double *N_edge[],
double *diffN,
959 double *diffN_face,
double *diffN_edge[],
double *
t,
960 double *t_edge[],
double *t_face,
double *dofs_x,
961 double *dofs_x_edge[],
double *dofs_x_face,
962 double *KExt_hface,
double *KExt_edgeface[3],
963 double *KExt_faceface,
int g_dim,
const double *g_w) {
965 int gg,
dd, ii, nn, ee;
967 bzero(KExt_hface, 9 * 3 * nb_dofs_face *
sizeof(
double));
968 if (KExt_edgeface != NULL) {
969 for (ee = 0; ee < 3; ee++) {
970 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
971 bzero(KExt_edgeface[ee],
972 3 * nb_dofs_face * 3 * nb_dofs_edge *
sizeof(
double));
975 if (KExt_faceface != NULL) {
976 bzero(KExt_faceface, 3 * nb_dofs_face * 3 * nb_dofs_face *
sizeof(
double));
978 for (gg = 0; gg < g_dim; gg++) {
979 double traction[3] = {0, 0, 0};
981 t_edge, t_face, traction, gg);
982 double idofs_x_face[3 * nb_dofs_face];
983 for (ii = 0; ii < 3 * nb_dofs_face; ii++) {
984 bzero(idofs_x_face, 3 * nb_dofs_face *
sizeof(
double));
985 idofs_x_face[ii] =
eps;
989 order, order_edge, diffN, diffN_face, diffN_edge, dofs_x, dofs_x_edge,
990 dofs_x_face, NULL, NULL, idofs_x_face, xnormal, xs1, xs2, gg);
992 double normal_imag[3], s1_imag[3], s2_imag[3];
993 for (
dd = 0;
dd < 3;
dd++) {
994 normal_imag[
dd] = 0.5 * xnormal[
dd].
i /
eps;
995 s1_imag[
dd] = 0.5 * xs1[
dd].
i /
eps;
996 s2_imag[
dd] = 0.5 * xs2[
dd].
i /
eps;
998 for (nn = 0; nn < 3; nn++) {
999 for (
dd = 0;
dd < 3;
dd++) {
1000 KExt_hface[ii + 3 * nb_dofs_face * 3 * nn + 3 * nb_dofs_face *
dd] +=
1001 g_w[gg] *
N[3 * gg + nn] * normal_imag[
dd] * traction[2];
1002 KExt_hface[ii + 3 * nb_dofs_face * 3 * nn + 3 * nb_dofs_face *
dd] +=
1003 g_w[gg] *
N[3 * gg + nn] * s1_imag[
dd] * traction[0];
1004 KExt_hface[ii + 3 * nb_dofs_face * 3 * nn + 3 * nb_dofs_face *
dd] +=
1005 g_w[gg] *
N[3 * gg + nn] * s2_imag[
dd] * traction[1];
1008 if (KExt_edgeface != NULL) {
1009 for (ee = 0; ee < 3; ee++) {
1010 int nb_dofs_edge =
NBEDGE_H1(order_edge[ee]);
1011 for (nn = 0; nn < nb_dofs_edge; nn++) {
1012 for (
dd = 0;
dd < 3;
dd++) {
1013 KExt_edgeface[ee][ii + 3 * nb_dofs_face * 3 * nn +
1014 3 * nb_dofs_face *
dd] +=
1015 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] *
1016 normal_imag[
dd] * traction[2];
1017 KExt_edgeface[ee][ii + 3 * nb_dofs_face * 3 * nn +
1018 3 * nb_dofs_face *
dd] +=
1019 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] * s1_imag[
dd] *
1021 KExt_edgeface[ee][ii + 3 * nb_dofs_face * 3 * nn +
1022 3 * nb_dofs_face *
dd] +=
1023 g_w[gg] * N_edge[ee][nb_dofs_edge * gg + nn] * s2_imag[
dd] *
1029 if (KExt_faceface != NULL) {
1030 for (nn = 0; nn < nb_dofs_face; nn++) {
1031 for (
dd = 0;
dd < 3;
dd++) {
1032 KExt_faceface[ii + 3 * nb_dofs_face * 3 * nn +
1033 3 * nb_dofs_face *
dd] +=
1034 g_w[gg] * N_face[nb_dofs_face * gg + nn] * normal_imag[
dd] *
1036 KExt_faceface[ii + 3 * nb_dofs_face * 3 * nn +
1037 3 * nb_dofs_face *
dd] +=
1038 g_w[gg] * N_face[nb_dofs_face * gg + nn] * s1_imag[
dd] *
1040 KExt_faceface[ii + 3 * nb_dofs_face * 3 * nn +
1041 3 * nb_dofs_face *
dd] +=
1042 g_w[gg] * N_face[nb_dofs_face * gg + nn] * s2_imag[
dd] *