Commit 963101f2 authored by David Moxey's avatar David Moxey

Clean up iterators up to FieldUtils

parent ffb66bd6
......@@ -48,8 +48,6 @@ Collection::Collection(
vector<StdRegions::StdExpansionSharedPtr> pCollExp,
OperatorImpMap &impTypes)
{
OperatorImpMap::iterator it;
// Initialise geometry data.
m_geomData = MemoryManager<CoalescedGeomData>::AllocateSharedPtr();
......@@ -59,7 +57,8 @@ Collection::Collection(
OperatorType opType = (OperatorType)i;
ImplementationType impType;
if ((it = impTypes.find(opType)) != impTypes.end())
auto it = impTypes.find(opType);
if (it != impTypes.end())
{
impType = it->second;
OperatorKey opKey(pCollExp[0]->DetShapeType(), opType, impType,
......
......@@ -51,9 +51,7 @@ CollectionOptimisation::CollectionOptimisation(
ImplementationType defaultType)
{
int i;
map<ElmtOrder, ImplementationType> defaults;
map<ElmtOrder, ImplementationType> defaultsPhysDeriv;
map<ElmtOrder, ImplementationType>::iterator it;
map<ElmtOrder, ImplementationType> defaults, defaultsPhysDeriv;
bool verbose = (pSession.get()) &&
(pSession->DefinesCmdLineArgument("verbose")) &&
(pSession->GetComm()->GetRank() == 0);
......@@ -64,7 +62,6 @@ CollectionOptimisation::CollectionOptimisation(
m_defaultType = defaultType == eNoImpType ? eIterPerExp : defaultType;
map<string, LibUtilities::ShapeType> elTypes;
map<string, LibUtilities::ShapeType>::iterator it2;
elTypes["S"] = LibUtilities::eSegment;
elTypes["T"] = LibUtilities::eTriangle;
elTypes["Q"] = LibUtilities::eQuadrilateral;
......@@ -74,24 +71,24 @@ CollectionOptimisation::CollectionOptimisation(
elTypes["H"] = LibUtilities::eHexahedron;
// Set defaults for all element types.
for (it2 = elTypes.begin(); it2 != elTypes.end(); ++it2)
for (auto &it2 : elTypes)
{
defaults [ElmtOrder(it2->second, -1)] = m_defaultType;
defaultsPhysDeriv [ElmtOrder(it2->second, -1)] = m_defaultType;
defaults [ElmtOrder(it2.second, -1)] = m_defaultType;
defaultsPhysDeriv [ElmtOrder(it2.second, -1)] = m_defaultType;
}
if (defaultType == eNoImpType)
{
for (it2 = elTypes.begin(); it2 != elTypes.end(); ++it2)
for (auto &it2 : elTypes)
{
defaultsPhysDeriv [ElmtOrder(it2->second, -1)] = eNoCollection;
defaultsPhysDeriv [ElmtOrder(it2.second, -1)] = eNoCollection;
for (int i = 1; i < 5; ++i)
{
defaults[ElmtOrder(it2->second, i)] = eStdMat;
defaults[ElmtOrder(it2.second, i)] = eStdMat;
}
for (int i = 1; i < 3; ++i)
{
defaultsPhysDeriv[ElmtOrder(it2->second, i)] = eSumFac;
defaultsPhysDeriv[ElmtOrder(it2.second, i)] = eSumFac;
}
}
}
......@@ -158,9 +155,9 @@ CollectionOptimisation::CollectionOptimisation(
"Unknown default collection scheme: "+collinfo);
// Override default types
for (it2 = elTypes.begin(); it2 != elTypes.end(); ++it2)
for (auto &it2 : elTypes)
{
defaults[ElmtOrder(it2->second, -1)] = m_defaultType;
defaults[ElmtOrder(it2.second, -1)] = m_defaultType;
}
for (i = 0; i < SIZE_OperatorType; ++i)
......@@ -204,7 +201,7 @@ CollectionOptimisation::CollectionOptimisation(
ASSERTL0(attr, "Missing TYPE in ELEMENT tag.");
string elType(attr);
it2 = elTypes.find(elType);
auto it2 = elTypes.find(elType);
ASSERTL0(it2 != elTypes.end(),
"Unknown element type "+elType+" in ELEMENT "
"tag");
......@@ -254,21 +251,17 @@ CollectionOptimisation::CollectionOptimisation(
if (m_setByXml)
{
map<OperatorType, map<ElmtOrder,
ImplementationType> >::iterator mIt;
map<ElmtOrder, ImplementationType>::iterator eIt;
for (mIt = m_global.begin(); mIt != m_global.end(); mIt++)
for (auto &mIt : m_global)
{
cout << "Operator " << OperatorTypeMap[mIt->first]
<< ":" << endl;
cout << "Operator " << OperatorTypeMap[mIt.first]
<< ":" << endl;
for (eIt = mIt->second.begin();
eIt != mIt->second.end(); eIt++)
for (auto &eIt : mIt.second)
{
cout << "- "
<< LibUtilities::ShapeTypeMap[eIt->first.first]
<< " order " << eIt->first.second << " -> "
<< ImplementationTypeMap[eIt->second] << endl;
<< LibUtilities::ShapeTypeMap[eIt.first.first]
<< " order " << eIt.first.second << " -> "
<< ImplementationTypeMap[eIt.second] << endl;
}
}
}
......@@ -280,24 +273,21 @@ CollectionOptimisation::CollectionOptimisation(
OperatorImpMap CollectionOptimisation::GetOperatorImpMap(
StdRegions::StdExpansionSharedPtr pExp)
{
map<OperatorType, map<ElmtOrder, ImplementationType> >::iterator it;
map<ElmtOrder, ImplementationType>::iterator it2;
OperatorImpMap ret;
ElmtOrder searchKey(pExp->DetShapeType(),
pExp->GetBasisNumModes(0));
ElmtOrder defSearch(pExp->DetShapeType(), -1);
for (it = m_global.begin(); it != m_global.end(); ++it)
for (auto &it : m_global)
{
ImplementationType impType;
it2 = it->second.find(searchKey);
auto it2 = it.second.find(searchKey);
if (it2 == it->second.end())
if (it2 == it.second.end())
{
it2 = it->second.find(defSearch);
if (it2 == it->second.end())
it2 = it.second.find(defSearch);
if (it2 == it.second.end())
{
// Shouldn't be able to reach here.
impType = eNoCollection;
......@@ -312,7 +302,7 @@ OperatorImpMap CollectionOptimisation::GetOperatorImpMap(
impType = it2->second;
}
ret[it->first] = impType;
ret[it.first] = impType;
}
return ret;
......
......@@ -423,8 +423,7 @@ struct Field
LibUtilities::CommSharedPtr c = m_session ? m_session->GetComm() :
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
string fmt = LibUtilities::FieldIO::GetFileType(filename, c);
map<string, LibUtilities::FieldIOSharedPtr>::iterator it =
m_fld.find(fmt);
auto it = m_fld.find(fmt);
if (it == m_fld.end())
{
......
......@@ -141,12 +141,11 @@ void InputFld::Process(po::variables_map &vm)
m_f->m_exp.resize(1);
Array<OneD, int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
i = 0;
for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
for (auto &expIt : expansions)
{
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
}
m_f->m_fielddef.clear();
......
......@@ -313,12 +313,11 @@ void InputXml::Process(po::variables_map &vm)
// this partition/subrange
Array<OneD, int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
int i = 0;
for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
for (auto &expIt : expansions)
{
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
}
m_f->m_fielddef.clear();
......
......@@ -852,28 +852,25 @@ void Interpolator::SetupTree()
m_rtree->insert(inPoints.begin(), inPoints.end());
// remove duplicates from tree
for (std::vector<PtsPointPair>::iterator it = inPoints.begin();
it != inPoints.end(); ++it)
for (auto &it : inPoints)
{
std::vector<PtsPointPair> result;
// find nearest 2 points (2 because one of these might be the one we
// are
// checking)
m_rtree->query(bgi::nearest((*it).first, 2),
m_rtree->query(bgi::nearest(it.first, 2),
std::back_inserter(result));
// in case any of these 2 points is too close, remove the current
// point
// from the tree
for (std::vector<PtsPointPair>::iterator it2 = result.begin();
it2 != result.end(); ++it2)
for (auto &it2 : result)
{
if ((*it).second != (*it2).second &&
bg::distance((*it).first, (*it2).first) <=
NekConstants::kNekZeroTol)
if (it.second != it2.second &&
bg::distance(it.first, it2.first) <= NekConstants::kNekZeroTol)
{
m_rtree->remove(*it);
m_rtree->remove(it);
break;
}
}
......
......@@ -100,7 +100,7 @@ void OutputModule::OpenStream()
*/
void Module::RegisterConfig(string key, string val)
{
map<string, ConfigOption>::iterator it = m_config.find(key);
auto it = m_config.find(key);
if (it == m_config.end())
{
cerr << "WARNING: Unrecognised config option " << key
......@@ -124,17 +124,15 @@ void Module::RegisterConfig(string key, string val)
*/
void Module::PrintConfig()
{
map<string, ConfigOption>::iterator it;
if (m_config.size() == 0)
{
cerr << "No configuration options for this module." << endl;
return;
}
for (it = m_config.begin(); it != m_config.end(); ++it)
for (auto &it : m_config)
{
cerr << setw(10) << it->first << ": " << it->second.m_desc << endl;
cerr << setw(10) << it.first << ": " << it.second.m_desc << endl;
}
}
......@@ -144,13 +142,11 @@ void Module::PrintConfig()
*/
void Module::SetDefaults()
{
map<string, ConfigOption>::iterator it;
for (it = m_config.begin(); it != m_config.end(); ++it)
for (auto &it : m_config)
{
if (!it->second.m_beenSet)
if (!it.second.m_beenSet)
{
it->second.m_value = it->second.m_defValue;
it.second.m_value = it.second.m_defValue;
}
}
}
......
......@@ -138,13 +138,11 @@ void OutputFld::Process(po::variables_map &vm)
m_f->m_exp[0]->GetGraph());
const SpatialDomains::BoundaryRegionCollection bregions =
bcs.GetBoundaryRegions();
SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
map<int, int> BndRegionMap;
int cnt = 0;
for (breg_it = bregions.begin(); breg_it != bregions.end();
++breg_it, ++cnt)
for (auto &breg_it : bregions)
{
BndRegionMap[breg_it->first] = cnt;
BndRegionMap[breg_it.first] = cnt++;
}
// find ending of output file and insert _b1, _b2
......
......@@ -98,8 +98,7 @@ void ProcessAddCompositeID::Process(po::variables_map &vm)
const SpatialDomains::CompositeMap CompositeMap =
m_f->m_graph->GetComposites();
SpatialDomains::CompositeMapConstIter it;
NekDouble compid=0;
int compid = -1;
// loop over elements
for (int n = 0; n < exp->GetNumElmts(); ++n)
......@@ -107,24 +106,24 @@ void ProcessAddCompositeID::Process(po::variables_map &vm)
LocalRegions::ExpansionSharedPtr elmt = exp->GetExp(n);
// loop over composite list and search for geomtry pointer in list
for (it = CompositeMap.begin(); it != CompositeMap.end(); ++it)
for (auto &it : CompositeMap)
{
if (find(it->second->begin(), it->second->end(), elmt->GetGeom()) !=
it->second->end())
if (find(it.second->begin(), it.second->end(), elmt->GetGeom()) !=
it.second->end())
{
compid = it->first;
compid = it.first;
break;
}
}
WARNINGL0(it != CompositeMap.end(),
WARNINGL0(compid != -1,
"Failed to find composite ID for element: " +
boost::lexical_cast<string>(n));
// Fill element with the value of the index
int npts = elmt->GetTotPoints();
Array<OneD, NekDouble> tmp;
Vmath::Fill(npts, compid,
Vmath::Fill(npts, (NekDouble)compid,
tmp = exp->UpdatePhys() + exp->GetPhys_Offset(n), 1);
}
......
......@@ -122,10 +122,9 @@ void ProcessBoundaryExtract::Process(po::variables_map &vm)
const SpatialDomains::BoundaryRegionCollection bregions =
bcs.GetBoundaryRegions();
SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
for (breg_it = bregions.begin(); breg_it != bregions.end(); ++breg_it)
for (auto &breg_it : bregions)
{
numBndExp = max(numBndExp, breg_it->first);
numBndExp = max(numBndExp, breg_it.first);
}
// assuming all boundary regions are consecutive number if
// regions is one more tham maximum id
......
......@@ -169,15 +169,14 @@ void ProcessDisplacement::Process(po::variables_map &vm)
}
const SpatialDomains::SegGeomMap &tmp = bndGraph->GetAllSegGeoms();
SpatialDomains::SegGeomMap::const_iterator sIt;
for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
for (auto &sIt : tmp)
{
map<int, int>::iterator mIt = bndCondIds.find(sIt->first);
auto mIt = bndCondIds.find(sIt.first);
if (mIt == bndCondIds.end())
{
cout << "Warning: couldn't find element " << sIt->first << endl;
cout << "Warning: couldn't find element " << sIt.first << endl;
continue;
}
......@@ -187,7 +186,7 @@ void ProcessDisplacement::Process(po::variables_map &vm)
std::dynamic_pointer_cast<SpatialDomains::SegGeom>(
bndCondExpU->GetExp(e)->GetGeom());
SpatialDomains::SegGeomSharedPtr to = sIt->second;
SpatialDomains::SegGeomSharedPtr to = sIt.second;
// Create temporary SegExp
LocalRegions::SegExpSharedPtr toSeg =
......@@ -248,31 +247,28 @@ void ProcessDisplacement::Process(po::variables_map &vm)
}
const SpatialDomains::TriGeomMap &tmp = bndGraph->GetAllTriGeoms();
SpatialDomains::TriGeomMap::const_iterator sIt;
for (sIt = tmp.begin(); sIt != tmp.end(); ++sIt)
for (auto &sIt : tmp)
{
TriFaceMap::iterator tIt;
int e;
if (useVertexIds)
{
TriFaceIDs t(sIt->second->GetVid(0), sIt->second->GetVid(1),
sIt->second->GetVid(2));
TriFaceIDs t(sIt.second->GetVid(0), sIt.second->GetVid(1),
sIt.second->GetVid(2));
tIt = vertexFaceMap.find(t);
e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
auto tIt = vertexFaceMap.find(t);
e = tIt == vertexFaceMap.end() ? -1 : tIt->second;
}
else
{
map<int, int>::iterator mIt;
mIt = bndCondIds.find(sIt->first);
e = mIt == bndCondIds.end() ? -1 : mIt->second;
auto mIt = bndCondIds.find(sIt.first);
e = mIt == bndCondIds.end() ? -1 : mIt->second;
}
if (e == -1)
{
cout << "Warning: couldn't find element " << sIt->first << endl;
cout << "Warning: couldn't find element " << sIt.first << endl;
continue;
}
......@@ -280,7 +276,7 @@ void ProcessDisplacement::Process(po::variables_map &vm)
std::dynamic_pointer_cast<SpatialDomains::TriGeom>(
bndCondExpU->GetExp(e)->GetGeom());
SpatialDomains::TriGeomSharedPtr to = sIt->second;
SpatialDomains::TriGeomSharedPtr to = sIt.second;
// Create temporary SegExp
LocalRegions::TriExpSharedPtr toSeg =
......
......@@ -155,12 +155,11 @@ void ProcessInterpField::Process(po::variables_map &vm)
}
Array<OneD, int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
int i = 0;
for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
for (auto &expIt : expansions)
{
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
}
string fromfld = m_config["fromfld"].as<string>();
......
......@@ -502,12 +502,11 @@ void ProcessInterpPoints::Process(po::variables_map &vm)
fromField->m_graph->GetExpansions();
Array<OneD, int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
int i = 0;
for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
for (auto &expIt : expansions)
{
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
ElementGIDs[i++] = expIt.second->m_geomShPtr->GetGlobalID();
}
// check to see that we do have some elmement in teh domain since
......
......@@ -688,7 +688,6 @@ void Iso::Condense(void)
register int i,j,cnt;
IsoVertex v;
vector<IsoVertex> vert;
vector<IsoVertex>::iterator pt;
if(!m_ntris) return;
......@@ -724,7 +723,7 @@ void Iso::Condense(void)
v.m_y = m_y[3*i+j];
v.m_z = m_z[3*i+j];
pt = find(vert.begin(),vert.end(),v);
auto pt = find(vert.begin(),vert.end(),v);
if(pt != vert.end())
{
m_vid[3*i+j] = pt[0].m_id;
......@@ -888,7 +887,6 @@ void Iso::GlobalCondense(vector<IsoSharedPtr> &iso, bool verbose)
//see if any values have unique value already
set<int> samept;
set<int>::iterator it;
int new_index = -1;
for(id1 = 0; id1 < result.size(); ++id1)
{
......@@ -912,9 +910,9 @@ void Iso::GlobalCondense(vector<IsoSharedPtr> &iso, bool verbose)
// reset all same values to new_index
global_to_unique_map[i] = new_index;
for(it = samept.begin(); it != samept.end(); ++it)
for(auto &it : samept)
{
global_to_unique_map[*it] = new_index;
global_to_unique_map[it] = new_index;
}
}
}
......@@ -993,8 +991,6 @@ void Iso::Smooth(int n_iter, NekDouble lambda, NekDouble mu)
Array<OneD, NekDouble> xtemp, ytemp, ztemp;
vector< vector<int> > adj,vertcon;
vector< vector<NekDouble > > wght;
vector<int>::iterator iad;
vector<int>::iterator ipt;
// determine elements around each vertex
vertcon.resize(m_nvert);
......@@ -1013,17 +1009,17 @@ void Iso::Smooth(int n_iter, NekDouble lambda, NekDouble mu)
for(i =0; i < m_nvert; ++i)
{
// loop over surrounding elements
for(ipt = vertcon[i].begin(); ipt != vertcon[i].end(); ++ipt)
for(auto &ipt : vertcon[i])
{
for(j = 0; j < 3; ++j)
{
// make sure not adding own vertex
if(m_vid[3*(*ipt)+j] != i)
if(m_vid[3*ipt+j] != i)
{
// check to see if vertex has already been added
for(k = 0; k < adj[i].size(); ++k)
{
if(adj[i][k] == m_vid[3*(*ipt)+j])
if(adj[i][k] == m_vid[3*ipt+j])
{
break;
}
......@@ -1031,7 +1027,7 @@ void Iso::Smooth(int n_iter, NekDouble lambda, NekDouble mu)
if(k == adj[i].size())
{
adj[i].push_back(m_vid[3*(*ipt)+j]);
adj[i].push_back(m_vid[3*ipt+j]);
}
}
}
......@@ -1095,9 +1091,7 @@ void Iso::SeparateRegions(vector<IsoSharedPtr> &sep_iso, int minsize, bool verbo
{
int i,j,k,id;
Array<OneD, vector<int> >vertcon(m_nvert);
vector<int>::iterator ipt;
list<int> tocheck;
list<int>::iterator cid;
Array<OneD, bool> viddone(m_nvert,false);
......@@ -1129,11 +1123,11 @@ void Iso::SeparateRegions(vector<IsoSharedPtr> &sep_iso, int minsize, bool verbo
vidregion[k] = ++nregions;
// find all elmts around this.. vertex that need to be checked
for(ipt = vertcon[k].begin(); ipt != vertcon[k].end(); ++ipt)
for(auto &ipt : vertcon[k])
{
for(i = 0; i < 3; ++i)
{
if(vidregion[id = m_vid[3*(ipt[0])+i]] == -1)
if(vidregion[id = m_vid[3*ipt+i]] == -1)
{
tocheck.push_back(id);
vidregion[id] = nregions;
......@@ -1145,16 +1139,16 @@ void Iso::SeparateRegions(vector<IsoSharedPtr> &sep_iso, int minsize, bool verbo
// check all other neighbouring vertices
while(tocheck.size())
{
cid = tocheck.begin();
auto cid = tocheck.begin();
while(cid != tocheck.end())
{
if(!viddone[*cid])
{
for(ipt = vertcon[*cid].begin(); ipt != vertcon[*cid].end(); ++ipt)
for(auto &ipt : vertcon[*cid])
{
for(i = 0; i < 3; ++i)
{
if(vidregion[id = m_vid[3*(ipt[0])+i]] == -1)
if(vidregion[id = m_vid[3*ipt+i]] == -1)
{
tocheck.push_back(id);
vidregion[id] = nregions;
......
......@@ -120,13 +120,13 @@ void ProcessNumModes::Process(po::variables_map &vm)
}
}
vector<MultiRegions::ExpListSharedPtr>::iterator it;
for (s = 0; s < nstrips; ++s)
{
for (i = 0; i < addfields; ++i)
{
it = m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i;
m_f->m_exp.insert(it, Exp[s * addfields + i]);
m_f->m_exp.insert(
m_f->m_exp.begin() + s * (nfields + addfields) + nfields + i,
Exp[s * addfields + i]);
}
}
......
......@@ -228,14 +228,13 @@ void ProcessQCriterion::Process(po::variables_map &vm)
}
}