50     namespace MultiRegions
 
   54           m_bndCondExpansions(),
 
   62             const bool            DeclareCoeffPhysArrays)
 
   64               m_bndCondExpansions  (In.m_bndCondExpansions),
 
   65               m_bndConditions      (In.m_bndConditions),
 
   66               m_globalBndMat       (In.m_globalBndMat),
 
   67               m_traceMap           (In.m_traceMap),
 
   68               m_boundaryEdges      (In.m_boundaryEdges),
 
   69               m_periodicVerts      (In.m_periodicVerts),
 
   70               m_periodicEdges      (In.m_periodicEdges),
 
   71               m_periodicFwdCopy    (In.m_periodicFwdCopy),
 
   72               m_periodicBwdCopy    (In.m_periodicBwdCopy),
 
   73               m_leftAdjacentEdges  (In.m_leftAdjacentEdges)
 
   78                     *boost::dynamic_pointer_cast<ExpList1D>(In.
m_trace),
 
   79                     DeclareCoeffPhysArrays);
 
   86             const std::string                          &variable,
 
   87             const bool                                  SetUpJustDG,
 
   88             const bool                                  DeclareCoeffPhysArrays)
 
   89             : 
ExpList2D(pSession,graph2D,DeclareCoeffPhysArrays,variable),
 
   90               m_bndCondExpansions(),
 
   99             if(variable.compare(
"DefaultVar") != 0) 
 
  103                                                    DeclareCoeffPhysArrays);
 
  105                 if (DeclareCoeffPhysArrays)
 
  122                 Array<OneD, int> ElmtID, EdgeID;
 
  131                     for(e = 0; e < locExpList->GetExpSize(); ++e)
 
  134                                 (*m_exp)[ElmtID[cnt+e]]->
 
  135                                         as<LocalRegions::Expansion2D>();
 
  137                                 locExpList->GetExp(e)->
 
  138                                         as<LocalRegions::Expansion1D>();
 
  140                                 locExpList->GetExp(e)->
 
  141                                         as<LocalRegions::Expansion>  ();
 
  143                         exp2d->SetEdgeExp(EdgeID[cnt+e], exp);
 
  144                         exp1d->SetAdjacentElementExp(EdgeID[cnt+e], exp2d);
 
  149                 if(
m_session->DefinesSolverInfo(
"PROJECTION"))
 
  151                     std::string ProjectStr =
 
  153                     if((ProjectStr == 
"MixedCGDG") ||
 
  154                        (ProjectStr == 
"Mixed_CG_Discontinuous"))
 
  176             const std::string                        &variable,
 
  177             const bool                                SetUpJustDG,
 
  178             const bool                                DeclareCoeffPhysArrays)
 
  184             if(variable.compare(
"DefaultVar") != 0)
 
  189                 if (DeclareCoeffPhysArrays)
 
  207                         Array<OneD, int> ElmtID,EdgeID;
 
  217                             for(e = 0; e < locExpList->GetExpSize(); ++e)
 
  220                                     = (*m_exp)[ElmtID[cnt+e]]->
 
  221                                     as<LocalRegions::Expansion2D>();
 
  223                                     = locExpList->GetExp(e)->
 
  224                                     as<LocalRegions::Expansion1D>();
 
  226                                     = locExpList->GetExp(e)->
 
  227                                     as<LocalRegions::Expansion>  ();
 
  229                                 exp2d->SetEdgeExp(EdgeID[cnt+e],exp);
 
  230                                 exp1d->SetAdjacentElementExp(EdgeID[cnt+e],exp2d);
 
  236                         if(
m_session->DefinesSolverInfo(
"PROJECTION"))
 
  238                             std::string ProjectStr =
 
  241                             if((ProjectStr == 
"MixedCGDG") ||
 
  242                                (ProjectStr == 
"Mixed_CG_Discontinuous"))
 
  285                         Array<OneD, int> ElmtID, EdgeID;
 
  295                             for(e = 0; e < locExpList->GetExpSize(); ++e)
 
  298                                     = (*m_exp)[ElmtID[cnt+e]]->
 
  299                                     as<LocalRegions::Expansion2D>();
 
  301                                     = locExpList->GetExp(e)->
 
  302                                     as<LocalRegions::Expansion1D>();
 
  304                                     = locExpList->GetExp(e)->
 
  305                                     as<LocalRegions::Expansion>  ();
 
  307                                 exp2d->SetEdgeExp(EdgeID[cnt+e],exp);
 
  308                                 exp1d->SetAdjacentElementExp(EdgeID[cnt+e],exp2d);
 
  330                      "Routine currently only tested for HybridDGHelmholtz");
 
  333                      "The local to global map is not set up for the requested " 
  342                 (*m_globalBndMat)[mkey] = glo_matrix;
 
  346                 glo_matrix = matrixIter->second;
 
  384             Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
 
  385                 &elmtToTrace = m_traceMap->GetElmtToTrace();
 
  392             for (
int i = 0; i < 
m_exp->size(); ++i)
 
  394                 for (
int j = 0; j < (*m_exp)[i]->GetNedges(); ++j)
 
  402                     exp2d->SetEdgeExp           (j, exp  );
 
  403                     exp1d->SetAdjacentElementExp(j, exp2d);
 
  411             for (
int i = 0; i < 
m_trace->GetExpSize(); ++i)
 
  416                 int offset      = 
m_trace->GetPhys_Offset(i);
 
  417                 int traceGeomId = traceEl->GetGeom1D()->GetGlobalID();
 
  423                     if (traceGeomId != min(pIt->second[0].id, traceGeomId))
 
  425                         traceEl->GetLeftAdjacentElementExp()->NegateEdgeNormal(
 
  426                             traceEl->GetLeftAdjacentElementEdge());
 
  429                 else if (m_traceMap->GetTraceToUniversalMapUnique(offset) < 0)
 
  431                     traceEl->GetLeftAdjacentElementExp()->NegateEdgeNormal(
 
  432                         traceEl->GetLeftAdjacentElementEdge());
 
  447                             m_traceMap->GetBndCondTraceToGlobalTraceMap(cnt+e));
 
  454             boost::unordered_map<int,pair<int,int> > perEdgeToExpMap;
 
  455             boost::unordered_map<int,pair<int,int> >
::iterator it2;
 
  456             for (cnt = n = 0; n < 
m_exp->size(); ++n)
 
  458                 for (e = 0; e < (*m_exp)[n]->GetNedges(); ++e, ++cnt)
 
  461                         (*
m_exp)[n]->GetGeom()->GetEid(e));
 
  465                         perEdgeToExpMap[it->first] = make_pair(n, e);
 
  473             for (
int i = 0; i < 
m_exp->size(); ++i)
 
  475                 for (
int j = 0; j < (*m_exp)[i]->GetNedges(); ++j, ++cnt)
 
  483             for (
int n = 0; n < 
m_exp->size(); ++n)
 
  485                 for (
int e = 0; e < (*m_exp)[n]->GetNedges(); ++e, ++cnt)
 
  487                     int edgeGeomId = (*m_exp)[n]->GetGeom()->GetEid(e);
 
  488                     int offset = 
m_trace->GetPhys_Offset(
 
  489                         elmtToTrace[n][e]->GetElmtId());
 
  497                         it2 = perEdgeToExpMap.find(ent.
id);
 
  499                         if (it2 == perEdgeToExpMap.end())
 
  501                             if (
m_session->GetComm()->GetRowComm()->GetSize() > 1 &&
 
  508                                 ASSERTL1(
false, 
"Periodic edge not found!");
 
  513                                  "Periodic edge in non-forward space?");
 
  515                         int offset2 = 
m_trace->GetPhys_Offset(
 
  516                             elmtToTrace[it2->second.first][it2->second.second]->
 
  521                         int nquad = elmtToTrace[n][e]->GetNumPoints(0);
 
  523                         vector<int> tmpBwd(nquad);
 
  524                         vector<int> tmpFwd(nquad);
 
  528                             for (
int i = 0; i < nquad; ++i)
 
  530                                 tmpBwd[i] = offset2 + i;
 
  531                                 tmpFwd[i] = offset  + i;
 
  536                             for (
int i = 0; i < nquad; ++i)
 
  538                                 tmpBwd[i] = offset2 + i;
 
  539                                 tmpFwd[i] = offset  + nquad - i - 1;
 
  543                         for (
int i = 0; i < nquad; ++i)
 
  563             bool returnval = 
true;
 
  583             int vSame = (returnval?1:0);
 
  607             const std::string &variable,
 
  608             const bool DeclareCoeffPhysArrays)
 
  617             SpatialDomains::BoundaryRegionCollection::const_iterator it;
 
  620             for (it = bregions.begin(); it != bregions.end(); ++it)
 
  631                 Array<OneD, MultiRegions::ExpListSharedPtr>(cnt);
 
  633                 Array<OneD, SpatialDomains::BoundaryConditionShPtr>(cnt);
 
  638             for (it = bregions.begin(); it != bregions.end(); ++it)
 
  646                                             DeclareCoeffPhysArrays, variable);
 
  649                     if(bc->GetBoundaryConditionType() != 
 
  656                     m_bndConditions[cnt]      = bc;
 
  658                         m_bndConditions[cnt++]->GetUserDefined();
 
  681             const std::string                        &variable)
 
  688                 = boost::dynamic_pointer_cast<
 
  690             SpatialDomains::BoundaryRegionCollection::const_iterator it;
 
  704             map<int,int>                     perComps;
 
  705             map<int,vector<int> >            allVerts;
 
  707             map<int,StdRegions::Orientation> allEdges;
 
  709             int region1ID, region2ID, i, j, k, cnt;
 
  713             for(i = 0; i < (*m_exp).size(); ++i)
 
  715                 for(j = 0; j < (*m_exp)[i]->GetNverts(); ++j)
 
  717                     int id = (*m_exp)[i]->GetGeom()->GetVid(j);
 
  723             for (it = bregions.begin(); it != bregions.end(); ++it)
 
  726                     bconditions, it->first, variable);
 
  728                 if (locBCond->GetBoundaryConditionType()
 
  735                 region1ID = it->first;
 
  736                 region2ID = boost::static_pointer_cast<
 
  738                         locBCond)->m_connectedBoundaryRegion;
 
  743                 if (vComm->GetSize() == 1)
 
  745                     cId1 = it->second->begin()->first;
 
  746                     cId2 = bregions.find(region2ID)->second->begin()->first;
 
  750                     cId1 = bndRegOrder.find(region1ID)->second[0];
 
  751                     cId2 = bndRegOrder.find(region2ID)->second[0];
 
  755                          "Boundary region "+boost::lexical_cast<
string>(
 
  756                              region1ID)+
" should only contain 1 composite.");
 
  761                 vector<unsigned int> tmpOrder;
 
  763                 for (i = 0; i < c->size(); ++i)
 
  766                         boost::dynamic_pointer_cast<
 
  768                     ASSERTL0(segGeom, 
"Unable to cast to shared ptr");
 
  771                         graph2D->GetElementsFromEdge(segGeom);
 
  773                              "The periodic boundaries belong to " 
  774                              "more than one element of the mesh");
 
  778                             (*elmt)[0]->m_Element);
 
  780                     allEdges[(*c)[i]->GetGlobalID()] = 
 
  781                         geom->GetEorient((*elmt)[0]->m_EdgeIndx);
 
  785                     if (vComm->GetSize() == 1)
 
  787                         tmpOrder.push_back((*c)[i]->GetGlobalID());
 
  790                     vector<int> vertList(2);
 
  791                     vertList[0] = segGeom->GetVid(0);
 
  792                     vertList[1] = segGeom->GetVid(1);
 
  793                     allVerts[(*c)[i]->GetGlobalID()] = vertList;
 
  796                 if (vComm->GetSize() == 1)
 
  798                     compOrder[it->second->begin()->first] = tmpOrder;
 
  803                 if (perComps.count(cId1) == 0)
 
  805                     if (perComps.count(cId2) == 0)
 
  807                         perComps[cId1] = cId2;
 
  811                         std::stringstream ss;
 
  812                         ss << 
"Boundary region " << cId2 << 
" should be " 
  813                            << 
"periodic with " << perComps[cId2] << 
" but " 
  814                            << 
"found " << cId1 << 
" instead!";
 
  815                         ASSERTL0(perComps[cId2] == cId1, ss.str());
 
  820                     std::stringstream ss;
 
  821                     ss << 
"Boundary region " << cId1 << 
" should be " 
  822                        << 
"periodic with " << perComps[cId1] << 
" but " 
  823                        << 
"found " << cId2 << 
" instead!";
 
  824                     ASSERTL0(perComps[cId1] == cId1, ss.str());
 
  829             int              n = vComm->GetSize();
 
  830             int              p = vComm->GetRank();
 
  832             Array<OneD, int> edgecounts(n,0);
 
  833             Array<OneD, int> edgeoffset(n,0);
 
  834             Array<OneD, int> vertoffset(n,0);
 
  836             edgecounts[p] = allEdges.size();
 
  840             for (i = 1; i < n; ++i)
 
  842                 edgeoffset[i] = edgeoffset[i-1] + edgecounts[i-1];
 
  846             Array<OneD, int> edgeIds   (totEdges, 0);
 
  847             Array<OneD, int> edgeOrient(totEdges, 0);
 
  848             Array<OneD, int> edgeVerts (totEdges, 0);
 
  852             for (i = 0, sIt = allEdges.begin(); sIt != allEdges.end(); ++sIt)
 
  854                 edgeIds   [edgeoffset[p] + i  ] = sIt->first;
 
  855                 edgeOrient[edgeoffset[p] + i  ] = sIt->second;
 
  856                 edgeVerts [edgeoffset[p] + i++] = allVerts[sIt->first].size();
 
  864             Array<OneD, int> procVerts(n,0);
 
  878             for (i = 0; i < n; ++i)
 
  880                 if (edgecounts[i] > 0)
 
  883                         edgecounts[i], edgeVerts + edgeoffset[i], 1);
 
  892             for (i = 1; i < n; ++i)
 
  894                 vertoffset[i] = vertoffset[i-1] + procVerts[i-1];
 
  897             Array<OneD, int> vertIds(nTotVerts, 0);
 
  898             for (i = 0, sIt = allEdges.begin(); sIt != allEdges.end(); ++sIt)
 
  900                 for (j = 0; j < allVerts[sIt->first].size(); ++j)
 
  902                     vertIds[vertoffset[p] + i++] = allVerts[sIt->first][j];
 
  909             map<int, StdRegions::Orientation> orientMap;
 
  910             map<int, vector<int> >            vertMap;
 
  912             for (cnt = i = 0; i < totEdges; ++i)
 
  914                 ASSERTL0(orientMap.count(edgeIds[i]) == 0,
 
  915                          "Already found edge in orientation map!");
 
  918                 vector<int> verts(edgeVerts[i]);
 
  920                 for (j = 0; j < edgeVerts[i]; ++j)
 
  922                     verts[j] = vertIds[cnt++];
 
  924                 vertMap[edgeIds[i]] = verts;
 
  931             map<int,int>::const_iterator oIt;
 
  933             map<int,int> allCompPairs;
 
  942             for (cIt = perComps.begin(); cIt != perComps.end(); ++cIt)
 
  945                 const int   id1  = cIt->first;
 
  946                 const int   id2  = cIt->second;
 
  947                 std::string id1s = boost::lexical_cast<
string>(id1);
 
  948                 std::string id2s = boost::lexical_cast<
string>(id2);
 
  950                 if (compMap.count(id1) > 0)
 
  955                 if (compMap.count(id2) > 0)
 
  961                          "Both composites not found on this process!");
 
  966                 map<int,int> compPairs;
 
  969                          "Unable to find composite "+id1s+
" in order map.");
 
  971                          "Unable to find composite "+id2s+
" in order map.");
 
  972                 ASSERTL0(compOrder[id1].size() == compOrder[id2].size(),
 
  973                          "Periodic composites "+id1s+
" and "+id2s+
 
  974                          " should have the same number of elements.");
 
  976                          "Periodic composites "+id1s+
" and "+id2s+
 
  980                 for (i = 0; i < compOrder[id1].size(); ++i)
 
  982                     int eId1 = compOrder[id1][i];
 
  983                     int eId2 = compOrder[id2][i];
 
  985                     ASSERTL0(compPairs.count(eId1) == 0,
 
  988                     if (compPairs.count(eId2) != 0)
 
  990                         ASSERTL0(compPairs[eId2] == eId1, 
"Pairing incorrect");
 
  992                     compPairs[eId1] = eId2;
 
  999                 for (i = 0; i < 2; ++i)
 
 1006                     if (c[i]->size() > 0)
 
 1008                         for (j = 0; j < c[i]->size(); ++j)
 
 1010                             locEdges.insert(c[i]->at(j)->GetGlobalID());
 
 1016                 for (pIt = compPairs.begin(); pIt != compPairs.end(); ++pIt)
 
 1018                     int  ids  [2] = {pIt->first, pIt->second};
 
 1019                     bool local[2] = {locEdges.count(pIt->first) > 0,
 
 1020                                      locEdges.count(pIt->second) > 0};
 
 1022                     ASSERTL0(orientMap.count(ids[0]) > 0 &&
 
 1023                              orientMap.count(ids[1]) > 0,
 
 1024                              "Unable to find edge in orientation map.");
 
 1026                     allCompPairs[pIt->first ] = pIt->second;
 
 1027                     allCompPairs[pIt->second] = pIt->first;
 
 1029                     for (i = 0; i < 2; ++i)
 
 1036                         int other = (i+1) % 2;
 
 1039                             orientMap[ids[i]] == orientMap[ids[other]] ?
 
 1048                     for (i = 0; i < 2; ++i)
 
 1050                         int other = (i+1) % 2;
 
 1053                             orientMap[ids[i]] == orientMap[ids[other]] ?
 
 1058                         vector<int> perVerts1 = vertMap[ids[i]];
 
 1059                         vector<int> perVerts2 = vertMap[ids[other]];
 
 1061                         map<int, pair<int, bool> > tmpMap;
 
 1065                             tmpMap[perVerts1[0]] = make_pair(
 
 1066                                 perVerts2[0], locVerts.count(perVerts2[0]) > 0);
 
 1067                             tmpMap[perVerts1[1]] = make_pair(
 
 1068                                 perVerts2[1], locVerts.count(perVerts2[1]) > 0);
 
 1072                             tmpMap[perVerts1[0]] = make_pair(
 
 1073                                 perVerts2[1], locVerts.count(perVerts2[1]) > 0);
 
 1074                             tmpMap[perVerts1[1]] = make_pair(
 
 1075                                 perVerts2[0], locVerts.count(perVerts2[0]) > 0);
 
 1078                         for (mIt = tmpMap.begin(); mIt != tmpMap.end(); ++mIt)
 
 1083                                                 mIt->second.second);
 
 1087                             if (perIt == periodicVerts.end())
 
 1089                                 periodicVerts[mIt->first].push_back(ent2);
 
 1090                                 perIt = periodicVerts.find(mIt->first);
 
 1095                                 for (j = 0; j < perIt->second.size(); ++j)
 
 1097                                     if (perIt->second[j].id == mIt->second.first)
 
 1106                                     perIt->second.push_back(ent2);
 
 1114             Array<OneD, int> pairSizes(n, 0);
 
 1115             pairSizes[p] = allCompPairs.size();
 
 1120             Array<OneD, int> pairOffsets(n, 0);
 
 1123             for (i = 1; i < n; ++i)
 
 1125                 pairOffsets[i] = pairOffsets[i-1] + pairSizes[i-1];
 
 1128             Array<OneD, int> first (totPairSizes, 0);
 
 1129             Array<OneD, int> second(totPairSizes, 0);
 
 1131             cnt = pairOffsets[p];
 
 1133             for (pIt = allCompPairs.begin(); pIt != allCompPairs.end(); ++pIt)
 
 1135                 first [cnt  ] = pIt->first;
 
 1136                 second[cnt++] = pIt->second;
 
 1142             allCompPairs.clear();
 
 1144             for(cnt = 0; cnt < totPairSizes; ++cnt)
 
 1146                 allCompPairs[first[cnt]] = second[cnt];
 
 1152             for (cnt = i = 0; i < totEdges; ++i)
 
 1154                 int edgeId    = edgeIds[i];
 
 1156                 ASSERTL0(allCompPairs.count(edgeId) > 0,
 
 1157                          "Unable to find matching periodic edge.");
 
 1159                 int perEdgeId = allCompPairs[edgeId];
 
 1161                 for (j = 0; j < edgeVerts[i]; ++j, ++cnt)
 
 1163                     int vId = vertIds[cnt];
 
 1167                     if (perId == periodicVerts.end())
 
 1174                             orientMap[edgeId] == orientMap[perEdgeId] ?
 
 1175                             vertMap[perEdgeId][(j+1)%2] : vertMap[perEdgeId][j];
 
 1179                                            locVerts.count(perVertexId) > 0);
 
 1181                         periodicVerts[vId].push_back(ent);
 
 1189             for (perIt  = periodicVerts.begin();
 
 1190                  perIt != periodicVerts.end(); ++perIt)
 
 1193                 for (i = 0; i < perIt->second.size(); ++i)
 
 1195                     perIt2 = periodicVerts.find(perIt->second[i].id);
 
 1196                     ASSERTL0(perIt2 != periodicVerts.end(),
 
 1197                              "Couldn't find periodic vertex.");
 
 1199                     for (j = 0; j < perIt2->second.size(); ++j)
 
 1201                         if (perIt2->second[j].id == perIt->first)
 
 1207                         for (k = 0; k < perIt->second.size(); ++k)
 
 1209                             if (perIt2->second[j].id == perIt->second[k].id)
 
 1218                             perIt->second.push_back(perIt2->second[j]);
 
 1226             for (perIt  = periodicVerts.begin();
 
 1227                  perIt != periodicVerts.end(); ++perIt)
 
 1229                 if (locVerts.count(perIt->first) > 0)
 
 1241                             as<LocalRegions::Expansion1D>();
 
 1245             if (traceEl->GetLeftAdjacentElementEdge () == -1 ||
 
 1246                 traceEl->GetRightAdjacentElementEdge() == -1)
 
 1256                     int traceGeomId = traceEl->GetGeom1D()->GetGlobalID();
 
 1262                         fwd = traceGeomId == min(traceGeomId,pIt->second[0].id);
 
 1266                         int offset = 
m_trace->GetPhys_Offset(traceEl->GetElmtId());
 
 1269                             GetTraceToUniversalMapUnique(offset) >= 0;
 
 1273             else if (traceEl->GetLeftAdjacentElementEdge () != -1 &&
 
 1274                      traceEl->GetRightAdjacentElementEdge() != -1)
 
 1278                     (traceEl->GetLeftAdjacentElementExp().get()) ==
 
 1283                 ASSERTL2(
false, 
"Unconnected trace element!");
 
 1294             Array<OneD, NekDouble> &Fwd,
 
 1295             Array<OneD, NekDouble> &Bwd)
 
 1326             const Array<OneD, const NekDouble> &field,
 
 1327                   Array<OneD,       NekDouble> &Fwd,
 
 1328                   Array<OneD,       NekDouble> &Bwd)
 
 1332             int cnt, n, e, 
npts, phys_offset;
 
 1333             Array<OneD,NekDouble> e_tmp;
 
 1335             boost::unordered_map<int,pair<int,int> >
::iterator it3;
 
 1338             Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
 
 1345             for(cnt = n = 0; n < nexp; ++n)
 
 1350                 for(e = 0; e < exp2d->GetNedges(); ++e, ++cnt)
 
 1352                     int offset = 
m_trace->GetPhys_Offset(
 
 1353                         elmtToTrace[n][e]->GetElmtId());
 
 1357                         exp2d->GetEdgePhysVals(e, elmtToTrace[n][e],
 
 1358                                                      field + phys_offset,
 
 1359                                                      e_tmp = Fwd + offset);
 
 1363                         exp2d->GetEdgePhysVals(e, elmtToTrace[n][e],
 
 1364                                                      field + phys_offset,
 
 1365                                                      e_tmp = Bwd + offset);
 
 1382                         id2  = 
m_trace->GetPhys_Offset(
 
 1383                             m_traceMap->GetBndCondTraceToGlobalTraceMap(cnt+e));
 
 1401                                  "Method not set up for non-zero Neumann " 
 1402                                  "boundary condition");
 
 1403                         id2  = 
m_trace->GetPhys_Offset(
 
 1404                             m_traceMap->GetBndCondTraceToGlobalTraceMap(cnt+e));
 
 1414                              "Method not set up for this boundary condition.");
 
 1435             Array<OneD, NekDouble> &outarray)
 
 1438                      "Field must be in physical state to extract trace space.");
 
 1455             const Array<OneD, const NekDouble> &inarray, 
 
 1456                   Array<OneD,       NekDouble> &outarray)
 
 1460             int n, e, offset, phys_offset;
 
 1461             Array<OneD,NekDouble> e_tmp;
 
 1462             Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
 
 1466                      "input array is of insufficient length");
 
 1469             for(n  = 0; n < nexp; ++n)
 
 1473                 for(e = 0; e < (*m_exp)[n]->GetNedges(); ++e)
 
 1475                     offset = 
m_trace->GetPhys_Offset(
 
 1476                         elmtToTrace[n][e]->GetElmtId());
 
 1477                     (*m_exp)[n]->GetEdgePhysVals(e,  elmtToTrace[n][e],
 
 1478                                                  inarray + phys_offset,
 
 1479                                                  e_tmp = outarray + offset);
 
 1485             const Array<OneD, const NekDouble> &Fx,
 
 1486             const Array<OneD, const NekDouble> &Fy,
 
 1487                   Array<OneD,       NekDouble> &outarray)
 
 1489             int e, n, offset, t_offset;
 
 1490             Array<OneD, NekDouble> e_outarray;
 
 1491             Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
 
 1497                 for(e = 0; e < (*m_exp)[n]->GetNedges(); ++e)
 
 1499                     t_offset = 
GetTrace()->GetPhys_Offset(
 
 1500                         elmtToTrace[n][e]->GetElmtId());
 
 1502                     (*m_exp)[n]->AddEdgeNormBoundaryInt(
 
 1503                         e,elmtToTrace[n][e],
 
 1506                         e_outarray = outarray+offset);
 
 1529             const Array<OneD, const NekDouble> &Fn, 
 
 1530                   Array<OneD,       NekDouble> &outarray)
 
 1532             int e, n, offset, t_offset;
 
 1533             Array<OneD, NekDouble> e_outarray;
 
 1534             Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
 
 1540                 for(e = 0; e < (*m_exp)[n]->GetNedges(); ++e)
 
 1542                     t_offset = 
GetTrace()->GetPhys_Offset(
 
 1543                         elmtToTrace[n][e]->GetElmtId());
 
 1544                     (*m_exp)[n]->AddEdgeNormBoundaryInt(
 
 1545                         e, elmtToTrace[n][e], Fn+t_offset,
 
 1546                         e_outarray = outarray+offset);
 
 1575             const Array<OneD, const NekDouble> &Fwd, 
 
 1576             const Array<OneD, const NekDouble> &Bwd, 
 
 1577                   Array<OneD,       NekDouble> &outarray)
 
 1579             int e,n,offset, t_offset;
 
 1580             Array<OneD, NekDouble> e_outarray;
 
 1581             Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
 
 1587                 for (e = 0; e < (*m_exp)[n]->GetNedges(); ++e)
 
 1589                     t_offset = 
GetTrace()->GetPhys_Offset(
 
 1590                                             elmtToTrace[n][e]->GetElmtId());
 
 1595                         (*m_exp)[n]->AddEdgeNormBoundaryInt(
 
 1596                         e, elmtToTrace[n][e], Fwd+t_offset,
 
 1597                         e_outarray = outarray+offset);
 
 1601                         (*m_exp)[n]->AddEdgeNormBoundaryInt(
 
 1602                         e, elmtToTrace[n][e], Bwd+t_offset,
 
 1603                         e_outarray = outarray+offset);
 
 1615             Array<OneD, int> &ElmtID, 
 
 1616             Array<OneD, int> &EdgeID)
 
 1618             map<int, int> globalIdMap;
 
 1631                 globalIdMap[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
 
 1641             if(ElmtID.num_elements() != nbcs)
 
 1643                 ElmtID = Array<OneD, int>(nbcs);
 
 1646             if(EdgeID.num_elements() != nbcs)
 
 1648                 EdgeID = Array<OneD, int>(nbcs);
 
 1658                                         as<LocalRegions::Expansion1D>();
 
 1661                         graph2D->GetElementsFromEdge(exp1d->GetGeom1D());
 
 1663                     ElmtID[cnt] = globalIdMap[(*tmp)[0]->
 
 1664                         m_Element->GetGlobalID()];
 
 1665                     EdgeID[cnt] = (*tmp)[0]->m_EdgeIndx;
 
 1682             const Array<OneD, const NekDouble> &soln)
 
 1684             int    i,e,ncoeff_edge;
 
 1685             Array<OneD, const NekDouble> tmp_coeffs;
 
 1686             Array<OneD, NekDouble> out_d(
m_ncoeffs), out_tmp;
 
 1688             Array<OneD, Array< OneD, StdRegions::StdExpansionSharedPtr> > 
 
 1694             int     LocBndCoeffs = 
m_traceMap->GetNumLocalBndCoeffs();
 
 1695             Array<OneD, NekDouble> loc_lambda(LocBndCoeffs), edge_lambda;
 
 1698             edge_lambda = loc_lambda;
 
 1708                 int nEdges = (*m_exp)[i]->GetNedges();
 
 1709                 Array<OneD, Array<OneD, NekDouble> > edgeCoeffs(nEdges);
 
 1711                 for(e = 0; e < nEdges; ++e)
 
 1713                     edgedir = (*m_exp)[eid]->GetEorient(e);
 
 1714                     ncoeff_edge = elmtToTrace[eid][e]->GetNcoeffs();
 
 1715                     edgeCoeffs[e] = Array<OneD, NekDouble>(ncoeff_edge);
 
 1716                     Vmath::Vcopy(ncoeff_edge, edge_lambda, 1, edgeCoeffs[e], 1);
 
 1717                     elmtToTrace[eid][e]->SetCoeffsToOrientation(
 
 1718                         edgedir, edgeCoeffs[e], edgeCoeffs[e]);
 
 1719                     edge_lambda = edge_lambda + ncoeff_edge;
 
 1722                 (*m_exp)[eid]->DGDeriv(dir,
 
 1726                                        out_tmp = out_d+cnt);
 
 1727                 cnt  += (*m_exp)[eid]->GetNcoeffs();
 
 1736                 const Array<OneD, const NekDouble> &inarray,
 
 1737                       Array<OneD,       NekDouble> &outarray,
 
 1741                 const Array<OneD, const NekDouble> &dirForcing)
 
 1743             int i,j,n,cnt,cnt1,nbndry;
 
 1749             Array<OneD,NekDouble> e_f, e_l;
 
 1760             int GloBndDofs   = 
m_traceMap->GetNumGlobalBndCoeffs();
 
 1761             int NumDirichlet = 
m_traceMap->GetNumLocalDirBndCoeffs();
 
 1772             Array<OneD,NekDouble> BndSol = 
m_trace->UpdateCoeffs();
 
 1775             Array<OneD,NekDouble> BndRhs(GloBndDofs,0.0);
 
 1782             int     LocBndCoeffs = 
m_traceMap->GetNumLocalBndCoeffs();
 
 1783             Array<OneD, NekDouble> loc_lambda(LocBndCoeffs);
 
 1791             for(cnt = cnt1 = n = 0; n < nexp; ++n)
 
 1797                 e_l       = loc_lambda + cnt1;
 
 1804                 Floc = 
Transpose(*(HDGLamToU->GetBlock(n,n)))*ElmtFce;
 
 1823                         id = 
m_traceMap->GetBndCondCoeffsToGlobalCoeffsMap(cnt++);
 
 1832                         id = 
m_traceMap->GetBndCondCoeffsToGlobalCoeffsMap(cnt++);
 
 1842             if(GloBndDofs - NumDirichlet > 0)
 
 1861             m_traceMap->GlobalToLocalBnd(BndSol,loc_lambda);
 
 1864             out = (*InvHDGHelm)*F + (*HDGLamToU)*LocLambda;
 
 1878                const Array<OneD,const NekDouble> &inarray,
 
 1879                Array<OneD,      NekDouble> &outarray,
 
 1882             int     LocBndCoeffs = 
m_traceMap->GetNumLocalBndCoeffs();
 
 1883             Array<OneD, NekDouble> loc_lambda(LocBndCoeffs);
 
 1887             m_traceMap->GlobalToLocalBnd(inarray, loc_lambda);
 
 1888             LocLambda = (*HDGHelm) * LocLambda;
 
 1889             m_traceMap->AssembleBnd(loc_lambda,outarray);
 
 1907             map<int, RobinBCInfoSharedPtr> returnval;
 
 1908             Array<OneD, int> ElmtID,EdgeID;
 
 1919                     Array<OneD, NekDouble> Array_tmp;
 
 1923                     for(e = 0; e < locExpList->GetExpSize(); ++e)
 
 1928                                 Array_tmp = locExpList->GetPhys() + 
 
 1929                                             locExpList->GetPhys_Offset(e));
 
 1930                         elmtid = ElmtID[cnt+e];
 
 1932                         if(returnval.count(elmtid) != 0)
 
 1934                             rInfo->next = returnval.find(elmtid)->second;
 
 1936                         returnval[elmtid] = rInfo;
 
 1966             Array<OneD, NekDouble> &outarray)
 
 1968             int    i,cnt,e,ncoeff_edge;
 
 1969             Array<OneD, NekDouble> force, out_tmp, qrhs, qrhs1;
 
 1970             Array<OneD, Array< OneD, StdRegions::StdExpansionSharedPtr> > 
 
 1975             int     eid,nq_elmt, nm_elmt;
 
 1976             int     LocBndCoeffs = 
m_traceMap->GetNumLocalBndCoeffs();
 
 1977             Array<OneD, NekDouble> loc_lambda(LocBndCoeffs), edge_lambda;
 
 1978             Array<OneD, NekDouble> tmp_coeffs;
 
 1981             edge_lambda = loc_lambda;
 
 1988                 nq_elmt = (*m_exp)[eid]->GetTotPoints();
 
 1989                 nm_elmt = (*m_exp)[eid]->GetNcoeffs();
 
 1990                 qrhs  = Array<OneD, NekDouble>(nq_elmt);
 
 1991                 qrhs1  = Array<OneD, NekDouble>(nq_elmt);
 
 1992                 force = Array<OneD, NekDouble>(2*nm_elmt);
 
 1993                 out_tmp = force + nm_elmt;
 
 1996                 int num_points0 = (*m_exp)[eid]->GetBasis(0)->GetNumPoints();
 
 1997                 int num_points1 = (*m_exp)[eid]->GetBasis(1)->GetNumPoints();
 
 1998                 int num_modes0 = (*m_exp)[eid]->GetBasis(0)->GetNumModes();
 
 1999                 int num_modes1 = (*m_exp)[eid]->GetBasis(1)->GetNumModes();
 
 2004                 int nEdges = (*m_exp)[i]->GetNedges();
 
 2005                 Array<OneD, Array<OneD, NekDouble> > edgeCoeffs(nEdges);
 
 2007                 for(e = 0; e < (*m_exp)[eid]->GetNedges(); ++e)
 
 2009                     edgedir = (*m_exp)[eid]->GetEorient(e);
 
 2010                     ncoeff_edge = elmtToTrace[eid][e]->GetNcoeffs();
 
 2011                     edgeCoeffs[e] = Array<OneD, NekDouble>(ncoeff_edge);
 
 2012                     Vmath::Vcopy(ncoeff_edge, edge_lambda, 1, edgeCoeffs[e], 1);
 
 2013                     elmtToTrace[eid][e]->SetCoeffsToOrientation(
 
 2014                         edgedir, edgeCoeffs[e], edgeCoeffs[e]);
 
 2015                     edge_lambda = edge_lambda + ncoeff_edge;
 
 2043                         ASSERTL0(
false, 
"Wrong shape type, HDG postprocessing is not implemented");
 
 2062                 (*m_exp)[eid]->DGDeriv(
 
 2064                     elmtToTrace[eid], edgeCoeffs, out_tmp);
 
 2065                 (*m_exp)[eid]->BwdTrans(out_tmp,qrhs);
 
 2067                 ppExp->IProductWRTDerivBase(0,qrhs,force);
 
 2071                 (*m_exp)[eid]->DGDeriv(
 
 2073                     elmtToTrace[eid], edgeCoeffs, out_tmp);
 
 2075                 (*m_exp)[eid]->BwdTrans(out_tmp,qrhs);
 
 2077                 ppExp->IProductWRTDerivBase(1,qrhs,out_tmp);
 
 2082                 (*m_exp)[eid]->BwdTrans(
 
 2084                 force[0] = (*m_exp)[eid]->Integral(qrhs);
 
 2097                 Array<OneD, NekDouble> work(nq_elmt);
 
 2098                 ppExp->BwdTrans(out.
GetPtr(), work);
 
 2099                 (*m_exp)[eid]->FwdTrans(work, tmp_coeffs = outarray + 
m_coeff_offset[eid]);
 
 2117             const std::string varName,
 
 2127             for (i = 0; i < nbnd; ++i)
 
 2134                     npoints    = locExpList->GetNpoints();
 
 2135                     Array<OneD, NekDouble> x0(npoints, 0.0);
 
 2136                     Array<OneD, NekDouble> x1(npoints, 0.0);
 
 2137                     Array<OneD, NekDouble> x2(npoints, 0.0);
 
 2142                         locExpList->GetCoords(x0, x1, x2);
 
 2146                         locExpList->GetCoords(x0, x1, x2);
 
 2153                         string filebcs = boost::static_pointer_cast<
 
 2164                                 boost::static_pointer_cast<
 
 2167                                             m_dirichletCondition;
 
 2169                             condition.
Evaluate(x0, x1, x2, time, 
 
 2170                                                locExpList->UpdatePhys());
 
 2173                         locExpList->FwdTrans_BndConstrained(
 
 2174                             locExpList->GetPhys(),
 
 2175                             locExpList->UpdateCoeffs());
 
 2180                         string filebcs = boost::static_pointer_cast<
 
 2191                                 boost::static_pointer_cast<
 
 2195                             condition.
Evaluate(x0, x1, x2, time, 
 
 2196                                                locExpList->UpdatePhys());
 
 2199                         locExpList->IProductWRTBase(
 
 2200                             locExpList->GetPhys(),
 
 2201                             locExpList->UpdateCoeffs());
 
 2206                         string filebcs = boost::static_pointer_cast<
 
 2217                                 boost::static_pointer_cast<
 
 2221                             condition.
Evaluate(x0, x1, x2, time,
 
 2222                                                locExpList->UpdatePhys());
 
 2226                             boost::static_pointer_cast<
 
 2229                         locExpList->IProductWRTBase(
 
 2230                             locExpList->GetPhys(),
 
 2231                             locExpList->UpdateCoeffs());
 
 2236                                        locExpList->UpdatePhys());
 
 2240                         ASSERTL0(
false, 
"This type of BC not implemented yet");