Skip to content
Snippets Groups Projects
Commit b98f9978 authored by Ludovic Noels's avatar Ludovic Noels
Browse files

Revert "start perturbation with mpi"

This reverts commit 02362e62
parent 3435433d
Branches
No related tags found
1 merge request!364Revert "start perturbation with mpi"
...@@ -2111,254 +2111,11 @@ void dG3DDomain::computeStrain(MElement *e, const int npts_bulk, IntPt *GP, ...@@ -2111,254 +2111,11 @@ void dG3DDomain::computeStrain(MElement *e, const int npts_bulk, IntPt *GP,
} }
} }
} }
void dG3DDomain::prepareMPIExchange(AllIPState *aips, IPStateBase::whichState ws)
{
MPI_Status status;
if (Msg::GetCommRank() == _rootRank){
// compute all IP strain on root rank
// this->computeAllIPStrain(aips,ufield,ws,false);
// send strain to other procs
// for bulk elements
for (std::set<int>::iterator it = _otherRanks.begin(); it!= _otherRanks.end(); it++){
int otherRank = *it;
std::set<int>& IPBulkonRank = _mapIPBulk[otherRank];
for (std::set<int>::iterator its = IPBulkonRank.begin(); its!= IPBulkonRank.end(); its++){
int num = *its;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(elnum);
IPStateBase* ips = (*vips)[gnum];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMacroNumberElementDataSendToMicroProblem(); // already known
double *buffer = new double[bufferSize];
ipv->getMacroDataSendToMicroProblem(buffer);
MPI_Send(buffer,bufferSize,MPI_DOUBLE,otherRank,num,MPI_COMM_WORLD);
delete[] buffer;
};
std::set<int>& IPInterfaceMinusonRank = _mapIPInterfaceMinus[otherRank];
for (std::set<int>::iterator its = IPInterfaceMinusonRank.begin(); its!= IPInterfaceMinusonRank.end(); its++){
int num = *its;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(elnum);
IPStateBase* ips = (*vips)[gnum];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMacroNumberElementDataSendToMicroProblem(); // already known
double *buffer = new double[bufferSize];
ipv->getMacroDataSendToMicroProblem(buffer);
MPI_Send(buffer,bufferSize,MPI_DOUBLE,otherRank,num,MPI_COMM_WORLD);
delete[] buffer;
};
std::set<int>& IPInterfacePlusonRank = _mapIPInterfacePlus[otherRank];
for (std::set<int>::iterator its = IPInterfacePlusonRank.begin(); its!= IPInterfacePlusonRank.end(); its++){
int num = *its;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(elnum);
IPStateBase* ips = (*vips)[gnum];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMacroNumberElementDataSendToMicroProblem(); // already known
double *buffer = new double[bufferSize];
ipv->getMacroDataSendToMicroProblem(buffer);
MPI_Send(buffer,bufferSize,MPI_DOUBLE,otherRank,num,MPI_COMM_WORLD);
delete[] buffer;
};
}
}
else if (_otherRanks.find(Msg::GetCommRank()) != _otherRanks.end()){
for (std::set<int>::iterator it = _domainIPBulk.begin(); it != _domainIPBulk.end(); it++){
int num = *it;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(num);
IPStateBase* ips = (*vips)[0];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMacroNumberElementDataSendToMicroProblem();
double *buffer = new double[bufferSize];
MPI_Recv(buffer,bufferSize,MPI_DOUBLE,_rootRank,num,MPI_COMM_WORLD,&status);
ipv->setReceivedMacroDataToMicroProblem(buffer);
delete [] buffer;
};
for (std::set<int>::iterator it = _domainIPInterfaceMinus.begin(); it != _domainIPInterfaceMinus.end(); it++){
int num = *it;
int elnum, phys, gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(num);
IPStateBase* ips = (*vips)[0];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMacroNumberElementDataSendToMicroProblem();
double *buffer = new double[bufferSize];
MPI_Recv(buffer,bufferSize,MPI_DOUBLE,_rootRank,num,MPI_COMM_WORLD,&status);
ipv->setReceivedMacroDataToMicroProblem(buffer);
delete [] buffer;
};
for (std::set<int>::iterator it = _domainIPInterfacePlus.begin(); it != _domainIPInterfacePlus.end(); it++){
int num = *it;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(num);
IPStateBase* ips = (*vips)[0];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMacroNumberElementDataSendToMicroProblem();
double *buffer = new double[bufferSize];
MPI_Recv(buffer,bufferSize,MPI_DOUBLE,_rootRank,num,MPI_COMM_WORLD,&status);
ipv->setReceivedMacroDataToMicroProblem(buffer);
delete [] buffer;
};
};
}
void dG3DDomain::endMPIExchange(AllIPState *aips, IPStateBase::whichState ws)
{
MPI_Status status;
IntPt *GP;
if (_otherRanks.find(Msg::GetCommRank()) != _otherRanks.end()){
for (std::set<int>::iterator it = _domainIPBulk.begin(); it != _domainIPBulk.end(); it++){
int num = *it;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(num);
IPStateBase* ips = (*vips)[0];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMicroNumberElementDataSendToMacroProblem();
double *buffer = new double[bufferSize];
ipv->getMicroDataToMacroProblem(buffer);
MPI_Send(buffer,bufferSize,MPI_DOUBLE,_rootRank,num,MPI_COMM_WORLD);
delete [] buffer;
};
for (std::set<int>::iterator it = _domainIPInterfaceMinus.begin(); it != _domainIPInterfaceMinus.end(); it++){
int num = *it;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(num);
IPStateBase* ips = (*vips)[0];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMicroNumberElementDataSendToMacroProblem();
double *buffer = new double[bufferSize];
ipv->getMicroDataToMacroProblem(buffer);
MPI_Send(buffer,bufferSize,MPI_DOUBLE,_rootRank,num,MPI_COMM_WORLD);
delete [] buffer;
};
for (std::set<int>::iterator it = _domainIPInterfacePlus.begin(); it != _domainIPInterfacePlus.end(); it++){
int num = *it;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(num);
IPStateBase* ips = (*vips)[0];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMicroNumberElementDataSendToMacroProblem();
double *buffer = new double[bufferSize];
ipv->getMicroDataToMacroProblem(buffer);
MPI_Send(buffer,bufferSize,MPI_DOUBLE,_rootRank,num,MPI_COMM_WORLD);
delete [] buffer;
};
}
else if (Msg::GetCommRank() == _rootRank){
for (std::set<int>::iterator it = _otherRanks.begin(); it!= _otherRanks.end(); it++){
int otherRank = *it;
std::set<int>& IPBulkonRank = _mapIPBulk[otherRank];
for (std::set<int>::iterator its = IPBulkonRank.begin(); its!= IPBulkonRank.end(); its++){
int num = *its;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(elnum);
IPStateBase* ips = (*vips)[gnum];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMicroNumberElementDataSendToMacroProblem();
double *buffer = new double[bufferSize];
MPI_Recv(buffer,bufferSize,MPI_DOUBLE,otherRank,num,MPI_COMM_WORLD,&status);
ipv->setReceivedMicroDataToMacroProblem(buffer);
dG3DMaterialLaw* mlaw = dynamic_cast<dG3DMaterialLaw*>(this->getMaterialLaw());
mlaw->setElasticStiffness(ipv);
delete[] buffer;
};
std::set<int>& IPInterfaceMinusonRank = _mapIPInterfaceMinus[otherRank];
for (std::set<int>::iterator its = IPInterfaceMinusonRank.begin(); its!= IPInterfaceMinusonRank.end(); its++){
int num = *its;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(elnum);
IPStateBase* ips = (*vips)[gnum];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMicroNumberElementDataSendToMacroProblem();
double *buffer = new double[bufferSize];
MPI_Recv(buffer,bufferSize,MPI_DOUBLE,otherRank,num,MPI_COMM_WORLD,&status);
ipv->setReceivedMicroDataToMacroProblem(buffer);
dG3DMaterialLaw* mlawMinus = dynamic_cast<dG3DMaterialLaw*>(this->getMaterialLawMinus());
mlawMinus->setElasticStiffness(ipv);
delete[] buffer;
};
std::set<int>& IPInterfacePlusonRank = _mapIPInterfacePlus[otherRank];
for (std::set<int>::iterator its = IPInterfacePlusonRank.begin(); its!= IPInterfacePlusonRank.end(); its++){
int num = *its;
int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(elnum);
IPStateBase* ips = (*vips)[gnum];
IPVariable* ipv = ips->getState(ws);
int bufferSize = ipv->getMicroNumberElementDataSendToMacroProblem();
double *buffer = new double[bufferSize];
MPI_Recv(buffer,bufferSize,MPI_DOUBLE,otherRank,num,MPI_COMM_WORLD,&status);
ipv->setReceivedMicroDataToMacroProblem(buffer);
dG3DMaterialLaw* mlawPlus = dynamic_cast<dG3DMaterialLaw*>(this->getMaterialLawPlus());
mlawPlus->setElasticStiffness(ipv);
delete[] buffer;
};
}
if (_averageStrainBased and (this->getMaterialLawMinus()->getNum() == this->getMaterialLawPlus()->getNum())){
for (elementGroup::elementContainer::const_iterator ite = gi->begin(); ite!= gi->end(); ite++){
MElement* ele = ite->second;
int npts = this->getInterfaceGaussIntegrationRule()->getIntPoints(ele,&GP);
AllIPState::ipstateElementContainer *vips = aips->getIPstate(ele->getNum());
for(int j=0;j<npts;j++){
IPStateBase* ipsm = (*vips)[j];
IPStateBase* ipsp = (*vips)[j+npts];
IPVariable* ipvm = ipsm->getState(IPStateBase::current);
IPVariable* ipvp = ipsp->getState(IPStateBase::current);
ipvp->operator=(*ipvm);
}
}
}
}
}
void dG3DDomain::computeIpvMPI(AllIPState *aips,MElement *e, IPStateBase::whichState ws,
materialLaw *mlaw__,fullVector<double> &disp, bool stiff)
{
prepareMPIExchange(aips,IPStateBase::current);
computeIpv(aips, e, ws, mlaw__, disp, stiff);
endMPIExchange(aips,IPStateBase::current);
}
void dG3DDomain::computeIpv(AllIPState *aips,MElement *e, IPStateBase::whichState ws, void dG3DDomain::computeIpv(AllIPState *aips,MElement *e, IPStateBase::whichState ws,
materialLaw *mlaw__,fullVector<double> &disp, bool stiff) materialLaw *mlaw__,fullVector<double> &disp, bool stiff)
{ {
if (!getElementErosionFilter()(e)) return; if (!getElementErosionFilter()(e)) return;
//#if defined(HAVE_MPI)
//if (mlaw__->isNumeric() and this->_otherRanks.size()>0 and stiff==false)
//{
// this->computeIpvMPI(aips,e,ws,mlaw__,disp,stiff);
//}
//else
//#endif //HAVE_MPI
{
dG3DMaterialLaw *mlaw; dG3DMaterialLaw *mlaw;
AllIPState::ipstateElementContainer *vips = aips->getIPstate(e->getNum()); AllIPState::ipstateElementContainer *vips = aips->getIPstate(e->getNum());
IntPt *GP; IntPt *GP;
...@@ -2472,7 +2229,6 @@ void dG3DDomain::computeIpv(AllIPState *aips,MElement *e, IPStateBase::whichStat ...@@ -2472,7 +2229,6 @@ void dG3DDomain::computeIpv(AllIPState *aips,MElement *e, IPStateBase::whichStat
} }
} }
} }
}
void dG3DDomain::setValuesForBodyForce(AllIPState *aips, const IPStateBase::whichState ws){ void dG3DDomain::setValuesForBodyForce(AllIPState *aips, const IPStateBase::whichState ws){
IntPt *GP; IntPt *GP;
...@@ -5186,18 +4942,11 @@ MElement* dG3DDomain::createInterface(IElement *ie1, IElement *ie2) const ...@@ -5186,18 +4942,11 @@ MElement* dG3DDomain::createInterface(IElement *ie1, IElement *ie2) const
#if defined(HAVE_MPI) #if defined(HAVE_MPI)
void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufield,const IPStateBase::whichState ws, bool stiff){ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufield,const IPStateBase::whichState ws, bool stiff){
IntPt *GP;
//IntPt *GP;
MPI_Status status; MPI_Status status;
if (Msg::GetCommRank() == _rootRank){ if (Msg::GetCommRank() == _rootRank){
// compute all IP strain on root rank // compute all IP strain on root rank
this->computeAllIPStrain(aips,ufield,ws,false); this->computeAllIPStrain(aips,ufield,ws,false);
}
this->prepareMPIExchange(aips, ws);
/*if (Msg::GetCommRank() == _rootRank){
// send strain to other procs // send strain to other procs
// for bulk elements // for bulk elements
for (std::set<int>::iterator it = _otherRanks.begin(); it!= _otherRanks.end(); it++){ for (std::set<int>::iterator it = _otherRanks.begin(); it!= _otherRanks.end(); it++){
...@@ -5290,7 +5039,7 @@ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufiel ...@@ -5290,7 +5039,7 @@ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufiel
ipv->setReceivedMacroDataToMicroProblem(buffer); ipv->setReceivedMacroDataToMicroProblem(buffer);
delete [] buffer; delete [] buffer;
}; };
};*/ };
bool needDTangent=false; bool needDTangent=false;
bool usePreviousModuli = false; bool usePreviousModuli = false;
...@@ -5346,8 +5095,8 @@ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufiel ...@@ -5346,8 +5095,8 @@ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufiel
mlawMinus->stress(ipv,ipvprev,stiff,true,needDTangent); mlawMinus->stress(ipv,ipvprev,stiff,true,needDTangent);
}; };
this->endMPIExchange(aips, ws);
/*for (std::set<int>::iterator it = _domainIPInterfacePlus.begin(); it != _domainIPInterfacePlus.end(); it++){ for (std::set<int>::iterator it = _domainIPInterfacePlus.begin(); it != _domainIPInterfacePlus.end(); it++){
int num = *it; int num = *it;
int elnum,gnum; int elnum,gnum;
numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum); numericalMaterialBase::getTwoIntsFromType(num,elnum,gnum);
...@@ -5483,7 +5232,7 @@ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufiel ...@@ -5483,7 +5232,7 @@ void dG3DDomain::computeIPVariableMPI(AllIPState *aips,const unknownField *ufiel
} }
} }
};*/ };
}; };
#endif #endif
......
...@@ -257,9 +257,6 @@ class dG3DDomain : public dgPartDomain{ ...@@ -257,9 +257,6 @@ class dG3DDomain : public dgPartDomain{
virtual double getNonLocalStabilityParameter() const { return _nonLocalBeta;} virtual double getNonLocalStabilityParameter() const { return _nonLocalBeta;}
virtual bool getNonLocalContinuity() const { return _nonLocalContinuity;} virtual bool getNonLocalContinuity() const { return _nonLocalContinuity;}
virtual double getNonLocalEqRatio() const { return _nonLocalEqRatio;} virtual double getNonLocalEqRatio() const { return _nonLocalEqRatio;}
virtual void computeIpvMPI(AllIPState *aips,MElement *e, IPStateBase::whichState ws,
materialLaw *mlaw__,fullVector<double> &disp, bool stiff);
// //
virtual bool getConstitutiveExtraDofDiffusionUseEnergyConjugatedField() const { return _constitutiveExtraDofDiffusionUseEnergyConjugatedField;} virtual bool getConstitutiveExtraDofDiffusionUseEnergyConjugatedField() const { return _constitutiveExtraDofDiffusionUseEnergyConjugatedField;}
...@@ -280,9 +277,6 @@ class dG3DDomain : public dgPartDomain{ ...@@ -280,9 +277,6 @@ class dG3DDomain : public dgPartDomain{
} }
}; };
virtual void prepareMPIExchange(AllIPState *aips, IPStateBase::whichState ws);
virtual void endMPIExchange(AllIPState *aips, IPStateBase::whichState ws);
#endif #endif
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment