39 template<
class X,
class Diag,
class OffDiag>
69 const bool explicitMode
92 const X fluxB = -
_r[c1];
94 const X dXC1 = bValue -
_x[c1];
121 const X& specifiedFlux)
const
125 const X fluxB = -
_r[c1];
158 const X fluxB = -
_r[c1];
220 const X xB = this->
_x[c0] - 2.*xC0_dotn * en;
222 Diag dxBdxC0(Diag::getZero());
223 dxBdxC0(0,0) = 1.0 - 2.*en[0]*en[0];
224 dxBdxC0(0,1) = - 2.*en[0]*en[1];
225 dxBdxC0(0,2) = - 2.*en[0]*en[2];
227 dxBdxC0(1,0) = - 2.*en[1]*en[0];
228 dxBdxC0(1,1) = 1.0 - 2.*en[1]*en[1];
229 dxBdxC0(1,2) = - 2.*en[1]*en[2];
231 dxBdxC0(2,0) = - 2.*en[2]*en[0];
232 dxBdxC0(2,1) = - 2.*en[2]*en[1];
233 dxBdxC0(2,2) = 1.0 - 2.*en[2]*en[2];
236 const X xc1mxB = xB-this->
_x[c1];
244 this->
_r[c1] = xc1mxB;
293 _geomFields(geomFields),
294 _structureFields(structureFields),
295 _deformationGradientModel(
_meshes,_structureFields.deformation,
296 _structureFields.deformationGradient,_geomFields),
297 _initialDeformationNorm(),
300 const int numMeshes =
_meshes.size();
301 for (
int n=0; n<numMeshes; n++)
307 _vcMap[mesh.
getID()] = vc;
311 if ((_bcMap.find(fg.
id) == _bcMap.end())&&(fg.
groupType !=
"interior"))
318 bc->
bcType =
"SpecifiedTraction";
328 else if ((fg.
groupType ==
"velocity-inlet") ||
331 bc->
bcType =
"SpecifiedDeformation";
333 else if (fg.
groupType ==
"pressure-outlet")
335 bc->
bcType =
"SpecifiedForce";
338 throw CException(
"StructuralModel: unknown face group type "
347 const int numMeshes =
_meshes.size();
348 for (
int n=0; n<numMeshes; n++)
360 initialDeformation[0] = _options[
"initialXDeformation"];
361 initialDeformation[1] = _options[
"initialYDeformation"];
362 initialDeformation[2] = _options[
"initialZDeformation"];
363 *sCell = initialDeformation;
365 _structureFields.deformation.addArray(cells,sCell);
367 if (_options.transient)
369 _structureFields.volume0.addArray(cells,
370 dynamic_pointer_cast<ArrayBase>
371 (_geomFields.volume[cells].newCopy()));
372 _structureFields.deformationN1.addArray(cells,
373 dynamic_pointer_cast<ArrayBase>(sCell->newCopy()));
374 _structureFields.deformationN2.addArray(cells,
375 dynamic_pointer_cast<ArrayBase>(sCell->newCopy()));
376 if (_options.timeDiscretizationOrder > 1)
377 _structureFields.deformationN3.addArray(cells,
378 dynamic_pointer_cast<ArrayBase>(sCell->newCopy()));
379 if(_options.variableTimeStep)
381 _options.timeStepN1 = _options[
"timeStep"];
382 _options.timeStepN2 = _options[
"timeStep"];
388 _structureFields.elasticDeformation.addArray(cells,
389 dynamic_pointer_cast<ArrayBase>(sCell->newCopy()));
391 devStressField->zero();
392 _structureFields.devStress.addArray(cells,devStressField);
394 VMStressField->zero();
395 _structureFields.VMStress.addArray(cells,VMStressField);
397 plasticStrainField->zero();
398 _structureFields.plasticStrain.addArray(cells,plasticStrainField);
400 *acCell = _options.A;
401 _structureFields.creepConstant.addArray(cells, acCell);
405 *rhoCell = vc[
"density"];
406 _structureFields.density.addArray(cells,rhoCell);
409 *etaCell = vc[
"eta"];
410 _structureFields.eta.addArray(cells,etaCell);
413 *eta1Cell = vc[
"eta1"];
414 _structureFields.eta1.addArray(cells,eta1Cell);
417 *alphaCell = vc[
"alpha"];
418 _structureFields.alpha.addArray(cells,alphaCell);
421 *tCell = _options[
"operatingTemperature"];
422 _structureFields.temperature.addArray(cells,tCell);
444 deformationFlux->zero();
447 _structureFields.deformationFlux.addArray(faces,deformationFlux);
452 _structureFields.eta.syncLocal();
453 _structureFields.eta1.syncLocal();
454 _structureFields.alpha.syncLocal();
455 _structureFields.density.syncLocal();
460 _initialDeformationNorm =
MFRPtr();
469 const int numMeshes =
_meshes.size();
470 for (
int n=0; n<numMeshes; n++)
476 dynamic_cast<VectorT3Array&
>(_structureFields.deformation[cells]);
478 dynamic_cast<VectorT3Array&
>(_structureFields.deformationN1[cells]);
480 dynamic_cast<VectorT3Array&
>(_structureFields.deformationN2[cells]);
481 if (_options.timeDiscretizationOrder > 1)
484 dynamic_cast<VectorT3Array&
>(_structureFields.deformationN3[cells]);
489 if(_options.variableTimeStep)
491 if (_options.timeDiscretizationOrder > 1)
493 _options.timeStepN2 = _options.timeStepN1;
495 _options.timeStepN1 = _options[
"timeStep"];
503 const int numMeshes =
_meshes.size();
504 for (
int n=0; n<numMeshes; n++)
510 dynamic_cast<VectorT3Array&
>(_structureFields.deformation[cells]);
512 dynamic_cast<VectorT3Array&
>(_structureFields.elasticDeformation[cells]);
515 _deformationGradientModel.compute();
517 dynamic_cast<const VGradArray&
>(_structureFields.deformationGradient[cells]);
520 dynamic_cast<const TArray&
>(_structureFields.eta[cells]);
522 const TArray& lambdaCell =
523 dynamic_cast<const TArray&
>(_structureFields.eta1[cells]);
527 dynamic_cast<VGradArray&
>(_structureFields.devStress[cells]);
529 dynamic_cast<TArray&
>(_structureFields.VMStress[cells]);
531 const int nCells = cells.
getCount();
532 const T onethird(1.0/3.0);
534 const T twothirds(2.0/3.0);
539 dynamic_cast<const VectorT3Array&
>(_geomFields.coordinate[cells]);
548 const T twelve(12.0);
550 const T mid(200.e-6);
553 xI = pow(th,three)/twelve;
555 for(
int k=0; k<nCells; k++)
558 VGradType wgPlusTranspose = wGradCell[k];
563 wgPlusTranspose[i][j] += wg[j][i];
565 stress[0][0] = wgPlusTranspose[0][0]*muCell[k]+
566 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
567 stress[0][1] = wgPlusTranspose[0][1]*muCell[k];
568 stress[0][2] = wgPlusTranspose[0][2]*muCell[k];
570 stress[1][0] = wgPlusTranspose[1][0]*muCell[k];
571 stress[1][1] = wgPlusTranspose[1][1]*muCell[k]+
572 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
573 stress[1][2] = wgPlusTranspose[1][2]*muCell[k];
575 stress[2][0] = wgPlusTranspose[2][0]*muCell[k];
576 stress[2][1] = wgPlusTranspose[2][1]*muCell[k];
577 stress[2][2] = wgPlusTranspose[2][2]*muCell[k]+
578 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
609 devStress[k] = stress;
610 const T trace = stress[0][0]+stress[1][1]+stress[2][2];
611 (devStress[k])[0][0] = (devStress[k])[0][0] - onethird*trace;
612 (devStress[k])[1][1] = (devStress[k])[1][1] - onethird*trace;
613 (devStress[k])[2][2] = (devStress[k])[2][2] - onethird*trace;
615 VMStress[k] =
sqrt(half*(pow((stress[0][0]-stress[1][1]),2.0) +
616 pow((stress[1][1]-stress[2][2]),2.0) +
617 pow((stress[2][2]-stress[0][0]),2.0) +
618 six*(pow((stress[0][1]),2.0) +
619 pow((stress[1][2]),2.0) +
620 pow((stress[2][0]),2.0))));
628 const int numMeshes =
_meshes.size();
629 for (
int n=0; n<numMeshes; n++)
635 dynamic_cast<VectorT3Array&
>(_structureFields.deformation[cells]);
636 _deformationGradientModel.compute();
638 dynamic_cast<const VGradArray&
>(_structureFields.deformationGradient[cells]);
641 dynamic_cast<const TArray&
>(_structureFields.eta[cells]);
643 const TArray& lambdaCell =
644 dynamic_cast<const TArray&
>(_structureFields.eta1[cells]);
647 dynamic_cast<VGradArray&
>(_structureFields.devStress[cells]);
649 dynamic_cast<VGradArray&
>(_structureFields.plasticStrain[cells]);
651 dynamic_cast<TArray&
>(_structureFields.VMStress[cells]);
653 const int nCells = cells.
getCount();
654 const T onethird(1.0/3.0);
656 const T twothirds(2.0/3.0);
664 for(
int k=0; k<nCells; k++)
667 VGradType wgPlusTranspose = wGradCell[k];
669 const VGradType pS = plasticStrainCell[k];
673 wgPlusTranspose[i][j] += wg[j][i];
675 stress[0][0] = wgPlusTranspose[0][0]*muCell[k]-
676 two*pS[0][0]*muCell[k]+
677 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
678 stress[0][1] = wgPlusTranspose[0][1]*muCell[k]-
679 two*pS[0][1]*muCell[k];
680 stress[0][2] = wgPlusTranspose[0][2]*muCell[k]-
681 two*pS[0][2]*muCell[k];
683 stress[1][0] = wgPlusTranspose[1][0]*muCell[k]-
684 two*pS[1][0]*muCell[k];
685 stress[1][1] = wgPlusTranspose[1][1]*muCell[k]-
686 two*pS[1][1]*muCell[k]+
687 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
688 stress[1][2] = wgPlusTranspose[1][2]*muCell[k]-
689 two*pS[1][2]*muCell[k];
691 stress[2][0] = wgPlusTranspose[2][0]*muCell[k]-
692 two*pS[2][0]*muCell[k];
693 stress[2][1] = wgPlusTranspose[2][1]*muCell[k]-
694 two*pS[2][1]*muCell[k];
695 stress[2][2] = wgPlusTranspose[2][2]*muCell[k]-
696 two*pS[2][2]*muCell[k]+
697 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
699 if(_options.creepModel!=3)
701 stress[0][0]-=(pS[0][0]+pS[1][1]+pS[2][2])*lambdaCell[k];
702 stress[1][1]-=(pS[0][0]+pS[1][1]+pS[2][2])*lambdaCell[k];
703 stress[2][2]-=(pS[0][0]+pS[1][1]+pS[2][2])*lambdaCell[k];
706 devStress[k] = stress;
707 const T trace = stress[0][0]+stress[1][1]+stress[2][2];
708 (devStress[k])[0][0] = (devStress[k])[0][0] - onethird*trace;
709 (devStress[k])[1][1] = (devStress[k])[1][1] - onethird*trace;
710 (devStress[k])[2][2] = (devStress[k])[2][2] - onethird*trace;
712 VMStress[k] =
sqrt(half*(pow((stress[0][0]-stress[1][1]),2.0) +
713 pow((stress[1][1]-stress[2][2]),2.0) +
714 pow((stress[2][2]-stress[0][0]),2.0) +
715 six*(pow((stress[0][1]),2.0) +
716 pow((stress[1][2]),2.0) +
717 pow((stress[2][0]),2.0))));
722 for(
int k=0; k<nCells; k++)
725 VGradType wgPlusTranspose = wGradCell[k];
727 const VGradType pS = plasticStrainCell[k];
731 wgPlusTranspose[i][j] += wg[j][i];
733 stress[0][0] = wgPlusTranspose[0][0]*muCell[k]-
734 two*pS[0][0]*muCell[k]+
735 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
736 stress[0][1] = wgPlusTranspose[0][1]*muCell[k]-
737 two*pS[0][1]*muCell[k];
738 stress[0][2] = wgPlusTranspose[0][2]*muCell[k]-
739 two*pS[0][2]*muCell[k];
741 stress[1][0] = wgPlusTranspose[1][0]*muCell[k]-
742 two*pS[1][0]*muCell[k];
743 stress[1][1] = wgPlusTranspose[1][1]*muCell[k]-
744 two*pS[1][1]*muCell[k]+
745 (wg[0][0]+wg[1][1]+wg[2][2])*lambdaCell[k];
746 stress[1][2] = wgPlusTranspose[1][2]*muCell[k]-
747 two*pS[1][2]*muCell[k];
750 if(_options.creepModel!=3)
752 stress[0][0]+=(pS[2][2])*lambdaCell[k];
753 stress[1][1]+=(pS[2][2])*lambdaCell[k];
760 devStress[k] = stress;
761 const T trace = stress[0][0]+stress[1][1]+stress[2][2];
762 (devStress[k])[0][0] = (devStress[k])[0][0] - onethird*trace;
763 (devStress[k])[1][1] = (devStress[k])[1][1] - onethird*trace;
764 (devStress[k])[2][2] = (devStress[k])[2][2] - onethird*trace;
774 VMStress[k] =
sqrt(half*(pow((stress[0][0]-stress[1][1]),2.0) +
775 pow((stress[1][1]-stress[2][2]),2.0) +
776 pow((stress[2][2]-stress[0][0]),2.0) +
777 six*(pow((stress[0][1]),2.0) +
778 pow((stress[1][2]),2.0) +
779 pow((stress[2][0]),2.0))));
789 const int numMeshes =
_meshes.size();
790 for (
int n=0; n<numMeshes; n++)
797 ls.
getX().
addArray(wIndex,_structureFields.deformation.getArrayPtr(cells));
810 bool allNeumann =
true;
812 const int numMeshes =
_meshes.size();
813 for (
int n=0; n<numMeshes; n++)
823 const int nFaces = faces.
getCount();
824 const TArray& faceAreaMag =
825 dynamic_cast<const TArray&
>(_geomFields.areaMag[faces]);
831 _structureFields.deformation,
837 if (bc.
bcType ==
"SpecifiedDeformation")
840 bDeformation(bc.
getVal(
"specifiedXDeformation"),
841 bc.
getVal(
"specifiedYDeformation"),
842 bc.
getVal(
"specifiedZDeformation"),
848 else if (bc.
bcType ==
"Symmetry")
850 gbc.applySymmetryBC();
853 else if (bc.
bcType ==
"Interface")
855 gbc.applyInterfaceBC();
857 else if (bc.
bcType ==
"ZeroDerivative")
859 gbc.applyZeroDerivativeBC();
861 else if (bc.
bcType ==
"SpecifiedTraction")
864 bTraction(bc.
getVal(
"specifiedXXTraction"),
865 bc.
getVal(
"specifiedXYTraction"),
866 bc.
getVal(
"specifiedXZTraction"),
867 bc.
getVal(
"specifiedYXTraction"),
868 bc.
getVal(
"specifiedYYTraction"),
869 bc.
getVal(
"specifiedYZTraction"),
870 bc.
getVal(
"specifiedZXTraction"),
871 bc.
getVal(
"specifiedZYTraction"),
872 bc.
getVal(
"specifiedZZTraction"),
875 for(
int f=0; f<nFaces; f++)
882 else if (bc.
bcType ==
"SpecifiedForce")
885 bForce(bc.
getVal(
"specifiedXForce"),
886 bc.
getVal(
"specifiedYForce"),
887 bc.
getVal(
"specifiedZForce"),
889 for(
int f=0; f<nFaces; f++)
896 else if (bc.
bcType ==
"SpecifiedDistForce")
899 bDistForce(bc.
getVal(
"specifiedXDistForce"),
900 bc.
getVal(
"specifiedYDistForce"),
901 bc.
getVal(
"specifiedZDistForce"),
903 for(
int f=0; f<nFaces; f++)
933 int allNeumannInt = int( allNeumann);
934 MPI::COMM_WORLD.Allreduce(MPI::IN_PLACE, &allNeumannInt, count, MPI::INT, MPI::PROD);
935 allNeumann = bool(allNeumannInt);
939 if(allNeumann && !explicitMode)
948 (_structureFields.deformation[cells]);
961 _deformationGradientModel.compute();
966 shared_ptr<Discretization>
969 _structureFields.deformation,
970 _structureFields.eta,
971 _structureFields.eta1,
972 _structureFields.alpha,
973 _structureFields.deformationGradient,
974 _structureFields.temperature,
975 _options[
"operatingTemperature"],
976 _options[
"residualXXStress"],
977 _options[
"residualYYStress"],
978 _options[
"residualZZStress"],
980 _options.residualStress));
988 discretizations.push_back(sd);
994 shared_ptr<Discretization>
997 _structureFields.deformation,
998 _structureFields.eta,
999 _structureFields.eta1,
1000 _structureFields.alpha,
1001 _structureFields.deformationGradient,
1002 _structureFields.temperature,
1003 _options[
"operatingTemperature"],
1004 _options[
"residualXXStress"],
1005 _options[
"residualYYStress"],
1006 _options[
"residualZZStress"],
1008 _options.residualStress,
1009 _structureFields.devStress,
1010 _structureFields.VMStress,
1011 _structureFields.plasticStrain,
1012 _structureFields.creepConstant,
1018 _options[
"timeStep"],
1019 _options.creepModel));
1021 discretizations.push_back(scd);
1024 if (_options.transient && !explicitMode)
1026 shared_ptr<Discretization>
1030 _structureFields.deformation,
1031 _structureFields.deformationN1,
1032 _structureFields.deformationN2,
1033 _structureFields.deformationN3,
1034 _structureFields.density,
1035 _structureFields.volume0,
1036 _options.variableTimeStep,
1037 _options[
"timeStep"],
1038 _options.timeStepN1,
1039 _options.timeStepN2));
1041 discretizations.push_back(td);
1057 applyBC(ls,explicitMode);
1060 shared_ptr<Discretization>
1062 (
_meshes,_structureFields.deformation,
1063 _options[
"deformationURF"]));
1066 discretizations2.push_back(ud);
1078 initDeformationLinearization(ls);
1080 linearizeDeformation(ls,
false);
1083 MFRPtr rNorm = _options.getDeformationLinearSolver().solve(ls);
1084 if (!_initialDeformationNorm) _initialDeformationNorm = rNorm;
1085 _options.getDeformationLinearSolver().cleanup();
1094 this->_lsK = shared_ptr<LinearSystem>(
new LinearSystem());
1096 initDeformationLinearization(ls);
1098 linearizeDeformation(ls,
true);
1100 ls.replaceDelta(dynamic_pointer_cast<MultiField>(ls.getX().newClone()));
1101 ls.replaceResidual(dynamic_pointer_cast<MultiField>(ls.getX().newClone()));
1107 this->_lsK = shared_ptr<LinearSystem>();
1112 const int nMeshes = this->
_meshes.size();
1118 _structureFields.deformation,
1119 _structureFields.deformationN1,
1120 _structureFields.deformationN2,
1121 _structureFields.deformationN3,
1122 _structureFields.density,
1123 _structureFields.volume0,
1124 _options.variableTimeStep,
1126 _options.timeStepN1,
1127 _options.timeStepN2);
1130 for(
int n=0; n<nSteps; n++)
1140 for(
int n=0; n<nMeshes; n++)
1161 const int numMeshes =
_meshes.size();
1162 for(
int n=0;n<numMeshes;n++)
1170 (_structureFields.deformation[cells]);
1176 for(
int c=0;c<nCells;c++)
1188 for(
int n=0; n<niter; n++)
1190 MFRPtr dNorm = solveDeformation();
1194 _initialDeformationNorm->setMax(*dNorm);
1197 MFRPtr dNormRatio(dNorm->normalize(*_initialDeformationNorm));
1201 if ( MPI::COMM_WORLD.Get_rank() == 0 ){
1202 if (_options.printNormalizedResiduals)
1203 cout << _niters <<
": " << *dNormRatio << endl;
1205 cout << _niters <<
": " << *dNorm << endl;
1209 #ifndef FVM_PARALLEL
1210 if (_options.printNormalizedResiduals)
1211 cout << _niters <<
": " << *dNormRatio << endl;
1213 cout << _niters <<
": " << *dNorm << endl;
1218 if (*dNormRatio < _options.deformationTolerance)
1227 foreach(
typename StructureBCMap::value_type& pos, _bcMap)
1229 cout <<
"Face Group " << pos.first <<
":" << endl;
1230 cout <<
" bc type " << pos.second->bcType << endl;
1233 cout <<
" " << vp.first <<
" " << vp.second.constant << endl;
1239 VectorT3 getDeformationFluxIntegral(
const Mesh& mesh,
const int faceGroupId)
1246 if (fg.
id == faceGroupId)
1249 const int nFaces = faces.
getCount();
1251 dynamic_cast<const VectorT3Array&
>(_structureFields.deformationFlux[faces]);
1252 for(
int f=0; f<nFaces; f++)
1253 r += deformationFlux[f];
1258 throw CException(
"getDeformationFluxIntegral: invalid faceGroupID");
1262 VectorT3 getDeformationDerivativeIntegral(
const Mesh& mesh)
1268 const TArray& density =
1269 dynamic_cast<const TArray&
>(_structureFields.density[cells]);
1271 dynamic_cast<const VectorT3Array&
>(_structureFields.deformation[cells]);
1273 dynamic_cast<const VectorT3Array&
>(_structureFields.deformationN1[cells]);
1275 dynamic_cast<const VectorT3Array&
>(_structureFields.deformationN2[cells]);
1277 const TArray& volume =
1278 dynamic_cast<const TArray&
>(_geomFields.volume[cells]);
1280 const T deltaT = _options[
"timeStep"];
1282 T onePointFive(1.5);
1286 for(
int c=0; c<nCells; c++)
1288 const T rhoVbydT = density[c]*volume[c]/deltaT;
1289 r += rhoVbydT*(onePointFive*w[c]- two*wN1[c]
1290 + pointFive*wN2[c]);
1295 boost::shared_ptr<ArrayBase> getStressTensor(
const Mesh& mesh,
const ArrayBase& gcellIds)
1304 _deformationGradientModel.compute();
1306 const VGradArray& wGrad =
1307 dynamic_cast<const VGradArray&
>(_structureFields.deformationGradient[cells]);
1312 const TArray& eta =
dynamic_cast<const TArray&
>(_structureFields.eta[cells]);
1313 const TArray& eta1 =
dynamic_cast<const TArray&
>(_structureFields.eta1[cells]);
1315 boost::shared_ptr<StressTensorArray> stressTensorPtr(
new StressTensorArray(nCells));
1316 StressTensorArray& stressTensor = *stressTensorPtr;
1318 for(
int n=0; n<nCells; n++)
1320 const int c = cellIds[n];
1321 const VGradType& wg = wGrad[c];
1322 VGradType wgPlusTranspose = wGrad[c];
1324 for(
int i=0;i<3;i++)
1325 for(
int j=0;j<3;j++)
1326 wgPlusTranspose[i][j] += wg[j][i];
1328 stressTensor[n][0] = wgPlusTranspose[0][0]*eta[c]+
1329 (wg[0][0]+wg[1][1]+wg[2][2])*eta1[c];
1330 stressTensor[n][1] = wgPlusTranspose[1][1]*eta[c]+
1331 (wg[0][0]+wg[1][1]+wg[2][2])*eta1[c];
1332 stressTensor[n][2] = wgPlusTranspose[2][2]*eta[c]+
1333 (wg[0][0]+wg[1][1]+wg[2][2])*eta1[c];
1334 stressTensor[n][3] = wgPlusTranspose[0][1]*eta[c];
1335 stressTensor[n][4] = wgPlusTranspose[1][2]*eta[c];
1336 stressTensor[n][5] = wgPlusTranspose[2][0]*eta[c];
1339 return stressTensorPtr;
1348 const int nCells = cells.
getCount();
1350 shared_ptr<VectorT3Array> tractionXPtr(
new VectorT3Array(nCells));
1351 tractionXPtr->zero();
1352 _structureFields.tractionX.addArray(cells,tractionXPtr);
1355 shared_ptr<VectorT3Array> tractionYPtr(
new VectorT3Array(nCells));
1356 tractionYPtr->zero();
1357 _structureFields.tractionY.addArray(cells,tractionYPtr);
1360 shared_ptr<VectorT3Array> tractionZPtr(
new VectorT3Array(nCells));
1361 tractionZPtr->zero();
1362 _structureFields.tractionZ.addArray(cells,tractionZPtr);
1365 _deformationGradientModel.compute();
1368 dynamic_cast<const VGradArray&
>(_structureFields.deformationGradient[cells]);
1371 dynamic_cast<VGradArray&
>(_structureFields.plasticStrain[cells]);
1373 const TArray& eta =
dynamic_cast<const TArray&
>(_structureFields.eta[cells]);
1374 const TArray& eta1 =
dynamic_cast<const TArray&
>(_structureFields.eta1[cells]);
1375 const TArray& alpha =
dynamic_cast<const TArray&
>(_structureFields.alpha[cells]);
1377 const TArray& temperature =
dynamic_cast<const TArray&
>(_structureFields.temperature[cells]);
1383 for(
int n=0; n<nCells; n++)
1387 const VGradType& pS = plasticStrainCell[n];
1388 for(
int i=0;i<3;i++)
1389 for(
int j=0;j<3;j++)
1390 wgPlusTranspose[i][j] += wg[j][i];
1392 tractionX[n][0] = wgPlusTranspose[0][0]*eta[n]+
1393 (wg[0][0]+wg[1][1]+wg[2][2])*eta1[n];
1394 tractionX[n][1] = wgPlusTranspose[0][1]*eta[n];
1395 tractionX[n][2] = wgPlusTranspose[0][2]*eta[n];
1397 tractionY[n][0] = wgPlusTranspose[1][0]*eta[n];
1398 tractionY[n][1] = wgPlusTranspose[1][1]*eta[n]+
1399 (wg[0][0]+wg[1][1]+wg[2][2])*eta1[n];
1400 tractionY[n][2] = wgPlusTranspose[1][2]*eta[n];
1402 tractionZ[n][0] = wgPlusTranspose[2][0]*eta[n];
1403 tractionZ[n][1] = wgPlusTranspose[2][1]*eta[n];
1404 tractionZ[n][2] = wgPlusTranspose[2][2]*eta[n]+
1405 (wg[0][0]+wg[1][1]+wg[2][2])*eta1[n];
1407 if(_options.residualStress)
1409 tractionX[n][0] += _options[
"residualXXStress"];
1410 tractionY[n][1] += _options[
"residualYYStress"];
1411 tractionZ[n][2] += _options[
"residualZZStress"];
1418 tractionX[n][0] -= (two*eta1[n]+two*eta[n])*alpha[n]*(temperature[n]-_options[
"operatingTemperature"]);
1419 tractionY[n][1] -= (two*eta1[n]+two*eta[n])*alpha[n]*(temperature[n]-_options[
"operatingTemperature"]);
1423 tractionX[n][0] -= (three*eta1[n]+two*eta[n])*alpha[n]*(temperature[n]-_options[
"operatingTemperature"]);
1424 tractionY[n][1] -= (three*eta1[n]+two*eta[n])*alpha[n]*(temperature[n]-_options[
"operatingTemperature"]);
1425 tractionZ[n][2] -= (three*eta1[n]+two*eta[n])*alpha[n]*(temperature[n]-_options[
"operatingTemperature"]);
1431 tractionX[n][0]-=(two*eta[n]*pS[0][0] +
1432 (pS[0][0] + pS[1][1])*eta1[n]);
1433 tractionX[n][1]-=(two*eta[n]*pS[0][1]);
1434 tractionX[n][2]-=(two*eta[n]*pS[0][2]);
1436 tractionY[n][0]-=(two*eta[n]*pS[1][0]);
1437 tractionY[n][1]-=(two*eta[n]*pS[1][1] +
1438 (pS[0][0] + pS[1][1])*eta1[n]);
1439 tractionY[n][2]-=(two*eta[n]*pS[1][2]);
1444 tractionZ[n] = zero;
1453 const int nCells = cells.
getCount();
1455 shared_ptr<VectorT3Array> strainXPtr(
new VectorT3Array(nCells));
1457 _structureFields.strainX.addArray(cells,strainXPtr);
1460 shared_ptr<VectorT3Array> strainYPtr(
new VectorT3Array(nCells));
1462 _structureFields.strainY.addArray(cells,strainYPtr);
1465 shared_ptr<VectorT3Array> strainZPtr(
new VectorT3Array(nCells));
1467 _structureFields.strainZ.addArray(cells,strainZPtr);
1470 _deformationGradientModel.compute();
1473 dynamic_cast<const VGradArray&
>(_structureFields.deformationGradient[cells]);
1475 const T half(1./2.);
1477 for(
int n=0; n<nCells; n++)
1482 for(
int i=0;i<3;i++)
1483 for(
int j=0;j<3;j++)
1484 wgPlusTranspose[i][j] += wg[j][i];
1486 strainX[n][0] = half*wgPlusTranspose[0][0];
1487 strainX[n][1] = half*wgPlusTranspose[0][1];
1488 strainX[n][2] = half*wgPlusTranspose[0][2];
1490 strainY[n][0] = half*wgPlusTranspose[1][0];
1491 strainY[n][1] = half*wgPlusTranspose[1][1];
1492 strainY[n][2] = half*wgPlusTranspose[1][2];
1494 strainZ[n][0] = half*wgPlusTranspose[2][0];
1495 strainZ[n][1] = half*wgPlusTranspose[2][1];
1496 strainZ[n][2] = half*wgPlusTranspose[2][2];
1506 shared_ptr<VectorT3Array> plasticDiagStrainPtr(
new VectorT3Array(nCells));
1507 plasticDiagStrainPtr->zero();
1508 _structureFields.plasticDiagStrain.addArray(cells,plasticDiagStrainPtr);
1512 dynamic_cast<const VGradArray&
>(_structureFields.plasticStrain[cells]);
1514 for(
int n=0; n<nCells; n++)
1516 plasticDiagStrain[n][0]=plasticStrain[n][0][0];
1517 plasticDiagStrain[n][1]=plasticStrain[n][1][1];
1518 plasticDiagStrain[n][2]=plasticStrain[n][0][1];
1531 const int offset = faceSite.
getOffset();
1532 for (
int i = 0; i < faceSite.
getCount(); i++ ){
1533 const int faceID = i + offset;
1535 const int indx = commonFacesMap.find(faceID)->second;
1536 fx[i] = bforce[indx][0];
1537 fy[i] = bforce[indx][1];
1538 fz[i] = bforce[indx][2];
1592 void printDeformationFluxIntegrals()
1594 const int numMeshes =
_meshes.size();
1595 for (
int n=0; n<numMeshes; n++)
1605 const int nFaces = faces.
getCount();
1607 dynamic_cast<const VectorT3Array&
>(_structureFields.deformationFlux[faces]);
1608 for(
int f=0; f<nFaces; f++)
1609 r += deformationFlux[f];
1611 cout <<
"Mesh " << mesh.
getID() <<
" faceGroup " << fg.
id <<
" : " << r << endl;
1681 _impl(new
Impl(geomFields,structureFields,meshes))
1727 return _impl->advance(niter);
1734 _impl->advanceExplicit(nsteps,deltaT);
1741 return _impl->initExplicitAdvance();
1751 _impl->updateForceOnBoundary(faceSite, bforceA, commonFacesMap, fxA, fyA, fzA);
1759 return _impl->finishExplicitAdvance();
1773 _impl->computeVMStress();
1780 return _impl->getStrain(mesh);
1787 return _impl->getPlasticDiagStrain(mesh);
1794 _impl->updateTime();
1803 _impl->printDeformationFluxIntegrals();
1811 return _impl->getDeformationFluxIntegral(mesh,faceGroupId);
1818 return _impl->getDeformationDerivativeIntegral(mesh);
1827 return _impl->getTraction(mesh);
1833 boost::shared_ptr<ArrayBase>
1836 return _impl->getStressTensor(mesh, cellIds);
const FaceGroupList & getBoundaryFaceGroups() const
void advanceExplicit(const int nsteps, const double deltaT)
void initExplicitAdvance()
void getTraction(const Mesh &mesh)
X applyNeumannBC(const int f, const X &specifiedFlux) const
CRMatrix< DiagTensorT3, DiagTensorT3, VectorT3 > VVMatrix
void linearizeDeformation(LinearSystem &ls, bool explicitMode)
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
shared_ptr< FaceGroup > FaceGroupPtr
StructureBCS(const StorageSite &faces, const Mesh &mesh, const GeomFields &geomFields, Field &varField, MultiFieldMatrix &matrix, MultiField &xField, MultiField &rField, const bool explicitMode)
const TArray & _faceAreaMag
Vector< double, 3 > VectorT3
void initExplicitAdvance()
StructureModelOptions< T > & getOptions()
std::map< int, StructureVC< T > * > StructureVCMap
const FaceGroupList & getAllFaceGroups() const
VVMatrix::DiagArray VVDiagArray
VectorTranspose< T, 3 > VectorT3T
const VectorT3Array & _faceArea
SquareTensor< T, 3 > DiagTensorT3
OffDiag & getCoeff10(const int np)
std::map< int, StructureBC< T > * > StructureBCMap
Array< VectorT3 > VectorT3Array
X applyDirichletBC(const FloatValEvaluator< X > &bValue) const
GradientModel< VectorT3 > _deformationGradientModel
StructureVCMap & getVCMap()
StructureModel(const GeomFields &geomFields, StructureFields &structureFields, const MeshList &meshes)
MFRPtr _initialDeformationNorm
FloatVal< T > getVal(const string varName) const
CCMatrix::PairWiseAssembler CCAssembler
void applySymmetryBC() const
FluxJacobianMatrix< Diag, X > FMatrix
void initDeformationLinearization(LinearSystem &ls)
Array< Vector< double, 3 > > VectorT3Array
Tangent sqrt(const Tangent &a)
bool advance(const int niter)
void getStrain(const Mesh &mesh)
StructureFields & _structureFields
DiagonalMatrix< Diag, X > BBMatrix
X applyDirichletBC(const X &bValue) const
void applyInterfaceBC(const int f) const
void getPlasticDiagStrain(const Mesh &mesh)
StructureBCMap & getBCMap()
pair< const Field *, const StorageSite * > ArrayIndex
void updateForceOnBoundary(const StorageSite &faceSite, const ArrayBase &bforceA, const map< int, int > &commonFacesMap, ArrayBase &fxA, ArrayBase &fyA, ArrayBase &fzA)
const StorageSite & _cells
void finishExplicitAdvance()
Vector< T_Scalar, 3 > VectorT3
StructureBCMap & getBCMap()
void getStrain(const Mesh &mesh)
vector< shared_ptr< Discretization > > DiscrList
void getTraction(const Mesh &mesh)
const StorageSite & getCells() const
void applyBC(LinearSystem &ls, bool explicitMode)
void applyInterfaceBC() const
int getCountLevel1() const
OffDiag & getCoeff01(const int np)
const GeomFields & _geomFields
const StorageSite & _faces
shared_ptr< LinearSystem > _lsK
virtual ~StructureModel()
X applyZeroDerivativeBC() const
void addMatrix(const Index &rowI, const Index &colI, shared_ptr< Matrix > m)
void setBoundary(const int nr)
Array< Gradient< VectorT3 > > VGradArray
StructureModelOptions< T > & getOptions()
Gradient< VectorT3 > VGradType
Array< VectorT3 > VectorT3Array
const MultiField::ArrayIndex _xIndex
const CRConnectivity & getCellCells2() const
X applyNeumannBC(const X &bFlux) const
StructureModelOptions< T > _options
X applyDirichletBC(int f, const X &bValue) const
void updateForceOnBoundary(const StorageSite &faceSite, const ArrayBase &bforceA, const map< int, int > &commonFacesMap, ArrayBase &fxA, ArrayBase &fyA, ArrayBase &fzA)
shared_ptr< MultiFieldReduction > MFRPtr
void addArray(const ArrayIndex &aIndex, shared_ptr< ArrayBase > a)
void setDirichlet(const int nr)
NumTypeTraits< X >::T_Scalar T_Scalar
CRMatrix< Diag, OffDiag, X > CCMatrix
virtual void multiply(IContainer &yB, const IContainer &xB) const
Impl(const GeomFields &geomFields, StructureFields &structureFields, const MeshList &meshes)
StructureVCMap & getVCMap()
T dot(const Vector< T, 3 > &a, const Vector< T, 3 > &b)
X applyNeumannBC(const FloatValEvaluator< X > &bFlux) const
void advanceExplicit(const int nSteps, const double deltaT)
MFRPtr solveDeformation()
Array< OffDiag > OffDiagArray
void eliminateDirichlet(const int j, Array< X > &b, const X &delta_j, const bool explicitMode=false)
const Field & _areaMagField
void getPlasticDiagStrain(const Mesh &mesh)
virtual void linearize(DiscrList &discretizations, const MeshList &meshes, MultiFieldMatrix &matrix, MultiField &x, MultiField &b)
const CRConnectivity & _faceCells
MultiFieldMatrix & getMatrix()
vector< Mesh * > MeshList
void finishExplicitAdvance()
bool advance(const int niter)