43 #include <boost/config.hpp>
44 #include <boost/graph/adjacency_list.hpp>
45 #include <boost/graph/cuthill_mckee_ordering.hpp>
46 #include <boost/graph/properties.hpp>
47 #include <boost/graph/bandwidth.hpp>
51 namespace MultiRegions
71 const std::string variable):
83 const int numLocalCoeffs,
87 ASSERTL0(
false,
"AssemblyMapCG: you need to instantiate dimension-specific derived class.");
117 int tmp1 = (int)faceOrient - 5;
118 int tmp2 = (int)perFaceOrient - 5;
120 int flipDir1Map [8] = {2,3,0,1,6,7,4,5};
121 int flipDir2Map [8] = {1,0,3,2,5,4,7,6};
122 int transposeMap[8] = {4,5,6,7,0,2,1,3};
127 tmp1 = transposeMap[tmp1];
131 if (tmp2 == 2 || tmp2 == 3 || tmp2 == 6 || tmp2 == 7)
133 tmp1 = flipDir1Map[tmp1];
139 tmp1 = flipDir2Map[tmp1];
174 int maxBndGlobalId = 0;
177 Array<OneD, unsigned int> edgeInteriorMap;
178 Array<OneD, int> edgeInteriorSign;
179 Array<OneD, unsigned int> faceInteriorMap;
180 Array<OneD, int> faceInteriorSign;
181 Array<OneD, unsigned int> interiorMap;
182 PeriodicMap::const_iterator pIt;
193 for(i = 0; i < locExpVector.size(); ++i)
195 locExpansion = locExpVector[i];
196 nVert += locExpansion->GetNverts();
197 nEdge += locExpansion->GetNedges();
198 nFace += locExpansion->GetNfaces();
200 for(j = 0; j < locExpansion->GetNedges(); ++j)
202 dof = locExpansion->GetEdgeNcoeffs(j)-2;
203 maxEdgeDof = (dof > maxEdgeDof ? dof : maxEdgeDof);
205 for(j = 0; j < locExpansion->GetNfaces(); ++j)
207 dof = locExpansion->GetFaceIntNcoeffs(j);
208 maxFaceDof = (dof > maxFaceDof ? dof : maxFaceDof);
210 locExpansion->GetInteriorMap(interiorMap);
211 dof = interiorMap.num_elements();
212 maxIntDof = (dof > maxIntDof ? dof : maxIntDof);
224 for(i = 0; i < locExpVector.size(); ++i)
226 locExpansion = locExpVector[i];
227 nDim = locExpansion->GetShapeDimension();
231 for(j = 0; j < locExpansion->GetNverts(); ++j)
233 meshVertId = locExpansion->GetGeom()->GetVid(j);
236 pIt = perVerts.find(meshVertId);
237 if (pIt != perVerts.end())
239 for (k = 0; k < pIt->second.size(); ++k)
241 meshVertId = min(meshVertId, pIt->second[k].id);
247 maxBndGlobalId = (vGlobalId > maxBndGlobalId ? vGlobalId : maxBndGlobalId);
251 for(j = 0; j < locExpansion->GetNedges(); ++j)
253 meshEdgeId = locExpansion->GetGeom()->GetEid(j);
254 pIt = perEdges.find(meshEdgeId);
255 if (pIt != perEdges.end())
257 for (k = 0; k < pIt->second.size(); ++k)
259 meshEdgeId = min(meshEdgeId, pIt->second[k].id);
263 edgeOrient = locExpansion->GetGeom()->GetEorient(j);
264 locExpansion->GetEdgeInteriorMap(j,edgeOrient,edgeInteriorMap,edgeInteriorSign);
265 dof = locExpansion->GetEdgeNcoeffs(j)-2;
268 for(k = 0; k < dof; ++k)
272 = nVert + meshEdgeId * maxEdgeDof + k + 1;
274 maxBndGlobalId = (vGlobalId > maxBndGlobalId ? vGlobalId : maxBndGlobalId);
279 for(j = 0; j < locExpansion->GetNfaces(); ++j)
284 meshFaceId = locExpansion->GetGeom()->GetFid(j);
286 pIt = perFaces.find(meshFaceId);
287 if (pIt != perFaces.end())
289 if(meshFaceId == min(meshFaceId, pIt->second[0].id))
293 meshFaceId = min(meshFaceId, pIt->second[0].id);
297 locExpansion->GetFaceInteriorMap(j,faceOrient,faceInteriorMap,faceInteriorSign);
298 dof = locExpansion->GetFaceIntNcoeffs(j);
301 for(k = 0; k < dof; ++k)
305 = nVert + nEdge*maxEdgeDof + meshFaceId * maxFaceDof
309 maxBndGlobalId = (vGlobalId > maxBndGlobalId ? vGlobalId : maxBndGlobalId);
314 locExpansion->GetInteriorMap(interiorMap);
315 dof = interiorMap.num_elements();
316 elementId = (locExpansion->GetGeom())->GetGlobalID();
317 for (k = 0; k < dof; ++k)
321 = nVert + nEdge*maxEdgeDof + nFace*maxFaceDof + elementId*maxIntDof + k + 1;
329 Nektar::Array<OneD, long> tmp(m_numGlobalCoeffs);
331 Nektar::Array<OneD, long> tmp2(m_numGlobalBndCoeffs, tmp);
342 m_globalToUniversalMapUnique[i] = (tmp[i] >= 0 ? 1 : 0);
346 m_globalToUniversalBndMapUnique[i] = (tmp2[i] >= 0 ? 1 : 0);
365 const boost::shared_ptr<LocalRegions::ExpansionVector> exp
367 int nelmts = exp->size();
372 returnval->m_solnType = solnType;
373 returnval->m_preconType =
eNull;
374 returnval->m_maxStaticCondLevel = 0;
375 returnval->m_signChange =
false;
376 returnval->m_comm =
m_comm;
379 for (i = 0; i < nelmts; ++i)
381 nverts += (*exp)[i]->GetNverts();
384 returnval->m_numLocalCoeffs = nverts;
385 returnval->m_localToGlobalMap = Array<OneD, int>(nverts, -1);
388 returnval->m_localToGlobalBndMap = Array<OneD, int>(nverts, -1);
395 for (i = 0; i < nelmts; ++i)
397 for (j = 0; j < (*exp)[i]->GetNverts(); ++j)
399 returnval->m_localToGlobalMap[cnt] =
400 returnval->m_localToGlobalBndMap[cnt] =
402 GlobCoeffs[returnval->m_localToGlobalMap[cnt]] = 1;
406 if ((returnval->m_localToGlobalMap[cnt]) <
409 returnval->m_numLocalDirBndCoeffs++;
414 cnt1 += (*exp)[i]->GetNcoeffs();
421 if (GlobCoeffs[i] != -1)
423 GlobCoeffs[i] = cnt++;
428 returnval->m_numGlobalCoeffs = cnt;
433 if (GlobCoeffs[i] != -1)
435 returnval->m_numGlobalDirBndCoeffs++;
444 int nglocoeffs = returnval->m_numGlobalCoeffs;
445 returnval->m_globalToUniversalMap
446 = Array<OneD, int> (nglocoeffs);
447 returnval->m_globalToUniversalMapUnique
448 = Array<OneD, int> (nglocoeffs);
451 for (i = 0; i < nverts; ++i)
453 cnt = returnval->m_localToGlobalMap[i];
454 returnval->m_localToGlobalMap[i] = GlobCoeffs[cnt];
456 returnval->m_globalToUniversalMap[GlobCoeffs[cnt]] =
460 Nektar::Array<OneD, long> tmp(nglocoeffs);
462 for (
unsigned int i = 0; i < nglocoeffs; ++i)
464 tmp[i] = returnval->m_globalToUniversalMap[i];
466 returnval->m_gsh =
Gs::Init(tmp, vCommRow);
468 for (
unsigned int i = 0; i < nglocoeffs; ++i)
470 returnval->m_globalToUniversalMapUnique[i]
471 = (tmp[i] >= 0 ? 1 : 0);
476 for (i = 0; i < nverts; ++i)
478 cnt = returnval->m_localToGlobalMap[i];
479 returnval->m_localToGlobalMap[i] = GlobCoeffs[cnt];
512 for(j = 0; j < locSize; j++)
527 bwidth = (bwidth>(maxId-minId))?bwidth:(maxId-minId);
551 const Array<OneD,const int>&
557 const Array<OneD,const int>&
563 const Array<OneD,const int>&
588 const Array<OneD, const NekDouble>& loc,
589 Array<OneD, NekDouble>& global)
const
591 Array<OneD, const NekDouble> local;
592 if(global.data() == loc.data())
594 local = Array<OneD, NekDouble>(loc.num_elements(),loc.data());
623 const Array<OneD, const NekDouble>& global,
624 Array<OneD, NekDouble>& loc)
const
626 Array<OneD, const NekDouble> glo;
627 if(global.data() == loc.data())
629 glo = Array<OneD, NekDouble>(global.num_elements(),global.data());
655 const Array<OneD, const NekDouble> &loc,
656 Array<OneD, NekDouble> &global)
const
658 Array<OneD, const NekDouble> local;
659 if(global.data() == loc.data())
661 local = Array<OneD, NekDouble>(local.num_elements(),local.data());
690 Array<OneD, NekDouble>& pGlobal)
const
702 Array<OneD, NekDouble>& pGlobal,
705 Array<OneD, NekDouble> tmp(offset);