本文整理汇总了C++中Solution::GetIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Solution::GetIndex方法的具体用法?C++ Solution::GetIndex怎么用?C++ Solution::GetIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution::GetIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FlagAMRRegionBasedOnSemiNorm
bool Solution::FlagAMRRegionBasedOnSemiNorm(const vector <unsigned> &SolIndex,const double &AMRthreshold){
vector <double> GradSolMax(SolIndex.size());
vector <unsigned> SolType(SolIndex.size());
vector <unsigned> SolEndInd(SolIndex.size());
unsigned dim=_msh->GetDimension();
unsigned nel= _msh->GetNumberOfElements();
for (unsigned k=0; k<SolIndex.size(); k++) {
if(SolType[k]<3){
SolType[k] = _SolType[SolIndex[k]];
BuildGradMatrixStructure(SolType[k]);
GradSolMax[k]=0.;
for(int i=0;i<dim;i++){
if(_GradVec[SolIndex[k]][i]==0){
_GradVec[SolIndex[k]][i] = NumericVector::build().release();
if(n_processors()==1) { // IF SERIAL
_GradVec[SolIndex[k]][i]->init(_msh->MetisOffset[3][n_processors()],_msh->own_size[3][processor_id()],false,SERIAL);
}
else { //discontinuous pressure has no ghost nodes
_GradVec[SolIndex[k]][i]->init(_msh->MetisOffset[3][n_processors()],_msh->own_size[3][processor_id()],false,PARALLEL);
}
}
_GradVec[SolIndex[k]][i]->matrix_mult(*_Sol[SolIndex[k]],*_GradMat[SolType[k]][i]);
double GradSolMaxi=_GradVec[SolIndex[k]][i]->linfty_norm();
GradSolMax[k] =GradSolMaxi*GradSolMaxi;
_GradVec[SolIndex[k]][i]->close();
_GradVec[SolIndex[k]][i]->matrix_mult(*_Eps[SolIndex[k]],*_GradMat[SolType[k]][i]);
}
GradSolMax[k]=AMRthreshold*(GradSolMax[k]);
}
}
Solution* AMR = _msh->_coordinate;
unsigned AMRIndex= AMR->GetIndex("AMR");
AMR->_Sol[AMRIndex]->zero();
NumericVector *counter_vec;
counter_vec = NumericVector::build().release();
if(_nprocs==1) {
counter_vec->init(_nprocs,1,false,SERIAL);
}
else {
counter_vec->init(_nprocs,1,false,PARALLEL);
}
counter_vec->zero();
for (int iel_metis=_msh->IS_Mts2Gmt_elem_offset[_iproc]; iel_metis < _msh->IS_Mts2Gmt_elem_offset[_iproc+1]; iel_metis++) {
for (unsigned k=0; k<SolIndex.size(); k++) {
if(SolType[k]<3){
double value=0.;
for(int i=0;i<dim;i++){
double valuei = (*_GradVec[SolIndex[k]][i])(iel_metis);
value+=valuei*valuei;
}
value=sqrt(value);
if(fabs(value)>GradSolMax[k]){
counter_vec->add(_iproc,1.);
AMR->_Sol[AMRIndex]->set(iel_metis,1.);
k=SolIndex.size();
}
}
}
}
AMR->_Sol[AMRIndex]->close();
counter_vec->close();
double counter=counter_vec->l1_norm();
bool test=(counter<=_nprocs)?1:0;
return test;
}
示例2: SolMax
bool Solution::FlagAMRRegionBasedOnl2(const vector <unsigned> &SolIndex,const double &AMRthreshold){
vector <double> SolMax(SolIndex.size());
vector <unsigned> SolType(SolIndex.size());
vector <unsigned> SolEndInd(SolIndex.size());
unsigned END_IND[5]= {0,1,1,4,5};
for (unsigned k=0; k<SolIndex.size(); k++) {
double EPSMAX = _AMREps[SolIndex[k]]->linfty_norm ();
double SOLMAX = _Sol[SolIndex[k]]->linfty_norm ();
cout << "Current maximum relative change = " <<EPSMAX/SOLMAX << endl << endl;
SolMax[k] = AMRthreshold * SOLMAX;
SolType[k] = _SolType[SolIndex[k]];
SolEndInd[k] = END_IND[SolType[k]];
}
Solution* AMR = _msh->_coordinate;
unsigned AMRIndex= AMR->GetIndex("AMR");
AMR->_Sol[AMRIndex]->zero();
unsigned nel= _msh->GetNumberOfElements();
NumericVector *counter_vec;
counter_vec = NumericVector::build().release();
if(_nprocs==1) {
counter_vec->init(_nprocs,1,false,SERIAL);
}
else {
counter_vec->init(_nprocs,1,false,PARALLEL);
}
counter_vec->zero();
for (int iel_metis=_msh->IS_Mts2Gmt_elem_offset[_iproc]; iel_metis < _msh->IS_Mts2Gmt_elem_offset[_iproc+1]; iel_metis++) {
unsigned kel = _msh->IS_Mts2Gmt_elem[iel_metis];
short unsigned kelt=_msh->el->GetElementType(kel);
for (unsigned k=0; k<SolIndex.size(); k++) {
if(SolType[k]<3){
unsigned nve=_msh->el->GetElementDofNumber(kel,SolEndInd[k]);
for(unsigned i=0; i<nve; i++) {
unsigned inode=(SolType[k]<3)?(_msh->el->GetElementVertexIndex(kel,i)-1u):(kel+i*nel);
unsigned inode_metis=_msh->GetMetisDof(inode,SolType[k]);
double value = (*_AMREps[SolIndex[k]])(inode_metis);
if(fabs(value)>SolMax[k]){
counter_vec->add(_iproc,1.);
AMR->_Sol[AMRIndex]->set(iel_metis,1.);
k=SolIndex.size();
i=nve;
}
}
}
}
}
AMR->_Sol[AMRIndex]->close();
counter_vec->close();
double counter=counter_vec->l1_norm();
bool test=(counter<=_nprocs)?1:0;
delete counter_vec;
return test;
}