485template <
class SC,
class LO,
class GO,
class NO>
486void FE<SC,LO,GO,NO>::assemblyLaplaceDiffusion(
int dim,
490 vec2D_dbl_Type diffusionTensor,
491 bool callFillComplete,
493 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
496 FEloc = this->
checkFE(dim,FEType);
498 FEloc = FELocExternal;
500 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
502 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
504 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
506 vec3D_dbl_ptr_Type dPhi;
507 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
519 vec_dbl_Type v_i(dim);
520 vec_dbl_Type v_j(dim);
525 if(diffusionTensor.size()==0 || diffusionTensor.size() < dim ){
526 vec2D_dbl_Type diffusionTensor(3,vec_dbl_Type(3,0));
527 for(
int i=0; i< dim; i++){
528 diffusionTensor[i][i]=1.;
532 for(
int i=0; i< dim; i++){
533 for(
int j=0; j<dim; j++){
534 diffusionT[i][j]=diffusionTensor[i][j];
539 for (UN T=0; T<elements->numberElements(); T++) {
542 detB = B.computeInverse(Binv);
543 absDetB = std::fabs(detB);
545 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
546 applyBTinv( dPhi, dPhiTrans, Binv );
548 vec3D_dbl_Type dPhiTransDiff( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
549 applyDiff( dPhiTrans, dPhiTransDiff, diffusionT );
551 for (UN i=0; i < dPhiTrans[0].size(); i++) {
552 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
553 Teuchos::Array<GO> indices( dPhiTrans[0].size(), 0 );
555 for (UN j=0; j < value.size(); j++) {
556 for (UN w=0; w<dPhiTrans.size(); w++) {
557 for (UN d=0; d<dim; d++){
558 value[j] += weights->at(w) * dPhiTrans[w][i][d] * dPhiTransDiff[w][j][d];
562 indices[j] = map->getGlobalElement( elements->getElement(T).getNode(j) );
563 if (this->setZeros_ && std::fabs(value[j]) < this->myeps_) {
567 GO row = map->getGlobalElement( elements->getElement(T).getNode(i) );
569 A->insertGlobalValues( row, indices(), value() );
574 if (callFillComplete)
579template <
class SC,
class LO,
class GO,
class NO>
580void FE<SC,LO,GO,NO>::applyDiff( vec3D_dbl_Type& dPhiIn,
581 vec3D_dbl_Type& dPhiOut,
583 UN dim = diffT.size();
584 for (UN w=0; w<dPhiIn.size(); w++){
585 for (UN i=0; i < dPhiIn[w].size(); i++) {
586 for (UN d1=0; d1<dim; d1++) {
587 for (UN d2=0; d2<dim; d2++) {
588 dPhiOut[w][i][d1] += dPhiIn[w][i][d2]* diffT[d2][d1];
918template <
class SC,
class LO,
class GO,
class NO>
919void FE<SC,LO,GO,NO>::assemblyMass(
int dim,
921 std::string fieldType,
923 bool callFillComplete){
925 TEUCHOS_TEST_FOR_EXCEPTION( FEType ==
"P0", std::logic_error,
"Not implemented for P0" );
926 UN FEloc = this->checkFE(dim,FEType);
927 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
929 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
931 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
933 vec2D_dbl_ptr_Type phi;
934 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
945 vec_dbl_Type v_i(dim);
946 vec_dbl_Type v_j(dim);
948 for (UN T=0; T<elements->numberElements(); T++) {
951 detB = B.computeDet( );
952 absDetB = std::fabs(detB);
954 for (UN i=0; i < phi->at(0).size(); i++) {
955 Teuchos::Array<SC> value( phi->at(0).size(), 0. );
956 Teuchos::Array<GO> indices( phi->at(0).size(), 0 );
957 for (UN j=0; j < value.size(); j++) {
958 for (UN w=0; w<phi->size(); w++) {
959 value[j] += weights->at(w) * (*phi)[w][i] * (*phi)[w][j];
963 if (!fieldType.compare(
"Scalar")) {
964 indices[j] = map->getGlobalElement( elements->getElement(T).getNode(j) );
968 if (!fieldType.compare(
"Scalar")) {
969 GO row = map->getGlobalElement( elements->getElement(T).getNode(i) );
970 A->insertGlobalValues( row, indices(), value() );
972 else if (!fieldType.compare(
"Vector")) {
973 for (UN d=0; d<dim; d++) {
974 for (
int j=0; j<indices.size(); j++) {
975 indices[j] = (GO) ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d );
977 GO row = (GO) ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d );
978 A->insertGlobalValues( row, indices(), value() );
982 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Specify valid vieldType for assembly of mass matrix.");
987 if (callFillComplete)
995template <
class SC,
class LO,
class GO,
class NO>
996void FE<SC,LO,GO,NO>::assemblyMass(
int dim,
998 std::string fieldType,
1001 bool callFillComplete){
1003 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
1005 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
1007 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1009 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1011 vec2D_dbl_ptr_Type phi;
1012 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1023 vec_dbl_Type v_i(dim);
1024 vec_dbl_Type v_j(dim);
1026 for (UN T=0; T<elements->numberElements(); T++) {
1029 detB = B.computeDet( );
1030 absDetB = std::fabs(detB);
1032 for (UN i=0; i < phi->at(0).size(); i++) {
1033 Teuchos::Array<SC> value( phi->at(0).size(), 0. );
1034 Teuchos::Array<GO> indices( phi->at(0).size(), 0 );
1035 for (UN j=0; j < value.size(); j++) {
1036 for (UN w=0; w<phi->size(); w++) {
1037 value[j] += weights->at(w) * (*phi)[w][i] * (*phi)[w][j];
1039 value[j] *= absDetB;
1040 if (!fieldType.compare(
"Scalar")) {
1041 indices[j] = map->getGlobalElement( elements->getElement(T).getNode(j) );
1045 if (!fieldType.compare(
"Scalar")) {
1046 GO row = map->getGlobalElement( elements->getElement(T).getNode(i) );
1047 A->insertGlobalValues( row, indices(), value() );
1049 else if (!fieldType.compare(
"Vector")) {
1050 for (UN d=0; d<dim; d++) {
1051 for (
int j=0; j<indices.size(); j++) {
1052 indices[j] = (GO) ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d );
1054 GO row = (GO) ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d );
1055 A->insertGlobalValues( row, indices(), value() );
1059 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Specify valid vieldType for assembly of mass matrix.");
1064 if (callFillComplete)
1069template <
class SC,
class LO,
class GO,
class NO>
1070void FE<SC,LO,GO,NO>::assemblyLaplace(
int dim,
1074 bool callFillComplete,
1076 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
1078 if (FELocExternal<0)
1079 FEloc = this->checkFE(dim,FEType);
1081 FEloc = FELocExternal;
1083 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
1085 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1087 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1089 vec3D_dbl_ptr_Type dPhi;
1090 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1100 vec_dbl_Type v_i(dim);
1101 vec_dbl_Type v_j(dim);
1103 for (UN T=0; T<elements->numberElements(); T++) {
1106 detB = B.computeInverse(Binv);
1107 absDetB = std::fabs(detB);
1109 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
1110 applyBTinv( dPhi, dPhiTrans, Binv );
1111 for (UN i=0; i < dPhiTrans[0].size(); i++) {
1112 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
1113 Teuchos::Array<GO> indices( dPhiTrans[0].size(), 0 );
1114 for (UN j=0; j < value.size(); j++) {
1115 for (UN w=0; w<dPhiTrans.size(); w++) {
1116 for (UN d=0; d<dim; d++){
1117 value[j] += weights->at(w) * dPhiTrans[w][i][d] * dPhiTrans[w][j][d];
1120 value[j] *= absDetB;
1121 indices[j] = map->getGlobalElement( elements->getElement(T).getNode(j) );
1123 GO row = map->getGlobalElement( elements->getElement(T).getNode(i) );
1125 A->insertGlobalValues( row, indices(), value() );
1130 if (callFillComplete)
1135template <
class SC,
class LO,
class GO,
class NO>
1136void FE<SC,LO,GO,NO>::assemblyLaplaceVecField(
int dim,
1140 bool callFillComplete){
1142 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P1-disc" || FEType ==
"P0",std::logic_error,
"Not implemented for P0 or P1-disc");
1143 UN FEloc = this->checkFE(dim,FEType);
1145 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
1147 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1149 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1151 vec3D_dbl_ptr_Type dPhi;
1152 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1163 vec_dbl_Type v_i(dim);
1164 vec_dbl_Type v_j(dim);
1167 for (UN T=0; T<elements->numberElements(); T++) {
1170 detB = B.computeInverse(Binv);
1171 absDetB = std::fabs(detB);
1173 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
1174 applyBTinv( dPhi, dPhiTrans, Binv );
1176 for (UN i=0; i < dPhiTrans[0].size(); i++) {
1177 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
1178 Teuchos::Array<GO> indices( dPhiTrans[0].size(), 0 );
1179 for (UN j=0; j < value.size(); j++) {
1180 for (UN w=0; w<dPhiTrans.size(); w++) {
1181 for (UN d=0; d<dim; d++)
1182 value[j] += weights->at(w) * dPhiTrans[w][i][d] * dPhiTrans[w][j][d];
1184 value[j] *= absDetB;
1185 if (this->setZeros_ && std::fabs(value[j]) < this->myeps_) {
1189 for (UN d=0; d<dim; d++) {
1190 for (UN j=0; j < indices.size(); j++)
1191 indices[j] = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d );
1193 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d );
1194 A->insertGlobalValues( row, indices(), value() );
1198 if (callFillComplete)
1202template <
class SC,
class LO,
class GO,
class NO>
1203void FE<SC,LO,GO,NO>::assemblyLaplaceVecFieldV2(
int dim,
1207 bool callFillComplete){
1209 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
1210 UN FEloc = this->checkFE(dim,FEType);
1212 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
1214 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1216 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1218 vec3D_dbl_ptr_Type dPhi;
1219 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1225 Teuchos::BLAS<int, SC> teuchosBLAS;
1227 int nmbQuadPoints = dPhi->size();
1228 int nmbScalarDPhi = dPhi->at(0).size();
1229 int nmbAllDPhi = nmbScalarDPhi * dim;
1230 int nmbAllDPhiAllQaud = nmbQuadPoints * nmbAllDPhi;
1231 int sizeLocStiff = dim*dim;
1232 Teuchos::Array<SmallMatrix<double> > dPhiMat( nmbAllDPhiAllQaud,
SmallMatrix<double>(dim) );
1233 this->buildFullDPhi( dPhi, dPhiMat );
1241 vec_dbl_Type v_i(dim);
1242 vec_dbl_Type v_j(dim);
1244 for (UN T=0; T<elements->numberElements(); T++) {
1247 detB = B.computeInverse(Binv);
1248 absDetB = std::fabs(detB);
1250 Teuchos::Array<SmallMatrix<double> > allDPhiMatTrans( dPhiMat.size(),
SmallMatrix<double>() );
1252 for (
int i=0; i<allDPhiMatTrans.size(); i++) {
1254 allDPhiMatTrans[i] = res;
1259 for (
int p=0; p<nmbQuadPoints; p++){
1261 double* allDPhiBlas =
new double[ nmbAllDPhi * sizeLocStiff ];
1263 int offset = p * nmbAllDPhi;
1264 int offsetInArray = 0;
1265 for (
int i=0; i<nmbAllDPhi; i++) {
1266 fillMatrixArray( allDPhiMatTrans[ offset + i ], allDPhiBlas,
"rows",offsetInArray );
1267 offsetInArray += sizeLocStiff;
1270 double* locStiffMatBlas =
new double[ nmbAllDPhi * nmbAllDPhi ];
1272 teuchosBLAS.GEMM (Teuchos::TRANS, Teuchos::NO_TRANS, nmbAllDPhi, nmbAllDPhi, sizeLocStiff, 1., allDPhiBlas, sizeLocStiff, allDPhiBlas, sizeLocStiff, 0., locStiffMatBlas, nmbAllDPhi);
1274 for (
int i=0; i<nmbAllDPhi; i++) {
1275 for (
int j=0; j<nmbAllDPhi; j++) {
1276 locStiffMat[i][j] += weights->at(p) * locStiffMatBlas[ j * nmbAllDPhi + i ];
1280 delete [] allDPhiBlas;
1281 delete [] locStiffMatBlas;
1285 for (UN i=0; i < nmbScalarDPhi; i++) {
1286 Teuchos::Array<SC> value( nmbAllDPhi, 0. );
1287 Teuchos::Array<GO> indices( nmbAllDPhi, 0 );
1288 for (UN d=0; d<dim; d++) {
1289 for (UN j=0; j < nmbScalarDPhi; j++){
1290 value[ j * dim + d ] = absDetB * locStiffMat[dim * i + d][j];
1291 indices[ j * dim + d ] = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d );
1293 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d );
1294 A->insertGlobalValues( row, indices(), value() );
1298 if (callFillComplete)
1304template <
class SC,
class LO,
class GO,
class NO>
1305void FE<SC,LO,GO,NO>::assemblyElasticityJacobianAndStressAceFEM(
int dim,
1308 MultiVectorPtr_Type &f,
1309 MultiVectorPtr_Type u,
1310 ParameterListPtr_Type pList,
1312 bool callFillComplete){
1313 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::runtime_error,
"Not implemented for P0");
1314 UN FEloc = this->checkFE(dim,FEType);
1317 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
1318 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1320 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1321 vec3D_dbl_ptr_Type dPhi;
1322 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1333 Teuchos::BLAS<int,SC> teuchosBLAS;
1335 int nmbQuadPoints = dPhi->size();
1336 int nmbScalarDPhi = dPhi->at(0).size();
1337 int nmbAllDPhi = nmbScalarDPhi * dim;
1338 int nmbAllDPhiAllQaud = nmbQuadPoints * nmbAllDPhi;
1339 int sizeLocStiff = dim*dim;
1340 Teuchos::Array<SmallMatrix<SC> > dPhiMat( nmbAllDPhiAllQaud,
SmallMatrix<SC>(dim) );
1342 this->buildFullDPhi( dPhi, dPhiMat );
1344 std::string material_model = pList->sublist(
"Parameter").get(
"Material model",
"Neo-Hooke");
1346 double poissonRatio = pList->sublist(
"Parameter").get(
"Poisson Ratio",0.4);
1347 double mue = pList->sublist(
"Parameter").get(
"Mu",2.0e+6);
1348 double mue1 = pList->sublist(
"Parameter").get(
"Mu1",2.0e+6);
1349 double mue2 = pList->sublist(
"Parameter").get(
"Mu2",2.0e+6);
1351 double E = pList->sublist(
"Parameter").get(
"E",3.0e+6);
1352 double E1 = pList->sublist(
"Parameter").get(
"E1",3.0e+6);
1353 double E2 = pList->sublist(
"Parameter").get(
"E2",3.0e+6);
1355 if (material_model==
"Saint Venant-Kirchhoff") {
1356 E = mue*2.*(1. + poissonRatio);
1357 E1 = mue1*2.*(1. + poissonRatio);
1358 E2 = mue2*2.*(1. + poissonRatio);
1362 double lambda = (poissonRatio*E)/((1 + poissonRatio)*(1 - 2*poissonRatio));
1363 double lambda1 = (poissonRatio*E1)/((1 + poissonRatio)*(1 - 2*poissonRatio));
1364 double lambda2 = (poissonRatio*E2)/((1 + poissonRatio)*(1 - 2*poissonRatio));
1368 if(!material_model.compare(
"Saint Venant-Kirchhoff"))
1369 v =
new double[154];
1371 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Saint Venant-Kirchhoff in 2D.");
1373 double** Pmat =
new double*[2];
1374 for (
int i=0; i<2; i++)
1375 Pmat[i] =
new double[2];
1377 double** F =
new double*[2];
1378 for (
int i=0; i<2; i++)
1379 F[i] =
new double[2];
1381 double**** Amat =
new double***[2];
1382 for (
int i=0; i<2; i++){
1383 Amat[i] =
new double**[2];
1384 for (
int j=0; j<2; j++) {
1385 Amat[i][j] =
new double*[2];
1386 for (
int k=0; k<2; k++)
1387 Amat[i][j][k] =
new double[2];
1391 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
1393 Teuchos::ArrayRCP<SC> fValues = f->getDataNonConst(0);
1395 Teuchos::Array<int> indices(2);
1396 for (
int T=0; T<elements->numberElements(); T++) {
1399 detB = B.computeInverse(Binv);
1400 absDetB = std::fabs(detB);
1402 Teuchos::Array<SmallMatrix<SC> > all_dPhiMat_Binv( dPhiMat.size(),
SmallMatrix<SC>() );
1404 for (
int i=0; i<all_dPhiMat_Binv.size(); i++) {
1406 all_dPhiMat_Binv[i] = res;
1410 std::vector<SC> locStresses( nmbAllDPhi, 0. );
1411 int elementFlag = 0;
1412 for (
int p=0; p<nmbQuadPoints; p++){
1416 Fmat[0][0] = 1.; Fmat[1][1] = 1.;
1418 for (
int i=0; i<nmbScalarDPhi; i++) {
1419 indices.at(0) = dim * elements->getElement(T).getNode(i);
1420 indices.at(1) = dim * elements->getElement(T).getNode(i) + 1;
1422 for (
int j=0; j<dim; j++) {
1423 tmpForScaling = all_dPhiMat_Binv[ p * nmbAllDPhi + dim * i + j ];
1424 SC v = uArray[indices.at(j)];
1425 tmpForScaling.scale( v );
1426 Fmat += tmpForScaling;
1430 for (
int i=0; i<Fmat.size(); i++) {
1431 for (
int j=0; j<Fmat.size(); j++) {
1432 F[i][j] = Fmat[i][j];
1436 elementFlag = elements->getElement(T).getFlag();
1437 if (elementFlag == 1){
1442 else if (elementFlag == 2){
1448 if ( !material_model.compare(
"Saint Venant-Kirchhoff") )
1449 stvk2d(v, &lambda, &mue, F, Pmat, Amat);
1452 for (
int i=0; i<2; i++) {
1453 for (
int j=0; j<2; j++) {
1454 for (
int k=0; k<2; k++) {
1455 for (
int l=0; l<2; l++) {
1456 Aloc[ 2 * i + j ][ 2 * k + l ] = Amat[i][j][k][l];
1462 double* aceFEMFunc =
new double[ sizeLocStiff * sizeLocStiff ];
1463 double* allDPhiBlas =
new double[ nmbAllDPhi * sizeLocStiff ];
1466 double* resTmp =
new double[ nmbAllDPhi * sizeLocStiff ];
1468 fillMatrixArray(Aloc, aceFEMFunc,
"cols");
1470 int offset = p * nmbAllDPhi;
1471 int offsetInArray = 0;
1472 for (
int i=0; i<nmbAllDPhi; i++) {
1473 fillMatrixArray( all_dPhiMat_Binv[ offset + i ], allDPhiBlas,
"rows",offsetInArray );
1474 offsetInArray += sizeLocStiff;
1477 teuchosBLAS.GEMM (Teuchos::NO_TRANS, Teuchos::NO_TRANS, sizeLocStiff, nmbAllDPhi, sizeLocStiff, 1., aceFEMFunc, sizeLocStiff, allDPhiBlas, sizeLocStiff, 0., resTmp, sizeLocStiff);
1480 double* locStiffMatBlas =
new double[ nmbAllDPhi * nmbAllDPhi ];
1482 teuchosBLAS.GEMM (Teuchos::TRANS, Teuchos::NO_TRANS, nmbAllDPhi, nmbAllDPhi, sizeLocStiff, 1., allDPhiBlas, sizeLocStiff, resTmp, sizeLocStiff, 0., locStiffMatBlas, nmbAllDPhi);
1484 for (
int i=0; i<nmbAllDPhi; i++) {
1485 for (
int j=0; j<nmbAllDPhi; j++)
1486 locStiffMat[i][j] += weights->at(p) * locStiffMatBlas[ j * nmbAllDPhi + i ];
1490 delete [] locStiffMatBlas;
1494 double* fArray =
new double[ sizeLocStiff ];
1495 for (
int i=0; i<dim; i++) {
1496 for (
int j=0; j<dim; j++) {
1497 fArray[i * dim + j] = Pmat[i][j];
1501 double* res =
new double[ nmbAllDPhi ];
1502 teuchosBLAS.GEMV(Teuchos::TRANS, sizeLocStiff, nmbAllDPhi, 1., allDPhiBlas, sizeLocStiff, fArray, 1, 0., res, 1);
1503 for (
int i=0; i<locStresses.size(); i++) {
1504 locStresses[i] += weights->at(p) * res[i];
1508 delete [] aceFEMFunc;
1509 delete [] allDPhiBlas;
1513 for (
int i=0; i<nmbScalarDPhi; i++) {
1514 for (
int d1=0; d1<dim; d1++) {
1516 LO rowLO = dim * elements->getElement(T).getNode(i) + d1;
1517 SC v = absDetB * locStresses[ dim * i + d1 ];
1518 fValues[rowLO] += v;
1520 Teuchos::Array<SC> value( nmbAllDPhi, 0. );
1521 Teuchos::Array<GO> indices( nmbAllDPhi, 0 );
1523 for (UN j=0; j < nmbScalarDPhi; j++){
1524 for (UN d2=0; d2<dim; d2++) {
1525 indices[counter] = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d2 );
1526 value[counter] = absDetB * locStiffMat[dim*i+d1][dim*j+d2];
1530 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d1 );
1531 A->insertGlobalValues( row, indices(), value() );
1537 for (
int i=0; i<2; i++)
1540 for (
int i=0; i<2; i++)
1544 for (
int i=0; i<2; i++){
1545 for (
int j=0; j<2; j++) {
1546 for (
int k=0; k<2; k++)
1547 delete [] Amat[i][j][k];
1548 delete [] Amat[i][j];
1556 else if (dim == 3) {
1558 if (!material_model.compare(
"Neo-Hooke"))
1559 v =
new double[466];
1560 else if(!material_model.compare(
"Mooney-Rivlin"))
1561 v =
new double[476];
1562 else if(!material_model.compare(
"Saint Venant-Kirchhoff"))
1563 v =
new double[279];
1565 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Neo-Hooke, Mooney-Rivlin and Saint Venant-Kirchhoff.");
1568 double** Pmat =
new double*[3];
1569 for (
int i=0; i<3; i++)
1570 Pmat[i] =
new double[3];
1572 double** F =
new double*[3];
1573 for (
int i=0; i<3; i++)
1574 F[i] =
new double[3];
1576 double**** Amat =
new double***[3];
1577 for (
int i=0; i<3; i++){
1578 Amat[i] =
new double**[3];
1579 for (
int j=0; j<3; j++) {
1580 Amat[i][j] =
new double*[3];
1581 for (
int k=0; k<3; k++)
1582 Amat[i][j][k] =
new double[3];
1586 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
1588 Teuchos::ArrayRCP<SC> fValues = f->getDataNonConst(0);
1590 Teuchos::Array<int> indices(3);
1591 for (
int T=0; T<elements->numberElements(); T++) {
1594 detB = B.computeInverse(Binv);
1595 absDetB = std::fabs(detB);
1597 Teuchos::Array<SmallMatrix<SC> > all_dPhiMat_Binv( dPhiMat.size(),
SmallMatrix<SC>() );
1599 for (
int i=0; i<all_dPhiMat_Binv.size(); i++) {
1601 all_dPhiMat_Binv[i] = res;
1605 std::vector<SC> locStresses( nmbAllDPhi, 0. );
1606 int elementFlag = 0;
1607 for (
int p=0; p<nmbQuadPoints; p++){
1611 Fmat[0][0] = 1.; Fmat[1][1] = 1.; Fmat[2][2] = 1.;
1613 for (
int i=0; i<nmbScalarDPhi; i++) {
1614 indices.at(0) = dim * elements->getElement(T).getNode(i);
1615 indices.at(1) = dim * elements->getElement(T).getNode(i) + 1;
1616 indices.at(2) = dim * elements->getElement(T).getNode(i) + 2;
1618 for (
int j=0; j<dim; j++) {
1619 tmpForScaling = all_dPhiMat_Binv[ p * nmbAllDPhi + dim * i + j ];
1620 SC v = uArray[indices.at(j)];
1621 tmpForScaling.scale( v );
1622 Fmat += tmpForScaling;
1626 for (
int i=0; i<Fmat.size(); i++) {
1627 for (
int j=0; j<Fmat.size(); j++) {
1628 F[i][j] = Fmat[i][j];
1632 elementFlag = elements->getElement(T).getFlag();
1633 if (elementFlag == 1){
1638 else if (elementFlag == 2){
1644 if ( !material_model.compare(
"Neo-Hooke") )
1645 nh3d(v, &E, &poissonRatio, F, Pmat, Amat);
1646 else if ( !material_model.compare(
"Mooney-Rivlin") )
1647 mr3d(v, &E, &poissonRatio, &C, F, Pmat, Amat);
1648 else if ( !material_model.compare(
"Saint Venant-Kirchhoff") )
1649 stvk3d(v, &lambda, &mue, F, Pmat, Amat);
1652 for (
int i=0; i<3; i++) {
1653 for (
int j=0; j<3; j++) {
1654 for (
int k=0; k<3; k++) {
1655 for (
int l=0; l<3; l++) {
1656 Aloc[ 3 * i + j ][ 3 * k + l ] = Amat[i][j][k][l];
1662 double* aceFEMFunc =
new double[ sizeLocStiff * sizeLocStiff ];
1663 double* allDPhiBlas =
new double[ nmbAllDPhi * sizeLocStiff ];
1666 double* resTmp =
new double[ nmbAllDPhi * sizeLocStiff ];
1668 fillMatrixArray(Aloc, aceFEMFunc,
"cols");
1670 int offset = p * nmbAllDPhi;
1671 int offsetInArray = 0;
1672 for (
int i=0; i<nmbAllDPhi; i++) {
1673 fillMatrixArray( all_dPhiMat_Binv[ offset + i ], allDPhiBlas,
"rows",offsetInArray );
1674 offsetInArray += sizeLocStiff;
1677 teuchosBLAS.GEMM (Teuchos::NO_TRANS, Teuchos::NO_TRANS, sizeLocStiff, nmbAllDPhi, sizeLocStiff, 1., aceFEMFunc, sizeLocStiff, allDPhiBlas, sizeLocStiff, 0., resTmp, sizeLocStiff);
1680 double* locStiffMatBlas =
new double[ nmbAllDPhi * nmbAllDPhi ];
1682 teuchosBLAS.GEMM (Teuchos::TRANS, Teuchos::NO_TRANS, nmbAllDPhi, nmbAllDPhi, sizeLocStiff, 1., allDPhiBlas, sizeLocStiff, resTmp, sizeLocStiff, 0., locStiffMatBlas, nmbAllDPhi);
1684 for (
int i=0; i<nmbAllDPhi; i++) {
1685 for (
int j=0; j<nmbAllDPhi; j++)
1686 locStiffMat[i][j] += weights->at(p) * locStiffMatBlas[ j * nmbAllDPhi + i ];
1690 delete [] locStiffMatBlas;
1694 double* fArray =
new double[ sizeLocStiff ];
1695 for (
int i=0; i<dim; i++) {
1696 for (
int j=0; j<dim; j++) {
1697 fArray[i * dim + j] = Pmat[i][j];
1701 double* res =
new double[ nmbAllDPhi ];
1702 teuchosBLAS.GEMV(Teuchos::TRANS, sizeLocStiff, nmbAllDPhi, 1., allDPhiBlas, sizeLocStiff, fArray, 1, 0., res, 1);
1703 for (
int i=0; i<locStresses.size(); i++) {
1704 locStresses[i] += weights->at(p) * res[i];
1708 delete [] aceFEMFunc;
1709 delete [] allDPhiBlas;
1713 for (
int i=0; i<nmbScalarDPhi; i++) {
1714 for (
int d1=0; d1<dim; d1++) {
1716 LO rowLO = dim * elements->getElement(T).getNode(i) + d1;
1717 SC v = absDetB * locStresses[ dim * i + d1 ];
1718 fValues[rowLO] += v;
1720 Teuchos::Array<SC> value( nmbAllDPhi, 0. );
1721 Teuchos::Array<GO> indices( nmbAllDPhi, 0 );
1723 for (UN j=0; j < nmbScalarDPhi; j++){
1724 for (UN d2=0; d2<dim; d2++) {
1725 indices[counter] = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d2 );
1726 value[counter] = absDetB * locStiffMat[dim*i+d1][dim*j+d2];
1731 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d1 );
1732 A->insertGlobalValues( row, indices(), value() );
1738 for (
int i=0; i<3; i++)
1741 for (
int i=0; i<3; i++)
1745 for (
int i=0; i<3; i++){
1746 for (
int j=0; j<3; j++) {
1747 for (
int k=0; k<3; k++)
1748 delete [] Amat[i][j][k];
1749 delete [] Amat[i][j];
1756 if (callFillComplete)
1762template <
class SC,
class LO,
class GO,
class NO>
1763void FE<SC,LO,GO,NO>::assemblyElasticityJacobianAceFEM(
int dim,
1766 MultiVectorPtr_Type u,
1767 std::string material_model,
1771 bool callFillComplete){
1772 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
1773 UN FEloc = this->checkFE(dim,FEType);
1775 vec2D_int_ptr_Type elements = this->domainVec_.at(FEloc)->getElements();
1777 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1779 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1780 vec3D_dbl_ptr_Type dPhi;
1781 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1792 Teuchos::BLAS<int, SC> teuchosBLAS;
1794 int nmbQuadPoints = dPhi->size();
1795 int nmbScalarDPhi = dPhi->at(0).size();
1796 int nmbAllDPhi = nmbScalarDPhi * dim;
1797 int nmbAllDPhiAllQaud = nmbQuadPoints * nmbAllDPhi;
1798 int sizeLocStiff = dim*dim;
1799 Teuchos::Array<SmallMatrix<SC> > dPhiMat( nmbAllDPhiAllQaud,
SmallMatrix<SC>(dim) );
1801 this->buildFullDPhi( dPhi, dPhiMat );
1804 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only for 3D.");
1806 else if (dim == 3) {
1809 if (!material_model.compare(
"Neo-Hooke"))
1810 v =
new double[466];
1811 else if(!material_model.compare(
"Mooney-Rivlin"))
1812 v =
new double[476];
1814 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Neo-Hooke and Mooney-Rivlin.");
1818 double** Pmat =
new double*[3];
1819 for (
int i=0; i<3; i++)
1820 Pmat[i] =
new double[3];
1822 double** F =
new double*[3];
1823 for (
int i=0; i<3; i++)
1824 F[i] =
new double[3];
1826 double**** Amat =
new double***[3];
1827 for (
int i=0; i<3; i++){
1828 Amat[i] =
new double**[3];
1829 for (
int j=0; j<3; j++) {
1830 Amat[i][j] =
new double*[3];
1831 for (
int k=0; k<3; k++)
1832 Amat[i][j][k] =
new double[3];
1836 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
1838 Teuchos::Array<int> indices(3);
1839 for (
int T=0; T<elements->size(); T++) {
1842 detB = B.computeInverse(Binv);
1843 absDetB = std::fabs(detB);
1845 Teuchos::Array<SmallMatrix<SC> > all_dPhiMat_Binv( dPhiMat.size(),
SmallMatrix<SC>() );
1847 for (
int i=0; i<all_dPhiMat_Binv.size(); i++) {
1849 all_dPhiMat_Binv[i] = res;
1854 for (
int p=0; p<nmbQuadPoints; p++){
1858 Fmat[0][0] = 1.; Fmat[1][1] = 1.; Fmat[2][2] = 1.;
1860 for (
int i=0; i<nmbScalarDPhi; i++) {
1861 indices.at(0) = dim * elements->at(T).at(i);
1862 indices.at(1) = dim * elements->at(T).at(i) + 1;
1863 indices.at(2) = dim * elements->at(T).at(i) + 2;
1865 for (
int j=0; j<dim; j++) {
1866 tmpForScaling = all_dPhiMat_Binv[ p * nmbAllDPhi + dim * i + j ];
1867 SC v = uArray[indices.at(j)];
1868 tmpForScaling.scale( v );
1869 Fmat += tmpForScaling;
1873 for (
int i=0; i<Fmat.size(); i++) {
1874 for (
int j=0; j<Fmat.size(); j++) {
1875 F[i][j] = Fmat[i][j];
1878 if ( !material_model.compare(
"Neo-Hooke") )
1879 nh3d(v, &E, &nu, F, Pmat, Amat);
1880 else if ( !material_model.compare(
"Mooney-Rivlin") )
1881 mr3d(v, &E, &nu, &C, F, Pmat, Amat);
1884 for (
int i=0; i<3; i++) {
1885 for (
int j=0; j<3; j++) {
1886 for (
int k=0; k<3; k++) {
1887 for (
int l=0; l<3; l++) {
1888 Aloc[ 3 * i + j ][ 3 * k + l ] = Amat[i][j][k][l];
1894 double* aceFEMFunc =
new double[ sizeLocStiff * sizeLocStiff ];
1895 double* allDPhiBlas =
new double[ nmbAllDPhi * sizeLocStiff ];
1896 double* resTmp =
new double[ nmbAllDPhi * sizeLocStiff ];
1898 fillMatrixArray(Aloc, aceFEMFunc,
"cols");
1900 int offset = p * nmbAllDPhi;
1901 int offsetInArray = 0;
1902 for (
int i=0; i<nmbAllDPhi; i++) {
1903 fillMatrixArray( all_dPhiMat_Binv[ offset + i ], allDPhiBlas,
"rows",offsetInArray );
1904 offsetInArray += sizeLocStiff;
1907 teuchosBLAS.GEMM (Teuchos::NO_TRANS, Teuchos::NO_TRANS, sizeLocStiff, nmbAllDPhi, sizeLocStiff, 1., aceFEMFunc, sizeLocStiff, allDPhiBlas, sizeLocStiff, 0., resTmp, sizeLocStiff);
1909 double* locStiffMatBlas =
new double[ nmbAllDPhi * nmbAllDPhi ];
1911 teuchosBLAS.GEMM (Teuchos::TRANS, Teuchos::NO_TRANS, nmbAllDPhi, nmbAllDPhi, sizeLocStiff, 1., allDPhiBlas, sizeLocStiff, resTmp, sizeLocStiff, 0., locStiffMatBlas, nmbAllDPhi);
1913 for (
int i=0; i<nmbAllDPhi; i++) {
1914 for (
int j=0; j<nmbAllDPhi; j++)
1915 locStiffMat[i][j] += weights->at(p) * locStiffMatBlas[ j * nmbAllDPhi + i ];
1918 delete [] aceFEMFunc;
1919 delete [] allDPhiBlas;
1921 delete [] locStiffMatBlas;
1924 for (
int i=0; i<nmbScalarDPhi; i++) {
1925 for (
int d1=0; d1<dim; d1++) {
1926 Teuchos::Array<SC> value( nmbAllDPhi, 0. );
1927 Teuchos::Array<GO> indices( nmbAllDPhi, 0 );
1929 for (UN j=0; j < nmbScalarDPhi; j++){
1930 for (UN d2=0; d2<dim; d2++) {
1931 indices[counter] = GO ( dim * map->getGlobalElement( elements->at(T).at(j) ) + d2 );
1932 value[counter] = absDetB * locStiffMat[dim*i+d1][dim*j+d2];
1936 GO row = GO ( dim * map->getGlobalElement( elements->at(T).at(i) ) + d1 );
1937 A->insertGlobalValues( row, indices(), value() );
1943 for (
int i=0; i<3; i++)
1946 for (
int i=0; i<3; i++)
1950 for (
int i=0; i<3; i++){
1951 for (
int j=0; j<3; j++) {
1952 for (
int k=0; k<3; k++)
1953 delete [] Amat[i][j][k];
1954 delete [] Amat[i][j];
1961 if (callFillComplete)
1966template <
class SC,
class LO,
class GO,
class NO>
1967void FE<SC,LO,GO,NO>::assemblyElasticityStressesAceFEM(
int dim,
1969 MultiVectorPtr_Type &f,
1970 MultiVectorPtr_Type u,
1971 std::string material_model,
1975 bool callFillComplete){
1976 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
1977 UN FEloc = this->checkFE(dim,FEType);
1979 vec2D_int_ptr_Type elements = this->domainVec_.at(FEloc)->getElements();
1981 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
1983 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
1985 vec3D_dbl_ptr_Type dPhi;
1986 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
1997 Teuchos::BLAS<int, SC> teuchosBLAS;
1999 int nmbQuadPoints = dPhi->size();
2000 int nmbScalarDPhi = dPhi->at(0).size();
2001 int nmbAllDPhi = nmbScalarDPhi * dim;
2002 int nmbAllDPhiAllQaud = nmbQuadPoints * nmbAllDPhi;
2003 int sizeLocStiff = dim*dim;
2004 Teuchos::Array<SmallMatrix<SC> > dPhiMat( nmbAllDPhiAllQaud,
SmallMatrix<SC>(dim) );
2006 this->buildFullDPhi( dPhi, dPhiMat );
2009 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only for 3D.");
2011 else if (dim == 3) {
2014 if (!material_model.compare(
"Neo-Hooke"))
2015 v =
new double[466];
2016 else if(!material_model.compare(
"Mooney-Rivlin"))
2017 v =
new double[476];
2019 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Only Neo-Hooke and Mooney-Rivlin.");
2023 double** Pmat =
new double*[3];
2024 for (
int i=0; i<3; i++)
2025 Pmat[i] =
new double[3];
2027 double** F =
new double*[3];
2028 for (
int i=0; i<3; i++)
2029 F[i] =
new double[3];
2031 double**** Amat =
new double***[3];
2032 for (
int i=0; i<3; i++){
2033 Amat[i] =
new double**[3];
2034 for (
int j=0; j<3; j++) {
2035 Amat[i][j] =
new double*[3];
2036 for (
int k=0; k<3; k++)
2037 Amat[i][j][k] =
new double[3];
2041 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
2043 Teuchos::ArrayRCP<SC> fValues = f->getDataNonConst(0);
2045 Teuchos::Array<int> indices(3);
2046 for (
int T=0; T<elements->size(); T++) {
2049 detB = B.computeInverse(Binv);
2050 absDetB = std::fabs(detB);
2052 Teuchos::Array<SmallMatrix<SC> > all_dPhiMat_Binv( dPhiMat.size(),
SmallMatrix<SC>() );
2054 for (
int i=0; i<all_dPhiMat_Binv.size(); i++) {
2056 all_dPhiMat_Binv[i] = res;
2058 std::vector<double> locStresses( nmbAllDPhi, 0. );
2060 for (
int p=0; p<nmbQuadPoints; p++){
2064 Fmat[0][0] = 1.; Fmat[1][1] = 1.; Fmat[2][2] = 1.;
2066 for (
int i=0; i<nmbScalarDPhi; i++) {
2067 indices.at(0) = dim * elements->at(T).at(i);
2068 indices.at(1) = dim * elements->at(T).at(i) + 1;
2069 indices.at(2) = dim * elements->at(T).at(i) + 2;
2071 for (
int j=0; j<dim; j++) {
2072 tmpForScaling = all_dPhiMat_Binv[ p * nmbAllDPhi + dim * i + j ];
2073 SC v = uArray[indices.at(j)];
2074 tmpForScaling.scale( v );
2075 Fmat += tmpForScaling;
2079 for (
int i=0; i<Fmat.size(); i++) {
2080 for (
int j=0; j<Fmat.size(); j++) {
2081 F[i][j] = Fmat[i][j];
2084 if ( !material_model.compare(
"Neo-Hooke") )
2085 nh3d(v, &E, &nu, F, Pmat, Amat);
2086 else if ( !material_model.compare(
"Mooney-Rivlin") )
2087 mr3d(v, &E, &nu, &C, F, Pmat, Amat);
2089 double* aceFEMFunc =
new double[ sizeLocStiff * sizeLocStiff ];
2090 double* allDPhiBlas =
new double[ nmbAllDPhi * sizeLocStiff ];
2092 int offset = p * nmbAllDPhi;
2093 int offsetInArray = 0;
2094 for (
int i=0; i<nmbAllDPhi; i++) {
2095 fillMatrixArray( all_dPhiMat_Binv[ offset + i ], allDPhiBlas,
"rows",offsetInArray );
2096 offsetInArray += sizeLocStiff;
2100 double* fArray =
new double[ sizeLocStiff ];
2101 for (
int i=0; i<dim; i++) {
2102 for (
int j=0; j<dim; j++) {
2103 fArray[i * dim + j] = Pmat[i][j];
2107 double* res =
new double[ nmbAllDPhi ];
2108 teuchosBLAS.GEMV(Teuchos::TRANS, sizeLocStiff, nmbAllDPhi, 1., allDPhiBlas, sizeLocStiff, fArray, 1, 0., res, 1);
2109 for (
int i=0; i<locStresses.size(); i++) {
2110 locStresses[i] += weights->at(p) * res[i];
2113 delete [] aceFEMFunc;
2114 delete [] allDPhiBlas;
2120 for (
int i=0; i<nmbScalarDPhi; i++) {
2121 for (
int d1=0; d1<dim; d1++) {
2122 LO row = dim * elements->at(T).at(i) + d1;
2123 SC v = absDetB * locStresses[ dim * i + d1 ];
2131 for (
int i=0; i<3; i++)
2134 for (
int i=0; i<3; i++)
2138 for (
int i=0; i<3; i++){
2139 for (
int j=0; j<3; j++) {
2140 for (
int k=0; k<3; k++)
2141 delete [] Amat[i][j][k];
2142 delete [] Amat[i][j];
2152template <
class SC,
class LO,
class GO,
class NO>
2156 MultiVectorPtr_Type u,
2157 bool callFillComplete){
2159 TEUCHOS_TEST_FOR_EXCEPTION( u->getNumVectors()>1, std::logic_error,
"Implement for numberMV > 1 ." );
2160 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
2162 UN FEloc = this->
checkFE(dim,FEType);
2164 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
2166 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
2168 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
2170 vec3D_dbl_ptr_Type dPhi;
2171 vec2D_dbl_ptr_Type phi;
2172 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
2187 vec_dbl_Type v_i(dim);
2188 vec_dbl_Type v_j(dim);
2190 vec2D_dbl_Type uLoc( dim, vec_dbl_Type( weights->size() , -1. ) );
2191 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
2193 for (UN T=0; T<elements->numberElements(); T++) {
2196 detB = B.computeInverse(Binv);
2197 absDetB = std::fabs(detB);
2199 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2200 applyBTinv( dPhi, dPhiTrans, Binv );
2202 for (
int w=0; w<phi->size(); w++){
2203 for (
int d=0; d<dim; d++) {
2205 for (
int i=0; i < phi->at(0).size(); i++) {
2206 LO index = dim * elements->getElement(T).getNode(i) + d;
2207 uLoc[d][w] += uArray[index] * phi->at(w).at(i);
2212 for (UN i=0; i < phi->at(0).size(); i++) {
2213 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
2214 Teuchos::Array<GO> indices( dPhiTrans[0].size(), 0 );
2215 for (UN j=0; j < value.size(); j++) {
2216 for (UN w=0; w<dPhiTrans.size(); w++) {
2217 for (UN d=0; d<dim; d++){
2218 value[j] += weights->at(w) * uLoc[d][w] * (*phi)[w][i] * dPhiTrans[w][j][d];
2222 value[j] *= absDetB;
2223 if (this->setZeros_ && std::fabs(value[j]) < this->myeps_) {
2227 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) );
2228 GO glob_j = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) );
2230 for (UN d=0; d<dim; d++) {
2231 for (UN j=0; j < indices.size(); j++)
2232 indices[j] = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d );
2234 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d );
2235 A->insertGlobalValues( row, indices(), value() );
2241 if (callFillComplete)
2246template <
class SC,
class LO,
class GO,
class NO>
2250 MultiVectorPtr_Type u,
2251 bool callFillComplete){
2253 TEUCHOS_TEST_FOR_EXCEPTION( u->getNumVectors()>1, std::logic_error,
"Implement for numberMV > 1 ." );
2254 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
2255 UN FEloc = this->
checkFE(dim,FEType);
2257 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
2259 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
2261 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
2263 vec3D_dbl_ptr_Type dPhi;
2264 vec2D_dbl_ptr_Type phi;
2265 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
2279 vec_dbl_Type v_i(dim);
2280 vec_dbl_Type v_j(dim);
2282 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
2284 for (UN T=0; T<elements->numberElements(); T++) {
2287 detB = B.computeInverse(Binv);
2288 absDetB = std::fabs(detB);
2290 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2291 applyBTinv( dPhi, dPhiTrans, Binv );
2293 std::vector<SmallMatrix<SC> > duLoc( weights->size(),
SmallMatrix<SC>(dim) );
2295 for (
int w=0; w<dPhiTrans.size(); w++){
2296 for (
int d1=0; d1<dim; d1++) {
2297 for (
int i=0; i < dPhiTrans[0].size(); i++) {
2298 LO index = dim * elements->getElement(T).getNode(i) + d1;
2299 for (
int d2=0; d2<dim; d2++)
2300 duLoc[w][d2][d1] += uArray[index] * dPhiTrans[w][i][d2];
2305 for (UN i=0; i < phi->at(0).size(); i++) {
2306 for (UN d1=0; d1<dim; d1++) {
2307 Teuchos::Array<SC> value( dim*phi->at(0).size(), 0. );
2308 Teuchos::Array<GO> indices( dim*phi->at(0).size(), 0 );
2309 for (UN j=0; j < phi->at(0).size(); j++) {
2310 for (UN d2=0; d2<dim; d2++){
2311 for (UN w=0; w<phi->size(); w++) {
2312 value[ dim * j + d2 ] += weights->at(w) * duLoc[w][d2][d1] * (*phi)[w][i] * (*phi)[w][j];
2314 value[ dim * j + d2 ] *= absDetB;
2316 if (this->setZeros_ && std::fabs(value[ dim * j + d2 ]) < this->myeps_) {
2317 value[ dim * j + d2 ] = 0.;
2321 for (UN j=0; j < phi->at(0).size(); j++){
2322 for (UN d2=0; d2<dim; d2++){
2323 indices[ dim * j + d2 ] = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(j) ) + d2 );
2327 GO row = GO ( dim * map->getGlobalElement( elements->getElement(T).getNode(i) ) + d1 );
2328 A->insertGlobalValues( row, indices(), value() );
2332 if (callFillComplete)
2337template <
class SC,
class LO,
class GO,
class NO>
2340 std::string FETypeV,
2342 MultiVectorPtr_Type u,
2343 bool callFillComplete){
2345 TEUCHOS_TEST_FOR_EXCEPTION( u->getNumVectors()>1, std::logic_error,
"Implement for numberMV > 1 ." );
2346 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
2348 UN FEloc = this->
checkFE(dim,FEType);
2350 ElementsPtr_Type elements = this->domainVec_.at(1)->getElementsC();
2351 ElementsPtr_Type elementsVel = this->domainVec_.at(0)->getElementsC();
2353 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(1)->getPointsRepeated();
2355 MapConstPtr_Type map = this->domainVec_.at(1)->getMapRepeated();
2357 vec3D_dbl_ptr_Type dPhi;
2358 vec2D_dbl_ptr_Type phi,phiV;
2359 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
2374 vec_dbl_Type v_i(dim);
2375 vec_dbl_Type v_j(dim);
2377 vec2D_dbl_Type uLoc( dim, vec_dbl_Type( weights->size() , -1. ) );
2378 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
2380 for (UN T=0; T<elements->numberElements(); T++) {
2383 detB = B.computeInverse(Binv);
2384 absDetB = std::fabs(detB);
2386 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2387 applyBTinv( dPhi, dPhiTrans, Binv );
2389 for (
int w=0; w<phiV->size(); w++){
2390 for (
int d=0; d<dim; d++) {
2392 for (
int i=0; i < phiV->at(0).size(); i++) {
2393 LO index = dim * elementsVel->getElement(T).getNode(i) + d;
2394 uLoc[d][w] += uArray[index] * phiV->at(w).at(i);
2399 for (UN i=0; i < phi->at(0).size(); i++) {
2400 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
2401 Teuchos::Array<GO> indices( dPhiTrans[0].size(), 0 );
2402 for (UN j=0; j < value.size(); j++) {
2403 for (UN w=0; w<dPhiTrans.size(); w++) {
2404 for (UN d=0; d<dim; d++){
2405 value[j] += weights->at(w) * uLoc[d][w]* dPhiTrans[w][j][d] * (*phi)[w][i] ;
2408 value[j] *= absDetB;
2409 indices[j] = GO ( map->getGlobalElement( elements->getElement(T).getNode(j) ) );
2412 GO row = GO ( map->getGlobalElement( elements->getElement(T).getNode(i) ) );
2413 A->insertGlobalValues( row, indices(), value() );
2419 if (callFillComplete)
2424template <
class SC,
class LO,
class GO,
class NO>
2426 std::string FEType1,
2427 std::string FEType2,
2429 MatrixPtr_Type &Bmat,
2430 MatrixPtr_Type &BTmat,
2431 MapConstPtr_Type map1,
2432 MapConstPtr_Type map2,
2433 bool callFillComplete) {
2436 UN FEloc1 = this->
checkFE(dim,FEType1);
2437 UN FEloc2 = this->
checkFE(dim,FEType2);
2439 ElementsPtr_Type elements1 = this->domainVec_.at(FEloc1)->getElementsC();
2440 ElementsPtr_Type elements2 = this->domainVec_.at(FEloc2)->getElementsC();
2442 vec2D_dbl_ptr_Type pointsRep1 = this->domainVec_.at(FEloc1)->getPointsRepeated();
2444 MapConstPtr_Type mapping1 = this->domainVec_.at(FEloc1)->getMapRepeated();
2445 MapConstPtr_Type mapping2;
2447 if (FEType2 ==
"P0")
2448 mapping2 = this->domainVec_.at(FEloc2)->getElementMap();
2450 mapping2 = this->domainVec_.at(FEloc2)->getMapRepeated();
2452 vec3D_dbl_ptr_Type dPhi;
2453 vec2D_dbl_ptr_Type phi;
2454 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
2463 if (FEType2==
"P1-disc" && FEType1==
"Q2" )
2473 vec_dbl_Type v_i(dim);
2474 vec_dbl_Type v_j(dim);
2476 for (UN T=0; T<elements1->numberElements(); T++) {
2479 detB = B.computeInverse(Binv);
2480 absDetB = std::fabs(detB);
2482 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2483 applyBTinv( dPhi, dPhiTrans, Binv );
2485 for (UN i=0; i < phi->at(0).size(); i++) {
2486 Teuchos::Array<Teuchos::Array<SC> >valueVec( dim, Teuchos::Array<SC>( dPhiTrans[0].size(), 0. ) );
2487 Teuchos::Array<GO> indices( dPhiTrans[0].size(), 0 );
2489 for (UN j=0; j < valueVec[0].size(); j++) {
2490 for (UN w=0; w<dPhiTrans.size(); w++) {
2491 for (UN d=0; d<dim; d++)
2492 valueVec[d][j] += weights->at(w) * phi->at(w)[i] * dPhiTrans[w][j][d];
2494 for (UN d=0; d<dim; d++){
2495 valueVec[d][j] *= absDetB;
2496 if (this->setZeros_ && std::fabs(valueVec[d][j]) < this->myeps_) {
2497 valueVec[d][j] = 0.;
2501 for (UN d=0; d<dim; d++) {
2502 for (UN j=0; j < indices.size(); j++)
2503 indices[j] = GO ( dim * mapping1->getGlobalElement( elements1->getElement(T).getNode(j) ) + d );
2507 row = GO ( mapping2->getGlobalElement( T ) );
2509 row = GO ( mapping2->getGlobalElement( elements2->getElement(T).getNode(i) ) );
2510 Bmat->insertGlobalValues( row, indices(), valueVec[d]() );
2515 for (UN i=0; i < dPhiTrans[0].size(); i++) {
2517 Teuchos::Array<Teuchos::Array<SC> >valueVec( dim, Teuchos::Array<SC>( phi->at(0).size(), 0. ) );
2518 Teuchos::Array<GO> indices( phi->at(0).size(), 0 );
2519 for (UN j=0; j < valueVec[0].size(); j++) {
2520 for (UN w=0; w<dPhiTrans.size(); w++) {
2521 for (UN d=0; d<dim; d++)
2522 valueVec[d][j] += weights->at(w) * phi->at(w)[j] * dPhiTrans[w][i][d];
2524 for (UN d=0; d<dim; d++){
2525 valueVec[d][j] *= absDetB;
2526 if (this->setZeros_ && std::fabs(valueVec[d][j]) < this->myeps_) {
2527 valueVec[d][j] = 0.;
2532 for (UN j=0; j < indices.size(); j++){
2534 indices[j] = GO ( mapping2->getGlobalElement( T ) );
2536 indices[j] = GO ( mapping2->getGlobalElement( elements2->getElement(T).getNode(j) ) );
2538 for (UN d=0; d<dim; d++) {
2539 GO row = GO ( dim * mapping1->getGlobalElement( elements1->getElement(T).getNode(i) ) + d );
2540 BTmat->insertGlobalValues( row, indices(), valueVec[d]() );
2546 if (callFillComplete) {
2547 Bmat->fillComplete( map1, map2 );
2548 BTmat->fillComplete( map2, map1 );
2554template <
class SC,
class LO,
class GO,
class NO>
2556 std::string FEType1,
2557 std::string FEType2,
2559 MatrixPtr_Type &Bmat,
2560 MatrixPtr_Type &BTmat,
2561 MapConstPtr_Type map1,
2562 MapConstPtr_Type map2,
2563 bool callFillComplete) {
2566 UN FEloc1 = this->
checkFE(dim,FEType1);
2567 UN FEloc2 = this->
checkFE(dim,FEType2);
2569 ElementsPtr_Type elements1 = this->domainVec_.at(FEloc1)->getElementsC();
2570 ElementsPtr_Type elements2 = this->domainVec_.at(FEloc2)->getElementsC();
2572 vec2D_dbl_ptr_Type pointsRep1 = this->domainVec_.at(FEloc1)->getPointsRepeated();
2574 MapConstPtr_Type mapping1 = this->domainVec_.at(FEloc1)->getMapRepeated();
2575 MapConstPtr_Type mapping2;
2577 if (FEType2 ==
"P0")
2578 mapping2 = this->domainVec_.at(FEloc2)->getElementMap();
2580 mapping2 = this->domainVec_.at(FEloc2)->getMapRepeated();
2582 vec3D_dbl_ptr_Type dPhi;
2583 vec2D_dbl_ptr_Type phi;
2584 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
2593 if (FEType2==
"P1-disc" && FEType1==
"Q2" )
2603 vec_dbl_Type v_i(dim);
2604 vec_dbl_Type v_j(dim);
2606 Teuchos::Array<GO> colIndex( 1, 0 );
2607 Teuchos::Array<GO> rowIndex( 1, 0 );
2608 Teuchos::Array<SC> value(1, 0.);
2610 for (UN T=0; T<elements1->numberElements(); T++) {
2613 detB = B.computeInverse(Binv);
2614 absDetB = std::fabs(detB);
2616 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2617 applyBTinv( dPhi, dPhiTrans, Binv );
2619 for (UN i=0; i < phi->at(0).size(); i++) {
2621 rowIndex[0] = GO ( mapping2->getGlobalElement( T ) );
2623 rowIndex[0] = GO ( mapping2->getGlobalElement( elements2->getElement(T).getNode(i) ) );
2625 for (UN j=0; j < dPhiTrans[0].size(); j++) {
2626 for (UN d=0; d<dim; d++){
2628 for (UN w=0; w<dPhiTrans.size(); w++)
2629 value[0] += weights->at(w) * phi->at(w)[i] * dPhiTrans[w][j][d];
2630 value[0] *= absDetB;
2631 colIndex[0] = GO ( dim * mapping1->getGlobalElement( elements1->getElement(T).getNode(j) ) + d );
2632 Bmat->insertGlobalValues( rowIndex[0], colIndex(), value() );
2633 BTmat->insertGlobalValues( colIndex[0], rowIndex(), value() );
2640 if (callFillComplete) {
2641 Bmat->fillComplete( map1, map2 );
2642 BTmat->fillComplete( map2, map1 );
2648template <
class SC,
class LO,
class GO,
class NO>
2652 bool callFillComplete){
2654 TEUCHOS_TEST_FOR_EXCEPTION(FEType !=
"P1" && FEType !=
"Q1",std::logic_error,
"Only implemented for P1, Q1.");
2655 UN FEloc = this->
checkFE(dim,FEType);
2657 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
2659 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
2661 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
2663 vec2D_dbl_ptr_Type phi;
2665 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
2675 vec_dbl_Type v_i(dim);
2676 vec_dbl_Type v_j(dim);
2682 refElementSize = 0.5;
2683 refElementScale = 1./9.;
2686 refElementSize = 1./6.;
2687 refElementScale = 1./16.;
2690 else if(FEType==
"Q1"){
2692 refElementScale=1./64;
2696 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Q1 Only implemented for 3D.");
2700 for (UN T=0; T<elements->numberElements(); T++) {
2703 detB = B.computeDet( );
2704 absDetB = std::fabs(detB);
2706 for (UN i=0; i < phi->at(0).size(); i++) {
2707 Teuchos::Array<SC> value( phi->at(0).size(), 0. );
2708 Teuchos::Array<GO> indices( phi->at(0).size(), 0 );
2709 for (UN j=0; j < value.size(); j++) {
2710 for (UN w=0; w<phi->size(); w++) {
2711 value[j] += weights->at(w) * (*phi)[w][i] * (*phi)[w][j];
2713 value[j] *= absDetB;
2714 value[j] -= refElementSize * absDetB * refElementScale;
2716 indices[j] = map->getGlobalElement( elements->getElement(T).getNode(j) );
2719 GO row = map->getGlobalElement( elements->getElement(T).getNode(i) );
2720 A->insertGlobalValues( row, indices(), value() );
2725 if (callFillComplete)
2731template <
class SC,
class LO,
class GO,
class NO>
2735 CoeffFuncDbl_Type func,
2737 bool callFillComplete)
2739 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
2740 int FEloc = this->
checkFE(dim,FEType);
2742 DomainConstPtr_Type domain = this->domainVec_.at(FEloc);
2743 ElementsPtr_Type elements = domain->getElementsC();
2744 vec2D_dbl_ptr_Type pointsRep = domain->getPointsRepeated();
2745 MapConstPtr_Type map = domain->getMapRepeated();
2747 vec3D_dbl_ptr_Type dPhi;
2748 vec_dbl_ptr_Type weightsDPhi = Teuchos::rcp(
new vec_dbl_Type(0));
2749 vec2D_dbl_ptr_Type quadPts;
2766 vec_dbl_ptr_Type dist = domain->getDistancesToInterface();
2769 double val, value1_j, value2_j , value1_i, value2_i;
2770 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0);
2772 double distance1, distance2, distance3;
2773 vec_dbl_Type distance_mean(1);
2774 for (
int T = 0; T < elements->numberElements(); T++)
2776 p1 = pointsRep->at(elements->getElement(T).getNode(0));
2777 p2 = pointsRep->at(elements->getElement(T).getNode(1));
2778 p3 = pointsRep->at(elements->getElement(T).getNode(2));
2780 distance1 = dist->at(elements->getElement(T).getNode(0));
2781 distance2 = dist->at(elements->getElement(T).getNode(1));
2782 distance3 = dist->at(elements->getElement(T).getNode(2));
2784 distance_mean.at(0) = (distance1 + distance2 + distance3)/3.0;
2785 double funcvalue = func(&distance_mean.at(0),parameters);
2788 detB = B.computeInverse(Binv);
2789 absDetB = std::fabs(detB);
2792 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2793 applyBTinv( dPhi, dPhiTrans, Binv );
2795 for (
int i = 0; i < dPhi->at(0).size(); i++)
2797 Teuchos::Array<SC> value( 1, 0. );
2798 Teuchos::Array<GO> indices( 1, 0 );
2800 for (
int j = 0; j < dPhi->at(0).size(); j++)
2803 for (
int k = 0; k < dPhi->size(); k++)
2806 value1_j = dPhiTrans.at(k).at(j).at(0);
2807 value2_j = dPhiTrans.at(k).at(j).at(1);
2809 value1_i = dPhiTrans.at(k).at(i).at(0);
2810 value2_i = dPhiTrans.at(k).at(i).at(1);
2812 val = val + funcvalue * weightsDPhi->at(k) * ( value1_j*value1_i + value2_j*value2_i );
2814 val = absDetB * val;
2817 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
2818 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
2819 indices[0] = glob_j;
2822 A->insertGlobalValues(glob_i, indices(), value());
2824 indices[0] = glob_j;
2825 A->insertGlobalValues(glob_i+1, indices(), value());
2829 if (callFillComplete)
2836 double val, value1_j, value2_j ,value3_j, value1_i, value2_i ,value3_i;
2838 long long glob_i, glob_j;
2839 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
2841 double distance1, distance2, distance3, distance4;
2842 vec_dbl_Type distance_mean(1);
2843 for (
int T = 0; T < elements->numberElements(); T++)
2845 p1 = pointsRep->at(elements->getElement(T).getNode(0));
2846 p2 = pointsRep->at(elements->getElement(T).getNode(1));
2847 p3 = pointsRep->at(elements->getElement(T).getNode(2));
2848 p4 = pointsRep->at(elements->getElement(T).getNode(3));
2850 distance1 = dist->at(elements->getElement(T).getNode(0));
2851 distance2 = dist->at(elements->getElement(T).getNode(1));
2852 distance3 = dist->at(elements->getElement(T).getNode(2));
2853 distance4 = dist->at(elements->getElement(T).getNode(3));
2855 distance_mean.at(0) = (distance1 + distance2 + distance3 + distance4)/4.0;
2856 double funcvalue = func(&distance_mean.at(0),parameters);
2859 detB = B.computeInverse(Binv);
2860 absDetB = std::fabs(detB);
2863 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2864 applyBTinv( dPhi, dPhiTrans, Binv );
2866 for (
int i = 0; i < dPhi->at(0).size(); i++)
2868 Teuchos::Array<SC> value( 1, 0. );
2869 Teuchos::Array<GO> indices( 1, 0 );
2871 for (
int j = 0; j < dPhi->at(0).size(); j++)
2874 for (
int k = 0; k < dPhi->size(); k++)
2876 value1_j = dPhiTrans.at(k).at(j).at(0);
2877 value2_j = dPhiTrans.at(k).at(j).at(1);
2878 value3_j = dPhiTrans.at(k).at(j).at(2);
2880 value1_i = dPhiTrans.at(k).at(i).at(0);
2881 value2_i = dPhiTrans.at(k).at(i).at(1);
2882 value3_i = dPhiTrans.at(k).at(i).at(2);
2884 val = val + funcvalue * weightsDPhi->at(k) * (value1_j*value1_i + value2_j*value2_i + value3_j*value3_i);
2886 val = absDetB * val;
2889 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
2890 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
2891 indices[0] = glob_j;
2892 A->insertGlobalValues(glob_i, indices(), value());
2894 indices[0] = glob_j;
2895 A->insertGlobalValues(glob_i+1, indices(), value());
2897 indices[0] = glob_j;
2898 A->insertGlobalValues(glob_i+2, indices(), value());
2903 if (callFillComplete)
2913template <
class SC,
class LO,
class GO,
class NO>
2917 CoeffFunc_Type func,
2919 bool callFillComplete)
2922 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
2923 int FEloc = this->
checkFE(dim,FEType);
2925 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
2926 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
2927 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
2929 vec3D_dbl_ptr_Type dPhi;
2930 vec_dbl_ptr_Type weightsDPhi = Teuchos::rcp(
new vec_dbl_Type(0));
2931 vec2D_dbl_ptr_Type quadPts;
2949 double v11, v12, v21, v22, value1_j, value2_j , value1_i, value2_i;
2950 double e_11_j_1,e_12_j_1,e_21_j_1,e_22_j_1;
2951 double e_11_j_2,e_12_j_2,e_21_j_2,e_22_j_2;
2952 double e_11_i_1,e_12_i_1,e_21_i_1,e_22_i_1;
2953 double e_11_i_2,e_12_i_2,e_21_i_2,e_22_i_2;
2962 long long glob_i, glob_j;
2963 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0);
2966 for (
int T = 0; T < elements->numberElements(); T++)
2968 p1 = pointsRep->at(elements->getElement(T).getNode(0));
2969 p2 = pointsRep->at(elements->getElement(T).getNode(1));
2970 p3 = pointsRep->at(elements->getElement(T).getNode(2));
2973 detB = B.computeInverse(Binv);
2974 absDetB = std::fabs(detB);
2978 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
2979 applyBTinv( dPhi, dPhiTrans, Binv );
2981 for (
int i = 0; i < dPhi->at(0).size(); i++)
2983 Teuchos::Array<SC> value11( 1, 0. );
2984 Teuchos::Array<SC> value12( 1, 0. );
2985 Teuchos::Array<SC> value21( 1, 0. );
2986 Teuchos::Array<SC> value22( 1, 0. );
2987 Teuchos::Array<GO> indices( 1, 0 );
2989 for (
int j=0; j < dPhi->at(0).size(); j++)
2991 v11 = 0.0;v12 = 0.0;v21 = 0.0;v22 = 0.0;
2992 for (
int k = 0; k < dPhi->size(); k++)
2997 for (
int r=0; r<2; r++) {
2998 xy[0] += B[0][r]*quadPts->at(k).at(r);
2999 xy[1] += B[1][r]*quadPts->at(k).at(r);
3004 value1_j = dPhiTrans.at(k).at(j).at(0);
3005 value2_j = dPhiTrans.at(k).at(j).at(1);
3007 value1_i = dPhiTrans.at(k).at(i).at(0);
3008 value2_i = dPhiTrans.at(k).at(i).at(1);
3010 tmpRes1[0][0] = value1_j;
3011 tmpRes1[0][1] = value2_j;
3015 tmpRes2[0][0] = value1_j;
3017 tmpRes2[1][0] = value2_j;
3020 tmpRes1.add(tmpRes2,e1j);
3022 e1i[0][0] = value1_i;
3023 e1i[0][1] = value2_i;
3028 tmpRes1[1][0] = value1_j;
3029 tmpRes1[1][1] = value2_j;
3032 tmpRes2[0][1] = value1_j;
3034 tmpRes2[1][1] = value2_j;
3036 tmpRes1.add(tmpRes2,e2j);
3038 e2i[1][0] = value1_i;
3039 e2i[1][1] = value2_i;
3041 double funcvalue = func(&xy.at(0),parameters);
3042 v11 = v11 + funcvalue * weightsDPhi->at(k) * e1i.innerProduct(e1j);
3043 v12 = v12 + funcvalue * weightsDPhi->at(k) * e1i.innerProduct(e2j);
3044 v21 = v21 + funcvalue * weightsDPhi->at(k) * e2i.innerProduct(e1j);
3045 v22 = v22 + funcvalue * weightsDPhi->at(k) * e2i.innerProduct(e2j);
3049 v11 = absDetB * v11;
3050 v12 = absDetB * v12;
3051 v21 = absDetB * v21;
3052 v22 = absDetB * v22;
3059 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
3060 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
3061 indices[0] = glob_j;
3063 A->insertGlobalValues(glob_i, indices(), value11());
3064 A->insertGlobalValues(glob_i+1, indices(), value21());
3066 indices[0] = glob_j;
3067 A->insertGlobalValues(glob_i, indices(), value12());
3068 A->insertGlobalValues(glob_i+1, indices(), value22());
3072 if (callFillComplete)
3079 double v11, v12, v13, v21, v22, v23, v31, v32, v33, value1_j, value2_j, value3_j , value1_i, value2_i, value3_i;
3088 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
3089 vec_dbl_Type xyz(3);
3091 for (
int T = 0; T < elements->numberElements(); T++)
3093 p1 = pointsRep->at(elements->getElement(T).getNode(0));
3094 p2 = pointsRep->at(elements->getElement(T).getNode(1));
3095 p3 = pointsRep->at(elements->getElement(T).getNode(2));
3096 p4 = pointsRep->at(elements->getElement(T).getNode(3));
3099 detB = B.computeInverse(Binv);
3100 absDetB = std::fabs(detB);
3103 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
3104 applyBTinv( dPhi, dPhiTrans, Binv );
3106 for (
int i = 0; i < dPhi->at(0).size(); i++)
3108 Teuchos::Array<SC> value11( 1, 0. );
3109 Teuchos::Array<SC> value12( 1, 0. );
3110 Teuchos::Array<SC> value13( 1, 0. );
3111 Teuchos::Array<SC> value21( 1, 0. );
3112 Teuchos::Array<SC> value22( 1, 0. );
3113 Teuchos::Array<SC> value23( 1, 0. );
3114 Teuchos::Array<SC> value31( 1, 0. );
3115 Teuchos::Array<SC> value32( 1, 0. );
3116 Teuchos::Array<SC> value33( 1, 0. );
3117 Teuchos::Array<GO> indices( 1, 0 );
3119 for (
int j = 0; j < dPhi->at(0).size(); j++)
3121 v11 = 0.0;v12 = 0.0;v13 = 0.0;v21 = 0.0;v22 = 0.0;v23 = 0.0;v31 = 0.0;v32 = 0.0;v33 = 0.0;
3122 for (
int k = 0; k < dPhi->size(); k++)
3125 xyz[0]=0.; xyz[1]=0.; xyz[2]=0.;
3126 for (
int r = 0; r < 3; r++)
3128 xyz[0] += B[0][r]*quadPts->at(k).at(r);
3129 xyz[1] += B[1][r]*quadPts->at(k).at(r);
3130 xyz[2] += B[2][r]*quadPts->at(k).at(r);
3138 value1_j = dPhiTrans.at(k).at(j).at(0);
3139 value2_j = dPhiTrans.at(k).at(j).at(1);
3140 value3_j = dPhiTrans.at(k).at(j).at(2);
3143 value1_i = dPhiTrans.at(k).at(i).at(0);
3144 value2_i = dPhiTrans.at(k).at(i).at(1);
3145 value3_i = dPhiTrans.at(k).at(i).at(2);
3148 e1j[0][0] = 2.*value1_j;
3149 e1j[0][1] = value2_j;
3150 e1j[0][2] = value3_j;
3151 e1j[1][0] = value2_j;
3152 e1j[2][0] = value3_j;
3154 e1i[0][0] = value1_i;
3155 e1i[0][1] = value2_i;
3156 e1i[0][2] = value3_i;
3159 e2j[1][0] = value1_j;
3160 e2j[1][1] = 2.*value2_j;
3161 e2j[1][2] = value3_j;
3162 e2j[0][1] = value1_j;
3163 e2j[2][1] = value3_j;
3165 e2i[1][0] = value1_i;
3166 e2i[1][1] = value2_i;
3167 e2i[1][2] = value3_i;
3170 e3j[2][0] = value1_j;
3171 e3j[2][1] = value2_j;
3172 e3j[2][2] = 2.*value3_j;
3173 e3j[0][2] = value1_j;
3174 e3j[1][2] = value2_j;
3176 e3i[2][0] = value1_i;
3177 e3i[2][1] = value2_i;
3178 e3i[2][2] = value3_i;
3180 double funcvalue = func(&xyz.at(0),parameters);
3182 v11 = v11 + funcvalue * weightsDPhi->at(k) * e1i.innerProduct(e1j);
3183 v12 = v12 + funcvalue * weightsDPhi->at(k) * e1i.innerProduct(e2j);
3184 v13 = v13 + funcvalue * weightsDPhi->at(k) * e1i.innerProduct(e3j);
3186 v21 = v21 + funcvalue * weightsDPhi->at(k) * e2i.innerProduct(e1j);
3187 v22 = v22 + funcvalue * weightsDPhi->at(k) * e2i.innerProduct(e2j);
3188 v23 = v23 + funcvalue * weightsDPhi->at(k) * e2i.innerProduct(e3j);
3190 v31 = v31 + funcvalue * weightsDPhi->at(k) * e3i.innerProduct(e1j);
3191 v32 = v32 + funcvalue * weightsDPhi->at(k) * e3i.innerProduct(e2j);
3192 v33 = v33 + funcvalue * weightsDPhi->at(k) * e3i.innerProduct(e3j);
3196 v11 = absDetB * v11;
3197 v12 = absDetB * v12;
3198 v13 = absDetB * v13;
3199 v21 = absDetB * v21;
3200 v22 = absDetB * v22;
3201 v23 = absDetB * v23;
3202 v31 = absDetB * v31;
3203 v32 = absDetB * v32;
3204 v33 = absDetB * v33;
3216 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
3217 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
3218 indices[0] = glob_j;
3219 A->insertGlobalValues(glob_i, indices(), value11());
3220 A->insertGlobalValues(glob_i+1, indices(), value21());
3221 A->insertGlobalValues(glob_i+2, indices(), value31());
3224 indices[0] = glob_j;
3225 A->insertGlobalValues(glob_i, indices(), value12());
3226 A->insertGlobalValues(glob_i+1, indices(), value22());
3227 A->insertGlobalValues(glob_i+2, indices(), value32());
3230 indices[0] = glob_j;
3231 A->insertGlobalValues(glob_i, indices(), value13());
3232 A->insertGlobalValues(glob_i+1, indices(), value23());
3233 A->insertGlobalValues(glob_i+2, indices(), value33());
3237 if (callFillComplete)
3246template <
class SC,
class LO,
class GO,
class NO>
3247double FE<SC,LO,GO,NO>::assemblyAbsorbingBoundaryPaper(
int dim,
3249 MultiVectorPtr_Type f,
3250 MultiVectorPtr_Type u_rep,
3251 vec_dbl_Type flowRate_vec,
3252 std::vector<SC>& funcParameter,
3254 double areaOutlet_init,
3255 double areaOutlet_T,
3256 ParameterListPtr_Type params,
3259 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
3261 ElementsPtr_Type elementsPressure = this->domainVec_.at(FEloc+1)->getElementsC();
3263 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
3265 vec2D_dbl_ptr_Type phi;
3268 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
3273 vec2D_dbl_ptr_Type quadPoints;
3274 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
3278 double poissonRatio=params->sublist(
"Parameter Fluid").get(
"Poisson Ratio",0.49);
3279 int flagInlet = params->sublist(
"General").get(
"Flag Inlet Fluid", 4);
3280 int flagOutlet = params->sublist(
"General").get(
"Flag Outlet Fluid", 5);
3282 double normalScale = params->sublist(
"Parameter Fluid").get(
"Normal Scale",1.0);
3283 double E = params->sublist(
"Parameter Fluid").get(
"E",12.0);
3284 double wallThickness = params->sublist(
"Parameter Fluid").get(
"Wall thickness",0.0006);
3285 double density = params->sublist(
"Parameter Fluid").get(
"Density",1000.0);
3286 double p_ref_input = params->sublist(
"Parameter Fluid").get(
"Reference fluid pressure",10666.);
3288 double rampTime = params->sublist(
"Parameter Fluid").get(
"Max Ramp Time",0.1);
3289 double unsteadyStart = params->sublist(
"Parameter Fluid").get(
"Unsteady Start",0.2);
3290 double flowRateInput = params->sublist(
"Parameter Fluid").get(
"Flowrate",3.0);
3292 double bcRamp = params->sublist(
"Parameter Fluid").get(
"BC Ramp",0.1);
3300 vec_dbl_Type b(dim);
3302 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
3304 std::vector<double> valueFunc(dim);
3306 double flowRateOutlet=0.;
3307 double flowRateInlet=0.;
3309 this->assemblyFlowRate(dim, flowRateInlet, FEType , dim, flagInlet , u_rep);
3311 int isNeg = this->assemblyFlowRate(dim, flowRateOutlet, FEType , dim, flagOutlet , u_rep);
3313 double flowRateOutletAveraged = (flowRate_vec[0] + flowRate_vec[1]) / 2.;
3315 double areaOutlet = 0.;
3316 this->assemblyArea(dim, areaOutlet, flagOutlet);
3318 double areaInlet =0.;
3319 this->assemblyArea(dim, areaInlet, flagInlet);
3322 if(funcParameter[0] < unsteadyStart)
3323 beta = ((wallThickness* E)/(1.-pow(poissonRatio,2))) * (M_PI/areaOutlet_init ) ;
3325 beta = ((wallThickness* E)/(1.-pow(poissonRatio,2))) * (M_PI/areaOutlet_T ) ;
3328 funcParameter.push_back(p_ref_input);
3329 funcParameter.push_back(bcRamp);
3330 funcParameter.push_back(flagOutlet);
3331 SC* paramsFunc = &(funcParameter[0]);
3332 vec_dbl_Type x_tmp(dim,0.);
3333 paramsFunc[ funcParameter.size() - 1 ] =flagOutlet;
3334 paramsFunc[ 1 ] = p_ref_input;
3335 func( &x_tmp[0], &valueFunc[0], paramsFunc);
3336 double p_ref = valueFunc[0];
3337 if(funcParameter[0]+1e-12 >= unsteadyStart){
3338 p_ref = p_ref - std::pow( (std::sqrt(density)/(2*std::sqrt(2)) * flowRateInput/areaOutlet_T + std::sqrt(beta*std::sqrt(areaOutlet_T))),2) + beta*std::sqrt(areaOutlet_T);
3340 if(this->domainVec_.at(0)->getComm()->getRank()==0){
3341 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3342 std::cout <<
" ---------------- Start of unsteady phase ---------------- " <<std::endl;
3343 std::cout <<
" Reference pressure adjusted from " << p_ref_input <<
" to " << p_ref <<std::endl;
3348 double flowRateUse = flowRateOutlet;
3349 if(params->sublist(
"Parameter Fluid").get(
"Average Flowrate",
false) )
3350 flowRateUse = flowRateOutletAveraged;
3355 double A_bar = 1./((std::sqrt(beta*std::sqrt(areaOutlet_init)+p_ref_input)-std::sqrt(beta*std::sqrt(areaOutlet_init)))*2.*std::sqrt(2.)*(1./std::sqrt(density))*(1./flowRateInput));
3358 if(funcParameter[0] < unsteadyStart)
3359 h_x= std::pow( (std::sqrt(density)/(2*std::sqrt(2)) * flowRateUse/A_bar + std::sqrt(beta*std::sqrt(areaOutlet_init))),2) - beta*std::sqrt(areaOutlet_init);
3361 h_x= std::pow( (std::sqrt(density)/(2*std::sqrt(2)) * flowRateUse/areaOutlet + std::sqrt(beta*std::sqrt(areaOutlet_T))),2) - beta*std::sqrt(areaOutlet_T) + p_ref;
3365 if(this->domainVec_.at(0)->getComm()->getRank()==0){
3366 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3367 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3368 std::cout <<
" Absorbing Boundary Condition " <<std::endl;
3369 std::cout <<
" Input p_ref: " << p_ref_input <<std::endl;
3370 std::cout <<
" Adjusted p_ref: " << p_ref <<std::endl;
3371 std::cout <<
" Unsteady start time_ " << unsteadyStart <<std::endl;
3372 std::cout <<
" Volmetric flow Inlet: " << flowRateInlet <<std::endl;
3373 std::cout <<
" Volmetric flow Outlet: " << flowRateOutlet <<std::endl;
3374 std::cout <<
" Averaged volmetric flow Outlet: " << flowRateOutletAveraged <<std::endl;
3375 std::cout <<
" beta per Input: " << beta <<std::endl;
3376 std::cout <<
" Area_init outlet: " << areaOutlet_init <<std::endl;
3377 std::cout <<
" Area_init outlet_T: " << areaOutlet_T <<std::endl;
3378 std::cout <<
" Area inlet: " << areaInlet <<std::endl;
3379 std::cout <<
" Area outlet: " << areaOutlet <<std::endl;
3380 std::cout <<
" A_bar: " << A_bar <<std::endl;
3381 std::cout <<
" Flowrate was negative: " << isNeg <<std::endl;
3382 std::cout <<
" Value h_x at outlet: " << h_x <<std::endl;
3383 std::cout <<
" --------------------------------------------------------- " <<std::endl;
3384 std::cout <<
" --------------------------------------------------------- " <<std::endl;
3388 for (UN T=0; T<elements->numberElements(); T++) {
3390 ElementsPtr_Type subEl = fe.getSubElements();
3391 for (
int surface=0; surface<fe.numSubElements(); surface++) {
3393 if(subEl->getDimension() == dim-1 ){
3394 if(feSub.getFlag() == flagOutlet){
3395 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
3396 vec_int_Type nodeListP = elementsPressure->getElement(T).getSubElements()->getElement(surface).getVectorNodeListNonConst();
3397 int numNodes_T = nodeList.size();
3398 vec_dbl_Type solution_u = this->getSolution(nodeList, u_rep,dim);
3399 vec2D_dbl_Type nodes;
3400 nodes = this->getCoordinates(nodeList, pointsRep);
3402 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
3404 double norm_v_E = 1.;
3406 v_E[0] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3407 v_E[1] = -(pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0));
3408 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2));
3413 p1[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0);
3414 p1[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3415 p1[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[1]).at(2);
3417 p2[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[2]).at(0);
3418 p2[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[2]).at(1);
3419 p2[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[2]).at(2);
3421 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
3422 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
3423 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
3425 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2)+pow(v_E[2],2));
3434 elScaling = B.computeScaling( );
3438 for (UN i=0; i < numNodes_T; i++) {
3441 Teuchos::Array<SC> value(0);
3442 value.resize( dim, 0. );
3444 for (UN w=0; w<phi->size(); w++) {
3445 for (
int j=0; j<dim; j++){
3446 value[j] += weights->at(w) *normalScale*v_E[j]/norm_v_E *h_x*(*phi)[w][i];
3451 for (
int j=0; j<value.size(); j++)
3452 valuesF[ dim * nodeList[ i ] + j ] += value[j] * elScaling;
3464template <
class SC,
class LO,
class GO,
class NO>
3465double FE<SC,LO,GO,NO>::assemblyAbsorbingBoundary(
int dim,
3467 MultiVectorPtr_Type f,
3468 MultiVectorPtr_Type u_rep,
3469 vec_dbl_Type flowRate_vec,
3470 std::vector<SC>& funcParameter,
3472 double areaOutlet_init,
3473 double areaOutlet_T,
3474 ParameterListPtr_Type params,
3477 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
3479 ElementsPtr_Type elementsPressure = this->domainVec_.at(FEloc+1)->getElementsC();
3481 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
3483 vec2D_dbl_ptr_Type phi;
3486 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
3491 vec2D_dbl_ptr_Type quadPoints;
3492 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
3496 double poissonRatio=params->sublist(
"Parameter Fluid").get(
"Poisson Ratio",0.49);
3497 int flagInlet = params->sublist(
"General").get(
"Flag Inlet Fluid", 4);
3498 int flagOutlet = params->sublist(
"General").get(
"Flag Outlet Fluid", 5);
3500 double normalScale = params->sublist(
"Parameter Fluid").get(
"Normal Scale",1.0);
3502 double density = params->sublist(
"Parameter Fluid").get(
"Density",1.0);
3503 double p_ref_input = params->sublist(
"Parameter Fluid").get(
"Reference fluid pressure",10666.);
3505 double rampTime = params->sublist(
"Parameter Fluid").get(
"Max Ramp Time",0.1);
3506 double unsteadyStart = params->sublist(
"Parameter Fluid").get(
"Heart Beat Start",0.2);
3507 double flowRateInput = params->sublist(
"Parameter Fluid").get(
"Flowrate",3.0e-06);
3509 double bcRamp = params->sublist(
"Parameter Fluid").get(
"BC Ramp",0.1);
3517 vec_dbl_Type b(dim);
3519 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
3521 std::vector<double> valueFunc(dim);
3523 double flowRateOutlet=0.;
3524 double flowRateInlet=0.;
3526 this->assemblyFlowRate(dim, flowRateInlet, FEType , dim, flagInlet , u_rep);
3527 int isNeg = this->assemblyFlowRate(dim, flowRateOutlet, FEType , dim, flagOutlet , u_rep);
3529 double flowRateOutletAveraged = (flowRate_vec[0] + flowRate_vec[1]) / 2.;
3531 double areaOutlet = 0.;
3532 this->assemblyArea(dim, areaOutlet, flagOutlet);
3534 double areaInlet =0.;
3535 this->assemblyArea(dim, areaInlet, flagInlet);
3539 double E = params->sublist(
"Parameter Fluid").get(
"E",12.0);
3540 double wallThickness = params->sublist(
"Parameter Fluid").get(
"Wall thickness",0.0006);
3542 beta = ((wallThickness* E)/(1.-pow(poissonRatio,2))) * (M_PI/areaOutlet_init ) ;
3545 funcParameter.push_back(p_ref_input);
3546 funcParameter.push_back(bcRamp);
3547 funcParameter.push_back(flagOutlet);
3549 SC* paramsFunc = &(funcParameter[0]);
3550 vec_dbl_Type x_tmp(dim,0.);
3555 func( &x_tmp[0], &valueFunc[0], paramsFunc);
3556 double p_ref = valueFunc[0];
3562 double flowRateUse = flowRateOutlet;
3563 if(params->sublist(
"Parameter Fluid").get(
"Average Flowrate",
false) )
3564 flowRateUse = flowRateOutletAveraged;
3569 if(this->domainVec_.at(0)->getComm()->getRank()==0){
3570 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3571 std::cout <<
" ---------------- computing p_ref ---------------- " <<std::endl;
3572 std::cout <<
" Reference pressure adjusted from " << p_ref_input <<
" to " << p_ref <<std::endl;
3576 double h_x = pow( (sqrt(density)/(2*sqrt(2)) * flowRateUse/areaOutlet + sqrt(beta*sqrt(areaOutlet_init))),2) - beta*sqrt(areaOutlet_init)+p_ref;
3580 if(this->domainVec_.at(0)->getComm()->getRank()==0){
3581 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3582 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3583 std::cout <<
" Absorbing Boundary Condition " <<std::endl;
3584 std::cout <<
" Input p_ref: " << p_ref_input <<std::endl;
3585 std::cout <<
" Adjusted p_ref: " << p_ref <<std::endl;
3586 std::cout <<
" Volmetric flow Inlet: " << flowRateInlet <<std::endl;
3587 std::cout <<
" Volmetric flow Outlet: " << flowRateOutlet <<std::endl;
3588 std::cout <<
" Averaged volmetric flow Outlet: " << flowRateOutletAveraged <<std::endl;
3589 std::cout <<
" beta per Input: " << beta <<std::endl;
3590 std::cout <<
" Area_init outlet: " << areaOutlet_init <<std::endl;
3591 std::cout <<
" Area inlet: " << areaInlet <<std::endl;
3592 std::cout <<
" Area outlet: " << areaOutlet <<std::endl;
3593 std::cout <<
" Value h_x at outlet: " << h_x <<std::endl;
3594 std::cout <<
" --------------------------------------------------------- " <<std::endl;
3595 std::cout <<
" --------------------------------------------------------- " <<std::endl;
3599 for (UN T=0; T<elements->numberElements(); T++) {
3601 ElementsPtr_Type subEl = fe.getSubElements();
3602 for (
int surface=0; surface<fe.numSubElements(); surface++) {
3604 if(subEl->getDimension() == dim-1 ){
3605 if(feSub.getFlag() == flagOutlet){
3606 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
3607 vec_int_Type nodeListP = elementsPressure->getElement(T).getSubElements()->getElement(surface).getVectorNodeListNonConst();
3608 int numNodes_T = nodeList.size();
3609 vec_dbl_Type solution_u = this->getSolution(nodeList, u_rep,dim);
3610 vec2D_dbl_Type nodes;
3611 nodes = this->getCoordinates(nodeList, pointsRep);
3613 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
3615 double norm_v_E = 1.;
3617 v_E[0] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3618 v_E[1] = -(pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0));
3619 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2));
3624 p1[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0);
3625 p1[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3626 p1[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[1]).at(2);
3628 p2[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[2]).at(0);
3629 p2[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[2]).at(1);
3630 p2[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[2]).at(2);
3632 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
3633 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
3634 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
3636 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2)+pow(v_E[2],2));
3642 elScaling = B.computeScaling( );
3644 for (UN i=0; i < numNodes_T; i++) {
3647 Teuchos::Array<SC> value(0);
3648 value.resize( dim, 0. );
3650 for (UN w=0; w<phi->size(); w++) {
3651 for (
int j=0; j<dim; j++){
3652 value[j] += weights->at(w) *normalScale*v_E[j]/norm_v_E *h_x*(*phi)[w][i];
3657 for (
int j=0; j<value.size(); j++)
3658 valuesF[ dim * nodeList[ i ] + j ] += value[j] * elScaling;
3671template <
class SC,
class LO,
class GO,
class NO>
3672double FE<SC,LO,GO,NO>::assemblyAbsorbingResistanceBoundary(
int dim,
3674 MultiVectorPtr_Type f,
3675 MultiVectorPtr_Type u_rep,
3676 vec_dbl_Type flowRate_vec,
3677 std::vector<SC>& funcParameter,
3679 double areaOutlet_init,
3680 ParameterListPtr_Type params,
3683 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
3685 ElementsPtr_Type elementsPressure = this->domainVec_.at(FEloc+1)->getElementsC();
3687 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
3689 vec2D_dbl_ptr_Type phi;
3692 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
3697 vec2D_dbl_ptr_Type quadPoints;
3698 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
3702 double poissonRatio=params->sublist(
"Parameter Fluid").get(
"Poisson Ratio",0.49);
3703 double viscosity=params->sublist(
"Parameter Fluid").get(
"Viscosity",1.0e-06);
3704 int flagInlet = params->sublist(
"General").get(
"Flag Inlet Fluid", 4);
3705 int flagOutlet = params->sublist(
"General").get(
"Flag Outlet Fluid", 5);
3707 double normalScale = params->sublist(
"Parameter Fluid").get(
"Normal Scale",1.0);
3708 double E = params->sublist(
"Parameter Fluid").get(
"E",12.0);
3709 double wallThickness = params->sublist(
"Parameter Fluid").get(
"Wall thickness",0.001);
3710 double density = params->sublist(
"Parameter Fluid").get(
"Density",1000.0);
3711 double p_ref_input = params->sublist(
"Parameter Fluid").get(
"Reference fluid pressure",8000.);
3712 double resistanceRamp = params->sublist(
"Parameter Fluid").get(
"Resistance Ramp",2.);
3713 double resistance = params->sublist(
"Parameter Fluid").get(
"Resistance",1.0);
3720 vec_dbl_Type b(dim);
3722 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
3724 std::vector<double> valueFunc(dim);
3726 double flowRateOutlet=0.;
3727 double flowRateInlet=0.;
3729 this->assemblyFlowRate(dim, flowRateInlet, FEType , dim, flagInlet , u_rep);
3730 this->assemblyFlowRate(dim, flowRateOutlet, FEType , dim, flagOutlet , u_rep);
3732 double flowRateOutletAveraged = (flowRate_vec[0] + flowRate_vec[1]) / 2.;
3734 double areaOutlet = 0.;
3735 this->assemblyArea(dim, areaOutlet, flagOutlet);
3737 double areaInlet =0.;
3738 this->assemblyArea(dim, areaInlet, flagInlet);
3740 double beta = (((wallThickness* E)/(1-pow(poissonRatio,2))) * M_PI/areaOutlet_init ) *sqrt(areaOutlet_init);
3742 SC* paramsFunc = &(funcParameter[0]);
3743 vec_dbl_Type x_tmp(dim,0.);
3744 paramsFunc[ funcParameter.size() - 1 ] =flagOutlet;
3748 double flowRateUse = flowRateOutlet;
3749 if(params->sublist(
"Parameter Fluid").get(
"Average Flowrate",
false) )
3750 flowRateUse = flowRateOutletAveraged;
3753 if(paramsFunc[0] < resistanceRamp){
3755 p_ref = flowRateUse*resistance;
3759 paramsFunc[ 1 ] = p_ref_input;
3760 func( &x_tmp[0], &valueFunc[0], paramsFunc);
3762 p_ref = valueFunc[0];
3766 double h_x = pow( (sqrt(density)/(2*sqrt(2)) * flowRateUse/areaOutlet + sqrt(beta)),2) - beta + p_ref;
3769 if(this->domainVec_.at(0)->getComm()->getRank()==0){
3770 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3771 std::cout <<
" ---------------------------------------------------------- " <<std::endl;
3772 std::cout <<
" Absorbing Boundary Condition " <<std::endl;
3773 std::cout <<
" p_ref: " << p_ref <<std::endl;
3774 std::cout <<
" Volmetric flow Inlet: " << flowRateInlet <<std::endl;
3775 std::cout <<
" Volmetric flow Outlet: " << flowRateOutlet <<std::endl;
3776 std::cout <<
" Averaged volmetric flow Outlet: " << flowRateOutletAveraged <<std::endl;
3777 std::cout <<
" beta*sqrt(A_0) per Input: " << beta <<std::endl;
3778 std::cout <<
" Area_init outlet: " << areaOutlet_init <<std::endl;
3779 std::cout <<
" Area inlet: " << areaInlet <<std::endl;
3780 std::cout <<
" Area outlet: " << areaOutlet <<std::endl;
3781 std::cout <<
" Value h_x at outlet: " << h_x <<std::endl;
3782 std::cout <<
" --------------------------------------------------------- " <<std::endl;
3783 std::cout <<
" --------------------------------------------------------- " <<std::endl;
3787 for (UN T=0; T<elements->numberElements(); T++) {
3789 ElementsPtr_Type subEl = fe.getSubElements();
3790 for (
int surface=0; surface<fe.numSubElements(); surface++) {
3792 if(subEl->getDimension() == dim-1 ){
3793 if(feSub.getFlag() == flagOutlet){
3794 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
3795 vec_int_Type nodeListP = elementsPressure->getElement(T).getSubElements()->getElement(surface).getVectorNodeListNonConst();
3796 int numNodes_T = nodeList.size();
3797 vec_dbl_Type solution_u = this->getSolution(nodeList, u_rep,dim);
3798 vec2D_dbl_Type nodes;
3799 nodes = this->getCoordinates(nodeList, pointsRep);
3801 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
3803 double norm_v_E = 1.;
3805 v_E[0] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3806 v_E[1] = -(pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0));
3807 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2));
3812 p1[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0);
3813 p1[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3814 p1[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[1]).at(2);
3816 p2[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[2]).at(0);
3817 p2[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[2]).at(1);
3818 p2[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[2]).at(2);
3820 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
3821 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
3822 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
3824 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2)+pow(v_E[2],2));
3833 elScaling = B.computeScaling( );
3837 for (UN i=0; i < numNodes_T; i++) {
3840 Teuchos::Array<SC> value(0);
3841 value.resize( dim, 0. );
3843 for (UN w=0; w<phi->size(); w++) {
3844 for (
int j=0; j<dim; j++){
3845 value[j] += weights->at(w) *normalScale*v_E[j]/norm_v_E *h_x*(*phi)[w][i];
3850 for (
int j=0; j<value.size(); j++)
3851 valuesF[ dim * nodeList[ i ] + j ] += value[j] * elScaling;
3864template <
class SC,
class LO,
class GO,
class NO>
3865double FE<SC,LO,GO,NO>::assemblyResistanceBoundary(
int dim,
3867 MultiVectorPtr_Type f,
3868 MultiVectorPtr_Type u_rep,
3869 vec_dbl_Type flowRate_vec,
3870 std::vector<SC>& funcParameter,
3872 ParameterListPtr_Type params,
3875 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
3877 ElementsPtr_Type elementsPressure = this->domainVec_.at(FEloc+1)->getElementsC();
3879 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
3881 vec2D_dbl_ptr_Type phi;
3882 vec2D_dbl_ptr_Type phi1;
3884 vec3D_dbl_ptr_Type dPhi;
3886 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
3887 vec_dbl_ptr_Type weights1 = Teuchos::rcp(
new vec_dbl_Type(0));
3894 vec2D_dbl_ptr_Type quadPoints;
3895 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
3899 double viscosity=params->sublist(
"Parameter").get(
"Viscosity",0.49);
3900 int flagInlet = params->sublist(
"General").get(
"Flag Inlet Fluid", 4);
3901 int flagOutlet = params->sublist(
"General").get(
"Flag Outlet Fluid", 5);
3903 double normalScale = params->sublist(
"Parameter Fluid").get(
"Normal Scale",1.0);
3904 double resistance = params->sublist(
"Parameter Fluid").get(
"Resistance",1.0);
3905 double bcRamp = params->sublist(
"Parameter Fluid").get(
"BC Ramp",0.1);
3907 double referencePressure = params->sublist(
"Parameter Fluid").get(
"Reference fluid pressure",11.99e1);
3915 vec_dbl_Type b(dim);
3917 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
3919 std::vector<double> valueFunc(dim);
3922 funcParameter.push_back(resistance);
3923 funcParameter.push_back(bcRamp);
3924 funcParameter.push_back(flagOutlet);
3926 SC* paramsFunc = &(funcParameter[0]);
3927 double flowRateInlet=0.;
3928 double flowRateOutlet=0.;
3929 this->assemblyFlowRate(dim, flowRateInlet, FEType , dim, flagInlet , u_rep);
3930 int isNeg = this->assemblyFlowRate(dim, flowRateOutlet, FEType , dim, flagOutlet , u_rep);
3932 double resistanceRef = referencePressure/flowRateInlet;
3934 double flowRateOutletAveraged = (flowRate_vec[0] + flowRate_vec[1]) / 2.;
3936 vec_dbl_Type x_tmp(dim,0.);
3939 func( &x_tmp[0], &valueFunc[0], paramsFunc);
3941 if(this->domainVec_.at(0)->getComm()->getRank()==0){
3942 std::cout <<
" ---------------------------------------------------------- " << std::endl;
3943 std::cout <<
" ---------------------------------------------------------- " << std::endl;
3944 std::cout <<
" Resistance Boundary Condition " << std::endl;
3945 std::cout <<
" Volmetric flow Inlet: " << flowRateInlet << std::endl;
3946 std::cout <<
" Volmetric flow Outlet: " << flowRateOutlet << std::endl;
3947 std::cout <<
" Averaged volmetric flow Outlet: " << flowRateOutletAveraged << std::endl;
3948 std::cout <<
" Resistance per Input: " << valueFunc[0] << std::endl;
3949 std::cout <<
" Assumed reference pressure at outlet " << referencePressure<< std::endl;
3950 std::cout <<
" Implicit pressure at outlet with p=R*Q: " << flowRateOutlet*valueFunc[0] << std::endl;
3951 std::cout <<
" Resistance based on (referencePressure)/flowRateInlet at this point would be: " << resistanceRef << std::endl;
3952 std::cout <<
" --------------------------------------------------------- " << std::endl;
3953 std::cout <<
" --------------------------------------------------------- " << std::endl;
3957 double flowRateUse = flowRateOutlet;
3958 if(params->sublist(
"Parameter Fluid").get(
"Average Flowrate",
false) )
3959 flowRateUse = flowRateOutletAveraged;
3964 double p_out = flowRateUse*valueFunc[0];
3967 for (UN T=0; T<elements->numberElements(); T++) {
3969 ElementsPtr_Type subEl = fe.getSubElements();
3970 for (
int surface=0; surface<fe.numSubElements(); surface++) {
3972 if(subEl->getDimension() == dim-1 ){
3975 if(feSub.getFlag() == flagOutlet){
3976 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
3977 vec_int_Type nodeListP = elementsPressure->getElement(T).getSubElements()->getElement(surface).getVectorNodeListNonConst();
3978 int numNodes_T = nodeList.size();
3979 vec_dbl_Type solution_u = this->getSolution(nodeList, u_rep,dim);
3980 vec2D_dbl_Type nodes;
3981 nodes = this->getCoordinates(nodeList, pointsRep);
3983 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
3985 double norm_v_E = 1.;
3987 v_E[0] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3988 v_E[1] = -(pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0));
3989 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2));
3994 p1[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0);
3995 p1[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
3996 p1[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[1]).at(2);
3998 p2[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[2]).at(0);
3999 p2[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[2]).at(1);
4000 p2[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[2]).at(2);
4002 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4003 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4004 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4006 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2)+pow(v_E[2],2));
4015 vec_dbl_Type quadWeights(dim);
4016 quadWeights[0] = 1/6.;
4017 quadWeights[1] = 1/6.;
4018 quadWeights[2] = 1/6.;
4019 vec2D_dbl_Type quadPoints(quadWeights.size(), vec_dbl_Type(dim));
4021 vec_int_Type kn1= elements->getElement(T).getVectorNodeListNonConst();
4023 vec2D_dbl_Type quadPointsT1(quadWeights.size(),vec_dbl_Type(dim));
4024 quadPointsT1.push_back({0.5,0.5,0.0});
4025 quadPointsT1.push_back({0.0,0.5,0.0});
4026 quadPointsT1.push_back({0.5,0.0,0.0});
4035 for (
int s=0; s<dim; s++) {
4037 for (
int t=0; t<dim; t++) {
4038 B1[t][s] = pointsRep->at(index).at(t) -pointsRep->at(index0).at(t);
4042 detB1 = B1.computeInverse(Binv1);
4043 detB1 = std::fabs(detB1);
4047 elScaling = B.computeScaling( );
4051 for (UN i=0; i < numNodes_T; i++) {
4054 Teuchos::Array<SC> value(0);
4055 value.resize( dim, 0. );
4057 for (UN w=0; w<phi->size(); w++) {
4058 for (
int d=0; d<dim; d++){
4059 value[d] += weights->at(w) *normalScale*v_E[d]/norm_v_E *flowRateUse*valueFunc[0]*(*phi)[w][i];
4064 for (
int d=0; d<dim; d++)
4065 valuesF[ dim * nodeList[ i ] + d ] += value[d] * elScaling;
4069 vec_dbl_Type valueSecondComp(dim,0.);
4071 for (UN t=0; t < numNodes_T; t++) {
4072 Teuchos::Array<SC> value( dim, 0. );
4073 for(
int l=0; l< quadWeights.size(); l++){
4074 vec_dbl_Type deriPhi1( dim,0.0) ;
4075 vec_dbl_ptr_Type valuePhi(
new vec_dbl_Type(dim,0.0));
4077 auto it1 = find( kn1.begin(), kn1.end() ,nodeList[t] );
4078 int id_in_element = distance( kn1.begin() , it1 );
4081 for (
int j=0; j<3; j++) {
4082 deriPhi1[j] = valuePhi->at(j);
4085 vec_dbl_Type deriPhiT1(dim,0.);
4086 for(
int q=0; q<dim; q++){
4087 for(
int s=0; s< dim ; s++)
4088 deriPhiT1[q] += (deriPhi1[s]*Binv1[s][q]);
4092 for (UN d=0; d<dim; d++) {
4093 value[d] += quadWeights[l] *solution_u[t*dim+d] * deriPhi1[d]* v_E[d]/norm_v_E * (*phi)[l][t];
4097 for (
int j=0; j<value.size(); j++)
4098 valuesF[ dim * nodeList[ t ] + j ] -= normalScale*value[j] *elScaling*viscosity;
4112template <
class SC,
class LO,
class GO,
class NO>
4113void FE<SC,LO,GO,NO>::assemblyArea(
int dim,
4118 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
4120 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
4122 int inletFlag=inflowFlag;
4124 double areaSurface=0.;
4127 for (UN T=0; T<elements->numberElements(); T++) {
4129 ElementsPtr_Type subEl = fe.getSubElements();
4130 for (
int surface=0; surface<fe.numSubElements(); surface++) {
4132 if(subEl->getDimension() == dim-1 ){
4133 if(feSub.getFlag() == inletFlag){
4134 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
4135 int numNodes_T = nodeList.size();
4136 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
4138 double norm_v_E = 1.;
4140 v_E[0] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
4141 v_E[1] = -(pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0));
4142 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2));
4143 areaSurface += norm_v_E;
4148 p1[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0);
4149 p1[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
4150 p1[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[1]).at(2);
4152 p2[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[2]).at(0);
4153 p2[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[2]).at(1);
4154 p2[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[2]).at(2);
4156 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4157 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4158 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4160 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2)+pow(v_E[2],2));
4163 areaSurface += norm_v_E*0.5;
4176 reduceAll<int, double> (*this->domainVec_.at(0)->getComm(), REDUCE_SUM, areaSurface, outArg (areaSurface));
4182template <
class SC,
class LO,
class GO,
class NO>
4183int FE<SC,LO,GO,NO>::assemblyFlowRate(
int dim,
4184 double &flowRateParabolic,
4188 MultiVectorPtr_Type solution_rep,
4191 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
4193 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
4195 vec2D_dbl_ptr_Type phi;
4197 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
4201 vec2D_dbl_ptr_Type quadPoints;
4202 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
4206 int inletFlag=inflowFlag;
4210 vec_dbl_Type b(dim);
4216 double flowRateInlet=0.;
4218 vec2D_dbl_Type uLoc( dim, vec_dbl_Type( weights->size() , -1. ) );
4220 Teuchos::ArrayRCP< const SC > uArray = solution_rep->getData(0);
4222 for (UN T=0; T<elements->numberElements(); T++) {
4224 ElementsPtr_Type subEl = fe.getSubElements();
4225 for (
int surface=0; surface<fe.numSubElements(); surface++) {
4227 if(subEl->getDimension() == dim-1 ){
4228 if(feSub.getFlag() == inletFlag){
4229 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
4230 int numNodes_T = nodeList.size();
4231 vec_dbl_Type solution_u = this->getSolution(nodeList, solution_rep,dofs);
4234 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
4236 double norm_v_E = 1.;
4238 v_E[0] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
4239 v_E[1] = -(pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0));
4240 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2));
4245 p1[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[1]).at(0);
4246 p1[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[1]).at(1);
4247 p1[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[1]).at(2);
4249 p2[0] = pointsRep->at(nodeList[0]).at(0) - pointsRep->at(nodeList[2]).at(0);
4250 p2[1] = pointsRep->at(nodeList[0]).at(1) - pointsRep->at(nodeList[2]).at(1);
4251 p2[2] = pointsRep->at(nodeList[0]).at(2) - pointsRep->at(nodeList[2]).at(2);
4253 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4254 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4255 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4257 norm_v_E = sqrt(pow(v_E[0],2)+pow(v_E[1],2)+pow(v_E[2],2));
4265 elScaling = B.computeScaling( );
4267 Teuchos::Array<SC> value(0);
4268 value.resize( numNodes_T, 0. );
4280 for (UN i=0; i < numNodes_T; i++) {
4282 for (UN w=0; w<phi->size(); w++) {
4283 for (
int j=0; j<dim; j++){
4285 value[i] += weights->at(w) *v_E[j]/norm_v_E *solution_u[i]*(*phi)[w][i];
4288 LO index = dim * i + j;
4289 value[i] += weights->at(w) *v_E[j]/norm_v_E *solution_u[index]*(*phi)[w][i];
4294 flowRateInlet += value[i] * elScaling;
4303 reduceAll<int, double> (*this->domainVec_.at(0)->getComm(), REDUCE_SUM, flowRateInlet, outArg (flowRateInlet));
4308 if(flowRateInlet <0)
4310 flowRateParabolic = fabs(flowRateInlet);
4317template <
class SC,
class LO,
class GO,
class NO>
4318void FE<SC,LO,GO,NO>::assemblyAverageVelocity(
int dim,
4319 double &averageVelocity,
4323 MultiVectorPtr_Type solution_rep,
4326 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
4328 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
4330 vec2D_dbl_ptr_Type phi;
4332 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
4336 vec2D_dbl_ptr_Type quadPoints;
4337 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
4342 this->assemblyArea(dim, area, flag);
4345 vec_dbl_Type b(dim);
4353 vec2D_dbl_Type uLoc( dim, vec_dbl_Type( weights->size() , -1. ) );
4355 Teuchos::ArrayRCP< const SC > uArray = solution_rep->getData(0);
4357 for (UN T=0; T<elements->numberElements(); T++) {
4359 ElementsPtr_Type subEl = fe.getSubElements();
4360 for(
int surface=0; surface<fe.numSubElements(); surface++) {
4362 if(subEl->getDimension() == dim-1 ){
4363 if(feSub.getFlag() == flag){
4364 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
4365 int numNodes_T = nodeList.size();
4366 vec_dbl_Type solution_u = this->getSolution(nodeList, solution_rep,dofs);
4368 vec_dbl_Type p1(dim),p2(dim),v_E(dim,1.);
4373 elScaling = B.computeScaling( );
4375 Teuchos::Array<SC> value(0);
4376 value.resize( numNodes_T, 0. );
4378 for (UN i=0; i < numNodes_T; i++) {
4380 for (UN w=0; w<phi->size(); w++) {
4381 for (
int j=0; j<dim; j++){
4383 value[i] += weights->at(w)*solution_u[i]*(*phi)[w][i];
4386 LO index = dim * i + j;
4387 value[i] += weights->at(w)*solution_u[index]*(*phi)[w][i];
4392 velocity += value[i] * elScaling;
4398 reduceAll<int, double> (*this->domainVec_.at(0)->getComm(), REDUCE_SUM, velocity, outArg (velocity));
4399 velocity = velocity/area;
4400 std::cout <<
" Average Flowvelocity "<< velocity <<
" ####### " <<std::endl;
4402 averageVelocity = velocity;
4407template <
class SC,
class LO,
class GO,
class NO>
4413 bool callFillComplete)
4415 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
4416 int FEloc = this->
checkFE(dim,FEType);
4419 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
4420 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
4421 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
4423 vec3D_dbl_ptr_Type dPhi;
4424 vec_dbl_ptr_Type weightsDPhi = Teuchos::rcp(
new vec_dbl_Type(0));
4425 vec2D_dbl_ptr_Type quadPts;
4447 double res_trace_i, res_trace_j;
4452 double v11, v12, v21, v22;
4454 vec_dbl_Type p1(2,0.0), p2(2,0.0), p3(2,0.0);
4458 epsilonValuesMat1_j(dim), epsilonValuesMat2_j(dim);
4460 for (
int T = 0; T < elements->numberElements(); T++)
4463 p1 = pointsRep->at(elements->getElement(T).getNode(0));
4464 p2 = pointsRep->at(elements->getElement(T).getNode(1));
4465 p3 = pointsRep->at(elements->getElement(T).getNode(2));
4469 detB = B.computeInverse(Binv);
4470 absDetB = std::fabs(detB);
4474 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
4475 applyBTinv( dPhi, dPhiTrans, Binv );
4477 for (
int i = 0; i < dPhi->at(0).size(); i++)
4479 Teuchos::Array<SC> value11( 1, 0. );
4480 Teuchos::Array<SC> value12( 1, 0. );
4481 Teuchos::Array<SC> value21( 1, 0. );
4482 Teuchos::Array<SC> value22( 1, 0. );
4483 Teuchos::Array<GO> indices( 1, 0 );
4485 for (
int j = 0; j < dPhi->at(0).size(); j++)
4487 v11 = 0.0; v12 = 0.0; v21 = 0.0; v22 = 0.0;
4488 for (
int k = 0; k < dPhi->size(); k++)
4498 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat1_i, 0);
4499 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat2_i, 1);
4505 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat1_j, 0);
4506 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat2_j, 1);
4511 epsilonValuesMat1_i.innerProduct(epsilonValuesMat1_j, res);
4512 epsilonValuesMat1_i.trace(res_trace_i);
4513 epsilonValuesMat1_j.trace(res_trace_j);
4514 v11 = v11 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4516 epsilonValuesMat1_i.innerProduct(epsilonValuesMat2_j, res);
4517 epsilonValuesMat1_i.trace(res_trace_i);
4518 epsilonValuesMat2_j.trace(res_trace_j);
4519 v12 = v12 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4521 epsilonValuesMat2_i.innerProduct(epsilonValuesMat1_j, res);
4522 epsilonValuesMat2_i.trace(res_trace_i);
4523 epsilonValuesMat1_j.trace(res_trace_j);
4524 v21 = v21 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4526 epsilonValuesMat2_i.innerProduct(epsilonValuesMat2_j, res);
4527 epsilonValuesMat2_i.trace(res_trace_i);
4528 epsilonValuesMat2_j.trace(res_trace_j);
4529 v22 = v22 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4534 v11 = absDetB * v11;
4535 v12 = absDetB * v12;
4536 v21 = absDetB * v21;
4537 v22 = absDetB * v22;
4545 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
4546 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
4547 indices[0] = glob_j;
4548 A->insertGlobalValues(glob_i, indices(), value11());
4549 A->insertGlobalValues(glob_i+1, indices(), value21());
4551 indices[0] = glob_j;
4552 A->insertGlobalValues(glob_i, indices(), value12());
4553 A->insertGlobalValues(glob_i+1, indices(), value22());
4557 if (callFillComplete)
4565 double v11, v12, v13, v21, v22, v23, v31, v32, v33;
4567 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
4568 SmallMatrix<double> epsilonValuesMat1_i(dim), epsilonValuesMat2_i(dim), epsilonValuesMat3_i(dim),
4569 epsilonValuesMat1_j(dim), epsilonValuesMat2_j(dim), epsilonValuesMat3_j(dim);
4571 for (
int T = 0; T < elements->numberElements(); T++)
4573 p1 = pointsRep->at(elements->getElement(T).getNode(0));
4574 p2 = pointsRep->at(elements->getElement(T).getNode(1));
4575 p3 = pointsRep->at(elements->getElement(T).getNode(2));
4576 p4 = pointsRep->at(elements->getElement(T).getNode(3));
4579 detB = B.computeInverse(Binv);
4580 absDetB = std::fabs(detB);
4583 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
4584 applyBTinv( dPhi, dPhiTrans, Binv );
4586 for (
int i = 0; i < dPhi->at(0).size(); i++)
4588 Teuchos::Array<SC> value11( 1, 0. );
4589 Teuchos::Array<SC> value12( 1, 0. );
4590 Teuchos::Array<SC> value13( 1, 0. );
4591 Teuchos::Array<SC> value21( 1, 0. );
4592 Teuchos::Array<SC> value22( 1, 0. );
4593 Teuchos::Array<SC> value23( 1, 0. );
4594 Teuchos::Array<SC> value31( 1, 0. );
4595 Teuchos::Array<SC> value32( 1, 0. );
4596 Teuchos::Array<SC> value33( 1, 0. );
4597 Teuchos::Array<GO> indices( 1, 0 );
4599 for (
int j = 0; j < dPhi->at(0).size(); j++)
4601 v11 = 0.0; v12 = 0.0; v13 = 0.0; v21 = 0.0; v22 = 0.0; v23 = 0.0; v31 = 0.0; v32 = 0.0; v33 = 0.0;
4602 for (
int k = 0; k < dPhi->size(); k++)
4607 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat1_i, 0);
4608 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat2_i, 1);
4609 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat3_i, 2);
4614 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat1_j, 0);
4615 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat2_j, 1);
4616 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat3_j, 2);
4618 epsilonValuesMat1_i.innerProduct(epsilonValuesMat1_j, res);
4619 epsilonValuesMat1_i.trace(res_trace_i);
4620 epsilonValuesMat1_j.trace(res_trace_j);
4621 v11 = v11 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4623 epsilonValuesMat1_i.innerProduct(epsilonValuesMat2_j, res);
4624 epsilonValuesMat1_i.trace(res_trace_i);
4625 epsilonValuesMat2_j.trace(res_trace_j);
4626 v12 = v12 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4628 epsilonValuesMat1_i.innerProduct(epsilonValuesMat3_j, res);
4629 epsilonValuesMat1_i.trace(res_trace_i);
4630 epsilonValuesMat3_j.trace(res_trace_j);
4631 v13 = v13 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4633 epsilonValuesMat2_i.innerProduct(epsilonValuesMat1_j, res);
4634 epsilonValuesMat2_i.trace(res_trace_i);
4635 epsilonValuesMat1_j.trace(res_trace_j);
4636 v21 = v21 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4638 epsilonValuesMat2_i.innerProduct(epsilonValuesMat2_j, res);
4639 epsilonValuesMat2_i.trace(res_trace_i);
4640 epsilonValuesMat2_j.trace(res_trace_j);
4641 v22 = v22 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4643 epsilonValuesMat2_i.innerProduct(epsilonValuesMat3_j, res);
4644 epsilonValuesMat2_i.trace(res_trace_i);
4645 epsilonValuesMat3_j.trace(res_trace_j);
4646 v23 = v23 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4648 epsilonValuesMat3_i.innerProduct(epsilonValuesMat1_j, res);
4649 epsilonValuesMat3_i.trace(res_trace_i);
4650 epsilonValuesMat1_j.trace(res_trace_j);
4651 v31 = v31 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4653 epsilonValuesMat3_i.innerProduct(epsilonValuesMat2_j, res);
4654 epsilonValuesMat3_i.trace(res_trace_i);
4655 epsilonValuesMat2_j.trace(res_trace_j);
4656 v32 = v32 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4658 epsilonValuesMat3_i.innerProduct(epsilonValuesMat3_j, res);
4659 epsilonValuesMat3_i.trace(res_trace_i);
4660 epsilonValuesMat3_j.trace(res_trace_j);
4661 v33 = v33 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4664 v11 = absDetB * v11;
4665 v12 = absDetB * v12;
4666 v13 = absDetB * v13;
4667 v21 = absDetB * v21;
4668 v22 = absDetB * v22;
4669 v23 = absDetB * v23;
4670 v31 = absDetB * v31;
4671 v32 = absDetB * v32;
4672 v33 = absDetB * v33;
4684 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
4685 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
4686 indices[0] = glob_j;
4687 A->insertGlobalValues(glob_i, indices(), value11());
4688 A->insertGlobalValues(glob_i+1, indices(), value21());
4689 A->insertGlobalValues(glob_i+2, indices(), value31());
4691 indices[0] = glob_j;
4692 A->insertGlobalValues(glob_i, indices(), value12());
4693 A->insertGlobalValues(glob_i+1, indices(), value22());
4694 A->insertGlobalValues(glob_i+2, indices(), value32());
4696 indices[0] = glob_j;
4697 A->insertGlobalValues(glob_i, indices(), value13());
4698 A->insertGlobalValues(glob_i+1, indices(), value23());
4699 A->insertGlobalValues(glob_i+2, indices(), value33());
4703 if (callFillComplete)
4711template <
class SC,
class LO,
class GO,
class NO>
4712void FE<SC,LO,GO,NO>::determineEMod(std::string FEType, MultiVectorPtr_Type solution,MultiVectorPtr_Type &eModVec, DomainConstPtr_Type domain, ParameterListPtr_Type params){
4715 ElementsPtr_Type elements = domain->getElementsC();
4717 int dim = domain->getDimension();
4718 vec2D_dbl_ptr_Type pointsRep = domain->getPointsRepeated();
4722 Teuchos::ArrayRCP< const SC > uArray = solution->getData(0);
4723 Teuchos::ArrayRCP< SC > eModVecA = eModVec->getDataNonConst(0);
4725 double E0 = params->sublist(
"Parameter Solid").get(
"E",3.0e+6);
4726 double E1 = params->sublist(
"Parameter Solid").get(
"E1",3.0e+5);
4727 double c1 = params->sublist(
"Parameter Solid").get(
"c1",1.0);
4729 double eModMin = E0;
4731 int nodesElement = elements->getElement(0).getVectorNodeList().size();
4732 for (UN T=0; T<elements->numberElements(); T++) {
4740 for(
int i=0; i< nodesElement;i++){
4741 LO index = elements->getElement(T).getNode(i) ;
4742 uLoc += 1./nodesElement*uArray[index];
4745 eModVecA[T] = E0-(E0-E1)*(uLoc/(uLoc+c1));
4746 if(eModVecA[T] > eModMax )
4747 eModMax = eModVecA[T];
4748 if(eModVecA[T] < eModMin)
4749 eModMin = eModVecA[T];
4751 Teuchos::reduceAll<int, double> (*(domain->getComm()), Teuchos::REDUCE_MIN, eModMin, Teuchos::outArg (eModMin));
4752 Teuchos::reduceAll<int, double> (*(domain->getComm()), Teuchos::REDUCE_MAX, eModMax, Teuchos::outArg (eModMax));
4754 if(domain->getComm()->getRank()==0)
4755 std::cout <<
" ################# eMOD Min: " << eModMin <<
" \t eModMax: " << eModMax<<
" ############# " << std::endl;
4762template <
class SC,
class LO,
class GO,
class NO>
4766 MultiVectorPtr_Type eModVec,
4768 bool callFillComplete)
4770 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
4771 int FEloc = this->
checkFE(dim,FEType);
4774 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
4775 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
4776 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
4778 vec3D_dbl_ptr_Type dPhi;
4779 vec_dbl_ptr_Type weightsDPhi = Teuchos::rcp(
new vec_dbl_Type(0));
4780 vec2D_dbl_ptr_Type quadPts;
4798 double res_trace_i, res_trace_j;
4800 Teuchos::ArrayRCP< const SC > E = eModVec->getData(0);
4807 double v11, v12, v21, v22;
4809 vec_dbl_Type p1(2,0.0), p2(2,0.0), p3(2,0.0);
4813 epsilonValuesMat1_j(dim), epsilonValuesMat2_j(dim);
4815 for (
int T = 0; T < elements->numberElements(); T++)
4818 lambda = E[T]* nu / ((1.+nu)*(1.-2.*nu));
4819 mu = E[T] / (2.*(1.+nu));
4822 p1 = pointsRep->at(elements->getElement(T).getNode(0));
4823 p2 = pointsRep->at(elements->getElement(T).getNode(1));
4824 p3 = pointsRep->at(elements->getElement(T).getNode(2));
4828 detB = B.computeInverse(Binv);
4829 absDetB = std::fabs(detB);
4833 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
4834 applyBTinv( dPhi, dPhiTrans, Binv );
4836 for (
int i = 0; i < dPhi->at(0).size(); i++)
4838 Teuchos::Array<SC> value11( 1, 0. );
4839 Teuchos::Array<SC> value12( 1, 0. );
4840 Teuchos::Array<SC> value21( 1, 0. );
4841 Teuchos::Array<SC> value22( 1, 0. );
4842 Teuchos::Array<GO> indices( 1, 0 );
4844 for (
int j = 0; j < dPhi->at(0).size(); j++)
4846 v11 = 0.0; v12 = 0.0; v21 = 0.0; v22 = 0.0;
4847 for (
int k = 0; k < dPhi->size(); k++)
4857 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat1_i, 0);
4858 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat2_i, 1);
4864 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat1_j, 0);
4865 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat2_j, 1);
4870 epsilonValuesMat1_i.innerProduct(epsilonValuesMat1_j, res);
4871 epsilonValuesMat1_i.trace(res_trace_i);
4872 epsilonValuesMat1_j.trace(res_trace_j);
4873 v11 = v11 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4875 epsilonValuesMat1_i.innerProduct(epsilonValuesMat2_j, res);
4876 epsilonValuesMat1_i.trace(res_trace_i);
4877 epsilonValuesMat2_j.trace(res_trace_j);
4878 v12 = v12 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4880 epsilonValuesMat2_i.innerProduct(epsilonValuesMat1_j, res);
4881 epsilonValuesMat2_i.trace(res_trace_i);
4882 epsilonValuesMat1_j.trace(res_trace_j);
4883 v21 = v21 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4885 epsilonValuesMat2_i.innerProduct(epsilonValuesMat2_j, res);
4886 epsilonValuesMat2_i.trace(res_trace_i);
4887 epsilonValuesMat2_j.trace(res_trace_j);
4888 v22 = v22 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4893 v11 = absDetB * v11;
4894 v12 = absDetB * v12;
4895 v21 = absDetB * v21;
4896 v22 = absDetB * v22;
4904 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
4905 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
4906 indices[0] = glob_j;
4907 A->insertGlobalValues(glob_i, indices(), value11());
4908 A->insertGlobalValues(glob_i+1, indices(), value21());
4910 indices[0] = glob_j;
4911 A->insertGlobalValues(glob_i, indices(), value12());
4912 A->insertGlobalValues(glob_i+1, indices(), value22());
4916 if (callFillComplete)
4924 double v11, v12, v13, v21, v22, v23, v31, v32, v33;
4926 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
4927 SmallMatrix<double> epsilonValuesMat1_i(dim), epsilonValuesMat2_i(dim), epsilonValuesMat3_i(dim),
4928 epsilonValuesMat1_j(dim), epsilonValuesMat2_j(dim), epsilonValuesMat3_j(dim);
4930 for (
int T = 0; T < elements->numberElements(); T++)
4932 lambda = E[T]* nu / ((1.+nu)*(1.-2.*nu));
4933 mu = E[T] / (2.*(1.+nu));
4935 p1 = pointsRep->at(elements->getElement(T).getNode(0));
4936 p2 = pointsRep->at(elements->getElement(T).getNode(1));
4937 p3 = pointsRep->at(elements->getElement(T).getNode(2));
4938 p4 = pointsRep->at(elements->getElement(T).getNode(3));
4941 detB = B.computeInverse(Binv);
4942 absDetB = std::fabs(detB);
4945 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
4946 applyBTinv( dPhi, dPhiTrans, Binv );
4948 for (
int i = 0; i < dPhi->at(0).size(); i++)
4951 Teuchos::Array<SC> value11( 1, 0. );
4952 Teuchos::Array<SC> value12( 1, 0. );
4953 Teuchos::Array<SC> value13( 1, 0. );
4954 Teuchos::Array<SC> value21( 1, 0. );
4955 Teuchos::Array<SC> value22( 1, 0. );
4956 Teuchos::Array<SC> value23( 1, 0. );
4957 Teuchos::Array<SC> value31( 1, 0. );
4958 Teuchos::Array<SC> value32( 1, 0. );
4959 Teuchos::Array<SC> value33( 1, 0. );
4960 Teuchos::Array<GO> indices( 1, 0 );
4962 for (
int j = 0; j < dPhi->at(0).size(); j++)
4964 v11 = 0.0; v12 = 0.0; v13 = 0.0; v21 = 0.0; v22 = 0.0; v23 = 0.0; v31 = 0.0; v32 = 0.0; v33 = 0.0;
4965 for (
int k = 0; k < dPhi->size(); k++)
4970 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat1_i, 0);
4971 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat2_i, 1);
4972 epsilonTensor( dPhiTrans.at(k).at(i), epsilonValuesMat3_i, 2);
4977 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat1_j, 0);
4978 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat2_j, 1);
4979 epsilonTensor( dPhiTrans.at(k).at(j), epsilonValuesMat3_j, 2);
4981 epsilonValuesMat1_i.innerProduct(epsilonValuesMat1_j, res);
4982 epsilonValuesMat1_i.trace(res_trace_i);
4983 epsilonValuesMat1_j.trace(res_trace_j);
4984 v11 = v11 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4986 epsilonValuesMat1_i.innerProduct(epsilonValuesMat2_j, res);
4987 epsilonValuesMat1_i.trace(res_trace_i);
4988 epsilonValuesMat2_j.trace(res_trace_j);
4989 v12 = v12 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4991 epsilonValuesMat1_i.innerProduct(epsilonValuesMat3_j, res);
4992 epsilonValuesMat1_i.trace(res_trace_i);
4993 epsilonValuesMat3_j.trace(res_trace_j);
4994 v13 = v13 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
4996 epsilonValuesMat2_i.innerProduct(epsilonValuesMat1_j, res);
4997 epsilonValuesMat2_i.trace(res_trace_i);
4998 epsilonValuesMat1_j.trace(res_trace_j);
4999 v21 = v21 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
5001 epsilonValuesMat2_i.innerProduct(epsilonValuesMat2_j, res);
5002 epsilonValuesMat2_i.trace(res_trace_i);
5003 epsilonValuesMat2_j.trace(res_trace_j);
5004 v22 = v22 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
5006 epsilonValuesMat2_i.innerProduct(epsilonValuesMat3_j, res);
5007 epsilonValuesMat2_i.trace(res_trace_i);
5008 epsilonValuesMat3_j.trace(res_trace_j);
5009 v23 = v23 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
5011 epsilonValuesMat3_i.innerProduct(epsilonValuesMat1_j, res);
5012 epsilonValuesMat3_i.trace(res_trace_i);
5013 epsilonValuesMat1_j.trace(res_trace_j);
5014 v31 = v31 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
5016 epsilonValuesMat3_i.innerProduct(epsilonValuesMat2_j, res);
5017 epsilonValuesMat3_i.trace(res_trace_i);
5018 epsilonValuesMat2_j.trace(res_trace_j);
5019 v32 = v32 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
5021 epsilonValuesMat3_i.innerProduct(epsilonValuesMat3_j, res);
5022 epsilonValuesMat3_i.trace(res_trace_i);
5023 epsilonValuesMat3_j.trace(res_trace_j);
5024 v33 = v33 + weightsDPhi->at(k)*(2*mu*res + lambda*res_trace_j*res_trace_i);
5027 v11 = absDetB * v11;
5028 v12 = absDetB * v12;
5029 v13 = absDetB * v13;
5030 v21 = absDetB * v21;
5031 v22 = absDetB * v22;
5032 v23 = absDetB * v23;
5033 v31 = absDetB * v31;
5034 v32 = absDetB * v32;
5035 v33 = absDetB * v33;
5047 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
5048 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
5049 indices[0] = glob_j;
5050 A->insertGlobalValues(glob_i, indices(), value11());
5051 A->insertGlobalValues(glob_i+1, indices(), value21());
5052 A->insertGlobalValues(glob_i+2, indices(), value31());
5054 indices[0] = glob_j;
5055 A->insertGlobalValues(glob_i, indices(), value12());
5056 A->insertGlobalValues(glob_i+1, indices(), value22());
5057 A->insertGlobalValues(glob_i+2, indices(), value32());
5059 indices[0] = glob_j;
5060 A->insertGlobalValues(glob_i, indices(), value13());
5061 A->insertGlobalValues(glob_i+1, indices(), value23());
5062 A->insertGlobalValues(glob_i+2, indices(), value33());
5066 if (callFillComplete)
5074template <
class SC,
class LO,
class GO,
class NO>
5078 MultiVectorPtr_Type w,
5079 bool callFillComplete)
5082 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
5083 int FEloc = this->
checkFE(dim,FEType);
5085 DomainConstPtr_Type domain = this->domainVec_.at(FEloc);
5086 ElementsPtr_Type elements = domain->getElementsC();
5087 vec2D_dbl_ptr_Type pointsRep = domain->getPointsRepeated();
5088 MapConstPtr_Type map = domain->getMapRepeated();
5090 vec3D_dbl_ptr_Type dPhi;
5091 vec2D_dbl_ptr_Type phi;
5092 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
5093 vec2D_dbl_ptr_Type quadPts;
5110 Teuchos::ArrayRCP< const SC > wArray = w->getData(0);
5115 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0);
5117 vec2D_dbl_Type w11(1, vec_dbl_Type(weights->size(), -1.));
5118 vec2D_dbl_Type w22(1, vec_dbl_Type(weights->size(), -1.));
5119 vec2D_dbl_Type divergenz(1, vec_dbl_Type(weights->size(), -1.));
5121 for (
int T = 0; T < elements->numberElements(); T++)
5123 p1 = pointsRep->at(elements->getElement(T).getNode(0));
5124 p2 = pointsRep->at(elements->getElement(T).getNode(1));
5125 p3 = pointsRep->at(elements->getElement(T).getNode(2));
5128 detB = B.computeInverse(Binv);
5129 absDetB = std::fabs(detB);
5132 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
5133 applyBTinv( dPhi, dPhiTrans, Binv );
5137 for(
int k = 0; k < dPhiTrans.size(); k++)
5141 for(
int i = 0; i < dPhiTrans[0].size(); i++)
5143 LO index1 = dim * elements->getElement(T).getNode(i) + 0;
5144 LO index2 = dim * elements->getElement(T).getNode(i) + 1;
5145 w11[0][k] += wArray[index1] * dPhiTrans[k][i][0];
5146 w22[0][k] += wArray[index2] * dPhiTrans[k][i][1];
5156 for(
int k = 0; k < dPhiTrans.size(); k++)
5158 divergenz[0][k] = w11[0][k] + w22[0][k];
5166 for (
int i = 0; i < dPhi->at(0).size(); i++)
5168 Teuchos::Array<SC> value( 1, 0. );
5169 Teuchos::Array<GO> indices( 1, 0 );
5171 for (
int j = 0; j < dPhi->at(0).size(); j++)
5174 for (
int k = 0; k < dPhi->size(); k++)
5176 val = val + divergenz[0][k] * weights->at(k) * (*phi)[k][i] * (*phi)[k][j];
5178 val = absDetB * val;
5186 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
5187 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
5188 indices[0] = glob_j;
5190 A->insertGlobalValues(glob_i, indices(), value());
5192 indices[0] = glob_j;
5193 A->insertGlobalValues(glob_i+1, indices(), value());
5197 if (callFillComplete)
5207 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
5209 vec2D_dbl_Type w11(1, vec_dbl_Type(weights->size(), -1.));
5210 vec2D_dbl_Type w22(1, vec_dbl_Type(weights->size(), -1.));
5211 vec2D_dbl_Type w33(1, vec_dbl_Type(weights->size(), -1.));
5212 vec2D_dbl_Type divergenz(1, vec_dbl_Type(weights->size(), -1.));
5214 for (
int T = 0; T < elements->numberElements(); T++)
5216 p1 = pointsRep->at(elements->getElement(T).getNode(0));
5217 p2 = pointsRep->at(elements->getElement(T).getNode(1));
5218 p3 = pointsRep->at(elements->getElement(T).getNode(2));
5219 p4 = pointsRep->at(elements->getElement(T).getNode(3));
5222 detB = B.computeInverse(Binv);
5223 absDetB = std::fabs(detB);
5226 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
5227 applyBTinv( dPhi, dPhiTrans, Binv );
5231 for(
int k = 0; k < dPhiTrans.size(); k++)
5236 for(
int i = 0; i < dPhiTrans[0].size(); i++)
5238 LO index1 = dim * elements->getElement(T).getNode(i) + 0;
5239 LO index2 = dim * elements->getElement(T).getNode(i) + 1;
5240 LO index3 = dim * elements->getElement(T).getNode(i) + 2;
5241 w11[0][k] += wArray[index1] * dPhiTrans[k][i][0];
5242 w22[0][k] += wArray[index2] * dPhiTrans[k][i][1];
5243 w33[0][k] += wArray[index3] * dPhiTrans[k][i][2];
5247 for(
int k = 0; k < dPhiTrans.size(); k++)
5249 divergenz[0][k] = w11[0][k] + w22[0][k] + w33[0][k];
5252 for (
int i = 0; i < dPhi->at(0).size(); i++)
5254 Teuchos::Array<SC> value( 1, 0. );
5255 Teuchos::Array<GO> indices( 1, 0 );
5257 for (
int j = 0; j < dPhi->at(0).size(); j++)
5260 for (
int k = 0; k < dPhi->size(); k++)
5262 val = val + divergenz[0][k] * weights->at(k) * (*phi)[k][i] * (*phi)[k][j];
5264 val = absDetB * val;
5267 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
5268 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
5269 indices[0] = glob_j;
5270 A->insertGlobalValues(glob_i, indices(), value());
5272 indices[0] = glob_j;
5273 A->insertGlobalValues(glob_i+1, indices(), value());
5275 indices[0] = glob_j;
5276 A->insertGlobalValues(glob_i+2, indices(), value());
5281 if (callFillComplete)
5288template <
class SC,
class LO,
class GO,
class NO>
5289void FE<SC,LO,GO,NO>::assemblyDummyCoupling(
int dim,
5293 bool callFillComplete)
5295 DomainConstPtr_Type domain = this->domainVec_.at(FEloc);
5297 MapConstPtr_Type mapInterfaceVecField = domain->getInterfaceMapVecFieldUnique();
5298 MapConstPtr_Type mapGlobalInterfaceVecField = domain->getGlobalInterfaceMapVecFieldUnique();
5300 MapConstPtr_Type mapFieldPartial = domain->getGlobalInterfaceMapVecFieldPartial();
5302 Teuchos::Array<SC> value( 1, 0. );
5304 Teuchos::Array<GO> indices( 1, 0 );
5306 GO dofGlobal, dofLocal;
5308 for(
int k = 0; k < mapGlobalInterfaceVecField->getNodeNumElements(); k++)
5310 dofGlobal = mapGlobalInterfaceVecField->getGlobalElement(k);
5311 if ( mapFieldPartial->getLocalElement( dofGlobal ) == Teuchos::OrdinalTraits<LO>::invalid() ) {
5313 dofGlobal = mapInterfaceVecField->getGlobalElement( k );
5314 indices[0] = dofGlobal;
5315 C->insertGlobalValues(dofGlobal, indices(), value());
5319 if (callFillComplete)
5320 C->fillComplete(mapInterfaceVecField, mapInterfaceVecField);
5324template <
class SC,
class LO,
class GO,
class NO>
5325void FE<SC,LO,GO,NO>::assemblyFSICoupling(
int dim,
5328 MatrixPtr_Type &C_T,
5331 MapConstPtr_Type map1,
5332 MapConstPtr_Type map2,
5333 bool callFillComplete)
5337 DomainConstPtr_Type domain1 = this->domainVec_.at(FEloc1);
5339 MapConstPtr_Type mapInterfaceVecField = domain1->getInterfaceMapVecFieldUnique();
5341 MapConstPtr_Type mapGlobalInterfaceVecField;
5342 MapConstPtr_Type mapFieldPartial;
5343 if (FEloc1!=FEloc2){
5344 mapFieldPartial = domain1->getOtherGlobalInterfaceMapVecFieldPartial();
5345 mapGlobalInterfaceVecField = domain1->getOtherGlobalInterfaceMapVecFieldUnique();
5348 mapFieldPartial = domain1->getGlobalInterfaceMapVecFieldPartial();
5349 mapGlobalInterfaceVecField = domain1->getGlobalInterfaceMapVecFieldUnique();
5352 Teuchos::Array<SC> value( 1, 0. );
5354 Teuchos::Array<GO> indices( 1, 0 );
5356 GO dofGlobal, dofLocal;
5357 if (mapFieldPartial.is_null()) {
5358 for(
int k = 0; k < mapGlobalInterfaceVecField->getNodeNumElements(); k++)
5361 dofGlobal = mapGlobalInterfaceVecField->getGlobalElement(k);
5362 dofLocal = mapInterfaceVecField->getGlobalElement(k);
5364 indices[0] = dofLocal;
5365 C_T->insertGlobalValues(dofGlobal, indices(), value());
5366 indices[0] = dofGlobal;
5367 C->insertGlobalValues(dofLocal, indices(), value());
5372 for(
int k = 0; k < mapGlobalInterfaceVecField->getNodeNumElements(); k++) {
5373 dofGlobal = mapGlobalInterfaceVecField->getGlobalElement(k);
5374 if ( mapFieldPartial->getLocalElement( dofGlobal ) != Teuchos::OrdinalTraits<LO>::invalid() ) {
5376 dofLocal = mapInterfaceVecField->getGlobalElement(k);
5378 indices[0] = dofLocal;
5379 C_T->insertGlobalValues(dofGlobal, indices(), value());
5380 indices[0] = dofGlobal;
5381 C->insertGlobalValues(dofLocal, indices(), value());
5386 if (callFillComplete)
5390 C_T->fillComplete(map1, map2);
5391 C->fillComplete(map2, map1);
5396template <
class SC,
class LO,
class GO,
class NO>
5397void FE<SC,LO,GO,NO>::assemblyGeometryCoupling(
int dim,
5401 MapConstPtr_Type map1,
5402 MapConstPtr_Type map2,
5403 MapConstPtr_Type map3,
5404 bool callFillComplete)
5407 DomainConstPtr_Type domain = this->domainVec_.at(FEloc);
5409 MapConstPtr_Type mapInt = domain->getGlobalInterfaceMapVecFieldUnique();
5410 MapConstPtr_Type mapOtherInt = domain->getOtherGlobalInterfaceMapVecFieldUnique();
5411 MapConstPtr_Type mapPartInt = domain->getGlobalInterfaceMapVecFieldPartial();
5412 MapConstPtr_Type mapOtherPartInt = domain->getOtherGlobalInterfaceMapVecFieldPartial();
5413 Teuchos::Array<SC> value( 1, 0. );
5415 Teuchos::Array<GO> indices( 1, 0 );
5418 if (mapPartInt.is_null()) {
5419 for(
int k = 0; k < mapInt->getNodeNumElements(); k++){
5420 dofRow = mapInt->getGlobalElement(k);
5421 indices[0] = mapOtherInt->getGlobalElement(k);
5422 C->insertGlobalValues(dofRow, indices(), value());
5426 for(
int k = 0; k < mapPartInt->getNodeNumElements(); k++){
5427 dofRow = mapPartInt->getGlobalElement(k);
5428 indices[0] = mapOtherPartInt->getGlobalElement(k);
5429 C->insertGlobalValues(dofRow, indices(), value());
5432 if (callFillComplete)
5435 C->fillComplete(map2, map3);
5440template <
class SC,
class LO,
class GO,
class NO>
5441void FE<SC,LO,GO,NO>::assemblyShapeDerivativeVelocity(
int dim,
5442 std::string FEType1,
5443 std::string FEType2,
5446 MultiVectorPtr_Type u,
5447 MultiVectorPtr_Type w,
5448 MultiVectorPtr_Type p,
5452 bool callFillComplete)
5456 DomainConstPtr_Type domain = this->domainVec_.at(FEloc);
5457 ElementsPtr_Type elements = domain->getElementsC();
5458 vec2D_dbl_ptr_Type pointsRep = domain->getPointsRepeated();
5459 MapConstPtr_Type map = domain->getMapRepeated();
5461 vec3D_dbl_ptr_Type dPhiU;
5462 vec2D_dbl_ptr_Type phiU;
5463 vec2D_dbl_ptr_Type phiP;
5464 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
5465 vec2D_dbl_ptr_Type quadPts;
5484 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
5485 Teuchos::ArrayRCP< const SC > wArray = w->getData(0);
5486 Teuchos::ArrayRCP< const SC > pArray = p->getData(0);
5490 double val11, val12, val21, val22;
5491 double valDK1_11, valDK1_12, valDK1_21, valDK1_22;
5492 double valDK2_11, valDK2_12, valDK2_21, valDK2_22;
5493 double valDN_11, valDN_12, valDN_21, valDN_22;
5494 double valDW_11, valDW_12, valDW_21, valDW_22;
5495 double valDP_11, valDP_12, valDP_21, valDP_22;
5496 double valDM_11, valDM_12, valDM_21, valDM_22;
5497 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0);
5502 vec2D_dbl_Type u1Loc(1, vec_dbl_Type(weights->size(), -1.));
5503 vec2D_dbl_Type u2Loc(1, vec_dbl_Type(weights->size(), -1.));
5504 vec2D_dbl_Type w1Loc(1, vec_dbl_Type(weights->size(), -1.));
5505 vec2D_dbl_Type w2Loc(1, vec_dbl_Type(weights->size(), -1.));
5506 vec2D_dbl_Type pLoc(1, vec_dbl_Type(weights->size(), -1.));
5507 vec2D_dbl_Type u11(1, vec_dbl_Type(weights->size(), -1.));
5508 vec2D_dbl_Type u12(1, vec_dbl_Type(weights->size(), -1.));
5509 vec2D_dbl_Type u21(1, vec_dbl_Type(weights->size(), -1.));
5510 vec2D_dbl_Type u22(1, vec_dbl_Type(weights->size(), -1.));
5511 vec2D_dbl_Type w11(1, vec_dbl_Type(weights->size(), -1.));
5512 vec2D_dbl_Type w12(1, vec_dbl_Type(weights->size(), -1.));
5513 vec2D_dbl_Type w21(1, vec_dbl_Type(weights->size(), -1.));
5514 vec2D_dbl_Type w22(1, vec_dbl_Type(weights->size(), -1.));
5515 vec2D_dbl_Type sigma11(1, vec_dbl_Type(weights->size(), -1.));
5516 vec2D_dbl_Type sigma12(1, vec_dbl_Type(weights->size(), -1.));
5517 vec2D_dbl_Type sigma21(1, vec_dbl_Type(weights->size(), -1.));
5518 vec2D_dbl_Type sigma22(1, vec_dbl_Type(weights->size(), -1.));
5520 for (
int T = 0; T < elements->numberElements(); T++)
5522 p1 = pointsRep->at(elements->getElement(T).getNode(0));
5523 p2 = pointsRep->at(elements->getElement(T).getNode(1));
5524 p3 = pointsRep->at(elements->getElement(T).getNode(2));
5527 detB = B.computeInverse(Binv);
5528 absDetB = std::fabs(detB);
5531 vec3D_dbl_Type dPhiTransU( dPhiU->size(), vec2D_dbl_Type( dPhiU->at(0).size(), vec_dbl_Type(dim,0.) ) );
5532 applyBTinv( dPhiU, dPhiTransU, Binv );
5535 for(
int k = 0; k < phiU->size(); k++)
5541 for(
int i = 0; i < phiU->at(0).size(); i++)
5543 LO index1 = dim * elements->getElement(T).getNode(i) + 0;
5544 LO index2 = dim * elements->getElement(T).getNode(i) + 1;
5545 u1Loc[0][k] += uArray[index1] * phiU->at(k).at(i);
5546 u2Loc[0][k] += uArray[index2] * phiU->at(k).at(i);
5547 w1Loc[0][k] += wArray[index1] * phiU->at(k).at(i);
5548 w2Loc[0][k] += wArray[index2] * phiU->at(k).at(i);
5555 for(
int k = 0; k < phiP->size(); k++)
5558 for(
int i = 0; i < phiP->at(0).size(); i++)
5562 LO index = elements->getElement(T).getNode(i) + 0;
5563 pLoc[0][k] += pArray[index] * phiP->at(k).at(i);
5570 for(
int k = 0; k < dPhiTransU.size(); k++)
5580 for(
int i = 0; i < dPhiTransU[0].size(); i++)
5582 LO index1 = dim * elements->getElement(T).getNode(i) + 0;
5583 LO index2 = dim * elements->getElement(T).getNode(i) + 1;
5584 u11[0][k] += uArray[index1] * dPhiTransU[k][i][0];
5585 u12[0][k] += uArray[index1] * dPhiTransU[k][i][1];
5586 u21[0][k] += uArray[index2] * dPhiTransU[k][i][0];
5587 u22[0][k] += uArray[index2] * dPhiTransU[k][i][1];
5588 w11[0][k] += wArray[index1] * dPhiTransU[k][i][0];
5589 w12[0][k] += wArray[index1] * dPhiTransU[k][i][1];
5590 w21[0][k] += wArray[index2] * dPhiTransU[k][i][0];
5591 w22[0][k] += wArray[index2] * dPhiTransU[k][i][1];
5598 for(
int k = 0; k < dPhiTransU.size(); k++)
5600 sigma11[0][k] = rho * nu * (u11[0][k] + u11[0][k]) - pLoc[0][k];
5601 sigma12[0][k] = rho * nu * (u12[0][k] + u21[0][k]);
5602 sigma21[0][k] = rho * nu * (u21[0][k] + u12[0][k]);
5603 sigma22[0][k] = rho * nu * (u22[0][k] + u22[0][k]) - pLoc[0][k];
5607 for (
int i = 0; i < dPhiU->at(0).size(); i++)
5609 Teuchos::Array<SC> value11( 1, 0. );
5610 Teuchos::Array<SC> value12( 1, 0. );
5611 Teuchos::Array<SC> value21( 1, 0. );
5612 Teuchos::Array<SC> value22( 1, 0. );
5613 Teuchos::Array<GO> indices( 1, 0 );
5615 for (
int j = 0; j < dPhiU->at(0).size(); j++)
5653 for (
int k = 0; k < dPhiU->size(); k++)
5656 valDK1_11 = valDK1_11 + weights->at(k) *
5657 ( 2 * u11[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
5658 u11[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] +
5659 u21[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] );
5660 valDK1_12 = valDK1_12 + weights->at(k) *
5661 ( 2 * u12[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
5662 u12[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] +
5663 u22[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] );
5664 valDK1_21 = valDK1_21 + weights->at(k) *
5665 ( u11[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
5666 u21[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
5667 2 * u21[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] );
5668 valDK1_22 = valDK1_22 + weights->at(k) *
5669 ( u12[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
5670 u22[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
5671 2 * u22[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] );
5674 valDK2_11 = valDK2_11 + weights->at(k) *
5675 ( -sigma12[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
5676 sigma12[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] );
5677 valDK2_12 = valDK2_12 + weights->at(k) *
5678 ( sigma11[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
5679 -sigma11[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] );
5680 valDK2_21 = valDK2_21 + weights->at(k) *
5681 ( -sigma22[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
5682 sigma22[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] );
5683 valDK2_22 = valDK2_22 + weights->at(k) *
5684 ( sigma21[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
5685 -sigma21[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] );
5688 valDN_11 = valDN_11 + weights->at(k) *
5689 ( -(u2Loc[0][k] - w2Loc[0][k]) * dPhiTransU[k][j][1] * u11[0][k] * phiU->at(k).at(i) +
5690 (u2Loc[0][k] - w2Loc[0][k]) * dPhiTransU[k][j][0] * u12[0][k] * phiU->at(k).at(i) );
5691 valDN_12 = valDN_12 + weights->at(k) *
5692 ( (u1Loc[0][k] - w1Loc[0][k]) * dPhiTransU[k][j][1] * u11[0][k] * phiU->at(k).at(i) -
5693 (u1Loc[0][k] - w1Loc[0][k]) * dPhiTransU[k][j][0] * u12[0][k] * phiU->at(k).at(i) );
5694 valDN_21 = valDN_21 + weights->at(k) *
5695 ( -(u2Loc[0][k] - w2Loc[0][k]) * dPhiTransU[k][j][1] * u21[0][k] * phiU->at(k).at(i) +
5696 (u2Loc[0][k] - w2Loc[0][k]) * dPhiTransU[k][j][0] * u22[0][k] * phiU->at(k).at(i) );
5697 valDN_22 = valDN_22 + weights->at(k) *
5698 ( (u1Loc[0][k] - w1Loc[0][k]) * dPhiTransU[k][j][1] * u21[0][k] * phiU->at(k).at(i) -
5699 (u1Loc[0][k] - w1Loc[0][k]) * dPhiTransU[k][j][0] * u22[0][k] * phiU->at(k).at(i) );
5702 valDW_11 = valDW_11 + weights->at(k) *
5703 ( u11[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
5704 valDW_12 = valDW_12 + weights->at(k) *
5705 ( u12[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
5706 valDW_21 = valDW_21 + weights->at(k) *
5707 ( u21[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
5708 valDW_22 = valDW_22 + weights->at(k) *
5709 ( u22[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
5712 valDP_11 = valDP_11 + weights->at(k) *
5713 ( ( -w21[0][k] * dPhiTransU[k][j][1] + w22[0][k] * dPhiTransU[k][j][0] ) * u1Loc[0][k] * phiU->at(k).at(i) );
5714 valDP_12 = valDP_12 + weights->at(k) *
5715 ( ( w11[0][k] * dPhiTransU[k][j][1] - w12[0][k] * dPhiTransU[k][j][0] ) * u1Loc[0][k] * phiU->at(k).at(i) );
5716 valDP_21 = valDP_21 + weights->at(k) *
5717 ( ( -w21[0][k] * dPhiTransU[k][j][1] + w22[0][k] * dPhiTransU[k][j][0] ) * u2Loc[0][k] * phiU->at(k).at(i) );
5718 valDP_22 = valDP_22 + weights->at(k) *
5719 ( ( w11[0][k] * dPhiTransU[k][j][1] - w12[0][k] * dPhiTransU[k][j][0] ) * u2Loc[0][k] * phiU->at(k).at(i) );
5722 valDM_11 = valDM_11 + weights->at(k) *
5723 ( dPhiTransU[k][j][0] * u1Loc[0][k] * phiU->at(k).at(i) );
5724 valDM_12 = valDM_12 + weights->at(k) *
5725 ( dPhiTransU[k][j][1] * u1Loc[0][k] * phiU->at(k).at(i) );
5726 valDM_21 = valDM_21 + weights->at(k) *
5727 ( dPhiTransU[k][j][0] * u2Loc[0][k] * phiU->at(k).at(i) );
5728 valDM_22 = valDM_22 + weights->at(k) *
5729 ( dPhiTransU[k][j][1] * u2Loc[0][k] * phiU->at(k).at(i) );
5732 val11 = -rho*nu*valDK1_11 + valDK2_11 + rho*valDN_11 - rho*valDP_11 - (1.0/dt)*rho*valDW_11 + (0.5/dt)*rho*valDM_11;
5733 val12 = -rho*nu*valDK1_12 + valDK2_12 + rho*valDN_12 - rho*valDP_12 - (1.0/dt)*rho*valDW_12 + (0.5/dt)*rho*valDM_12;
5734 val21 = -rho*nu*valDK1_21 + valDK2_21 + rho*valDN_21 - rho*valDP_21 - (1.0/dt)*rho*valDW_21 + (0.5/dt)*rho*valDM_21;
5735 val22 = -rho*nu*valDK1_22 + valDK2_22 + rho*valDN_22 - rho*valDP_22 - (1.0/dt)*rho*valDW_22 + (0.5/dt)*rho*valDM_22;
5737 val11 = absDetB * val11;
5738 val12 = absDetB * val12;
5739 val21 = absDetB * val21;
5740 val22 = absDetB * val22;
5747 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
5748 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
5749 indices[0] = glob_j;
5751 D->insertGlobalValues(glob_i, indices(), value11());
5752 D->insertGlobalValues(glob_i+1, indices(), value21());
5754 indices[0] = glob_j;
5755 D->insertGlobalValues(glob_i, indices(), value12());
5756 D->insertGlobalValues(glob_i+1, indices(), value22());
5760 if (callFillComplete)
5767 double val11, val12, val13, val21, val22, val23, val31, val32, val33;
5768 double valDK1_11, valDK1_12, valDK1_13, valDK1_21, valDK1_22, valDK1_23, valDK1_31, valDK1_32, valDK1_33;
5769 double valDK2_11, valDK2_12, valDK2_13, valDK2_21, valDK2_22, valDK2_23, valDK2_31, valDK2_32, valDK2_33;
5770 double valDN_11, valDN_12, valDN_13, valDN_21, valDN_22, valDN_23, valDN_31, valDN_32, valDN_33;
5771 double valDW_11, valDW_12, valDW_13, valDW_21, valDW_22, valDW_23, valDW_31, valDW_32, valDW_33;
5772 double valDP_11, valDP_12, valDP_13, valDP_21, valDP_22, valDP_23, valDP_31, valDP_32, valDP_33;
5773 double valDM_11, valDM_12, valDM_13, valDM_21, valDM_22, valDM_23, valDM_31, valDM_32, valDM_33;
5774 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
5779 vec2D_dbl_Type u1Loc(1, vec_dbl_Type(weights->size(), -1.));
5780 vec2D_dbl_Type u2Loc(1, vec_dbl_Type(weights->size(), -1.));
5781 vec2D_dbl_Type u3Loc(1, vec_dbl_Type(weights->size(), -1.));
5782 vec2D_dbl_Type w1Loc(1, vec_dbl_Type(weights->size(), -1.));
5783 vec2D_dbl_Type w2Loc(1, vec_dbl_Type(weights->size(), -1.));
5784 vec2D_dbl_Type w3Loc(1, vec_dbl_Type(weights->size(), -1.));
5785 vec2D_dbl_Type pLoc(1, vec_dbl_Type(weights->size(), -1.));
5786 vec2D_dbl_Type u11(1, vec_dbl_Type(weights->size(), -1.));
5787 vec2D_dbl_Type u12(1, vec_dbl_Type(weights->size(), -1.));
5788 vec2D_dbl_Type u13(1, vec_dbl_Type(weights->size(), -1.));
5789 vec2D_dbl_Type u21(1, vec_dbl_Type(weights->size(), -1.));
5790 vec2D_dbl_Type u22(1, vec_dbl_Type(weights->size(), -1.));
5791 vec2D_dbl_Type u23(1, vec_dbl_Type(weights->size(), -1.));
5792 vec2D_dbl_Type u31(1, vec_dbl_Type(weights->size(), -1.));
5793 vec2D_dbl_Type u32(1, vec_dbl_Type(weights->size(), -1.));
5794 vec2D_dbl_Type u33(1, vec_dbl_Type(weights->size(), -1.));
5795 vec2D_dbl_Type w11(1, vec_dbl_Type(weights->size(), -1.));
5796 vec2D_dbl_Type w12(1, vec_dbl_Type(weights->size(), -1.));
5797 vec2D_dbl_Type w13(1, vec_dbl_Type(weights->size(), -1.));
5798 vec2D_dbl_Type w21(1, vec_dbl_Type(weights->size(), -1.));
5799 vec2D_dbl_Type w22(1, vec_dbl_Type(weights->size(), -1.));
5800 vec2D_dbl_Type w23(1, vec_dbl_Type(weights->size(), -1.));
5801 vec2D_dbl_Type w31(1, vec_dbl_Type(weights->size(), -1.));
5802 vec2D_dbl_Type w32(1, vec_dbl_Type(weights->size(), -1.));
5803 vec2D_dbl_Type w33(1, vec_dbl_Type(weights->size(), -1.));
5804 vec2D_dbl_Type sigma11(1, vec_dbl_Type(weights->size(), -1.));
5805 vec2D_dbl_Type sigma12(1, vec_dbl_Type(weights->size(), -1.));
5806 vec2D_dbl_Type sigma13(1, vec_dbl_Type(weights->size(), -1.));
5807 vec2D_dbl_Type sigma21(1, vec_dbl_Type(weights->size(), -1.));
5808 vec2D_dbl_Type sigma22(1, vec_dbl_Type(weights->size(), -1.));
5809 vec2D_dbl_Type sigma23(1, vec_dbl_Type(weights->size(), -1.));
5810 vec2D_dbl_Type sigma31(1, vec_dbl_Type(weights->size(), -1.));
5811 vec2D_dbl_Type sigma32(1, vec_dbl_Type(weights->size(), -1.));
5812 vec2D_dbl_Type sigma33(1, vec_dbl_Type(weights->size(), -1.));
5814 for (
int T = 0; T < elements->numberElements(); T++)
5816 p1 = pointsRep->at(elements->getElement(T).getNode(0));
5817 p2 = pointsRep->at(elements->getElement(T).getNode(1));
5818 p3 = pointsRep->at(elements->getElement(T).getNode(2));
5819 p4 = pointsRep->at(elements->getElement(T).getNode(3));
5822 detB = B.computeInverse(Binv);
5823 absDetB = std::fabs(detB);
5826 vec3D_dbl_Type dPhiTransU( dPhiU->size(), vec2D_dbl_Type( dPhiU->at(0).size(), vec_dbl_Type(dim,0.) ) );
5827 applyBTinv( dPhiU, dPhiTransU, Binv );
5830 for(
int k = 0; k < phiU->size(); k++)
5838 for(
int i = 0; i < phiU->at(0).size(); i++)
5840 LO index1 = dim * elements->getElement(T).getNode(i) + 0;
5841 LO index2 = dim * elements->getElement(T).getNode(i) + 1;
5842 LO index3 = dim * elements->getElement(T).getNode(i) + 2;
5843 u1Loc[0][k] += uArray[index1] * phiU->at(k).at(i);
5844 u2Loc[0][k] += uArray[index2] * phiU->at(k).at(i);
5845 u3Loc[0][k] += uArray[index3] * phiU->at(k).at(i);
5846 w1Loc[0][k] += wArray[index1] * phiU->at(k).at(i);
5847 w2Loc[0][k] += wArray[index2] * phiU->at(k).at(i);
5848 w3Loc[0][k] += wArray[index3] * phiU->at(k).at(i);
5854 for(
int k = 0; k < phiP->size(); k++)
5857 for(
int i = 0; i < phiP->at(0).size(); i++)
5860 LO index = elements->getElement(T).getNode(i) + 0;
5861 pLoc[0][k] += pArray[index] * phiP->at(k).at(i);
5867 for(
int k = 0; k < dPhiTransU.size(); k++)
5887 for(
int i = 0; i < dPhiTransU[0].size(); i++)
5889 LO index1 = dim * elements->getElement(T).getNode(i) + 0;
5890 LO index2 = dim * elements->getElement(T).getNode(i) + 1;
5891 LO index3 = dim * elements->getElement(T).getNode(i) + 2;
5892 u11[0][k] += uArray[index1] * dPhiTransU[k][i][0];
5893 u12[0][k] += uArray[index1] * dPhiTransU[k][i][1];
5894 u13[0][k] += uArray[index1] * dPhiTransU[k][i][2];
5895 u21[0][k] += uArray[index2] * dPhiTransU[k][i][0];
5896 u22[0][k] += uArray[index2] * dPhiTransU[k][i][1];
5897 u23[0][k] += uArray[index2] * dPhiTransU[k][i][2];
5898 u31[0][k] += uArray[index3] * dPhiTransU[k][i][0];
5899 u32[0][k] += uArray[index3] * dPhiTransU[k][i][1];
5900 u33[0][k] += uArray[index3] * dPhiTransU[k][i][2];
5901 w11[0][k] += wArray[index1] * dPhiTransU[k][i][0];
5902 w12[0][k] += wArray[index1] * dPhiTransU[k][i][1];
5903 w13[0][k] += wArray[index1] * dPhiTransU[k][i][2];
5904 w21[0][k] += wArray[index2] * dPhiTransU[k][i][0];
5905 w22[0][k] += wArray[index2] * dPhiTransU[k][i][1];
5906 w23[0][k] += wArray[index2] * dPhiTransU[k][i][2];
5907 w31[0][k] += wArray[index3] * dPhiTransU[k][i][0];
5908 w32[0][k] += wArray[index3] * dPhiTransU[k][i][1];
5909 w33[0][k] += wArray[index3] * dPhiTransU[k][i][2];
5915 for(
int k = 0; k < dPhiTransU.size(); k++)
5917 sigma11[0][k] = rho * nu * (u11[0][k] + u11[0][k]) - pLoc[0][k];
5918 sigma12[0][k] = rho * nu * (u12[0][k] + u21[0][k]);
5919 sigma13[0][k] = rho * nu * (u13[0][k] + u31[0][k]);
5920 sigma21[0][k] = rho * nu * (u21[0][k] + u12[0][k]);
5921 sigma22[0][k] = rho * nu * (u22[0][k] + u22[0][k]) - pLoc[0][k];
5922 sigma23[0][k] = rho * nu * (u23[0][k] + u32[0][k]);
5923 sigma31[0][k] = rho * nu * (u31[0][k] + u13[0][k]);
5924 sigma32[0][k] = rho * nu * (u32[0][k] + u23[0][k]);
5925 sigma33[0][k] = rho * nu * (u33[0][k] + u33[0][k]) - pLoc[0][k];
5929 for (
int i = 0; i < dPhiU->at(0).size(); i++)
5931 Teuchos::Array<SC> value11( 1, 0. );
5932 Teuchos::Array<SC> value12( 1, 0. );
5933 Teuchos::Array<SC> value13( 1, 0. );
5934 Teuchos::Array<SC> value21( 1, 0. );
5935 Teuchos::Array<SC> value22( 1, 0. );
5936 Teuchos::Array<SC> value23( 1, 0. );
5937 Teuchos::Array<SC> value31( 1, 0. );
5938 Teuchos::Array<SC> value32( 1, 0. );
5939 Teuchos::Array<SC> value33( 1, 0. );
5940 Teuchos::Array<GO> indices( 1, 0 );
5942 for (
int j = 0; j < dPhiU->at(0).size(); j++)
6010 for (
int k = 0; k < dPhiU->size(); k++)
6013 valDK1_11 = valDK1_11 + weights->at(k) *
6014 ( 2 * u11[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
6015 ( u11[0][k] * dPhiTransU[k][j][1] + u21[0][k] * dPhiTransU[k][j][0] ) * dPhiTransU[k][i][1] +
6016 ( u11[0][k] * dPhiTransU[k][j][2] + u31[0][k] * dPhiTransU[k][j][0] ) * dPhiTransU[k][i][2] );
6017 valDK1_12 = valDK1_12 + weights->at(k) *
6018 ( 2 * u12[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
6019 ( u12[0][k] * dPhiTransU[k][j][1] + u22[0][k] * dPhiTransU[k][j][0] ) * dPhiTransU[k][i][1] +
6020 ( u12[0][k] * dPhiTransU[k][j][2] + u32[0][k] * dPhiTransU[k][j][0] ) * dPhiTransU[k][i][2] );
6021 valDK1_13 = valDK1_13 + weights->at(k) *
6022 ( 2 * u13[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][0] +
6023 ( u13[0][k] * dPhiTransU[k][j][1] + u23[0][k] * dPhiTransU[k][j][0] ) * dPhiTransU[k][i][1] +
6024 ( u13[0][k] * dPhiTransU[k][j][2] + u33[0][k] * dPhiTransU[k][j][0] ) * dPhiTransU[k][i][2] );
6025 valDK1_21 = valDK1_21 + weights->at(k) *
6026 ( ( u21[0][k] * dPhiTransU[k][j][0] + u11[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][0] +
6027 2 * u21[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] +
6028 ( u21[0][k] * dPhiTransU[k][j][2] + u31[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][2] );
6029 valDK1_22 = valDK1_22 + weights->at(k) *
6030 ( ( u22[0][k] * dPhiTransU[k][j][0] + u12[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][0] +
6031 2 * u22[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] +
6032 ( u22[0][k] * dPhiTransU[k][j][2] + u32[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][2] );
6033 valDK1_23 = valDK1_23 + weights->at(k) *
6034 ( ( u23[0][k] * dPhiTransU[k][j][0] + u13[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][0] +
6035 2 * u23[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][1] +
6036 ( u23[0][k] * dPhiTransU[k][j][2] + u33[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][2] );
6037 valDK1_31 = valDK1_31 + weights->at(k) *
6038 ( ( u31[0][k] * dPhiTransU[k][j][0] + u11[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][0] +
6039 ( u31[0][k] * dPhiTransU[k][j][1] + u21[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][1] ) +
6040 2 * u31[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][2];
6041 valDK1_32 = valDK1_32 + weights->at(k) *
6042 ( ( u32[0][k] * dPhiTransU[k][j][0] + u12[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][0] +
6043 ( u32[0][k] * dPhiTransU[k][j][1] + u22[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][1] ) +
6044 2 * u32[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][2];
6045 valDK1_33 = valDK1_33 + weights->at(k) *
6046 ( ( u33[0][k] * dPhiTransU[k][j][0] + u13[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][0] +
6047 ( u33[0][k] * dPhiTransU[k][j][1] + u23[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][1] ) +
6048 2 * u33[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][2];
6051 valDK2_11 = valDK2_11 + weights->at(k) *
6052 ( ( -sigma12[0][k] * dPhiTransU[k][j][1] - sigma13[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][0] +
6053 sigma12[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] +
6054 sigma13[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][2] );
6055 valDK2_12 = valDK2_12 + weights->at(k) *
6056 ( sigma11[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
6057 ( -sigma11[0][k] * dPhiTransU[k][j][0] - sigma13[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][1] +
6058 sigma13[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][2] );
6059 valDK2_13 = valDK2_13 + weights->at(k) *
6060 ( sigma11[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][0] +
6061 sigma12[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][1] +
6062 ( -sigma11[0][k] * dPhiTransU[k][j][0] - sigma12[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][2] );
6063 valDK2_21 = valDK2_21 + weights->at(k) *
6064 ( ( -sigma22[0][k] * dPhiTransU[k][j][1] - sigma23[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][0] +
6065 sigma22[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] +
6066 sigma23[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][2] );
6067 valDK2_22 = valDK2_22 + weights->at(k) *
6068 ( sigma21[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
6069 ( -sigma21[0][k] * dPhiTransU[k][j][0] - sigma23[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][1] +
6070 sigma23[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][2] );
6071 valDK2_23 = valDK2_23 + weights->at(k) *
6072 ( sigma21[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][0] +
6073 sigma22[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][1] +
6074 ( -sigma21[0][k] * dPhiTransU[k][j][0] - sigma22[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][2] );
6075 valDK2_31 = valDK2_31 + weights->at(k) *
6076 ( ( -sigma32[0][k] * dPhiTransU[k][j][1] - sigma33[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][0] +
6077 sigma32[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][1] +
6078 sigma33[0][k] * dPhiTransU[k][j][0] * dPhiTransU[k][i][2] );
6079 valDK2_32 = valDK2_32 + weights->at(k) *
6080 ( sigma31[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][0] +
6081 ( -sigma31[0][k] * dPhiTransU[k][j][0] - sigma33[0][k] * dPhiTransU[k][j][2] ) * dPhiTransU[k][i][1] +
6082 sigma33[0][k] * dPhiTransU[k][j][1] * dPhiTransU[k][i][2] );
6083 valDK2_33 = valDK2_33 + weights->at(k) *
6084 ( sigma31[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][0] +
6085 sigma32[0][k] * dPhiTransU[k][j][2] * dPhiTransU[k][i][1] +
6086 ( -sigma31[0][k] * dPhiTransU[k][j][0] - sigma32[0][k] * dPhiTransU[k][j][1] ) * dPhiTransU[k][i][2] );
6098 ZN_11 = - ( u2Loc[0][k] - w2Loc[0][k] ) * dPhiTransU[k][j][1] - ( u3Loc[0][k] - w3Loc[0][k] ) * dPhiTransU[k][j][2];
6099 ZN_12 = ( u2Loc[0][k] - w2Loc[0][k] ) * dPhiTransU[k][j][0];
6100 ZN_13 = ( u3Loc[0][k] - w3Loc[0][k] ) * dPhiTransU[k][j][0];
6101 ZN_21 = ( u1Loc[0][k] - w1Loc[0][k] ) * dPhiTransU[k][j][1];
6102 ZN_22 = - ( u1Loc[0][k] - w1Loc[0][k] ) * dPhiTransU[k][j][0] - ( u3Loc[0][k] - w3Loc[0][k] ) * dPhiTransU[k][j][2];
6103 ZN_23 = ( u3Loc[0][k] - w3Loc[0][k] ) * dPhiTransU[k][j][1];
6104 ZN_31 = ( u1Loc[0][k] - w1Loc[0][k] ) * dPhiTransU[k][j][2];
6105 ZN_32 = ( u2Loc[0][k] - w2Loc[0][k] ) * dPhiTransU[k][j][2];
6106 ZN_33 = - ( u1Loc[0][k] - w1Loc[0][k] ) * dPhiTransU[k][j][0] - ( u2Loc[0][k] - w2Loc[0][k] ) * dPhiTransU[k][j][1];
6108 valDN_11 = valDN_11 + weights->at(k) *
6109 ( ZN_11 * u11[0][k] * phiU->at(k).at(i) +
6110 ZN_12 * u12[0][k] * phiU->at(k).at(i) +
6111 ZN_13 * u13[0][k] * phiU->at(k).at(i) );
6112 valDN_12 = valDN_12 + weights->at(k) *
6113 ( ZN_21 * u11[0][k] * phiU->at(k).at(i) +
6114 ZN_22 * u12[0][k] * phiU->at(k).at(i) +
6115 ZN_23 * u13[0][k] * phiU->at(k).at(i) );
6116 valDN_13 = valDN_13 + weights->at(k) *
6117 ( ZN_31 * u11[0][k] * phiU->at(k).at(i) +
6118 ZN_32 * u12[0][k] * phiU->at(k).at(i) +
6119 ZN_33 * u13[0][k] * phiU->at(k).at(i) );
6120 valDN_21 = valDN_21 + weights->at(k) *
6121 ( ZN_11 * u21[0][k] * phiU->at(k).at(i) +
6122 ZN_12 * u22[0][k] * phiU->at(k).at(i) +
6123 ZN_13 * u23[0][k] * phiU->at(k).at(i) );
6124 valDN_22 = valDN_22 + weights->at(k) *
6125 ( ZN_21 * u21[0][k] * phiU->at(k).at(i) +
6126 ZN_22 * u22[0][k] * phiU->at(k).at(i) +
6127 ZN_23 * u23[0][k] * phiU->at(k).at(i) );
6128 valDN_23 = valDN_23 + weights->at(k) *
6129 ( ZN_31 * u21[0][k] * phiU->at(k).at(i) +
6130 ZN_32 * u22[0][k] * phiU->at(k).at(i) +
6131 ZN_33 * u23[0][k] * phiU->at(k).at(i) );
6132 valDN_31 = valDN_31 + weights->at(k) *
6133 ( ZN_11 * u31[0][k] * phiU->at(k).at(i) +
6134 ZN_12 * u32[0][k] * phiU->at(k).at(i) +
6135 ZN_13 * u33[0][k] * phiU->at(k).at(i) );
6136 valDN_32 = valDN_32 + weights->at(k) *
6137 ( ZN_21 * u31[0][k] * phiU->at(k).at(i) +
6138 ZN_22 * u32[0][k] * phiU->at(k).at(i) +
6139 ZN_23 * u33[0][k] * phiU->at(k).at(i) );
6140 valDN_33 = valDN_33 + weights->at(k) *
6141 ( ZN_31 * u31[0][k] * phiU->at(k).at(i) +
6142 ZN_32 * u32[0][k] * phiU->at(k).at(i) +
6143 ZN_33 * u33[0][k] * phiU->at(k).at(i) );
6146 valDW_11 = valDW_11 + weights->at(k) *
6147 ( u11[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6148 valDW_12 = valDW_12 + weights->at(k) *
6149 ( u12[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6150 valDW_13 = valDW_13 + weights->at(k) *
6151 ( u13[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6152 valDW_21 = valDW_21 + weights->at(k) *
6153 ( u21[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6154 valDW_22 = valDW_22 + weights->at(k) *
6155 ( u22[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6156 valDW_23 = valDW_23 + weights->at(k) *
6157 ( u23[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6158 valDW_31 = valDW_31 + weights->at(k) *
6159 ( u31[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6160 valDW_32 = valDW_32 + weights->at(k) *
6161 ( u32[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6162 valDW_33 = valDW_33 + weights->at(k) *
6163 ( u33[0][k] * phiU->at(k).at(j) * phiU->at(k).at(i) );
6169 ZP_1 = -w21[0][k] * dPhiTransU[k][j][1] + w22[0][k] * dPhiTransU[k][j][0] -
6170 w31[0][k] * dPhiTransU[k][j][2] + w33[0][k] * dPhiTransU[k][j][0];
6171 ZP_2 = w11[0][k] * dPhiTransU[k][j][1] - w12[0][k] * dPhiTransU[k][j][0] -
6172 w32[0][k] * dPhiTransU[k][j][2] + w33[0][k] * dPhiTransU[k][j][1];
6173 ZP_3 = w11[0][k] * dPhiTransU[k][j][2] - w13[0][k] * dPhiTransU[k][j][0] +
6174 w22[0][k] * dPhiTransU[k][j][2] - w23[0][k] * dPhiTransU[k][j][1];
6176 valDP_11 = valDP_11 + weights->at(k) *
6177 ( ZP_1 * u1Loc[0][k] * phiU->at(k).at(i) );
6178 valDP_12 = valDP_12 + weights->at(k) *
6179 ( ZP_2 * u1Loc[0][k] * phiU->at(k).at(i) );
6180 valDP_13 = valDP_13 + weights->at(k) *
6181 ( ZP_3 * u1Loc[0][k] * phiU->at(k).at(i) );
6182 valDP_21 = valDP_21 + weights->at(k) *
6183 ( ZP_1 * u2Loc[0][k] * phiU->at(k).at(i) );
6184 valDP_22 = valDP_22 + weights->at(k) *
6185 ( ZP_2 * u2Loc[0][k] * phiU->at(k).at(i) );
6186 valDP_23 = valDP_23 + weights->at(k) *
6187 ( ZP_3 * u2Loc[0][k] * phiU->at(k).at(i) );
6188 valDP_31 = valDP_31 + weights->at(k) *
6189 ( ZP_1 * u3Loc[0][k] * phiU->at(k).at(i) );
6190 valDP_32 = valDP_32 + weights->at(k) *
6191 ( ZP_2 * u3Loc[0][k] * phiU->at(k).at(i) );
6192 valDP_33 = valDP_33 + weights->at(k) *
6193 ( ZP_3 * u3Loc[0][k] * phiU->at(k).at(i) );
6196 valDM_11 = valDM_11 + weights->at(k) *
6197 ( dPhiTransU[k][j][0] * u1Loc[0][k] * phiU->at(k).at(i) );
6198 valDM_12 = valDM_12 + weights->at(k) *
6199 ( dPhiTransU[k][j][1] * u1Loc[0][k] * phiU->at(k).at(i) );
6200 valDM_13 = valDM_13 + weights->at(k) *
6201 ( dPhiTransU[k][j][2] * u1Loc[0][k] * phiU->at(k).at(i) );
6202 valDM_21 = valDM_21 + weights->at(k) *
6203 ( dPhiTransU[k][j][0] * u2Loc[0][k] * phiU->at(k).at(i) );
6204 valDM_22 = valDM_22 + weights->at(k) *
6205 ( dPhiTransU[k][j][1] * u2Loc[0][k] * phiU->at(k).at(i) );
6206 valDM_23 = valDM_23 + weights->at(k) *
6207 ( dPhiTransU[k][j][2] * u2Loc[0][k] * phiU->at(k).at(i) );
6208 valDM_31 = valDM_31 + weights->at(k) *
6209 ( dPhiTransU[k][j][0] * u3Loc[0][k] * phiU->at(k).at(i) );
6210 valDM_32 = valDM_32 + weights->at(k) *
6211 ( dPhiTransU[k][j][1] * u3Loc[0][k] * phiU->at(k).at(i) );
6212 valDM_33 = valDM_33 + weights->at(k) *
6213 ( dPhiTransU[k][j][2] * u3Loc[0][k] * phiU->at(k).at(i) );
6216 val11 = -rho*nu*valDK1_11 + valDK2_11 + rho*valDN_11 - rho*valDP_11 - (1.0/dt)*rho*valDW_11 + (0.5/dt)*rho*valDM_11;
6217 val12 = -rho*nu*valDK1_12 + valDK2_12 + rho*valDN_12 - rho*valDP_12 - (1.0/dt)*rho*valDW_12 + (0.5/dt)*rho*valDM_12;
6218 val13 = -rho*nu*valDK1_13 + valDK2_13 + rho*valDN_13 - rho*valDP_13 - (1.0/dt)*rho*valDW_13 + (0.5/dt)*rho*valDM_13;
6219 val21 = -rho*nu*valDK1_21 + valDK2_21 + rho*valDN_21 - rho*valDP_21 - (1.0/dt)*rho*valDW_21 + (0.5/dt)*rho*valDM_21;
6220 val22 = -rho*nu*valDK1_22 + valDK2_22 + rho*valDN_22 - rho*valDP_22 - (1.0/dt)*rho*valDW_22 + (0.5/dt)*rho*valDM_22;
6221 val23 = -rho*nu*valDK1_23 + valDK2_23 + rho*valDN_23 - rho*valDP_23 - (1.0/dt)*rho*valDW_23 + (0.5/dt)*rho*valDM_23;
6222 val31 = -rho*nu*valDK1_31 + valDK2_31 + rho*valDN_31 - rho*valDP_31 - (1.0/dt)*rho*valDW_31 + (0.5/dt)*rho*valDM_31;
6223 val32 = -rho*nu*valDK1_32 + valDK2_32 + rho*valDN_32 - rho*valDP_32 - (1.0/dt)*rho*valDW_32 + (0.5/dt)*rho*valDM_32;
6224 val33 = -rho*nu*valDK1_33 + valDK2_33 + rho*valDN_33 - rho*valDP_33 - (1.0/dt)*rho*valDW_33 + (0.5/dt)*rho*valDM_33;
6226 val11 = absDetB * val11;
6227 val12 = absDetB * val12;
6228 val13 = absDetB * val13;
6229 val21 = absDetB * val21;
6230 val22 = absDetB * val22;
6231 val23 = absDetB * val23;
6232 val31 = absDetB * val31;
6233 val32 = absDetB * val32;
6234 val33 = absDetB * val33;
6247 glob_j = dim * map->getGlobalElement(elements->getElement(T).getNode(j));
6248 glob_i = dim * map->getGlobalElement(elements->getElement(T).getNode(i));
6249 indices[0] = glob_j;
6251 D->insertGlobalValues(glob_i, indices(), value11());
6252 D->insertGlobalValues(glob_i+1, indices(), value21());
6253 D->insertGlobalValues(glob_i+2, indices(), value31());
6255 indices[0] = glob_j;
6256 D->insertGlobalValues(glob_i, indices(), value12());
6257 D->insertGlobalValues(glob_i+1, indices(), value22());
6258 D->insertGlobalValues(glob_i+2, indices(), value32());
6260 indices[0] = glob_j;
6261 D->insertGlobalValues(glob_i, indices(), value13());
6262 D->insertGlobalValues(glob_i+1, indices(), value23());
6263 D->insertGlobalValues(glob_i+2, indices(), value33());
6267 if (callFillComplete)
6276template <
class SC,
class LO,
class GO,
class NO>
6277void FE<SC,LO,GO,NO>::assemblyShapeDerivativeDivergence(
int dim,
6278 std::string FEType1,
6279 std::string FEType2,
6283 MapConstPtr_Type map1_unique,
6284 MapConstPtr_Type map2_unique,
6285 MultiVectorPtr_Type u,
6286 bool callFillComplete)
6288 DomainConstPtr_Type domain1 = this->domainVec_.at(FEloc1);
6289 ElementsPtr_Type elements = domain1->getElementsC();
6290 vec2D_dbl_ptr_Type pointsRep = domain1->getPointsRepeated();
6291 MapConstPtr_Type map1_rep = domain1->getMapRepeated();
6294 DomainConstPtr_Type domain2 = this->domainVec_.at(FEloc2);
6295 MapConstPtr_Type map2_rep = domain2->getMapRepeated();
6296 ElementsPtr_Type elements2 = domain2->getElementsC();
6298 vec3D_dbl_ptr_Type dPhiU;
6299 vec2D_dbl_ptr_Type phiU;
6300 vec2D_dbl_ptr_Type phiP;
6301 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
6302 vec2D_dbl_ptr_Type quadPts;
6321 Teuchos::ArrayRCP< const SC > uArray = u->getData(0);
6326 double valDB_1, valDB_2;
6327 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0);
6332 vec2D_dbl_Type u11(1, vec_dbl_Type(weights->size(), -1.));
6333 vec2D_dbl_Type u12(1, vec_dbl_Type(weights->size(), -1.));
6334 vec2D_dbl_Type u21(1, vec_dbl_Type(weights->size(), -1.));
6335 vec2D_dbl_Type u22(1, vec_dbl_Type(weights->size(), -1.));
6337 for (
int T = 0; T < elements->numberElements(); T++)
6339 p1 = pointsRep->at(elements->getElement(T).getNode(0));
6340 p2 = pointsRep->at(elements->getElement(T).getNode(1));
6341 p3 = pointsRep->at(elements->getElement(T).getNode(2));
6344 detB = B.computeInverse(Binv);
6345 absDetB = std::fabs(detB);
6348 vec3D_dbl_Type dPhiTransU( dPhiU->size(), vec2D_dbl_Type( dPhiU->at(0).size(), vec_dbl_Type(dim,0.) ) );
6349 applyBTinv( dPhiU, dPhiTransU, Binv );
6353 for(
int k = 0; k < dPhiTransU.size(); k++)
6359 for(
int i = 0; i < dPhiTransU[0].size(); i++)
6361 LO index1 = dim * elements2->getElement(T).getNode(i) + 0;
6362 LO index2 = dim * elements2->getElement(T).getNode(i) + 1;
6363 u11[0][k] += uArray[index1] * dPhiTransU[k][i][0];
6364 u12[0][k] += uArray[index1] * dPhiTransU[k][i][1];
6365 u21[0][k] += uArray[index2] * dPhiTransU[k][i][0];
6366 u22[0][k] += uArray[index2] * dPhiTransU[k][i][1];
6371 for (
int i = 0; i < phiP->at(0).size(); i++)
6373 Teuchos::Array<SC> value1( 1, 0. );
6374 Teuchos::Array<SC> value2( 1, 0. );
6375 Teuchos::Array<GO> indices( 1, 0 );
6377 for (
int j = 0; j < dPhiU->at(0).size(); j++)
6382 for (
int k = 0; k < dPhiU->size(); k++)
6385 valDB_1 = valDB_1 + weights->at(k) *
6386 ( phiP->at(k).at(i) * ( -u21[0][k] * dPhiTransU[k][j][1] + u22[0][k] * dPhiTransU[k][j][0] ) );
6387 valDB_2 = valDB_2 + weights->at(k) *
6388 ( phiP->at(k).at(i) * ( u11[0][k] * dPhiTransU[k][j][1] - u12[0][k] * dPhiTransU[k][j][0] ) );
6394 val1 = absDetB * val1;
6395 val2 = absDetB * val2;
6400 glob_j = dim * map2_rep->getGlobalElement(elements2->getElement(T).getNode(j));
6401 glob_i = map1_rep->getGlobalElement(elements->getElement(T).getNode(i));
6402 indices[0] = glob_j;
6404 DB->insertGlobalValues(glob_i, indices(), value1());
6406 indices[0] = glob_j;
6407 DB->insertGlobalValues(glob_i, indices(), value2());
6411 if (callFillComplete)
6413 DB->fillComplete(map2_unique, map1_unique);
6418 double val1, val2, val3;
6419 double valDB_1, valDB_2, valDB_3;
6420 vec_dbl_Type p1(3,0.0), p2(3,0.0), p3(3,0.0), p4(3,0.0);
6425 vec2D_dbl_Type u11(1, vec_dbl_Type(weights->size(), -1.));
6426 vec2D_dbl_Type u12(1, vec_dbl_Type(weights->size(), -1.));
6427 vec2D_dbl_Type u13(1, vec_dbl_Type(weights->size(), -1.));
6428 vec2D_dbl_Type u21(1, vec_dbl_Type(weights->size(), -1.));
6429 vec2D_dbl_Type u22(1, vec_dbl_Type(weights->size(), -1.));
6430 vec2D_dbl_Type u23(1, vec_dbl_Type(weights->size(), -1.));
6431 vec2D_dbl_Type u31(1, vec_dbl_Type(weights->size(), -1.));
6432 vec2D_dbl_Type u32(1, vec_dbl_Type(weights->size(), -1.));
6433 vec2D_dbl_Type u33(1, vec_dbl_Type(weights->size(), -1.));
6435 for (
int T = 0; T < elements->numberElements(); T++)
6437 p1 = pointsRep->at(elements->getElement(T).getNode(0));
6438 p2 = pointsRep->at(elements->getElement(T).getNode(1));
6439 p3 = pointsRep->at(elements->getElement(T).getNode(2));
6440 p4 = pointsRep->at(elements->getElement(T).getNode(3));
6443 detB = B.computeInverse(Binv);
6444 absDetB = std::fabs(detB);
6447 vec3D_dbl_Type dPhiTransU( dPhiU->size(), vec2D_dbl_Type( dPhiU->at(0).size(), vec_dbl_Type(dim,0.) ) );
6448 applyBTinv( dPhiU, dPhiTransU, Binv );
6452 for(
int k = 0; k < dPhiTransU.size(); k++)
6464 for(
int i = 0; i < dPhiTransU[0].size(); i++)
6466 LO index1 = dim * elements2->getElement(T).getNode(i) + 0;
6467 LO index2 = dim * elements2->getElement(T).getNode(i) + 1;
6468 LO index3 = dim * elements2->getElement(T).getNode(i) + 2;
6469 u11[0][k] += uArray[index1] * dPhiTransU[k][i][0];
6470 u12[0][k] += uArray[index1] * dPhiTransU[k][i][1];
6471 u13[0][k] += uArray[index1] * dPhiTransU[k][i][2];
6472 u21[0][k] += uArray[index2] * dPhiTransU[k][i][0];
6473 u22[0][k] += uArray[index2] * dPhiTransU[k][i][1];
6474 u23[0][k] += uArray[index2] * dPhiTransU[k][i][2];
6475 u31[0][k] += uArray[index3] * dPhiTransU[k][i][0];
6476 u32[0][k] += uArray[index3] * dPhiTransU[k][i][1];
6477 u33[0][k] += uArray[index3] * dPhiTransU[k][i][2];
6481 for (
int i = 0; i < phiP->at(0).size(); i++)
6483 Teuchos::Array<SC> value1( 1, 0. );
6484 Teuchos::Array<SC> value2( 1, 0. );
6485 Teuchos::Array<SC> value3( 1, 0. );
6486 Teuchos::Array<GO> indices( 1, 0 );
6488 for (
int j = 0; j < dPhiU->at(0).size(); j++)
6494 for (
int k = 0; k < dPhiU->size(); k++)
6497 valDB_1 = valDB_1 + weights->at(k) *
6498 ( phiP->at(k).at(i) * ( -u21[0][k] * dPhiTransU[k][j][1] + u22[0][k] * dPhiTransU[k][j][0] -
6499 u31[0][k] * dPhiTransU[k][j][2] + u33[0][k] * dPhiTransU[k][j][0] ) );
6500 valDB_2 = valDB_2 + weights->at(k) *
6501 ( phiP->at(k).at(i) * ( u11[0][k] * dPhiTransU[k][j][1] - u12[0][k] * dPhiTransU[k][j][0] -
6502 u32[0][k] * dPhiTransU[k][j][2] + u33[0][k] * dPhiTransU[k][j][1] ) );
6503 valDB_3 = valDB_3 + weights->at(k) *
6504 ( phiP->at(k).at(i) * ( u11[0][k] * dPhiTransU[k][j][2] - u13[0][k] * dPhiTransU[k][j][0] +
6505 u22[0][k] * dPhiTransU[k][j][2] - u23[0][k] * dPhiTransU[k][j][1] ) );
6512 val1 = absDetB * val1;
6513 val2 = absDetB * val2;
6514 val3 = absDetB * val3;
6520 glob_j = dim * map2_rep->getGlobalElement(elements2->getElement(T).getNode(j));
6521 glob_i = map1_rep->getGlobalElement(elements->getElement(T).getNode(i));
6522 indices[0] = glob_j;
6524 DB->insertGlobalValues(glob_i, indices(), value1());
6526 indices[0] = glob_j;
6527 DB->insertGlobalValues(glob_i, indices(), value2());
6529 indices[0] = glob_j;
6530 DB->insertGlobalValues(glob_i, indices(), value3());
6534 if (callFillComplete)
6536 DB->fillComplete(map2_unique, map1_unique);
6542template <
class SC,
class LO,
class GO,
class NO>
6543void FE<SC,LO,GO,NO>::assemblySurfaceIntegralExternal(
int dim,
6545 MultiVectorPtr_Type f,
6546 MultiVectorPtr_Type d_rep,
6547 std::vector<SC>& funcParameter,
6549 ParameterListPtr_Type params,
6552 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
6554 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
6558 vec_dbl_Type b(dim);
6560 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
6562 int flagSurface = params->sublist(
"Parameter Solid").get(
"Flag Surface",5);
6564 std::vector<double> valueFunc(dim);
6566 SC* paramsFunc = &(funcParameter[0]);
6569 for (UN T=0; T<elements->numberElements(); T++) {
6571 ElementsPtr_Type subEl = fe.getSubElements();
6572 for (
int surface=0; surface<fe.numSubElements(); surface++) {
6574 if(subEl->getDimension() == dim-1 ){
6576 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
6579 vec_dbl_Type solution_d = this->getSolution(nodeList, d_rep,dim);
6580 vec2D_dbl_Type nodes;
6581 nodes = this->getCoordinates(nodeList, pointsRep);
6584 double positions[18];
6586 for(
int i=0;i<6;i++)
6587 for(
int j=0;j<3;j++){
6588 positions[count] = nodes[i][j];
6594 paramsFunc[ funcParameter.size() - 1 ] = feSub.getFlag();
6595 vec_dbl_Type p1 = {0.,0.,0.};
6596 func( &p1[0], &valueFunc[0], paramsFunc);
6598 if(valueFunc[0] != 0.){
6600 double *residuumVector;
6601 #ifdef FEDD_HAVE_ACEGENINTERFACE
6603 AceGenInterface::PressureTriangle3D6 pt(valueFunc[0], 1., 35, &positions[0], &solution_d[0]);
6604 pt.computeTangentResidual();
6605 residuumVector = pt.getResiduum();
6608 for(
int i=0; i< nodeList.size() ; i++){
6609 for(
int d=0; d<dim; d++)
6610 valuesF[nodeList[i]*dim+d] += residuumVector[i*dim+d];
6626template <
class SC,
class LO,
class GO,
class NO>
6629 MultiVectorPtr_Type f,
6630 MultiVectorPtr_Type d_rep,
6631 MatrixPtr_Type &Kext,
6632 std::vector<SC>& funcParameter,
6634 ParameterListPtr_Type params,
6639 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
6641 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
6643 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
6646 vec_dbl_Type b(dim);
6648 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
6650 std::vector<double> valueFunc(dim);
6652 SC* paramsFunc = &(funcParameter[0]);
6655 for (UN T=0; T<elements->numberElements(); T++) {
6657 ElementsPtr_Type subEl = fe.getSubElements();
6658 for (
int surface=0; surface<fe.numSubElements(); surface++) {
6660 if(subEl->getDimension() == dim-1 ){
6661 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
6663 vec_dbl_Type solution_d = this->
getSolution(nodeList, d_rep,dim);
6664 vec2D_dbl_Type nodes;
6668 double positions[18];
6670 for(
int i=0;i<6;i++){
6671 for(
int j=0;j<3;j++){
6672 positions[count] = nodes[i][j];
6678 vec_dbl_Type p1 = {0.,0.,0.};
6679 paramsFunc[ funcParameter.size() - 1 ] = feSub.getFlag();
6680 func( &p1[0], &valueFunc[0], paramsFunc);
6682 if(valueFunc[0] != 0.){
6684 double *residuumVector;
6687 #ifdef FEDD_HAVE_ACEGENINTERFACE
6688 AceGenInterface::PressureTriangle3D6 pt(valueFunc[0], 1.0, 35, &positions[0], &solution_d[0]);
6689 pt.computeTangentResidual();
6691 residuumVector = pt.getResiduum();
6692 stiffMat = pt.getStiffnessMatrix();
6698 int numNodes1 =nodeList.size();
6700 SmallMatrix_Type elementMatrixPrint(18,0.);
6701 for(
int i=0; i< 18 ; i++){
6702 for(
int j=0; j< 18; j++){
6703 if(std::fabs(stiffMat[i][j]) >1e-13)
6704 elementMatrixPrint[i][j] = stiffMat[i][j];
6709 SmallMatrix_Type elementMatrixWrite(18,0.);
6711 SmallMatrix_Type elementMatrixIDsRow(18,0.);
6712 SmallMatrix_Type elementMatrixIDsCol(18,0.);
6715 for (UN i=0; i < numNodes1 ; i++) {
6716 for(
int di=0; di<dim; di++){
6717 Teuchos::Array<SC> value1( numNodes1*dim, 0. );
6718 Teuchos::Array<GO> columnIndices1( numNodes1*dim, 0 );
6719 GO row =GO (dim* map->getGlobalElement( nodeList[i] )+di);
6720 LO rowLO = dim*i+di;
6722 for (UN j=0; j <numNodes1; j++){
6723 for(
int d=0; d<dim; d++){
6724 columnIndices1[dim*j+d] = GO ( dim * map->getGlobalElement( nodeList[j] ) + d );
6725 value1[dim*j+d] = stiffMat[rowLO][dim*j+d];
6728 Kext->insertGlobalValues( row, columnIndices1(), value1() );
6734 for(
int i=0; i< nodeList.size() ; i++){
6735 for(
int d=0; d<dim; d++){
6736 valuesF[nodeList[i]*dim+d] += residuumVector[i*dim+d];
6748 Kext->fillComplete(this->domainVec_.at(FEloc)->getMapVecFieldUnique(),this->domainVec_.at(FEloc)->getMapVecFieldUnique());
6753template <
class SC,
class LO,
class GO,
class NO>
6754void FE<SC,LO,GO,NO>::assemblySurfaceIntegral(
int dim,
6756 MultiVectorPtr_Type f,
6757 std::string fieldType,
6759 std::vector<SC>& funcParameter) {
6763 UN FEloc = this->checkFE(dim,FEType);
6765 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
6767 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
6769 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
6770 vec2D_dbl_ptr_Type phi;
6771 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
6773 UN degFunc = funcParameter[funcParameter.size()-1] + 1.e-14;
6778 vec2D_dbl_ptr_Type quadPoints;
6779 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
6785 vec_dbl_Type b(dim);
6787 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
6791 std::vector<double> valueFunc(dim);
6793 SC* params = &(funcParameter[0]);
6794 for (UN T=0; T<elements->numberElements(); T++) {
6796 ElementsPtr_Type subEl = fe.getSubElements();
6797 for (
int surface=0; surface<fe.numSubElements(); surface++) {
6799 if(subEl->getDimension() == dim-1){
6801 params[ funcParameter.size() - 1 ] = feSub.getFlag();
6803 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
6805 vec_dbl_Type v_E(dim,1.);
6811 elScaling = B.computeScaling( );
6813 for (UN i=0; i < phi->at(0).size(); i++) {
6814 Teuchos::Array<SC> value(0);
6815 if ( fieldType ==
"Scalar" )
6816 value.resize( 1, 0. );
6817 else if ( fieldType ==
"Vector" )
6818 value.resize( dim, 0. );
6820 for (UN w=0; w<phi->size(); w++) {
6821 vec_dbl_Type x(dim,0.);
6822 for (
int k=0; k<dim; k++) {
6823 for (
int l=0; l<dim-1; l++){
6824 x[ k ] += B[k][l] * (*quadPoints)[ w ][ l ];
6829 func( &x[0], &valueFunc[0], params);
6830 if ( fieldType ==
"Scalar" )
6831 value[0] += weights->at(w) * valueFunc[0] * (*phi)[w][i];
6832 else if ( fieldType ==
"Vector" ){
6833 for (
int j=0; j<value.size(); j++){
6834 value[j] += weights->at(w) * valueFunc[j]*v_E[j]/norm_v_E * (*phi)[w][i];
6839 for (
int j=0; j<value.size(); j++)
6840 value[j] *= elScaling;
6842 if ( fieldType==
"Scalar" )
6843 valuesF[ nodeList[ i ] ] += value[0];
6846 else if ( fieldType==
"Vector" ){
6847 for (
int j=0; j<value.size(); j++)
6848 valuesF[ dim * nodeList[ i ] + j ] += value[j];
6857template <
class SC,
class LO,
class GO,
class NO>
6858void FE<SC,LO,GO,NO>::assemblySurfaceIntegralFlag(
int dim,
6860 MultiVectorPtr_Type f,
6861 std::string fieldType,
6863 std::vector<SC>& funcParameter) {
6866 TEUCHOS_TEST_FOR_EXCEPTION(funcParameter[0]!=0,std::logic_error,
"We only support constant functions for now.");
6868 UN FEloc = this->checkFE(dim,FEType);
6870 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
6872 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
6874 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
6875 vec2D_dbl_ptr_Type phi;
6876 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
6877 UN degFunc = funcParameter[0] + 1.e-14;
6882 vec2D_dbl_ptr_Type quadPoints;
6883 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
6889 vec_dbl_Type b(dim);
6891 Teuchos::ArrayRCP< SC > valuesF = f->getDataNonConst(0);
6894 std::vector<double> valueFunc(dim);
6895 SC* params = &(funcParameter[1]);
6896 for (UN T=0; T<elements->numberElements(); T++) {
6898 ElementsPtr_Type subEl = fe.getSubElements();
6899 for (
int surface=0; surface<fe.numSubElements(); surface++) {
6901 if (params[1] == feSub.getFlag()){
6903 vec_int_Type nodeList = feSub.getVectorNodeListNonConst ();
6905 elScaling = B.computeScaling( );
6907 for (UN i=0; i < phi->at(0).size(); i++) {
6908 Teuchos::Array<SC> value(0);
6909 if ( fieldType ==
"Scalar" )
6910 value.resize( 1, 0. );
6911 else if ( fieldType ==
"Vector" )
6912 value.resize( dim, 0. );
6914 for (UN w=0; w<phi->size(); w++) {
6915 vec_dbl_Type x(dim,0.);
6916 for (
int k=0; k<dim; k++) {
6917 for (
int l=0; l<dim-1; l++)
6918 x[ k ] += B[k][l] * (*quadPoints)[ w ][ l ];
6922 func( &x[0], &valueFunc[0], params[0], params);
6924 if ( fieldType ==
"Scalar" )
6925 value[0] += weights->at(w) * valueFunc[0] * (*phi)[w][i];
6926 else if ( fieldType ==
"Vector" ){
6927 for (
int j=0; j<value.size(); j++){
6928 value[j] += weights->at(w) * valueFunc[j] * (*phi)[w][i];
6933 for (
int j=0; j<value.size(); j++)
6934 value[j] *= elScaling;
6936 if ( fieldType==
"Scalar" )
6937 valuesF[ nodeList[ i ] ] += value[0];
6940 else if ( fieldType==
"Vector" ){
6941 for (
int j=0; j<value.size(); j++)
6942 valuesF[ dim * nodeList[ i ] + j ] += value[j];
6951template <
class SC,
class LO,
class GO,
class NO>
6952void FE<SC,LO,GO,NO>::assemblyRHS(
int dim,
6954 MultiVectorPtr_Type a,
6955 std::string fieldType,
6957 std::vector<SC>& funcParameter
6960 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
6962 TEUCHOS_TEST_FOR_EXCEPTION( a.is_null(), std::runtime_error,
"MultiVector in assemblyConstRHS is null." );
6963 TEUCHOS_TEST_FOR_EXCEPTION( a->getNumVectors()>1, std::logic_error,
"Implement for numberMV > 1 ." );
6965 FEloc = this->checkFE(dim,FEType);
6967 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
6969 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
6971 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
6972 vec2D_dbl_ptr_Type phi;
6973 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
6982 vec2D_dbl_ptr_Type quadPoints;
6992 vec_dbl_Type v_i(dim);
6993 vec_dbl_Type v_j(dim);
6995 Teuchos::ArrayRCP< SC > valuesRhs = a->getDataNonConst(0);
6999 std::vector<double> valueFunc(dim);
7000 SC* paras = &(funcParameter[0]);
7002 func( &x, &valueFunc[0], paras );
7005 for (UN T=0; T<elements->numberElements(); T++) {
7008 detB = B.computeDet( );
7009 absDetB = std::fabs(detB);
7011 vec2D_dbl_Type quadPointsTrans(weights->size(),vec_dbl_Type(dim));
7012 for(
int i=0; i< weights->size(); i++){
7013 for(
int j=0; j< dim ; j++){
7014 for(
int k=0; k< dim; k++){
7015 quadPointsTrans[i][j] += B[j][k]* quadPoints->at(i).at(k) ;
7017 quadPointsTrans[i][j] += pointsRep->at(elements->getElement(T).getNode(0)).at(j);
7020 for (UN i=0; i < phi->at(0).size(); i++) {
7021 if ( !fieldType.compare(
"Scalar") ) {
7022 value = Teuchos::ScalarTraits<SC>::zero();
7023 for (UN w=0; w<weights->size(); w++){
7024 func(&quadPointsTrans[w][0], &valueFunc[0] ,paras);
7025 value += weights->at(w) * phi->at(w).at(i)*valueFunc[0];
7028 LO row = (LO) elements->getElement(T).getNode(i);
7029 valuesRhs[row] += value;
7031 else if( !fieldType.compare(
"Vector") ) {
7032 for (UN d=0; d<dim; d++) {
7033 value = Teuchos::ScalarTraits<SC>::zero();
7034 for (UN w=0; w<weights->size(); w++){
7035 func(&quadPointsTrans[w][0], &valueFunc[0] ,paras);
7036 value += weights->at(w) * phi->at(w).at(i)*valueFunc[d];
7040 LO row = (LO) ( dim * elements->getElement(T).getNode(i) + d );
7041 valuesRhs[row] += v_i;
7045 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Invalid field type." );
7056template <
class SC,
class LO,
class GO,
class NO>
7059 MultiVectorPtr_Type a)
7062 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
7064 TEUCHOS_TEST_FOR_EXCEPTION( a.is_null(), std::runtime_error,
"Multivector is null." );
7067 FEloc = this->
checkFE(dim,FEType);
7069 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
7071 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
7073 vec2D_dbl_ptr_Type phi;
7074 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
7078 vec2D_dbl_ptr_Type quadPoints;
7088 MultiVectorPtr_Type a_rep = Teuchos::rcp(
new MultiVector_Type( this->domainVec_.at(FEloc)->getMapRepeated(), 1 ) );
7089 a_rep->putScalar(0.);
7090 Teuchos::ArrayRCP< SC > values_a = a_rep->getDataNonConst(0);
7092 for (UN T=0; T<elements->numberElements(); T++) {
7095 detB = B.computeDet( );
7096 absDetB = std::fabs(detB);
7098 for (UN i=0; i < phi->at(0).size(); i++) {
7099 Teuchos::Array<SC> value( 1, 0. );
7100 for (UN w=0; w<weights->size(); w++){
7101 value[0] += weights->at(w) * phi->at(w).at(i)*1.0;
7103 value[0] *= absDetB;
7104 LO row = (LO) elements->getElement(T).getNode(i);
7106 values_a[row] += value[0];
7112 a->exportFromVector( a_rep,
true,
"Add" );
7116template <
class SC,
class LO,
class GO,
class NO>
7117void FE<SC,LO,GO,NO>::assemblyRHSDegTest(
int dim,
7119 MultiVectorPtr_Type a,
7120 std::string fieldType,
7122 std::vector<SC>& funcParameter,
7125 TEUCHOS_TEST_FOR_EXCEPTION(FEType ==
"P0",std::logic_error,
"Not implemented for P0");
7127 TEUCHOS_TEST_FOR_EXCEPTION( a.is_null(), std::runtime_error,
"MultiVector in assemblyConstRHS is null." );
7128 TEUCHOS_TEST_FOR_EXCEPTION( a->getNumVectors()>1, std::logic_error,
"Implement for numberMV > 1 ." );
7130 UN FEloc = this->checkFE(dim,FEType);
7132 ElementsPtr_Type elements = this->domainVec_.at(FEloc)->getElementsC();
7134 vec2D_dbl_ptr_Type pointsRep = this->domainVec_.at(FEloc)->getPointsRepeated();
7136 MapConstPtr_Type map = this->domainVec_.at(FEloc)->getMapRepeated();
7137 vec2D_dbl_ptr_Type phi;
7138 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
7141 vec2D_dbl_ptr_Type quadPoints;
7142 vec_dbl_ptr_Type w = Teuchos::rcp(
new vec_dbl_Type(0));
7150 vec_dbl_Type b(dim);
7152 vec_dbl_Type v_i(dim);
7153 vec_dbl_Type v_j(dim);
7155 Teuchos::ArrayRCP< SC > valuesRhs = a->getDataNonConst(0);
7159 std::vector<double> valueFunc(dim);
7160 SC* params = &(funcParameter[1]);
7161 for (UN T=0; T<elements->numberElements(); T++) {
7164 detB = B.computeDet( );
7165 absDetB = std::fabs(detB);
7167 for (UN i=0; i < phi->at(0).size(); i++) {
7168 Teuchos::Array<SC> value(1);
7169 for (UN w=0; w<weights->size(); w++){
7170 vec_dbl_Type x(dim,0.);
7171 for (
int k=0; k<dim; k++) {
7172 for (
int l=0; l<dim; l++)
7173 x[ k ] += B[k][l] * (*quadPoints)[ w ][ l ] + b[k];
7176 func( &x[0], &valueFunc[0], params);
7177 if ( !fieldType.compare(
"Scalar") ) {
7178 value[0] += weights->at(w) * valueFunc[0] * (*phi)[w][i];
7180 else if( !fieldType.compare(
"Vector") ) {
7181 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"No test for field type Vector." );
7184 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Invalid field type." );
7187 value[0] *= absDetB;
7188 LO row = (LO) elements->getElement(T).getNode(i);
7189 valuesRhs[row] += value[0];
7196template <
class SC,
class LO,
class GO,
class NO>
7197void FE<SC,LO,GO,NO>::buildFullDPhi(vec3D_dbl_ptr_Type dPhi, Teuchos::Array<
SmallMatrix<double> >& dPhiMat){
7199 TEUCHOS_TEST_FOR_EXCEPTION(dPhi->size()*dPhi->at(0).size()*dPhi->at(0).at(0).size() != dPhiMat.size(), std::logic_error,
"Wrong sizes for dPhi and dPhiMat.");
7201 int dim = dPhi->at(0).at(0).size();
7202 int nmbBasisFunc = dPhi->at(0).size();
7203 int nmbTotalBasisFunc = nmbBasisFunc * dim;
7205 for (
int p=0; p<dPhi->size(); p++) {
7206 for (
int i=0; i<nmbBasisFunc; i++) {
7207 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][0][0] = dPhi->at(p).at(i).at(0);
7208 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][0][1] = dPhi->at(p).at(i).at(1);
7209 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][1][0] = 0.;
7210 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][1][1] = 0.;
7212 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][0][0] = 0.;
7213 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][0][1] = 0.;
7214 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][1][0] = dPhi->at(p).at(i).at(0);
7215 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][1][1] = dPhi->at(p).at(i).at(1);
7220 for (
int p=0; p<dPhi->size(); p++) {
7221 for (
int i=0; i<nmbBasisFunc; i++) {
7222 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][0][0] = dPhi->at(p).at(i).at(0);
7223 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][0][1] = dPhi->at(p).at(i).at(1);
7224 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][0][2] = dPhi->at(p).at(i).at(2);
7225 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][1][0] = 0.;
7226 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][1][1] = 0.;
7227 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][1][2] = 0.;
7228 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][2][0] = 0.;
7229 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][2][1] = 0.;
7230 dPhiMat[ p * nmbTotalBasisFunc + dim*i ][2][2] = 0.;
7232 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][0][0] = 0.;
7233 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][0][1] = 0.;
7234 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][0][2] = 0.;
7235 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][1][0] = dPhi->at(p).at(i).at(0);
7236 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][1][1] = dPhi->at(p).at(i).at(1);
7237 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][1][2] = dPhi->at(p).at(i).at(2);
7238 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][2][0] = 0.;
7239 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][2][1] = 0.;
7240 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 1 ][2][2] = 0.;
7242 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][0][0] = 0.;
7243 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][0][1] = 0.;
7244 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][0][2] = 0.;
7245 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][1][0] = 0.;
7246 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][1][1] = 0.;
7247 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][1][2] = 0.;
7248 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][2][0] = dPhi->at(p).at(i).at(0);
7249 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][2][1] = dPhi->at(p).at(i).at(1);
7250 dPhiMat[ p * nmbTotalBasisFunc + dim*i + 2 ][2][2] = dPhi->at(p).at(i).at(2);
7256template <
class SC,
class LO,
class GO,
class NO>
7257void FE<SC,LO,GO,NO>::fillMatrixArray(
SmallMatrix<double> &matIn,
double* matArrayOut, std::string order,
int offset){
7258 if (!order.compare(
"cols")) {
7259 for (
int j=0; j<matIn.size(); j++) {
7260 for (
int i=0; i<matIn.size(); i++) {
7261 matArrayOut[ j * matIn.size() + i + offset ] = matIn[i][j];
7265 else if(!order.compare(
"rows")) {
7266 for (
int i=0; i<matIn.size(); i++) {
7267 for (
int j=0; j<matIn.size(); j++) {
7268 matArrayOut[ i * matIn.size() + j + offset ] = matIn[i][j];
7273 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Unknown ordering for matrix to array conversion. Choose rows or cols.");
7276template <
class SC,
class LO,
class GO,
class NO>
7277void FE<SC,LO,GO,NO>::epsilonTensor(vec_dbl_Type &basisValues,
SmallMatrix<SC> &epsilonValues,
int activeDof){
7279 for (
int i=0; i<epsilonValues.size(); i++) {
7280 for (
int j=0; j<epsilonValues.size(); j++) {
7281 epsilonValues[i][j] = 0.;
7283 epsilonValues[i][j] += 0.5*basisValues.at(j);
7286 epsilonValues[i][j] += 0.5*basisValues.at(i);
7305template <
class SC,
class LO,
class GO,
class NO>
7306void FE<SC,LO,GO,NO>::nh3d(
double* v,
double (*E),
double (*Nu),
double** F ,
double** Pmat,
double**** Amat)
7310 v[323]=(*E)/(1e0+(*Nu));
7311 v[3]=((*Nu)*v[323])/(1e0-2e0*(*Nu));
7321 v[18]=F[0][0]*F[0][1]+F[1][0]*F[1][1]+F[2][0]*F[2][1];
7322 v[335]=(v[18]*v[18]);
7324 v[24]=F[0][1]*F[0][2]+F[1][1]*F[1][2]+F[2][1]*F[2][2];
7325 v[334]=(v[24]*v[24]);
7327 v[22]=F[0][0]*F[0][2]+F[1][0]*F[1][2]+F[2][0]*F[2][2];
7328 v[15]=Power(F[0][0],2)+Power(F[1][0],2)+Power(F[2][0],2);
7329 v[228]=-(F[2][1]*v[18]);
7330 v[225]=F[2][2]*v[18];
7331 v[217]=-(F[1][1]*v[18]);
7332 v[214]=F[1][2]*v[18];
7333 v[194]=-(F[2][0]*v[18]);
7334 v[185]=-(F[1][0]*v[18]);
7335 v[268]=F[2][1]*v[22];
7336 v[264]=-(F[2][2]*v[22]);
7337 v[255]=F[1][1]*v[22];
7338 v[251]=-(F[1][2]*v[22]);
7339 v[190]=-(F[2][0]*v[22]);
7340 v[181]=-(F[1][0]*v[22]);
7341 v[172]=-(F[0][0]*v[22]);
7342 v[20]=Power(F[0][1],2)+Power(F[1][1],2)+Power(F[2][1],2);
7343 v[324]=-(v[20]*v[22]);
7344 v[327]=2e0*(v[324]+v[325]);
7348 v[138]=v[15]*v[20]-v[335];
7349 v[270]=F[2][0]*v[24];
7350 v[260]=-(F[2][2]*v[24]);
7351 v[257]=F[1][0]*v[24];
7352 v[247]=-(F[1][2]*v[24]);
7353 v[244]=F[0][0]*v[24];
7354 v[232]=-(F[0][2]*v[24]);
7355 v[222]=-(F[2][1]*v[24]);
7356 v[211]=-(F[1][1]*v[24]);
7357 v[198]=-(F[0][1]*v[24]);
7358 v[168]=v[18]*v[22]-v[15]*v[24];
7362 v[38]=-(v[22]*v[22]);
7363 v[26]=Power(F[0][2],2)+Power(F[1][2],2)+Power(F[2][2],2);
7364 v[333]=v[20]*v[26]-v[334];
7365 v[351]=2e0*F[0][0]*v[333];
7366 v[236]=v[22]*v[24]-v[18]*v[26];
7375 v[148]=v[15]*v[26]+v[38];
7376 v[29]=v[148]*v[20]+2e0*v[22]*v[325]-v[15]*v[334]-v[26]*v[335];
7377 v[336]=1e0/Power(v[29],2);
7378 v[32]=-v[5]+v[3]*std::log(std::sqrt(v[29]));
7379 v[337]=(v[3]/4e0-v[32]/2e0)*v[336];
7380 v[137]=v[337]*(F[2][1]*v[326]+F[2][0]*v[327]-v[335]*v[88]+v[15]*v[94]);
7381 v[147]=v[137]*v[138];
7382 v[136]=v[337]*(F[2][2]*v[329]+F[2][0]*v[330]+v[38]*v[67]+v[15]*v[93]);
7383 v[156]=v[136]*v[148];
7384 v[135]=v[337]*(F[2][2]*v[327]+F[2][1]*v[328]-v[334]*v[58]+v[20]*v[99]);
7385 v[165]=v[135]*v[333];
7386 v[134]=v[337]*(F[1][1]*v[326]+F[1][0]*v[327]-v[335]*v[87]+v[15]*v[92]);
7387 v[144]=v[134]*v[138];
7388 v[133]=v[337]*(F[1][2]*v[331]+F[1][0]*v[332]+v[38]*v[66]+v[15]*v[91]);
7389 v[153]=v[133]*v[148];
7390 v[132]=v[337]*(F[1][2]*v[327]+F[1][1]*v[328]-v[334]*v[57]+v[20]*v[97]);
7391 v[162]=v[132]*v[333];
7392 v[131]=v[337]*(F[0][0]*v[327]+F[0][1]*v[329]-v[335]*v[86]+v[15]*v[90]);
7393 v[130]=v[337]*(F[0][2]*v[331]+F[0][0]*v[332]+v[38]*v[65]+v[15]*v[89]);
7394 v[128]=v[337]*(F[0][2]*v[327]+F[0][1]*v[330]+v[351]);
7395 v[37]=v[32]/(2e0*v[29]);
7396 v[355]=v[37]*(2e0*v[172]+v[15]*v[86]);
7397 v[353]=v[37]*(2e0*v[232]+v[89]);
7398 v[352]=v[37]*(2e0*v[198]+v[90]);
7399 v[349]=-2e0*(F[1][0]*v[20]+v[217])*v[37];
7400 v[348]=-(v[37]*(2e0*v[185]+v[15]*v[66]));
7401 v[347]=-2e0*(F[2][0]*v[20]+v[228])*v[37];
7402 v[346]=-(v[37]*(2e0*v[194]+v[15]*v[67]));
7403 v[345]=-(v[37]*(2e0*v[251]+v[97]));
7404 v[344]=-(v[37]*(2e0*v[181]+v[15]*v[87]));
7405 v[343]=-(v[37]*(2e0*v[264]+v[99]));
7406 v[342]=-(v[37]*(2e0*v[190]+v[15]*v[88]));
7407 v[341]=-(v[37]*(2e0*v[247]+v[91]));
7408 v[340]=-(v[37]*(2e0*v[211]+v[92]));
7409 v[339]=-(v[37]*(2e0*v[260]+v[93]));
7410 v[338]=-(v[37]*(2e0*v[222]+v[94]));
7411 v[272]=v[137]*v[328]+v[37]*(2e0*v[268]+2e0*v[270]-2e0*v[18]*v[88]);
7412 v[267]=v[136]*v[328]+v[343];
7413 v[263]=v[135]*v[328]+v[339];
7414 v[259]=v[134]*v[328]+v[37]*(2e0*v[255]+2e0*v[257]-2e0*v[18]*v[87]);
7415 v[254]=v[133]*v[328]+v[345];
7416 v[250]=v[132]*v[328]+v[341];
7417 v[246]=v[131]*v[328]+v[37]*(2e0*F[0][1]*v[22]+2e0*v[244]-2e0*v[18]*v[86]);
7418 v[241]=v[130]*v[328]+2e0*(F[0][2]*v[22]-F[0][0]*v[26])*v[37];
7419 v[231]=v[137]*v[327]+v[347];
7420 v[227]=v[136]*v[327]+v[37]*(2e0*v[225]+2e0*v[270]-2e0*v[22]*v[67]);
7421 v[224]=v[135]*v[327]+v[338];
7422 v[301]=2e0*F[1][0]*v[165]+F[1][2]*v[224]+F[1][1]*v[263];
7423 v[279]=2e0*F[0][0]*v[165]+F[0][2]*v[224]+F[0][1]*v[263];
7424 v[220]=v[134]*v[327]+v[349];
7425 v[216]=v[133]*v[327]+v[37]*(2e0*v[214]+2e0*v[257]-2e0*v[22]*v[66]);
7426 v[213]=v[132]*v[327]+v[340];
7427 v[276]=2e0*F[0][0]*v[162]+F[0][2]*v[213]+F[0][1]*v[250];
7428 v[209]=v[131]*v[327]+2e0*(F[0][1]*v[18]-F[0][0]*v[20])*v[37];
7429 v[196]=v[137]*v[326]+v[346];
7430 v[314]=2e0*F[1][2]*v[147]+F[1][1]*v[196]+F[1][0]*v[231];
7431 v[296]=2e0*F[0][2]*v[147]+F[0][1]*v[196]+F[0][0]*v[231];
7432 v[192]=v[136]*v[326]+v[342];
7433 v[308]=2e0*F[1][1]*v[156]+F[1][2]*v[192]+F[1][0]*v[267];
7434 v[288]=2e0*F[0][1]*v[156]+F[0][2]*v[192]+F[0][0]*v[267];
7435 v[188]=v[135]*v[326]+v[37]*(2e0*v[225]+2e0*v[268]-2e0*v[24]*v[58]);
7436 v[187]=v[134]*v[326]+v[348];
7437 v[293]=2e0*F[0][2]*v[144]+F[0][1]*v[187]+F[0][0]*v[220];
7438 v[183]=v[133]*v[326]+v[344];
7439 v[285]=2e0*F[0][1]*v[153]+F[0][2]*v[183]+F[0][0]*v[254];
7440 v[179]=v[132]*v[326]+v[37]*(2e0*v[214]+2e0*v[255]-2e0*v[24]*v[57]);
7441 v[178]=v[131]*v[326]+2e0*(-(F[0][1]*v[15])+F[0][0]*v[18])*v[37];
7442 v[167]=v[137]*v[333]-v[338];
7443 v[303]=2e0*F[1][0]*v[167]+F[1][2]*v[231]+F[1][1]*v[272];
7444 v[281]=2e0*F[0][0]*v[167]+F[0][2]*v[231]+F[0][1]*v[272];
7445 v[166]=v[136]*v[333]-v[339];
7446 v[302]=2e0*F[1][0]*v[166]+F[1][2]*v[227]+F[1][1]*v[267];
7447 v[280]=2e0*F[0][0]*v[166]+F[0][2]*v[227]+F[0][1]*v[267];
7448 v[164]=v[134]*v[333]-v[340];
7449 v[278]=2e0*F[0][0]*v[164]+F[0][2]*v[220]+F[0][1]*v[259];
7450 v[163]=v[133]*v[333]-v[341];
7451 v[277]=2e0*F[0][0]*v[163]+F[0][2]*v[216]+F[0][1]*v[254];
7452 v[157]=v[137]*v[148]-v[342];
7453 v[309]=2e0*F[1][1]*v[157]+F[1][2]*v[196]+F[1][0]*v[272];
7454 v[289]=2e0*F[0][1]*v[157]+F[0][2]*v[196]+F[0][0]*v[272];
7455 v[155]=v[135]*v[148]-v[343];
7456 v[307]=2e0*F[1][1]*v[155]+F[1][2]*v[188]+F[1][0]*v[263];
7457 v[287]=2e0*F[0][1]*v[155]+F[0][2]*v[188]+F[0][0]*v[263];
7458 v[154]=v[134]*v[148]-v[344];
7459 v[286]=2e0*F[0][1]*v[154]+F[0][2]*v[187]+F[0][0]*v[259];
7460 v[284]=F[0][2]*v[179]+F[0][0]*v[250]+2e0*F[0][1]*(v[132]*v[148]-v[345]);
7461 v[146]=v[136]*v[138]-v[346];
7462 v[313]=2e0*F[1][2]*v[146]+F[1][1]*v[192]+F[1][0]*v[227];
7463 v[295]=2e0*F[0][2]*v[146]+F[0][1]*v[192]+F[0][0]*v[227];
7464 v[145]=v[135]*v[138]-v[347];
7465 v[312]=2e0*F[1][2]*v[145]+F[1][1]*v[188]+F[1][0]*v[224];
7466 v[294]=2e0*F[0][2]*v[145]+F[0][1]*v[188]+F[0][0]*v[224];
7467 v[292]=F[0][1]*v[183]+F[0][0]*v[216]+2e0*F[0][2]*(v[133]*v[138]-v[348]);
7468 v[291]=F[0][1]*v[179]+F[0][0]*v[213]+(v[132]*v[138]-v[349])*v[356];
7469 v[35]=v[36]+v[138]*v[37];
7471 v[40]=v[36]+v[148]*v[37];
7473 v[43]=v[36]+v[333]*v[37];
7476 v[319]=2e0*F[2][1]*v[157]+F[2][2]*v[196]+F[2][0]*v[272]+v[44];
7477 v[306]=2e0*F[1][1]*v[154]+F[1][2]*v[187]+F[1][0]*v[259]+v[44];
7478 v[283]=F[0][2]*v[178]+F[0][0]*v[246]+v[354]*(v[131]*v[148]+v[355])+v[44];
7480 v[317]=2e0*F[2][0]*v[167]+F[2][2]*v[231]+F[2][1]*v[272]+v[45];
7481 v[300]=2e0*F[1][0]*v[164]+F[1][2]*v[220]+F[1][1]*v[259]+v[45];
7482 v[275]=F[0][2]*v[209]+F[0][1]*v[246]+2e0*F[0][0]*(v[131]*v[333]+v[352])+v[45];
7484 v[316]=2e0*F[2][0]*v[166]+F[2][2]*v[227]+F[2][1]*v[267]+v[46];
7485 v[299]=2e0*F[1][0]*v[163]+F[1][2]*v[216]+F[1][1]*v[254]+v[46];
7486 v[274]=F[0][1]*v[241]+2e0*F[0][0]*(v[130]*v[333]+v[353])+v[46]+F[0][2]*(v[130]*v[327]+v[37]*
7487 (2e0*F[0][2]*v[18]+2e0*v[244]-2e0*v[22]*v[65]));
7488 Pmat[0][0]=F[0][0]*v[297]+F[0][2]*v[45]+F[0][1]*v[46];
7489 Pmat[0][1]=F[0][1]*v[304]+F[0][2]*v[44]+F[0][0]*v[46];
7490 Pmat[0][2]=F[0][2]*v[310]+F[0][1]*v[44]+F[0][0]*v[45];
7491 Pmat[1][0]=2e0*F[1][0]*v[43]+F[1][2]*v[45]+F[1][1]*v[46];
7492 Pmat[1][1]=2e0*F[1][1]*v[40]+F[1][2]*v[44]+F[1][0]*v[46];
7493 Pmat[1][2]=2e0*F[1][2]*v[35]+F[1][1]*v[44]+F[1][0]*v[45];
7494 Pmat[2][0]=F[2][0]*v[297]+F[2][2]*v[45]+F[2][1]*v[46];
7495 Pmat[2][1]=F[2][1]*v[304]+F[2][2]*v[44]+F[2][0]*v[46];
7496 Pmat[2][2]=F[2][2]*v[310]+F[2][1]*v[44]+F[2][0]*v[45];
7497 Amat[0][0][0][0]=v[297]+v[128]*v[351]+F[0][2]*(v[128]*v[327]-v[352])+F[0][1]*(v[128]*v[328]-v[353]
7499 Amat[0][0][0][1]=v[274];
7500 Amat[0][0][0][2]=v[275];
7501 Amat[0][0][1][0]=v[276];
7502 Amat[0][0][1][1]=v[277];
7503 Amat[0][0][1][2]=v[278];
7504 Amat[0][0][2][0]=v[279];
7505 Amat[0][0][2][1]=v[280];
7506 Amat[0][0][2][2]=v[281];
7507 Amat[0][1][0][0]=v[274];
7508 Amat[0][1][0][1]=F[0][0]*v[241]+v[304]+v[130]*v[148]*v[354]+F[0][2]*(v[130]*v[326]-v[355]);
7509 Amat[0][1][0][2]=v[283];
7510 Amat[0][1][1][0]=v[284];
7511 Amat[0][1][1][1]=v[285];
7512 Amat[0][1][1][2]=v[286];
7513 Amat[0][1][2][0]=v[287];
7514 Amat[0][1][2][1]=v[288];
7515 Amat[0][1][2][2]=v[289];
7516 Amat[0][2][0][0]=v[275];
7517 Amat[0][2][0][1]=v[283];
7518 Amat[0][2][0][2]=F[0][1]*v[178]+F[0][0]*v[209]+v[310]+v[131]*v[138]*v[356];
7519 Amat[0][2][1][0]=v[291];
7520 Amat[0][2][1][1]=v[292];
7521 Amat[0][2][1][2]=v[293];
7522 Amat[0][2][2][0]=v[294];
7523 Amat[0][2][2][1]=v[295];
7524 Amat[0][2][2][2]=v[296];
7525 Amat[1][0][0][0]=v[276];
7526 Amat[1][0][0][1]=v[284];
7527 Amat[1][0][0][2]=v[291];
7528 Amat[1][0][1][0]=2e0*F[1][0]*v[162]+F[1][2]*v[213]+F[1][1]*v[250]+v[297];
7529 Amat[1][0][1][1]=v[299];
7530 Amat[1][0][1][2]=v[300];
7531 Amat[1][0][2][0]=v[301];
7532 Amat[1][0][2][1]=v[302];
7533 Amat[1][0][2][2]=v[303];
7534 Amat[1][1][0][0]=v[277];
7535 Amat[1][1][0][1]=v[285];
7536 Amat[1][1][0][2]=v[292];
7537 Amat[1][1][1][0]=v[299];
7538 Amat[1][1][1][1]=2e0*F[1][1]*v[153]+F[1][2]*v[183]+F[1][0]*v[254]+v[304];
7539 Amat[1][1][1][2]=v[306];
7540 Amat[1][1][2][0]=v[307];
7541 Amat[1][1][2][1]=v[308];
7542 Amat[1][1][2][2]=v[309];
7543 Amat[1][2][0][0]=v[278];
7544 Amat[1][2][0][1]=v[286];
7545 Amat[1][2][0][2]=v[293];
7546 Amat[1][2][1][0]=v[300];
7547 Amat[1][2][1][1]=v[306];
7548 Amat[1][2][1][2]=2e0*F[1][2]*v[144]+F[1][1]*v[187]+F[1][0]*v[220]+v[310];
7549 Amat[1][2][2][0]=v[312];
7550 Amat[1][2][2][1]=v[313];
7551 Amat[1][2][2][2]=v[314];
7552 Amat[2][0][0][0]=v[279];
7553 Amat[2][0][0][1]=v[287];
7554 Amat[2][0][0][2]=v[294];
7555 Amat[2][0][1][0]=v[301];
7556 Amat[2][0][1][1]=v[307];
7557 Amat[2][0][1][2]=v[312];
7558 Amat[2][0][2][0]=2e0*F[2][0]*v[165]+F[2][2]*v[224]+F[2][1]*v[263]+v[297];
7559 Amat[2][0][2][1]=v[316];
7560 Amat[2][0][2][2]=v[317];
7561 Amat[2][1][0][0]=v[280];
7562 Amat[2][1][0][1]=v[288];
7563 Amat[2][1][0][2]=v[295];
7564 Amat[2][1][1][0]=v[302];
7565 Amat[2][1][1][1]=v[308];
7566 Amat[2][1][1][2]=v[313];
7567 Amat[2][1][2][0]=v[316];
7568 Amat[2][1][2][1]=2e0*F[2][1]*v[156]+F[2][2]*v[192]+F[2][0]*v[267]+v[304];
7569 Amat[2][1][2][2]=v[319];
7570 Amat[2][2][0][0]=v[281];
7571 Amat[2][2][0][1]=v[289];
7572 Amat[2][2][0][2]=v[296];
7573 Amat[2][2][1][0]=v[303];
7574 Amat[2][2][1][1]=v[309];
7575 Amat[2][2][1][2]=v[314];
7576 Amat[2][2][2][0]=v[317];
7577 Amat[2][2][2][1]=v[319];
7578 Amat[2][2][2][2]=2e0*F[2][2]*v[147]+F[2][1]*v[196]+F[2][0]*v[231]+v[310];
7595template <
class SC,
class LO,
class GO,
class NO>
7596void FE<SC,LO,GO,NO>::mr3d(
double* v,
double (*E),
double (*Nu),
double (*C)
7597 ,
double** F,
double** Pmat,
double**** Amat)
7601 v[4]=(*E)/(2e0+2e0*(*Nu));
7602 v[139]=((*C)*v[4])/2e0;
7603 v[5]=(*E)/(3e0-6e0*(*Nu));
7605 v[150]=v[139]*v[57];
7607 v[165]=v[139]*v[66];
7609 v[167]=v[139]*v[87];
7611 v[155]=v[139]*v[58];
7613 v[170]=v[139]*v[67];
7615 v[172]=v[139]*v[88];
7617 v[159]=v[139]*v[59];
7619 v[175]=v[139]*v[68];
7620 v[18]=F[0][0]*F[0][1]+F[1][0]*F[1][1]+F[2][0]*F[2][1];
7621 v[345]=(v[18]*v[18]);
7623 v[177]=v[139]*v[89];
7624 v[24]=F[0][1]*F[0][2]+F[1][1]*F[1][2]+F[2][1]*F[2][2];
7625 v[344]=(v[24]*v[24]);
7627 v[22]=F[0][0]*F[0][2]+F[1][0]*F[1][2]+F[2][0]*F[2][2];
7628 v[15]=Power(F[0][0],2)+Power(F[1][0],2)+Power(F[2][0],2);
7629 v[239]=-(F[2][1]*v[18]);
7630 v[236]=F[2][2]*v[18];
7631 v[228]=-(F[1][1]*v[18]);
7632 v[225]=F[1][2]*v[18];
7633 v[205]=-(F[2][0]*v[18]);
7634 v[196]=-(F[1][0]*v[18]);
7635 v[279]=F[2][1]*v[22];
7636 v[275]=-(F[2][2]*v[22]);
7637 v[266]=F[1][1]*v[22];
7638 v[262]=-(F[1][2]*v[22]);
7639 v[201]=-(F[2][0]*v[22]);
7640 v[192]=-(F[1][0]*v[22]);
7641 v[183]=-(F[0][0]*v[22]);
7642 v[20]=Power(F[0][1],2)+Power(F[1][1],2)+Power(F[2][1],2);
7643 v[334]=-(v[20]*v[22]);
7644 v[337]=2e0*(v[334]+v[335]);
7648 v[140]=v[15]*v[20]-v[345];
7649 v[281]=F[2][0]*v[24];
7650 v[271]=-(F[2][2]*v[24]);
7651 v[268]=F[1][0]*v[24];
7652 v[258]=-(F[1][2]*v[24]);
7653 v[255]=F[0][0]*v[24];
7654 v[243]=-(F[0][2]*v[24]);
7655 v[233]=-(F[2][1]*v[24]);
7656 v[222]=-(F[1][1]*v[24]);
7657 v[209]=-(F[0][1]*v[24]);
7658 v[179]=v[18]*v[22]-v[15]*v[24];
7662 v[38]=-(v[22]*v[22]);
7663 v[26]=Power(F[0][2],2)+Power(F[1][2],2)+Power(F[2][2],2);
7664 v[343]=v[20]*v[26]-v[344];
7665 v[361]=v[343]*v[57];
7666 v[247]=v[22]*v[24]-v[18]*v[26];
7675 v[151]=v[15]*v[26]+v[38];
7676 v[29]=v[151]*v[20]+2e0*v[22]*v[335]-v[15]*v[344]-v[26]*v[345];
7677 v[346]=1e0/Power(v[29],2);
7678 v[33]=-2e0*v[139]-v[4]+v[5]*std::log(std::sqrt(v[29]));
7679 v[347]=v[346]*(-v[33]/2e0+v[5]/4e0);
7680 v[138]=v[347]*(F[2][1]*v[336]+F[2][0]*v[337]-v[345]*v[89]+v[15]*v[95]);
7681 v[149]=v[138]*v[140];
7682 v[137]=v[347]*(F[2][2]*v[339]+F[2][0]*v[340]+v[38]*v[68]+v[15]*v[94]);
7683 v[161]=v[137]*v[151];
7684 v[136]=v[347]*(v[100]*v[20]+F[2][2]*v[337]+F[2][1]*v[338]-v[344]*v[59]);
7685 v[174]=v[136]*v[343];
7686 v[135]=v[347]*(F[1][1]*v[336]+F[1][0]*v[337]-v[345]*v[88]+v[15]*v[93]);
7687 v[146]=v[135]*v[140];
7688 v[134]=v[347]*(F[1][2]*v[341]+F[1][0]*v[342]+v[38]*v[67]+v[15]*v[92]);
7689 v[157]=v[134]*v[151];
7690 v[133]=v[347]*(F[1][2]*v[337]+F[1][1]*v[338]-v[344]*v[58]+v[20]*v[98]);
7691 v[169]=v[133]*v[343];
7692 v[132]=v[347]*(F[0][0]*v[337]+F[0][1]*v[339]-v[345]*v[87]+v[15]*v[91]);
7693 v[131]=v[347]*(F[0][2]*v[341]+F[0][0]*v[342]+v[38]*v[66]+v[15]*v[90]);
7694 v[129]=v[347]*(F[0][2]*v[337]+F[0][1]*v[340]+v[361]);
7695 v[37]=v[33]/(2e0*v[29]);
7696 v[365]=v[37]*(2e0*v[183]+v[15]*v[87]);
7697 v[363]=v[37]*(2e0*v[243]+v[90]);
7698 v[362]=v[37]*(2e0*v[209]+v[91]);
7699 v[359]=-2e0*(F[1][0]*v[20]+v[228])*v[37];
7700 v[358]=-(v[37]*(2e0*v[196]+v[15]*v[67]));
7701 v[357]=-2e0*(F[2][0]*v[20]+v[239])*v[37];
7702 v[356]=-(v[37]*(2e0*v[205]+v[15]*v[68]));
7703 v[355]=-(v[37]*(2e0*v[262]+v[98]));
7704 v[354]=-(v[37]*(2e0*v[192]+v[15]*v[88]));
7705 v[353]=-((v[100]+2e0*v[275])*v[37]);
7706 v[352]=-(v[37]*(2e0*v[201]+v[15]*v[89]));
7707 v[351]=-(v[37]*(2e0*v[258]+v[92]));
7708 v[350]=-(v[37]*(2e0*v[222]+v[93]));
7709 v[349]=-(v[37]*(2e0*v[271]+v[94]));
7710 v[348]=-(v[37]*(2e0*v[233]+v[95]));
7711 v[283]=v[138]*v[338]+v[37]*(2e0*v[279]+2e0*v[281]-2e0*v[18]*v[89]);
7712 v[278]=-v[159]+v[137]*v[338]+v[353];
7713 v[274]=-v[175]+v[136]*v[338]+v[349];
7714 v[270]=v[135]*v[338]+v[37]*(2e0*v[266]+2e0*v[268]-2e0*v[18]*v[88]);
7715 v[265]=-v[155]+v[134]*v[338]+v[355];
7716 v[261]=-v[170]+v[133]*v[338]+v[351];
7717 v[257]=v[132]*v[338]+v[37]*(2e0*F[0][1]*v[22]+2e0*v[255]-2e0*v[18]*v[87]);
7718 v[252]=-v[150]+v[131]*v[338]+2e0*(F[0][2]*v[22]-F[0][0]*v[26])*v[37];
7719 v[242]=-v[159]+v[138]*v[337]+v[357];
7720 v[238]=v[137]*v[337]+v[37]*(2e0*v[236]+2e0*v[281]-2e0*v[22]*v[68]);
7721 v[235]=-v[177]+v[136]*v[337]+v[348];
7722 v[312]=2e0*F[1][0]*v[174]+F[1][2]*v[235]+F[1][1]*v[274];
7723 v[290]=2e0*F[0][0]*v[174]+F[0][2]*v[235]+F[0][1]*v[274];
7724 v[231]=-v[155]+v[135]*v[337]+v[359];
7725 v[227]=v[134]*v[337]+v[37]*(2e0*v[225]+2e0*v[268]-2e0*v[22]*v[67]);
7726 v[224]=-v[172]+v[133]*v[337]+v[350];
7727 v[287]=2e0*F[0][0]*v[169]+F[0][2]*v[224]+F[0][1]*v[261];
7728 v[220]=-v[150]+v[132]*v[337]+2e0*(F[0][1]*v[18]-F[0][0]*v[20])*v[37];
7729 v[207]=-v[175]+v[138]*v[336]+v[356];
7730 v[325]=2e0*F[1][2]*v[149]+F[1][1]*v[207]+F[1][0]*v[242];
7731 v[307]=2e0*F[0][2]*v[149]+F[0][1]*v[207]+F[0][0]*v[242];
7732 v[203]=-v[177]+v[137]*v[336]+v[352];
7733 v[319]=2e0*F[1][1]*v[161]+F[1][2]*v[203]+F[1][0]*v[278];
7734 v[299]=2e0*F[0][1]*v[161]+F[0][2]*v[203]+F[0][0]*v[278];
7735 v[199]=v[136]*v[336]+v[37]*(2e0*v[236]+2e0*v[279]-2e0*v[24]*v[59]);
7736 v[198]=-v[170]+v[135]*v[336]+v[358];
7737 v[304]=2e0*F[0][2]*v[146]+F[0][1]*v[198]+F[0][0]*v[231];
7738 v[194]=-v[172]+v[134]*v[336]+v[354];
7739 v[296]=2e0*F[0][1]*v[157]+F[0][2]*v[194]+F[0][0]*v[265];
7740 v[190]=v[133]*v[336]+v[37]*(2e0*v[225]+2e0*v[266]-2e0*v[24]*v[58]);
7741 v[189]=-v[165]+v[132]*v[336]+2e0*(-(F[0][1]*v[15])+F[0][0]*v[18])*v[37];
7742 v[178]=v[177]+v[138]*v[343]-v[348];
7743 v[314]=2e0*F[1][0]*v[178]+F[1][2]*v[242]+F[1][1]*v[283];
7744 v[292]=2e0*F[0][0]*v[178]+F[0][2]*v[242]+F[0][1]*v[283];
7745 v[176]=v[175]+v[137]*v[343]-v[349];
7746 v[313]=2e0*F[1][0]*v[176]+F[1][2]*v[238]+F[1][1]*v[278];
7747 v[291]=2e0*F[0][0]*v[176]+F[0][2]*v[238]+F[0][1]*v[278];
7748 v[173]=v[172]+v[135]*v[343]-v[350];
7749 v[289]=2e0*F[0][0]*v[173]+F[0][2]*v[231]+F[0][1]*v[270];
7750 v[171]=v[170]+v[134]*v[343]-v[351];
7751 v[288]=2e0*F[0][0]*v[171]+F[0][2]*v[227]+F[0][1]*v[265];
7752 v[162]=v[138]*v[151]+v[177]-v[352];
7753 v[320]=2e0*F[1][1]*v[162]+F[1][2]*v[207]+F[1][0]*v[283];
7754 v[300]=2e0*F[0][1]*v[162]+F[0][2]*v[207]+F[0][0]*v[283];
7755 v[160]=v[136]*v[151]+v[159]-v[353];
7756 v[318]=2e0*F[1][1]*v[160]+F[1][2]*v[199]+F[1][0]*v[274];
7757 v[298]=2e0*F[0][1]*v[160]+F[0][2]*v[199]+F[0][0]*v[274];
7758 v[158]=v[135]*v[151]+v[172]-v[354];
7759 v[297]=2e0*F[0][1]*v[158]+F[0][2]*v[198]+F[0][0]*v[270];
7760 v[295]=F[0][2]*v[190]+F[0][0]*v[261]+2e0*F[0][1]*(v[133]*v[151]+v[155]-v[355]);
7761 v[148]=v[137]*v[140]+v[175]-v[356];
7762 v[324]=2e0*F[1][2]*v[148]+F[1][1]*v[203]+F[1][0]*v[238];
7763 v[306]=2e0*F[0][2]*v[148]+F[0][1]*v[203]+F[0][0]*v[238];
7764 v[147]=v[136]*v[140]+v[159]-v[357];
7765 v[323]=2e0*F[1][2]*v[147]+F[1][1]*v[199]+F[1][0]*v[235];
7766 v[305]=2e0*F[0][2]*v[147]+F[0][1]*v[199]+F[0][0]*v[235];
7767 v[303]=F[0][1]*v[194]+F[0][0]*v[227]+2e0*F[0][2]*(v[134]*v[140]+v[170]-v[358]);
7768 v[302]=F[0][1]*v[190]+F[0][0]*v[224]+(v[133]*v[140]+v[155]-v[359])*v[366];
7769 v[36]=v[140]*v[37]+((1e0+(*C)*(-1e0+v[15]+v[20]))*v[4])/2e0;
7771 v[40]=v[151]*v[37]+((1e0+(*C)*(-1e0+v[15]+v[26]))*v[4])/2e0;
7773 v[43]=v[343]*v[37]+((1e0+(*C)*(-1e0+v[20]+v[26]))*v[4])/2e0;
7775 v[45]=-2e0*v[139]*v[24]+v[336]*v[37];
7776 v[330]=2e0*F[2][1]*v[162]+F[2][2]*v[207]+F[2][0]*v[283]+v[45];
7777 v[317]=2e0*F[1][1]*v[158]+F[1][2]*v[198]+F[1][0]*v[270]+v[45];
7778 v[294]=F[0][2]*v[189]+F[0][0]*v[257]+v[364]*(v[132]*v[151]+v[167]+v[365])+v[45];
7779 v[46]=-2e0*v[139]*v[22]+v[337]*v[37];
7780 v[328]=2e0*F[2][0]*v[178]+F[2][2]*v[242]+F[2][1]*v[283]+v[46];
7781 v[311]=2e0*F[1][0]*v[173]+F[1][2]*v[231]+F[1][1]*v[270]+v[46];
7782 v[286]=F[0][2]*v[220]+F[0][1]*v[257]+2e0*F[0][0]*(v[167]+v[132]*v[343]+v[362])+v[46];
7783 v[47]=-2e0*v[139]*v[18]+v[338]*v[37];
7784 v[327]=2e0*F[2][0]*v[176]+F[2][2]*v[238]+F[2][1]*v[278]+v[47];
7785 v[310]=2e0*F[1][0]*v[171]+F[1][2]*v[227]+F[1][1]*v[265]+v[47];
7786 v[285]=F[0][1]*v[252]+2e0*F[0][0]*(v[165]+v[131]*v[343]+v[363])+v[47]+F[0][2]*(v[131]*v[337]+v[37]*
7787 (2e0*F[0][2]*v[18]+2e0*v[255]-2e0*v[22]*v[66]));
7788 Pmat[0][0]=F[0][0]*v[308]+F[0][2]*v[46]+F[0][1]*v[47];
7789 Pmat[0][1]=F[0][1]*v[315]+F[0][2]*v[45]+F[0][0]*v[47];
7790 Pmat[0][2]=F[0][2]*v[321]+F[0][1]*v[45]+F[0][0]*v[46];
7791 Pmat[1][0]=2e0*F[1][0]*v[43]+F[1][2]*v[46]+F[1][1]*v[47];
7792 Pmat[1][1]=2e0*F[1][1]*v[40]+F[1][2]*v[45]+F[1][0]*v[47];
7793 Pmat[1][2]=2e0*F[1][2]*v[36]+F[1][1]*v[45]+F[1][0]*v[46];
7794 Pmat[2][0]=F[2][0]*v[308]+F[2][2]*v[46]+F[2][1]*v[47];
7795 Pmat[2][1]=F[2][1]*v[315]+F[2][2]*v[45]+F[2][0]*v[47];
7796 Pmat[2][2]=F[2][2]*v[321]+F[2][1]*v[45]+F[2][0]*v[46];
7797 Amat[0][0][0][0]=v[308]+v[129]*v[361]+F[0][2]*(-v[167]+v[129]*v[337]-v[362])+F[0][1]*(-v[165]
7798 +v[129]*v[338]-v[363]);
7799 Amat[0][0][0][1]=v[285];
7800 Amat[0][0][0][2]=v[286];
7801 Amat[0][0][1][0]=v[287];
7802 Amat[0][0][1][1]=v[288];
7803 Amat[0][0][1][2]=v[289];
7804 Amat[0][0][2][0]=v[290];
7805 Amat[0][0][2][1]=v[291];
7806 Amat[0][0][2][2]=v[292];
7807 Amat[0][1][0][0]=v[285];
7808 Amat[0][1][0][1]=F[0][0]*v[252]+v[315]+v[131]*v[151]*v[364]+F[0][2]*(-v[167]+v[131]*v[336]-v[365]);
7809 Amat[0][1][0][2]=v[294];
7810 Amat[0][1][1][0]=v[295];
7811 Amat[0][1][1][1]=v[296];
7812 Amat[0][1][1][2]=v[297];
7813 Amat[0][1][2][0]=v[298];
7814 Amat[0][1][2][1]=v[299];
7815 Amat[0][1][2][2]=v[300];
7816 Amat[0][2][0][0]=v[286];
7817 Amat[0][2][0][1]=v[294];
7818 Amat[0][2][0][2]=F[0][1]*v[189]+F[0][0]*v[220]+v[321]+v[132]*v[140]*v[366];
7819 Amat[0][2][1][0]=v[302];
7820 Amat[0][2][1][1]=v[303];
7821 Amat[0][2][1][2]=v[304];
7822 Amat[0][2][2][0]=v[305];
7823 Amat[0][2][2][1]=v[306];
7824 Amat[0][2][2][2]=v[307];
7825 Amat[1][0][0][0]=v[287];
7826 Amat[1][0][0][1]=v[295];
7827 Amat[1][0][0][2]=v[302];
7828 Amat[1][0][1][0]=2e0*F[1][0]*v[169]+F[1][2]*v[224]+F[1][1]*v[261]+v[308];
7829 Amat[1][0][1][1]=v[310];
7830 Amat[1][0][1][2]=v[311];
7831 Amat[1][0][2][0]=v[312];
7832 Amat[1][0][2][1]=v[313];
7833 Amat[1][0][2][2]=v[314];
7834 Amat[1][1][0][0]=v[288];
7835 Amat[1][1][0][1]=v[296];
7836 Amat[1][1][0][2]=v[303];
7837 Amat[1][1][1][0]=v[310];
7838 Amat[1][1][1][1]=2e0*F[1][1]*v[157]+F[1][2]*v[194]+F[1][0]*v[265]+v[315];
7839 Amat[1][1][1][2]=v[317];
7840 Amat[1][1][2][0]=v[318];
7841 Amat[1][1][2][1]=v[319];
7842 Amat[1][1][2][2]=v[320];
7843 Amat[1][2][0][0]=v[289];
7844 Amat[1][2][0][1]=v[297];
7845 Amat[1][2][0][2]=v[304];
7846 Amat[1][2][1][0]=v[311];
7847 Amat[1][2][1][1]=v[317];
7848 Amat[1][2][1][2]=2e0*F[1][2]*v[146]+F[1][1]*v[198]+F[1][0]*v[231]+v[321];
7849 Amat[1][2][2][0]=v[323];
7850 Amat[1][2][2][1]=v[324];
7851 Amat[1][2][2][2]=v[325];
7852 Amat[2][0][0][0]=v[290];
7853 Amat[2][0][0][1]=v[298];
7854 Amat[2][0][0][2]=v[305];
7855 Amat[2][0][1][0]=v[312];
7856 Amat[2][0][1][1]=v[318];
7857 Amat[2][0][1][2]=v[323];
7858 Amat[2][0][2][0]=2e0*F[2][0]*v[174]+F[2][2]*v[235]+F[2][1]*v[274]+v[308];
7859 Amat[2][0][2][1]=v[327];
7860 Amat[2][0][2][2]=v[328];
7861 Amat[2][1][0][0]=v[291];
7862 Amat[2][1][0][1]=v[299];
7863 Amat[2][1][0][2]=v[306];
7864 Amat[2][1][1][0]=v[313];
7865 Amat[2][1][1][1]=v[319];
7866 Amat[2][1][1][2]=v[324];
7867 Amat[2][1][2][0]=v[327];
7868 Amat[2][1][2][1]=2e0*F[2][1]*v[161]+F[2][2]*v[203]+F[2][0]*v[278]+v[315];
7869 Amat[2][1][2][2]=v[330];
7870 Amat[2][2][0][0]=v[292];
7871 Amat[2][2][0][1]=v[300];
7872 Amat[2][2][0][2]=v[307];
7873 Amat[2][2][1][0]=v[314];
7874 Amat[2][2][1][1]=v[320];
7875 Amat[2][2][1][2]=v[325];
7876 Amat[2][2][2][0]=v[328];
7877 Amat[2][2][2][1]=v[330];
7878 Amat[2][2][2][2]=2e0*F[2][2]*v[149]+F[2][1]*v[207]+F[2][0]*v[242]+v[321];
7895template <
class SC,
class LO,
class GO,
class NO>
7896void FE<SC,LO,GO,NO>::stvk3d(
double* v,
double (*lam),
double (*mue),
double** F
7897 ,
double** Pmat,
double**** Amat)
7899 v[169]=Power(F[0][0],2);
7901 v[167]=Power(F[0][2],2);
7902 v[166]=F[2][2]*(*mue);
7903 v[165]=F[2][1]*(*mue);
7904 v[164]=F[2][0]*(*mue);
7905 v[163]=F[1][2]*(*mue);
7906 v[162]=F[1][1]*(*mue);
7907 v[161]=F[1][0]*(*mue);
7908 v[88]=F[0][0]*(*mue);
7909 v[116]=F[0][0]*v[88];
7910 v[70]=F[0][1]*(*lam);
7911 v[93]=F[0][1]*(*mue);
7912 v[117]=F[0][1]*v[93];
7913 v[71]=F[0][2]*(*lam);
7914 v[105]=(*mue)*v[167];
7915 v[72]=F[1][0]*(*lam);
7916 v[85]=2e0*v[161]+v[72];
7917 v[142]=F[1][0]*v[161];
7918 v[121]=F[0][0]*v[161];
7919 v[73]=F[1][1]*(*lam);
7920 v[100]=F[0][1]*v[161]+F[0][0]*v[73];
7921 v[82]=2e0*v[162]+v[73];
7922 v[143]=F[1][1]*v[162];
7923 v[122]=F[0][1]*v[162];
7924 v[108]=F[0][0]*v[162]+F[0][1]*v[72];
7925 v[74]=F[1][2]*(*lam);
7926 v[111]=F[0][2]*v[162]+F[0][1]*v[74];
7927 v[101]=F[0][2]*v[161]+F[0][0]*v[74];
7928 v[79]=2e0*v[163]+v[74];
7929 v[123]=v[121]+v[122]+F[0][2]*v[79];
7930 v[135]=F[1][2]*v[163];
7931 v[120]=F[0][1]*v[163]+F[0][2]*v[73];
7932 v[119]=F[0][0]*v[163]+F[0][2]*v[72];
7933 v[109]=F[0][2]*v[163];
7934 v[110]=v[109]+v[121]+F[0][1]*v[82];
7935 v[99]=v[109]+v[122]+F[0][0]*v[85];
7936 v[75]=F[2][0]*(*lam);
7937 v[86]=2e0*v[164]+v[75];
7938 v[156]=F[2][0]*v[164];
7939 v[147]=F[1][0]*v[164];
7940 v[126]=F[0][0]*v[164];
7941 v[76]=F[2][1]*(*lam);
7942 v[133]=F[1][1]*v[164]+F[1][0]*v[76];
7943 v[103]=F[0][1]*v[164]+F[0][0]*v[76];
7944 v[83]=2e0*v[165]+v[76];
7945 v[157]=F[2][1]*v[165];
7946 v[148]=F[1][1]*v[165];
7947 v[138]=F[1][0]*v[165]+F[1][1]*v[75];
7948 v[127]=F[0][1]*v[165];
7949 v[112]=F[0][0]*v[165]+F[0][1]*v[75];
7950 v[77]=F[2][2]*(*lam);
7951 v[141]=F[1][2]*v[165]+F[1][1]*v[77];
7952 v[134]=F[1][2]*v[164]+F[1][0]*v[77];
7953 v[115]=F[0][2]*v[165]+F[0][1]*v[77];
7954 v[104]=F[0][2]*v[164]+F[0][0]*v[77];
7955 v[80]=2e0*v[166]+v[77];
7956 v[149]=v[147]+v[148]+F[1][2]*v[80];
7957 v[128]=v[126]+v[127]+F[0][2]*v[80];
7958 v[153]=F[2][2]*v[166];
7959 v[146]=F[1][1]*v[166]+F[1][2]*v[76];
7960 v[145]=F[1][0]*v[166]+F[1][2]*v[75];
7961 v[139]=F[1][2]*v[166];
7962 v[140]=v[139]+v[147]+F[1][1]*v[83];
7963 v[132]=v[139]+v[148]+F[1][0]*v[86];
7964 v[125]=F[0][1]*v[166]+F[0][2]*v[76];
7965 v[124]=F[0][0]*v[166]+F[0][2]*v[75];
7966 v[113]=F[0][2]*v[166];
7967 v[114]=v[113]+v[126]+F[0][1]*v[83];
7968 v[102]=v[113]+v[127]+F[0][0]*v[86];
7969 v[24]=(-1e0+Power(F[1][0],2)+Power(F[2][0],2)+v[169])/2e0;
7970 v[28]=(-1e0+Power(F[0][1],2)+Power(F[1][1],2)+Power(F[2][1],2))/2e0;
7971 v[32]=(-1e0+Power(F[1][2],2)+Power(F[2][2],2)+v[167])/2e0;
7972 v[36]=(*lam)*(v[24]+v[28]+v[32]);
7973 v[35]=2e0*(*mue)*v[32]+v[36];
7974 v[37]=2e0*(*mue)*v[28]+v[36];
7975 v[38]=2e0*(*mue)*v[24]+v[36];
7976 v[39]=(F[0][0]*F[0][2]+F[1][0]*F[1][2]+F[2][0]*F[2][2])*(*mue);
7977 v[152]=F[2][2]*v[164]+v[39]+F[2][0]*v[77];
7978 v[131]=F[1][2]*v[161]+v[39]+F[1][0]*v[74];
7979 v[98]=v[39]+F[0][0]*v[71]+F[0][2]*v[88];
7980 v[40]=(F[0][1]*F[0][2]+F[1][1]*F[1][2]+F[2][1]*F[2][2])*(*mue);
7981 v[155]=F[2][2]*v[165]+v[40]+F[2][1]*v[77];
7982 v[137]=F[1][2]*v[162]+v[40]+F[1][1]*v[74];
7983 v[107]=v[40]+F[0][1]*v[71]+F[0][2]*v[93];
7984 v[41]=(F[0][0]*F[0][1]+F[1][0]*F[1][1]+F[2][0]*F[2][1])*(*mue);
7985 v[151]=F[2][1]*v[164]+v[41]+F[2][0]*v[76];
7986 v[130]=F[1][1]*v[161]+v[41]+F[1][0]*v[73];
7987 v[97]=v[41]+F[0][0]*v[70]+F[0][1]*v[88];
7988 Pmat[0][0]=F[0][0]*v[38]+F[0][2]*v[39]+F[0][1]*v[41];
7989 Pmat[0][1]=F[0][1]*v[37]+F[0][2]*v[40]+F[0][0]*v[41];
7990 Pmat[0][2]=F[0][2]*v[35]+F[0][0]*v[39]+F[0][1]*v[40];
7991 Pmat[1][0]=F[1][0]*v[38]+F[1][2]*v[39]+F[1][1]*v[41];
7992 Pmat[1][1]=F[1][1]*v[37]+F[1][2]*v[40]+F[1][0]*v[41];
7993 Pmat[1][2]=F[1][2]*v[35]+F[1][0]*v[39]+F[1][1]*v[40];
7994 Pmat[2][0]=F[2][0]*v[38]+F[2][2]*v[39]+F[2][1]*v[41];
7995 Pmat[2][1]=F[2][1]*v[37]+F[2][2]*v[40]+F[2][0]*v[41];
7996 Pmat[2][2]=F[2][2]*v[35]+F[2][0]*v[39]+F[2][1]*v[40];
7997 Amat[0][0][0][0]=v[105]+v[117]+((*lam)+v[168])*v[169]+v[38];
7998 Amat[0][0][0][1]=v[97];
7999 Amat[0][0][0][2]=v[98];
8000 Amat[0][0][1][0]=v[99];
8001 Amat[0][0][1][1]=v[100];
8002 Amat[0][0][1][2]=v[101];
8003 Amat[0][0][2][0]=v[102];
8004 Amat[0][0][2][1]=v[103];
8005 Amat[0][0][2][2]=v[104];
8006 Amat[0][1][0][0]=v[97];
8007 Amat[0][1][0][1]=v[105]+v[116]+v[37]+F[0][1]*(v[70]+2e0*v[93]);
8008 Amat[0][1][0][2]=v[107];
8009 Amat[0][1][1][0]=v[108];
8010 Amat[0][1][1][1]=v[110];
8011 Amat[0][1][1][2]=v[111];
8012 Amat[0][1][2][0]=v[112];
8013 Amat[0][1][2][1]=v[114];
8014 Amat[0][1][2][2]=v[115];
8015 Amat[0][2][0][0]=v[98];
8016 Amat[0][2][0][1]=v[107];
8017 Amat[0][2][0][2]=v[116]+v[117]+v[35]+F[0][2]*(F[0][2]*v[168]+v[71]);
8018 Amat[0][2][1][0]=v[119];
8019 Amat[0][2][1][1]=v[120];
8020 Amat[0][2][1][2]=v[123];
8021 Amat[0][2][2][0]=v[124];
8022 Amat[0][2][2][1]=v[125];
8023 Amat[0][2][2][2]=v[128];
8024 Amat[1][0][0][0]=v[99];
8025 Amat[1][0][0][1]=v[108];
8026 Amat[1][0][0][2]=v[119];
8027 Amat[1][0][1][0]=v[135]+v[143]+v[38]+F[1][0]*v[85];
8028 Amat[1][0][1][1]=v[130];
8029 Amat[1][0][1][2]=v[131];
8030 Amat[1][0][2][0]=v[132];
8031 Amat[1][0][2][1]=v[133];
8032 Amat[1][0][2][2]=v[134];
8033 Amat[1][1][0][0]=v[100];
8034 Amat[1][1][0][1]=v[110];
8035 Amat[1][1][0][2]=v[120];
8036 Amat[1][1][1][0]=v[130];
8037 Amat[1][1][1][1]=v[135]+v[142]+v[37]+F[1][1]*v[82];
8038 Amat[1][1][1][2]=v[137];
8039 Amat[1][1][2][0]=v[138];
8040 Amat[1][1][2][1]=v[140];
8041 Amat[1][1][2][2]=v[141];
8042 Amat[1][2][0][0]=v[101];
8043 Amat[1][2][0][1]=v[111];
8044 Amat[1][2][0][2]=v[123];
8045 Amat[1][2][1][0]=v[131];
8046 Amat[1][2][1][1]=v[137];
8047 Amat[1][2][1][2]=v[142]+v[143]+v[35]+F[1][2]*v[79];
8048 Amat[1][2][2][0]=v[145];
8049 Amat[1][2][2][1]=v[146];
8050 Amat[1][2][2][2]=v[149];
8051 Amat[2][0][0][0]=v[102];
8052 Amat[2][0][0][1]=v[112];
8053 Amat[2][0][0][2]=v[124];
8054 Amat[2][0][1][0]=v[132];
8055 Amat[2][0][1][1]=v[138];
8056 Amat[2][0][1][2]=v[145];
8057 Amat[2][0][2][0]=v[153]+v[157]+v[38]+F[2][0]*v[86];
8058 Amat[2][0][2][1]=v[151];
8059 Amat[2][0][2][2]=v[152];
8060 Amat[2][1][0][0]=v[103];
8061 Amat[2][1][0][1]=v[114];
8062 Amat[2][1][0][2]=v[125];
8063 Amat[2][1][1][0]=v[133];
8064 Amat[2][1][1][1]=v[140];
8065 Amat[2][1][1][2]=v[146];
8066 Amat[2][1][2][0]=v[151];
8067 Amat[2][1][2][1]=v[153]+v[156]+v[37]+F[2][1]*v[83];
8068 Amat[2][1][2][2]=v[155];
8069 Amat[2][2][0][0]=v[104];
8070 Amat[2][2][0][1]=v[115];
8071 Amat[2][2][0][2]=v[128];
8072 Amat[2][2][1][0]=v[134];
8073 Amat[2][2][1][1]=v[141];
8074 Amat[2][2][1][2]=v[149];
8075 Amat[2][2][2][0]=v[152];
8076 Amat[2][2][2][1]=v[155];
8077 Amat[2][2][2][2]=v[156]+v[157]+v[35]+F[2][2]*v[80];
8093template <
class SC,
class LO,
class GO,
class NO>
8094void FE<SC,LO,GO,NO>::stvk2d(
double* v,
double (*lam),
double (*mue),
double** F
8095 ,
double** Pmat,
double**** Amat)
8097 v[43]=F[0][0]*F[1][0];
8098 v[42]=F[0][1]*F[1][1];
8099 v[37]=Power(F[0][0],2);
8101 v[36]=Power(F[0][1],2);
8102 v[34]=F[0][0]*F[0][1];
8104 v[27]=Power(F[1][0],2);
8105 v[31]=-1e0+v[27]+v[37];
8107 v[25]=Power(F[1][1],2);
8108 v[26]=-1e0+v[25]+v[36];
8109 v[23]=F[1][0]*F[1][1];
8111 v[35]=(*lam)*v[34]+(*mue)*(v[22]+v[34]);
8112 v[24]=(*lam)*v[23]+(*mue)*(v[22]+v[23]);
8113 v[21]=(*lam)*v[42]+2e0*(*mue)*(2e0*v[12]*v[14]+v[42]);
8114 v[20]=F[0][0]*F[1][1]*(*lam)+4e0*(*mue)*v[11]*v[14];
8116 v[30]=F[0][1]*F[1][0]*(*lam)+4e0*(*mue)*v[12]*v[13];
8117 v[29]=(*lam)*v[43]+2e0*(*mue)*(2e0*v[11]*v[13]+v[43]);
8119 v[32]=((*lam)*(v[26]+v[31]))/2e0;
8120 Pmat[0][0]=F[0][0]*v[32]+(*mue)*(F[0][0]*v[31]+v[11]*v[44]);
8121 Pmat[0][1]=F[0][1]*v[32]+(*mue)*(F[0][1]*v[26]+v[12]*v[44]);
8122 Pmat[1][0]=F[1][0]*v[32]+(*mue)*(F[1][0]*v[31]+v[13]*v[44]);
8123 Pmat[1][1]=F[1][1]*v[32]+(*mue)*(F[1][1]*v[26]+v[14]*v[44]);
8124 Amat[0][0][0][0]=v[32]+(*lam)*v[37]+(*mue)*(v[31]+v[36]+2e0*v[37]);
8125 Amat[0][0][0][1]=v[35];
8126 Amat[0][0][1][0]=v[29];
8127 Amat[0][0][1][1]=v[20];
8128 Amat[0][1][0][0]=v[35];
8129 Amat[0][1][0][1]=v[32]+(*lam)*v[36]+(*mue)*(v[26]+2e0*v[36]+v[37]);
8130 Amat[0][1][1][0]=v[30];
8131 Amat[0][1][1][1]=v[21];
8132 Amat[1][0][0][0]=v[29];
8133 Amat[1][0][0][1]=v[30];
8134 Amat[1][0][1][0]=(*lam)*v[27]+(*mue)*(v[25]+2e0*v[27]+v[31])+v[32];
8135 Amat[1][0][1][1]=v[24];
8136 Amat[1][1][0][0]=v[20];
8137 Amat[1][1][0][1]=v[21];
8138 Amat[1][1][1][0]=v[24];
8139 Amat[1][1][1][1]=(*lam)*v[25]+(*mue)*(2e0*v[25]+v[26]+v[27])+v[32];