v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
FractureMechanics::GriffithForceElement::OpConstrainsLhs Struct Reference

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

Inheritance diagram for FractureMechanics::GriffithForceElement::OpConstrainsLhs:
[legend]
Collaboration diagram for FractureMechanics::GriffithForceElement::OpConstrainsLhs:
[legend]

Public Member Functions

 OpConstrainsLhs (MoFEM::Interface &m_field, int tag, BlockData &block_data, CommonData &common_data, const std::string &lambda_field_name, SmartPetscObj< Vec > &delta_vec)
 
MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 
- Public Member Functions inherited from FractureMechanics::GriffithForceElement::AuxOp
 AuxOp (int tag, BlockData &block_data, CommonData &common_data)
 
MoFEMErrorCode setIndices (DataForcesAndSourcesCore::EntData &data)
 
MoFEMErrorCode setVariables (FaceElementForcesAndSourcesCore::UserDataOperator *fe_ptr, DataForcesAndSourcesCore::EntData &data)
 
MoFEMErrorCode setLambdaNodes (FaceElementForcesAndSourcesCore::UserDataOperator *fe_ptr, const std::string &lambda_field_name)
 
MoFEMErrorCode setLambdaIndices (FaceElementForcesAndSourcesCore::UserDataOperator *fe_ptr, const std::string &lambda_field_name)
 

Public Attributes

MoFEM::InterfacemField
 
SmartPetscObj< Vec > & deltaVec
 
MatrixDouble nG_dX
 
MatrixDouble nF_dLambda
 
MatrixDouble nF_dX
 
MatrixDouble jacDelta
 
ublas::vector< double * > jacDeltaPtr
 
VectorDouble d_dA
 
VectorDouble d_Delta
 
ublas::vector< adoublea_Delta
 
AuxFunctions< adoublea_auxFun
 
ublas::vector< adoublea_dA
 
ublas::vector< adoublea_lambdaAtNodes
 
- Public Attributes inherited from FractureMechanics::GriffithForceElement::AuxOp
int tAg
 
BlockDatablockData
 
CommonDatacommonData
 
ublas::vector< int > rowIndices
 
ublas::vector< int > rowIndicesLocal
 
VectorInt3 rowLambdaIndices
 
VectorInt3 rowLambdaIndicesLocal
 
VectorDouble3 lambdaAtNodes
 
VectorDouble activeVariables
 

Detailed Description

Definition at line 1050 of file GriffithForceElement.hpp.

Constructor & Destructor Documentation

◆ OpConstrainsLhs()

FractureMechanics::GriffithForceElement::OpConstrainsLhs::OpConstrainsLhs ( MoFEM::Interface m_field,
int  tag,
BlockData block_data,
CommonData common_data,
const std::string &  lambda_field_name,
SmartPetscObj< Vec > &  delta_vec 
)
inline

Definition at line 1057 of file GriffithForceElement.hpp.

1061 : FaceElementForcesAndSourcesCore::UserDataOperator(
1062 "MESH_NODE_POSITIONS", lambda_field_name,
1063 UserDataOperator::OPROWCOL,
1064 false // not symmetric operator
1065 ),
1066 AuxOp(tag, block_data, common_data), mField(m_field),
1067 deltaVec(delta_vec) {}
AuxOp(int tag, BlockData &block_data, CommonData &common_data)

Member Function Documentation

◆ doWork()

MoFEMErrorCode FractureMechanics::GriffithForceElement::OpConstrainsLhs::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
DataForcesAndSourcesCore::EntData &  row_data,
DataForcesAndSourcesCore::EntData &  col_data 
)
inline

Definition at line 1083 of file GriffithForceElement.hpp.

1086 {
1088
1089 if (row_type != MBVERTEX || col_type != MBVERTEX)
1091
1092 CHKERR setIndices(row_data);
1093 CHKERR setLambdaNodes(this, colFieldName);
1094 CHKERR setLambdaIndices(this, colFieldName);
1095
1096 activeVariables.resize(18, false);
1097 a_auxFun.referenceCoords.resize(9, false);
1098 a_auxFun.currentCoords.resize(9, false);
1099
1100 a_Delta.resize(3, false);
1101 d_Delta.resize(3, false);
1102 trace_on(tAg);
1103 for (int dd = 0; dd != 9; dd++) {
1104 double val = getCoords()[dd];
1105 a_auxFun.referenceCoords[dd] <<= val;
1106 activeVariables[dd] = val;
1107 }
1108 for (int dd = 0; dd != 9; dd++) {
1109 double val = row_data.getFieldData()[dd];
1110 a_auxFun.currentCoords[dd] <<= val;
1111 activeVariables[9 + dd] = val;
1112 }
1113
1114 CHKERR a_auxFun.calculateGriffithForce(1, getGaussPts()(2, 0) * 0.5,
1115 row_data.getDiffN(0));
1116
1117 // calculate area change
1118 std::fill(a_Delta.begin(), a_Delta.end(), 0);
1119 for (int nn = 0; nn != 3; nn++) {
1120 if (col_data.getIndices()[nn] == -1)
1121 continue;
1122 if (col_data.getIndices()[nn] != rowLambdaIndices[nn]) {
1123 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
1124 "data inconsistency");
1125 }
1126 for (int dd = 0; dd != 3; dd++) {
1127 int idx = 3 * nn + dd;
1128 if (row_data.getFieldDofs()[idx]->getEnt() !=
1129 col_data.getFieldDofs()[nn]->getEnt()) {
1130 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
1131 "data inconsistency");
1132 }
1133 a_Delta[nn] +=
1134 a_auxFun.griffithForce[idx] *
1135 (a_auxFun.currentCoords[idx] - a_auxFun.referenceCoords[idx]);
1136 }
1137 }
1138 for (int nn = 0; nn != 3; nn++) {
1139 a_Delta[nn] >>= d_Delta[nn];
1140 }
1141 trace_off();
1142
1143 jacDelta.resize(3, 18, false);
1144 jacDeltaPtr.resize(3, false);
1145 for (int nn = 0; nn != 3; nn++) {
1146 jacDeltaPtr[nn] = &jacDelta(nn, 0);
1147 }
1148
1149 {
1150 int r;
1151 // play recorder for jacobian
1152 r = ::jacobian(tAg, 3, 18, &activeVariables[0], &jacDeltaPtr[0]);
1153 if (r < 3) { // function is locally analytic
1154 SETERRQ1(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
1155 "ADOL-C function evaluation with error r = %d", r);
1156 }
1157 }
1158
1159 const double *delta;
1160 Vec delta_vec_local;
1161 CHKERR VecGhostGetLocalForm(deltaVec, &delta_vec_local);
1162 int vec_size;
1163 CHKERR VecGetSize(delta_vec_local, &vec_size);
1164 CHKERR VecGetArrayRead(delta_vec_local, &delta);
1165 nG_dX.resize(3, 9, false);
1166 nG_dX.clear();
1167 for (int nn = 0; nn != 3; ++nn) {
1168 int local_idx = col_data.getLocalIndices()[nn];
1169 if (local_idx != rowLambdaIndicesLocal[nn]) {
1170 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
1171 "data inconsistency");
1172 }
1173 if (local_idx == -1)
1174 continue;
1175 if (vec_size < local_idx) {
1176 int g_vec_size;
1177 CHKERR VecGetLocalSize(deltaVec, &g_vec_size);
1178 SETERRQ3(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
1179 "data inconsistency %d < %d (%d)", vec_size, local_idx,
1180 g_vec_size);
1181 }
1182 double W = col_data.getFieldData()[nn] - blockData.E * delta[local_idx];
1183 double diff_constrain = -diffCalMax_a(W, 0, blockData.r);
1184 for (int dd = 0; dd != 9; dd++) {
1185 double diffW = -blockData.E * jacDelta(nn, 9 + dd);
1186 nG_dX(nn, dd) = diff_constrain * diffW;
1187 }
1188 }
1189 CHKERR VecRestoreArrayRead(delta_vec_local, &delta);
1190 CHKERR VecGhostRestoreLocalForm(deltaVec, &delta_vec_local);
1191 CHKERR MatSetValues(getFEMethod()->snes_B, 3,
1192 &*col_data.getIndices().data().begin(), 9,
1193 &*row_data.getIndices().data().begin(),
1194 &*nG_dX.data().begin(), ADD_VALUES);
1195
1196 // Dervatives of nF
1197
1198 // Linearisation with adol-C
1199 activeVariables.resize(21, false);
1200 d_dA.resize(9, false);
1201 a_dA.resize(9, false);
1202 a_lambdaAtNodes.resize(3, false);
1203 a_auxFun.referenceCoords.resize(9, false);
1204
1205 trace_on(tAg);
1206 for (int dd = 0; dd != 9; dd++) {
1207 double val = getCoords()[dd];
1208 a_auxFun.referenceCoords[dd] <<= val;
1209 activeVariables[dd] = val;
1210 }
1211 for (int dd = 0; dd != 9; dd++) {
1212 double val = row_data.getFieldData()[dd];
1213 a_auxFun.currentCoords[dd] <<= val;
1214 activeVariables[9 + dd] = val;
1215 }
1216 for (int nn = 0; nn != 3; nn++) {
1217 double val = col_data.getFieldData()[nn];
1218 a_lambdaAtNodes[nn] <<= val;
1219 activeVariables[18 + nn] = val;
1220 }
1221
1222 CHKERR a_auxFun.calculateGriffithForce(1, getGaussPts()(2, 0) * 0.5,
1223 row_data.getDiffN(0));
1224
1225 std::fill(a_dA.begin(), a_dA.end(), 0);
1226 for (int nn = 0; nn != 3; nn++) {
1227 if (col_data.getIndices()[nn] == -1)
1228 continue;
1229 for (int dd = 0; dd != 3; dd++) {
1230 int idx = 3 * nn + dd;
1231 a_dA[idx] -= a_lambdaAtNodes[nn] * a_auxFun.griffithForce[idx];
1232 }
1233 }
1234 for (int dd = 0; dd != 9; dd++) {
1235 a_dA[dd] >>= d_dA[dd];
1236 }
1237 trace_off();
1238
1239 commonData.tangentGriffithForce.resize(9, 21, false);
1241 for (int dd = 0; dd != 9; ++dd) {
1244 }
1245
1246 {
1247 int r;
1248 // play recorder for jacobian
1249 r = ::jacobian(tAg, 9, 21, &activeVariables[0],
1251 if (r < 3) { // function is locally analytic
1252 SETERRQ1(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
1253 "ADOL-C function evaluation with error r = %d", r);
1254 }
1255 }
1256
1257 nF_dLambda.resize(9, 3);
1258 for (int rr = 0; rr != 9; rr++) {
1259 for (int cc = 0; cc != 3; cc++) {
1260 nF_dLambda(rr, cc) = commonData.tangentGriffithForce(rr, 18 + cc);
1261 }
1262 }
1263 CHKERR MatSetValues(getFEMethod()->snes_B, 9, &*rowIndices.data().begin(),
1264 3, &*col_data.getIndices().data().begin(),
1265 &*nF_dLambda.data().begin(), ADD_VALUES);
1266
1267 nF_dX.resize(9, 9, false);
1268 for (int rr = 0; rr != 9; rr++) {
1269 for (int cc = 0; cc != 9; cc++) {
1270 nF_dX(rr, cc) = commonData.tangentGriffithForce(rr, 9 + cc);
1271 }
1272 }
1273 CHKERR MatSetValues(getFEMethod()->snes_B, 9, &*rowIndices.data().begin(),
1274 9, &*row_data.getIndices().data().begin(),
1275 &*nF_dX.data().begin(), ADD_VALUES);
1276
1278 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:34
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
double W
const FTensor::Tensor2< T, Dim, Dim > Vec
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
static double diffCalMax_a(double a, double b, double r)
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
int r
Definition: sdf.py:8
static constexpr double delta
MoFEMErrorCode setLambdaNodes(FaceElementForcesAndSourcesCore::UserDataOperator *fe_ptr, const std::string &lambda_field_name)
MoFEMErrorCode setLambdaIndices(FaceElementForcesAndSourcesCore::UserDataOperator *fe_ptr, const std::string &lambda_field_name)
MoFEMErrorCode setIndices(DataForcesAndSourcesCore::EntData &data)
vector< double * > tangentGriffithForceRowPtr
Pointers to rows of tangent matrix.

Member Data Documentation

◆ a_auxFun

AuxFunctions<adouble> FractureMechanics::GriffithForceElement::OpConstrainsLhs::a_auxFun

Definition at line 1079 of file GriffithForceElement.hpp.

◆ a_dA

ublas::vector<adouble> FractureMechanics::GriffithForceElement::OpConstrainsLhs::a_dA

Definition at line 1080 of file GriffithForceElement.hpp.

◆ a_Delta

ublas::vector<adouble> FractureMechanics::GriffithForceElement::OpConstrainsLhs::a_Delta

Definition at line 1078 of file GriffithForceElement.hpp.

◆ a_lambdaAtNodes

ublas::vector<adouble> FractureMechanics::GriffithForceElement::OpConstrainsLhs::a_lambdaAtNodes

Definition at line 1081 of file GriffithForceElement.hpp.

◆ d_dA

VectorDouble FractureMechanics::GriffithForceElement::OpConstrainsLhs::d_dA

Definition at line 1075 of file GriffithForceElement.hpp.

◆ d_Delta

VectorDouble FractureMechanics::GriffithForceElement::OpConstrainsLhs::d_Delta

Definition at line 1076 of file GriffithForceElement.hpp.

◆ deltaVec

SmartPetscObj<Vec>& FractureMechanics::GriffithForceElement::OpConstrainsLhs::deltaVec

Definition at line 1055 of file GriffithForceElement.hpp.

◆ jacDelta

MatrixDouble FractureMechanics::GriffithForceElement::OpConstrainsLhs::jacDelta

Definition at line 1073 of file GriffithForceElement.hpp.

◆ jacDeltaPtr

ublas::vector<double *> FractureMechanics::GriffithForceElement::OpConstrainsLhs::jacDeltaPtr

Definition at line 1074 of file GriffithForceElement.hpp.

◆ mField

MoFEM::Interface& FractureMechanics::GriffithForceElement::OpConstrainsLhs::mField

Definition at line 1054 of file GriffithForceElement.hpp.

◆ nF_dLambda

MatrixDouble FractureMechanics::GriffithForceElement::OpConstrainsLhs::nF_dLambda

Definition at line 1070 of file GriffithForceElement.hpp.

◆ nF_dX

MatrixDouble FractureMechanics::GriffithForceElement::OpConstrainsLhs::nF_dX

Definition at line 1071 of file GriffithForceElement.hpp.

◆ nG_dX

MatrixDouble FractureMechanics::GriffithForceElement::OpConstrainsLhs::nG_dX

Definition at line 1069 of file GriffithForceElement.hpp.


The documentation for this struct was generated from the following file: