27 #ifndef __NITCHE_BOUNDARY_CONDITIONS_HPP__
28 #define __NITCHE_BOUNDARY_CONDITIONS_HPP__
47 boost::shared_ptr<NumeredEntFiniteElement_multiIndex>>(
48 boost::shared_ptr<NumeredEntFiniteElement_multiIndex> &fes) {
93 std::vector<EntityHandle>
fAces;
94 std::vector<boost::shared_ptr<const NumeredEntFiniteElement>>
facesFePtr;
101 std::vector<VectorDouble>
rAy;
110 std::vector<std::vector<MatrixDouble>>
P;
117 std::map<EntityType, std::vector<std::vector<MatrixDouble>>>
dP;
133 typedef multi_index_container<
136 ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(MultiIndexData,
int,
138 ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(MultiIndexData,
int,
140 ordered_non_unique<BOOST_MULTI_INDEX_MEMBER(
142 ordered_unique<composite_key<
144 member<MultiIndexData, int, &MultiIndexData::gG>,
145 member<MultiIndexData, int, &MultiIndexData::sIde>,
146 member<MultiIndexData, EntityType, &MultiIndexData::tYpe>>>>>
160 "DISPLACEMENT",
OPROW),
171 if (
type == MBVERTEX) {
174 for (
int fgg = 0; fgg < nb_face_gauss_pts; fgg++) {
182 0.5 * getNormalsAtGaussPtss();
195 }
catch (
const std::exception &ex) {
196 std::ostringstream ss;
197 ss <<
"throw in method: " << ex.what() << std::endl;
198 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
202 for (
int fgg = 0; fgg < nb_face_gauss_pts; fgg++) {
207 std::pair<CommonData::Container::iterator, bool> p;
211 "data not inserted");
216 int nb_shape_fun = data.getN().size2();
217 shape_fun.resize(nb_shape_fun);
220 cblas_dcopy(nb_shape_fun, &data.getN()(fgg, 0), 1, &shape_fun[0],
223 p_data.
iNdices = data.getIndices();
224 p_data.
dofOrders.resize(data.getFieldDofs().size(),
false);
225 for (
unsigned int dd = 0;
dd < data.getFieldDofs().size();
dd++) {
226 p_data.
dofOrders[
dd] = data.getFieldDofs()[
dd]->getDofOrder();
230 }
catch (
const std::exception &ex) {
231 std::ostringstream ss;
232 ss <<
"throw in method: " << ex.what() << std::endl;
233 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
272 for (
int ff = 0; ff < 4; ff++) {
283 }
catch (
const std::exception &ex) {
284 std::ostringstream ss;
285 ss <<
"throw in method: " << ex.what() << std::endl;
286 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
291 for (
int ff = 0; ff < 4; ff++) {
293 NumeredEntFiniteElement_multiIndex::index<
294 Composite_Name_And_Ent_mi_tag>::type::iterator it,
299 .get<Composite_Name_And_Ent_mi_tag>()
304 .get<Composite_Name_And_Ent_mi_tag>()
309 .get<Composite_Name_And_Ent_mi_tag>()
312 "No finite element found < %s >",
324 for (
int ff = 0; ff < 4; ff++) {
326 boost::shared_ptr<const NumeredEntFiniteElement> faceFEPtr =
332 faceFE.dataPtr = faceFEPtr->sPtr->data_dofs;
333 faceFE.rowPtr = faceFEPtr->rows_dofs;
334 faceFE.colPtr = faceFEPtr->cols_dofs;
340 }
catch (
const std::exception &ex) {
341 std::ostringstream ss;
342 ss <<
"throw in method: " << ex.what() << std::endl;
343 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
347 int nb_gauss_pts = 0;
348 for (
int ff = 0; ff < 4; ff++) {
353 gaussPts.resize(4, nb_gauss_pts,
false);
354 const double coords_tet[12] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
356 for (
int ff = 0; ff < 4; ff++) {
362 for (
int fgg = 0; fgg < nb_gauss_face_pts; fgg++, gg++) {
364 CommonData::Container::nth_index<3>::type::iterator sit;
366 boost::make_tuple(gg, 0, MBVERTEX));
370 for (
int dd = 0;
dd < 3;
dd++) {
379 }
catch (
const std::exception &ex) {
380 std::ostringstream ss;
381 ss <<
"throw in method: " << ex.what() << std::endl;
382 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
402 CommonData &nitsche_common_data,
bool field_disp,
418 cblas_daxpy(3, -1, &coords[0], 1, center, 1);
463 int nb = data.getFieldData().size();
464 jac.resize(9, nb,
false);
468 for (
int dd = 0;
dd < nb / 3;
dd++) {
469 for (
int rr = 0; rr < 3; rr++) {
470 for (
int ii = 0; ii < 9; ii++) {
471 for (
int jj = 0; jj < 3; jj++) {
472 jac(ii, 3 *
dd + rr) +=
473 jac_stress(ii, 3 * rr + jj) * diffN(
dd, jj);
478 }
catch (
const std::exception &ex) {
479 std::ostringstream ss;
480 ss <<
"throw in method: " << ex.what() << std::endl;
481 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
491 3, ublas::shallow_array_adaptor<double>(
493 trac.resize(3, jac.size2());
495 for (
unsigned int dd2 = 0; dd2 < jac.size2(); dd2++) {
496 for (
int nn = 0; nn < 3; nn++) {
498 cblas_ddot(3, &jac(3 * nn, dd2), jac.size2(), &normal[0], 1);
501 }
catch (
const std::exception &ex) {
502 std::ostringstream ss;
503 ss <<
"throw in method: " << ex.what() << std::endl;
504 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
536 if (row_data.getIndices().size() == 0)
538 if (col_data.getIndices().size() == 0)
540 int nb_dofs_row = row_data.getIndices().size();
541 int nb_dofs_col = col_data.getIndices().size();
545 kMatrix0.resize(nb_dofs_row, nb_dofs_col,
false);
546 kMatrix1.resize(nb_dofs_row, nb_dofs_col,
false);
547 kMatrix.resize(nb_dofs_row, nb_dofs_col,
false);
553 for (
int ff = 0; ff < 4; ff++) {
561 for (
int fgg = 0; fgg < nb_face_gauss_pts; fgg++, gg++) {
574 3, ublas::shallow_array_adaptor<double>(
576 double area = cblas_dnrm2(3, &normal[0], 1);
583 for (
int dd1 = 0; dd1 < nb_dofs_row / 3; dd1++) {
584 double n_row = row_data.getN()(gg, dd1);
585 for (
int dd2 = 0; dd2 < nb_dofs_col / 3; dd2++) {
586 double n_col = col_data.getN()(gg, dd2);
587 for (
int dd3 = 0; dd3 < 3; dd3++) {
588 for (
int dd4 = 0; dd4 < 3; dd4++) {
591 kMatrix0(3 * dd1 + dd3, 3 * dd2 + dd4) +=
592 val * n_row *
P(dd3, dd4) * n_col * area;
597 for (
int dd1 = 0; dd1 < nb_dofs_row / 3; dd1++) {
598 double n_row = row_data.getN()(gg, dd1);
599 for (
int dd2 = 0; dd2 < nb_dofs_col; dd2++) {
600 for (
int dd3 = 0; dd3 < 3; dd3++) {
601 double t = cblas_ddot(3, &
P(dd3, 0), 1, &
tRac_u(0, dd2),
603 kMatrix1(3 * dd1 + dd3, dd2) -= val * n_row *
t;
607 for (
int dd1 = 0; dd1 < nb_dofs_row; dd1++) {
608 for (
int dd2 = 0; dd2 < nb_dofs_col / 3; dd2++) {
609 double n_col = col_data.getN()(gg, dd2);
610 for (
int dd3 = 0; dd3 < 3; dd3++) {
611 double t = cblas_ddot(3, &
P(0, dd3), 3, &
tRac_v(0, dd1),
621 (
unsigned int)nb_face_gauss_pts) {
623 if (dP.size1() == 3 &&
624 dP.size2() == (
unsigned int)nb_dofs_col) {
628 for (
int dd1 = 0; dd1 < nb_dofs_row / 3; dd1++) {
629 double n_row = row_data.getN()(gg, dd1);
630 for (
int dd2 = 0; dd2 < nb_dofs_col / 3; dd2++) {
631 for (
int dd3 = 0; dd3 < 3; dd3++) {
632 for (
int dd4 = 0; dd4 < 3; dd4++) {
633 kMatrix0(3 * dd1 + dd3, 3 * dd2 + dd4) +=
634 val * n_row * u[dd4] * dP(dd4, 3 * dd2 + dd4);
642 for (
int dd1 = 0; dd1 < nb_dofs_row / 3; dd1++) {
643 double n_row = row_data.getN()(gg, dd1);
644 for (
int dd2 = 0; dd2 < nb_dofs_col / 3; dd2++) {
645 for (
int dd3 = 0; dd3 < 3; dd3++) {
646 for (
int dd4 = 0; dd4 < 3; dd4++) {
647 kMatrix1(3 * dd1 + dd3, 3 * dd2 + dd4) +=
648 val * n_row *
t[dd4] * dP(dd4, 3 * dd2 + dd4);
665 "wrong number of gauss pts");
669 getFEMethod()->snes_B, nb_dofs_row, &row_data.getIndices()[0],
670 nb_dofs_col, &col_data.getIndices()[0], &
kMatrix(0, 0), ADD_VALUES);
673 }
catch (
const std::exception &ex) {
674 std::ostringstream ss;
675 ss <<
"throw in method: " << ex.what() << std::endl;
676 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
706 if (row_data.getIndices().size() == 0)
708 int nb_dofs_row = row_data.getIndices().size();
714 nF.resize(nb_dofs_row,
false);
718 for (
int ff = 0; ff < 4; ff++) {
724 for (
int fgg = 0; fgg < nb_face_gauss_pts; fgg++, gg++) {
734 3, ublas::shallow_array_adaptor<double>(
736 double area = cblas_dnrm2(3, &normal[0], 1);
747 for (
int dd1 = 0; dd1 < nb_dofs_row / 3; dd1++) {
748 double n_row = row_data.getN()(gg, dd1);
749 for (
int dd2 = 0; dd2 < 3; dd2++) {
752 (val * area * n_row *
753 (
P(dd2, 0) * u[0] +
P(dd2, 1) * u[1] +
P(dd2, 2) * u[2]));
756 (
P(dd2, 0) *
t[0] +
P(dd2, 1) *
t[1] +
P(dd2, 2) *
t[2]);
759 (
P(dd2, 0) * u[0] +
P(dd2, 1) * u[1] +
P(dd2, 2) * u[2]);
766 &row_data.getIndices()[0], &
nF[0], ADD_VALUES);
769 }
catch (
const std::exception &ex) {
770 std::ostringstream ss;
771 ss <<
"throw in method: " << ex.what() << std::endl;
772 SETERRQ(PETSC_COMM_SELF, 1, ss.str().c_str());
780 #endif // __NITCHE_BOUNDARY_CONDITIONS_HPP__