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),
164 DataForcesAndSourcesCore::EntData &data) {
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));
367 const VectorDouble &shape_fun = sit->shapeFunctions;
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);
423 virtual MoFEMErrorCode
getGammaH(
double gamma,
int gg) {
459 MoFEMErrorCode
getJac(DataForcesAndSourcesCore::EntData &data,
int gg,
463 int nb = data.getFieldData().size();
464 jac.resize(9, nb,
false);
466 const MatrixAdaptor diffN = data.getDiffN(gg, nb / 3);
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());
487 MatrixDouble &jac, MatrixDouble &trac) {
490 VectorAdaptor normal = VectorAdaptor(
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());
528 DataForcesAndSourcesCore::EntData &row_data,
529 DataForcesAndSourcesCore::EntData &col_data) {
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++) {
573 VectorAdaptor normal = VectorAdaptor(
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());
699 DataForcesAndSourcesCore::EntData &row_data) {
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++) {
733 VectorAdaptor normal = VectorAdaptor(
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());
ForcesAndSourcesCore::UserDataOperator UserDataOperator
NumeredEntFiniteElement_multiIndex & returnNumeredEntFiniteElement_multiIndex< NumeredEntFiniteElement_multiIndex >(NumeredEntFiniteElement_multiIndex &fes)
NumeredEntFiniteElement_multiIndex & returnNumeredEntFiniteElement_multiIndex(T &fes)
static PetscErrorCode ierr
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
multi_index_container< boost::shared_ptr< NumeredEntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, UId, &NumeredEntFiniteElement::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_RefEntity, EntityHandle, &NumeredEntFiniteElement::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Part_mi_tag >, composite_key< NumeredEntFiniteElement, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > > > > > NumeredEntFiniteElement_multiIndex
MultiIndex for entities for NumeredEntFiniteElement.
implementation of Data Operators for Forces and Sources
constexpr double t
plate stiffness
constexpr auto field_name
MoFEMErrorCode copyBasicMethod(const BasicMethod &basic)
Copy data from other base method to this base method.
int nInTheLoop
number currently of processed method
const Problem * problemPtr
raw pointer to problem
virtual moab::Interface & get_moab()=0
bool sYmm
If true assume that matrix is symmetric structure.
Deprecated interface functions.
MatrixInt facesNodes
nodes on finite element faces
std::string feName
Name of finite element.
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
default operator for TRI element
VectorDouble & getNormal()
get triangle normal
VectorDouble & getCoords()
get triangle coordinates
MatrixDouble & getCoordsAtGaussPts()
Gauss points and weight, matrix (nb. of points x 3)
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
@ OPROW
operator doWork function is executed on FE rows
@ OPROWCOL
operator doWork is executed on FE rows &columns
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
EntitiesFieldData & dataH1
MatrixDouble gaussPts
Matrix of integration points.
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
FTensor::Tensor2< double *, 3, 3 > & getJac()
get element Jacobian
Volume finite element base.
VolumeElementForcesAndSourcesCore(Interface &m_field, const EntityType type=MBTET)
Block data for Nitsche method.
double gamma
Penalty term, see .
string faceElemName
name of element face
double phi
Nitsche method parameter, see .
Range fAces
faces on which constrain is applied
ublas::vector< int > dofOrders
ublas::vector< int > iNdices
VectorDouble shapeFunctions
MultiIndexData(int gg, int side, EntityType type)
MatrixDouble diffShapeFunctions
Common data shared between finite element operators.
std::vector< std::vector< int > > inTetFaceGaussPtsNumber
std::vector< boost::shared_ptr< const NumeredEntFiniteElement > > facesFePtr
std::vector< MatrixDouble > faceNormals
multi_index_container< MultiIndexData, indexed_by< ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(MultiIndexData, int, MultiIndexData::gG)>, ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(MultiIndexData, int, MultiIndexData::sIde)>, ordered_non_unique< BOOST_MULTI_INDEX_MEMBER(MultiIndexData, EntityType, MultiIndexData::tYpe)>, ordered_unique< composite_key< MultiIndexData, member< MultiIndexData, int, &MultiIndexData::gG >, member< MultiIndexData, int, &MultiIndexData::sIde >, member< MultiIndexData, EntityType, &MultiIndexData::tYpe > > > > > Container
std::vector< VectorDouble > rAy
std::vector< MatrixDouble > coordsAtGaussPts
std::map< EntityType, std::vector< std::vector< MatrixDouble > > > dP
derivative of projection matrix in respect DoFs This is EntityType, face, gauss point at face....
std::vector< std::vector< MatrixDouble > > P
projection matrix
std::vector< VectorDouble > cOords
std::vector< MatrixDouble > hoCoordsAtGaussPts
std::vector< MatrixDouble > faceGaussPts
std::vector< EntityHandle > fAces
MyFace(MoFEM::Interface &m_field)
Definition of volume element.
MyVolumeFE(MoFEM::Interface &m_field, BlockData &block_data, CommonData &common_data)
virtual MoFEMErrorCode doAdditionalJobWhenGuassPtsAreCalulated()
MoFEMErrorCode setGaussPts(int order)
Basic operated shared between all Nitsche operators.
virtual MoFEMErrorCode getFaceRadius(int ff)
BlockData & nitscheBlockData
OpBasicCommon(const std::string field_name, BlockData &nitsche_block_data, CommonData &nitsche_common_data, bool field_disp, const char type)
CommonData & nitscheCommonData
virtual MoFEMErrorCode getGammaH(double gamma, int gg)
Calculate jacobian and variation of tractions.
NonlinearElasticElement::CommonData & commonData
OpCommon(const std::string field_name, BlockData &nitsche_block_data, CommonData &nitsche_common_data, NonlinearElasticElement::BlockData &data, NonlinearElasticElement::CommonData &common_data, bool field_disp, const char type)
MoFEMErrorCode getJac(DataForcesAndSourcesCore::EntData &data, int gg, MatrixDouble &jac)
virtual MoFEMErrorCode calculateP(int gg, int fgg, int ff)
NonlinearElasticElement::BlockData & dAta
MoFEMErrorCode getTractionVariance(int gg, int fgg, int ff, MatrixDouble &jac, MatrixDouble &trac)
Get integration pts data on face.
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpGetFaceData(CommonData &common_data)
Calculate Nitsche method terms on left hand side.
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
std::vector< MatrixDouble > kMatrixFace
std::vector< MatrixDouble > kMatrixFace0
OpLhsNormal(const std::string field_name, BlockData &nitsche_block_data, CommonData &nitsche_common_data, NonlinearElasticElement::BlockData &data, NonlinearElasticElement::CommonData &common_data, bool field_disp)
std::vector< MatrixDouble > kMatrixFace1
Calculate Nitsche method terms on right hand side.
OpRhsNormal(const std::string field_name, BlockData &nitsche_block_data, CommonData &nitsche_common_data, NonlinearElasticElement::BlockData &data, NonlinearElasticElement::CommonData &common_data, bool field_disp)
MoFEMErrorCode doWork(int row_side, EntityType row_type, DataForcesAndSourcesCore::EntData &row_data)
Basic implementation of Nitsche's method.
data for calculation heat conductivity and heat capacity elements
Range tEts
constrains elements in block set
common data used by volume elements
std::vector< MatrixDouble > jacStress
this is simply material tangent operator
std::map< std::string, std::vector< VectorDouble > > dataAtGaussPts
std::vector< MatrixDouble3by3 > sTress
void tricircumcenter3d_tp(a, b, c, circumcenter, double *xi, double *eta)