From 9d413e44f5614636988941b49e832ae4a3fa45d0 Mon Sep 17 00:00:00 2001 From: Van Dung Nguyen <vdg.nguyen@gmail.com> Date: Tue, 7 Nov 2017 16:24:35 +0100 Subject: [PATCH] bug for multiscale viscoplasticity --- NonLinearSolver/internalPoints/ipstate.cpp | 17 +++++++++++ NonLinearSolver/internalPoints/ipstate.h | 2 ++ .../materialLaw/mlawHyperelastic.cpp | 2 +- .../nlsolver/nonLinearMechSolver.cpp | 30 ++++++++----------- .../nlsolver/nonLinearMechSolver.h | 3 +- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/NonLinearSolver/internalPoints/ipstate.cpp b/NonLinearSolver/internalPoints/ipstate.cpp index f595d8ddd..579870fa5 100644 --- a/NonLinearSolver/internalPoints/ipstate.cpp +++ b/NonLinearSolver/internalPoints/ipstate.cpp @@ -495,6 +495,23 @@ void AllIPState::restart() } } +void AllIPState::setTime(const double time, const double dtime, const int numstep){ + if (isMultiscale){ + for(ipstateContainer::iterator its=_mapall.begin(); its!=_mapall.end();++its) + { + ipstateElementContainer& vips = its->second; + for(ipstateElementContainer::iterator it=vips.begin(); it!=vips.end();++it) + { + IPStateBase* ips = *it; + if (ips->getSolver() != NULL){ + ips->getSolver()->setTime(time,dtime,numstep); + } + } + } + + } +}; + void AllIPState::nextStep() { //state ? state=false : state=true; this->copy(IPStateBase::current,IPStateBase::previous); diff --git a/NonLinearSolver/internalPoints/ipstate.h b/NonLinearSolver/internalPoints/ipstate.h index 3799fd761..c4d2a038d 100644 --- a/NonLinearSolver/internalPoints/ipstate.h +++ b/NonLinearSolver/internalPoints/ipstate.h @@ -136,6 +136,8 @@ class AllIPState{ } } void restart(); + + void setTime(const double time, const double dtime, const int numstep); ipstateContainer* getAIPSContainer() {return &_mapall;}; const ipstateContainer* getAIPSContainer() const {return &_mapall;}; diff --git a/NonLinearSolver/materialLaw/mlawHyperelastic.cpp b/NonLinearSolver/materialLaw/mlawHyperelastic.cpp index 7a627061d..88b3d59b4 100644 --- a/NonLinearSolver/materialLaw/mlawHyperelastic.cpp +++ b/NonLinearSolver/materialLaw/mlawHyperelastic.cpp @@ -1714,7 +1714,7 @@ mlawPowerYieldHyper::mlawPowerYieldHyper(const int num,const double E,const doub mlawPowerYieldHyper::mlawPowerYieldHyper(const mlawPowerYieldHyper& src):mlawHyperViscoElastic(src), _tol(src._tol),_n(src._n),_nonAssociatedFlow(src._nonAssociatedFlow),_b(src._b), - _I4(src._I4), _I(src._I), _Idev(src._Idev),_p(1.){ + _I4(src._I4), _I(src._I), _Idev(src._Idev),_p(src._p){ _viscosity = NULL; if (src._viscosity) _viscosity = src._viscosity->clone(); diff --git a/NonLinearSolver/nlsolver/nonLinearMechSolver.cpp b/NonLinearSolver/nlsolver/nonLinearMechSolver.cpp index 0939ee302..712757952 100644 --- a/NonLinearSolver/nlsolver/nonLinearMechSolver.cpp +++ b/NonLinearSolver/nlsolver/nonLinearMechSolver.cpp @@ -102,7 +102,7 @@ _stressflag(true),_tangentflag(false),_enum(0),_gnum(0),_rveVolume(0.), _systemType(nonLinearMechSolver::MULT_ELIM),_controlType(nonLinearMechSolver::LOAD_CONTROL), _highOrderFlag(false), _eigenValueFile(NULL), _perturbationfactor(0.1), - _archive(true),_archivecounter(0),_stiffEstimation(true),_stiffnessModification(true), + _archive(true),_stiffEstimation(true),_stiffnessModification(true), _iterativeNR(true),_messageView(false), _outputFile(NULL), _eigenFollowing(false), _homogenizeStressMethod(nonLinearMechSolver::VOLUME), _stabilityCriterionFollowing(false), _homogenizeTangentMethod(nonLinearMechSolver::PERTURB), _isHommStrainSaveToFile(true), @@ -2021,6 +2021,8 @@ void nonLinearMechSolver::setTimeForLaw(const double t,const double dt, const in it->second->setTime(t,dt); } } + // if multiscale + _ipf->getAips()->setTime(t,dt,numstep); } void nonLinearMechSolver::fixNodalDofs(){ @@ -10283,7 +10285,7 @@ void nonLinearMechSolver::nextStep(){ } // archive data - this->archiveData(0.,0.); + this->archiveData(_macroTime,_macroStep); // next step for solver std::string name = "A"; @@ -10754,7 +10756,7 @@ double nonLinearMechSolver::solveMicroSolverSNL(){ double dendtime = double(endtime); double dtmax = dendtime/double(_numstepImpl); // time step value prescribed by user (time step can not be greater than this value) double dt = dtmax; // initial time step value - int ii = 0; // iteration counter + int ii =0.; // iteration counter double tolend = 0.000001/dendtime; // OTHERWISE LAST STEP CAN BE DONE TWICE ?? double toldtmax = 0.000001/dtmax; // IDEM (PRECISION PROBLEM) int numberTimeStepReduction=0; @@ -10969,36 +10971,28 @@ void nonLinearMechSolver::archiveData(const double curtime, const int numstep){ // Archiving if (_outputFile) fprintf(_outputFile,"Archiving on element %d, IP point %d \n",getElementSolverNumber(),getGaussPointSolverNumber()); - double time = curtime; - double step = numstep; - - if (_multiscaleFlag){ - _archivecounter++; - time += (double)_archivecounter; - step += _archivecounter; - } if (_criterionFile != NULL){ std::string name = "A"; linearSystem<double>* lsys = pAssembler->getLinearSystem(name); nonLinearSystem<double>* nonsys = dynamic_cast<nonLinearSystem<double>*>(lsys); double val = nonsys->getInstabilityCriterion(); - fprintf(_criterionFile,"%e; %e; \n",time,val); + fprintf(_criterionFile,"%e; %e; \n",curtime,val); } if (_archive){ - _energField->archive(time,step); - _ufield->archive(time,step); + _energField->archive(curtime,numstep); + _ufield->archive(curtime,numstep); if (_oneUnknownField != NULL) - _oneUnknownField->archive(time,step); - _ipf->archive(time,step); + _oneUnknownField->archive(curtime,numstep); + _ipf->archive(curtime,numstep); } - this->homogenizedDataToFile(time); + this->homogenizedDataToFile(curtime); staticDofManager<double>* sAssembler = dynamic_cast<staticDofManager<double>*>(pAssembler); if (sAssembler) - this->forceArchiving(time,step,sAssembler); + this->forceArchiving(curtime,numstep,sAssembler); }; diff --git a/NonLinearSolver/nlsolver/nonLinearMechSolver.h b/NonLinearSolver/nlsolver/nonLinearMechSolver.h index 88b62820e..5146a7967 100644 --- a/NonLinearSolver/nlsolver/nonLinearMechSolver.h +++ b/NonLinearSolver/nlsolver/nonLinearMechSolver.h @@ -757,7 +757,6 @@ class nonLinearMechSolver // for archiving bool _archive; int _iterMax; - int _archivecounter; // all homogenized filename bool _isHommProSaveToFile; // flag -->save homogenized properties to files bool _isHommStrainSaveToFile; //flag --> save homogenized strain to files @@ -925,7 +924,7 @@ class nonLinearMechSolver double microSolve(); void nextStep(); - void archiveData(const double curtime, const int iter); + void archiveData(const double curtime, const int numstep); void setMessageView(const bool view); void setPeriodicity(const double x, const double y, const double z, const std::string direction); -- GitLab