54 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
57 const bool CheckforSingularSys):
58 AssemblyMapCG2D(pSession)
68 int nEdgeInteriorCoeffs;
69 int firstNonDirGraphVertId;
70 int nLocBndCondDofs = 0;
71 int nLocDirBndCondDofs = 0;
72 int nExtraDirichlet = 0;
77 Array<OneD, unsigned int> edgeInteriorMap;
78 Array<OneD, int> edgeInteriorSign;
79 int nvel = fields.num_elements();
83 int nel = fields[0]->GetNumElmts();
87 Array<OneD, map<int,int> > ReorderedGraphVertId(2);
89 int staticCondLevel = 0;
91 if(CheckforSingularSys)
108 fields[0]->GetPeriodicEntities(periodicVerts,periodicEdges);
111 const Array<OneD, const MultiRegions::ExpListSharedPtr> bndCondExp = fields[0]->GetBndCondExpansions();
113 Array<OneD, Array<OneD, const SpatialDomains::BoundaryConditionShPtr> > bndConditionsVec(nvel);
114 for(i = 0; i < nvel; ++i)
116 bndConditionsVec[i] = fields[i]->GetBndConditions();
119 map<int,int> IsDirVertDof;
120 map<int,int> IsDirEdgeDof;
124 for(j = 0; j < bndCondExp.num_elements(); ++j)
126 map<int,int> BndExpVids;
128 for(k = 0; k < bndCondExp[j]->GetNumElmts(); ++k)
132 BndExpVids[g->GetVid(0)] = g->GetVid(0);
133 BndExpVids[g->GetVid(1)] = g->GetVid(1);
136 for(i = 0; i < nvel; ++i)
141 for(k = 0; k < bndCondExp[j]->GetNumElmts(); ++k)
143 IsDirEdgeDof[bndCondExp[j]->GetExp(k)
145 ->GetGeom1D()->GetEid()] += 1;
152 for(mapIt = BndExpVids.begin(); mapIt != BndExpVids.end(); mapIt++)
154 id = IsDirVertDof[mapIt->second]+1;
155 IsDirVertDof[mapIt->second] = (
id > nvel)?nvel:
id;
164 for(k = 0; k < bndCondExp[j]->GetNumElmts(); ++k)
166 Array<OneD,Array<OneD,NekDouble> > locnorm;
168 = bndCondExp[j]->GetExp(k)
173 int ndir = locnorm.num_elements();
176 for(
int l = 0; l < locnorm[0].num_elements(); ++l)
194 Array<OneD, map<int,int> >Dofs(2);
196 Array<OneD, int> AddMeanPressureToEdgeId(nel,-1);
207 for(i = 0; i < bndConditionsVec[0].num_elements(); ++i)
211 id = bndCondExp[i]->GetExp(0)
218 ASSERTL0(
id != -1,
" Did not find an edge to attach singular pressure degree of freedom");
222 for(i = 0; i < nel; ++i)
224 for(j = 0; j < locExpVector[i]->GetNverts(); ++j)
227 ->GetGeom2D())->GetEid(j);
231 AddMeanPressureToEdgeId[i] = id;
236 if(AddMeanPressureToEdgeId[i] != -1)
244 for(i = 0; i < nel; ++i)
246 eid = fields[0]->GetOffset_Elmt_Id(i);
247 for(j = 0; j < locExpVector[eid]->GetNverts(); ++j)
250 ->GetGeom2D())->GetVid(j);
251 if(Dofs[0].count(vertId) == 0)
253 Dofs[0][vertId] = nvel*nz_loc;
256 if(IsDirVertDof.count(vertId) != 0)
258 Dofs[0][vertId] -= IsDirVertDof[vertId]*nz_loc;
263 ->GetGeom2D())->GetEid(j);
264 if(Dofs[1].count(edgeId) == 0)
266 Dofs[1][edgeId] = nvel*(locExpVector[eid]->GetEdgeNcoeffs(j)-2)*nz_loc;
270 if(IsDirEdgeDof.count(edgeId) != 0)
272 Dofs[1][edgeId] -= IsDirEdgeDof[edgeId]*nz_loc*(locExpVector[eid]->GetEdgeNcoeffs(j)-2);
281 periodicVerts, periodicEdges,
282 Dofs, ReorderedGraphVertId,
283 firstNonDirGraphVertId, nExtraDirichlet,
284 bottomUpGraph, extraDir,
false, 4);
300 edgeId, vertId, firstNonDirGraphVertId, IsDirEdgeDof,
302 AddMeanPressureToEdgeId);
308 for(i = 0; i < nel; ++i)
310 eid = fields[0]->GetOffset_Elmt_Id(i);
311 for(j = 0; j < locExpVector[eid]->GetNverts(); ++j)
314 ->GetGeom2D())->GetEid(j);
316 if(IsDirEdgeDof.count(edgeId) == 0)
320 if(AddMeanPressureToEdgeId[eid] == -1)
322 AddMeanPressureToEdgeId[eid] = edgeId;
326 ASSERTL0((AddMeanPressureToEdgeId[eid] != -1),
"Did not determine "
327 "an edge to attach mean pressure dof");
329 Dofs[1][AddMeanPressureToEdgeId[eid]] += nz_loc;
332 map<int,int> pressureEdgeOffset;
337 for(i = 0; i < bndCondExp.num_elements(); i++)
339 for(j = 0; j < bndCondExp[i]->GetNumElmts(); j++)
341 bndSegExp = bndCondExp[i]->GetExp(j)
343 for(k = 0; k < nvel; ++k)
347 nLocDirBndCondDofs += bndSegExp->
GetNcoeffs()*nz_loc;
349 nLocBndCondDofs += bndSegExp->GetNcoeffs()*nz_loc;
374 Array<OneD, int> graphVertOffset(nvel*nz_loc*(ReorderedGraphVertId[0].size() + ReorderedGraphVertId[1].size()),0);
375 graphVertOffset[0] = 0;
379 for(i = 0; i < nel; ++i)
381 eid = fields[0]->GetOffset_Elmt_Id(i);
384 for(j = 0; j < locExpansion->GetNedges(); ++j)
388 ->GetGeom2D())->GetEid(j);
390 ->GetGeom2D())->GetVid(j);
392 for(k = 0; k < nvel*nz_loc; ++k)
394 graphVertOffset[ReorderedGraphVertId[0][meshVertId]*nvel*nz_loc+k] = 1;
395 graphVertOffset[ReorderedGraphVertId[1][meshEdgeId]*nvel*nz_loc+k] = (nEdgeCoeffs-2);
398 bType = locExpansion->GetEdgeBasisType(j);
400 if( (nEdgeCoeffs >= 4)&&
410 for(i = 0; i < nel; ++i)
412 graphVertOffset[(ReorderedGraphVertId[1][AddMeanPressureToEdgeId[i]]+1)*nvel*nz_loc-1] += nz_loc;
421 map<int,int> DirVertChk;
423 for(i = 0; i < bndConditionsVec[0].num_elements(); ++i)
426 for(j = 0; j < nvel; ++j)
435 if((cnt > 0)&&(cnt < nvel))
437 for(j = 0; j < nvel; ++j)
443 for(k = 0; k < bndCondExp[i]->GetNumElmts(); ++k)
446 id = bndCondExp[i]->GetExp(k)
448 ->GetGeom1D()->GetVid(0);
449 if(DirVertChk.count(
id*nvel+j) == 0)
451 DirVertChk[
id*nvel+j] = 1;
452 for(n = 0; n < nz_loc; ++n)
454 graphVertOffset[ReorderedGraphVertId[0][id]*nvel*nz_loc+j*nz_loc + n] *= -1;
458 id = bndCondExp[i]->GetExp(k)
460 ->GetGeom1D()->GetVid(1);
461 if(DirVertChk.count(
id*nvel+j) == 0)
463 DirVertChk[
id*nvel+j] = 1;
464 for(n = 0; n < nz_loc; ++n)
466 graphVertOffset[ReorderedGraphVertId[0][id]*nvel*nz_loc+j*nz_loc+n] *= -1;
471 id = bndCondExp[i]->GetExp(k)
473 ->GetGeom1D()->GetEid();
474 for(n = 0; n < nz_loc; ++n)
476 graphVertOffset[ReorderedGraphVertId[1][id]*nvel*nz_loc+j*nz_loc +n] *= -1;
487 for(i = 0; i < firstNonDirGraphVertId*nvel*nz_loc; ++i)
489 diff = abs(graphVertOffset[i]);
490 graphVertOffset[i] = cnt;
495 for(i = firstNonDirGraphVertId*nvel*nz_loc; i < graphVertOffset.num_elements(); ++i)
497 if(graphVertOffset[i] < 0)
499 diff = -graphVertOffset[i];
500 graphVertOffset[i] = -cnt;
509 for(i = firstNonDirGraphVertId*nvel*nz_loc; i < graphVertOffset.num_elements(); ++i)
511 if(graphVertOffset[i] >= 0)
513 diff = graphVertOffset[i];
514 graphVertOffset[i] = cnt;
521 for(i = firstNonDirGraphVertId*nvel*nz_loc; i < graphVertOffset.num_elements(); ++i)
523 if(graphVertOffset[i] < 0)
525 graphVertOffset[i] = -graphVertOffset[i];
536 for(i = 0; i < nel; ++i)
563 for(i = 0; i < nel; ++i)
566 m_numLocalIntCoeffsPerPatch[i] = (
unsigned int) nz_loc*(pressure->GetExp(eid)->GetNcoeffs()-1);
580 Array<OneD, unsigned int> bmap;
585 for(i = 0; i < nel; ++i)
587 eid = fields[0]->GetOffset_Elmt_Id(i);
596 map<int,int> inv_bmap;
597 locExpansion->GetBoundaryMap(bmap);
598 for(j = 0; j < bmap.num_elements(); ++j)
600 inv_bmap[bmap[j]] = j;
604 for(j = 0; j < locExpansion->GetNedges(); ++j)
606 nEdgeInteriorCoeffs = locExpansion->GetEdgeNcoeffs(j)-2;
608 ->GetGeom2D())->GetEorient(j);
610 ->GetGeom2D())->GetEid(j);
612 ->GetGeom2D())->GetVid(j);
614 locExpansion->GetEdgeInteriorMap(j,edgeOrient,edgeInteriorMap,edgeInteriorSign);
617 for(nv = 0; nv < nvel*nz_loc; ++nv)
619 m_localToGlobalMap[cnt+nv*velnbndry+inv_bmap[locExpansion->GetVertexMap(j)]] = graphVertOffset[ReorderedGraphVertId[0][meshVertId]*nvel*nz_loc+ nv];
621 for(k = 0; k < nEdgeInteriorCoeffs; ++k)
623 m_localToGlobalMap[cnt+nv*velnbndry+inv_bmap[edgeInteriorMap[k]]] = graphVertOffset[ReorderedGraphVertId[1][meshEdgeId]*nvel*nz_loc+nv]+k;
630 for(nv = 0; nv < nvel*nz_loc; ++nv)
632 for(k = 0; k < nEdgeInteriorCoeffs; ++k)
634 m_localToGlobalSign[cnt+nv*velnbndry + inv_bmap[edgeInteriorMap[k]]] = (
NekDouble) edgeInteriorSign[k];
641 nEdgeInteriorCoeffs = graphVertOffset[(ReorderedGraphVertId[1][AddMeanPressureToEdgeId[eid]])*nvel*nz_loc+1] - graphVertOffset[(ReorderedGraphVertId[1][AddMeanPressureToEdgeId[eid]])*nvel*nz_loc];
643 int psize = pressure->GetExp(eid)->GetNcoeffs();
644 for(n = 0; n < nz_loc; ++n)
646 m_localToGlobalMap[cnt + nz_loc*nvel*velnbndry + n*psize] = graphVertOffset[(ReorderedGraphVertId[1][AddMeanPressureToEdgeId[eid]]+1)*nvel*nz_loc-1]+nEdgeInteriorCoeffs + pressureEdgeOffset[AddMeanPressureToEdgeId[eid]];
648 pressureEdgeOffset[AddMeanPressureToEdgeId[eid]] += 1;
651 cnt += (velnbndry*nvel+ psize)*nz_loc;
656 for(nv = 0; nv < nvel; ++nv)
658 for(i = 0; i < bndCondExp.num_elements(); i++)
660 for(n = 0; n < nz_loc; ++n)
663 for(j = 0; j < bndCondExp[i]->GetNumElmts(); j++)
665 bndSegExp = bndCondExp[i]->GetExp(j)
668 cnt = offset + bndCondExp[i]->GetCoeff_Offset(j);
669 for(k = 0; k < 2; k++)
671 meshVertId = (bndSegExp->GetGeom1D())->GetVid(k);
672 m_bndCondCoeffsToGlobalCoeffsMap[cnt+bndSegExp->
GetVertexMap(k)] = graphVertOffset[ReorderedGraphVertId[0][meshVertId]*nvel*nz_loc+nv*nz_loc+n];
675 meshEdgeId = (bndSegExp->GetGeom1D())->GetEid();
678 for(k = 0; k < nEdgeCoeffs; k++)
680 if(m_bndCondCoeffsToGlobalCoeffsMap[cnt+k] == -1)
682 m_bndCondCoeffsToGlobalCoeffsMap[cnt+k] =
683 graphVertOffset[ReorderedGraphVertId[1][meshEdgeId]*nvel*nz_loc+nv*nz_loc+n]+bndEdgeCnt;
687 ncoeffcnt += nEdgeCoeffs;
728 Array<OneD, int> vwgts_perm(
729 Dofs[0].size()+Dofs[1].size()-firstNonDirGraphVertId);
730 for(i = 0; i < locExpVector.size(); ++i)
732 int eid = fields[0]->GetOffset_Elmt_Id(i);
733 locExpansion = locExpVector[eid]
735 for(j = 0; j < locExpansion->GetNverts(); ++j)
737 meshEdgeId = (locExpansion
739 ->GetGeom2D())->GetEid(j);
740 meshVertId = (locExpansion
742 ->GetGeom2D())->GetVid(j);
744 if(ReorderedGraphVertId[0][meshVertId] >=
745 firstNonDirGraphVertId)
747 vwgts_perm[ReorderedGraphVertId[0][meshVertId]-
748 firstNonDirGraphVertId] =
752 if(ReorderedGraphVertId[1][meshEdgeId] >=
753 firstNonDirGraphVertId)
755 vwgts_perm[ReorderedGraphVertId[1][meshEdgeId]-
756 firstNonDirGraphVertId] =
762 bottomUpGraph->ExpandGraphWithVertexWeights(vwgts_perm);
772 void CoupledLocalToGlobalC0ContMap::FindEdgeIdToAddMeanPressure(Array<
OneD, map<int,int> > &ReorderedGraphVertId,
774 int &edgeId,
int &vertId,
int &firstNonDirGraphVertId, map<int,int> &IsDirEdgeDof,
776 Array<OneD, int> &AddMeanPressureToEdgeId)
782 Array<TwoD, int> EdgeIdToElmts(ReorderedGraphVertId[1].size(),2,-1);
783 map<int,int> HomGraphEdgeIdToEdgeId;
785 for(i = 0; i < nel; ++i)
787 for(j = 0; j < locExpVector[i]->GetNverts(); ++j)
790 ->GetGeom2D())->GetEid(j);
793 if((ReorderedGraphVertId[1][edgeId] >= firstNonDirGraphVertId)
794 && (IsDirEdgeDof.count(edgeId) == 0))
796 HomGraphEdgeIdToEdgeId[ReorderedGraphVertId[1][edgeId]-firstNonDirGraphVertId] = edgeId;
798 if(EdgeIdToElmts[edgeId][0] == -1)
800 EdgeIdToElmts[edgeId][0] = i;
804 EdgeIdToElmts[edgeId][1] = i;
815 int nlevels = bottomUpGraph->GetNlevels();
821 vector<MultiRegions::SubGraphSharedPtr> bndgraphs = bottomUpGraph->GetInteriorBlocks(nlevels);
822 for(i = 0; i < bndgraphs.size(); ++i)
824 int GlobIdOffset = bndgraphs[i]->GetIdOffset();
826 for(j = 0; j < bndgraphs[i]->GetNverts(); ++j)
829 if(HomGraphEdgeIdToEdgeId.count(GlobIdOffset+j) != 0)
831 edgeId = HomGraphEdgeIdToEdgeId[GlobIdOffset+j];
846 for(
int n = 1; n < nlevels; ++n)
850 vector<MultiRegions::SubGraphSharedPtr> bndgraphs = bottomUpGraph->GetInteriorBlocks(n+1);
853 map<int,int> ElmtInBndry;
855 for(i = 0; i < bndgraphs.size(); ++i)
857 int GlobIdOffset = bndgraphs[i]->GetIdOffset();
859 for(j = 0; j < bndgraphs[i]->GetNverts(); ++j)
862 if(HomGraphEdgeIdToEdgeId.count(GlobIdOffset+j) != 0)
864 edgeId = HomGraphEdgeIdToEdgeId[GlobIdOffset+j];
866 if(EdgeIdToElmts[edgeId][0] != -1)
868 ElmtInBndry[EdgeIdToElmts[edgeId][0]] = i;
870 if(EdgeIdToElmts[edgeId][1] != -1)
872 ElmtInBndry[EdgeIdToElmts[edgeId][1]] = i;
881 vector<MultiRegions::SubGraphSharedPtr> intgraphs = bottomUpGraph->GetInteriorBlocks(n);
882 for(i = 0; i < intgraphs.size(); ++i)
884 int GlobIdOffset = intgraphs[i]->GetIdOffset();
885 bool SetEdge =
false;
887 for(j = 0; j < intgraphs[i]->GetNverts(); ++j)
890 if(HomGraphEdgeIdToEdgeId.count(GlobIdOffset+j) != 0)
892 edgeId = HomGraphEdgeIdToEdgeId[GlobIdOffset+j];
894 for(k = 0; k < 2; ++k)
897 elmtid = EdgeIdToElmts[edgeId][k];
901 mapIt = ElmtInBndry.find(elmtid);
903 if(mapIt != ElmtInBndry.end())
906 int GlobIdOffset1 = bndgraphs[mapIt->second]->GetIdOffset();
907 for(
int l = 0; l < bndgraphs[mapIt->second]->GetNverts(); ++l)
910 if(HomGraphEdgeIdToEdgeId.count(GlobIdOffset1+l) != 0)
919 AddMeanPressureToEdgeId[elmtid] = defedge;
941 for(j = 0; j < intgraphs[i]->GetNverts(); ++j)
943 if(HomGraphEdgeIdToEdgeId.count(GlobIdOffset+j) != 0)
945 edgeId = HomGraphEdgeIdToEdgeId[GlobIdOffset+j];
946 for(k = 0; k < 2; ++k)
949 elmtid = EdgeIdToElmts[edgeId][k];
962 if(AddMeanPressureToEdgeId[elmtid] == -1)
964 AddMeanPressureToEdgeId[elmtid] = defedge;