39 #include "petscversion.h"
43 namespace MultiRegions
54 const boost::weak_ptr<ExpList> &pExp,
55 const boost::shared_ptr<AssemblyMap> &pLocToGloMap)
59 PetscInitialize(0, NULL, NULL, NULL);
62 MatCreate(PETSC_COMM_WORLD, &
m_matrix);
81 const Array<OneD,const NekDouble> &pInput,
82 Array<OneD, NekDouble> &pOutput,
86 const int nHomDofs = pNumRows - pNumDir;
90 &pInput[pNumDir], INSERT_VALUES);
93 VecAssemblyBegin(
m_b);
101 INSERT_VALUES, SCATTER_FORWARD);
103 INSERT_VALUES, SCATTER_FORWARD);
124 IS isGlobal, isLocal;
126 PETSC_COPY_VALUES, &isGlobal);
127 ISCreateStride (PETSC_COMM_SELF, nHomDofs, 0, 1, &isLocal);
130 VecCreate (PETSC_COMM_SELF, &
m_locVec);
131 VecSetSizes (
m_locVec, nHomDofs, PETSC_DECIDE);
138 ISDestroy(&isGlobal);
151 const Array<OneD, const int> &glo2uniMap,
152 const Array<OneD, const int> &glo2unique,
156 =
m_expList.lock()->GetSession()->GetComm();
158 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
159 const int nHomDofs = glo2uniMap.num_elements() - nDirDofs;
160 const int nProc = vComm->GetSize();
161 const int rank = vComm->GetRank();
170 Array<OneD, int> localCounts(nProc, 0), localOffset(nProc, 0);
171 localCounts[rank] = nHomDofs;
174 for (n = 1; n < nProc; ++n)
176 localOffset[n] = localOffset[n-1] + localCounts[n-1];
179 int totHomDofs =
Vmath::Vsum(nProc, localCounts, 1);
180 vector<unsigned int> allUniIds(totHomDofs, 0);
183 for (n = 0; n < nHomDofs; ++n)
185 int gid = n + nDirDofs;
186 allUniIds[n + localOffset[rank]] = glo2uniMap[gid];
192 std::sort(allUniIds.begin(), allUniIds.end());
193 map<int,int> uniIdReorder;
196 for (cnt = n = 0; n < allUniIds.size(); ++n)
198 if (uniIdReorder.count(allUniIds[n]) > 0)
203 uniIdReorder[allUniIds[n]] = cnt++;
207 for (n = 0; n < nHomDofs; ++n)
209 int gid = n + nDirDofs;
210 int uniId = glo2uniMap[gid];
211 ASSERTL0(uniIdReorder.count(uniId) > 0,
"Error in ordering");
225 VecCreate (PETSC_COMM_WORLD, &
m_x);
227 VecSetFromOptions(
m_x);
231 MatCreate (PETSC_COMM_WORLD, &
m_matrix);
234 PETSC_DETERMINE, PETSC_DETERMINE);
247 KSPCreate(PETSC_COMM_WORLD, &
m_ksp);
249 m_ksp, tolerance, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT);
250 KSPSetFromOptions(
m_ksp);
251 #if PETSC_VERSION_GE(3,5,0)