129 ParallelComm* pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
130 if(pcomm == NULL) pcomm =
new ParallelComm(&moab,PETSC_COMM_WORLD);
132 PetscBool flg = PETSC_TRUE;
135 if(flg != PETSC_TRUE) {
136 SETERRQ(PETSC_COMM_SELF,1,
"*** ERROR -my_file (MESH FILE NEEDED)");
141 if(flg != PETSC_TRUE) {
144 PetscInt bubble_order;
146 if(flg != PETSC_TRUE) {
147 bubble_order =
order;
152 PetscBool is_partitioned = PETSC_FALSE;
156 double mygiven_strain[6];
160 given_strain.resize(6);
161 cblas_dcopy(6, &mygiven_strain[0], 1, &given_strain(0), 1);
162 cout<<
"given_strain ="<<given_strain<<endl;
166 if(is_partitioned == PETSC_TRUE) {
168 option =
"PARALLEL=BCAST_DELETE;PARALLEL_RESOLVE_SHARED_ENTS;PARTITION=PARALLEL_PARTITION;";
179 SmallStrainParaboloidalPlasticity cp;
215 PetscPrintf(PETSC_COMM_WORLD,
"young_modulus = %4.2e \n",
young_modulus);
216 PetscPrintf(PETSC_COMM_WORLD,
"poisson_ratio = %4.2e \n",
poisson_ratio);
218 PetscPrintf(PETSC_COMM_WORLD,
"sIgma_yt = %4.2e \n",cp.sIgma_yt);
219 PetscPrintf(PETSC_COMM_WORLD,
"sIgma_yc = %4.2e \n",cp.sIgma_yc);
221 PetscPrintf(PETSC_COMM_WORLD,
"nup = %4.2e \n",cp.nup);
223 cp.sTrain.resize(6,
false);
225 cp.plasticStrain.resize(6,
false);
226 cp.plasticStrain.clear();
227 cp.internalVariables.resize(2,
false);
228 cp.internalVariables.clear();
284 vector<BitRefLevel> bit_levels;
286 int def_meshset_info[2] = {0,0};
287 rval = moab.tag_get_handle(
"MESHSET_INFO",2,MB_TYPE_INTEGER,th_meshset_info,MB_TAG_CREAT|MB_TAG_SPARSE,&def_meshset_info);
291 if(meshset_data[0]==0) {
295 bit_levels.push_back(
BitRefLevel().set(meshset_data[0]-1));
315 Range interface_prims_on_problem_bit_level;
316 ierr = m_field.get_entities_by_type_and_ref_level(
317 problem_bit_level,
BitRefLevel().set(),MBPRISM,interface_prims_on_problem_bit_level
319 Range tets_on_problem_bit_level;
320 ierr = m_field.get_entities_by_type_and_ref_level(
321 problem_bit_level,
BitRefLevel().set(),MBTET,tets_on_problem_bit_level
324 cout<<
"interface_prims_on_problem_bit_level "<<interface_prims_on_problem_bit_level.size()<<endl;
325 cout<<
"tets_on_problem_bit_level "<<tets_on_problem_bit_level.size()<<endl;
330 Range preriodic_prisms;
335 ierr = m_field.get_cubit_msId_entities_by_dimension(101,
SIDESET,2,SurTrisNeg,
true); CHKERRQ(
ierr);
336 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Old+New triangles on SideSet 101 = %d\n",SurTrisNeg.size()); CHKERRQ(
ierr);
339 ierr = m_field.get_entities_by_type_and_ref_level(problem_bit_level,
BitRefLevel().set(),MBTRI,AllTris); CHKERRQ(
ierr);
340 ierr = PetscPrintf(PETSC_COMM_WORLD,
"All triangles in the new bit-level = %d\n",AllTris.size()); CHKERRQ(
ierr);
343 SurTrisNeg = intersect(AllTris,SurTrisNeg);
344 ierr = PetscPrintf(PETSC_COMM_WORLD,
"New triangles on SideSet 101 = %d\n",SurTrisNeg.size()); CHKERRQ(
ierr);
348 double TriCen[3], coords_Tri[9];
352 double roundfact=1e3;
354 for(Range::iterator it = SurTrisNeg.begin(); it!=SurTrisNeg.end(); it++) {
363 TriCen[0]= (coords_Tri[0]+coords_Tri[3]+coords_Tri[6])/3.0;
364 TriCen[1]= (coords_Tri[1]+coords_Tri[4]+coords_Tri[7])/3.0;
365 TriCen[2]= (coords_Tri[2]+coords_Tri[5]+coords_Tri[8])/3.0;
368 TriCen[0]=round(TriCen[0]*roundfact)/roundfact;
369 TriCen[1]=round(TriCen[1]*roundfact)/roundfact;
370 TriCen[2]=round(TriCen[2]*roundfact)/roundfact;
374 Face_CenPos_Handle_varNeg.insert(
Face_CenPos_Handle(TriCen[0], TriCen[1], TriCen[2], *it));
388 ierr = m_field.get_cubit_msId_entities_by_dimension(102,
SIDESET,2,SurTrisPos,
true); CHKERRQ(
ierr);
389 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Old+New triangles on SideSet 102 = %d\n",SurTrisPos.size()); CHKERRQ(
ierr);
392 SurTrisPos = intersect(AllTris,SurTrisPos);
393 ierr = PetscPrintf(PETSC_COMM_WORLD,
"New triangles on SideSet 102 = %d\n",SurTrisPos.size()); CHKERRQ(
ierr);
398 for(Range::iterator it = SurTrisPos.begin(); it!=SurTrisPos.end(); it++) {
407 TriCen[0]= (coords_Tri[0]+coords_Tri[3]+coords_Tri[6])/3.0;
408 TriCen[1]= (coords_Tri[1]+coords_Tri[4]+coords_Tri[7])/3.0;
409 TriCen[2]= (coords_Tri[2]+coords_Tri[5]+coords_Tri[8])/3.0;
412 TriCen[0]=round(TriCen[0]*roundfact)/roundfact;
413 TriCen[1]=round(TriCen[1]*roundfact)/roundfact;
414 TriCen[2]=round(TriCen[2]*roundfact)/roundfact;
419 Face_CenPos_Handle_varPos.insert(
Face_CenPos_Handle(TriCen[0], TriCen[1], TriCen[2], *it));
423 double XcoordMin, YcoordMin, ZcoordMin, XcoordMax, YcoordMax, ZcoordMax;
424 typedef Face_CenPos_Handle_multiIndex::index<xcoord_tag>::type::iterator Tri_Xcoord_iterator;
425 typedef Face_CenPos_Handle_multiIndex::index<ycoord_tag>::type::iterator Tri_Ycoord_iterator;
426 typedef Face_CenPos_Handle_multiIndex::index<zcoord_tag>::type::iterator Tri_Zcoord_iterator;
427 Tri_Xcoord_iterator XcoordMin_it, XcoordMax_it;
428 Tri_Ycoord_iterator YcoordMin_it, YcoordMax_it;
429 Tri_Zcoord_iterator ZcoordMin_it, ZcoordMax_it;
432 XcoordMin_it=Face_CenPos_Handle_varNeg.get<
xcoord_tag>().begin(); XcoordMin=XcoordMin_it->xcoord;
433 XcoordMax_it=Face_CenPos_Handle_varPos.get<
xcoord_tag>().end(); XcoordMax_it--; XcoordMax=XcoordMax_it->xcoord;
434 YcoordMin_it=Face_CenPos_Handle_varNeg.get<
ycoord_tag>().begin(); YcoordMin=YcoordMin_it->ycoord;
435 YcoordMax_it=Face_CenPos_Handle_varPos.get<
ycoord_tag>().end(); YcoordMax_it--; YcoordMax=YcoordMax_it->ycoord;
436 ZcoordMin_it=Face_CenPos_Handle_varNeg.get<
zcoord_tag>().begin(); ZcoordMin=ZcoordMin_it->zcoord;
437 ZcoordMax_it=Face_CenPos_Handle_varPos.get<
zcoord_tag>().end(); ZcoordMax_it--; ZcoordMax=ZcoordMax_it->zcoord;
439 cout<<
"XcoordMin "<<XcoordMin <<
" XcoordMax "<<XcoordMax <<endl;
440 cout<<
"YcoordMin "<<YcoordMin <<
" YcoordMax "<<YcoordMax <<endl;
441 cout<<
"ZcoordMin "<<ZcoordMin <<
" ZcoordMax "<<ZcoordMax <<endl;
449 typedef Face_CenPos_Handle_multiIndex::index<Tri_Hand_tag>::type::iterator Tri_Hand_iterator;
450 Tri_Hand_iterator Tri_Neg;
451 typedef Face_CenPos_Handle_multiIndex::index<Composite_xyzcoord>::type::iterator xyzcoord_iterator;
452 xyzcoord_iterator Tri_Pos;
453 double XPos, YPos, ZPos;
459 for(Range::iterator it = SurTrisNeg.begin(); it!=SurTrisNeg.end(); it++) {
466 Tri_Neg=Face_CenPos_Handle_varNeg.get<
Tri_Hand_tag>().find(*it);
470 if(Tri_Neg->xcoord==XcoordMin){XPos=XcoordMax; YPos=Tri_Neg->ycoord; ZPos=Tri_Neg->zcoord;};
471 if(Tri_Neg->ycoord==YcoordMin){XPos=YPos=Tri_Neg->xcoord; YPos=YcoordMax; ZPos=Tri_Neg->zcoord;};
472 if(Tri_Neg->zcoord==ZcoordMin){XPos=YPos=Tri_Neg->xcoord; YPos=Tri_Neg->ycoord; ZPos=ZcoordMax; };
473 Tri_Pos=Face_CenPos_Handle_varPos.get<
Composite_xyzcoord>().find(boost::make_tuple(XPos, YPos, ZPos));
481 vector<EntityHandle> TriNodesNeg, TriNodesPos;
482 double CoordNodeNeg[9], CoordNodePos[9];
487 for(
int ii=0; ii<3; ii++){
488 PrismNodes[ii]=TriNodesNeg[ii];
499 double XNodeNeg, YNodeNeg, ZNodeNeg, XNodePos, YNodePos, ZNodePos;
500 for(
int ii=0; ii<3; ii++){
501 if(Tri_Neg->xcoord==XcoordMin){XNodeNeg=XcoordMax; YNodeNeg=CoordNodeNeg[3*ii+1]; ZNodeNeg=CoordNodeNeg[3*ii+2];};
502 if(Tri_Neg->ycoord==YcoordMin){XNodeNeg=CoordNodeNeg[3*ii]; YNodeNeg=YcoordMax; ZNodeNeg=CoordNodeNeg[3*ii+2];};
503 if(Tri_Neg->zcoord==ZcoordMin){XNodeNeg=CoordNodeNeg[3*ii]; YNodeNeg=CoordNodeNeg[3*ii+1]; ZNodeNeg=ZcoordMax;};
504 for(
int jj=0; jj<3; jj++){
506 XNodeNeg=round(XNodeNeg*roundfact)/roundfact;
507 YNodeNeg=round(YNodeNeg*roundfact)/roundfact;
508 ZNodeNeg=round(ZNodeNeg*roundfact)/roundfact;
510 XNodePos=CoordNodePos[3*jj]; YNodePos=CoordNodePos[3*jj+1]; ZNodePos=CoordNodePos[3*jj+2];
511 XNodePos=round(XNodePos*roundfact)/roundfact;
512 YNodePos=round(YNodePos*roundfact)/roundfact;
513 ZNodePos=round(ZNodePos*roundfact)/roundfact;
515 if(XNodeNeg==XNodePos && YNodeNeg==YNodePos && ZNodeNeg==ZNodePos){
516 PrismNodes[3+ii]=TriNodesPos[jj];
522 double CoordNodesPrisms[18];
532 preriodic_prisms.insert(PeriodicPrism);
563 ierr = m_field.seed_finite_elements(preriodic_prisms); CHKERRQ(
ierr);
572 ierr = m_field.get_entities_by_ref_level(bit_levels.back(),
BitRefLevel().set(),out_meshset); CHKERRQ(
ierr);
574 Range LatestRefinedTets;
575 rval = moab.get_entities_by_type(out_meshset, MBTET,LatestRefinedTets,
true);
CHKERRQ_MOAB(
rval);
577 Range Interface_Periodic_Prisms;
578 rval = moab.get_entities_by_type(out_meshset, MBPRISM,Interface_Periodic_Prisms,
true);
CHKERRQ_MOAB(
rval);
579 cout<<
"Interface_Periodic_Prisms " <<Interface_Periodic_Prisms.size()<<endl;
615 ierr = m_field.
loop_dofs(
"MESH_NODE_POSITIONS",ent_method_material,0); CHKERRQ(
ierr);
627 if(it->getName() !=
"MAT_PLASTIC")
continue;
629 int id = it->getMeshsetId();
632 meshset,MBTET,newtets,
true
635 cout<<
"========================== newtets "<<newtets.size()<<endl;
638 newtets = intersect(newtets,LatestRefinedTets);
639 ierr = m_field.seed_finite_elements(newtets); CHKERRQ(
ierr);
643 cout<<
"========================== newtets "<<newtets.size()<<endl;
651 trans_elastic.commonData.spatialPositions =
"DISPLACEMENT";
652 trans_elastic.commonData.meshPositions =
"MESH_NODE_POSITIONS";
653 std::map<int,boost::shared_ptr<SmallStrainTranverslyIsotropicADouble> > tranversly_isotropic_adouble_ptr_map;
654 std::map<int,boost::shared_ptr<SmallStrainTranverslyIsotropicDouble> > tranversly_isotropic_double_ptr_map;
655 bool trans_iso_blocks =
false;
658 string name = it->getName();
659 if (name.compare(0,20,
"MAT_ELASTIC_TRANSISO") == 0) {
660 cout<<
"================================ it is MAT_ELASTIC_TRANSISO "<<endl;
661 trans_iso_blocks =
true;
662 int id = it->getMeshsetId();
664 ierr = it->getAttributeDataStructure(mydata); CHKERRQ(
ierr);
665 tranversly_isotropic_adouble_ptr_map[id] = boost::make_shared<SmallStrainTranverslyIsotropicADouble>();
666 tranversly_isotropic_double_ptr_map[id] = boost::make_shared<SmallStrainTranverslyIsotropicDouble>();
668 tranversly_isotropic_adouble_ptr_map.at(
id)->E_p = mydata.
data.Youngp;
669 tranversly_isotropic_double_ptr_map.at(
id)->E_p = mydata.
data.Youngp;
670 tranversly_isotropic_adouble_ptr_map.at(
id)->E_z = mydata.
data.Youngz;
671 tranversly_isotropic_double_ptr_map.at(
id)->E_z = mydata.
data.Youngz;
672 tranversly_isotropic_adouble_ptr_map.at(
id)->nu_p = mydata.
data.Poissonp;
673 tranversly_isotropic_double_ptr_map.at(
id)->nu_p = mydata.
data.Poissonp;
674 tranversly_isotropic_adouble_ptr_map.at(
id)->nu_pz = mydata.
data.Poissonpz;
675 tranversly_isotropic_double_ptr_map.at(
id)->nu_pz = mydata.
data.Poissonpz;
677 if(mydata.
data.Shearzp!=0) {
678 shear_zp = mydata.
data.Shearzp;
680 shear_zp = mydata.
data.Youngz/(2*(1+mydata.
data.Poissonpz));
682 tranversly_isotropic_adouble_ptr_map.at(it->getMeshsetId())->G_zp = shear_zp;
683 tranversly_isotropic_double_ptr_map.at(it->getMeshsetId())->G_zp = shear_zp;
687 meshset,MBTET,trans_elastic.setOfBlocks[
id].tEts,
true
692 trans_elastic.setOfBlocks[id].tEts = intersect(trans_elastic.setOfBlocks[
id].tEts,LatestRefinedTets);
696 trans_elastic.setOfBlocks[id].iD = id;
698 trans_elastic.setOfBlocks[id].E = 0;
699 trans_elastic.setOfBlocks[id].PoissonRatio = 0;
700 trans_elastic.setOfBlocks[id].materialDoublePtr = tranversly_isotropic_double_ptr_map.at(
id);
701 trans_elastic.setOfBlocks[id].materialAdoublePtr = tranversly_isotropic_adouble_ptr_map.at(
id);
702 ierr = m_field.seed_finite_elements(trans_elastic.setOfBlocks[
id].tEts); CHKERRQ(
ierr);
718 map<int,NonlinearElasticElement::BlockData>::iterator sit = trans_elastic.setOfBlocks.begin();
719 sit!=trans_elastic.setOfBlocks.end();sit++
723 cout<<
" sit->second.tEts "<<sit->second.tEts.size()<<endl;
734 map<int,NonlinearElasticElement::BlockData>::iterator sit = trans_elastic.setOfBlocks.begin();
735 for(;sit!=trans_elastic.setOfBlocks.end();sit++) {
746 sit = trans_elastic.setOfBlocks.begin();
747 for(;sit!=trans_elastic.setOfBlocks.end();sit++) {
766 boost::ptr_vector<CohesiveInterfaceElement::PhysicalEquation> interface_materials;
772 double interface_beta, interface_ft, interface_Gf, interface_h;
780 cout << endl << *it << endl;
782 string name = it->getName();
783 if (name.compare(0,10,
"MAT_INTERF") == 0) {
785 ierr = it->getAttributeDataStructure(mydata); CHKERRQ(
ierr);
789 interface_materials.back().youngModulus = mydata.
data.alpha;
794 interface_materials.back().h = interface_h;
795 interface_materials.back().beta = interface_beta;
796 interface_materials.back().ft = interface_ft;
797 interface_materials.back().Gf = interface_Gf;
805 interface_materials.back().pRisms = ents3d.subset_by_type(MBPRISM);
810 ierr = m_field.seed_finite_elements(interface_materials.back().pRisms); CHKERRQ(
ierr);
817 boost::ptr_vector<CohesiveInterfaceElement::PhysicalEquation>::iterator pit = interface_materials.begin();
818 for(; pit != interface_materials.end();pit++) {
824 ierr = cohesive_elements.addOps(
"DISPLACEMENT",interface_materials); CHKERRQ(
ierr);
831 lagrangian_element_periodic.addLagrangiangElement(
"LAGRANGE_ELEM",
"DISPLACEMENT",
"LAGRANGE_MUL_PERIODIC",
"MESH_NODE_POSITIONS",preriodic_prisms);
852 if(it->getName().compare(0,12,
"AllBoundSurf") == 0 || it->getMeshsetId() == 103) {
856 ierr = PetscPrintf(PETSC_COMM_WORLD,
"Old triangles on SideSet 103 = %d\n",Tri103.size()); CHKERRQ(
ierr);
858 Tri103 = intersect(AllTris, Tri103);
859 ierr = PetscPrintf(PETSC_COMM_WORLD,
"New triangles on SideSet 103 = %d\n",Tri103.size()); CHKERRQ(
ierr);
870 DMType dm_name =
"PLASTIC_PROB";
874 ierr = DMCreate(PETSC_COMM_WORLD,&dm);CHKERRQ(
ierr);
875 ierr = DMSetType(dm,dm_name);CHKERRQ(
ierr);
879 ierr = DMSetFromOptions(dm); CHKERRQ(
ierr);
897 ierr = VecGhostUpdateBegin(
D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
898 ierr = VecGhostUpdateEnd(
D,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
900 ierr = MatZeroEntries(Aij); CHKERRQ(
ierr);
903 for(
int ii = 0;ii<6;ii++) {
904 ierr = VecDuplicate(
D,&Fvec[ii]); CHKERRQ(
ierr);
905 ierr = VecZeroEntries(Fvec[ii]); CHKERRQ(
ierr);
906 ierr = VecGhostUpdateBegin(Fvec[ii],INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
907 ierr = VecGhostUpdateEnd(Fvec[ii],INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
911 SmallStrainPlasticity small_strain_plasticity(m_field);
913 PetscBool bbar = PETSC_TRUE;
915 small_strain_plasticity.commonData.bBar = bbar;
918 small_strain_plasticity.feRhs.getOpPtrVector().push_back(
919 new SmallStrainPlasticity::OpGetCommonDataAtGaussPts(
920 "DISPLACEMENT",small_strain_plasticity.commonData
923 small_strain_plasticity.feRhs.getOpPtrVector().push_back(
924 new SmallStrainPlasticity::OpCalculateStress(
925 m_field,
"DISPLACEMENT",small_strain_plasticity.commonData,cp,
false
928 small_strain_plasticity.feRhs.getOpPtrVector().push_back(
929 new SmallStrainPlasticity::OpAssembleRhs(
930 "DISPLACEMENT",small_strain_plasticity.commonData
933 small_strain_plasticity.feLhs.getOpPtrVector().push_back(
934 new SmallStrainPlasticity::OpGetCommonDataAtGaussPts(
935 "DISPLACEMENT",small_strain_plasticity.commonData
938 small_strain_plasticity.feLhs.getOpPtrVector().push_back(
939 new SmallStrainPlasticity::OpCalculateStress(
940 m_field,
"DISPLACEMENT",small_strain_plasticity.commonData,cp,
false
943 small_strain_plasticity.feLhs.getOpPtrVector().push_back(
944 new SmallStrainPlasticity::OpAssembleLhs(
945 "DISPLACEMENT",small_strain_plasticity.commonData
948 small_strain_plasticity.feUpdate.getOpPtrVector().push_back(
949 new SmallStrainPlasticity::OpGetCommonDataAtGaussPts(
950 "DISPLACEMENT",small_strain_plasticity.commonData
953 small_strain_plasticity.feUpdate.getOpPtrVector().push_back(
954 new SmallStrainPlasticity::OpCalculateStress(
955 m_field,
"DISPLACEMENT",small_strain_plasticity.commonData,cp,
false
958 small_strain_plasticity.feUpdate.getOpPtrVector().push_back(
959 new SmallStrainPlasticity::OpUpdate(
960 "DISPLACEMENT",small_strain_plasticity.commonData
963 ierr = small_strain_plasticity.createInternalVariablesTag(); CHKERRQ(
ierr);
968 lagrangian_element_periodic.setRVEBCsOperatorsNonlinear(
"DISPLACEMENT",
"LAGRANGE_MUL_PERIODIC",
"MESH_NODE_POSITIONS",Aij,Fvec,
F,given_strain);
970 lagrangian_element_rigid_body_trans.setRVEBCsRigidBodyTranOperators(
"DISPLACEMENT",
"LAGRANGE_MUL_RIGID_TRANS",Aij, lagrangian_element_periodic.setOfRVEBC);
974 lagrangian_element_periodic.methodsOp.push_back(
new TimeForceScale(
"-my_macro_strian_history",
false));
994 SNES snes_one_step_only;
997 ierr = SNESCreate(PETSC_COMM_WORLD,&snes); CHKERRQ(
ierr);
1002 ierr = SNESSetFromOptions(snes); CHKERRQ(
ierr);
1004 ierr = SNESCreate(PETSC_COMM_WORLD,&snes_one_step_only); CHKERRQ(
ierr);
1005 ierr = SNESSetFunction(snes_one_step_only,
F,
SnesRhs,snes_ctx); CHKERRQ(
ierr);
1006 ierr = SNESSetJacobian(snes_one_step_only,Aij,Aij,
SnesMat,snes_ctx); CHKERRQ(
ierr);
1007 ierr = SNESSetFromOptions(snes_one_step_only); CHKERRQ(
ierr);
1008 double atol,rtol,stol;
1010 SNESGetTolerances(snes_one_step_only,&atol,&rtol,&stol,&maxit,&maxf);
1013 SNESSetTolerances(snes_one_step_only,atol,rtol,stol,maxit,maxf);
1014 SNESLineSearch linesearch;
1015 SNESGetLineSearch(snes_one_step_only,&linesearch);
1016 SNESLineSearchSetType(linesearch,SNESLINESEARCHBASIC);
1021 ierr = post_proc.generateReferenceElementMesh(); CHKERRQ(
ierr);
1022 ierr = post_proc.addFieldValuesPostProc(
"DISPLACEMENT"); CHKERRQ(
ierr);
1023 ierr = post_proc.addFieldValuesGradientPostProc(
"DISPLACEMENT"); CHKERRQ(
ierr);
1024 ierr = post_proc.addFieldValuesPostProc(
"MESH_NODE_POSITIONS"); CHKERRQ(
ierr);
1030 int volume_vec_ghost[] = { 0 };
1031 ierr = VecCreateGhost(
1032 PETSC_COMM_WORLD,(!m_field.
get_comm_rank())?1:0,1,1,volume_vec_ghost,&volume_vec
1034 ierr = VecZeroEntries(volume_vec); CHKERRQ(
ierr);
1035 vol_elem.getOpPtrVector().push_back(
new VolumeCalculation(
"DISPLACEMENT",volume_vec));
1040 ierr = VecAssemblyBegin(volume_vec); CHKERRQ(
ierr);
1041 ierr = VecAssemblyEnd(volume_vec); CHKERRQ(
ierr);
1043 ierr = VecSum(volume_vec,&rve_volume); CHKERRQ(
ierr);
1046 ierr = PetscPrintf(PETSC_COMM_WORLD,
"RVE Volume %3.2g\n",rve_volume); CHKERRQ(
ierr);
1047 ierr = VecDestroy(&volume_vec);
1050 double final_time = 1,delta_time = 0.1;
1053 double delta_time0 = delta_time;
1060 ierr = VecDuplicate(
D,&D0); CHKERRQ(
ierr);
1064 SNESConvergedReason reason = SNES_CONVERGED_ITERATING;
1065 for(;
t<final_time;step++) {
1072 PETSC_COMM_WORLD,
"Step %d Time %6.4g final time %3.2g\n",step,
t,final_time
1075 lagrangian_element_periodic.getLoopFeRVEBCRhs().ts_t =
t;
1077 ierr = VecAssemblyBegin(
D);
1078 ierr = VecAssemblyEnd(
D);
1080 if(step == 0 || reason < 0) {
1081 ierr = SNESSetLagJacobian(snes,-2); CHKERRQ(
ierr);
1083 ierr = SNESSetLagJacobian(snes,-1); CHKERRQ(
ierr);
1085 ierr = SNESSetLagJacobian(snes_one_step_only,-2);
1086 ierr = SNESSolve(snes_one_step_only,PETSC_NULL,
D); CHKERRQ(
ierr);
1087 ierr = SNESGetConvergedReason(snes_one_step_only,&reason); CHKERRQ(
ierr);
1089 ierr = SNESSolve(snes,PETSC_NULL,
D); CHKERRQ(
ierr);
1092 ierr = SNESGetIterationNumber(snes,&its); CHKERRQ(
ierr);
1095 PETSC_COMM_WORLD,
"number of Newton iterations = %D\n",its
1098 ierr = SNESGetConvergedReason(snes,&reason); CHKERRQ(
ierr);
1104 }
else {
const int its_d = 60;
1105 const double gamma = 0.5;
1106 const double max_reudction = 1;
1107 const double min_reduction = 1e-1;
1109 reduction = pow((
double)its_d/(
double)(its+1),gamma);
1110 if(delta_time >= max_reudction*delta_time0 && reduction > 1) {
1112 }
else if(delta_time <= min_reduction*delta_time0 && reduction < 1) {
1118 "reduction delta_time = %6.4e delta_time = %6.4e\n",
1119 reduction,delta_time
1121 delta_time *= reduction;
1122 if(reduction>1 && delta_time < min_reduction*delta_time0) {
1123 delta_time = min_reduction*delta_time0;
1127 dm,
D,INSERT_VALUES,SCATTER_REVERSE
1131 dm,
"PLASTIC",&small_strain_plasticity.feUpdate
1136 dm,
"INTERFACE",&cohesive_elements.feHistory
1142 dm,
"PLASTIC",&post_proc
1147 std::ostringstream stm;
1148 stm <<
"out_matrix_" << step <<
".h5m";
1156 rval = post_proc.postProcMesh.write_file(
1163 dm,
"TRAN_ISOTROPIC_ELASTIC",&post_proc
1166 std::ostringstream stm;
1167 stm <<
"out_fibres_" << step <<
".h5m";
1174 rval = post_proc.postProcMesh.write_file(
1182 StressHomo.resize(6);
1188 int stress_homo_ghost[] = { 0,1,2,3,4,5,6 };
1189 ierr = VecCreateGhost(
1190 PETSC_COMM_WORLD,(!m_field.
get_comm_rank())?6:0,6,6,stress_homo_ghost,&stress_homo
1193 lagrangian_element_periodic.setRVEBCsHomoStressOperators(
"DISPLACEMENT",
"LAGRANGE_MUL_PERIODIC",
"MESH_NODE_POSITIONS",stress_homo);
1197 ierr = VecGetArray(stress_homo,&avec); CHKERRQ(
ierr);
1198 ierr = VecZeroEntries(stress_homo); CHKERRQ(
ierr);
1200 "PLASTIC_PROB",
"LAGRANGE_ELEM",lagrangian_element_periodic.getLoopFeRVEBCStress()
1203 PETSC_NULL,
"-my_rve_volume",&rve_volume,PETSC_NULL
1205 ierr = VecAssemblyBegin(stress_homo); CHKERRQ(
ierr);
1206 ierr = VecAssemblyEnd(stress_homo); CHKERRQ(
ierr);
1207 ierr = VecScale(stress_homo,1.0/rve_volume); CHKERRQ(
ierr);
1208 ierr = VecGhostUpdateBegin(stress_homo,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
1209 ierr = VecGhostUpdateEnd(stress_homo,INSERT_VALUES,SCATTER_FORWARD); CHKERRQ(
ierr);
1211 for(
int jj=0; jj<6; jj++) {
1212 StressHomo(jj) = avec[jj];
1218 PetscPrintf(PETSC_COMM_WORLD,
1219 "Macro_Strain Homo_Stress Path "
1223 for(
int ii=0; ii<6; ii++) {
1232 for(
int ii=0; ii<6; ii++) {
1240 PetscPrintf(PETSC_COMM_WORLD,
1247 ierr = VecDestroy(&D0); CHKERRQ(
ierr);
1248 ierr = MatDestroy(&Aij); CHKERRQ(
ierr);