v0.14.0
Public Member Functions | Public Attributes | List of all members
ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain Struct Reference

#include <users_modules/fracture_mechanics/src/ComplexConstArea.hpp>

Inheritance diagram for ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain:
[legend]
Collaboration diagram for ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain:
[legend]

Public Member Functions

 TangentWithMeshSmoothingFrontConstrain (MoFEM::Interface &m_field, string lambda_field_name, int verbose=0)
 
virtual ~TangentWithMeshSmoothingFrontConstrain ()
 
PetscErrorCode preProcess ()
 
PetscErrorCode operator() ()
 
PetscErrorCode postProcess ()
 
- Public Member Functions inherited from ObosleteUsersModules::ConstrainConstantAarea
 ConstrainConstantAarea (MoFEM::Interface &m_field, Mat _C, Mat _Q, string lambda_field_name, int _verbose=0)
 
virtual ~ConstrainConstantAarea ()=default
 
template<typename DOFS >
auto loIt (DOFS dofs, const FieldBitNumber bit, const EntityHandle ent)
 
template<typename DOFS >
auto hiIt (DOFS dofs, const FieldBitNumber bit, const EntityHandle ent)
 
PetscErrorCode getData (bool is_that_C_otherwise_dC, bool trans)
 get face data, indices and coors and nodal values More...
 
PetscErrorCode calcDirevatives (double *diffNTRI, double *dofs_X, double *dofs_iX, double *C, double *iC, double *T, double *iT)
 calculate direvatives More...
 
PetscErrorCode preProcess ()
 
PetscErrorCode operator() ()
 
PetscErrorCode postProcess ()
 

Public Attributes

Vec frontF
 
Vec tangentFrontF
 
const double eps
 
bool ownVectors
 
Tag thFrontTangent
 
- Public Attributes inherited from ObosleteUsersModules::ConstrainConstantAarea
MoFEM::InterfacemField
 
moab::Interface & moab
 
Mat C
 
Mat Q
 
string lambdaFieldName
 
int verbose
 
MatrixDouble diffNTRI
 
const doubleG_TRI_W
 
vector< DofIdx > DirichletBC
 
VectorInt dispDofsColIdx
 
VectorInt dispDofsRowIdx
 
VectorInt localDispDofsRowIdx
 
VectorInt lambdaDofsRowIdx
 
VectorInt lambdaDofsColIdx
 
ublas::vector< double, ublas::bounded_array< double, 9 > > coords
 
ublas::vector< double, ublas::bounded_array< double, 9 > > dofs_X
 
ublas::vector< double, ublas::bounded_array< double, 3 > > lambda
 
EntityHandle face
 
Range problemTets
 
map< DofIdx, Vec > mapV
 

Detailed Description

Constrains is vector_tangent_to_front*nodal_element_quality_at_crack_front = 0, multiplying that constrain by Legrange multipliers, we get

1) vector_tangent_to_front*nodal_element_quality_at_crack_front=0 for each lambda, 2) lambda*vector_tangent_to_front*direvatives_of_quality = 0

Those two equations need to be linearsed and assembled into system of equations

Definition at line 583 of file ComplexConstArea.hpp.

Constructor & Destructor Documentation

◆ TangentWithMeshSmoothingFrontConstrain()

ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::TangentWithMeshSmoothingFrontConstrain ( MoFEM::Interface m_field,
string  lambda_field_name,
int  verbose = 0 
)
inline

Definition at line 590 of file ComplexConstArea.hpp.

593  : ConstrainConstantAarea(m_field, PETSC_NULL, PETSC_NULL,
594  lambda_field_name, verbose),
595  frontF(PETSC_NULL), tangentFrontF(PETSC_NULL), eps(1e-10),
596  ownVectors(false) {}

◆ ~TangentWithMeshSmoothingFrontConstrain()

virtual ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::~TangentWithMeshSmoothingFrontConstrain ( )
inlinevirtual

Definition at line 598 of file ComplexConstArea.hpp.

598  {
599  if (ownVectors) {
600  CHKERR VecDestroy(&frontF);
601  CHKERRABORT(PETSC_COMM_WORLD, ierr);
602  CHKERR VecDestroy(&tangentFrontF);
603  CHKERRABORT(PETSC_COMM_WORLD, ierr);
604  }
605  }

Member Function Documentation

◆ operator()()

PetscErrorCode ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::operator() ( )
inline

Definition at line 648 of file ComplexConstArea.hpp.

648  {
650  // get elemet hanlde
651  EntityHandle face = numeredEntFiniteElementPtr->getEnt();
652  // get adjacent tets
653  Range tet;
654  CHKERR mField.get_moab().get_adjacencies(&face, 1, 3, false, tet);
655  // get data and indices on dofs
656  CHKERR getData(true, true);
657 
658  // Calculate tangent vector constrains
659  ublas::vector<double, ublas::bounded_array<double, 9>> tangent_constrains(
660  9);
661  CHKERR calcDirevatives(&*diffNTRI.data().begin(), &*dofs_X.data().begin(),
662  NULL, NULL, NULL,
663  &*tangent_constrains.data().begin(), NULL);
664  // take in account face orientation in respect crack surface
665  Tag th_interface_side;
666  CHKERR moab.tag_get_handle("INTERFACE_SIDE", th_interface_side);
667  int side;
668  CHKERR moab.tag_get_data(th_interface_side, &face, 1, &side);
669  if (side == 1) {
670  tangent_constrains *= -1;
671  }
672  // get smoothing element forces
673  ublas::vector<double, ublas::bounded_array<double, 9>>
674  f_front_mesh_smoothing(9);
675  ublas::noalias(f_front_mesh_smoothing) = ublas::zero_vector<double>(9);
676  double *f_front_mesh_array;
677  CHKERR VecGetArray(frontF, &f_front_mesh_array);
678  for (int nn = 0; nn < 3; nn++) {
679  for (int dd = 0; dd < 3; dd++) {
680  if (localDispDofsRowIdx[3 * nn + dd] == -1)
681  continue;
682  f_front_mesh_smoothing[3 * nn + dd] =
683  f_front_mesh_array[localDispDofsRowIdx[3 * nn + dd]];
684  }
685  }
686  CHKERR VecRestoreArray(frontF, &f_front_mesh_array);
687  // calculate tangent matrix
688  if (snes_ctx == CTX_SNESSETJACOBIAN) {
689  // get radius
690  double center[3];
691  tricircumcenter3d_tp(&coords.data()[0], &coords.data()[3],
692  &coords.data()[6], center, NULL, NULL);
693  cblas_daxpy(3, -1, &coords.data()[0], 1, center, 1);
694  double r = cblas_dnrm2(3, center, 1);
695  for (int nn = 0; nn < 3; nn++) {
696  for (int dd = 0; dd < 3; dd++) {
697  // ---> calculate tangent starts here
698  ublas::vector<double, ublas::bounded_array<double, 9>> idofs_X(9, 0);
699  idofs_X[nn * 3 + dd] = r * eps;
700  ublas::vector<double, ublas::bounded_array<double, 9>>
701  direvative_of_constrains(9);
702  // use complex derivative
703  CHKERR calcDirevatives(&*diffNTRI.data().begin(),
704  &*dofs_X.data().begin(),
705  &*idofs_X.data().begin(), NULL, NULL, NULL,
706  &*direvative_of_constrains.data().begin());
707  if (side == 1) {
708  direvative_of_constrains /= -r * eps;
709  } else {
710  direvative_of_constrains /= +r * eps;
711  }
712  // dg -> C*q_quality
713  double g[3] = {0, 0, 0};
714  for (int nnn = 0; nnn < 3; nnn++) {
715  if (lambdaDofsRowIdx[nnn] == -1)
716  continue;
717  for (int ddd = 0; ddd < 3; ddd++) {
718  g[nnn] += direvative_of_constrains[nnn * 3 + ddd] *
719  f_front_mesh_smoothing[3 * nnn + ddd];
720  }
721  }
722  for (int nnn = 0; nnn < 3; nnn++) {
723  if (lambdaDofsRowIdx[nnn] == -1)
724  continue;
725  CHKERR MatSetValues(snes_B, 1, &lambdaDofsRowIdx[nnn], 1,
726  &dispDofsColIdx[3 * nn + dd], &g[nnn],
727  ADD_VALUES);
728  }
729  // dCT_lambda
730  for (int nnn = 0; nnn < 3; nnn++) {
731  for (int ddd = 0; ddd < 3; ddd++) {
732  direvative_of_constrains[nnn * 3 + ddd] *= lambda[nnn];
733  }
734  }
735  for (int nnn = 0; nnn < 3; nnn++) {
736  if (lambdaDofsRowIdx[nnn] == -1)
737  continue;
738  CHKERR MatSetValues(snes_B, 3, &dispDofsRowIdx[3 * nnn], 1,
739  &dispDofsColIdx[3 * nn + dd],
740  &direvative_of_constrains[3 * nnn], ADD_VALUES);
741  }
742  // ---> calculate tangent end here
743  }
744  }
745  }
746  switch (snes_ctx) {
747  case CTX_SNESSETFUNCTION: {
748  ublas::vector<double, ublas::bounded_array<double, 3>> g(3);
749  for (int nn = 0; nn < 3; nn++) {
750  g[nn] = cblas_ddot(3, &tangent_constrains[3 * nn], 1,
751  &f_front_mesh_smoothing[3 * nn], 1);
752  }
753  // cerr << "g : " << g << endl;
754  CHKERR VecSetValues(snes_f, 3, &*lambdaDofsRowIdx.data().begin(),
755  &*g.data().begin(), ADD_VALUES);
757  &*tangent_constrains.data().begin(), ADD_VALUES);
758  ublas::vector<double, ublas::bounded_array<double, 9>> f(9);
759  for (int nn = 0; nn < 3; nn++) {
760  for (int dd = 0; dd < 3; dd++) {
761  f[nn * 3 + dd] = lambda[nn] * tangent_constrains[3 * nn + dd];
762  }
763  }
764  // cerr << "f : " << f << endl;
765  CHKERR VecSetValues(snes_f, 9, &dispDofsRowIdx[0], &*f.data().begin(),
766  ADD_VALUES);
767  /*//TAG - only for one proc analysis
768  for(int nn = 0;nn<3;nn++) {
769  EntityHandle ent = lambda_dofs_row_ents[nn];
770  if(ent == no_handle) continue;
771  double *t;
772  CHKERR mField.get_moab().tag_get_by_ptr(thFrontTangent,&ent,1,(const void
773  **)&t); cblas_daxpy(3,+1,&tangent_constrains[3*nn],1,t,1);
774  }*/
775  } break;
776  case CTX_SNESSETJACOBIAN: {
777  for (int nn = 0; nn < 3; nn++) {
778  int lambda_dof_idx = lambdaDofsColIdx[nn];
779  CHKERR MatSetValues(snes_B, 3, &dispDofsRowIdx[3 * nn], 1,
780  &lambda_dof_idx, &tangent_constrains[3 * nn],
781  ADD_VALUES);
782  }
783  } break;
784  default:
785  break;
786  }
788  }

◆ postProcess()

PetscErrorCode ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::postProcess ( )
inline

Definition at line 790 of file ComplexConstArea.hpp.

790  {
792  switch (snes_ctx) {
793  case CTX_SNESSETFUNCTION: {
794  CHKERR VecAssemblyBegin(tangentFrontF);
795  CHKERR VecAssemblyEnd(tangentFrontF);
796  CHKERR VecGhostUpdateBegin(tangentFrontF, ADD_VALUES, SCATTER_REVERSE);
797  CHKERR VecGhostUpdateEnd(tangentFrontF, ADD_VALUES, SCATTER_REVERSE);
798  CHKERR VecGhostUpdateBegin(tangentFrontF, INSERT_VALUES, SCATTER_FORWARD);
799  CHKERR VecGhostUpdateEnd(tangentFrontF, INSERT_VALUES, SCATTER_FORWARD);
800  } break;
801  case CTX_SNESSETJACOBIAN: {
802  CHKERR MatAssemblyBegin(snes_B, MAT_FLUSH_ASSEMBLY);
803  CHKERR MatAssemblyEnd(snes_B, MAT_FLUSH_ASSEMBLY);
804  } break;
805  default: {
806  } break;
807  }
809  }

◆ preProcess()

PetscErrorCode ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::preProcess ( )
inline

Definition at line 608 of file ComplexConstArea.hpp.

608  {
610 
611  switch (ts_ctx) {
612  case CTX_TSSETIFUNCTION: {
613  snes_ctx = CTX_SNESSETFUNCTION;
614  snes_f = ts_F;
615  break;
616  }
617  case CTX_TSSETIJACOBIAN: {
618  snes_ctx = CTX_SNESSETJACOBIAN;
619  snes_B = ts_B;
620  break;
621  }
622  default:
623  break;
624  }
625 
627 
628  switch (snes_ctx) {
629  case CTX_SNESSETFUNCTION: {
630  CHKERR VecAssemblyBegin(snes_f);
631  CHKERR VecAssemblyEnd(snes_f);
632  CHKERR VecZeroEntries(tangentFrontF);
633  CHKERR VecGhostUpdateBegin(tangentFrontF, INSERT_VALUES, SCATTER_FORWARD);
634  CHKERR VecGhostUpdateEnd(tangentFrontF, INSERT_VALUES, SCATTER_FORWARD);
635  CHKERR VecAssemblyBegin(tangentFrontF);
636  CHKERR VecAssemblyEnd(tangentFrontF);
637  } break;
638  case CTX_SNESSETJACOBIAN: {
639  CHKERR MatAssemblyBegin(snes_B, MAT_FLUSH_ASSEMBLY);
640  CHKERR MatAssemblyEnd(snes_B, MAT_FLUSH_ASSEMBLY);
641  } break;
642  default: {
643  } break;
644  }
646  }

Member Data Documentation

◆ eps

const double ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::eps

Definition at line 587 of file ComplexConstArea.hpp.

◆ frontF

Vec ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::frontF

Definition at line 585 of file ComplexConstArea.hpp.

◆ ownVectors

bool ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::ownVectors

Definition at line 588 of file ComplexConstArea.hpp.

◆ tangentFrontF

Vec ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::tangentFrontF

Definition at line 586 of file ComplexConstArea.hpp.

◆ thFrontTangent

Tag ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::thFrontTangent

Definition at line 607 of file ComplexConstArea.hpp.


The documentation for this struct was generated from the following file:
ObosleteUsersModules::ConstrainConstantAarea::dofs_X
ublas::vector< double, ublas::bounded_array< double, 9 > > dofs_X
Definition: ComplexConstArea.hpp:83
g
constexpr double g
Definition: shallow_wave.cpp:63
MoFEM::MatSetValues
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
Definition: EntitiesFieldData.hpp:1644
EntityHandle
ObosleteUsersModules::ConstrainConstantAarea::verbose
int verbose
Definition: ComplexConstArea.hpp:46
ObosleteUsersModules::ConstrainConstantAarea::mField
MoFEM::Interface & mField
Definition: ComplexConstArea.hpp:39
ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::eps
const double eps
Definition: ComplexConstArea.hpp:587
ObosleteUsersModules::ConstrainConstantAarea::dispDofsRowIdx
VectorInt dispDofsRowIdx
Definition: ComplexConstArea.hpp:79
ts_ctx
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1932
ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::tangentFrontF
Vec tangentFrontF
Definition: ComplexConstArea.hpp:586
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1589
sdf.r
int r
Definition: sdf.py:8
ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::ownVectors
bool ownVectors
Definition: ComplexConstArea.hpp:588
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
ObosleteUsersModules::ConstrainConstantAarea::lambda
ublas::vector< double, ublas::bounded_array< double, 3 > > lambda
Definition: ComplexConstArea.hpp:84
ObosleteUsersModules::ConstrainConstantAarea::localDispDofsRowIdx
VectorInt localDispDofsRowIdx
Definition: ComplexConstArea.hpp:80
ObosleteUsersModules::ConstrainConstantAarea::dispDofsColIdx
VectorInt dispDofsColIdx
Definition: ComplexConstArea.hpp:79
ObosleteUsersModules::ConstrainConstantAarea::diffNTRI
MatrixDouble diffNTRI
Definition: ComplexConstArea.hpp:76
ObosleteUsersModules::ConstrainConstantAarea::getData
PetscErrorCode getData(bool is_that_C_otherwise_dC, bool trans)
get face data, indices and coors and nodal values
Definition: ComplexConstArea.hpp:105
ObosleteUsersModules::ConstrainConstantAarea::face
EntityHandle face
Definition: ComplexConstArea.hpp:86
ObosleteUsersModules::ConstrainConstantAarea::calcDirevatives
PetscErrorCode calcDirevatives(double *diffNTRI, double *dofs_X, double *dofs_iX, double *C, double *iC, double *T, double *iT)
calculate direvatives
Definition: ComplexConstArea.hpp:245
ObosleteUsersModules::ConstrainConstantAarea::ConstrainConstantAarea
ConstrainConstantAarea(MoFEM::Interface &m_field, Mat _C, Mat _Q, string lambda_field_name, int _verbose=0)
Definition: ComplexConstArea.hpp:48
ObosleteUsersModules::TangentWithMeshSmoothingFrontConstrain::frontF
Vec frontF
Definition: ComplexConstArea.hpp:585
ObosleteUsersModules::ConstrainConstantAarea::lambdaDofsRowIdx
VectorInt lambdaDofsRowIdx
Definition: ComplexConstArea.hpp:81
Range
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
ObosleteUsersModules::ConstrainConstantAarea::moab
moab::Interface & moab
Definition: ComplexConstArea.hpp:41
ObosleteUsersModules::ConstrainConstantAarea::lambdaDofsColIdx
VectorInt lambdaDofsColIdx
Definition: ComplexConstArea.hpp:81
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
ObosleteUsersModules::ConstrainConstantAarea::coords
ublas::vector< double, ublas::bounded_array< double, 9 > > coords
Definition: ComplexConstArea.hpp:82
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
ObosleteUsersModules::ConstrainConstantAarea::preProcess
PetscErrorCode preProcess()
Definition: ComplexConstArea.hpp:470
tricircumcenter3d_tp
void tricircumcenter3d_tp(double a[3], double b[3], double c[3], double circumcenter[3], double *xi, double *eta)