'/usr/bin/mpiexec' --allow-run-as-root -np 5 /root/../home/andras/FFinstall/FreeFem-sources/src/mpi/FreeFem++-mpi -nw '../include/PSEsolver.edp' -log_view -DwDir=PSE1 -x1 0.75 -nX 3 -iname c1 -inameBiG c1test -oname c1_2_test -basemeshname m0 -fixGrid 1 -BFD2 1 -enableDamping 1 -normType 1 -linEqSolutionTimer 0 -- FreeFem++ v4.1 (2021. nov. 22., hétfő, 16:21:03 CET - git v4.10-5-gfd0971d2) file : ../include/PSEsolver.edp Load: lg_fem lg_mesh lg_mesh3 parallelempi 1 : load "PETSc-complex" // PETSc plugin 2 : 3 : /* macro required for variable allocation */ 4 : macro newtonianincompressible()//EOM 5 : /* macro required for BiGlobal stability variable allocation */ 6 : macro PSE()//EOM 7 : /* general parameter and macro files */ 8 : include "../include/genpar.idp"/* ################### general parameter file ################### */ 2 : 3 : load "gsl" 4 : load "msh3" 5 : load "ff-NLopt" 6 : 7 : /* some general macros for ff ddm */ 8 : //macro trueRestrict()true// 9 : //macro removeZeros()true// 10 : macro dimension()2// 11 : include "macro_ddm.idp"IFMACRO(!macroDDMidp) 2 & macro macroDDMidp()1// EOM include "getARGV.idp" 3 & IFMACRO(!partitioner) 4 & macro partitioner()metis// EOM ENDIFMACRO IFMACRO(partitioner,metis) 5 & load "metis" 6 & macro partitionerSeq(part, Th, size){ if(size <= 1) part = 0; else metisdual(part, Th, size); }// EOM macro partitionerPar(part, Th, comm, size)broadcast(processor(0, comm), part)// EOM ENDIFMACRO IFMACRO(partitioner,scotch) 7 & load "scotch" 8 & macro partitionerSeq(part, Th, size){ if(size <= 1) part = 0; else scotch(part, Th, size); }// EOM macro partitionerPar(part, Th, comm, size)broadcast(processor(0, comm), part)// EOM ENDIFMACRO IFMACRO(partitioner,parmetis) 9 & load "parmetis" 10 & macro partitionerSeq(part, Th, size)// EOM macro partitionerPar(part, Th, comm, size)parmetis(part, Th, size, communicator = comm, worker = getARGV("-parmetis_worker", 1))// EOM ENDIFMACRO IFMACRO(!partitionerSeq) 11 & cout << "The macro 'partitioner' must be set to 'metis', 'scotch', or 'parmetis'" << endl; 12 & exit(1); 13 & ENDIFMACRO IFMACRO(dimension,2) 14 & macro meshN()mesh// EOM // two-dimensional problem macro intN()int2d// EOM // two-dimensional integral macro intN1()int1d// EOM // one-dimensional integral macro readmeshN()readmesh// EOM // two-dimensional problem macro defVel(u)[u, u#Y]// EOM // two-dimensional velocity for convect/advect ENDIFMACRO IFMACRO(dimension,3) 15 & load "msh3" 16 & macro meshN()mesh3// EOM // three-dimensional problem macro intN()int3d// EOM // three-dimensional integral macro intN1()int2d// EOM // two-dimensional integral macro readmeshN()readmesh3// EOM // three-dimensional problem macro defVel(u)[u, u#Y, u#Z]// EOM // three-dimensional velocity for convect/advect ENDIFMACRO IFMACRO(dimension,3S) 17 & load "msh3" 18 & macro meshN()meshS// EOM // three-dimensional surface problem macro intN()int2d// EOM // two-dimensional integral macro intN1()int1d// EOM // one-dimensional integral macro intNxN()int2dx2d// EOM // two-dimensional integral for BEM ENDIFMACRO IFMACRO(dimension,3L) 19 & load "msh3" 20 & macro meshN()meshL// EOM // three-dimensional line problem macro intN()int1d// EOM // one-dimensional integral macro intN1()int0d// EOM // zero-dimensional integral macro intNxN()int1dx1d// EOM // one-dimensional integral for BEM ENDIFMACRO 21 & macro plotDmesh(Th, params) 22 & if(!NoGraphicWindow || usedARGV("-fglut") != -1) { 23 & fespace PhPlotPrivate(Th, P0); 24 & PhPlotPrivate plt; 25 & if(Th.nt) 26 & plt[] = mpirank; 27 & NewMacro defPlt#Th(u)u EndMacro plotMPI(Th, plt, P0, defPlt#Th, real, params) 28 & }// 29 & 30 & macro plotD(Th, u, params) 31 & if(!NoGraphicWindow || usedARGV("-fglut") != -1) { 32 & fespace VhPlotPrivate(Th, P1); 33 & VhPlotPrivate plt; 34 & if(Th.nt) 35 & plt = u; 36 & NewMacro defPlt#Th(v)v EndMacro plotMPI(Th, plt, P1, defPlt#Th, real, params) 37 & }// 38 & 39 & macro plotMPI(Th, u, Pk, def, K, params) 40 & if(!NoGraphicWindow || usedARGV("-fglut") != -1) { 41 & IFMACRO(!meshN) 42 & NewMacro meshN()mesh EndMacro ENDIFMACRO IFMACRO(!def) 43 & NewMacro def(i)i EndMacro ENDIFMACRO meshN ThCurrent = Th; 44 & fespace XhPlotPrivate(ThCurrent, Pk); 45 & XhPlotPrivate def(uSend); 46 & if(ThCurrent.nt) 47 & def(uSend) = u; 48 & if(mpirank == 0) { 49 & meshN[int] meshTab(mpisize); 50 & XhPlotPrivate[int] def(uTab)(mpisize); 51 & if(ThCurrent.nt) 52 & uTab[0][] = uSend[]; 53 & meshTab[0] = ThCurrent; 54 & mpiRequest[int] rq(mpisize - 1); 55 & for(int i = 1; i < mpisize; ++i) 56 & Irecv(processor(i, mpiCommWorld, rq[i - 1]), meshTab[i]); 57 & mpiWaitAll(rq); 58 & for(int i = 1; i < mpisize; ++i) { 59 & ThCurrent = meshTab[i]; 60 & if(ThCurrent.nt) 61 & Irecv(processor(i, mpiCommWorld, rq[i - 1]), uTab[i][]); 62 & } 63 & mpiWaitAll(rq); 64 & plot(def(uTab), params); 65 & } 66 & else { 67 & mpiRequest[int] rq(2); 68 & Isend(processor(0, rq[0]), ThCurrent); 69 & if(ThCurrent.nt) 70 & Isend(processor(0, rq[1]), uSend[]); 71 & mpiWaitAll(rq); 72 & } 73 & }// EOM 74 & macro partitionPrivate(meshName, borderName, globalName, PhGlobalPrivate, VhGlobalPrivate, part, rank, size, s, overlap, level, prolongation, D, P, intersection, comm, fakeInterface, PkPart, defPart, initPart, bs) { 75 & int backupSM = searchMethod; 76 & searchMethod = 1; 77 & assert(level >= 1); 78 & IFMACRO(!privateCreatePartition) 79 & IFMACRO(!privateCreateMat) 80 & intersection.resize(1); 81 & intersection[0].resize(0); 82 & PhGlobalPrivate supp; 83 & VhGlobalPrivate suppSmooth; 84 & { 85 & int constant = rank; 86 & for[i, v : supp[]] v = abs(part[][i] - constant) < 0.1; 87 & AddLayers(globalName, supp[], 2 * overlap, suppSmooth[]); 88 & int[int] n2o; 89 & meshN neighbors; 90 & bool connected = false; 91 & for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 92 & if(!connected) 93 & n2o.resize(0); 94 & else neighbors = trunc(globalName, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 95 & int[int] partOverlap(n2o.n); 96 & for[i, v : n2o] partOverlap[i] = part[][v]; 97 & Unique(partOverlap, intersection[0], remove = constant); 98 & if(s > 1 && level <= 1) { 99 & globalName = trunc(globalName, suppSmooth > 0.001, split = s); 100 & supp = abs(part - constant) < 0.1; 101 & suppSmooth = 0; 102 & AddLayers(globalName, supp[], 2 * overlap, suppSmooth[]); 103 & } 104 & } 105 & int[int] n2oNeighbor; 106 & IFMACRO(!privateDmesh#CartesianPartitioning) 107 & globalName = trunc(globalName, suppSmooth > 0.001, label = 9999 108 & IFMACRO(privateDmesh#N2O) 109 & , new2old = n2oNeighbor ENDIFMACRO ); 110 & ENDIFMACRO real eps = globalName.measure; 111 & real[int] epsTab(intersection[0].n); 112 & mpiRequest[int] rq(2 * intersection[0].n); 113 & if(mpiSize(comm) == size) { 114 & for(int j = 0; j < intersection[0].n; ++j) 115 & Irecv(processor(intersection[0][j], comm, rq[j]), epsTab[j]); 116 & for(int j = 0; j < intersection[0].n; ++j) 117 & Isend(processor(intersection[0][j], comm, rq[intersection[0].n + j]), eps); 118 & } 119 & else epsTab = 1.0e+30; 120 & suppSmooth = suppSmooth; 121 & IFMACRO(!privateDmesh#N2O) 122 & meshName[level - 1] = trunc(globalName, suppSmooth > 0.501, label = fakeInterface, new2old = n2oNeighbor); 123 & IFMACRO(privateDmesh#CartesianPartitioning) 124 & real[int] bb(2 * dimension); 125 & boundingbox(meshName[level - 1], bb); 126 & meshName[level - 1] = trunc(globalName, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 127 & IFMACRO(dimension,3) 128 & && z > bb[4] && z < bb[5] 129 & ENDIFMACRO , label = fakeInterface); 130 & globalName = meshName[level - 1]; 131 & n2oNeighbor = 0:globalName.nt - 1; 132 & ENDIFMACRO ENDIFMACRO IFMACRO(privateDmesh#N2O) 133 & meshName[level - 1] = trunc(globalName, suppSmooth > 0.501, label = fakeInterface, new2old = privateDmesh#N2O); 134 & IFMACRO(privateDmesh#CartesianPartitioning) 135 & real[int] bb(2 * dimension); 136 & boundingbox(meshName[level - 1], bb); 137 & meshName[level - 1] = trunc(globalName, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 138 & IFMACRO(dimension,3) 139 & && z > bb[4] && z < bb[5] 140 & ENDIFMACRO , label = fakeInterface, new2old = privateDmesh#N2O); 141 & globalName = meshName[level - 1]; 142 & n2oNeighbor = 0:globalName.nt - 1; 143 & ENDIFMACRO IFMACRO(!privateDmesh#CartesianPartitioning) 144 & { 145 & int[int] backup = privateDmesh#N2O; 146 & int[int] new = n2oNeighbor(privateDmesh#N2O); 147 & privateDmesh#N2O.resize(new.n); 148 & privateDmesh#N2O = new; 149 & n2oNeighbor.resize(backup.n); 150 & n2oNeighbor = backup; 151 & } 152 & ENDIFMACRO ENDIFMACRO if(level > 1) { 153 & prolongation.resize(level - 1); 154 & if(s > 1) { 155 & meshN globalNameRefined = globalName; 156 & for(int i = level - 1; i > 0; --i) { 157 & globalNameRefined = trunc(globalNameRefined, 1, split = s); 158 & meshName[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = fakeInterface); 159 & fespace WhLocalRefinedPrivate(meshName[i - 1], P); 160 & fespace WhLocalCoarsePrivate(meshName[i], P); 161 & prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 162 & } 163 & } 164 & else for(int i = level - 1; i > 0; --i) 165 & meshName[i - 1] = meshName[i]; 166 & } 167 & if(!removeZeros && (fakeInterface != -111111 || overlap != 1)) { 168 & if(suppSmooth[].min < 0.501) { 169 & supp = supp; 170 & borderName[level - 1] = trunc(globalName, (suppSmooth > (overlap - 0.999) / real(2 * overlap)) && (suppSmooth < 0.501), label = (abs(fakeInterface) + 1) * 100); 171 & if(s > 1) 172 & for(int i = level - 2; i >= 0; --i) { 173 & borderName[i] = trunc(borderName[i + 1], 1, split = s, label = (abs(fakeInterface) + 1) * 100); 174 & meshN tempRefined = meshName[i] + borderName[i]; 175 & fespace PhRefinedPrivate(tempRefined, P0); 176 & PhRefinedPrivate suppRefined = supp; 177 & fespace VhBorderRefinedPrivate(borderName[i], P1); 178 & VhBorderRefinedPrivate suppBorder = suppRefined; 179 & borderName[i] = trunc(borderName[i], suppBorder > 0.01); 180 & } 181 & else for(int i = level - 2; i >= 0; --i) 182 & borderName[i] = borderName[i + 1]; 183 & } 184 & } 185 & fespace VhLocalPrivate(meshName[level - 1], P1); 186 & VhLocalPrivate[int] partitionIntersection(intersection[0].n); 187 & VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 188 & VhLocalPrivate sum = khi; 189 & VhGlobalPrivate phi; 190 & part = part; 191 & int numberIntersection = 0; 192 & { 193 & int[int] restriction = restrict(VhLocalPrivate, VhGlobalPrivate, n2oNeighbor); 194 & n2oNeighbor.resize(0); 195 & mpiWaitAll(rq); 196 & for(int i = 0; i < intersection[0].n; ++i) { 197 & PhGlobalPrivate suppPartition = abs(part - intersection[0][i]) < 0.1; 198 & AddLayers(globalName, suppPartition[], overlap, phi[]); 199 & if(min(eps, epsTab[i]) > 0.0) { 200 & if(intN(globalName)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 201 & partitionIntersection[numberIntersection][] = phi[](restriction); 202 & if(!trueRestrict) 203 & sum[] += partitionIntersection[numberIntersection][]; 204 & intersection[0][numberIntersection++] = intersection[0][i]; 205 & } 206 & } 207 & } 208 & } 209 & if(numberIntersection != intersection[0].n) 210 & intersection[0].resize(numberIntersection); 211 & intersection.resize(1 + level * numberIntersection); 212 & ENDIFMACRO IFMACRO(privateCreateMat) 213 & assert(level == 1); 214 & int numberIntersection = privateDmesh#meshName#intersectionDef.n - 1; 215 & intersection.resize(1 + level * numberIntersection); 216 & intersection[0].resize(numberIntersection); 217 & fespace VhLocalPrivate(meshName[level - 1], P1); 218 & VhLocalPrivate[int] partitionIntersection(numberIntersection); 219 & for(int i = 0; i < numberIntersection; ++i) { 220 & intersection[0][i] = privateDmesh#meshName#intersectionDef[0][i]; 221 & partitionIntersection[i][] = privateDmesh#meshName#intersectionDef[1 + i]; 222 & } 223 & IFMACRO(privateDmesh#N2O) 224 & IFMACRO(privateDmesh#Original) 225 & IFMACRO(privateDmesh#Restriction) 226 & { 227 & fespace WhLocalPrivate(meshName[level - 1], P); 228 & fespace WhOriginalPrivate(privateDmesh#Original, P); 229 & privateDmesh#Restriction.resize(WhOriginalPrivate.ndof); 230 & privateDmesh#Restriction = restrict(WhLocalPrivate, WhOriginalPrivate, privateDmesh#N2O); 231 & } 232 & ENDIFMACRO ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(privateBuildDmesh) 233 & privateDmesh#meshName#intersectionDef.resize(1 + numberIntersection); 234 & privateDmesh#meshName#intersectionDef[0].resize(numberIntersection); 235 & for(int i = 0; i < numberIntersection; ++i) { 236 & privateDmesh#meshName#intersectionDef[0][i] = intersection[0][i]; 237 & privateDmesh#meshName#intersectionDef[1 + i].resize(VhLocalPrivate.ndof); 238 & privateDmesh#meshName#intersectionDef[1 + i] = partitionIntersection[i][]; 239 & } 240 & ENDIFMACRO meshN[int] meshIntersection(numberIntersection); 241 & for(int j = 0; j < (s == 1 ? 1 : level); ++j) { 242 & for(int i = 0; i < numberIntersection; ++i) { 243 & int[int] n2o; 244 & meshIntersection[i] = trunc(meshName[j], partitionIntersection[i] > 1.0e-6, new2old = n2o, label = 9999); 245 & IFMACRO(privateDmesh#CartesianPartitioning) 246 & real[int] bb(2 * dimension); 247 & boundingbox(meshIntersection[i], bb); 248 & meshIntersection[i] = trunc(meshName[j], x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 249 & IFMACRO(dimension,3) 250 & && z > bb[4] && z < bb[5] 251 & ENDIFMACRO , new2old = n2o, label = 9999); 252 & ENDIFMACRO IFMACRO(!privateCreateMat) 253 & if(!removeZeros) 254 & ENDIFMACRO { 255 & IFMACRO(vectorialfe) 256 & fespace singleComponentWhPrivate(meshName[j], vectorialfe); 257 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 258 & ENDIFMACRO IFMACRO(!vectorialfe) 259 & fespace singleComponentWhPrivate(meshName[j], P); 260 & fespace WhIntersectionPrivate(meshIntersection[i], P); 261 & ENDIFMACRO intersection[1 + i + j * numberIntersection] = restrict(WhIntersectionPrivate, singleComponentWhPrivate, n2o); 262 & } 263 & } 264 & } 265 & IFMACRO(!privateCreateMat) 266 & if(s == 1 && level > 1 && !removeZeros) 267 & for(int j = 1; j < level; ++j) 268 & for(int i = 0; i < numberIntersection; ++i) { 269 & intersection[1 + i + j * numberIntersection].resize(intersection[1 + i].n); 270 & intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 271 & } 272 & partitionIntersection.resize(0); 273 & for(int i = 0; i < (trueRestrict ? level : level - 1); ++i) { 274 & fespace VhRefinedPrivate(meshName[i], P1); 275 & fespace PhRefinedPrivate(meshName[i], P0); 276 & PhRefinedPrivate partRefined = part; 277 & PhRefinedPrivate supp = abs(partRefined - rank) < 0.1; 278 & varf vSupp(u, v) = intN(meshName[i], qforder = 1)(supp * v); 279 & VhRefinedPrivate khiL; 280 & khiL[] = vSupp(0, VhRefinedPrivate); 281 & khiL = khiL > 0.0; 282 & VhRefinedPrivate sum = khiL; 283 & for(int j = 0; j < numberIntersection; ++j) { 284 & supp = abs(partRefined - intersection[0][j]) < 0.1; 285 & VhRefinedPrivate phiL; 286 & phiL[] = vSupp(0, VhRefinedPrivate); 287 & phiL = phiL > 0.0; 288 & sum[] += phiL[]; 289 & } 290 & khiL[] ./= sum[]; 291 & if(i < level - 1) { 292 & fespace WhRefinedPrivate(meshName[i], PkPart); 293 & WhRefinedPrivate defPart(func2vec); 294 & defPart(func2vec) = initPart(khiL); 295 & D[i].resize(WhRefinedPrivate.ndof); 296 & D[i] = func2vec[]; 297 & } 298 & else khi[] = khiL[]; 299 & } 300 & if(!trueRestrict) 301 & khi[] = khi[] ./= sum[]; 302 & if(trueRestrict && mpiSize(comm) == size && removeZeros) { 303 & assert(level == 1); 304 & meshN ThIntersection; 305 & fespace PhIntersectionPrivate(ThIntersection, P0); 306 & PhIntersectionPrivate[int] recv(numberIntersection); 307 & PhIntersectionPrivate[int] send(numberIntersection); 308 & mpiRequest[int] rq(2 * numberIntersection); 309 & for(int i = 0; i < numberIntersection; ++i) { 310 & ThIntersection = meshIntersection[i]; 311 & Irecv(processor(intersection[0][i], comm, rq[i]), recv[i][]); 312 & send[i] = khi; 313 & Isend(processor(intersection[0][i], comm, rq[numberIntersection + i]), send[i][]); 314 & } 315 & meshName[0] = trunc(meshName[0], khi > 1.0e-6, label = 9999); 316 & khi = khi; 317 & int[int] skip(0); 318 & for(int k = 0; k < 2 * numberIntersection; ++k) { 319 & int i = mpiWaitAny(rq); 320 & if(i < numberIntersection) { 321 & ThIntersection = meshIntersection[i]; 322 & PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 323 & if(intersection[].l2 > 1.0e-6) 324 & meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 325 & else { 326 & skip.resize(skip.n + 1); 327 & skip[skip.n - 1] = i; 328 & } 329 & } 330 & } 331 & skip.sort; 332 & intersection.resize(1 + numberIntersection - skip.n); 333 & int j = 0; 334 & for(int i = 0; i < numberIntersection; ++i) { 335 & bool skipped = false; 336 & if(j < skip.n) { 337 & if(skip[j] == i) { 338 & ++j; 339 & skipped = true; 340 & } 341 & } 342 & if(!skipped) { 343 & IFMACRO(vectorialfe) 344 & fespace singleComponentWhPrivate(meshName[0], vectorialfe); 345 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 346 & ENDIFMACRO IFMACRO(!vectorialfe) 347 & fespace singleComponentWhPrivate(meshName[0], P); 348 & fespace WhIntersectionPrivate(meshIntersection[i], P); 349 & ENDIFMACRO matrix meshName#R = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 350 & meshName#R.thresholding(1.0e-10); 351 & real[int] meshName#C; 352 & int[int] meshName#I; 353 & [meshName#I, intersection[1 + i - j], meshName#C] = meshName#R; 354 & intersection[1 + i - j].resize(meshName#R.nbcoef); 355 & intersection[0][i - j] = intersection[0][i]; 356 & } 357 & } 358 & numberIntersection -= skip.n; 359 & intersection[0].resize(numberIntersection); 360 & if(fakeInterface != -111111 || overlap != 1) { 361 & PhGlobalPrivate suppPartition = khi > 0.1; 362 & AddLayers(globalName, suppPartition[], 1, phi[]); 363 & borderName[0] = trunc(globalName, phi > 0.001 && phi < 0.501, label = (abs(fakeInterface) + 1) * 100); 364 & } 365 & } 366 & ENDIFMACRO IFMACRO(vectorialfe) 367 & if(bs > 1) 368 & for(int i = 0; i < intersection.n - 1; ++i) { 369 & int n = intersection[1 + i].n; 370 & intersection[1 + i].resize(n * bs); 371 & for(int j = n - 1; j != -1; --j) 372 & for(int k = bs - 1; k != -1; --k) 373 & intersection[1 + i][j * bs + k] = intersection[1 + i][j] * bs + k; 374 & } 375 & ENDIFMACRO ENDIFMACRO IFMACRO(privateCreatePartition) 376 & fespace VhLocalPrivate(meshName[level - 1], P1); 377 & IFMACRO(!privateCreateMat) 378 & VhLocalPrivate khi; 379 & ENDIFMACRO ENDIFMACRO IFMACRO(privateCreateMat) 380 & VhLocalPrivate khi; 381 & khi[] = privateDmesh#meshName#khiDef[0]; 382 & ENDIFMACRO fespace WhPartPrivate(meshName[level - 1], PkPart); 383 & WhPartPrivate defPart(func2vec); 384 & D[level - 1].resize(WhPartPrivate.ndof); 385 & if((WhPartPrivate.ndof % meshName[level - 1].nt) == 0) { 386 & int constant = rank; 387 & IFMACRO(privateCreateMat) 388 & fespace PhLocalPrivate(meshName[level - 1], P0); 389 & PhLocalPrivate partLocal; 390 & partLocal[] = privateDmesh#meshName#khiDef[1]; 391 & defPart(func2vec) = initPart(abs(partLocal - constant) < 0.1); 392 & ENDIFMACRO IFMACRO(!privateCreateMat) 393 & defPart(func2vec) = initPart(abs(part - constant) < 0.1); 394 & ENDIFMACRO } 395 & else if(WhPartPrivate.ndof == meshName[level - 1].nv) { 396 & func2vec[] = khi[]; 397 & } 398 & else { 399 & defPart(func2vec) = initPart(khi); 400 & } 401 & D[level - 1] = func2vec[]; 402 & IFMACRO(!privateCreatePartition) 403 & IFMACRO(!privateCreateMat) 404 & IFMACRO(privateBuildDmesh) 405 & fespace PhLocalPrivate(meshName[level - 1], P0); 406 & PhLocalPrivate partLocal; 407 & partLocal = part; 408 & privateDmesh#meshName#khiDef[1].resize(partLocal[].n); 409 & privateDmesh#meshName#khiDef[1] = partLocal[]; 410 & ENDIFMACRO ENDIFMACRO ENDIFMACRO searchMethod = backupSM; 411 & }// EOM 412 & macro saveDmesh(ThName, name) 413 & IFMACRO(privateDmesh#ThName) 414 & { 415 & IFMACRO(!ThName#Comm) 416 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(dimension,3) 417 & savemesh(ThName, name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".meshb"); 418 & ENDIFMACRO IFMACRO(dimension,2) 419 & savemesh(ThName, name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".msh"); 420 & ENDIFMACRO ofstream khi(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".khi"); 421 & khi << privateDmesh#ThName#khi << endl; 422 & khi << privateDmesh#ThName#intersection << endl; 423 & IFMACRO(ThName#N2O) 424 & khi << ThName#N2O << endl; 425 & ENDIFMACRO } 426 & ENDIFMACRO IFMACRO(!privateDmesh#ThName) 427 & assert(0); 428 & ENDIFMACRO EndMacro 429 & macro loadDmesh(ThName, name) 430 & IFMACRO(!privateDmesh#ThName) 431 & NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 432 & real[int][int] privateDmesh#ThName#intersection; 433 & ENDIFMACRO { 434 & IFMACRO(!ThName#Comm) 435 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(dimension,3) 436 & ThName = readmesh3(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".meshb"); 437 & ENDIFMACRO IFMACRO(dimension,2) 438 & ThName = readmesh(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".msh"); 439 & ENDIFMACRO privateDmesh#ThName#khi.resize(2); 440 & privateDmesh#ThName#khi[0].resize(ThName.nv); 441 & privateDmesh#ThName#khi[1].resize(ThName.nt); 442 & if(mpiSize(ThName#Comm) > 1) { 443 & ifstream khi(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".khi"); 444 & int m; 445 & khi >> m; 446 & assert(m == 2); 447 & khi >> privateDmesh#ThName#khi[0]; 448 & khi >> privateDmesh#ThName#khi[1]; 449 & khi >> m; 450 & privateDmesh#ThName#intersection.resize(m); 451 & for(int j = 0; j < m; ++j) { 452 & int n; 453 & khi >> n; 454 & privateDmesh#ThName#intersection[j].resize(n); 455 & for[i, v : privateDmesh#ThName#intersection[j]] 456 & khi >> v; 457 & } 458 & IFMACRO(ThName#N2O) 459 & ThName#N2O.resize(ThName.nt); 460 & khi >> ThName#N2O; 461 & ENDIFMACRO } 462 & else { 463 & privateDmesh#ThName#khi[0] = 1.0; 464 & privateDmesh#ThName#khi[1] = 1.0; 465 & } 466 & } 467 & EndMacro 468 & macro buildDmesh(ThName) 469 & IFMACRO(!privateDmesh#ThName) 470 & NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 471 & real[int][int] privateDmesh#ThName#intersection; 472 & ENDIFMACRO { 473 & IFMACRO(!meshN) 474 & IFMACRO(dimension,3) 475 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 476 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 477 & ENDIFMACRO IFMACRO(dimension,3S) 478 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 479 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 480 & ENDIFMACRO IFMACRO(dimension,3L) 481 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 482 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 483 & ENDIFMACRO IFMACRO(!meshN) 484 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 485 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 486 & ENDIFMACRO ENDIFMACRO IFMACRO(!ThName#Comm) 487 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO NewMacro privateBuildDmesh()1 EndMacro int[int][int] intersection; 488 & NewMacro privateDmesh#ThTab()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThTab#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThTab#intersection()privateDmesh#ThName#intersectionDef EndMacro IFMACRO(ThName#N2O) 489 & NewMacro privateDmesh#N2O()ThName#N2O EndMacro ENDIFMACRO IFMACRO(ThName#UserPartitioning) 490 & buildWithPartitioning(ThName, ThName#UserPartitioning, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm); 491 & ENDIFMACRO IFMACRO(ThName#Periodicity) 492 & buildPeriodic(ThName, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm, ThName#Periodicity); 493 & ENDIFMACRO IFMACRO(!ThName#UserPartitioning) 494 & IFMACRO(!ThName#Periodicity) 495 & IFMACRO(ThName#CartesianPartitioning) 496 & NewMacro privateDmesh#CartesianPartitioning() EndMacro ENDIFMACRO build(ThName, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm); 497 & ENDIFMACRO ENDIFMACRO } 498 & EndMacro 499 & macro reconstructDmesh(ThName) 500 & IFMACRO(!privateDmesh#ThName) 501 & NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 502 & real[int][int] privateDmesh#ThName#intersection; 503 & ENDIFMACRO IFMACRO(!ThName#Comm) 504 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(ThName#Comm) { 505 & IFMACRO(!dimension) 506 & NewMacro dimension()2 EndMacro ENDIFMACRO IFMACRO(!meshN) 507 & NewMacro meshN()mesh EndMacro NewMacro intN()int2d EndMacro ENDIFMACRO int[int] neighbors; 508 & { 509 & real[int] bb(2 * dimension); 510 & boundingbox(ThName, bb); 511 & real[int] bbAll(2 * dimension * mpiSize(ThName#Comm)); 512 & mpiAllgather(bb, bbAll, ThName#Comm); 513 & real hmax; 514 & { 515 & real tmp = ThName.hmax; 516 & mpiAllReduce(tmp, hmax, ThName#Comm, mpiMAX); 517 & } 518 & int between = 0; 519 & for(int i = 0; i < mpiSize(ThName#Comm); ++i) { 520 & if(i != mpiRank(ThName#Comm) && 521 & IFMACRO(dimension,2) 522 & !(bbAll[1 + 4 * i] < bb[0] - hmax || bbAll[0 + 4 * i] > bb[1] + hmax || bbAll[3 + 4 * i] < bb[2] - hmax || bbAll[2 + 4 * i] > bb[3] + hmax) 523 & ENDIFMACRO IFMACRO(dimension,3) 524 & !(bbAll[1 + 6 * i] < bb[0] - hmax || bbAll[0 + 6 * i] > bb[1] + hmax || bbAll[3 + 6 * i] < bb[2] - hmax || bbAll[2 + 6 * i] > bb[3] + hmax || bbAll[5 + 6 * i] < bb[4] - hmax || bbAll[4 + 6 * i] > bb[5] + hmax) 525 & ENDIFMACRO ) { 526 & neighbors.resize(neighbors.n + 1); 527 & neighbors[neighbors.n - 1] = i; 528 & } 529 & } 530 & } 531 & reconstructDmeshWithNeighbors(ThName, neighbors) 532 & } 533 & EndMacro macro reconstructDmeshWithNeighbors(ThName, neighborsName) 534 & IFMACRO(!privateDmesh#ThName) 535 & NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 536 & real[int][int] privateDmesh#ThName#intersection; 537 & ENDIFMACRO { 538 & IFMACRO(!ThName#Comm) 539 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO real[int] part; 540 & { 541 & if(verbosity > 0) 542 & mpiBarrier(ThName#Comm); 543 & real timerReconstruction = mpiWtime(); 544 & varf vG(u, v) = on(labels(ThName), u = 1.0); 545 & fespace VhGammaPrivate(ThName, P1); 546 & fespace PhGammaPrivate(ThName, P0); 547 & VhGammaPrivate gamma; 548 & gamma[] = vG(0, VhGammaPrivate, tgv = -1); 549 & PhGammaPrivate gammaElt = gamma > 0.1; 550 & meshN ThLocalInit = trunc(ThName, gammaElt > 0.1, label = -111112); 551 & meshN ThLocalInitInterior = trunc(ThName, gammaElt < 0.1, label = -111112); 552 & neighborsName.sort; 553 & int between = 0; 554 & for(int i = 0; i < neighborsName.n; ++i) 555 & if(neighborsName[i] > mpiRank(ThName#Comm)) { 556 & between = i; 557 & break; 558 & } 559 & if(neighborsName.n) 560 & if(neighborsName[neighborsName.n - 1] < mpiRank(ThName#Comm)) 561 & between = neighborsName.n; 562 & meshN[int] ThTab(neighborsName.n + 1); 563 & ThTab[between] = ThLocalInit; 564 & mpiRequest[int] rqRecv(neighborsName.n); 565 & mpiRequest[int] rqSend(neighborsName.n); 566 & for(int i = 0; i < neighborsName.n; ++i) 567 & Isend(processor(neighborsName[i], ThName#Comm, rqSend[i]), ThLocalInit); 568 & for(int i = 0; i < between; ++i) 569 & Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i]); 570 & for(int i = between; i < neighborsName.n; ++i) 571 & Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i + 1]); 572 & mpiWaitAll(rqRecv); 573 & meshN ThLocalNew = gluemesh(ThTab); 574 & int m = 0; 575 & for(int i = 0; i < between; ++i) 576 & m += ThTab[i].nt; 577 & ThTab[between] = trunc(ThLocalNew, nuTriangle >= m && nuTriangle < m + ThTab[between].nt, label = -111111); 578 & mpiWaitAll(rqSend); 579 & for(int i = 0; i < neighborsName.n; ++i) 580 & Isend(processor(neighborsName[i], ThName#Comm, rqSend[i]), ThTab[between]); 581 & for(int i = 0; i < between; ++i) 582 & Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i]); 583 & for(int i = between; i < neighborsName.n; ++i) 584 & Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i + 1]); 585 & mpiWaitAll(rqRecv); 586 & ThTab.resize(neighborsName.n + 2); 587 & ThTab[neighborsName.n + 1] = ThLocalInitInterior; 588 & ThName = gluemesh(ThTab); 589 & IFMACRO(dimension,3) 590 & ThName = change(ThName, rmlfaces = -111112); 591 & ENDIFMACRO IFMACRO(dimension,2) 592 & ThName = change(ThName, rmledges = -111112); 593 & ENDIFMACRO part.resize(ThName.nt); 594 & m = 0; 595 & for(int i = 0; i < between; ++i) { 596 & part(m:m + ThTab[i].nt - 1) = neighborsName[i]; 597 & m += ThTab[i].nt; 598 & } 599 & part(m:m + ThTab[between].nt - 1) = mpiRank(ThName#Comm); 600 & m += ThTab[between].nt; 601 & for(int i = between; i < neighborsName.n; ++i) { 602 & part(m:m + ThTab[i + 1].nt - 1) = neighborsName[i]; 603 & m += ThTab[i + 1].nt; 604 & } 605 & part(part.n - ThLocalInitInterior.nt:ThName.nt - 1) = mpiRank(ThName#Comm); 606 & mpiWaitAll(rqSend); 607 & if(verbosity > 0) { 608 & mpiBarrier(ThName#Comm); 609 & if(mpiRank(ThName#Comm) == 0) 610 & cout.scientific << " --- distributed mesh reconstructed (in " << mpiWtime() - timerReconstruction << ")" << endl; 611 & } 612 & } 613 & NewMacro privateBuildDmesh()1 EndMacro NewMacro privateReconstructDmesh()1 EndMacro int[int][int] intersection; 614 & NewMacro privateDmesh#ThTab()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThTab#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThTab#intersection()privateDmesh#ThName#intersectionDef EndMacro IFMACRO(ThName#N2O) 615 & NewMacro privateDmesh#N2O()ThName#N2O EndMacro ENDIFMACRO buildWithPartitioning(ThName, part, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm) 616 & } 617 & EndMacro macro copyDmesh(OldName, NewName) 618 & IFMACRO(!privateDmesh#NewName) 619 & NewMacro privateDmesh#NewName()privateDmesh#NewName EndMacro NewMacro privateDmesh#NewName#khi()privateDmesh#NewName#khiDef EndMacro NewMacro privateDmesh#NewName#intersection()privateDmesh#NewName#intersectionDef EndMacro real[int][int] privateDmesh#NewName#khi(2); 620 & real[int][int] privateDmesh#NewName#intersection; 621 & ENDIFMACRO IFMACRO(privateDmesh#OldName) 622 & NewName = OldName; 623 & privateDmesh#NewName#khi[0].resize(privateDmesh#OldName#khi[0].n); 624 & privateDmesh#NewName#khi[0] = privateDmesh#OldName#khi[0]; 625 & privateDmesh#NewName#khi[1].resize(privateDmesh#OldName#khi[1].n); 626 & privateDmesh#NewName#khi[1] = privateDmesh#OldName#khi[1]; 627 & privateDmesh#NewName#intersection.resize(privateDmesh#OldName#intersection.n); 628 & for(int i = 0; i < privateDmesh#NewName#intersection.n; ++i) { 629 & privateDmesh#NewName#intersection[i].resize(privateDmesh#OldName#intersection[i].n); 630 & privateDmesh#NewName#intersection[i] = privateDmesh#OldName#intersection[i]; 631 & } 632 & ENDIFMACRO EndMacro macro createMat(ThName, MatName, PkName) 633 & IFMACRO(privateDmesh#ThName) 634 & { 635 & IFMACRO(!meshN) 636 & IFMACRO(dimension,3) 637 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 638 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 639 & ENDIFMACRO IFMACRO(dimension,3S) 640 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 641 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 642 & ENDIFMACRO IFMACRO(dimension,3L) 643 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 644 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 645 & ENDIFMACRO IFMACRO(!meshN) 646 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 647 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 648 & ENDIFMACRO ENDIFMACRO IFMACRO(!ThName#Comm) 649 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!privateCreateMatCheckDmesh) 650 & if(ThName.nv != privateDmesh#ThName#khi[0].n || (privateDmesh#ThName#khi[1].n && ThName.nt != privateDmesh#ThName#khi[1].n)) { 651 & buildDmesh(ThName) 652 & } 653 & ENDIFMACRO NewMacro privateCreateMat()1 EndMacro int[int][int] intersection; 654 & real[int][int] DTab(1); 655 & meshN[int] ThTab(1); 656 & ThTab[0] = ThName; 657 & NewMacro privateDmesh#ThTab()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThTab#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThTab#intersection()privateDmesh#ThName#intersectionDef EndMacro IFMACRO(!def) 658 & NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!init) 659 & NewMacro init(i)i EndMacro ENDIFMACRO if(mpiSize(ThName#Comm) > 1) { 660 & IFMACRO(ThName#N2O) 661 & IFMACRO(ThName#Original) 662 & IFMACRO(ThName#Restriction) 663 & NewMacro privateDmesh#N2O()ThName#N2O EndMacro NewMacro privateDmesh#Original()ThName#Original EndMacro NewMacro privateDmesh#Restriction()ThName#Restriction EndMacro ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(!ThName#PkPart) 664 & NewMacro ThName#PkPart()PkName EndMacro ENDIFMACRO IFMACRO(ThName#CartesianPartitioning) 665 & NewMacro privateDmesh#CartesianPartitioning() EndMacro ENDIFMACRO partitionPrivate(ThTab, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, mpiRank(ThName#Comm), mpiSize(ThName#Comm), 1, 1, 1, privateCreateMat, DTab, PkName, intersection, ThName#Comm, -111111, ThName#PkPart, def, init, 1) 666 & } 667 & else { 668 & fespace WhGlobalPrivate(ThName, PkName); 669 & DTab[0].resize(WhGlobalPrivate.ndof); 670 & DTab[0] = 1; 671 & intersection.resize(0); 672 & IFMACRO(ThName#N2O) 673 & IFMACRO(ThName#Original) 674 & IFMACRO(ThName#Restriction) 675 & ThName#Restriction.resize(WhGlobalPrivate.ndof); 676 & ThName#Restriction = 0:WhGlobalPrivate.ndof - 1; 677 & ENDIFMACRO ENDIFMACRO ENDIFMACRO } 678 & IFMACRO(!privateCreatePartition) 679 & constructor(MatName, DTab[0].n, intersection, DTab[0], communicator = ThName#Comm); 680 & ENDIFMACRO IFMACRO(privateCreatePartition) 681 & privateCreatePartition.resize(DTab[0].n); 682 & privateCreatePartition = DTab[0]; 683 & ENDIFMACRO } 684 & ENDIFMACRO IFMACRO(!privateDmesh#ThName) 685 & buildDmesh(ThName) 686 & { 687 & IFMACRO(!meshN) 688 & IFMACRO(dimension,3) 689 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 690 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 691 & ENDIFMACRO IFMACRO(dimension,3S) 692 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 693 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 694 & ENDIFMACRO IFMACRO(dimension,3L) 695 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 696 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 697 & ENDIFMACRO IFMACRO(!meshN) 698 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 699 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 700 & ENDIFMACRO ENDIFMACRO NewMacro privateCreateMatCheckDmesh()1 EndMacro createMat(ThName, MatName, PkName) 701 & } 702 & ENDIFMACRO EndMacro 703 & macro createPartition(ThName, PartName, PkName) 704 & IFMACRO(!privateDmesh#ThName) 705 & buildDmesh(ThName) 706 & ENDIFMACRO { 707 & NewMacro privateCreateMatCheckDmesh()1 EndMacro NewMacro privateCreatePartition()PartName EndMacro createMat(ThName, privateCreatePartition, PkName) 708 & } 709 & EndMacro 710 & macro buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, DTab, P, comm, excluded, PkPart, defPart, initPart, labPeriodic, userPartitioning, bs) { 711 & IFMACRO(!def) 712 & NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!init) 713 & NewMacro init(i)i EndMacro ENDIFMACRO Th.resize(level); 714 & ThBorder.resize(level); 715 & prolongation.resize(level - 1); 716 & real timerPartition = mpiWtime(); 717 & if(mpiSize(comm) > 1 && !excluded) { 718 & meshN ThGlobal = Th[level - 1]; 719 & fespace PhGlobalPrivate(ThGlobal, P0); 720 & fespace VhGlobalPrivate(ThGlobal, P1); 721 & PhGlobalPrivate partGlobal; 722 & IFMACRO(!privateReconstructDmesh) 723 & IFMACRO(privateDmesh#CartesianPartitioning) 724 & { 725 & real[int] bb(2 * dimension); 726 & boundingbox(ThGlobal, bb); 727 & PhGlobalPrivate xx = x / (bb[1] - bb[0]), yy = y / (bb[3] - bb[2]) 728 & IFMACRO(dimension,2) 729 & ; 730 & int i = int(sqrt(mpiSize(comm))); 731 & while(mpiSize(comm) % i != 0) 732 & --i; 733 & int j = mpiSize(comm) / i; 734 & partGlobal = int(j * xx) + int(i * yy) * j; 735 & ENDIFMACRO IFMACRO(dimension,3) 736 & , zz = z / (bb[5] - bb[4]); 737 & i = int(mpiSize(comm)^(0.333333333333333)); 738 & while(mpiSize(comm) % i != 0) 739 & --i; 740 & real p = mpiSize(comm) / i; 741 & j = int(sqrt(p)); 742 & while(p % j != 0) 743 & --j; 744 & real k = int(p / j); 745 & partGlobal = int(i * zz) * k * j + int(j * yy) * k + int(k * xx); 746 & ENDIFMACRO } 747 & ENDIFMACRO IFMACRO(!privateDmesh#CartesianPartitioning) 748 & if(userPartitioning.n != PhGlobalPrivate.ndof || labPeriodic.n > 0) { 749 & timerPartition = mpiWtime(); 750 & meshN ThGlobalPeriodic; 751 & if(labPeriodic.n > 0) { 752 & VhGlobalPrivate marker; 753 & for(int i = 0; i < labPeriodic.n; ++i) { 754 & varf vMarker(u, v) = on(labPeriodic[i], u = 1.0); 755 & marker[] += vMarker(0, VhGlobalPrivate, tgv = -1); 756 & } 757 & PhGlobalPrivate partPeriodic = marker > 0.1; 758 & while(1) { 759 & AddLayers(ThGlobal, partPeriodic[], 1 + overlap, marker[]); 760 & partPeriodic = marker > 0.001; 761 & ThGlobalPeriodic = trunc(ThGlobal, partPeriodic < 0.999); 762 & if(ThGlobal.nt / real(ThGlobalPeriodic.nt) > mpisize / real(mpisize - 1)) 763 & break; 764 & } 765 & } 766 & if(mpiRank(comm) == 0) { 767 & if(verbosity > 0) 768 & cout.scientific << " --- global mesh of " << ThGlobal.nt << " elements (prior to refinement) partitioned with " << Stringification(partitioner); 769 & if(labPeriodic.n > 0) { 770 & fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 771 & PhPeriodicPrivate partPeriodic; 772 & if(mpiSize(comm) > 2) { 773 & partitionerSeq(partPeriodic[], ThGlobalPeriodic, mpiSize(comm) - 1); 774 & partPeriodic[] += 1.0; 775 & } 776 & else partPeriodic[] = 1.0; 777 & partGlobal = partPeriodic; 778 & } 779 & else { 780 & partitionerSeq(partGlobal[], ThGlobal, mpiSize(comm)); 781 & } 782 & } 783 & if(labPeriodic.n > 0 && Stringification(partitioner) != "metis" && Stringification(partitioner) != "scotch") { 784 & fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 785 & PhPeriodicPrivate partPeriodic; 786 & if(mpiSize(comm) > 2) { 787 & partitionerPar(partPeriodic[], ThGlobalPeriodic, comm, mpiSize(comm) - 1); 788 & partPeriodic[] += 1.0; 789 & } 790 & else partPeriodic[] = 1.0; 791 & partGlobal = partPeriodic; 792 & } 793 & else partitionerPar(partGlobal[], ThGlobal, comm, mpiSize(comm)); 794 & if(mpiRank(comm) == 0 && verbosity > 0) 795 & cout.scientific << " (in " << mpiWtime() - timerPartition << ")" << endl; 796 & timerPartition = mpiWtime(); 797 & } 798 & else { 799 & partGlobal[] = userPartitioning; 800 & } 801 & ENDIFMACRO ENDIFMACRO IFMACRO(privateReconstructDmesh) 802 & partGlobal[] = userPartitioning; 803 & ENDIFMACRO IFMACRO(!trueRestrict) 804 & bool trueRestrict = usedARGV("-true_restrict") != -1; 805 & ENDIFMACRO IFMACRO(!removeZeros) 806 & bool removeZeros = trueRestrict && overlap == 1 && usedARGV("-remove_zeros") != -1; 807 & ENDIFMACRO if(verbosity > 0) { 808 & mpiBarrier(comm); 809 & timerPartition = mpiWtime(); 810 & } 811 & IFMACRO(privateBuildDmesh) 812 & NewMacro defP1(i)i EndMacro NewMacro initP1(i)i EndMacro partitionPrivate(Th, ThBorder, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank(comm), mpiSize(comm), s, overlap, level, prolongation, DTab, P, intersection, comm, fakeInterface, PkPart, defP1, initP1, bs) 813 & ENDIFMACRO IFMACRO(!privateBuildDmesh) 814 & partitionPrivate(Th, ThBorder, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank(comm), mpiSize(comm), s, overlap, level, prolongation, DTab, P, intersection, comm, fakeInterface, PkPart, defPart, initPart, bs) 815 & ENDIFMACRO } 816 & else if(mpiSize(comm) == 1) { 817 & for(int i = level - 1; i > 0; --i) { 818 & Th[i - 1] = trunc(Th[i], 1, split = s); 819 & fespace WhLocalRefinedPrivate(Th[i - 1], P); 820 & fespace WhLocalCoarsePrivate(Th[i], P); 821 & prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 822 & DTab[i].resize(WhLocalCoarsePrivate.ndof); 823 & DTab[i] = 1.0; 824 & } 825 & if(level == 1) { 826 & IFMACRO(privateBuildDmesh) 827 & IFMACRO(privateDmesh#N2O) 828 & if(s > 1) 829 & Th[0] = trunc(Th[0], 1, split = s, new2old = privateDmesh#N2O); 830 & else { 831 & privateDmesh#N2O.resize(Th[0].nt); 832 & privateDmesh#N2O = 0:Th[0].nt-1; 833 & } 834 & ENDIFMACRO IFMACRO(!privateDmesh#N2O) 835 & if(s > 1) 836 & Th[0] = trunc(Th[0], 1, split = s); 837 & ENDIFMACRO ENDIFMACRO IFMACRO(!privateBuildDmesh) 838 & if(s > 1) 839 & Th[0] = trunc(Th[0], 1, split = s); 840 & ENDIFMACRO } 841 & fespace WhLocalPrivate(Th[0], P); 842 & DTab[0].resize(WhLocalPrivate.ndof); 843 & DTab[0] = 1.0; 844 & } 845 & if(verbosity > 0) { 846 & mpiBarrier(comm); 847 & if(mpiRank(comm) == 0) 848 & cout.scientific << " --- partition of unity built (in " << mpiWtime() - timerPartition << ")" << endl; 849 & } 850 & }// EOM 851 & macro buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, labPeriodic, userPartitioning, bs) { 852 & meshN[int] ThTab(1); 853 & meshN[int] ThBorderTab(1); 854 & real[int][int] DTab(1); 855 & ThTab[0] = Th; 856 & matrix[int] prolongation(0); 857 & buildOverlapEdgePeriodicRecursive(ThTab, ThBorderTab, fakeInterface, s, overlap, 1, prolongation, intersection, DTab, P, comm, excluded, PkPart, defPart, initPart, labPeriodic, userPartitioning, bs) 858 & Th = ThTab[0]; 859 & ThBorder = ThBorderTab[0]; 860 & D.resize(DTab[0].n); 861 & D = DTab[0]; 862 & }// EOM 863 & IFMACRO(vectorialfe) 864 & macro buildOverlapEdgeRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, bs) { 865 & int[int] emptyArray(0); 866 & real[int] emptyRealArray(0); 867 & buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, bs) 868 & }// EOM macro buildOverlapEdge(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, bs) { 869 & int[int] emptyArray(0); 870 & real[int] emptyRealArray(0); 871 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, bs) 872 & }// EOM macro buildOverlapEdgeWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, bs) { 873 & int[int] emptyArray(0); 874 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, bs) 875 & }// EOM macro buildOverlapWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, bs) { 876 & int[int] emptyArray(0); 877 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, bs) 878 & }// EOM macro buildOverlap(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, bs) { 879 & int[int] emptyArray(0); 880 & real[int] emptyRealArray(0); 881 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, bs) 882 & }// EOM macro buildOverlapPeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, labPeriodic, bs) { 883 & real[int] emptyArray(0); 884 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyArray, bs) 885 & }// EOM macro buildEdgeWithPartitioning(Th, part, s, intersection, D, P, comm, PkPart, defPart, initPart, bs) { 886 & int[int] emptyArray(0); 887 & meshN ThBorder; 888 & int fakeInterface = -111111; 889 & int overlap = 1; 890 & bool excluded = false; 891 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, bs) 892 & }// EOM macro buildWithPartitioning(Th, part, s, intersection, D, P, comm, bs) { 893 & int[int] emptyArray(0); 894 & meshN ThBorder; 895 & int fakeInterface = -111111; 896 & int overlap = 1; 897 & bool excluded = false; 898 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, bs) 899 & }// EOM macro build(Th, s, intersection, D, P, comm, bs) { 900 & int[int] emptyArray(0); 901 & real[int] emptyRealArray(0); 902 & meshN ThBorder; 903 & int fakeInterface = -111111; 904 & int overlap = 1; 905 & bool excluded = false; 906 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, bs) 907 & }// EOM macro buildPeriodic(Th, s, intersection, D, P, comm, labPeriodic, bs) { 908 & int[int] emptyArray(0); 909 & real[int] emptyRealArray(0); 910 & meshN ThBorder; 911 & int fakeInterface = -111111; 912 & int overlap = 1; 913 & bool excluded = false; 914 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyRealArray, bs) 915 & }// EOM macro buildMinimalist(Th, intersection, D, P, bs) { 916 & int[int] emptyArray(0); 917 & real[int] emptyRealArray(0); 918 & meshN ThBorder; 919 & int fakeInterface = -111111; 920 & int overlap = 1; 921 & bool excluded = false; 922 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, 1, overlap, intersection, D, P, mpiCommWorld, excluded, P, def, init, emptyArray, emptyRealArray, bs) 923 & }// EOM macro buildRecursive(Th, s, level, prolongation, intersectionMat, DTab, P, comm, bsMat) { 924 & int[int] emptyArray(0); 925 & real[int] emptyRealArray(0); 926 & meshN[int] ThBorderTab(level); 927 & DTab.resize(level); 928 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, level, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, bsMat) 929 & }// EOM macro buildMatRecursive(Th, s, nlevel, prolongation, A, P, comm, bsMat) { 930 & int[int] emptyArray(0); 931 & real[int] emptyRealArray(0); 932 & meshN[int] ThBorderTab(nlevel); 933 & int[int][int] intersectionMat; 934 & real[int][int] DTab(nlevel); 935 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, bsMat) 936 & for(int i = 0; i < nlevel; ++i) 937 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], bs = bsMat, communicator = comm, level = i); 938 & }// EOM macro buildMatEdgeRecursive(Th, s, nlevel, prolongation, A, P, comm, PkPart, defPart, initPart, bsMat) { 939 & int[int] emptyArray(0); 940 & real[int] emptyRealArray(0); 941 & meshN[int] ThBorderTab(nlevel); 942 & int[int][int] intersectionMat; 943 & real[int][int] DTab(nlevel); 944 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, PkPart, defPart, initPart, emptyArray, emptyRealArray, bsMat) 945 & for(int i = 0; i < nlevel; ++i) 946 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], bs = bsMat, communicator = comm, level = i); 947 & }// EOM macro buildMatEdgeWithPartitioning(Th, part, s, A, P, comm, PkPart, defPart, initPart, bsMat) { 948 & real[int] DMat; 949 & int[int][int] intersectionMat; 950 & buildEdgeWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, PkPart, defPart, initPart, bsMat) 951 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 952 & }// EOM macro buildMatWithPartitioning(Th, part, s, A, P, comm, bsMat) { 953 & real[int] DMat; 954 & int[int][int] intersectionMat; 955 & buildWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, bsMat) 956 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 957 & }// EOM macro buildMat(Th, s, A, P, comm, bsMat) { 958 & real[int] DMat; 959 & int[int][int] intersectionMat; 960 & build(Th, s, intersectionMat, DMat, P, comm, bsMat) 961 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 962 & }// EOM macro buildMatPeriodic(Th, s, A, P, comm, labPeriodic, bsMat) { 963 & real[int] DMat; 964 & int[int][int] intersectionMat; 965 & buildPeriodic(Th, s, intersectionMat, DMat, P, comm, labPeriodic, bsMat) 966 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 967 & }// EOM macro buildMatMinimalist(Th, A, P, bsMat) { 968 & real[int] DMat; 969 & int[int][int] intersectionMat; 970 & buildMinimalist(Th, intersectionMat, DMat, P, bsMat) 971 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 972 & }// EOM ENDIFMACRO IFMACRO(!vectorialfe) 973 & macro buildOverlapEdgeRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 974 & int[int] emptyArray(0); 975 & real[int] emptyRealArray(0); 976 & buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 977 & }// EOM macro buildOverlapEdge(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 978 & int[int] emptyArray(0); 979 & real[int] emptyRealArray(0); 980 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 981 & }// EOM macro buildOverlapEdgeWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 982 & int[int] emptyArray(0); 983 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, 1) 984 & }// EOM macro buildOverlapWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded) { 985 & int[int] emptyArray(0); 986 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, 1) 987 & }// EOM macro buildOverlap(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded) { 988 & int[int] emptyArray(0); 989 & real[int] emptyRealArray(0); 990 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, 1) 991 & }// EOM macro buildOverlapPeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, labPeriodic) { 992 & real[int] emptyArray(0); 993 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyArray, 1) 994 & }// EOM macro buildEdgeWithPartitioning(Th, part, s, intersection, D, P, comm, PkPart, defPart, initPart) { 995 & int[int] emptyArray(0); 996 & meshN ThBorder; 997 & int fakeInterface = -111111; 998 & int overlap = 1; 999 & bool excluded = false; 1000 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, 1) 1001 & }// EOM macro buildWithPartitioning(Th, part, s, intersection, D, P, comm) { 1002 & int[int] emptyArray(0); 1003 & meshN ThBorder; 1004 & int fakeInterface = -111111; 1005 & int overlap = 1; 1006 & bool excluded = false; 1007 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, 1) 1008 & }// EOM macro build(Th, s, intersection, D, P, comm) { 1009 & int[int] emptyArray(0); 1010 & real[int] emptyRealArray(0); 1011 & meshN ThBorder; 1012 & int fakeInterface = -111111; 1013 & int overlap = 1; 1014 & bool excluded = false; 1015 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1016 & }// EOM macro buildPeriodic(Th, s, intersection, D, P, comm, labPeriodic) { 1017 & int[int] emptyArray(0); 1018 & real[int] emptyRealArray(0); 1019 & meshN ThBorder; 1020 & int fakeInterface = -111111; 1021 & int overlap = 1; 1022 & bool excluded = false; 1023 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyRealArray, 1) 1024 & }// EOM macro buildMinimalist(Th, intersection, D, P) { 1025 & int[int] emptyArray(0); 1026 & real[int] emptyRealArray(0); 1027 & meshN ThBorder; 1028 & int fakeInterface = -111111; 1029 & int overlap = 1; 1030 & bool excluded = false; 1031 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, 1, overlap, intersection, D, P, mpiCommWorld, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1032 & }// EOM macro buildRecursive(Th, s, level, prolongation, intersectionMat, DTab, P, comm) { 1033 & int[int] emptyArray(0); 1034 & real[int] emptyRealArray(0); 1035 & meshN[int] ThBorderTab(level); 1036 & DTab.resize(level); 1037 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, level, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, 1) 1038 & }// EOM macro buildMatRecursive(Th, s, nlevel, prolongation, A, P, comm) { 1039 & int[int] emptyArray(0); 1040 & real[int] emptyRealArray(0); 1041 & meshN[int] ThBorderTab(nlevel); 1042 & int[int][int] intersectionMat; 1043 & real[int][int] DTab(nlevel); 1044 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, 1) 1045 & for(int i = 0; i < nlevel; ++i) 1046 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], communicator = comm, level = i); 1047 & }// EOM macro buildMatEdgeRecursive(Th, s, nlevel, prolongation, A, P, comm, PkPart, defPart, initPart) { 1048 & int[int] emptyArray(0); 1049 & real[int] emptyRealArray(0); 1050 & meshN[int] ThBorderTab(nlevel); 1051 & int[int][int] intersectionMat; 1052 & real[int][int] DTab(nlevel); 1053 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1054 & for(int i = 0; i < nlevel; ++i) 1055 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], communicator = comm, level = i); 1056 & }// EOM macro buildMatEdgeWithPartitioning(Th, part, s, A, P, comm, PkPart, defPart, initPart) { 1057 & real[int] DMat; 1058 & int[int][int] intersectionMat; 1059 & buildEdgeWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, PkPart, defPart, initPart) 1060 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1061 & }// EOM macro buildMatWithPartitioning(Th, part, s, A, P, comm) { 1062 & real[int] DMat; 1063 & int[int][int] intersectionMat; 1064 & buildWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm) 1065 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1066 & }// EOM macro buildMat(Th, s, A, P, comm) { 1067 & real[int] DMat; 1068 & int[int][int] intersectionMat; 1069 & build(Th, s, intersectionMat, DMat, P, comm) 1070 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1071 & }// EOM macro buildMatPeriodic(Th, s, A, P, comm, labPeriodic) { 1072 & real[int] DMat; 1073 & int[int][int] intersectionMat; 1074 & buildPeriodic(Th, s, intersectionMat, DMat, P, comm, labPeriodic) 1075 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1076 & }// EOM macro buildMatMinimalist(Th, A, P) { 1077 & real[int] DMat; 1078 & int[int][int] intersectionMat; 1079 & buildMinimalist(Th, intersectionMat, DMat, P) 1080 & constructor(A, DMat.n, intersectionMat, DMat); 1081 & }// EOM ENDIFMACRO 1082 & macro convectParallel(ThName, uVel, dt, uChi, safety) 1083 & IFMACRO(privateDmesh#ThName) 1084 & { 1085 & IFMACRO(!ThName#Comm) 1086 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0) 1087 & mpiBarrier(ThName#Comm); 1088 & real timerConvect = mpiWtime(); 1089 & if(mpiSize(ThName#Comm) == 1) { 1090 & uChi = convect(uVel, dt, uChi); 1091 & } 1092 & else { 1093 & int backupSM = searchMethod; 1094 & searchMethod = 0; 1095 & real[int] bb(2 * dimension); 1096 & boundingbox(ThName, bb); 1097 & bb(0) -= safety * ThName.hmax; 1098 & bb(1) += safety * ThName.hmax; 1099 & bb(2) -= safety * ThName.hmax; 1100 & bb(3) += safety * ThName.hmax; 1101 & IFMACRO(dimension,3) 1102 & bb(4) -= safety * ThName.hmax; 1103 & bb(5) += safety * ThName.hmax; 1104 & ENDIFMACRO int size = mpiSize(ThName#Comm); 1105 & real[int] bbAll(2 * dimension * size); 1106 & mpiAllgather(bb, bbAll, ThName#Comm); 1107 & int[int] rankExchange(0); 1108 & for(int i = 0; i < size; ++i) { 1109 & IFMACRO(dimension,2) 1110 & if(!(bbAll[1 + 4 * i] < bb[0] 1111 & || bbAll[0 + 4 * i] > bb[1] 1112 & || bbAll[3 + 4 * i] < bb[2] 1113 & || bbAll[2 + 4 * i] > bb[3])) 1114 & ENDIFMACRO IFMACRO(dimension,3) 1115 & if(!(bbAll[1 + 6 * i] < bb[0] 1116 & || bbAll[0 + 6 * i] > bb[1] 1117 & || bbAll[3 + 6 * i] < bb[2] 1118 & || bbAll[2 + 6 * i] > bb[3] 1119 & || bbAll[5 + 6 * i] < bb[4] 1120 & || bbAll[4 + 6 * i] > bb[5])) 1121 & ENDIFMACRO { 1122 & rankExchange.resize(rankExchange.n + 1); 1123 & rankExchange[rankExchange.n - 1] = i; 1124 & } 1125 & } 1126 & real[int] D, backupRegion(ThName.nt); 1127 & real[int] buffer(ThName.nt * (dimension + 1)); 1128 & IFMACRO(dimension,2) 1129 & func PkVel = [P1, P1]; 1130 & ENDIFMACRO IFMACRO(dimension,3) 1131 & func PkVel = [P1, P1, P1]; 1132 & ENDIFMACRO fespace VhVelPrivate(ThName, PkVel); 1133 & fespace VhChiPrivate(ThName, P1); 1134 & { 1135 & VhVelPrivate defVel(uVelLocal) = uVel; 1136 & for[i, v : uVelLocal[]] v *= privateDmesh#ThName#khiDef[0][i / dimension]; 1137 & buffer(0:ThName.nv * dimension - 1) = uVelLocal[]; 1138 & } 1139 & buffer(ThName.nv * dimension:ThName.nv * (dimension + 1) - 1) = uChi[]; 1140 & buffer(ThName.nv * dimension:ThName.nv * (dimension + 1) - 1) .*= privateDmesh#ThName#khiDef[0]; 1141 & fespace PhPartPrivate(ThName, P0); 1142 & { 1143 & PhPartPrivate backup = region; 1144 & backupRegion = backup[]; 1145 & ThName = change(ThName, fregion = privateDmesh#ThName#khiDef[1][nuTriangle]); 1146 & } 1147 & meshN[int] recvTh(rankExchange.n); 1148 & meshN[int] sendTh(rankExchange.n); 1149 & real[int][int] exchangeU(rankExchange.n + rankExchange.n); 1150 & mpiRequest[int] rqSendTh(rankExchange.n); 1151 & mpiRequest[int] rqSendU(rankExchange.n); 1152 & mpiRequest[int] rqRecvTh(rankExchange.n); 1153 & mpiRequest[int] rqRecvU(rankExchange.n); 1154 & for[i, v : rankExchange] 1155 & Irecv(processor(v, rqRecvTh[i]), recvTh[i]); 1156 & for[i, v : rankExchange] { 1157 & PhPartPrivate part; 1158 & IFMACRO(dimension,2) 1159 & part = (bbAll[0 + 4 * v] < x 1160 & && bbAll[1 + 4 * v] > x 1161 & && bbAll[2 + 4 * v] < y 1162 & && bbAll[3 + 4 * v] > y) ? 1.0 : 0.0; 1163 & ENDIFMACRO IFMACRO(dimension,3) 1164 & part = (bbAll[0 + 6 * v] < x 1165 & && bbAll[1 + 6 * v] > x 1166 & && bbAll[2 + 6 * v] < y 1167 & && bbAll[3 + 6 * v] > y 1168 & && bbAll[4 + 6 * v] < z 1169 & && bbAll[5 + 6 * v] > z) ? 1.0 : 0.0; 1170 & ENDIFMACRO if(part[].linfty > 1.0e-2) { 1171 & int[int] n2o; 1172 & sendTh[i] = trunc(ThName, part > 1.0e-2, new2old = n2o); 1173 & fespace VhRestrictionPrivate(sendTh[i], P1); 1174 & int[int] map; 1175 & map = restrict(VhRestrictionPrivate, VhChiPrivate, n2o); 1176 & exchangeU[rankExchange.n + i].resize(VhRestrictionPrivate.ndof * (dimension + 1)); 1177 & for[j, w : map] { 1178 & exchangeU[rankExchange.n + i][dimension * j] = buffer[dimension * w]; 1179 & exchangeU[rankExchange.n + i][dimension * j + 1] = buffer[dimension * w + 1]; 1180 & IFMACRO(dimension,3) 1181 & exchangeU[rankExchange.n + i][dimension * j + 2] = buffer[dimension * w + 2]; 1182 & ENDIFMACRO exchangeU[rankExchange.n + i][VhRestrictionPrivate.ndof * dimension + j] = buffer[VhChiPrivate.ndof * dimension + w]; 1183 & } 1184 & Isend(processor(v, rqSendTh[i]), sendTh[i]); 1185 & Isend(processor(v, rqSendU[i]), exchangeU[rankExchange.n + i]); 1186 & } 1187 & else Isend(processor(v, rqSendTh[i]), sendTh[i]); 1188 & } 1189 & meshN gluedExchange; 1190 & { 1191 & meshN[int] toGlue(rankExchange.n); 1192 & int j = 0; 1193 & for[i, v : rankExchange] { 1194 & int index = mpiWaitAny(rqRecvTh); 1195 & if(recvTh[index].nt) { 1196 & fespace VhRestrictionPrivate(recvTh[index], P1); 1197 & exchangeU[index].resize(VhRestrictionPrivate.ndof * (dimension + 1)); 1198 & Irecv(processor(rankExchange[index], rqRecvU[index]), exchangeU[index]); 1199 & fespace PhRestrictionPrivate(recvTh[index], P0); 1200 & PhRestrictionPrivate ind = abs(region - rankExchange[index]) < 1.0e-2 ? 1.0 : 0.0; 1201 & if(abs(ind[].max - 1.0) < 1.0e-2) { 1202 & toGlue[j] = trunc(recvTh[index], ind > 1.0e-2); 1203 & ++j; 1204 & } 1205 & } 1206 & } 1207 & toGlue.resize(j); 1208 & gluedExchange = gluemesh(toGlue); 1209 & } 1210 & meshN interpolateExchange; 1211 & fespace VhVelExchangePrivate(gluedExchange, PkVel); 1212 & fespace VhChiExchangePrivate(gluedExchange, P1); 1213 & VhVelExchangePrivate defVel(uVelExchange); 1214 & VhChiExchangePrivate uChiExchange; 1215 & for[i, v : rankExchange] { 1216 & int index = mpiWaitAny(rqRecvU); 1217 & if(index != mpiUndefined) { 1218 & if(recvTh[index].nt) { 1219 & fespace VhRestrictionPrivate(recvTh[index], P1); 1220 & matrix R = interpolate(VhRestrictionPrivate, VhChiExchangePrivate); 1221 & if(R.nnz != R.n) { 1222 & R.thresholding(1.0e-2); 1223 & assert(R.nnz == R.n); 1224 & } 1225 & for[i, j, v : R] { 1226 & uVelExchange[][dimension * j] += exchangeU[index][dimension * i]; 1227 & uVelExchange[][dimension * j + 1] += exchangeU[index][dimension * i + 1]; 1228 & IFMACRO(dimension,3) 1229 & uVelExchange[][dimension * j + 2] += exchangeU[index][dimension * i + 2]; 1230 & ENDIFMACRO uChiExchange[][j] += exchangeU[index][dimension * VhRestrictionPrivate.ndof + i]; 1231 & } 1232 & } 1233 & } 1234 & } 1235 & searchMethod = backupSM; 1236 & fespace VhPhiExchangePrivate(gluedExchange, P0); 1237 & int rank = mpiRank(ThName#Comm); 1238 & VhPhiExchangePrivate phi = abs(region - rank) < 1.0e-2 ? 1.0 : 0.0; 1239 & VhChiExchangePrivate chi; 1240 & AddLayers(gluedExchange, phi[], safety, chi[]); 1241 & int[int] n2o; 1242 & meshN gluedExchangeSafety = trunc(gluedExchange, abs(chi) > 0.1, new2old = n2o); 1243 & fespace VhVelExchangeSafetyPrivate(gluedExchangeSafety, PkVel); 1244 & fespace VhChiExchangeSafetyPrivate(gluedExchangeSafety, P1); 1245 & int[int] map = restrict(VhChiExchangeSafetyPrivate, VhChiExchangePrivate, n2o); 1246 & VhVelExchangeSafetyPrivate defVel(uVelExchangeSafety); 1247 & VhChiExchangeSafetyPrivate uChiExchangeSafety; 1248 & uChiExchangeSafety[] = uChiExchange[](map); 1249 & for[j, w : map] { 1250 & uVelExchangeSafety[][dimension * j] = uVelExchange[][dimension * w]; 1251 & uVelExchangeSafety[][dimension * j + 1] = uVelExchange[][dimension * w + 1]; 1252 & IFMACRO(dimension,3) 1253 & uVelExchangeSafety[][dimension * j + 2] = uVelExchange[][dimension * w + 2]; 1254 & ENDIFMACRO } 1255 & uChiExchangeSafety = convect(defVel(uVelExchangeSafety), dt, uChiExchangeSafety); 1256 & uChi = uChiExchangeSafety; 1257 & ThName = change(ThName, fregion = backupRegion[nuTriangle]); 1258 & mpiWaitAll(rqSendTh); 1259 & mpiWaitAll(rqSendU); 1260 & } 1261 & if(verbosity > 0) { 1262 & mpiBarrier(ThName#Comm); 1263 & if(mpiRank(ThName#Comm) == 0) 1264 & cout.scientific << " --- distributed solution convected (in " << mpiWtime() - timerConvect << ")" << endl; 1265 & } 1266 & } 1267 & ENDIFMACRO // EOM 1268 & macro transferBase(ThName, Pk, uA, ThNew, PkNew, uANew, P) 1269 & IFMACRO(privateDmesh#ThName) 1270 & { 1271 & IFMACRO(!ThName#Comm) 1272 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0) 1273 & mpiBarrier(ThName#Comm); 1274 & real timerTransfer = mpiWtime(); 1275 & IFMACRO(!def) 1276 & NewMacro def(i)i EndMacro ENDIFMACRO if(mpiSize(ThName#Comm) == 1) { 1277 & IFMACRO(!transfer#Q) 1278 & def(uANew) = def(uA); 1279 & ENDIFMACRO IFMACRO(transfer#Q) 1280 & fespace VhLocalOldPrivate(ThName, Pk); 1281 & fespace VhLocalNewPrivate(ThNew, PkNew); 1282 & matrix loc = interpolate(VhLocalNewPrivate, VhLocalOldPrivate); 1283 & matrix locPetscScalar = loc; 1284 & constructor(P, uANew, uA, locPetscScalar); 1285 & ENDIFMACRO } 1286 & else { 1287 & int backupSM = searchMethod; 1288 & searchMethod = 0; 1289 & fespace VhLocalOldPrivate(ThName, Pk); 1290 & fespace VhLocalNewPrivate(ThNew, PkNew); 1291 & IFMACRO(!transfer#Q) 1292 & assert(uA[].n == VhLocalOldPrivate.ndof); 1293 & assert(uANew[].n == VhLocalNewPrivate.ndof); 1294 & ENDIFMACRO IFMACRO(!dimension) 1295 & NewMacro dimension()2 EndMacro ENDIFMACRO IFMACRO(!meshN) 1296 & NewMacro meshN()mesh EndMacro ENDIFMACRO real[int] bb(4 * dimension); 1297 & { 1298 & real[int] tmp(2 * dimension); 1299 & boundingbox(ThName, tmp); 1300 & bb(0:2 * dimension - 1) = tmp; 1301 & boundingbox(ThNew, tmp); 1302 & bb(2 * dimension:4 * dimension - 1) = tmp; 1303 & bb(0) -= max(ThName.hmax, ThNew.hmax); 1304 & bb(1) += max(ThName.hmax, ThNew.hmax); 1305 & bb(2) -= max(ThName.hmax, ThNew.hmax); 1306 & bb(3) += max(ThName.hmax, ThNew.hmax); 1307 & bb(4) -= max(ThName.hmax, ThNew.hmax); 1308 & bb(5) += max(ThName.hmax, ThNew.hmax); 1309 & bb(6) -= max(ThName.hmax, ThNew.hmax); 1310 & bb(7) += max(ThName.hmax, ThNew.hmax); 1311 & IFMACRO(dimension,3) 1312 & bb(8) -= max(ThName.hmax, ThNew.hmax); 1313 & bb(9) += max(ThName.hmax, ThNew.hmax); 1314 & bb(10) -= max(ThName.hmax, ThNew.hmax); 1315 & bb(11) += max(ThName.hmax, ThNew.hmax); 1316 & ENDIFMACRO } 1317 & int size = mpiSize(ThName#Comm); 1318 & real[int] bbAll(4 * dimension * size); 1319 & mpiAllgather(bb, bbAll, ThName#Comm); 1320 & int[int] rankSend(0); 1321 & int[int] rankRecv(0); 1322 & for(int i = 0; i < size; ++i) { 1323 & IFMACRO(dimension,2) 1324 & if(!(bbAll[1 + 8 * i] < bb[4] 1325 & || bbAll[0 + 8 * i] > bb[5] 1326 & || bbAll[3 + 8 * i] < bb[6] 1327 & || bbAll[2 + 8 * i] > bb[7])) 1328 & ENDIFMACRO IFMACRO(dimension,3) 1329 & if(!(bbAll[1 + 12 * i] < bb[6] 1330 & || bbAll[0 + 12 * i] > bb[7] 1331 & || bbAll[3 + 12 * i] < bb[8] 1332 & || bbAll[2 + 12 * i] > bb[9] 1333 & || bbAll[5 + 12 * i] < bb[10] 1334 & || bbAll[4 + 12 * i] > bb[11])) 1335 & ENDIFMACRO { 1336 & rankRecv.resize(rankRecv.n + 1); 1337 & rankRecv[rankRecv.n - 1] = i; 1338 & } 1339 & IFMACRO(dimension,2) 1340 & if(!(bbAll[5 + 8 * i] < bb[0] 1341 & || bbAll[4 + 8 * i] > bb[1] 1342 & || bbAll[7 + 8 * i] < bb[2] 1343 & || bbAll[6 + 8 * i] > bb[3])) 1344 & ENDIFMACRO IFMACRO(dimension,3) 1345 & if(!(bbAll[7 + 12 * i] < bb[0] 1346 & || bbAll[6 + 12 * i] > bb[1] 1347 & || bbAll[9 + 12 * i] < bb[2] 1348 & || bbAll[8 + 12 * i] > bb[3] 1349 & || bbAll[11 + 12 * i] < bb[4] 1350 & || bbAll[10 + 12 * i] > bb[5])) 1351 & ENDIFMACRO { 1352 & rankSend.resize(rankSend.n + 1); 1353 & rankSend[rankSend.n - 1] = i; 1354 & } 1355 & } 1356 & real[int] D, backupRegion(ThName.nt); 1357 & VhLocalOldPrivate def(scaledU); 1358 & IFMACRO(!transfer#Q) 1359 & createPartition(ThName, D, Pk) 1360 & scaledU[] = uA[]; 1361 & ENDIFMACRO IFMACRO(transfer#Q) 1362 & GlobalNumbering(uA, scaledU[]); 1363 & D.resize(scaledU[].n); 1364 & D = uA.D; 1365 & ENDIFMACRO for[i, v : D] scaledU[][i] *= v; 1366 & fespace PhPartPrivate(ThName, P0); 1367 & { 1368 & PhPartPrivate backup = region; 1369 & backupRegion = backup[]; 1370 & int[int] newRegion(ThName.nt); 1371 & int rank = mpiRank(ThName#Comm); 1372 & for[i, v : privateDmesh#ThName#khiDef[1]] newRegion[i] = abs(v - rank) < 1.0e-2 ? 1 : 0; 1373 & ThName = change(ThName, fregion = newRegion[nuTriangle]); 1374 & } 1375 & meshN[int] recvTh(rankRecv.n); 1376 & meshN[int] sendTh(rankSend.n); 1377 & PetscScalar[int][int] exchangeU(rankSend.n + rankRecv.n); 1378 & mpiRequest[int] rqSendTh(rankSend.n); 1379 & mpiRequest[int] rqSendU(rankSend.n); 1380 & mpiRequest[int] rqRecvTh(rankRecv.n); 1381 & mpiRequest[int] rqRecvU(rankRecv.n); 1382 & for[i, v : rankRecv] 1383 & Irecv(processor(v, rqRecvTh[i]), recvTh[i]); 1384 & for[i, v : rankSend] { 1385 & PhPartPrivate part; 1386 & IFMACRO(dimension,2) 1387 & part = (bbAll[4 + 8 * v] < x 1388 & && bbAll[5 + 8 * v] > x 1389 & && bbAll[6 + 8 * v] < y 1390 & && bbAll[7 + 8 * v] > y) ? 1.0 : 0.0; 1391 & ENDIFMACRO IFMACRO(dimension,3) 1392 & part = (bbAll[6 + 12 * v] < x 1393 & && bbAll[7 + 12 * v] > x 1394 & && bbAll[8 + 12 * v] < y 1395 & && bbAll[9 + 12 * v] > y 1396 & && bbAll[10 + 12 * v] < z 1397 & && bbAll[11 + 12 * v] > z) ? 1.0 : 0.0; 1398 & ENDIFMACRO if(part[].linfty > 1.0e-2) { 1399 & int[int] n2o; 1400 & sendTh[i] = trunc(ThName, part > 1.0e-2, new2old = n2o); 1401 & fespace VhRestrictionPrivate(sendTh[i], Pk); 1402 & int[int] map; 1403 & map = restrict(VhRestrictionPrivate, VhLocalOldPrivate, n2o); 1404 & exchangeU[rankRecv.n + i].resize(VhRestrictionPrivate.ndof); 1405 & for[j, w : map] exchangeU[rankRecv.n + i][j] = scaledU[][w]; 1406 & Isend(processor(v, rqSendTh[i]), sendTh[i]); 1407 & Isend(processor(v, rqSendU[i]), exchangeU[rankRecv.n + i]); 1408 & } 1409 & else Isend(processor(v, rqSendTh[i]), sendTh[i]); 1410 & } 1411 & meshN gluedExchange; 1412 & { 1413 & meshN[int] toGlue(rankRecv.n); 1414 & int j = 0; 1415 & for[i, v : rankRecv] { 1416 & int index = mpiWaitAny(rqRecvTh); 1417 & if(recvTh[index].nt) { 1418 & fespace VhRestrictionPrivate(recvTh[index], Pk); 1419 & exchangeU[index].resize(VhRestrictionPrivate.ndof); 1420 & Irecv(processor(rankRecv[index], rqRecvU[index]), exchangeU[index]); 1421 & fespace PhRestrictionPrivate(recvTh[index], P0); 1422 & PhRestrictionPrivate ind = region; 1423 & if(abs(ind[].max - 1.0) < 1.0e-2) { 1424 & toGlue[j] = trunc(recvTh[index], ind > 1.0e-2); 1425 & ++j; 1426 & } 1427 & } 1428 & } 1429 & toGlue.resize(j); 1430 & gluedExchange = gluemesh(toGlue); 1431 & } 1432 & meshN interpolateExchange; 1433 & fespace PhExchangePrivate(gluedExchange, P0); 1434 & fespace VhExchangePrivate(gluedExchange, Pk); 1435 & VhExchangePrivate def(uExchange); 1436 & for[i, v : rankRecv] { 1437 & int index = mpiWaitAny(rqRecvU); 1438 & if(index != mpiUndefined) { 1439 & if(recvTh[index].nt) { 1440 & fespace PhRestrictionPrivate(recvTh[index], P0); 1441 & matrix R = interpolate(PhRestrictionPrivate, PhExchangePrivate); 1442 & if(R.nnz != R.n) { 1443 & R.thresholding(1.0e-2); 1444 & assert(R.nnz == R.n); 1445 & } 1446 & int[int] I, J; 1447 & real[int] C; 1448 & [I, J, C] = R; 1449 & fespace VhRestrictionPrivate(recvTh[index], Pk); 1450 & int[int] restriction = restrict(VhRestrictionPrivate, VhExchangePrivate, J); 1451 & for[i, v : restriction] uExchange[][v] += exchangeU[index][i]; 1452 & } 1453 & } 1454 & } 1455 & searchMethod = backupSM; 1456 & IFMACRO(!transfer#Q) 1457 & def(uANew) = def(uExchange); 1458 & ENDIFMACRO IFMACRO(transfer#Q) 1459 & matrix loc = interpolate(VhLocalNewPrivate, VhExchangePrivate); 1460 & matrix locPetscScalar = loc; 1461 & constructor(P, uANew, uA, locPetscScalar, numbering = uExchange[]); 1462 & ENDIFMACRO ThName = change(ThName, fregion = backupRegion[nuTriangle]); 1463 & mpiWaitAll(rqSendTh); 1464 & mpiWaitAll(rqSendU); 1465 & } 1466 & if(verbosity > 0) { 1467 & mpiBarrier(ThName#Comm); 1468 & if(mpiRank(ThName#Comm) == 0) 1469 & cout.scientific << " --- distributed solution transferred (in " << mpiWtime() - timerTransfer << ")" << endl; 1470 & } 1471 & } 1472 & ENDIFMACRO IFMACRO(!privateDmesh#ThName) 1473 & assert(0); 1474 & ENDIFMACRO // EOM 1475 & macro transferMat(ThName, Pk, A, ThNew, PkNew, ANew, P) { 1476 & NewMacro transfer#Q() EndMacro transferBase(ThName, Pk, A, ThNew, PkNew, ANew, P) 1477 & } 1478 & // EOM 1479 & macro transfer(ThName, Pk, u, ThNew, PkNew, uNew) { 1480 & transferBase(ThName, Pk, u, ThNew, PkNew, uNew, 1) 1481 & } 1482 & // EOM 1483 & macro createParMmgCommunicators(ThName, ThParMmgName, ThN2O, ThCommunicators) { 1484 & IFMACRO(!privateDmesh#ThName) 1485 & assert(0); 1486 & ENDIFMACRO Mat A; 1487 & createMat(ThName, A, P1); 1488 & real[int] D(ThName.nt); 1489 & createPartition(ThName, D, P0); 1490 & fespace PhPrivate(ThName, P0); 1491 & PhPrivate d; 1492 & d[] = D; 1493 & ThParMmgName = trunc(ThName, abs(d) > 1.0e-2, label = -111111, new2old = ThN2O); 1494 & fespace VhWithoutOverlapPrivate(ThParMmgName, P1); 1495 & varf vG(u, v) = on(-111111, u = 1.0); 1496 & real[int] gamma(ThParMmgName.nv); 1497 & gamma = vG(0, VhWithoutOverlapPrivate, tgv = -1); 1498 & fespace VhWithOverlapPrivate(ThName, P1); 1499 & int[int] restriction = restrict(VhWithoutOverlapPrivate, VhWithOverlapPrivate, ThN2O); 1500 & ParMmgCommunicators(A, gamma, restriction, ThCommunicators); 1501 & }// EOM 1502 & macro gatherDmesh(ThName, comm, ThGatherName) { 1503 & IFMACRO(!privateDmesh#ThName) 1504 & assert(0); 1505 & ENDIFMACRO IFMACRO(!ThName#Comm) 1506 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThGatherName#Comm) 1507 & NewMacro ThGatherName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThName#Comm) 1508 & mpiBarrier(ThName#Comm); 1509 & real timerGather = mpiWtime(); 1510 & int size; 1511 & if(ThGatherName#Comm) 1512 & size = mpiSize(comm); 1513 & else size = 0; 1514 & int reduce; 1515 & mpiAllReduce(size, reduce, ThName#Comm, mpiSUM); 1516 & assert(reduce == mpiSize(ThName#Comm)); 1517 & meshN ThNoOverlap; 1518 & if(mpiSize(ThName#Comm) == 1) 1519 & ThNoOverlap = ThName; 1520 & else ThNoOverlap = trunc(ThName, abs(privateDmesh#ThName#khiDef[1][nuTriangle] - mpiRank(ThName#Comm)) < 1.0e-2, label = -111112); 1521 & if(ThGatherName#Comm) { 1522 & meshN[int] recvTh(size); 1523 & mpiRequest[int] rqRecv(size - 1); 1524 & for(int i = 1; i < size; ++i) 1525 & Irecv(processor(i, comm, rqRecv[i - 1]), recvTh[i]); 1526 & recvTh[0] = ThNoOverlap; 1527 & mpiWaitAll(rqRecv); 1528 & ThGatherName = gluemesh(recvTh); 1529 & } 1530 & else { 1531 & mpiRequest rqSend; 1532 & Isend(processor(0, comm, rqSend), ThNoOverlap); 1533 & mpiWait(rqSend); 1534 & } 1535 & if(verbosity > 0 && ThName#Comm) { 1536 & mpiBarrier(ThName#Comm); 1537 & if(mpiRank(ThName#Comm) == 0) 1538 & cout.scientific << " --- distributed mesh gathered (in " << mpiWtime() - timerGather << ")" << endl; 1539 & } 1540 & } 1541 & reconstructDmesh(ThGatherName) 1542 & // EOM 1543 & macro scatterDmesh(ThName, comm, ThScatterName) { 1544 & IFMACRO(!privateDmesh#ThName) 1545 & assert(0); 1546 & ENDIFMACRO IFMACRO(!ThName#Comm) 1547 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThScatterName#Comm) 1548 & NewMacro ThScatterName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThScatterName#Comm) 1549 & mpiBarrier(ThScatterName#Comm); 1550 & real timerScatter = mpiWtime(); 1551 & int size; 1552 & if(ThName#Comm) { 1553 & size = mpiSize(comm); 1554 & } 1555 & else size = 0; 1556 & int reduce; 1557 & mpiAllReduce(size, reduce, ThScatterName#Comm, mpiSUM); 1558 & assert(reduce == mpiSize(ThScatterName#Comm)); 1559 & if(ThName#Comm) { 1560 & meshN ThNoOverlap; 1561 & if(mpiSize(ThName#Comm) == 1) 1562 & ThNoOverlap = ThName; 1563 & else ThNoOverlap = trunc(ThName, abs(privateDmesh#ThName#khiDef[1][nuTriangle] - mpiRank(ThName#Comm)) < 1.0e-2, label = -111112); 1564 & fespace PhPartPrivate(ThNoOverlap, P0); 1565 & PhPartPrivate part; 1566 & partitionerSeq(part[], ThNoOverlap, mpiSize(comm)); 1567 & partitionerPar(part[], ThNoOverlap, mpiCommSelf, mpiSize(comm)); 1568 & meshN[int] sendTh(mpiSize(comm) - 1); 1569 & mpiRequest[int] rqSend(mpiSize(comm) - 1); 1570 & for(int i = 1; i < mpiSize(comm); ++i) { 1571 & sendTh[i - 1] = trunc(ThNoOverlap, abs(part - i) < 1.0e-2, label = -111112); 1572 & Isend(processor(i, comm, rqSend[i - 1]), sendTh[i - 1]); 1573 & } 1574 & ThScatterName = trunc(ThNoOverlap, abs(part) < 1.0e-2, label = -111112); 1575 & mpiWaitAll(rqSend); 1576 & } 1577 & else if(ThScatterName#Comm) { 1578 & mpiRequest rqRecv; 1579 & Irecv(processor(0, comm, rqRecv), ThScatterName); 1580 & mpiWait(rqRecv); 1581 & } 1582 & if(verbosity > 0 && ThScatterName#Comm) { 1583 & mpiBarrier(ThScatterName#Comm); 1584 & if(mpiRank(ThScatterName#Comm) == 0) 1585 & cout.scientific << " --- distributed mesh scattered (in " << mpiWtime() - timerScatter << ")" << endl; 1586 & } 1587 & } 1588 & reconstructDmesh(ThScatterName) 1589 & // EOM 1590 & macro gatherSolution(ThName, comm, ThGatherName, Pk, u, uNew) { 1591 & IFMACRO(!privateDmesh#ThName) 1592 & assert(0); 1593 & ENDIFMACRO IFMACRO(!privateDmesh#ThGatherName) 1594 & assert(0); 1595 & ENDIFMACRO IFMACRO(!ThName#Comm) 1596 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThGatherName#Comm) 1597 & NewMacro ThGatherName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThName#Comm) 1598 & mpiBarrier(ThName#Comm); 1599 & real timerGather = mpiWtime(); 1600 & if(ThGatherName#Comm) { 1601 & meshN[int] recvTh(mpiSize(comm) - 1); 1602 & PetscScalar[int][int] recvU(mpiSize(comm) - 1); 1603 & mpiRequest[int] rqRecvTh(mpiSize(comm) - 1); 1604 & mpiRequest[int] rqRecvU(mpiSize(comm) - 1); 1605 & for(int i = 0; i < mpiSize(comm) - 1; ++i) 1606 & Irecv(processor(i + 1, comm, rqRecvTh[i]), recvTh[i]); 1607 & for(int i = 0; i < mpiSize(comm) - 1; ++i) { 1608 & int index = mpiWaitAny(rqRecvTh); 1609 & fespace VhRecvPrivate(recvTh[index], Pk); 1610 & recvU[index].resize(VhRecvPrivate.ndof); 1611 & Irecv(processor(index + 1, comm, rqRecvU[index]), recvU[index]); 1612 & } 1613 & fespace VhGlobalGatherPrivate(ThGatherName, Pk); 1614 & PetscScalar[int] visited(VhGlobalGatherPrivate.ndof); 1615 & visited = 1.0; 1616 & { 1617 & fespace VhRestrictionPrivate(ThName, Pk); 1618 & matrix R = interpolate(VhRestrictionPrivate, VhGlobalGatherPrivate); 1619 & PetscScalar[int] buffer = R' * u[]; 1620 & buffer .*= visited; 1621 & PetscScalar[int] ones(VhRestrictionPrivate.ndof); 1622 & ones = -1.0; 1623 & visited += R' * ones; 1624 & for[j, v : visited] v = max(abs(v), 0.0); 1625 & uNew[] += buffer; 1626 & } 1627 & for(int i = 0; i < mpiSize(comm) - 1; ++i) { 1628 & int index = mpiWaitAny(rqRecvU); 1629 & fespace VhRestrictionPrivate(recvTh[index], Pk); 1630 & matrix R = interpolate(VhRestrictionPrivate, VhGlobalGatherPrivate); 1631 & PetscScalar[int] buffer = R' * recvU[index]; 1632 & buffer .*= visited; 1633 & PetscScalar[int] ones(VhRestrictionPrivate.ndof); 1634 & ones = -1.0; 1635 & visited += R' * ones; 1636 & for[j, v : visited] v = max(abs(v), 0.0); 1637 & uNew[] += buffer; 1638 & } 1639 & } 1640 & else { 1641 & mpiRequest[int] rqSend(2); 1642 & Isend(processor(0, comm, rqSend[0]), ThName); 1643 & fespace VhLocalGatherPrivate(ThName, Pk); 1644 & assert(u[].n == VhLocalGatherPrivate.ndof); 1645 & Isend(processor(0, comm, rqSend[1]), u[]); 1646 & mpiWaitAll(rqSend); 1647 & } 1648 & if(verbosity > 0 && ThName#Comm) { 1649 & mpiBarrier(ThName#Comm); 1650 & if(mpiRank(ThName#Comm) == 0) 1651 & cout.scientific << " --- distributed solution gathered (in " << mpiWtime() - timerGather << ")" << endl; 1652 & } 1653 & } // EOM 1654 & macro scatterSolution(ThName, comm, ThScatterName, Pk, u, uNew) { 1655 & IFMACRO(!privateDmesh#ThName) 1656 & assert(0); 1657 & ENDIFMACRO IFMACRO(!privateDmesh#ThScatterName) 1658 & assert(0); 1659 & ENDIFMACRO IFMACRO(!def) 1660 & NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!ThName#Comm) 1661 & NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThScatterName#Comm) 1662 & NewMacro ThScatterName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThScatterName#Comm) 1663 & mpiBarrier(ThScatterName#Comm); 1664 & real timerScatter = mpiWtime(); 1665 & if(mpiRank(comm) == 0) { 1666 & broadcast(processor(0, comm), ThName); 1667 & broadcast(processor(0, comm), u[]); 1668 & def(uNew) = def(u); 1669 & } 1670 & else { 1671 & meshN ThGlobalScatter; 1672 & broadcast(processor(0, comm), ThGlobalScatter); 1673 & fespace VhGlobalScatterPrivate(ThGlobalScatter, Pk); 1674 & VhGlobalScatterPrivate def(uGlobalScatter); 1675 & broadcast(processor(0, comm), uGlobalScatter[]); 1676 & def(uNew) = def(uGlobalScatter); 1677 & } 1678 & if(verbosity > 0 && ThScatterName#Comm) { 1679 & mpiBarrier(ThScatterName#Comm); 1680 & if(mpiRank(ThScatterName#Comm) == 0) 1681 & cout.scientific << " --- distributed solution scattered (in " << mpiWtime() - timerScatter << ")" << endl; 1682 & } 1683 & } 1684 & // EOM ENDIFMACRO 2 @ macro macroDDMidp()1// EOM 3 @ include "getARGV.idp" // for gestion of FreeFem++ argument and in version 3.10-1 FH 2 : // F. Hecht 3 : // Usage: getARGV(n,defaultvalue) // get the fist used default valeu 4 : // or getARGV(after,defaultvalue) // get the arg after after 5 : // the type of delfaut value given the return type: int,double, string 6 : // Modif version 3.54-2 Jan 2018 (add ones include) 7 : IFMACRO(!getARGVidp) 8 & macro getARGVidp 1 // 9 & 10 & 11 & func int usedARGV(int n) 12 & { 13 & int k=1,ii=1,kk=1,ret=-1; 14 & for(int i=1;i=0;--i) 41 & if(ARGV[i]==after) { ret=++i; break;} 42 & if(ARGV.n0) d=strtol(ARGV[k]); 51 & return d; 52 & } 53 & func real getARGV(int n,real default) 54 & { 55 & real d=default; 56 & int k=usedARGV(n); 57 & if(k>0) d=strtod(ARGV[k]); 58 & return d; 59 & } 60 & func string getARGV(int n,string default) 61 & { 62 & string d=default; 63 & int k=usedARGV(n); 64 & if(k>0) d=ARGV[k]; 65 & return d; 66 & } 67 & 68 & func int getARGV(string after,int default) 69 & { 70 & int d=default; 71 & int k=usedARGV(after); 72 & if(k>0) d=strtol(ARGV[k]); 73 & return d; 74 & } 75 & func real getARGV(string after,real default) 76 & { 77 & real d=default; 78 & int k=usedARGV(after); 79 & if(k>0) d=strtod(ARGV[k]); 80 & return d; 81 & } 82 & func string getARGV(string after,string default) 83 & { 84 & string d=default; 85 & int k=usedARGV(after); 86 & if(k>0) d=ARGV[k]; 87 & return d; 88 & } 89 & 90 & /* 91 & cout << getARGV(1,100) << endl; 92 & cout << getARGV(2,200.) << endl; 93 & cout << getARGV(3,"300.000") << endl; 94 & cout << getARGV("-n"," xxx") << endl; 95 & */ 96 & ENDIFMACRO 8 @ macro getARGVidp 1 // 9 @ 10 @ 11 @ func int usedARGV(int n) 12 @ { 13 @ int k=1,ii=1,kk=1,ret=-1; 14 @ for(int i=1;i=0;--i) 41 @ if(ARGV[i]==after) { ret=++i; break;} 42 @ if(ARGV.n0) d=strtol(ARGV[k]); 51 @ return d; 52 @ } 53 @ func real getARGV(int n,real default) 54 @ { 55 @ real d=default; 56 @ int k=usedARGV(n); 57 @ if(k>0) d=strtod(ARGV[k]); 58 @ return d; 59 @ } 60 @ func string getARGV(int n,string default) 61 @ { 62 @ string d=default; 63 @ int k=usedARGV(n); 64 @ if(k>0) d=ARGV[k]; 65 @ return d; 66 @ } 67 @ 68 @ func int getARGV(string after,int default) 69 @ { 70 @ int d=default; 71 @ int k=usedARGV(after); 72 @ if(k>0) d=strtol(ARGV[k]); 73 @ return d; 74 @ } 75 @ func real getARGV(string after,real default) 76 @ { 77 @ real d=default; 78 @ int k=usedARGV(after); 79 @ if(k>0) d=strtod(ARGV[k]); 80 @ return d; 81 @ } 82 @ func string getARGV(string after,string default) 83 @ { 84 @ string d=default; 85 @ int k=usedARGV(after); 86 @ if(k>0) d=ARGV[k]; 87 @ return d; 88 @ } 89 @ 90 @ /* 91 @ cout << getARGV(1,100) << endl; 92 @ cout << getARGV(2,200.) << endl; 93 @ cout << getARGV(3,"300.000") << endl; 94 @ cout << getARGV("-n"," xxx") << endl; 95 @ */ 96 @ 4 @ IFMACRO(!partitioner) 5 & macro partitioner()metis// EOM ENDIFMACRO 5 @ macro partitioner()metis// EOM 6 @ 6 @ IFMACRO(partitioner,metis) 7 & load "metis" 8 & macro partitionerSeq(part, Th, size){ if(size <= 1) part = 0; else metisdual(part, Th, size); }// EOM macro partitionerPar(part, Th, comm, size)broadcast(processor(0, comm), part)// EOM ENDIFMACRO 7 @ load "metis" load: init metis (v 5 ) 8 @ macro partitionerSeq(part, Th, size){ if(size <= 1) part = 0; else metisdual(part, Th, size); } ) // EOM 9 @ macro partitionerPar(part, Th, comm, size)broadcast(processor(0, comm), part) ) // EOM 10 @ 9 @ IFMACRO(partitioner,scotch) 10 & load "scotch" 11 & macro partitionerSeq(part, Th, size){ if(size <= 1) part = 0; else scotch(part, Th, size); }// EOM macro partitionerPar(part, Th, comm, size)broadcast(processor(0, comm), part)// EOM ENDIFMACRO 12 @ IFMACRO(partitioner,parmetis) 13 & load "parmetis" 14 & macro partitionerSeq(part, Th, size)// EOM macro partitionerPar(part, Th, comm, size)parmetis(part, Th, size, communicator = comm, worker = getARGV("-parmetis_worker", 1))// EOM ENDIFMACRO 15 @ IFMACRO(!partitionerSeq) 16 & cout << "The macro 'partitioner' must be set to 'metis', 'scotch', or 'parmetis'" << endl; 17 & exit(1); 18 & ENDIFMACRO 19 @ IFMACRO(dimension,2) 20 & macro meshN()mesh// EOM // two-dimensional problem macro intN()int2d// EOM // two-dimensional integral macro intN1()int1d// EOM // one-dimensional integral macro readmeshN()readmesh// EOM // two-dimensional problem macro defVel(u)[u, u#Y]// EOM // two-dimensional velocity for convect/advect ENDIFMACRO 20 @ macro meshN()mesh// EOM // two-dimensional problem 21 @ macro intN()int2d// EOM // two-dimensional integral 22 @ macro intN1()int1d// EOM // one-dimensional integral 23 @ macro readmeshN()readmesh// EOM // two-dimensional problem 24 @ macro defVel(u)[u, u#Y] ) // EOM // two-dimensional velocity for convect/advect 25 @ 21 @ IFMACRO(dimension,3) 22 & load "msh3" 23 & macro meshN()mesh3// EOM // three-dimensional problem macro intN()int3d// EOM // three-dimensional integral macro intN1()int2d// EOM // two-dimensional integral macro readmeshN()readmesh3// EOM // three-dimensional problem macro defVel(u)[u, u#Y, u#Z]// EOM // three-dimensional velocity for convect/advect ENDIFMACRO 24 @ IFMACRO(dimension,3S) 25 & load "msh3" 26 & macro meshN()meshS// EOM // three-dimensional surface problem macro intN()int2d// EOM // two-dimensional integral macro intN1()int1d// EOM // one-dimensional integral macro intNxN()int2dx2d// EOM // two-dimensional integral for BEM ENDIFMACRO 27 @ IFMACRO(dimension,3L) 28 & load "msh3" 29 & macro meshN()meshL// EOM // three-dimensional line problem macro intN()int1d// EOM // one-dimensional integral macro intN1()int0d// EOM // zero-dimensional integral macro intNxN()int1dx1d// EOM // one-dimensional integral for BEM ENDIFMACRO 30 @ 31 @ macro plotDmesh(Th, params) 32 # if(!NoGraphicWindow || usedARGV("-fglut") != -1) { 33 # fespace PhPlotPrivate(Th, P0); 34 # PhPlotPrivate plt; 35 # if(Th.nt) 36 # plt[] = mpirank; 37 # NewMacro defPlt#Th(u)u EndMacro plotMPI(Th, plt, P0, defPlt#Th, real, params) 38 # } ) // 39 @ 40 @ macro plotD(Th, u, params) 41 # if(!NoGraphicWindow || usedARGV("-fglut") != -1) { 42 # fespace VhPlotPrivate(Th, P1); 43 # VhPlotPrivate plt; 44 # if(Th.nt) 45 # plt = u; 46 # NewMacro defPlt#Th(v)v EndMacro plotMPI(Th, plt, P1, defPlt#Th, real, params) 47 # } ) // 48 @ 49 @ macro plotMPI(Th, u, Pk, def, K, params) 50 # if(!NoGraphicWindow || usedARGV("-fglut") != -1) { 51 # IFMACRO(!meshN) 52 # NewMacro meshN()mesh EndMacro ENDIFMACRO IFMACRO(!def) 53 # NewMacro def(i)i EndMacro ENDIFMACRO meshN ThCurrent = Th; 54 # fespace XhPlotPrivate(ThCurrent, Pk); 55 # XhPlotPrivate def(uSend); 56 # if(ThCurrent.nt) 57 # def(uSend) = u; 58 # if(mpirank == 0) { 59 # meshN[int] meshTab(mpisize); 60 # XhPlotPrivate[int] def(uTab)(mpisize); 61 # if(ThCurrent.nt) 62 # uTab[0][] = uSend[]; 63 # meshTab[0] = ThCurrent; 64 # mpiRequest[int] rq(mpisize - 1); 65 # for(int i = 1; i < mpisize; ++i) 66 # Irecv(processor(i, mpiCommWorld, rq[i - 1]), meshTab[i]); 67 # mpiWaitAll(rq); 68 # for(int i = 1; i < mpisize; ++i) { 69 # ThCurrent = meshTab[i]; 70 # if(ThCurrent.nt) 71 # Irecv(processor(i, mpiCommWorld, rq[i - 1]), uTab[i][]); 72 # } 73 # mpiWaitAll(rq); 74 # plot(def(uTab), params); 75 # } 76 # else { 77 # mpiRequest[int] rq(2); 78 # Isend(processor(0, rq[0]), ThCurrent); 79 # if(ThCurrent.nt) 80 # Isend(processor(0, rq[1]), uSend[]); 81 # mpiWaitAll(rq); 82 # } 83 # } ) // EOM 84 @ 85 @ macro partitionPrivate(meshName, borderName, globalName, PhGlobalPrivate, VhGlobalPrivate, part, rank, size, s, overlap, level, prolongation, D, P, intersection, comm, fakeInterface, PkPart, defPart, initPart, bs) { 86 # int backupSM = searchMethod; 87 # searchMethod = 1; 88 # assert(level >= 1); 89 # IFMACRO(!privateCreatePartition) 90 # IFMACRO(!privateCreateMat) 91 # intersection.resize(1); 92 # intersection[0].resize(0); 93 # PhGlobalPrivate supp; 94 # VhGlobalPrivate suppSmooth; 95 # { 96 # int constant = rank; 97 # for[i, v : supp[]] v = abs(part[][i] - constant) < 0.1; 98 # AddLayers(globalName, supp[], 2 * overlap, suppSmooth[]); 99 # int[int] n2o; 100 # meshN neighbors; 101 # bool connected = false; 102 # for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 103 # if(!connected) 104 # n2o.resize(0); 105 # else neighbors = trunc(globalName, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 106 # int[int] partOverlap(n2o.n); 107 # for[i, v : n2o] partOverlap[i] = part[][v]; 108 # Unique(partOverlap, intersection[0], remove = constant); 109 # if(s > 1 && level <= 1) { 110 # globalName = trunc(globalName, suppSmooth > 0.001, split = s); 111 # supp = abs(part - constant) < 0.1; 112 # suppSmooth = 0; 113 # AddLayers(globalName, supp[], 2 * overlap, suppSmooth[]); 114 # } 115 # } 116 # int[int] n2oNeighbor; 117 # IFMACRO(!privateDmesh#CartesianPartitioning) 118 # globalName = trunc(globalName, suppSmooth > 0.001, label = 9999 119 # IFMACRO(privateDmesh#N2O) 120 # , new2old = n2oNeighbor ENDIFMACRO ); 121 # ENDIFMACRO real eps = globalName.measure; 122 # real[int] epsTab(intersection[0].n); 123 # mpiRequest[int] rq(2 * intersection[0].n); 124 # if(mpiSize(comm) == size) { 125 # for(int j = 0; j < intersection[0].n; ++j) 126 # Irecv(processor(intersection[0][j], comm, rq[j]), epsTab[j]); 127 # for(int j = 0; j < intersection[0].n; ++j) 128 # Isend(processor(intersection[0][j], comm, rq[intersection[0].n + j]), eps); 129 # } 130 # else epsTab = 1.0e+30; 131 # suppSmooth = suppSmooth; 132 # IFMACRO(!privateDmesh#N2O) 133 # meshName[level - 1] = trunc(globalName, suppSmooth > 0.501, label = fakeInterface, new2old = n2oNeighbor); 134 # IFMACRO(privateDmesh#CartesianPartitioning) 135 # real[int] bb(2 * dimension); 136 # boundingbox(meshName[level - 1], bb); 137 # meshName[level - 1] = trunc(globalName, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 138 # IFMACRO(dimension,3) 139 # && z > bb[4] && z < bb[5] 140 # ENDIFMACRO , label = fakeInterface); 141 # globalName = meshName[level - 1]; 142 # n2oNeighbor = 0:globalName.nt - 1; 143 # ENDIFMACRO ENDIFMACRO IFMACRO(privateDmesh#N2O) 144 # meshName[level - 1] = trunc(globalName, suppSmooth > 0.501, label = fakeInterface, new2old = privateDmesh#N2O); 145 # IFMACRO(privateDmesh#CartesianPartitioning) 146 # real[int] bb(2 * dimension); 147 # boundingbox(meshName[level - 1], bb); 148 # meshName[level - 1] = trunc(globalName, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 149 # IFMACRO(dimension,3) 150 # && z > bb[4] && z < bb[5] 151 # ENDIFMACRO , label = fakeInterface, new2old = privateDmesh#N2O); 152 # globalName = meshName[level - 1]; 153 # n2oNeighbor = 0:globalName.nt - 1; 154 # ENDIFMACRO IFMACRO(!privateDmesh#CartesianPartitioning) 155 # { 156 # int[int] backup = privateDmesh#N2O; 157 # int[int] new = n2oNeighbor(privateDmesh#N2O); 158 # privateDmesh#N2O.resize(new.n); 159 # privateDmesh#N2O = new; 160 # n2oNeighbor.resize(backup.n); 161 # n2oNeighbor = backup; 162 # } 163 # ENDIFMACRO ENDIFMACRO if(level > 1) { 164 # prolongation.resize(level - 1); 165 # if(s > 1) { 166 # meshN globalNameRefined = globalName; 167 # for(int i = level - 1; i > 0; --i) { 168 # globalNameRefined = trunc(globalNameRefined, 1, split = s); 169 # meshName[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = fakeInterface); 170 # fespace WhLocalRefinedPrivate(meshName[i - 1], P); 171 # fespace WhLocalCoarsePrivate(meshName[i], P); 172 # prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 173 # } 174 # } 175 # else for(int i = level - 1; i > 0; --i) 176 # meshName[i - 1] = meshName[i]; 177 # } 178 # if(!removeZeros && (fakeInterface != -111111 || overlap != 1)) { 179 # if(suppSmooth[].min < 0.501) { 180 # supp = supp; 181 # borderName[level - 1] = trunc(globalName, (suppSmooth > (overlap - 0.999) / real(2 * overlap)) && (suppSmooth < 0.501), label = (abs(fakeInterface) + 1) * 100); 182 # if(s > 1) 183 # for(int i = level - 2; i >= 0; --i) { 184 # borderName[i] = trunc(borderName[i + 1], 1, split = s, label = (abs(fakeInterface) + 1) * 100); 185 # meshN tempRefined = meshName[i] + borderName[i]; 186 # fespace PhRefinedPrivate(tempRefined, P0); 187 # PhRefinedPrivate suppRefined = supp; 188 # fespace VhBorderRefinedPrivate(borderName[i], P1); 189 # VhBorderRefinedPrivate suppBorder = suppRefined; 190 # borderName[i] = trunc(borderName[i], suppBorder > 0.01); 191 # } 192 # else for(int i = level - 2; i >= 0; --i) 193 # borderName[i] = borderName[i + 1]; 194 # } 195 # } 196 # fespace VhLocalPrivate(meshName[level - 1], P1); 197 # VhLocalPrivate[int] partitionIntersection(intersection[0].n); 198 # VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 199 # VhLocalPrivate sum = khi; 200 # VhGlobalPrivate phi; 201 # part = part; 202 # int numberIntersection = 0; 203 # { 204 # int[int] restriction = restrict(VhLocalPrivate, VhGlobalPrivate, n2oNeighbor); 205 # n2oNeighbor.resize(0); 206 # mpiWaitAll(rq); 207 # for(int i = 0; i < intersection[0].n; ++i) { 208 # PhGlobalPrivate suppPartition = abs(part - intersection[0][i]) < 0.1; 209 # AddLayers(globalName, suppPartition[], overlap, phi[]); 210 # if(min(eps, epsTab[i]) > 0.0) { 211 # if(intN(globalName)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 212 # partitionIntersection[numberIntersection][] = phi[](restriction); 213 # if(!trueRestrict) 214 # sum[] += partitionIntersection[numberIntersection][]; 215 # intersection[0][numberIntersection++] = intersection[0][i]; 216 # } 217 # } 218 # } 219 # } 220 # if(numberIntersection != intersection[0].n) 221 # intersection[0].resize(numberIntersection); 222 # intersection.resize(1 + level * numberIntersection); 223 # ENDIFMACRO IFMACRO(privateCreateMat) 224 # assert(level == 1); 225 # int numberIntersection = privateDmesh#meshName#intersectionDef.n - 1; 226 # intersection.resize(1 + level * numberIntersection); 227 # intersection[0].resize(numberIntersection); 228 # fespace VhLocalPrivate(meshName[level - 1], P1); 229 # VhLocalPrivate[int] partitionIntersection(numberIntersection); 230 # for(int i = 0; i < numberIntersection; ++i) { 231 # intersection[0][i] = privateDmesh#meshName#intersectionDef[0][i]; 232 # partitionIntersection[i][] = privateDmesh#meshName#intersectionDef[1 + i]; 233 # } 234 # IFMACRO(privateDmesh#N2O) 235 # IFMACRO(privateDmesh#Original) 236 # IFMACRO(privateDmesh#Restriction) 237 # { 238 # fespace WhLocalPrivate(meshName[level - 1], P); 239 # fespace WhOriginalPrivate(privateDmesh#Original, P); 240 # privateDmesh#Restriction.resize(WhOriginalPrivate.ndof); 241 # privateDmesh#Restriction = restrict(WhLocalPrivate, WhOriginalPrivate, privateDmesh#N2O); 242 # } 243 # ENDIFMACRO ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(privateBuildDmesh) 244 # privateDmesh#meshName#intersectionDef.resize(1 + numberIntersection); 245 # privateDmesh#meshName#intersectionDef[0].resize(numberIntersection); 246 # for(int i = 0; i < numberIntersection; ++i) { 247 # privateDmesh#meshName#intersectionDef[0][i] = intersection[0][i]; 248 # privateDmesh#meshName#intersectionDef[1 + i].resize(VhLocalPrivate.ndof); 249 # privateDmesh#meshName#intersectionDef[1 + i] = partitionIntersection[i][]; 250 # } 251 # ENDIFMACRO meshN[int] meshIntersection(numberIntersection); 252 # for(int j = 0; j < (s == 1 ? 1 : level); ++j) { 253 # for(int i = 0; i < numberIntersection; ++i) { 254 # int[int] n2o; 255 # meshIntersection[i] = trunc(meshName[j], partitionIntersection[i] > 1.0e-6, new2old = n2o, label = 9999); 256 # IFMACRO(privateDmesh#CartesianPartitioning) 257 # real[int] bb(2 * dimension); 258 # boundingbox(meshIntersection[i], bb); 259 # meshIntersection[i] = trunc(meshName[j], x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 260 # IFMACRO(dimension,3) 261 # && z > bb[4] && z < bb[5] 262 # ENDIFMACRO , new2old = n2o, label = 9999); 263 # ENDIFMACRO IFMACRO(!privateCreateMat) 264 # if(!removeZeros) 265 # ENDIFMACRO { 266 # IFMACRO(vectorialfe) 267 # fespace singleComponentWhPrivate(meshName[j], vectorialfe); 268 # fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 269 # ENDIFMACRO IFMACRO(!vectorialfe) 270 # fespace singleComponentWhPrivate(meshName[j], P); 271 # fespace WhIntersectionPrivate(meshIntersection[i], P); 272 # ENDIFMACRO intersection[1 + i + j * numberIntersection] = restrict(WhIntersectionPrivate, singleComponentWhPrivate, n2o); 273 # } 274 # } 275 # } 276 # IFMACRO(!privateCreateMat) 277 # if(s == 1 && level > 1 && !removeZeros) 278 # for(int j = 1; j < level; ++j) 279 # for(int i = 0; i < numberIntersection; ++i) { 280 # intersection[1 + i + j * numberIntersection].resize(intersection[1 + i].n); 281 # intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 282 # } 283 # partitionIntersection.resize(0); 284 # for(int i = 0; i < (trueRestrict ? level : level - 1); ++i) { 285 # fespace VhRefinedPrivate(meshName[i], P1); 286 # fespace PhRefinedPrivate(meshName[i], P0); 287 # PhRefinedPrivate partRefined = part; 288 # PhRefinedPrivate supp = abs(partRefined - rank) < 0.1; 289 # varf vSupp(u, v) = intN(meshName[i], qforder = 1)(supp * v); 290 # VhRefinedPrivate khiL; 291 # khiL[] = vSupp(0, VhRefinedPrivate); 292 # khiL = khiL > 0.0; 293 # VhRefinedPrivate sum = khiL; 294 # for(int j = 0; j < numberIntersection; ++j) { 295 # supp = abs(partRefined - intersection[0][j]) < 0.1; 296 # VhRefinedPrivate phiL; 297 # phiL[] = vSupp(0, VhRefinedPrivate); 298 # phiL = phiL > 0.0; 299 # sum[] += phiL[]; 300 # } 301 # khiL[] ./= sum[]; 302 # if(i < level - 1) { 303 # fespace WhRefinedPrivate(meshName[i], PkPart); 304 # WhRefinedPrivate defPart(func2vec); 305 # defPart(func2vec) = initPart(khiL); 306 # D[i].resize(WhRefinedPrivate.ndof); 307 # D[i] = func2vec[]; 308 # } 309 # else khi[] = khiL[]; 310 # } 311 # if(!trueRestrict) 312 # khi[] = khi[] ./= sum[]; 313 # if(trueRestrict && mpiSize(comm) == size && removeZeros) { 314 # assert(level == 1); 315 # meshN ThIntersection; 316 # fespace PhIntersectionPrivate(ThIntersection, P0); 317 # PhIntersectionPrivate[int] recv(numberIntersection); 318 # PhIntersectionPrivate[int] send(numberIntersection); 319 # mpiRequest[int] rq(2 * numberIntersection); 320 # for(int i = 0; i < numberIntersection; ++i) { 321 # ThIntersection = meshIntersection[i]; 322 # Irecv(processor(intersection[0][i], comm, rq[i]), recv[i][]); 323 # send[i] = khi; 324 # Isend(processor(intersection[0][i], comm, rq[numberIntersection + i]), send[i][]); 325 # } 326 # meshName[0] = trunc(meshName[0], khi > 1.0e-6, label = 9999); 327 # khi = khi; 328 # int[int] skip(0); 329 # for(int k = 0; k < 2 * numberIntersection; ++k) { 330 # int i = mpiWaitAny(rq); 331 # if(i < numberIntersection) { 332 # ThIntersection = meshIntersection[i]; 333 # PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 334 # if(intersection[].l2 > 1.0e-6) 335 # meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 336 # else { 337 # skip.resize(skip.n + 1); 338 # skip[skip.n - 1] = i; 339 # } 340 # } 341 # } 342 # skip.sort; 343 # intersection.resize(1 + numberIntersection - skip.n); 344 # int j = 0; 345 # for(int i = 0; i < numberIntersection; ++i) { 346 # bool skipped = false; 347 # if(j < skip.n) { 348 # if(skip[j] == i) { 349 # ++j; 350 # skipped = true; 351 # } 352 # } 353 # if(!skipped) { 354 # IFMACRO(vectorialfe) 355 # fespace singleComponentWhPrivate(meshName[0], vectorialfe); 356 # fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 357 # ENDIFMACRO IFMACRO(!vectorialfe) 358 # fespace singleComponentWhPrivate(meshName[0], P); 359 # fespace WhIntersectionPrivate(meshIntersection[i], P); 360 # ENDIFMACRO matrix meshName#R = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 361 # meshName#R.thresholding(1.0e-10); 362 # real[int] meshName#C; 363 # int[int] meshName#I; 364 # [meshName#I, intersection[1 + i - j], meshName#C] = meshName#R; 365 # intersection[1 + i - j].resize(meshName#R.nbcoef); 366 # intersection[0][i - j] = intersection[0][i]; 367 # } 368 # } 369 # numberIntersection -= skip.n; 370 # intersection[0].resize(numberIntersection); 371 # if(fakeInterface != -111111 || overlap != 1) { 372 # PhGlobalPrivate suppPartition = khi > 0.1; 373 # AddLayers(globalName, suppPartition[], 1, phi[]); 374 # borderName[0] = trunc(globalName, phi > 0.001 && phi < 0.501, label = (abs(fakeInterface) + 1) * 100); 375 # } 376 # } 377 # ENDIFMACRO IFMACRO(vectorialfe) 378 # if(bs > 1) 379 # for(int i = 0; i < intersection.n - 1; ++i) { 380 # int n = intersection[1 + i].n; 381 # intersection[1 + i].resize(n * bs); 382 # for(int j = n - 1; j != -1; --j) 383 # for(int k = bs - 1; k != -1; --k) 384 # intersection[1 + i][j * bs + k] = intersection[1 + i][j] * bs + k; 385 # } 386 # ENDIFMACRO ENDIFMACRO IFMACRO(privateCreatePartition) 387 # fespace VhLocalPrivate(meshName[level - 1], P1); 388 # IFMACRO(!privateCreateMat) 389 # VhLocalPrivate khi; 390 # ENDIFMACRO ENDIFMACRO IFMACRO(privateCreateMat) 391 # VhLocalPrivate khi; 392 # khi[] = privateDmesh#meshName#khiDef[0]; 393 # ENDIFMACRO fespace WhPartPrivate(meshName[level - 1], PkPart); 394 # WhPartPrivate defPart(func2vec); 395 # D[level - 1].resize(WhPartPrivate.ndof); 396 # if((WhPartPrivate.ndof % meshName[level - 1].nt) == 0) { 397 # int constant = rank; 398 # IFMACRO(privateCreateMat) 399 # fespace PhLocalPrivate(meshName[level - 1], P0); 400 # PhLocalPrivate partLocal; 401 # partLocal[] = privateDmesh#meshName#khiDef[1]; 402 # defPart(func2vec) = initPart(abs(partLocal - constant) < 0.1); 403 # ENDIFMACRO IFMACRO(!privateCreateMat) 404 # defPart(func2vec) = initPart(abs(part - constant) < 0.1); 405 # ENDIFMACRO } 406 # else if(WhPartPrivate.ndof == meshName[level - 1].nv) { 407 # func2vec[] = khi[]; 408 # } 409 # else { 410 # defPart(func2vec) = initPart(khi); 411 # } 412 # D[level - 1] = func2vec[]; 413 # IFMACRO(!privateCreatePartition) 414 # IFMACRO(!privateCreateMat) 415 # IFMACRO(privateBuildDmesh) 416 # fespace PhLocalPrivate(meshName[level - 1], P0); 417 # PhLocalPrivate partLocal; 418 # partLocal = part; 419 # privateDmesh#meshName#khiDef[1].resize(partLocal[].n); 420 # privateDmesh#meshName#khiDef[1] = partLocal[]; 421 # ENDIFMACRO ENDIFMACRO ENDIFMACRO searchMethod = backupSM; 422 # } ) // EOM 423 @ 424 @ macro saveDmesh(ThName, name) 425 # IFMACRO(privateDmesh#ThName) 426 # { 427 # IFMACRO(!ThName#Comm) 428 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(dimension,3) 429 # savemesh(ThName, name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".meshb"); 430 # ENDIFMACRO IFMACRO(dimension,2) 431 # savemesh(ThName, name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".msh"); 432 # ENDIFMACRO ofstream khi(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".khi"); 433 # khi << privateDmesh#ThName#khi << endl; 434 # khi << privateDmesh#ThName#intersection << endl; 435 # IFMACRO(ThName#N2O) 436 # khi << ThName#N2O << endl; 437 # ENDIFMACRO } 438 # ENDIFMACRO IFMACRO(!privateDmesh#ThName) 439 # assert(0); 440 # ENDIFMACRO EndMacro ) 441 @ 442 @ macro loadDmesh(ThName, name) 443 # IFMACRO(!privateDmesh#ThName) 444 # NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 445 # real[int][int] privateDmesh#ThName#intersection; 446 # ENDIFMACRO { 447 # IFMACRO(!ThName#Comm) 448 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(dimension,3) 449 # ThName = readmesh3(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".meshb"); 450 # ENDIFMACRO IFMACRO(dimension,2) 451 # ThName = readmesh(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".msh"); 452 # ENDIFMACRO privateDmesh#ThName#khi.resize(2); 453 # privateDmesh#ThName#khi[0].resize(ThName.nv); 454 # privateDmesh#ThName#khi[1].resize(ThName.nt); 455 # if(mpiSize(ThName#Comm) > 1) { 456 # ifstream khi(name + "_" + mpiRank(ThName#Comm) + "_" + mpiSize(ThName#Comm) + ".khi"); 457 # int m; 458 # khi >> m; 459 # assert(m == 2); 460 # khi >> privateDmesh#ThName#khi[0]; 461 # khi >> privateDmesh#ThName#khi[1]; 462 # khi >> m; 463 # privateDmesh#ThName#intersection.resize(m); 464 # for(int j = 0; j < m; ++j) { 465 # int n; 466 # khi >> n; 467 # privateDmesh#ThName#intersection[j].resize(n); 468 # for[i, v : privateDmesh#ThName#intersection[j]] 469 # khi >> v; 470 # } 471 # IFMACRO(ThName#N2O) 472 # ThName#N2O.resize(ThName.nt); 473 # khi >> ThName#N2O; 474 # ENDIFMACRO } 475 # else { 476 # privateDmesh#ThName#khi[0] = 1.0; 477 # privateDmesh#ThName#khi[1] = 1.0; 478 # } 479 # } 480 # EndMacro ) 481 @ 482 @ macro buildDmesh(ThName) 483 # IFMACRO(!privateDmesh#ThName) 484 # NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 485 # real[int][int] privateDmesh#ThName#intersection; 486 # ENDIFMACRO { 487 # IFMACRO(!meshN) 488 # IFMACRO(dimension,3) 489 # NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 490 # NewMacro intN()int3d EndMacro /* three-dimensional integral */ 491 # ENDIFMACRO IFMACRO(dimension,3S) 492 # NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 493 # NewMacro intN()int2d EndMacro /* two-dimensional integral */ 494 # ENDIFMACRO IFMACRO(dimension,3L) 495 # NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 496 # NewMacro intN()int1d EndMacro /* one-dimensional integral */ 497 # ENDIFMACRO IFMACRO(!meshN) 498 # NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 499 # NewMacro intN()int2d EndMacro /* two-dimensional integral */ 500 # ENDIFMACRO ENDIFMACRO IFMACRO(!ThName#Comm) 501 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO NewMacro privateBuildDmesh()1 EndMacro int[int][int] intersection; 502 # NewMacro privateDmesh#ThTab()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThTab#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThTab#intersection()privateDmesh#ThName#intersectionDef EndMacro IFMACRO(ThName#N2O) 503 # NewMacro privateDmesh#N2O()ThName#N2O EndMacro ENDIFMACRO IFMACRO(ThName#UserPartitioning) 504 # buildWithPartitioning(ThName, ThName#UserPartitioning, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm); 505 # ENDIFMACRO IFMACRO(ThName#Periodicity) 506 # buildPeriodic(ThName, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm, ThName#Periodicity); 507 # ENDIFMACRO IFMACRO(!ThName#UserPartitioning) 508 # IFMACRO(!ThName#Periodicity) 509 # IFMACRO(ThName#CartesianPartitioning) 510 # NewMacro privateDmesh#CartesianPartitioning() EndMacro ENDIFMACRO build(ThName, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm); 511 # ENDIFMACRO ENDIFMACRO } 512 # EndMacro ) 513 @ 514 @ macro reconstructDmesh(ThName) 515 # IFMACRO(!privateDmesh#ThName) 516 # NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 517 # real[int][int] privateDmesh#ThName#intersection; 518 # ENDIFMACRO IFMACRO(!ThName#Comm) 519 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(ThName#Comm) { 520 # IFMACRO(!dimension) 521 # NewMacro dimension()2 EndMacro ENDIFMACRO IFMACRO(!meshN) 522 # NewMacro meshN()mesh EndMacro NewMacro intN()int2d EndMacro ENDIFMACRO int[int] neighbors; 523 # { 524 # real[int] bb(2 * dimension); 525 # boundingbox(ThName, bb); 526 # real[int] bbAll(2 * dimension * mpiSize(ThName#Comm)); 527 # mpiAllgather(bb, bbAll, ThName#Comm); 528 # real hmax; 529 # { 530 # real tmp = ThName.hmax; 531 # mpiAllReduce(tmp, hmax, ThName#Comm, mpiMAX); 532 # } 533 # int between = 0; 534 # for(int i = 0; i < mpiSize(ThName#Comm); ++i) { 535 # if(i != mpiRank(ThName#Comm) && 536 # IFMACRO(dimension,2) 537 # !(bbAll[1 + 4 * i] < bb[0] - hmax || bbAll[0 + 4 * i] > bb[1] + hmax || bbAll[3 + 4 * i] < bb[2] - hmax || bbAll[2 + 4 * i] > bb[3] + hmax) 538 # ENDIFMACRO IFMACRO(dimension,3) 539 # !(bbAll[1 + 6 * i] < bb[0] - hmax || bbAll[0 + 6 * i] > bb[1] + hmax || bbAll[3 + 6 * i] < bb[2] - hmax || bbAll[2 + 6 * i] > bb[3] + hmax || bbAll[5 + 6 * i] < bb[4] - hmax || bbAll[4 + 6 * i] > bb[5] + hmax) 540 # ENDIFMACRO ) { 541 # neighbors.resize(neighbors.n + 1); 542 # neighbors[neighbors.n - 1] = i; 543 # } 544 # } 545 # } 546 # reconstructDmeshWithNeighbors(ThName, neighbors) 547 # } 548 # EndMacro ) 549 @ macro reconstructDmeshWithNeighbors(ThName, neighborsName) 550 # IFMACRO(!privateDmesh#ThName) 551 # NewMacro privateDmesh#ThName()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThName#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThName#intersection()privateDmesh#ThName#intersectionDef EndMacro real[int][int] privateDmesh#ThName#khi(2); 552 # real[int][int] privateDmesh#ThName#intersection; 553 # ENDIFMACRO { 554 # IFMACRO(!ThName#Comm) 555 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO real[int] part; 556 # { 557 # if(verbosity > 0) 558 # mpiBarrier(ThName#Comm); 559 # real timerReconstruction = mpiWtime(); 560 # varf vG(u, v) = on(labels(ThName), u = 1.0); 561 # fespace VhGammaPrivate(ThName, P1); 562 # fespace PhGammaPrivate(ThName, P0); 563 # VhGammaPrivate gamma; 564 # gamma[] = vG(0, VhGammaPrivate, tgv = -1); 565 # PhGammaPrivate gammaElt = gamma > 0.1; 566 # meshN ThLocalInit = trunc(ThName, gammaElt > 0.1, label = -111112); 567 # meshN ThLocalInitInterior = trunc(ThName, gammaElt < 0.1, label = -111112); 568 # neighborsName.sort; 569 # int between = 0; 570 # for(int i = 0; i < neighborsName.n; ++i) 571 # if(neighborsName[i] > mpiRank(ThName#Comm)) { 572 # between = i; 573 # break; 574 # } 575 # if(neighborsName.n) 576 # if(neighborsName[neighborsName.n - 1] < mpiRank(ThName#Comm)) 577 # between = neighborsName.n; 578 # meshN[int] ThTab(neighborsName.n + 1); 579 # ThTab[between] = ThLocalInit; 580 # mpiRequest[int] rqRecv(neighborsName.n); 581 # mpiRequest[int] rqSend(neighborsName.n); 582 # for(int i = 0; i < neighborsName.n; ++i) 583 # Isend(processor(neighborsName[i], ThName#Comm, rqSend[i]), ThLocalInit); 584 # for(int i = 0; i < between; ++i) 585 # Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i]); 586 # for(int i = between; i < neighborsName.n; ++i) 587 # Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i + 1]); 588 # mpiWaitAll(rqRecv); 589 # meshN ThLocalNew = gluemesh(ThTab); 590 # int m = 0; 591 # for(int i = 0; i < between; ++i) 592 # m += ThTab[i].nt; 593 # ThTab[between] = trunc(ThLocalNew, nuTriangle >= m && nuTriangle < m + ThTab[between].nt, label = -111111); 594 # mpiWaitAll(rqSend); 595 # for(int i = 0; i < neighborsName.n; ++i) 596 # Isend(processor(neighborsName[i], ThName#Comm, rqSend[i]), ThTab[between]); 597 # for(int i = 0; i < between; ++i) 598 # Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i]); 599 # for(int i = between; i < neighborsName.n; ++i) 600 # Irecv(processor(neighborsName[i], ThName#Comm, rqRecv[i]), ThTab[i + 1]); 601 # mpiWaitAll(rqRecv); 602 # ThTab.resize(neighborsName.n + 2); 603 # ThTab[neighborsName.n + 1] = ThLocalInitInterior; 604 # ThName = gluemesh(ThTab); 605 # IFMACRO(dimension,3) 606 # ThName = change(ThName, rmlfaces = -111112); 607 # ENDIFMACRO IFMACRO(dimension,2) 608 # ThName = change(ThName, rmledges = -111112); 609 # ENDIFMACRO part.resize(ThName.nt); 610 # m = 0; 611 # for(int i = 0; i < between; ++i) { 612 # part(m:m + ThTab[i].nt - 1) = neighborsName[i]; 613 # m += ThTab[i].nt; 614 # } 615 # part(m:m + ThTab[between].nt - 1) = mpiRank(ThName#Comm); 616 # m += ThTab[between].nt; 617 # for(int i = between; i < neighborsName.n; ++i) { 618 # part(m:m + ThTab[i + 1].nt - 1) = neighborsName[i]; 619 # m += ThTab[i + 1].nt; 620 # } 621 # part(part.n - ThLocalInitInterior.nt:ThName.nt - 1) = mpiRank(ThName#Comm); 622 # mpiWaitAll(rqSend); 623 # if(verbosity > 0) { 624 # mpiBarrier(ThName#Comm); 625 # if(mpiRank(ThName#Comm) == 0) 626 # cout.scientific << " --- distributed mesh reconstructed (in " << mpiWtime() - timerReconstruction << ")" << endl; 627 # } 628 # } 629 # NewMacro privateBuildDmesh()1 EndMacro NewMacro privateReconstructDmesh()1 EndMacro int[int][int] intersection; 630 # NewMacro privateDmesh#ThTab()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThTab#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThTab#intersection()privateDmesh#ThName#intersectionDef EndMacro IFMACRO(ThName#N2O) 631 # NewMacro privateDmesh#N2O()ThName#N2O EndMacro ENDIFMACRO buildWithPartitioning(ThName, part, 1, intersection, privateDmesh#ThName#khi[0], P1, ThName#Comm) 632 # } 633 # EndMacro ) 634 @ macro copyDmesh(OldName, NewName) 635 # IFMACRO(!privateDmesh#NewName) 636 # NewMacro privateDmesh#NewName()privateDmesh#NewName EndMacro NewMacro privateDmesh#NewName#khi()privateDmesh#NewName#khiDef EndMacro NewMacro privateDmesh#NewName#intersection()privateDmesh#NewName#intersectionDef EndMacro real[int][int] privateDmesh#NewName#khi(2); 637 # real[int][int] privateDmesh#NewName#intersection; 638 # ENDIFMACRO IFMACRO(privateDmesh#OldName) 639 # NewName = OldName; 640 # privateDmesh#NewName#khi[0].resize(privateDmesh#OldName#khi[0].n); 641 # privateDmesh#NewName#khi[0] = privateDmesh#OldName#khi[0]; 642 # privateDmesh#NewName#khi[1].resize(privateDmesh#OldName#khi[1].n); 643 # privateDmesh#NewName#khi[1] = privateDmesh#OldName#khi[1]; 644 # privateDmesh#NewName#intersection.resize(privateDmesh#OldName#intersection.n); 645 # for(int i = 0; i < privateDmesh#NewName#intersection.n; ++i) { 646 # privateDmesh#NewName#intersection[i].resize(privateDmesh#OldName#intersection[i].n); 647 # privateDmesh#NewName#intersection[i] = privateDmesh#OldName#intersection[i]; 648 # } 649 # ENDIFMACRO EndMacro ) 650 @ macro createMat(ThName, MatName, PkName) 651 # IFMACRO(privateDmesh#ThName) 652 # { 653 # IFMACRO(!meshN) 654 # IFMACRO(dimension,3) 655 # NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 656 # NewMacro intN()int3d EndMacro /* three-dimensional integral */ 657 # ENDIFMACRO IFMACRO(dimension,3S) 658 # NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 659 # NewMacro intN()int2d EndMacro /* two-dimensional integral */ 660 # ENDIFMACRO IFMACRO(dimension,3L) 661 # NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 662 # NewMacro intN()int1d EndMacro /* one-dimensional integral */ 663 # ENDIFMACRO IFMACRO(!meshN) 664 # NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 665 # NewMacro intN()int2d EndMacro /* two-dimensional integral */ 666 # ENDIFMACRO ENDIFMACRO IFMACRO(!ThName#Comm) 667 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!privateCreateMatCheckDmesh) 668 # if(ThName.nv != privateDmesh#ThName#khi[0].n || (privateDmesh#ThName#khi[1].n && ThName.nt != privateDmesh#ThName#khi[1].n)) { 669 # buildDmesh(ThName) 670 # } 671 # ENDIFMACRO NewMacro privateCreateMat()1 EndMacro int[int][int] intersection; 672 # real[int][int] DTab(1); 673 # meshN[int] ThTab(1); 674 # ThTab[0] = ThName; 675 # NewMacro privateDmesh#ThTab()privateDmesh#ThName EndMacro NewMacro privateDmesh#ThTab#khi()privateDmesh#ThName#khiDef EndMacro NewMacro privateDmesh#ThTab#intersection()privateDmesh#ThName#intersectionDef EndMacro IFMACRO(!def) 676 # NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!init) 677 # NewMacro init(i)i EndMacro ENDIFMACRO if(mpiSize(ThName#Comm) > 1) { 678 # IFMACRO(ThName#N2O) 679 # IFMACRO(ThName#Original) 680 # IFMACRO(ThName#Restriction) 681 # NewMacro privateDmesh#N2O()ThName#N2O EndMacro NewMacro privateDmesh#Original()ThName#Original EndMacro NewMacro privateDmesh#Restriction()ThName#Restriction EndMacro ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(!ThName#PkPart) 682 # NewMacro ThName#PkPart()PkName EndMacro ENDIFMACRO IFMACRO(ThName#CartesianPartitioning) 683 # NewMacro privateDmesh#CartesianPartitioning() EndMacro ENDIFMACRO partitionPrivate(ThTab, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, mpiRank(ThName#Comm), mpiSize(ThName#Comm), 1, 1, 1, privateCreateMat, DTab, PkName, intersection, ThName#Comm, -111111, ThName#PkPart, def, init, 1) 684 # } 685 # else { 686 # fespace WhGlobalPrivate(ThName, PkName); 687 # DTab[0].resize(WhGlobalPrivate.ndof); 688 # DTab[0] = 1; 689 # intersection.resize(0); 690 # IFMACRO(ThName#N2O) 691 # IFMACRO(ThName#Original) 692 # IFMACRO(ThName#Restriction) 693 # ThName#Restriction.resize(WhGlobalPrivate.ndof); 694 # ThName#Restriction = 0:WhGlobalPrivate.ndof - 1; 695 # ENDIFMACRO ENDIFMACRO ENDIFMACRO } 696 # IFMACRO(!privateCreatePartition) 697 # constructor(MatName, DTab[0].n, intersection, DTab[0], communicator = ThName#Comm); 698 # ENDIFMACRO IFMACRO(privateCreatePartition) 699 # privateCreatePartition.resize(DTab[0].n); 700 # privateCreatePartition = DTab[0]; 701 # ENDIFMACRO } 702 # ENDIFMACRO IFMACRO(!privateDmesh#ThName) 703 # buildDmesh(ThName) 704 # { 705 # IFMACRO(!meshN) 706 # IFMACRO(dimension,3) 707 # NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 708 # NewMacro intN()int3d EndMacro /* three-dimensional integral */ 709 # ENDIFMACRO IFMACRO(dimension,3S) 710 # NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 711 # NewMacro intN()int2d EndMacro /* two-dimensional integral */ 712 # ENDIFMACRO IFMACRO(dimension,3L) 713 # NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 714 # NewMacro intN()int1d EndMacro /* one-dimensional integral */ 715 # ENDIFMACRO IFMACRO(!meshN) 716 # NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 717 # NewMacro intN()int2d EndMacro /* two-dimensional integral */ 718 # ENDIFMACRO ENDIFMACRO NewMacro privateCreateMatCheckDmesh()1 EndMacro createMat(ThName, MatName, PkName) 719 # } 720 # ENDIFMACRO EndMacro ) 721 @ 722 @ macro createPartition(ThName, PartName, PkName) 723 # IFMACRO(!privateDmesh#ThName) 724 # buildDmesh(ThName) 725 # ENDIFMACRO { 726 # NewMacro privateCreateMatCheckDmesh()1 EndMacro NewMacro privateCreatePartition()PartName EndMacro createMat(ThName, privateCreatePartition, PkName) 727 # } 728 # EndMacro ) 729 @ 730 @ macro buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, DTab, P, comm, excluded, PkPart, defPart, initPart, labPeriodic, userPartitioning, bs) { 731 # IFMACRO(!def) 732 # NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!init) 733 # NewMacro init(i)i EndMacro ENDIFMACRO Th.resize(level); 734 # ThBorder.resize(level); 735 # prolongation.resize(level - 1); 736 # real timerPartition = mpiWtime(); 737 # if(mpiSize(comm) > 1 && !excluded) { 738 # meshN ThGlobal = Th[level - 1]; 739 # fespace PhGlobalPrivate(ThGlobal, P0); 740 # fespace VhGlobalPrivate(ThGlobal, P1); 741 # PhGlobalPrivate partGlobal; 742 # IFMACRO(!privateReconstructDmesh) 743 # IFMACRO(privateDmesh#CartesianPartitioning) 744 # { 745 # real[int] bb(2 * dimension); 746 # boundingbox(ThGlobal, bb); 747 # PhGlobalPrivate xx = x / (bb[1] - bb[0]), yy = y / (bb[3] - bb[2]) 748 # IFMACRO(dimension,2) 749 # ; 750 # int i = int(sqrt(mpiSize(comm))); 751 # while(mpiSize(comm) % i != 0) 752 # --i; 753 # int j = mpiSize(comm) / i; 754 # partGlobal = int(j * xx) + int(i * yy) * j; 755 # ENDIFMACRO IFMACRO(dimension,3) 756 # , zz = z / (bb[5] - bb[4]); 757 # i = int(mpiSize(comm)^(0.333333333333333)); 758 # while(mpiSize(comm) % i != 0) 759 # --i; 760 # real p = mpiSize(comm) / i; 761 # j = int(sqrt(p)); 762 # while(p % j != 0) 763 # --j; 764 # real k = int(p / j); 765 # partGlobal = int(i * zz) * k * j + int(j * yy) * k + int(k * xx); 766 # ENDIFMACRO } 767 # ENDIFMACRO IFMACRO(!privateDmesh#CartesianPartitioning) 768 # if(userPartitioning.n != PhGlobalPrivate.ndof || labPeriodic.n > 0) { 769 # timerPartition = mpiWtime(); 770 # meshN ThGlobalPeriodic; 771 # if(labPeriodic.n > 0) { 772 # VhGlobalPrivate marker; 773 # for(int i = 0; i < labPeriodic.n; ++i) { 774 # varf vMarker(u, v) = on(labPeriodic[i], u = 1.0); 775 # marker[] += vMarker(0, VhGlobalPrivate, tgv = -1); 776 # } 777 # PhGlobalPrivate partPeriodic = marker > 0.1; 778 # while(1) { 779 # AddLayers(ThGlobal, partPeriodic[], 1 + overlap, marker[]); 780 # partPeriodic = marker > 0.001; 781 # ThGlobalPeriodic = trunc(ThGlobal, partPeriodic < 0.999); 782 # if(ThGlobal.nt / real(ThGlobalPeriodic.nt) > mpisize / real(mpisize - 1)) 783 # break; 784 # } 785 # } 786 # if(mpiRank(comm) == 0) { 787 # if(verbosity > 0) 788 # cout.scientific << " --- global mesh of " << ThGlobal.nt << " elements (prior to refinement) partitioned with " << Stringification(partitioner); 789 # if(labPeriodic.n > 0) { 790 # fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 791 # PhPeriodicPrivate partPeriodic; 792 # if(mpiSize(comm) > 2) { 793 # partitionerSeq(partPeriodic[], ThGlobalPeriodic, mpiSize(comm) - 1); 794 # partPeriodic[] += 1.0; 795 # } 796 # else partPeriodic[] = 1.0; 797 # partGlobal = partPeriodic; 798 # } 799 # else { 800 # partitionerSeq(partGlobal[], ThGlobal, mpiSize(comm)); 801 # } 802 # } 803 # if(labPeriodic.n > 0 && Stringification(partitioner) != "metis" && Stringification(partitioner) != "scotch") { 804 # fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 805 # PhPeriodicPrivate partPeriodic; 806 # if(mpiSize(comm) > 2) { 807 # partitionerPar(partPeriodic[], ThGlobalPeriodic, comm, mpiSize(comm) - 1); 808 # partPeriodic[] += 1.0; 809 # } 810 # else partPeriodic[] = 1.0; 811 # partGlobal = partPeriodic; 812 # } 813 # else partitionerPar(partGlobal[], ThGlobal, comm, mpiSize(comm)); 814 # if(mpiRank(comm) == 0 && verbosity > 0) 815 # cout.scientific << " (in " << mpiWtime() - timerPartition << ")" << endl; 816 # timerPartition = mpiWtime(); 817 # } 818 # else { 819 # partGlobal[] = userPartitioning; 820 # } 821 # ENDIFMACRO ENDIFMACRO IFMACRO(privateReconstructDmesh) 822 # partGlobal[] = userPartitioning; 823 # ENDIFMACRO IFMACRO(!trueRestrict) 824 # bool trueRestrict = usedARGV("-true_restrict") != -1; 825 # ENDIFMACRO IFMACRO(!removeZeros) 826 # bool removeZeros = trueRestrict && overlap == 1 && usedARGV("-remove_zeros") != -1; 827 # ENDIFMACRO if(verbosity > 0) { 828 # mpiBarrier(comm); 829 # timerPartition = mpiWtime(); 830 # } 831 # IFMACRO(privateBuildDmesh) 832 # NewMacro defP1(i)i EndMacro NewMacro initP1(i)i EndMacro partitionPrivate(Th, ThBorder, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank(comm), mpiSize(comm), s, overlap, level, prolongation, DTab, P, intersection, comm, fakeInterface, PkPart, defP1, initP1, bs) 833 # ENDIFMACRO IFMACRO(!privateBuildDmesh) 834 # partitionPrivate(Th, ThBorder, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank(comm), mpiSize(comm), s, overlap, level, prolongation, DTab, P, intersection, comm, fakeInterface, PkPart, defPart, initPart, bs) 835 # ENDIFMACRO } 836 # else if(mpiSize(comm) == 1) { 837 # for(int i = level - 1; i > 0; --i) { 838 # Th[i - 1] = trunc(Th[i], 1, split = s); 839 # fespace WhLocalRefinedPrivate(Th[i - 1], P); 840 # fespace WhLocalCoarsePrivate(Th[i], P); 841 # prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 842 # DTab[i].resize(WhLocalCoarsePrivate.ndof); 843 # DTab[i] = 1.0; 844 # } 845 # if(level == 1) { 846 # IFMACRO(privateBuildDmesh) 847 # IFMACRO(privateDmesh#N2O) 848 # if(s > 1) 849 # Th[0] = trunc(Th[0], 1, split = s, new2old = privateDmesh#N2O); 850 # else { 851 # privateDmesh#N2O.resize(Th[0].nt); 852 # privateDmesh#N2O = 0:Th[0].nt-1; 853 # } 854 # ENDIFMACRO IFMACRO(!privateDmesh#N2O) 855 # if(s > 1) 856 # Th[0] = trunc(Th[0], 1, split = s); 857 # ENDIFMACRO ENDIFMACRO IFMACRO(!privateBuildDmesh) 858 # if(s > 1) 859 # Th[0] = trunc(Th[0], 1, split = s); 860 # ENDIFMACRO } 861 # fespace WhLocalPrivate(Th[0], P); 862 # DTab[0].resize(WhLocalPrivate.ndof); 863 # DTab[0] = 1.0; 864 # } 865 # if(verbosity > 0) { 866 # mpiBarrier(comm); 867 # if(mpiRank(comm) == 0) 868 # cout.scientific << " --- partition of unity built (in " << mpiWtime() - timerPartition << ")" << endl; 869 # } 870 # } ) // EOM 871 @ 872 @ macro buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, labPeriodic, userPartitioning, bs) { 873 # meshN[int] ThTab(1); 874 # meshN[int] ThBorderTab(1); 875 # real[int][int] DTab(1); 876 # ThTab[0] = Th; 877 # matrix[int] prolongation(0); 878 # buildOverlapEdgePeriodicRecursive(ThTab, ThBorderTab, fakeInterface, s, overlap, 1, prolongation, intersection, DTab, P, comm, excluded, PkPart, defPart, initPart, labPeriodic, userPartitioning, bs) 879 # Th = ThTab[0]; 880 # ThBorder = ThBorderTab[0]; 881 # D.resize(DTab[0].n); 882 # D = DTab[0]; 883 # } ) // EOM 884 @ 885 @ IFMACRO(vectorialfe) 886 & macro buildOverlapEdgeRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, bs) { 887 & int[int] emptyArray(0); 888 & real[int] emptyRealArray(0); 889 & buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, bs) 890 & }// EOM macro buildOverlapEdge(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, bs) { 891 & int[int] emptyArray(0); 892 & real[int] emptyRealArray(0); 893 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, bs) 894 & }// EOM macro buildOverlapEdgeWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, bs) { 895 & int[int] emptyArray(0); 896 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, bs) 897 & }// EOM macro buildOverlapWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, bs) { 898 & int[int] emptyArray(0); 899 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, bs) 900 & }// EOM macro buildOverlap(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, bs) { 901 & int[int] emptyArray(0); 902 & real[int] emptyRealArray(0); 903 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, bs) 904 & }// EOM macro buildOverlapPeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, labPeriodic, bs) { 905 & real[int] emptyArray(0); 906 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyArray, bs) 907 & }// EOM macro buildEdgeWithPartitioning(Th, part, s, intersection, D, P, comm, PkPart, defPart, initPart, bs) { 908 & int[int] emptyArray(0); 909 & meshN ThBorder; 910 & int fakeInterface = -111111; 911 & int overlap = 1; 912 & bool excluded = false; 913 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, bs) 914 & }// EOM macro buildWithPartitioning(Th, part, s, intersection, D, P, comm, bs) { 915 & int[int] emptyArray(0); 916 & meshN ThBorder; 917 & int fakeInterface = -111111; 918 & int overlap = 1; 919 & bool excluded = false; 920 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, bs) 921 & }// EOM macro build(Th, s, intersection, D, P, comm, bs) { 922 & int[int] emptyArray(0); 923 & real[int] emptyRealArray(0); 924 & meshN ThBorder; 925 & int fakeInterface = -111111; 926 & int overlap = 1; 927 & bool excluded = false; 928 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, bs) 929 & }// EOM macro buildPeriodic(Th, s, intersection, D, P, comm, labPeriodic, bs) { 930 & int[int] emptyArray(0); 931 & real[int] emptyRealArray(0); 932 & meshN ThBorder; 933 & int fakeInterface = -111111; 934 & int overlap = 1; 935 & bool excluded = false; 936 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyRealArray, bs) 937 & }// EOM macro buildMinimalist(Th, intersection, D, P, bs) { 938 & int[int] emptyArray(0); 939 & real[int] emptyRealArray(0); 940 & meshN ThBorder; 941 & int fakeInterface = -111111; 942 & int overlap = 1; 943 & bool excluded = false; 944 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, 1, overlap, intersection, D, P, mpiCommWorld, excluded, P, def, init, emptyArray, emptyRealArray, bs) 945 & }// EOM macro buildRecursive(Th, s, level, prolongation, intersectionMat, DTab, P, comm, bsMat) { 946 & int[int] emptyArray(0); 947 & real[int] emptyRealArray(0); 948 & meshN[int] ThBorderTab(level); 949 & DTab.resize(level); 950 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, level, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, bsMat) 951 & }// EOM macro buildMatRecursive(Th, s, nlevel, prolongation, A, P, comm, bsMat) { 952 & int[int] emptyArray(0); 953 & real[int] emptyRealArray(0); 954 & meshN[int] ThBorderTab(nlevel); 955 & int[int][int] intersectionMat; 956 & real[int][int] DTab(nlevel); 957 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, bsMat) 958 & for(int i = 0; i < nlevel; ++i) 959 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], bs = bsMat, communicator = comm, level = i); 960 & }// EOM macro buildMatEdgeRecursive(Th, s, nlevel, prolongation, A, P, comm, PkPart, defPart, initPart, bsMat) { 961 & int[int] emptyArray(0); 962 & real[int] emptyRealArray(0); 963 & meshN[int] ThBorderTab(nlevel); 964 & int[int][int] intersectionMat; 965 & real[int][int] DTab(nlevel); 966 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, PkPart, defPart, initPart, emptyArray, emptyRealArray, bsMat) 967 & for(int i = 0; i < nlevel; ++i) 968 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], bs = bsMat, communicator = comm, level = i); 969 & }// EOM macro buildMatEdgeWithPartitioning(Th, part, s, A, P, comm, PkPart, defPart, initPart, bsMat) { 970 & real[int] DMat; 971 & int[int][int] intersectionMat; 972 & buildEdgeWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, PkPart, defPart, initPart, bsMat) 973 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 974 & }// EOM macro buildMatWithPartitioning(Th, part, s, A, P, comm, bsMat) { 975 & real[int] DMat; 976 & int[int][int] intersectionMat; 977 & buildWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, bsMat) 978 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 979 & }// EOM macro buildMat(Th, s, A, P, comm, bsMat) { 980 & real[int] DMat; 981 & int[int][int] intersectionMat; 982 & build(Th, s, intersectionMat, DMat, P, comm, bsMat) 983 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 984 & }// EOM macro buildMatPeriodic(Th, s, A, P, comm, labPeriodic, bsMat) { 985 & real[int] DMat; 986 & int[int][int] intersectionMat; 987 & buildPeriodic(Th, s, intersectionMat, DMat, P, comm, labPeriodic, bsMat) 988 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 989 & }// EOM macro buildMatMinimalist(Th, A, P, bsMat) { 990 & real[int] DMat; 991 & int[int][int] intersectionMat; 992 & buildMinimalist(Th, intersectionMat, DMat, P, bsMat) 993 & constructor(A, DMat.n, intersectionMat, DMat, bs = bsMat, communicator = comm); 994 & }// EOM ENDIFMACRO 995 @ IFMACRO(!vectorialfe) 996 & macro buildOverlapEdgeRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 997 & int[int] emptyArray(0); 998 & real[int] emptyRealArray(0); 999 & buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1000 & }// EOM macro buildOverlapEdge(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 1001 & int[int] emptyArray(0); 1002 & real[int] emptyRealArray(0); 1003 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1004 & }// EOM macro buildOverlapEdgeWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 1005 & int[int] emptyArray(0); 1006 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, 1) 1007 & }// EOM macro buildOverlapWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded) { 1008 & int[int] emptyArray(0); 1009 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, 1) 1010 & }// EOM macro buildOverlap(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded) { 1011 & int[int] emptyArray(0); 1012 & real[int] emptyRealArray(0); 1013 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1014 & }// EOM macro buildOverlapPeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, labPeriodic) { 1015 & real[int] emptyArray(0); 1016 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyArray, 1) 1017 & }// EOM macro buildEdgeWithPartitioning(Th, part, s, intersection, D, P, comm, PkPart, defPart, initPart) { 1018 & int[int] emptyArray(0); 1019 & meshN ThBorder; 1020 & int fakeInterface = -111111; 1021 & int overlap = 1; 1022 & bool excluded = false; 1023 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, 1) 1024 & }// EOM macro buildWithPartitioning(Th, part, s, intersection, D, P, comm) { 1025 & int[int] emptyArray(0); 1026 & meshN ThBorder; 1027 & int fakeInterface = -111111; 1028 & int overlap = 1; 1029 & bool excluded = false; 1030 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, 1) 1031 & }// EOM macro build(Th, s, intersection, D, P, comm) { 1032 & int[int] emptyArray(0); 1033 & real[int] emptyRealArray(0); 1034 & meshN ThBorder; 1035 & int fakeInterface = -111111; 1036 & int overlap = 1; 1037 & bool excluded = false; 1038 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1039 & }// EOM macro buildPeriodic(Th, s, intersection, D, P, comm, labPeriodic) { 1040 & int[int] emptyArray(0); 1041 & real[int] emptyRealArray(0); 1042 & meshN ThBorder; 1043 & int fakeInterface = -111111; 1044 & int overlap = 1; 1045 & bool excluded = false; 1046 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyRealArray, 1) 1047 & }// EOM macro buildMinimalist(Th, intersection, D, P) { 1048 & int[int] emptyArray(0); 1049 & real[int] emptyRealArray(0); 1050 & meshN ThBorder; 1051 & int fakeInterface = -111111; 1052 & int overlap = 1; 1053 & bool excluded = false; 1054 & buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, 1, overlap, intersection, D, P, mpiCommWorld, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1055 & }// EOM macro buildRecursive(Th, s, level, prolongation, intersectionMat, DTab, P, comm) { 1056 & int[int] emptyArray(0); 1057 & real[int] emptyRealArray(0); 1058 & meshN[int] ThBorderTab(level); 1059 & DTab.resize(level); 1060 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, level, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, 1) 1061 & }// EOM macro buildMatRecursive(Th, s, nlevel, prolongation, A, P, comm) { 1062 & int[int] emptyArray(0); 1063 & real[int] emptyRealArray(0); 1064 & meshN[int] ThBorderTab(nlevel); 1065 & int[int][int] intersectionMat; 1066 & real[int][int] DTab(nlevel); 1067 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, 1) 1068 & for(int i = 0; i < nlevel; ++i) 1069 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], communicator = comm, level = i); 1070 & }// EOM macro buildMatEdgeRecursive(Th, s, nlevel, prolongation, A, P, comm, PkPart, defPart, initPart) { 1071 & int[int] emptyArray(0); 1072 & real[int] emptyRealArray(0); 1073 & meshN[int] ThBorderTab(nlevel); 1074 & int[int][int] intersectionMat; 1075 & real[int][int] DTab(nlevel); 1076 & buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1077 & for(int i = 0; i < nlevel; ++i) 1078 & constructor(A[i], DTab[i].n, intersectionMat, DTab[i], communicator = comm, level = i); 1079 & }// EOM macro buildMatEdgeWithPartitioning(Th, part, s, A, P, comm, PkPart, defPart, initPart) { 1080 & real[int] DMat; 1081 & int[int][int] intersectionMat; 1082 & buildEdgeWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, PkPart, defPart, initPart) 1083 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1084 & }// EOM macro buildMatWithPartitioning(Th, part, s, A, P, comm) { 1085 & real[int] DMat; 1086 & int[int][int] intersectionMat; 1087 & buildWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm) 1088 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1089 & }// EOM macro buildMat(Th, s, A, P, comm) { 1090 & real[int] DMat; 1091 & int[int][int] intersectionMat; 1092 & build(Th, s, intersectionMat, DMat, P, comm) 1093 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1094 & }// EOM macro buildMatPeriodic(Th, s, A, P, comm, labPeriodic) { 1095 & real[int] DMat; 1096 & int[int][int] intersectionMat; 1097 & buildPeriodic(Th, s, intersectionMat, DMat, P, comm, labPeriodic) 1098 & constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1099 & }// EOM macro buildMatMinimalist(Th, A, P) { 1100 & real[int] DMat; 1101 & int[int][int] intersectionMat; 1102 & buildMinimalist(Th, intersectionMat, DMat, P) 1103 & constructor(A, DMat.n, intersectionMat, DMat); 1104 & }// EOM ENDIFMACRO 996 @ macro buildOverlapEdgeRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 997 # int[int] emptyArray(0); 998 # real[int] emptyRealArray(0); 999 # buildOverlapEdgePeriodicRecursive(Th, ThBorder, fakeInterface, s, overlap, level, prolongation, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1000 # } ) // EOM 1001 @ macro buildOverlapEdge(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 1002 # int[int] emptyArray(0); 1003 # real[int] emptyRealArray(0); 1004 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1005 # } ) // EOM 1006 @ macro buildOverlapEdgeWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart) { 1007 # int[int] emptyArray(0); 1008 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, 1) 1009 # } ) // EOM 1010 @ macro buildOverlapWithPartitioning(Th, ThBorder, part, fakeInterface, s, overlap, intersection, D, P, comm, excluded) { 1011 # int[int] emptyArray(0); 1012 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, 1) 1013 # } ) // EOM 1014 @ macro buildOverlap(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded) { 1015 # int[int] emptyArray(0); 1016 # real[int] emptyRealArray(0); 1017 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1018 # } ) // EOM 1019 @ macro buildOverlapPeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, labPeriodic) { 1020 # real[int] emptyArray(0); 1021 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyArray, 1) 1022 # } ) // EOM 1023 @ macro buildEdgeWithPartitioning(Th, part, s, intersection, D, P, comm, PkPart, defPart, initPart) { 1024 # int[int] emptyArray(0); 1025 # meshN ThBorder; 1026 # int fakeInterface = -111111; 1027 # int overlap = 1; 1028 # bool excluded = false; 1029 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, PkPart, defPart, initPart, emptyArray, part, 1) 1030 # } ) // EOM 1031 @ macro buildWithPartitioning(Th, part, s, intersection, D, P, comm) { 1032 # int[int] emptyArray(0); 1033 # meshN ThBorder; 1034 # int fakeInterface = -111111; 1035 # int overlap = 1; 1036 # bool excluded = false; 1037 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, part, 1) 1038 # } ) // EOM 1039 @ macro build(Th, s, intersection, D, P, comm) { 1040 # int[int] emptyArray(0); 1041 # real[int] emptyRealArray(0); 1042 # meshN ThBorder; 1043 # int fakeInterface = -111111; 1044 # int overlap = 1; 1045 # bool excluded = false; 1046 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1047 # } ) // EOM 1048 @ macro buildPeriodic(Th, s, intersection, D, P, comm, labPeriodic) { 1049 # int[int] emptyArray(0); 1050 # real[int] emptyRealArray(0); 1051 # meshN ThBorder; 1052 # int fakeInterface = -111111; 1053 # int overlap = 1; 1054 # bool excluded = false; 1055 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, s, overlap, intersection, D, P, comm, excluded, P, def, init, labPeriodic, emptyRealArray, 1) 1056 # } ) // EOM 1057 @ macro buildMinimalist(Th, intersection, D, P) { 1058 # int[int] emptyArray(0); 1059 # real[int] emptyRealArray(0); 1060 # meshN ThBorder; 1061 # int fakeInterface = -111111; 1062 # int overlap = 1; 1063 # bool excluded = false; 1064 # buildOverlapEdgePeriodic(Th, ThBorder, fakeInterface, 1, overlap, intersection, D, P, mpiCommWorld, excluded, P, def, init, emptyArray, emptyRealArray, 1) 1065 # } ) // EOM 1066 @ macro buildRecursive(Th, s, level, prolongation, intersectionMat, DTab, P, comm) { 1067 # int[int] emptyArray(0); 1068 # real[int] emptyRealArray(0); 1069 # meshN[int] ThBorderTab(level); 1070 # DTab.resize(level); 1071 # buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, level, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, 1) 1072 # } ) // EOM 1073 @ macro buildMatRecursive(Th, s, nlevel, prolongation, A, P, comm) { 1074 # int[int] emptyArray(0); 1075 # real[int] emptyRealArray(0); 1076 # meshN[int] ThBorderTab(nlevel); 1077 # int[int][int] intersectionMat; 1078 # real[int][int] DTab(nlevel); 1079 # buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, P, def, init, emptyArray, emptyRealArray, 1) 1080 # for(int i = 0; i < nlevel; ++i) 1081 # constructor(A[i], DTab[i].n, intersectionMat, DTab[i], communicator = comm, level = i); 1082 # } ) // EOM 1083 @ macro buildMatEdgeRecursive(Th, s, nlevel, prolongation, A, P, comm, PkPart, defPart, initPart) { 1084 # int[int] emptyArray(0); 1085 # real[int] emptyRealArray(0); 1086 # meshN[int] ThBorderTab(nlevel); 1087 # int[int][int] intersectionMat; 1088 # real[int][int] DTab(nlevel); 1089 # buildOverlapEdgePeriodicRecursive(Th, ThBorderTab, -111111, s, 1, nlevel, prolongation, intersectionMat, DTab, P, comm, false, PkPart, defPart, initPart, emptyArray, emptyRealArray, 1) 1090 # for(int i = 0; i < nlevel; ++i) 1091 # constructor(A[i], DTab[i].n, intersectionMat, DTab[i], communicator = comm, level = i); 1092 # } ) // EOM 1093 @ macro buildMatEdgeWithPartitioning(Th, part, s, A, P, comm, PkPart, defPart, initPart) { 1094 # real[int] DMat; 1095 # int[int][int] intersectionMat; 1096 # buildEdgeWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm, PkPart, defPart, initPart) 1097 # constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1098 # } ) // EOM 1099 @ macro buildMatWithPartitioning(Th, part, s, A, P, comm) { 1100 # real[int] DMat; 1101 # int[int][int] intersectionMat; 1102 # buildWithPartitioning(Th, part, s, intersectionMat, DMat, P, comm) 1103 # constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1104 # } ) // EOM 1105 @ macro buildMat(Th, s, A, P, comm) { 1106 # real[int] DMat; 1107 # int[int][int] intersectionMat; 1108 # build(Th, s, intersectionMat, DMat, P, comm) 1109 # constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1110 # } ) // EOM 1111 @ macro buildMatPeriodic(Th, s, A, P, comm, labPeriodic) { 1112 # real[int] DMat; 1113 # int[int][int] intersectionMat; 1114 # buildPeriodic(Th, s, intersectionMat, DMat, P, comm, labPeriodic) 1115 # constructor(A, DMat.n, intersectionMat, DMat, communicator = comm); 1116 # } ) // EOM 1117 @ macro buildMatMinimalist(Th, A, P) { 1118 # real[int] DMat; 1119 # int[int][int] intersectionMat; 1120 # buildMinimalist(Th, intersectionMat, DMat, P) 1121 # constructor(A, DMat.n, intersectionMat, DMat); 1122 # } ) // EOM 1123 @ 1105 @ 1106 @ macro convectParallel(ThName, uVel, dt, uChi, safety) 1107 # IFMACRO(privateDmesh#ThName) 1108 # { 1109 # IFMACRO(!ThName#Comm) 1110 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0) 1111 # mpiBarrier(ThName#Comm); 1112 # real timerConvect = mpiWtime(); 1113 # if(mpiSize(ThName#Comm) == 1) { 1114 # uChi = convect(uVel, dt, uChi); 1115 # } 1116 # else { 1117 # int backupSM = searchMethod; 1118 # searchMethod = 0; 1119 # real[int] bb(2 * dimension); 1120 # boundingbox(ThName, bb); 1121 # bb(0) -= safety * ThName.hmax; 1122 # bb(1) += safety * ThName.hmax; 1123 # bb(2) -= safety * ThName.hmax; 1124 # bb(3) += safety * ThName.hmax; 1125 # IFMACRO(dimension,3) 1126 # bb(4) -= safety * ThName.hmax; 1127 # bb(5) += safety * ThName.hmax; 1128 # ENDIFMACRO int size = mpiSize(ThName#Comm); 1129 # real[int] bbAll(2 * dimension * size); 1130 # mpiAllgather(bb, bbAll, ThName#Comm); 1131 # int[int] rankExchange(0); 1132 # for(int i = 0; i < size; ++i) { 1133 # IFMACRO(dimension,2) 1134 # if(!(bbAll[1 + 4 * i] < bb[0] 1135 # || bbAll[0 + 4 * i] > bb[1] 1136 # || bbAll[3 + 4 * i] < bb[2] 1137 # || bbAll[2 + 4 * i] > bb[3])) 1138 # ENDIFMACRO IFMACRO(dimension,3) 1139 # if(!(bbAll[1 + 6 * i] < bb[0] 1140 # || bbAll[0 + 6 * i] > bb[1] 1141 # || bbAll[3 + 6 * i] < bb[2] 1142 # || bbAll[2 + 6 * i] > bb[3] 1143 # || bbAll[5 + 6 * i] < bb[4] 1144 # || bbAll[4 + 6 * i] > bb[5])) 1145 # ENDIFMACRO { 1146 # rankExchange.resize(rankExchange.n + 1); 1147 # rankExchange[rankExchange.n - 1] = i; 1148 # } 1149 # } 1150 # real[int] D, backupRegion(ThName.nt); 1151 # real[int] buffer(ThName.nt * (dimension + 1)); 1152 # IFMACRO(dimension,2) 1153 # func PkVel = [P1, P1]; 1154 # ENDIFMACRO IFMACRO(dimension,3) 1155 # func PkVel = [P1, P1, P1]; 1156 # ENDIFMACRO fespace VhVelPrivate(ThName, PkVel); 1157 # fespace VhChiPrivate(ThName, P1); 1158 # { 1159 # VhVelPrivate defVel(uVelLocal) = uVel; 1160 # for[i, v : uVelLocal[]] v *= privateDmesh#ThName#khiDef[0][i / dimension]; 1161 # buffer(0:ThName.nv * dimension - 1) = uVelLocal[]; 1162 # } 1163 # buffer(ThName.nv * dimension:ThName.nv * (dimension + 1) - 1) = uChi[]; 1164 # buffer(ThName.nv * dimension:ThName.nv * (dimension + 1) - 1) .*= privateDmesh#ThName#khiDef[0]; 1165 # fespace PhPartPrivate(ThName, P0); 1166 # { 1167 # PhPartPrivate backup = region; 1168 # backupRegion = backup[]; 1169 # ThName = change(ThName, fregion = privateDmesh#ThName#khiDef[1][nuTriangle]); 1170 # } 1171 # meshN[int] recvTh(rankExchange.n); 1172 # meshN[int] sendTh(rankExchange.n); 1173 # real[int][int] exchangeU(rankExchange.n + rankExchange.n); 1174 # mpiRequest[int] rqSendTh(rankExchange.n); 1175 # mpiRequest[int] rqSendU(rankExchange.n); 1176 # mpiRequest[int] rqRecvTh(rankExchange.n); 1177 # mpiRequest[int] rqRecvU(rankExchange.n); 1178 # for[i, v : rankExchange] 1179 # Irecv(processor(v, rqRecvTh[i]), recvTh[i]); 1180 # for[i, v : rankExchange] { 1181 # PhPartPrivate part; 1182 # IFMACRO(dimension,2) 1183 # part = (bbAll[0 + 4 * v] < x 1184 # && bbAll[1 + 4 * v] > x 1185 # && bbAll[2 + 4 * v] < y 1186 # && bbAll[3 + 4 * v] > y) ? 1.0 : 0.0; 1187 # ENDIFMACRO IFMACRO(dimension,3) 1188 # part = (bbAll[0 + 6 * v] < x 1189 # && bbAll[1 + 6 * v] > x 1190 # && bbAll[2 + 6 * v] < y 1191 # && bbAll[3 + 6 * v] > y 1192 # && bbAll[4 + 6 * v] < z 1193 # && bbAll[5 + 6 * v] > z) ? 1.0 : 0.0; 1194 # ENDIFMACRO if(part[].linfty > 1.0e-2) { 1195 # int[int] n2o; 1196 # sendTh[i] = trunc(ThName, part > 1.0e-2, new2old = n2o); 1197 # fespace VhRestrictionPrivate(sendTh[i], P1); 1198 # int[int] map; 1199 # map = restrict(VhRestrictionPrivate, VhChiPrivate, n2o); 1200 # exchangeU[rankExchange.n + i].resize(VhRestrictionPrivate.ndof * (dimension + 1)); 1201 # for[j, w : map] { 1202 # exchangeU[rankExchange.n + i][dimension * j] = buffer[dimension * w]; 1203 # exchangeU[rankExchange.n + i][dimension * j + 1] = buffer[dimension * w + 1]; 1204 # IFMACRO(dimension,3) 1205 # exchangeU[rankExchange.n + i][dimension * j + 2] = buffer[dimension * w + 2]; 1206 # ENDIFMACRO exchangeU[rankExchange.n + i][VhRestrictionPrivate.ndof * dimension + j] = buffer[VhChiPrivate.ndof * dimension + w]; 1207 # } 1208 # Isend(processor(v, rqSendTh[i]), sendTh[i]); 1209 # Isend(processor(v, rqSendU[i]), exchangeU[rankExchange.n + i]); 1210 # } 1211 # else Isend(processor(v, rqSendTh[i]), sendTh[i]); 1212 # } 1213 # meshN gluedExchange; 1214 # { 1215 # meshN[int] toGlue(rankExchange.n); 1216 # int j = 0; 1217 # for[i, v : rankExchange] { 1218 # int index = mpiWaitAny(rqRecvTh); 1219 # if(recvTh[index].nt) { 1220 # fespace VhRestrictionPrivate(recvTh[index], P1); 1221 # exchangeU[index].resize(VhRestrictionPrivate.ndof * (dimension + 1)); 1222 # Irecv(processor(rankExchange[index], rqRecvU[index]), exchangeU[index]); 1223 # fespace PhRestrictionPrivate(recvTh[index], P0); 1224 # PhRestrictionPrivate ind = abs(region - rankExchange[index]) < 1.0e-2 ? 1.0 : 0.0; 1225 # if(abs(ind[].max - 1.0) < 1.0e-2) { 1226 # toGlue[j] = trunc(recvTh[index], ind > 1.0e-2); 1227 # ++j; 1228 # } 1229 # } 1230 # } 1231 # toGlue.resize(j); 1232 # gluedExchange = gluemesh(toGlue); 1233 # } 1234 # meshN interpolateExchange; 1235 # fespace VhVelExchangePrivate(gluedExchange, PkVel); 1236 # fespace VhChiExchangePrivate(gluedExchange, P1); 1237 # VhVelExchangePrivate defVel(uVelExchange); 1238 # VhChiExchangePrivate uChiExchange; 1239 # for[i, v : rankExchange] { 1240 # int index = mpiWaitAny(rqRecvU); 1241 # if(index != mpiUndefined) { 1242 # if(recvTh[index].nt) { 1243 # fespace VhRestrictionPrivate(recvTh[index], P1); 1244 # matrix R = interpolate(VhRestrictionPrivate, VhChiExchangePrivate); 1245 # if(R.nnz != R.n) { 1246 # R.thresholding(1.0e-2); 1247 # assert(R.nnz == R.n); 1248 # } 1249 # for[i, j, v : R] { 1250 # uVelExchange[][dimension * j] += exchangeU[index][dimension * i]; 1251 # uVelExchange[][dimension * j + 1] += exchangeU[index][dimension * i + 1]; 1252 # IFMACRO(dimension,3) 1253 # uVelExchange[][dimension * j + 2] += exchangeU[index][dimension * i + 2]; 1254 # ENDIFMACRO uChiExchange[][j] += exchangeU[index][dimension * VhRestrictionPrivate.ndof + i]; 1255 # } 1256 # } 1257 # } 1258 # } 1259 # searchMethod = backupSM; 1260 # fespace VhPhiExchangePrivate(gluedExchange, P0); 1261 # int rank = mpiRank(ThName#Comm); 1262 # VhPhiExchangePrivate phi = abs(region - rank) < 1.0e-2 ? 1.0 : 0.0; 1263 # VhChiExchangePrivate chi; 1264 # AddLayers(gluedExchange, phi[], safety, chi[]); 1265 # int[int] n2o; 1266 # meshN gluedExchangeSafety = trunc(gluedExchange, abs(chi) > 0.1, new2old = n2o); 1267 # fespace VhVelExchangeSafetyPrivate(gluedExchangeSafety, PkVel); 1268 # fespace VhChiExchangeSafetyPrivate(gluedExchangeSafety, P1); 1269 # int[int] map = restrict(VhChiExchangeSafetyPrivate, VhChiExchangePrivate, n2o); 1270 # VhVelExchangeSafetyPrivate defVel(uVelExchangeSafety); 1271 # VhChiExchangeSafetyPrivate uChiExchangeSafety; 1272 # uChiExchangeSafety[] = uChiExchange[](map); 1273 # for[j, w : map] { 1274 # uVelExchangeSafety[][dimension * j] = uVelExchange[][dimension * w]; 1275 # uVelExchangeSafety[][dimension * j + 1] = uVelExchange[][dimension * w + 1]; 1276 # IFMACRO(dimension,3) 1277 # uVelExchangeSafety[][dimension * j + 2] = uVelExchange[][dimension * w + 2]; 1278 # ENDIFMACRO } 1279 # uChiExchangeSafety = convect(defVel(uVelExchangeSafety), dt, uChiExchangeSafety); 1280 # uChi = uChiExchangeSafety; 1281 # ThName = change(ThName, fregion = backupRegion[nuTriangle]); 1282 # mpiWaitAll(rqSendTh); 1283 # mpiWaitAll(rqSendU); 1284 # } 1285 # if(verbosity > 0) { 1286 # mpiBarrier(ThName#Comm); 1287 # if(mpiRank(ThName#Comm) == 0) 1288 # cout.scientific << " --- distributed solution convected (in " << mpiWtime() - timerConvect << ")" << endl; 1289 # } 1290 # } 1291 # ENDIFMACRO ) // EOM 1292 @ 1293 @ macro transferBase(ThName, Pk, uA, ThNew, PkNew, uANew, P) 1294 # IFMACRO(privateDmesh#ThName) 1295 # { 1296 # IFMACRO(!ThName#Comm) 1297 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0) 1298 # mpiBarrier(ThName#Comm); 1299 # real timerTransfer = mpiWtime(); 1300 # IFMACRO(!def) 1301 # NewMacro def(i)i EndMacro ENDIFMACRO if(mpiSize(ThName#Comm) == 1) { 1302 # IFMACRO(!transfer#Q) 1303 # def(uANew) = def(uA); 1304 # ENDIFMACRO IFMACRO(transfer#Q) 1305 # fespace VhLocalOldPrivate(ThName, Pk); 1306 # fespace VhLocalNewPrivate(ThNew, PkNew); 1307 # matrix loc = interpolate(VhLocalNewPrivate, VhLocalOldPrivate); 1308 # matrix locPetscScalar = loc; 1309 # constructor(P, uANew, uA, locPetscScalar); 1310 # ENDIFMACRO } 1311 # else { 1312 # int backupSM = searchMethod; 1313 # searchMethod = 0; 1314 # fespace VhLocalOldPrivate(ThName, Pk); 1315 # fespace VhLocalNewPrivate(ThNew, PkNew); 1316 # IFMACRO(!transfer#Q) 1317 # assert(uA[].n == VhLocalOldPrivate.ndof); 1318 # assert(uANew[].n == VhLocalNewPrivate.ndof); 1319 # ENDIFMACRO IFMACRO(!dimension) 1320 # NewMacro dimension()2 EndMacro ENDIFMACRO IFMACRO(!meshN) 1321 # NewMacro meshN()mesh EndMacro ENDIFMACRO real[int] bb(4 * dimension); 1322 # { 1323 # real[int] tmp(2 * dimension); 1324 # boundingbox(ThName, tmp); 1325 # bb(0:2 * dimension - 1) = tmp; 1326 # boundingbox(ThNew, tmp); 1327 # bb(2 * dimension:4 * dimension - 1) = tmp; 1328 # bb(0) -= max(ThName.hmax, ThNew.hmax); 1329 # bb(1) += max(ThName.hmax, ThNew.hmax); 1330 # bb(2) -= max(ThName.hmax, ThNew.hmax); 1331 # bb(3) += max(ThName.hmax, ThNew.hmax); 1332 # bb(4) -= max(ThName.hmax, ThNew.hmax); 1333 # bb(5) += max(ThName.hmax, ThNew.hmax); 1334 # bb(6) -= max(ThName.hmax, ThNew.hmax); 1335 # bb(7) += max(ThName.hmax, ThNew.hmax); 1336 # IFMACRO(dimension,3) 1337 # bb(8) -= max(ThName.hmax, ThNew.hmax); 1338 # bb(9) += max(ThName.hmax, ThNew.hmax); 1339 # bb(10) -= max(ThName.hmax, ThNew.hmax); 1340 # bb(11) += max(ThName.hmax, ThNew.hmax); 1341 # ENDIFMACRO } 1342 # int size = mpiSize(ThName#Comm); 1343 # real[int] bbAll(4 * dimension * size); 1344 # mpiAllgather(bb, bbAll, ThName#Comm); 1345 # int[int] rankSend(0); 1346 # int[int] rankRecv(0); 1347 # for(int i = 0; i < size; ++i) { 1348 # IFMACRO(dimension,2) 1349 # if(!(bbAll[1 + 8 * i] < bb[4] 1350 # || bbAll[0 + 8 * i] > bb[5] 1351 # || bbAll[3 + 8 * i] < bb[6] 1352 # || bbAll[2 + 8 * i] > bb[7])) 1353 # ENDIFMACRO IFMACRO(dimension,3) 1354 # if(!(bbAll[1 + 12 * i] < bb[6] 1355 # || bbAll[0 + 12 * i] > bb[7] 1356 # || bbAll[3 + 12 * i] < bb[8] 1357 # || bbAll[2 + 12 * i] > bb[9] 1358 # || bbAll[5 + 12 * i] < bb[10] 1359 # || bbAll[4 + 12 * i] > bb[11])) 1360 # ENDIFMACRO { 1361 # rankRecv.resize(rankRecv.n + 1); 1362 # rankRecv[rankRecv.n - 1] = i; 1363 # } 1364 # IFMACRO(dimension,2) 1365 # if(!(bbAll[5 + 8 * i] < bb[0] 1366 # || bbAll[4 + 8 * i] > bb[1] 1367 # || bbAll[7 + 8 * i] < bb[2] 1368 # || bbAll[6 + 8 * i] > bb[3])) 1369 # ENDIFMACRO IFMACRO(dimension,3) 1370 # if(!(bbAll[7 + 12 * i] < bb[0] 1371 # || bbAll[6 + 12 * i] > bb[1] 1372 # || bbAll[9 + 12 * i] < bb[2] 1373 # || bbAll[8 + 12 * i] > bb[3] 1374 # || bbAll[11 + 12 * i] < bb[4] 1375 # || bbAll[10 + 12 * i] > bb[5])) 1376 # ENDIFMACRO { 1377 # rankSend.resize(rankSend.n + 1); 1378 # rankSend[rankSend.n - 1] = i; 1379 # } 1380 # } 1381 # real[int] D, backupRegion(ThName.nt); 1382 # VhLocalOldPrivate def(scaledU); 1383 # IFMACRO(!transfer#Q) 1384 # createPartition(ThName, D, Pk) 1385 # scaledU[] = uA[]; 1386 # ENDIFMACRO IFMACRO(transfer#Q) 1387 # GlobalNumbering(uA, scaledU[]); 1388 # D.resize(scaledU[].n); 1389 # D = uA.D; 1390 # ENDIFMACRO for[i, v : D] scaledU[][i] *= v; 1391 # fespace PhPartPrivate(ThName, P0); 1392 # { 1393 # PhPartPrivate backup = region; 1394 # backupRegion = backup[]; 1395 # int[int] newRegion(ThName.nt); 1396 # int rank = mpiRank(ThName#Comm); 1397 # for[i, v : privateDmesh#ThName#khiDef[1]] newRegion[i] = abs(v - rank) < 1.0e-2 ? 1 : 0; 1398 # ThName = change(ThName, fregion = newRegion[nuTriangle]); 1399 # } 1400 # meshN[int] recvTh(rankRecv.n); 1401 # meshN[int] sendTh(rankSend.n); 1402 # PetscScalar[int][int] exchangeU(rankSend.n + rankRecv.n); 1403 # mpiRequest[int] rqSendTh(rankSend.n); 1404 # mpiRequest[int] rqSendU(rankSend.n); 1405 # mpiRequest[int] rqRecvTh(rankRecv.n); 1406 # mpiRequest[int] rqRecvU(rankRecv.n); 1407 # for[i, v : rankRecv] 1408 # Irecv(processor(v, rqRecvTh[i]), recvTh[i]); 1409 # for[i, v : rankSend] { 1410 # PhPartPrivate part; 1411 # IFMACRO(dimension,2) 1412 # part = (bbAll[4 + 8 * v] < x 1413 # && bbAll[5 + 8 * v] > x 1414 # && bbAll[6 + 8 * v] < y 1415 # && bbAll[7 + 8 * v] > y) ? 1.0 : 0.0; 1416 # ENDIFMACRO IFMACRO(dimension,3) 1417 # part = (bbAll[6 + 12 * v] < x 1418 # && bbAll[7 + 12 * v] > x 1419 # && bbAll[8 + 12 * v] < y 1420 # && bbAll[9 + 12 * v] > y 1421 # && bbAll[10 + 12 * v] < z 1422 # && bbAll[11 + 12 * v] > z) ? 1.0 : 0.0; 1423 # ENDIFMACRO if(part[].linfty > 1.0e-2) { 1424 # int[int] n2o; 1425 # sendTh[i] = trunc(ThName, part > 1.0e-2, new2old = n2o); 1426 # fespace VhRestrictionPrivate(sendTh[i], Pk); 1427 # int[int] map; 1428 # map = restrict(VhRestrictionPrivate, VhLocalOldPrivate, n2o); 1429 # exchangeU[rankRecv.n + i].resize(VhRestrictionPrivate.ndof); 1430 # for[j, w : map] exchangeU[rankRecv.n + i][j] = scaledU[][w]; 1431 # Isend(processor(v, rqSendTh[i]), sendTh[i]); 1432 # Isend(processor(v, rqSendU[i]), exchangeU[rankRecv.n + i]); 1433 # } 1434 # else Isend(processor(v, rqSendTh[i]), sendTh[i]); 1435 # } 1436 # meshN gluedExchange; 1437 # { 1438 # meshN[int] toGlue(rankRecv.n); 1439 # int j = 0; 1440 # for[i, v : rankRecv] { 1441 # int index = mpiWaitAny(rqRecvTh); 1442 # if(recvTh[index].nt) { 1443 # fespace VhRestrictionPrivate(recvTh[index], Pk); 1444 # exchangeU[index].resize(VhRestrictionPrivate.ndof); 1445 # Irecv(processor(rankRecv[index], rqRecvU[index]), exchangeU[index]); 1446 # fespace PhRestrictionPrivate(recvTh[index], P0); 1447 # PhRestrictionPrivate ind = region; 1448 # if(abs(ind[].max - 1.0) < 1.0e-2) { 1449 # toGlue[j] = trunc(recvTh[index], ind > 1.0e-2); 1450 # ++j; 1451 # } 1452 # } 1453 # } 1454 # toGlue.resize(j); 1455 # gluedExchange = gluemesh(toGlue); 1456 # } 1457 # meshN interpolateExchange; 1458 # fespace PhExchangePrivate(gluedExchange, P0); 1459 # fespace VhExchangePrivate(gluedExchange, Pk); 1460 # VhExchangePrivate def(uExchange); 1461 # for[i, v : rankRecv] { 1462 # int index = mpiWaitAny(rqRecvU); 1463 # if(index != mpiUndefined) { 1464 # if(recvTh[index].nt) { 1465 # fespace PhRestrictionPrivate(recvTh[index], P0); 1466 # matrix R = interpolate(PhRestrictionPrivate, PhExchangePrivate); 1467 # if(R.nnz != R.n) { 1468 # R.thresholding(1.0e-2); 1469 # assert(R.nnz == R.n); 1470 # } 1471 # int[int] I, J; 1472 # real[int] C; 1473 # [I, J, C] = R; 1474 # fespace VhRestrictionPrivate(recvTh[index], Pk); 1475 # int[int] restriction = restrict(VhRestrictionPrivate, VhExchangePrivate, J); 1476 # for[i, v : restriction] uExchange[][v] += exchangeU[index][i]; 1477 # } 1478 # } 1479 # } 1480 # searchMethod = backupSM; 1481 # IFMACRO(!transfer#Q) 1482 # def(uANew) = def(uExchange); 1483 # ENDIFMACRO IFMACRO(transfer#Q) 1484 # matrix loc = interpolate(VhLocalNewPrivate, VhExchangePrivate); 1485 # matrix locPetscScalar = loc; 1486 # constructor(P, uANew, uA, locPetscScalar, numbering = uExchange[]); 1487 # ENDIFMACRO ThName = change(ThName, fregion = backupRegion[nuTriangle]); 1488 # mpiWaitAll(rqSendTh); 1489 # mpiWaitAll(rqSendU); 1490 # } 1491 # if(verbosity > 0) { 1492 # mpiBarrier(ThName#Comm); 1493 # if(mpiRank(ThName#Comm) == 0) 1494 # cout.scientific << " --- distributed solution transferred (in " << mpiWtime() - timerTransfer << ")" << endl; 1495 # } 1496 # } 1497 # ENDIFMACRO IFMACRO(!privateDmesh#ThName) 1498 # assert(0); 1499 # ENDIFMACRO ) // EOM 1500 @ 1501 @ macro transferMat(ThName, Pk, A, ThNew, PkNew, ANew, P) { 1502 # NewMacro transfer#Q() EndMacro transferBase(ThName, Pk, A, ThNew, PkNew, ANew, P) 1503 # } 1504 # ) // EOM 1505 @ 1506 @ macro transfer(ThName, Pk, u, ThNew, PkNew, uNew) { 1507 # transferBase(ThName, Pk, u, ThNew, PkNew, uNew, 1) 1508 # } 1509 # ) // EOM 1510 @ 1511 @ macro createParMmgCommunicators(ThName, ThParMmgName, ThN2O, ThCommunicators) { 1512 # IFMACRO(!privateDmesh#ThName) 1513 # assert(0); 1514 # ENDIFMACRO Mat A; 1515 # createMat(ThName, A, P1); 1516 # real[int] D(ThName.nt); 1517 # createPartition(ThName, D, P0); 1518 # fespace PhPrivate(ThName, P0); 1519 # PhPrivate d; 1520 # d[] = D; 1521 # ThParMmgName = trunc(ThName, abs(d) > 1.0e-2, label = -111111, new2old = ThN2O); 1522 # fespace VhWithoutOverlapPrivate(ThParMmgName, P1); 1523 # varf vG(u, v) = on(-111111, u = 1.0); 1524 # real[int] gamma(ThParMmgName.nv); 1525 # gamma = vG(0, VhWithoutOverlapPrivate, tgv = -1); 1526 # fespace VhWithOverlapPrivate(ThName, P1); 1527 # int[int] restriction = restrict(VhWithoutOverlapPrivate, VhWithOverlapPrivate, ThN2O); 1528 # ParMmgCommunicators(A, gamma, restriction, ThCommunicators); 1529 # } ) // EOM 1530 @ 1531 @ macro gatherDmesh(ThName, comm, ThGatherName) { 1532 # IFMACRO(!privateDmesh#ThName) 1533 # assert(0); 1534 # ENDIFMACRO IFMACRO(!ThName#Comm) 1535 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThGatherName#Comm) 1536 # NewMacro ThGatherName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThName#Comm) 1537 # mpiBarrier(ThName#Comm); 1538 # real timerGather = mpiWtime(); 1539 # int size; 1540 # if(ThGatherName#Comm) 1541 # size = mpiSize(comm); 1542 # else size = 0; 1543 # int reduce; 1544 # mpiAllReduce(size, reduce, ThName#Comm, mpiSUM); 1545 # assert(reduce == mpiSize(ThName#Comm)); 1546 # meshN ThNoOverlap; 1547 # if(mpiSize(ThName#Comm) == 1) 1548 # ThNoOverlap = ThName; 1549 # else ThNoOverlap = trunc(ThName, abs(privateDmesh#ThName#khiDef[1][nuTriangle] - mpiRank(ThName#Comm)) < 1.0e-2, label = -111112); 1550 # if(ThGatherName#Comm) { 1551 # meshN[int] recvTh(size); 1552 # mpiRequest[int] rqRecv(size - 1); 1553 # for(int i = 1; i < size; ++i) 1554 # Irecv(processor(i, comm, rqRecv[i - 1]), recvTh[i]); 1555 # recvTh[0] = ThNoOverlap; 1556 # mpiWaitAll(rqRecv); 1557 # ThGatherName = gluemesh(recvTh); 1558 # } 1559 # else { 1560 # mpiRequest rqSend; 1561 # Isend(processor(0, comm, rqSend), ThNoOverlap); 1562 # mpiWait(rqSend); 1563 # } 1564 # if(verbosity > 0 && ThName#Comm) { 1565 # mpiBarrier(ThName#Comm); 1566 # if(mpiRank(ThName#Comm) == 0) 1567 # cout.scientific << " --- distributed mesh gathered (in " << mpiWtime() - timerGather << ")" << endl; 1568 # } 1569 # } 1570 # reconstructDmesh(ThGatherName) 1571 # ) // EOM 1572 @ 1573 @ macro scatterDmesh(ThName, comm, ThScatterName) { 1574 # IFMACRO(!privateDmesh#ThName) 1575 # assert(0); 1576 # ENDIFMACRO IFMACRO(!ThName#Comm) 1577 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThScatterName#Comm) 1578 # NewMacro ThScatterName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThScatterName#Comm) 1579 # mpiBarrier(ThScatterName#Comm); 1580 # real timerScatter = mpiWtime(); 1581 # int size; 1582 # if(ThName#Comm) { 1583 # size = mpiSize(comm); 1584 # } 1585 # else size = 0; 1586 # int reduce; 1587 # mpiAllReduce(size, reduce, ThScatterName#Comm, mpiSUM); 1588 # assert(reduce == mpiSize(ThScatterName#Comm)); 1589 # if(ThName#Comm) { 1590 # meshN ThNoOverlap; 1591 # if(mpiSize(ThName#Comm) == 1) 1592 # ThNoOverlap = ThName; 1593 # else ThNoOverlap = trunc(ThName, abs(privateDmesh#ThName#khiDef[1][nuTriangle] - mpiRank(ThName#Comm)) < 1.0e-2, label = -111112); 1594 # fespace PhPartPrivate(ThNoOverlap, P0); 1595 # PhPartPrivate part; 1596 # partitionerSeq(part[], ThNoOverlap, mpiSize(comm)); 1597 # partitionerPar(part[], ThNoOverlap, mpiCommSelf, mpiSize(comm)); 1598 # meshN[int] sendTh(mpiSize(comm) - 1); 1599 # mpiRequest[int] rqSend(mpiSize(comm) - 1); 1600 # for(int i = 1; i < mpiSize(comm); ++i) { 1601 # sendTh[i - 1] = trunc(ThNoOverlap, abs(part - i) < 1.0e-2, label = -111112); 1602 # Isend(processor(i, comm, rqSend[i - 1]), sendTh[i - 1]); 1603 # } 1604 # ThScatterName = trunc(ThNoOverlap, abs(part) < 1.0e-2, label = -111112); 1605 # mpiWaitAll(rqSend); 1606 # } 1607 # else if(ThScatterName#Comm) { 1608 # mpiRequest rqRecv; 1609 # Irecv(processor(0, comm, rqRecv), ThScatterName); 1610 # mpiWait(rqRecv); 1611 # } 1612 # if(verbosity > 0 && ThScatterName#Comm) { 1613 # mpiBarrier(ThScatterName#Comm); 1614 # if(mpiRank(ThScatterName#Comm) == 0) 1615 # cout.scientific << " --- distributed mesh scattered (in " << mpiWtime() - timerScatter << ")" << endl; 1616 # } 1617 # } 1618 # reconstructDmesh(ThScatterName) 1619 # ) // EOM 1620 @ 1621 @ macro gatherSolution(ThName, comm, ThGatherName, Pk, u, uNew) { 1622 # IFMACRO(!privateDmesh#ThName) 1623 # assert(0); 1624 # ENDIFMACRO IFMACRO(!privateDmesh#ThGatherName) 1625 # assert(0); 1626 # ENDIFMACRO IFMACRO(!ThName#Comm) 1627 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThGatherName#Comm) 1628 # NewMacro ThGatherName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThName#Comm) 1629 # mpiBarrier(ThName#Comm); 1630 # real timerGather = mpiWtime(); 1631 # if(ThGatherName#Comm) { 1632 # meshN[int] recvTh(mpiSize(comm) - 1); 1633 # PetscScalar[int][int] recvU(mpiSize(comm) - 1); 1634 # mpiRequest[int] rqRecvTh(mpiSize(comm) - 1); 1635 # mpiRequest[int] rqRecvU(mpiSize(comm) - 1); 1636 # for(int i = 0; i < mpiSize(comm) - 1; ++i) 1637 # Irecv(processor(i + 1, comm, rqRecvTh[i]), recvTh[i]); 1638 # for(int i = 0; i < mpiSize(comm) - 1; ++i) { 1639 # int index = mpiWaitAny(rqRecvTh); 1640 # fespace VhRecvPrivate(recvTh[index], Pk); 1641 # recvU[index].resize(VhRecvPrivate.ndof); 1642 # Irecv(processor(index + 1, comm, rqRecvU[index]), recvU[index]); 1643 # } 1644 # fespace VhGlobalGatherPrivate(ThGatherName, Pk); 1645 # PetscScalar[int] visited(VhGlobalGatherPrivate.ndof); 1646 # visited = 1.0; 1647 # { 1648 # fespace VhRestrictionPrivate(ThName, Pk); 1649 # matrix R = interpolate(VhRestrictionPrivate, VhGlobalGatherPrivate); 1650 # PetscScalar[int] buffer = R' * u[]; 1651 # buffer .*= visited; 1652 # PetscScalar[int] ones(VhRestrictionPrivate.ndof); 1653 # ones = -1.0; 1654 # visited += R' * ones; 1655 # for[j, v : visited] v = max(abs(v), 0.0); 1656 # uNew[] += buffer; 1657 # } 1658 # for(int i = 0; i < mpiSize(comm) - 1; ++i) { 1659 # int index = mpiWaitAny(rqRecvU); 1660 # fespace VhRestrictionPrivate(recvTh[index], Pk); 1661 # matrix R = interpolate(VhRestrictionPrivate, VhGlobalGatherPrivate); 1662 # PetscScalar[int] buffer = R' * recvU[index]; 1663 # buffer .*= visited; 1664 # PetscScalar[int] ones(VhRestrictionPrivate.ndof); 1665 # ones = -1.0; 1666 # visited += R' * ones; 1667 # for[j, v : visited] v = max(abs(v), 0.0); 1668 # uNew[] += buffer; 1669 # } 1670 # } 1671 # else { 1672 # mpiRequest[int] rqSend(2); 1673 # Isend(processor(0, comm, rqSend[0]), ThName); 1674 # fespace VhLocalGatherPrivate(ThName, Pk); 1675 # assert(u[].n == VhLocalGatherPrivate.ndof); 1676 # Isend(processor(0, comm, rqSend[1]), u[]); 1677 # mpiWaitAll(rqSend); 1678 # } 1679 # if(verbosity > 0 && ThName#Comm) { 1680 # mpiBarrier(ThName#Comm); 1681 # if(mpiRank(ThName#Comm) == 0) 1682 # cout.scientific << " --- distributed solution gathered (in " << mpiWtime() - timerGather << ")" << endl; 1683 # } 1684 # } ) // EOM 1685 @ 1686 @ macro scatterSolution(ThName, comm, ThScatterName, Pk, u, uNew) { 1687 # IFMACRO(!privateDmesh#ThName) 1688 # assert(0); 1689 # ENDIFMACRO IFMACRO(!privateDmesh#ThScatterName) 1690 # assert(0); 1691 # ENDIFMACRO IFMACRO(!def) 1692 # NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!ThName#Comm) 1693 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!ThScatterName#Comm) 1694 # NewMacro ThScatterName#Comm()mpiCommWorld EndMacro ENDIFMACRO if(verbosity > 0 && ThScatterName#Comm) 1695 # mpiBarrier(ThScatterName#Comm); 1696 # real timerScatter = mpiWtime(); 1697 # if(mpiRank(comm) == 0) { 1698 # broadcast(processor(0, comm), ThName); 1699 # broadcast(processor(0, comm), u[]); 1700 # def(uNew) = def(u); 1701 # } 1702 # else { 1703 # meshN ThGlobalScatter; 1704 # broadcast(processor(0, comm), ThGlobalScatter); 1705 # fespace VhGlobalScatterPrivate(ThGlobalScatter, Pk); 1706 # VhGlobalScatterPrivate def(uGlobalScatter); 1707 # broadcast(processor(0, comm), uGlobalScatter[]); 1708 # def(uNew) = def(uGlobalScatter); 1709 # } 1710 # if(verbosity > 0 && ThScatterName#Comm) { 1711 # mpiBarrier(ThScatterName#Comm); 1712 # if(mpiRank(ThScatterName#Comm) == 0) 1713 # cout.scientific << " --- distributed solution scattered (in " << mpiWtime() - timerScatter << ")" << endl; 1714 # } 1715 # } 1716 # ) // EOM 1717 @ 1685 : 1686 : macro CoherentGlobalMesh(MatT, MatV, ThName, ThGlobal) 1687 # { 1688 # IFMACRO(!ThName#Comm) 1689 # NewMacro ThName#Comm()mpiCommWorld EndMacro ENDIFMACRO int[int] numberingT; 1690 # int[int] numberingV; 1691 # GlobalNumbering(MatT, numberingT); 1692 # GlobalNumbering(MatV, numberingV); 1693 # fespace VhLocalPrivateT(ThName, P0); 1694 # fespace VhGlobalPrivateT(ThGlobal, P0); 1695 # fespace VhLocalPrivateV(ThName, P1); 1696 # fespace VhGlobalPrivateV(ThGlobal, P1); 1697 # PetscScalar[int] numberingScalarT(numberingT.n), globalT, reduceT(ThGlobal.nt); 1698 # PetscScalar[int] numberingScalarV(numberingV.n), globalV, reduceV(ThGlobal.nv); 1699 # for[i, v : numberingT] numberingScalarT[i] = v; 1700 # for[i, v : numberingV] numberingScalarV[i] = v; 1701 # ChangeNumbering(MatT, numberingScalarT, globalT); 1702 # ChangeNumbering(MatV, numberingScalarV, globalV); 1703 # if (ThName.nv) { 1704 # ChangeNumbering(MatT, numberingScalarT, globalT, inverse = true); 1705 # ChangeNumbering(MatV, numberingScalarV, globalV, inverse = true); 1706 # IFMACRO(ThName#N2O) 1707 # int[int] restrictionT = restrict(VhLocalPrivateT, VhGlobalPrivateT, ThName#N2O); 1708 # int[int] restrictionV = restrict(VhLocalPrivateV, VhGlobalPrivateV, ThName#N2O); 1709 # ENDIFMACRO IFMACRO(!ThName#N2O) 1710 # int[int] restrictionT, restrictionV; 1711 # { 1712 # fespace PhGlobalPrivate(ThGlobal, P0); 1713 # fespace PhLocalPrivate(ThName, P0); 1714 # matrix R = interpolate(PhLocalPrivate, PhGlobalPrivate); 1715 # int[int] I, J; 1716 # real[int] C; 1717 # [I, J, C] = R; 1718 # restrictionT = restrict(VhLocalPrivateT, VhGlobalPrivateT, J); 1719 # restrictionV = restrict(VhLocalPrivateV, VhGlobalPrivateV, J); 1720 # } 1721 # ENDIFMACRO for[i, v : restrictionT] reduceT[v] = numberingScalarT[i]; 1722 # for[i, v : restrictionV] reduceV[v] = numberingScalarV[i]; 1723 # } 1724 # globalT.resize(ThGlobal.nt); 1725 # globalV.resize(ThGlobal.nv); 1726 # mpiAllReduce(reduceT, globalT, ThName#Comm, mpiSUM); 1727 # mpiAllReduce(reduceV, globalV, ThName#Comm, mpiSUM); 1728 # int[int] globalIntT(globalT.n); 1729 # int[int] globalIntV(globalV.n); 1730 # for[i, v : globalT] globalIntT[i] = abs(v); 1731 # for[i, v : globalV] globalIntV[i] = abs(v); 1732 # ThGlobal = change(ThGlobal, renumt = globalIntT, renumv = globalIntV); 1733 # } 1734 # ) // EOM 1735 : 12 : 13 : /* working directory and run name */ 14 : /* IMPORTANT: STANDARD INPUT is via command lin input macro (-DwDir=mydirectoryname ), other option is code modification */ 15 : /* required for custom input */ 16 : string workDir; 17 : IFMACRO(wDir) 18 & workDir = Stringification(wDir); 19 & ENDIFMACRO 18 @ workDir = Stringification((wDirPSE1PSE1)); 19 @ 20 : 21 : /* ############################################################################ */ 22 : /* ############################################################################ */ 23 : /* macro for general FE function handling for incompressible Newtonian flow */ 24 : IFMACRO(newtonianincompressible) 25 & 26 & if(mpirank==0) cout << "macro exists " << endl; 27 & int[int] labPeriodic = [8, 9]; /* LHS-RHS boundary labels*/ 28 & macro Pk() [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM /* main FE space for solution */ 29 & macro PkNonPer() [P2,P2,P2,P1]// EOM /* nonperiodic FE space just in case */ 30 & macro Pk1NonPer() [P1,P1,P1,P1]// EOM /* nonperiodic FE space just in case */ 31 & macro P2k() P2, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM /* single periodic P2 space */ 32 & macro P1k() P1, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM /* single periodic P1 space */ 33 & 34 & /* macro required for handling periodic boundary condition in distributed mesh */ 35 & macro thPeriodicity()labPeriodic// 36 & 37 & /* required macros for handling the FE spaces*/ 38 & macro gendef(i)[i, i#B, i#C, i#D]// 39 & macro geninit(i)[i,i,i,i]// 40 & 41 & /* general macro for resizing the FE spaces */ 42 & macro genzeros()[1, 0, 0, 0] //EOM 43 & 44 & /* vector required for .vtu input files */ 45 & int[int] VTUOrder = [1, 1, 1, 1]; 46 & 47 & ENDIFMACRO 25 @ 26 @ if(mpirank==0) cout << "macro exists " << endl; 27 @ int[int] labPeriodic = [8, 9]; /* LHS-RHS boundary labels*/ 28 @ macro Pk() [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM /* main FE space for solution */ 29 @ macro PkNonPer() [P2,P2,P2,P1]// EOM /* nonperiodic FE space just in case */ 30 @ macro Pk1NonPer() [P1,P1,P1,P1]// EOM /* nonperiodic FE space just in case */ 31 @ macro P2k() P2, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM /* single periodic P2 space */ 32 @ macro P1k() P1, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM /* single periodic P1 space */ 33 @ 34 @ /* macro required for handling periodic boundary condition in distributed mesh */ 35 @ macro thPeriodicity()labPeriodic// 36 @ 37 @ /* required macros for handling the FE spaces*/ 38 @ macro gendef(i)[i, i#B, i#C, i#D] ) // 39 @ macro geninit(i)[i,i,i,i] ) // 40 @ 41 @ /* general macro for resizing the FE spaces */ 42 @ macro genzeros()[1, 0, 0, 0] //EOM 43 @ 44 @ /* vector required for .vtu input files */ 45 @ int[int] VTUOrder = [1, 1, 1, 1]; 46 @ 47 @ 48 : 49 : /* ---------------------------------------------------------------------------- */ 50 : /* only for the 2D Blasius solution test - should be deleted later */ 51 : IFMACRO(Blasius) 52 & if(mpirank==0) cout << "macro exists " << endl; 53 & int[int] labPeriodic = [8, 9]; 54 & macro Pk() [P2, P2], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM 55 & macro P2k() P2, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM 56 & macro P1k() P1, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]// EOM 57 & macro thPeriodicity()labPeriodic// 58 & macro gendef(i)[i, i#B]// 59 & macro geninit(i)[i,i]// 60 & ENDIFMACRO 61 : 62 : /* ############################################################################ */ 63 : /* ############################################################################ */ 64 : 65 : /* ################### adaptation parameters - not used ATM ################### */ 66 : 67 : real nNbvx = 100000; 68 : real hmaxPar = 1; 69 : real hminPar = 0.001; 70 : real errgPar = 0.001; 71 : real errPar = 0.01; 72 : real ratioPar = 10.; 73 : bool kepbckVert = true; 74 : real maxmeshangle = 10; 75 : bool Splitpbedge= false; 76 : bool Splitin2 = false ; 77 : int nbsmoothiter = 5; 78 : int nbjacobyiter = 6; 79 : int powerHess = 1; 80 : 81 : /* ################### Newton and KSP (lin eq. solution) parameters ################### */ 82 : real tolNewton = getARGV("-tolNewton", 5.e-13); 83 : real rtolNewton = getARGV("-rtolNewton", 5.e-13); 84 : real stolNewton = getARGV("-stolNewton", 5.e-13); 85 : 86 : /* nonlinear line-search order */ 87 : int lsearchoder = getARGV("-lsearchoder", 2); 88 : /* maximum line-search iterations */ 89 : int lsearchmaxiter= getARGV("-lsearchmaxiter", 20); 90 : /* trust-region method initial step param - if negative, normal run; deltanaught=0.01 is a goto value */ 91 : real deltanaught = getARGV("-deltanaught", -1.); 92 : 93 : /* line search parameters */ 94 : string snespar; 95 : if(deltanaught<0){ 96 : snespar = "-snes_monitor -snes_max_it " + lsearchmaxiter + " -snes_linesearch_monitor -snes_linesearch_order ... : " + lsearchoder + " -snes_atol " + tolNewton + " -snes_rtol " + rtolNewton + " -snes_stol " + stolNewton + " -snes_converged_reason "; 97 : } else { 98 : snespar = " -snes_type newtontr -snes_tr_delta0 " + deltanaught + " -snes_monitor -snes_max_it " + lsearchmaxiter + " -snes_linesearch_monitor -snes_linesearch_order ... : " + lsearchoder + " -snes_atol " + tolNewton + " -snes_rtol " + rtolNewton + " -snes_stol " + stolNewton + " -snes_converged_reason "; 99 : } 100 : 101 : /* direct solver parameters */ 102 : string linsolvePar = "-ksp_type preonly -pc_type lu"; 103 : 104 : /* Parameters for the distributed PEP solver */ 105 : string PEPParamsbase = 106 : " -pep_basis monomial " + 107 : " -pep_general " + 108 : " -st_type sinvert " + 109 : " -st_pc_type lu " + 110 : " -pep_monitor_all" ; 111 : 112 : /* ################### mesh and FE space initialization ################### */ 113 : /* distributed mesh */ 114 : mesh th = square(1, 1); 115 : /* non-distributed Global mesh */ 116 : mesh thGlobal = square(1, 1); 117 : 118 : /* horizontal (y=const.) and vertical (x=const.) mesh, respectively */ 119 : meshL thLx = segment(5,[1,0,0],removeduplicate=true); 120 : meshL thLy = segment(5,[0,1,0],removeduplicate=true); 121 : 122 : int[int] n2oth; // need to know how to go from the local to the global mesh 123 : macro thN2O()n2oth// // macro name shoud coincide the mesh used: "meshname"N2O 124 : fespace VhC(th,Pk [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 125 : fespace VhCGlob(thGlobal, Pk [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 126 : fespace VP2(th,P2k P2, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 127 : fespace VP1(th,P1k P1, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 128 : fespace VP2Glob(thGlobal,P2k P2, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 129 : fespace VP1Glob(thGlobal,P1k P1, periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 130 : 131 : fespace VhLxP2(thLx,P1); 132 : fespace VhLyP2(thLy,P1); 133 : 134 : /* restriction vector */ 135 : int[int] rest; 136 : 137 : IFMACRO(BRE) 138 & VhLxP2 uLx; 139 & VhLyP2 uLy; 140 & VhC gendef(usol); 141 & VhC gendef(usolprev); 142 & VhC gendef(usolprevprev); 143 & VhCGlob gendef(uGlobal), gendef(uReduce); 144 & 145 & Mat dJ; 146 & 147 & real[int] XgridBRE; 148 & ENDIFMACRO 149 : IFMACRO(EV) 150 & VhLxP2 uLx; 151 & VhLyP2 uLy; 152 & VhC gendef(usol); 153 & VhCGlob gendef(uGlobal), gendef(uReduce); 154 & VhC gendef(uBF), gendef(uBFprev); 155 & 156 & Mat dJ; 157 & 158 & real[int] XgridBRE, XgridBiGlob; 159 & ENDIFMACRO 160 : IFMACRO(PSE) 161 & VhLxP2 uLx; 162 & VhLyP2 uLy; 163 & VhC gendef(usol); 164 & VhC gendef(usolprev); 165 & VhC gendef(usolprevprev); 166 & VhCGlob gendef(uGlobal), gendef(uReduce); 167 & VhC gendef(uBF), gendef(uBFprev), gendef(uBFprevprev), gendef(uBFx), gendef(uBFn); 168 & 169 & /* variable for faster RHS evaluation in the multistep case */ 170 & VhC gendef(usol2Evalrhs); 171 & /* variable for collapsed previous step */ 172 & VhCGlob gendef(uGlobal2Evalrhs); 173 & 174 & Mat dJ; 175 & 176 & real[int] XgridBRE, XgridBiGlob, XgridPSE; 177 & /* vector for linear Eq. solution RHS */ 178 & complex[int] rhsvec, rhsvecPETSc, usolPETSc, usol2EvalrhsPETSc, auxvecPETSc; 179 & ENDIFMACRO 161 @ VhLxP2 uLx; 162 @ VhLyP2 uLy; 163 @ VhC gendef(usol) [usol, usolB, usolC, usolD]; 164 @ VhC gendef(usolprev) [usolprev, usolprevB, usolprevC, usolprevD]; 165 @ VhC gendef(usolprevprev) [usolprevprev, usolprevprevB, usolprevprevC, usolprevprevD]; 166 @ VhCGlob gendef(uGlobal) [uGlobal, uGlobalB, uGlobalC, uGlobalD], gendef(uReduce) [uReduce, uReduceB, uReduceC, uReduceD]; 167 @ VhC gendef(uBF) [uBF, uBFB, uBFC, uBFD], gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD], gendef(uBFprevprev) [uBFprevprev, uBFprevprevB, uBFprevprevC, uBFprevprevD], gendef(uBFx) [uBFx, uBFxB, uBFxC, uBFxD], gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD]; 168 @ 169 @ /* variable for faster RHS evaluation in the multistep case */ 170 @ VhC gendef(usol2Evalrhs) [usol2Evalrhs, usol2EvalrhsB, usol2EvalrhsC, usol2EvalrhsD]; 171 @ /* variable for collapsed previous step */ 172 @ VhCGlob gendef(uGlobal2Evalrhs) [uGlobal2Evalrhs, uGlobal2EvalrhsB, uGlobal2EvalrhsC, uGlobal2EvalrhsD]; 173 @ 174 @ Mat dJ; 175 @ 176 @ real[int] XgridBRE, XgridBiGlob, XgridPSE; 177 @ /* vector for linear Eq. solution RHS */ 178 @ complex[int] rhsvec, rhsvecPETSc, usolPETSc, usol2EvalrhsPETSc, auxvecPETSc; 179 @ 180 : 181 : /* ################### general intput from command line ################### */ 182 : 183 : /* x grid */ 184 : real dX; 185 : real X0, X1, X2; 186 : 187 : string infilename; 188 : string outfilename; 189 : /* general parameters definition */ 9 : include "../include/stabmacros.idp"/* #################################################################################################### */ 2 : /* ################################ general stability related macros ################################## */ 3 : /* #################################################################################################### */ 4 : 5 : 6 : /* #################################################################################################### */ 7 : /* ##################################### export - import macros ###################################### */ 8 : /* #################################################################################################### */ 9 : 10 : 11 : /* ---------------------------------------------------------------------------------------------------- */ 12 : /* export meshes */ 13 : macro exportMesh(bmeshname) 14 # 15 # saveDmesh(th, workDir + "/" + bmeshname) 16 # if(mpirank==0){ 17 # savemesh(thGlobal, workDir + "/" + bmeshname + "_th0.mesh"); 18 # savemesh(thLx, workDir + "/" + bmeshname + "_thLx.mesh"); 19 # savemesh(thLy, workDir + "/" + bmeshname + "_thLy.mesh"); 20 # } 21 # 22 # ) //EOM 23 : 24 : /* ---------------------------------------------------------------------------------------------------- */ 25 : /* import meshes */ 26 : macro importMesh(bmeshname) 27 # 28 # loadDmesh(th, workDir + "/" + bmeshname) 29 # if(mpirank==0){ 30 # thGlobal = readmesh(workDir + "/" + bmeshname + "_th0.mesh"); 31 # thLx = readmeshL(workDir + "/" + bmeshname + "_thLx.mesh"); 32 # thLy = readmeshL(workDir + "/" + bmeshname + "_thLy.mesh"); 33 # } 34 # broadcast(processor(0),thGlobal); 35 # broadcast(processor(0),thLx); 36 # broadcast(processor(0),thLy); 37 # 38 # if(mpirank==0){ 39 # cout << "meshes loaded successfully " << endl; 40 # } 41 # 42 # ) //EOM 43 : 44 : /* ---------------------------------------------------------------------------------------------------- */ 45 : /* export variable on rank 0 process */ 46 : macro exportVar(vec,eqType,fname){ 47 # 48 # if(mpirank==0){ 49 # string ofname; 50 # ofname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + ".dat"; 51 # 52 # ofstream ofile(ofname); 53 # ofile.precision(16); 54 # ofile << vec << endl; 55 # } 56 # 57 # } ) //EOM 58 : 59 : /* ---------------------------------------------------------------------------------------------------- */ 60 : /* import variable on rank 0 process */ 61 : macro importVar(vec,eqType,fname){ 62 # 63 # if(mpirank==0){ 64 # string ifname; 65 # ifname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + ".dat"; 66 # 67 # ifstream ifile(ifname); 68 # ifile >> vec; 69 # } 70 # broadcast(processor(0), vec); 71 # 72 # } ) //EOM 73 : 74 : /* ---------------------------------------------------------------------------------------------------- */ 75 : /* export vector on rank 0 process */ 76 : macro exportVec(vec,eqType,fname){ 77 # 78 # if(mpirank==0){ 79 # string ofname; 80 # ofname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + ".dat"; 81 # 82 # ofstream ofile(ofname); 83 # ofile.precision(16); 84 # ofile << vec.n << endl; 85 # ofile << vec << endl; 86 # } 87 # 88 # } ) //EOM 89 : 90 : /* ---------------------------------------------------------------------------------------------------- */ 91 : /* import vector on rank 0 process */ 92 : macro importVec(vec,eqType,fname){ 93 # 94 # int dummyN; 95 # 96 # if(mpirank==0){ 97 # string ifname; 98 # ifname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + ".dat"; 99 # ifstream ifile(ifname); 100 # ifile >> dummyN; 101 # vec.resize(dummyN); 102 # ifile >> vec; 103 # } 104 # broadcast(processor(0), dummyN); 105 # if(mpirank!=0){ 106 # vec.resize(dummyN); 107 # } 108 # broadcast(processor(0), vec); 109 # 110 # } ) //EOM 111 : 112 : /* ---------------------------------------------------------------------------------------------------- */ 113 : /* export matrix on rank 0 process */ 114 : macro exportMat(matvar,eqType,fname){ 115 # 116 # if(mpirank==0){ 117 # string ofname; 118 # ofname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + ".dat"; 119 # 120 # ofstream ofile(ofname); 121 # ofile.precision(16); 122 # ofile << matvar.n << endl; 123 # ofile << matvar.m << endl; 124 # ofile << matvar << endl; 125 # } 126 # 127 # } ) //EOM 128 : /* ---------------------------------------------------------------------------------------------------- */ 129 : /* import matrix on rank 0 process */ 130 : macro importMat(matvar,eqType,fname){ 131 # 132 # int matn,matm; 133 # 134 # if(mpirank==0){ 135 # string ifname; 136 # ifname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + ".dat"; 137 # ifstream ifile(ifname); 138 # ifile >> matn; 139 # ifile >> matm; 140 # matvar.resize(matn,matm); 141 # ifile >> matvar; 142 # } 143 # broadcast(processor(0), matn); 144 # broadcast(processor(0), matm); 145 # mpiBarrier(mpiCommWorld); 146 # if(mpirank!=0){ 147 # matvar.resize(matn,matm); 148 # } 149 # broadcast(processor(0), matvar); 150 # 151 # } ) //EOM 152 : 153 : 154 : /* ---------------------------------------------------------------------------------------------------- */ 155 : /* export 2D sol */ 156 : macro export2DField(field,eqType,fname,i){ 157 # 158 # string ofname; 159 # if(i<0){ 160 # ofname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_np" + mpisize + "_" + mpirank + ".dat"; 161 # } else { 162 # ofname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_" + i + "_np" + mpisize + "_" + mpirank + ".dat"; 163 # } 164 # 165 # ofstream ofile(ofname); 166 # ofile.precision(16); 167 # ofile << field[] << endl; 168 # 169 # } ) //EOM 170 : 171 : /* ---------------------------------------------------------------------------------------------------- */ 172 : /* import 2D sol */ 173 : macro import2DField(field,eqType,fname,i){ 174 # 175 # string ifname; 176 # if(i<0){ 177 # ifname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 # } else { 179 # ifname = workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_" + i + "_np" + mpisize + "_" + mpirank + ".dat"; 180 # } 181 # 182 # ifstream ifile(ifname); 183 # ifile >> field[]; 184 # 185 # } ) //EOM 186 : 187 : /* ---------------------------------------------------------------------------------------------------- */ 188 : /* export VTU data */ 189 : macro VTUexportGendata(field,eqType,fname,cname){ 190 # IFMACRO(BRE) 191 # savevtk(workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_" + cname,thGlobal,field,field#B,field#C,field#D, 192 # dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 193 # ENDIFMACRO 194 # IFMACRO(EV) 195 # VhCGlob gendef(uGr),gendef(uGi); 196 # uGr[] = field[].re; 197 # uGi[] = field[].im; 198 # savevtk(workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_" + cname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 199 # dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 200 # ENDIFMACRO 201 # IFMACRO(PSE) 202 # VhCGlob gendef(uGr),gendef(uGi); 203 # uGr[] = field[].re; 204 # uGi[] = field[].im; 205 # savevtk(workDir + "/" + basemeshname + "_" + eqType + "_" + fname + "_" + cname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 # dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 # ENDIFMACRO 208 # } ) //EOM 209 : 210 : /* ---------------------------------------------------------------------------------------------------- */ 211 : 212 : macro exportGenpar(fname){ 213 # 214 # if(mpirank==0){ 215 # string ofname; 216 # ofname = workDir + "/" + basemeshname + "_genpar_" + fname + ".dat"; 217 # 218 # ofstream ofile(ofname); 219 # ofile.precision(16); 220 # ofile << Rey << endl; 221 # ofile << Rex0 << endl; 222 # ofile << Rex1 << endl; 223 # ofile << Redelta0 << endl; 224 # ofile << Redelta1 << endl; 225 # ofile << Reydelta << endl; 226 # ofile << Ufs << endl; 227 # ofile << nuvar << endl; 228 # 229 # } 230 # 231 # } ) //EOM 232 : 233 : /* ---------------------------------------------------------------------------------------------------- */ 234 : 235 : macro importGenpar(fname){ 236 # 237 # if(mpirank==0){ 238 # string ifname; 239 # ifname = workDir + "/" + basemeshname + "_genpar_" + fname + ".dat"; 240 # 241 # ifstream ifile(ifname); 242 # ifile >> Rey; 243 # ifile >> Rex0; 244 # ifile >> Rex1; 245 # ifile >> Redelta0; 246 # ifile >> Redelta1; 247 # ifile >> Reydelta; 248 # ifile >> Ufs; 249 # ifile >> nuvar; 250 # 251 # } 252 # broadcast(processor(0), Rey); 253 # broadcast(processor(0), Rex0); 254 # broadcast(processor(0), Rex1); 255 # broadcast(processor(0), Redelta0); 256 # broadcast(processor(0), Redelta1); 257 # broadcast(processor(0), Reydelta); 258 # broadcast(processor(0), Ufs); 259 # broadcast(processor(0), nuvar); 260 # 261 # } ) //EOM 262 : 263 : /* ---------------------------------------------------------------------------------------------------- */ 264 : /* BF for BiGlobal stability calculation */ 265 : macro importBREBF4BiGlobalcalc(fielvar,ind) 266 # /* remark: ind refers to the EV grid, although it is the same as the BRE grid when BiGlobXtype==1 */ 267 # /* TODO: downsample & variable x0 IC*/ 268 # if(BiGlobXtype==0){ 269 # import2DField(fielvar,"BRE",iname,0) 270 # } else if(BiGlobXtype==1){ 271 # import2DField(fielvar,"BRE",iname,ind) 272 # } else if(BiGlobXtype==2){ 273 # if(mpirank==0) cout << "TODO downsample" << endl; 274 # } else if(BiGlobXtype==3){ 275 # /* find the "right neighbour coordinate */ 276 # int xind = 0; 277 # while(XgridBiGlob[ind] > XgridBRE[xind] & xind < XgridBRE.n-1){ 278 # xind++; 279 # } 280 # /* if very close to a BRe grid value, take it, otherwise interpolate - !!!tolerance is valid for Blasius scale only!!! */ 281 # if(abs(XgridBiGlob[ind] - XgridBRE[xind]) < 1e-3){ 282 # import2DField(fielvar,"BRE",iname,xind) 283 # } else if(abs(XgridBiGlob[ind] - XgridBRE[xind-1])<1e-3){ 284 # xind -= 1; 285 # import2DField(fielvar,"BRE",iname,xind) 286 # } else { 287 # import2DField(fielvar,"BRE",iname,xind) 288 # xind -= 1; 289 # import2DField(uBFprev,"BRE",iname,xind) 290 # fielvar[] = fielvar[]*(XgridBiGlob[ind]-XgridBRE[xind]) + uBFprev[]*(XgridBRE[xind+1]-XgridBiGlob[ind]); 291 # fielvar[] *= (1/(XgridBRE[xind+1] - XgridBRE[xind])); 292 # } 293 # } 294 # ) //EOM 295 : 296 : /* #################################################################################################### */ 297 : /* ##################################### Miscellaneous macros ######################################### */ 298 : /* #################################################################################################### */ 299 : 300 : /* ----------------------------------------------------------------------------------------------- */ 301 : /* default createMat macro */ 302 : macro defcreateMat(){ 303 # 304 # NewMacro def(i)gendef(i) EndMacro 305 # NewMacro init(i)geninit(i) EndMacro 306 # createMat(th, dJ, Pk) 307 # 308 # }//EOM 309 : 310 : /* mass-matrix allocation and creation for PSE */ 311 : macro createMassMatPSE() 312 # 313 # Mat dM(dJ); 314 # Mat dMvel(dJ); 315 # 316 # { 317 # varf fullMassMatvarf([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)(u1*v1+u2*v2+u3*v3+p*q); 318 # dM = fullMassMatvarf(VhC,VhC); 319 # varf velMassMatvarf([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)(u1*v1+u2*v2+u3*v3); 320 # dMvel = velMassMatvarf(VhC,VhC); 321 # } 322 # 323 # //EOM 324 : 325 : /* parallel integration macro: calculates the inner product as vec1' * massMat * vec2 */ 326 : /* everything should be in PETSc numbering */ 327 : macro integrateParallel(massMat,vec1,vec2,auxvec,integralValue){ 328 # MatMult(massMat, vec2, auxvec); 329 # complex tempDistIntegral = vec1' * auxvec; 330 # mpiAllReduce(tempDistIntegral, integralValue, mpiCommWorld, mpiSUM); 331 # } ) //EOM 332 : 333 : /* ---------------------------------------------------------------------------------------------------- */ 334 : /* resizing variables after the mesh is read */ 335 : macro resizeFieldVar() 336 # 337 # IFMACRO(BRE) 338 # uLx = uLx; 339 # uLy = uLy; 340 # gendef(usol) = gendef(usol); 341 # gendef(usolprev) = gendef(usolprev); 342 # gendef(usolprevprev) = gendef(usolprevprev); 343 # gendef(uReduce) = gendef(uReduce); 344 # gendef(uGlobal) = gendef(uGlobal); 345 # ENDIFMACRO 346 # IFMACRO(EV) 347 # uLx = uLx; 348 # uLy = uLy; 349 # gendef(usol) = gendef(usol); 350 # gendef(uReduce) = gendef(uReduce); 351 # gendef(uGlobal) = gendef(uGlobal); 352 # gendef(uBF) = gendef(uBF); 353 # gendef(uBFprev) = gendef(uBFprev); 354 # ENDIFMACRO 355 # IFMACRO(PSE) 356 # uLx = uLx; 357 # uLy = uLy; 358 # gendef(usol) = gendef(usol); 359 # gendef(usolprev) = gendef(usolprev); 360 # gendef(usolprevprev) = gendef(usolprevprev); 361 # gendef(uReduce) = gendef(uReduce); 362 # gendef(uGlobal) = gendef(uGlobal); 363 # gendef(uBF) = gendef(uBF); 364 # gendef(uBFprev) = gendef(uBFprev); 365 # gendef(uBFx) = gendef(uBFx); 366 # gendef(uBFn) = gendef(uBFn); 367 # gendef(usol2Evalrhs) = gendef(usol2Evalrhs); 368 # gendef(uGlobal2Evalrhs) = gendef(uGlobal2Evalrhs); 369 # rhsvec.resize(VhC.ndof); 370 # ENDIFMACRO 371 # 372 # //EOM 373 : 374 : /* ---------------------------------------------------------------------------------------------------- */ 375 : /* BiGlobal stability - leading eigenvalue allocations */ 376 : macro setupBiGlobEVmat() 377 # /* TODO: downsample */ 378 # complex[int,int] leadingEvalvec(nF,1); 379 # if(BiGlobXtype==1){ 380 # leadingEvalvec.resize(nF,XgridBRE.n); 381 # } else if(BiGlobXtype==2){ 382 # if(mpirank==0) cout << "TODO downsample" << endl; 383 # } else if(BiGlobXtype==3){ 384 # leadingEvalvec.resize(nF,XgridBiGlob.n); 385 # } 386 # //EOM 387 : 388 : /* ---------------------------------------------------------------------------------------------------- */ 389 : /* streak amplitude calculation following Andersson 2001 */ 390 : macro calcstreakAmplAndersson(Ampl,Field){ 391 # 392 # /* number of points in the y and x(z) direction */ 393 # int npl = 100; 394 # /* definition and allocation */ 395 # real[int] diffvecy(npl),yvec; 396 # /* defining the vectors on the y domain */ 397 # linspace(yvec,thLy[0][0].y,thLy[thLy.nt-1][1].y/6.,npl) 398 # 399 # for(int k=0; k gendef(uGloc); 664 # sendvecDistributed2Global(Field,uGloc) 665 # /* gathered x component FE space */ 666 # VP2Glob tempu = uGloc; 667 # /* extracting real part, and dividing with it's maximum*/ 668 # VP2Glob tempur; 669 # tempur[] = tempu[].re; 670 # complex normfac = tempur[] .max; 671 # Field[] = Field[] / normfac; 672 # } else if(normType==1){ 673 # /* energy norm: consensing solution*/ 674 # VhCGlob gendef(uGloc); 675 # sendvecDistributed2Global(Field,uGloc) 676 # /* calculation and distribution of the factor */ 677 # complex locKinEnerg; 678 # if(mpirank==0){ 679 # locKinEnerg = 0.5*int2d(thGlobal, qforder=3)(conj(uGloc)*uGloc + conj(uGlocB)*uGlocB + conj(uGlocC)*uGlocC); 680 # locKinEnerg = sqrt(locKinEnerg); /* because it is a quadratic funciton */ 681 # } 682 # broadcast(processor(0),locKinEnerg); 683 # Field[] *= (1./locKinEnerg); 684 # } 685 # 686 # } ) //EOM 687 : 688 : /* ---------------------------------------------------------------------------------------------------- */ 689 : /* macro calculation the Blasius IC at a given Rey local Reynolds number*/ 690 : macro setBlasiusIC(Field,Rey){ 691 # 692 # /* Blasius solution components in splines */ 693 # gslspline splineBlasU; 694 # gslspline splineBlasf; 695 # 696 # CalcBlasius(splineBlasU,splineBlasf) 697 # 698 # /* function for U and V that can handle extrapolation */ 699 # func real BlasU(real y) { 700 # real ylim = 20.; 701 # real Uval; 702 # if(y>ylim){ 703 # Uval = splineBlasU(ylim); 704 # } else { 705 # Uval = splineBlasU(y); 706 # } 707 # return Uval; 708 # } 709 # func real BlasV(real y) { 710 # real ylim = 20.; 711 # real Vval; 712 # if(y>ylim){ 713 # Vval = 0.5*(splineBlasU(ylim)*ylim - splineBlasf(ylim))/sqrt(Rex0); 714 # } else { 715 # Vval = 0.5*(splineBlasU(y)*y - splineBlasf(y))/sqrt(Rex0); 716 # } 717 # return Vval; 718 # } 719 # 720 # /* setting the Blasius solution in the vector */ 721 # gendef(Field) = [BlasU(y*sqrt(Rey)/sqrt(Rex0)), BlasV(y*sqrt(Rey)/sqrt(Rex0)), 0, 0]; 722 # 723 # } ) //EOM 724 : 725 : /* ---------------------------------------------------------------------------------------------------- */ 726 : /* collapsing the solution to the non-distributed mesh */ 727 : macro sendvecDistributed2Global(vecdist,veczero){ 728 # /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 # IFMACRO(BRE) 730 # VhC gendef(locsol); 731 # locsol[] = vecdist[]; 732 # locsol[] .*= dJ.D; 733 # ENDIFMACRO 734 # IFMACRO(EV) 735 # VhC gendef(locsol); 736 # locsol[] = vecdist[]; 737 # locsol[].re .*= dJ.D; 738 # locsol[].im .*= dJ.D; 739 # ENDIFMACRO 740 # IFMACRO(PSE) 741 # VhC gendef(locsol); 742 # locsol[] = vecdist[]; 743 # locsol[].re .*= dJ.D; 744 # locsol[].im .*= dJ.D; 745 # ENDIFMACRO 746 # 747 # /* TODO: description */ 748 # for[i, v : rest] uReduce[][v] = locsol[][i]; 749 # mpiAllReduce(uReduce[], veczero[], mpiCommWorld, mpiSUM); 750 # 751 # } ) //EOM 752 : 753 : /* ---------------------------------------------------------------------------------------------------- */ 754 : /* distribute solution from a collapsed mesh to the distributed mesh */ 755 : macro sendvecGlobal2Distributed(veczero,vecdist){ 756 # 757 # for[j, v : rest] vecdist[][j] = veczero[][v]; 758 # 759 # } ) //EOM 760 : 761 : /* ---------------------------------------------------------------------------------------------------- */ 762 : /* x grid setup for BRE solution */ 763 : macro setXgrid(xgrid,nn){ 764 # 765 # /* x-grid distribution: if dxtype= boundary layer scaling - equidistane in sqrt(x) - otherwise normal scaling */ 766 # if(dxtype==1){ 767 # linspace(xgrid,sqrt(x0),sqrt(x1),nn) 768 # xgrid=xgrid.*xgrid; 769 # } else if(dxtype==2){ 770 # linspace(xgrid,x0,x1,nn) 771 # } else if(dxtype==0){ 772 # linspace(xgrid,x0,x1,nn) 773 # } else { 774 # if(mpirank==0){ 775 # cout << "dxtype is incorrect" << endl; 776 # } 777 # } 778 # 779 # } ) //EOM 780 : 781 : /* ---------------------------------------------------------------------------------------------------- */ 782 : /* BiGlobal EV calculation - x grid setup */ 783 : /* BiGlobXtype 0: only at the location of x0; 1: all the x values; 2: downsample the BRE x grid - TODO; 3: specific x grid */ 784 : macro setupXgridBiGlob() 785 # 786 # if(BiGlobXtype==0){ 787 # nX = 1; 788 # XgridBiGlob.resize(nX); 789 # XgridBiGlob[0] = XgridBRE[0]; 790 # }else if(BiGlobXtype==1){ 791 # XgridBiGlob.resize(XgridBRE.n); 792 # XgridBiGlob = XgridBRE; 793 # }else if(BiGlobXtype==2){ 794 # if(mpirank==0) cout << "TODO: downsample" << endl; 795 # }else if(BiGlobXtype==3){ 796 # 797 # if(dxtype==1){ 798 # linspace(XgridBiGlob,sqrt(x0),sqrt(x1),nX) 799 # XgridBiGlob=XgridBiGlob.*XgridBiGlob; 800 # } else if(dxtype==2){ 801 # linspace(XgridBiGlob,x0,x1,nX) 802 # } else if(dxtype==0){ 803 # linspace(XgridBiGlob,x0,x1,nX) 804 # } else { 805 # if(mpirank==0){ 806 # cout << "dxtype is incorrect" << endl; 807 # } 808 # } 809 # /* nondim */ 810 # XgridBiGlob = XgridBiGlob *(Ufs /(nuvar*Rex0)); 811 # 812 # } 813 # //EOM 814 : 815 : /* ---------------------------------------------------------------------------------------------------- */ 816 : /* X grid setup for PSE */ 817 : macro setupPSEXgrid(ind) 818 # 819 # if(Fvec.n==XgridBiGlob.n){ 820 # x0 = XgridBiGlob[ind]; 821 # } else { 822 # x0 = XgridBiGlob[0]; 823 # } 824 # if(fixGrid){ 825 # /* nondim with x0 - BRE scale */ 826 # if(ind==0){ 827 # /* for a single x0 grid */ 828 # setupXgrid(XgridPSE,x0,x1,nX) 829 # } else { 830 # /* for an x0(F) grid, roughly the same stepsize - TODO TEST*/ 831 # real dLsqrt = (sqrt(x1)-sqrt(XgridBiGlob[0]))/nX; 832 # real nXlocal = ceil((sqrt(x1)-sqrt(x0))/dLsqrt); 833 # setupXgrid(XgridPSE,x0,x1,nXlocal) 834 # } 835 # alphavec.resize(XgridPSE.n); 836 # energyvec.resize(nX); 837 # growthmat.resize(nX,growthmat.m); 838 # IFMACRO(GROWTHDEBUG) 839 # growthmatDEBUGu.resize(nX,2); 840 # growthmatDEBUGv.resize(nX,2); 841 # ENDIFMACRO 842 # } else { 843 # XgridPSE.resize(1); 844 # XgridPSE[0] = x0; 845 # alphavec.resize(1); 846 # energyvec.resize(1); 847 # growthmat.resize(1,growthmat.m); 848 # IFMACRO(GROWTHDEBUG) 849 # growthmatDEBUGu.resize(nX,2); 850 # growthmatDEBUGv.resize(nX,2); 851 # ENDIFMACRO 852 # } 853 # 854 # ) //EOM 855 : 856 : /* ---------------------------------------------------------------------------------------------------- */ 857 : /* new X grid setup */ 858 : macro setupXgrid(xgrid,x0,x1,nn) 859 # 860 # if(dxtype==1){ 861 # linspace(xgrid,sqrt(x0),sqrt(x1),nn) 862 # xgrid=xgrid.*xgrid; 863 # } else if(dxtype==2){ 864 # linspace(xgrid,x0,x1,nn) 865 # } 866 # 867 # ) //EOM 868 : 869 : /* ---------------------------------------------------------------------------------------------------- */ 870 : /* linspace function with auto resize */ 871 : macro linspace(vec,xmin,xmax,n){ 872 # 873 # vec.resize(n); 874 # if(n>1){ 875 # real dx = (xmax - xmin)/(n - 1.); 876 # vec[0] = xmin; 877 # for(int i=1; i errtol){ 936 # 937 # niter = niter++; 938 # matrix jac; 939 # jac = Jacob(VhB,VhB,tgv=-1,solver=sparsesolver); 940 # df1[] = jac^-1 * res1[]; 941 # df1[] = -df1[]; 942 # normdf = df1[].l2; 943 # 944 # /* if norm is too large, scale it */ 945 # if(normdf > dfnormlim){ 946 # df1[] = df1[] *(1/normdf); 947 # df1[] = df1[] * dfnormlim; 948 # normdf = df1[].l2; 949 # } 950 # f1[] += df1[]; 951 # 952 # res1[] = Resid(0,VhB,tgv=-1); 953 # l2err = res1[].l2; 954 # 955 # } 956 # cout << "Blasius solution converged after " << niter << " iterations, l2 error: " << l2err << endl; 957 # 958 # /* creating a grid to define the spline */ 959 # real[int] ygrid(thLy.nv); 960 # real[int] solU(thLy.nv); 961 # solyUF.resize(3,thLy.nv); 962 # 963 # /* calculate the function on the spline */ 964 # for(int i=0; i> Rey; 243 @ ifile >> Rex0; 244 @ ifile >> Rex1; 245 @ ifile >> Redelta0; 246 @ ifile >> Redelta1; 247 @ ifile >> Reydelta; 248 @ ifile >> Ufs; 249 @ ifile >> nuvar; 250 @ 251 @ } 252 @ broadcast(processor(0), Rey); 253 @ broadcast(processor(0), Rex0); 254 @ broadcast(processor(0), Rex1); 255 @ broadcast(processor(0), Redelta0); 256 @ broadcast(processor(0), Redelta1); 257 @ broadcast(processor(0), Reydelta); 258 @ broadcast(processor(0), Ufs); 259 @ broadcast(processor(0), nuvar); 260 @ 261 @ } 13 : /* PSE run specific input */ 14 : include "../include/PSEinput.idp"/* 2 : 3 : General description of the main combinations to run the PSE solver 4 : #1: prescribed fix grid, first order backward Euler, adaptive damping for stability (DEFAULT): 5 : options: -fixGrid=1, -enableDamping=1, -BDF2=0 6 : #2: prescribed fix grid, first order backward Euler, NO adaptive damping - NOT RECOMMENDED: SMALL STEPS CAN UNSTABLE MARCHING DUE TO THE ILL-POSEDNESS - one should be careful, only recommanded in high Re limit (Redelta > 800-1000) 7 : options: -fixGrid=1, -enableDamping=0, -BDF2=0 8 : #3: prescribed fix grid, second order backward Euler, NO adaptive damping - NOT RECOMMENDED: SMALL STEPS CAN UNSTABLE MARCHING DUE TO THE ILL-POSEDNESS - one should be careful, only recommanded in high Re limit (Redelta > 800-1000), lower step-size restriction than that of the first order 9 : options: -fixGrid=1, -enableDamping=0, -BDF2=1 10 : #4: prescribed fix grid, second order backward Euler, adaptive damping - NOT RECOMMENDED: DAMPING FORMULA IS UNKNOWN FOR THE SECOND ORDER SCHEME 11 : options: -fixGrid=1, -enableDamping=1, -BDF2=1 12 : #5: adaptive grid, first order backward Euler, NO damping - RECOMMENDED: seems to work, also robust; however, this does not follow the BL length scale, i.e., might not that effective 13 : options: -fixGrid=0, -enableDamping=0, -BDF2=0 14 : #6: adaptive grid, first order backward Euler, NO damping - NOT RECOMMENDED: STEP-SIZE LIMIT FORMULA IS UNKNOWN FOR THE SECOND ORDER SCHEME 15 : options: -fixGrid=0, -enableDamping=0, -BDF2=1 16 : 17 : IMPORTANT OPTION: 18 : -prestep: if 1, initially small steps are used 19 : in the case of fixgrid=1, the first step is divided into a few smaller, undamped steps, first order steps. 20 : The first step which appears in the PSE ouput is the last step of the presteps; however, this 21 : should not affect the final output. 22 : in the case of fixgrid=0, 'nPreStep' number of steps are taken with a reduced tolerance 23 : 'adaptiveprestepSF'; then the original tolerance 'adaptivestepSF' is used 24 : REMARK: default values of 'adaptiveprestepSF' and 'adaptivestepSF' are close 25 : 26 : 27 : #additional options: see in code 28 : 29 : TODO: adaptive step - adaptive safety factor - accounting for the BL scale, or monitoring dalpha/dx? 30 : TODO: MORE DOCUMENTATION 31 : TODO: DERIVING THE SECOND ORDER STEPSIZE LIMIT/DAMPING FACTOR FORMULA 32 : Note: for derivation, useful papers are 33 : Li, Malik, 1997: Spectral analysis of parabolized stability equations; see the formula after Eq. 48, 34 : Andersson et al, 1998: On a Stabilization Procedure for the Parabolic Stability Equations 35 : TODO: PRESSURE GRADIENT REMOVAL BASED STABILIZATION VIA A MACRO & new stepsize limit calculation for this 36 : literature on this: Li, Malik 1996: On the nature of PSE approximation, Eq. 33-34 37 : 38 : */ 39 : 40 : /* the zeroth "step" is the IC */ 41 : nX = nX + 1; 42 : 43 : /* ------------- BRE param & variables ------------- */ 44 : /* import x grid from BRE solution */ 45 : importVec(XgridBRE,"BRE",iname + "_Xgrid") 93 @ 94 @ 95 @ 96 @ 97 @ 98 @ 99 @ 100 @ 101 @ 102 @ 103 @ 104 @ 105 @ 106 @ 107 @ 108 @ 109 @ 110 @ { 93 @ 94 @ int dummyN; 95 @ 96 @ if(mpirank==0){ 97 @ string ifname; 98 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_Xgrid" + ".dat"; 99 @ ifstream ifile(ifname); 100 @ ifile >> dummyN; 101 @ XgridBRE.resize(dummyN); 102 @ ifile >> XgridBRE; 103 @ } 104 @ broadcast(processor(0), dummyN); 105 @ if(mpirank!=0){ 106 @ XgridBRE.resize(dummyN); 107 @ } 108 @ broadcast(processor(0), XgridBRE); 109 @ 110 @ } 46 : scaleXBRE2Blas(XgridBRE,Rey) 643 @ 644 @ 645 @ 646 @ { 643 @ 644 @ XgridBRE *= sqrt(Rey); 645 @ 646 @ } 47 : 48 : /* index for tracking the BRE solution for I/O */ 49 : int indBRE = 0, indBREprev = -1; 50 : 51 : /* ------------- BiGlobal param & variables - IC ------------- */ 52 : /* input file name FOR THE BiGlobal stability input */ 53 : string inameBiG = getARGV("-inameBiG", "r1"); 54 : real omega; 55 : real[int] Fvec; 56 : importVec(Fvec,"BiGlob",inameBiG + "_Fvec") 93 @ 94 @ 95 @ 96 @ 97 @ 98 @ 99 @ 100 @ 101 @ 102 @ 103 @ 104 @ 105 @ 106 @ 107 @ 108 @ 109 @ 110 @ { 93 @ 94 @ int dummyN; 95 @ 96 @ if(mpirank==0){ 97 @ string ifname; 98 @ ifname = workDir + "/" + basemeshname + "_" + "BiGlob" + "_" + inameBiG + "_Fvec" + ".dat"; 99 @ ifstream ifile(ifname); 100 @ ifile >> dummyN; 101 @ Fvec.resize(dummyN); 102 @ ifile >> Fvec; 103 @ } 104 @ broadcast(processor(0), dummyN); 105 @ if(mpirank!=0){ 106 @ Fvec.resize(dummyN); 107 @ } 108 @ broadcast(processor(0), Fvec); 109 @ 110 @ } 57 : int nF = Fvec.n; 58 : 59 : importVec(XgridBiGlob,"BiGlob",inameBiG + "_Xgrid") 93 @ 94 @ 95 @ 96 @ 97 @ 98 @ 99 @ 100 @ 101 @ 102 @ 103 @ 104 @ 105 @ 106 @ 107 @ 108 @ 109 @ 110 @ { 93 @ 94 @ int dummyN; 95 @ 96 @ if(mpirank==0){ 97 @ string ifname; 98 @ ifname = workDir + "/" + basemeshname + "_" + "BiGlob" + "_" + inameBiG + "_Xgrid" + ".dat"; 99 @ ifstream ifile(ifname); 100 @ ifile >> dummyN; 101 @ XgridBiGlob.resize(dummyN); 102 @ ifile >> XgridBiGlob; 103 @ } 104 @ broadcast(processor(0), dummyN); 105 @ if(mpirank!=0){ 106 @ XgridBiGlob.resize(dummyN); 107 @ } 108 @ broadcast(processor(0), XgridBiGlob); 109 @ 110 @ } 60 : 61 : complex[int,int] alpha0mat(1,1); 62 : importMat(alpha0mat,"BiGlob",inameBiG + "_leadingEvalvec") 131 @ 132 @ 133 @ 134 @ 135 @ 136 @ 137 @ 138 @ 139 @ 140 @ 141 @ 142 @ 143 @ 144 @ 145 @ 146 @ 147 @ 148 @ 149 @ 150 @ 151 @ { 131 @ 132 @ int matn,matm; 133 @ 134 @ if(mpirank==0){ 135 @ string ifname; 136 @ ifname = workDir + "/" + basemeshname + "_" + "BiGlob" + "_" + inameBiG + "_leadingEvalvec" + ".dat"; 137 @ ifstream ifile(ifname); 138 @ ifile >> matn; 139 @ ifile >> matm; 140 @ alpha0mat.resize(matn,matm); 141 @ ifile >> alpha0mat; 142 @ } 143 @ broadcast(processor(0), matn); 144 @ broadcast(processor(0), matm); 145 @ mpiBarrier(mpiCommWorld); 146 @ if(mpirank!=0){ 147 @ alpha0mat.resize(matn,matm); 148 @ } 149 @ broadcast(processor(0), alpha0mat); 150 @ 151 @ } 63 : /* ------------- PSE param & variables ------------- */ 64 : 65 : complex alpha, alphaprev, alphaprevprev; 66 : complex[int,int] alphamat(1,1); 67 : complex[int] alphavec; 68 : real nudelta = 1. / Reydelta; 69 : 70 : /* MAIN OPTION: 0 if adaptive step is used; 1 if fix grid is used */ 71 : bool fixGrid = (getARGV("-fixGrid", 1)==1); 72 : 73 : /* ADAPTIVE OPTION: safety factor which account for the variation of alpha */ 74 : real adaptivestepSF = getARGV("-adaptivestepSF", 1.1); 75 : /* adaptive stepping factor: dX = adaptiveStepFactor/real(alpha) 76 : different for first/second order stepping: larger steps are favored */ 77 : real adaptiveStepFactor = getARGV("-adaptiveStepFactor", (BDF2 ? 1.1 : 1.6)); 78 : 79 : /* FIXGRID OPTION: whether 's' damping is used: 1 - adaptive damping; otherwise 0 - standard stabilization method */ 80 : //int dampingpar = getARGV("-dampingpar",1); 81 : bool enableDamping = (getARGV("-enableDamping",0)==1); 82 : bool noDpdx = (getARGV("-noDpdx",0)==1); 83 : if(!enableDamping & !noDpdx & false){ /* TODO */ 84 : enableDamping = true; 85 : if(mpirank==0) cout << "no stabilization technique is specified - damping ... : is enabled " << endl; 86 : } 87 : 88 : real dxLowerBound = getARGV("-dxLowerBound", 0.1); 89 : 90 : /* FIXGRID OPTION: safety factor for dX whether stabilization is required or not - different for first & second order stepping */ 91 : real dxSafetyFactor = getARGV("-dxSafetyFactor", (BDF2 ? 1.05 : 1.01)); 92 : 93 : /* FIXGRID OPTION: safety factor for the adaptive damping */ 94 : real dampingSafetyFactor = getARGV("-dampingSafetyFactor", 1.1); 95 : 96 : /* s damping factor */ 97 : real spar; 98 : bool fixGridStabilizationFlag; 99 : 100 : /* taking a few non-damped small steps to avoid divergence of the eigenvalue by large inital steps */ 101 : bool preStep = (getARGV("-preStep", 1)==1); 102 : /* aux bool, not to switch off damping if prestep is requested, and damping is also requested */ 103 : bool enableDampingPostPrestep = (preStep & enableDamping) ? true : false; 104 : /* PreStep stepsize calculation flag: 105 : (0) either based on the value of prescribed damping in "sParPreStep", or by 106 : (1) PreStepdxRatio*1/real(alpha0), PreStepdxRatio<1, alpha0 is the value from BiGlobal stability calculation 107 : the latter is the new default */ 108 : int preStepdxCalcMethod = getARGV("-preStepdxCalcMethod", 1); 109 : real PreStepdxRatio = getARGV("-PreStepdxRatio",0.75); 110 : /* s damping during prestepping: if >0, uses damping only for presteping, otherwise it is turned off; if negative, no damping for prestepping */ 111 : /* important: this damping is only used to roughly determine the step size - the actual theoretical damping is smaller usually, but the 'dampingSafetyFactor' safety factor increases it */ 112 : real sParPreStep = getARGV("-sParPreStep", 2.); // first try was 5. 113 : // // /* prestep option - minimum dX size */ 114 : real dxLowerBoundPreStep = getARGV("-dxLowerBoundPreStep", 2); 115 : /* number of presteps - IMPORTANT - this is used by both the fix-grid and adaptive grid solvers */ 116 : int nPreStep = getARGV("-nPreStep", 3); /* previously: 4 */ 117 : /* bool variable for handling prestepping */ 118 : bool justExitPreStep=false; 119 : bool inPreStepFlag = false; 120 : 121 : /* relative and absolute step when solving for alpha */ 122 : bool secantIterationAlpha = (getARGV("-secantIterationAlpha", 0)==1); 123 : real relstepalpha = getARGV("-relstepalpha", 0.05); /* original 0.01 - was incorrect; next try - kind of OK except for a few steps 0.1 */ 124 : real absstepalpha = getARGV("-absstepalpha", 0.0125);/* original 0.01; next try - kind of OK except for a few steps 0.025 */ 125 : 126 : /* first-step controlling: from a BiGlobal solution, in the case of the first few steps, the tolerance is relaxed */ 127 : int initcorrenabled = getARGV("-initcorrenabled", 1); 128 : real initcorrreltol = getARGV("-initcorrreltol", 0.1); /* original 1D: 0.2 */ 129 : real initcorrweight = getARGV("-initcorrweight", 0.1); /* original 1D: 0.2 */ 130 : int initcorrind = getARGV("-initcorrind", 4); 131 : 132 : /* maximum number of iterations for alpha */ 133 : int maxiter = getARGV("-maxiter",10); // original 1D: 50 134 : 135 : /* tolerance of the integral criterion separating the growth */ 136 : real intnormtol = getARGV("-intnormtol",1e-7); // original 1D: 1e-8; try0: 1e-6; try1: 1e-8; try2 1e-7 137 : 138 : /* tolerance for alpha step during the iteration */ 139 : real dalphatol = getARGV("-dalphatol", 1e-9); // original 1D:1e-12; try0: 1e-10; try1: 1e-11; try2 1e-9 (Paredes 2014 has 1e-8) 140 : 141 : if(!fixGrid & !enableDamping & !noDpdx){ 142 : if(mpirank==0) cout << "################################################# ... : ########################################" << endl; 143 : if(mpirank==0) cout << "WARNING: Adaptive grid and no stabilization is no ... : t allowed - turning on damping " << endl; 144 : if(mpirank==0) cout << "################################################# ... : ########################################" << endl; 145 : enableDamping = true; 146 : } 147 : 148 : /* nondim the variables */ 149 : real delta0 = nuvar/Ufs*sqrt(Rey); 150 : x1 /= delta0; 151 : 152 : /* eigenvector norm type - for the initial condition */ 153 : /* 0: max(u)=1 */ 154 : /* 1: unit perturbation energy */ 155 : int normType = getARGV("-normType", 0); 156 : 157 : /* measures of growth rate: different methods */ 158 : int growthEnergy = getARGV("-growthEnergy", 1); 159 : int growthU = getARGV("-growthU", 0); 160 : int growthV = getARGV("-growthV", 0); 161 : complex[int] energyvec(1); 162 : 163 : complex[int,int] growthmat(1,growthEnergy + growthU + growthV); 164 : IFMACRO(GROWTHDEBUG) 165 & real[int,int] growthmatDEBUGu(1,2); 166 & real[int,int] growthmatDEBUGv(1,2); 167 & ENDIFMACRO 168 : //complex prevEnergy,prevprevEnergy; 169 : /* variable for saving maximum location for a good initial guess when extracting the growth at a maximum variable location */ 170 : real[int] growthUZY(2); 171 : real[int] growthVZY(2); 172 : growthUZY = [0,2.]; /* initial guess */ 173 : growthVZY = [0,2.]; /* initial guess */ 174 : 175 : /* if a single FIX grid is used for all F values, set up the grid */ 176 : if(fixGrid==1){ 177 : if(XgridBiGlob.n == 1){ 178 : setupPSEXgrid(0) 818 @ 819 @ 820 @ 821 @ 822 @ 823 @ 824 @ 825 @ /* nondim with x0 - BRE scale */ 826 @ 827 @ /* for a single x0 grid */ 828 @ 829 @ 830 @ /* for an x0(F) grid, roughly the same stepsize - TODO TEST*/ 831 @ 832 @ 833 @ 834 @ 835 @ 836 @ 837 @ 838 @ 839 @ 840 @ 841 @ 842 @ 843 @ 844 @ 845 @ 846 @ 847 @ 848 @ 849 @ 850 @ 851 @ 852 @ 853 @ 854 @ 818 @ 819 @ if(Fvec.n==XgridBiGlob.n){ 820 @ x0 = XgridBiGlob[0]; 821 @ } else { 822 @ x0 = XgridBiGlob[0]; 823 @ } 824 @ if(fixGrid){ 825 @ /* nondim with x0 - BRE scale */ 826 @ if(0==0){ 827 @ /* for a single x0 grid */ 828 @ setupXgrid(XgridPSE,x0,x1,nX) 859 @ 860 @ 861 @ 862 @ 863 @ 864 @ 865 @ 866 @ 867 @ 859 @ 860 @ if(dxtype==1){ 861 @ linspace(XgridPSE,sqrt(x0),sqrt(x1),nX) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ XgridPSE.resize(nX); 874 @ if(nX>1){ 875 @ real dx = (sqrt(x1) - sqrt(x0))/(nX - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = sqrt(x0); 877 @ for(int i=1; i1){ 875 @ real dx = (x1 - x0)/(nX - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = x0; 877 @ for(int i=1; i1){ 875 @ real dx = (sqrt(x1) - sqrt(x0))/(nXlocal - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = sqrt(x0); 877 @ for(int i=1; i1){ 875 @ real dx = (x1 - x0)/(nXlocal - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = x0; 877 @ for(int i=1; i 1) { 460 @ ifstream khi( workDir + "/" + basemeshname + "_" + mpiRank(thComm mpiCommWorld ) + "_" + mpiSize(thComm mpiCommWorld ) + ".khi"); 461 @ int m; 462 @ khi >> m; 463 @ assert(m == 2); 464 @ khi >> privateDmeshthkhi privateDmeshthkhiDef [0]; 465 @ khi >> privateDmeshthkhi privateDmeshthkhiDef [1]; 466 @ khi >> m; 467 @ privateDmeshthintersection privateDmeshthintersectionDef .resize(m); 468 @ for(int j = 0; j < m; ++j) { 469 @ int n; 470 @ khi >> n; 471 @ privateDmeshthintersection privateDmeshthintersectionDef [j].resize(n); 472 @ for[i, v : privateDmeshthintersection privateDmeshthintersectionDef [j]] 473 @ khi >> v; 474 @ } 475 @ IFMACRO(thN2O) 476 & n2oth.resize(th.nt); 477 & khi >> n2oth; 478 & ENDIFMACRO 476 @ n2oth.resize(th.nt); 477 @ khi >> n2oth; 478 @ 479 @ } 480 @ else { 481 @ privateDmeshthkhi privateDmeshthkhiDef [0] = 1.0; 482 @ privateDmeshthkhi privateDmeshthkhiDef [1] = 1.0; 483 @ } 484 @ } 485 @ 29 @ if(mpirank==0){ 30 @ thGlobal = readmesh(workDir + "/" + basemeshname + "_th0.mesh"); 31 @ thLx = readmeshL(workDir + "/" + basemeshname + "_thLx.mesh"); 32 @ thLy = readmeshL(workDir + "/" + basemeshname + "_thLy.mesh"); 33 @ } 34 @ broadcast(processor(0),thGlobal); 35 @ broadcast(processor(0),thLx); 36 @ broadcast(processor(0),thLy); 37 @ 38 @ if(mpirank==0){ 39 @ cout << "meshes loaded successfully " << endl; 40 @ } 41 @ 42 @ 18 : 19 : /* creating the distributed matrix for parallel solution */ 20 : defcreateMat 303 @ 304 @ 305 @ 306 @ 307 @ 308 @ { 303 @ 304 @ NewMacro def(i)gendef(i) EndMacro ) 305 @ NewMacro init(i)geninit(i) EndMacro ) 306 @ createMat(th, dJ, Pk) 651 @ 652 @ 653 @ 654 @ 655 @ /* three-dimensional problem */ 656 @ /* three-dimensional integral */ 657 @ 658 @ 659 @ /* three-dimensional surface problem */ 660 @ /* two-dimensional integral */ 661 @ 662 @ 663 @ /* three-dimensional line problem */ 664 @ /* one-dimensional integral */ 665 @ 666 @ 667 @ /* two-dimensional problem */ 668 @ /* two-dimensional integral */ 669 @ 670 @ 671 @ 672 @ 673 @ 674 @ 675 @ 676 @ 677 @ 678 @ 679 @ 680 @ 681 @ 682 @ 683 @ 684 @ 685 @ 686 @ 687 @ 688 @ 689 @ 690 @ 691 @ 692 @ 693 @ 694 @ 695 @ 696 @ 697 @ 698 @ 699 @ 700 @ 701 @ 702 @ 703 @ 704 @ 705 @ 706 @ 707 @ 708 @ 709 @ 710 @ 711 @ 712 @ 713 @ 714 @ 715 @ 716 @ 717 @ 718 @ 719 @ 720 @ 721 @ 722 @ 723 @ 724 @ 725 @ 726 @ 727 @ 728 @ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ /* three-dimensional problem */ 740 @ /* three-dimensional integral */ 741 @ 742 @ 743 @ /* three-dimensional surface problem */ 744 @ /* two-dimensional integral */ 745 @ 746 @ 747 @ /* three-dimensional line problem */ 748 @ /* one-dimensional integral */ 749 @ 750 @ 751 @ /* two-dimensional problem */ 752 @ /* two-dimensional integral */ 753 @ 754 @ 755 @ 756 @ 757 @ 758 @ 759 @ 651 @ IFMACRO(privateDmeshth) 652 & { 653 & IFMACRO(!meshN) 654 & IFMACRO(dimension,3) 655 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 656 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 657 & ENDIFMACRO IFMACRO(dimension,3S) 658 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 659 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 660 & ENDIFMACRO IFMACRO(dimension,3L) 661 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 662 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 663 & ENDIFMACRO IFMACRO(!meshN) 664 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 665 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 666 & ENDIFMACRO ENDIFMACRO IFMACRO(!thComm) 667 & NewMacro thComm()mpiCommWorld EndMacro ENDIFMACRO IFMACRO(!privateCreateMatCheckDmesh) 668 & if(th.nv != privateDmeshthkhiDef[0].n || (privateDmeshthkhiDef[1].n && th.nt != privateDmeshthkhiDef[1].n)) { 669 & buildDmesh(th) 670 & } 671 & ENDIFMACRO NewMacro privateCreateMat()1 EndMacro int[int][int] intersection; 672 & real[int][int] DTab(1); 673 & meshN[int] ThTab(1); 674 & ThTab[0] = th; 675 & NewMacro privateDmeshThTab()privateDmeshth EndMacro NewMacro privateDmeshThTabkhi()privateDmeshthkhiDef EndMacro NewMacro privateDmeshThTabintersection()privateDmeshthintersectionDef EndMacro IFMACRO(!def) 676 & NewMacro def(i)i EndMacro ENDIFMACRO IFMACRO(!init) 677 & NewMacro init(i)i EndMacro ENDIFMACRO if(mpiSize(thComm) > 1) { 678 & IFMACRO(thN2O) 679 & IFMACRO(thOriginal) 680 & IFMACRO(thRestriction) 681 & NewMacro privateDmeshN2O()n2oth EndMacro NewMacro privateDmeshOriginal()thOriginal EndMacro NewMacro privateDmeshRestriction()thRestriction EndMacro ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(!thPkPart) 682 & NewMacro thPkPart() Pk EndMacro ENDIFMACRO IFMACRO(thCartesianPartitioning) 683 & NewMacro privateDmeshCartesianPartitioning() EndMacro ENDIFMACRO partitionPrivate(ThTab, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, mpiRank(thComm), mpiSize(thComm), 1, 1, 1, privateCreateMat, DTab, Pk, intersection, thComm, -111111, thPkPart, def, init, 1) 684 & } 685 & else { 686 & fespace WhGlobalPrivate(th, Pk); 687 & DTab[0].resize(WhGlobalPrivate.ndof); 688 & DTab[0] = 1; 689 & intersection.resize(0); 690 & IFMACRO(thN2O) 691 & IFMACRO(thOriginal) 692 & IFMACRO(thRestriction) 693 & thRestriction.resize(WhGlobalPrivate.ndof); 694 & thRestriction = 0:WhGlobalPrivate.ndof - 1; 695 & ENDIFMACRO ENDIFMACRO ENDIFMACRO } 696 & IFMACRO(!privateCreatePartition) 697 & constructor( dJ, DTab[0].n, intersection, DTab[0], communicator = thComm); 698 & ENDIFMACRO IFMACRO(privateCreatePartition) 699 & privateCreatePartition.resize(DTab[0].n); 700 & privateCreatePartition = DTab[0]; 701 & ENDIFMACRO } 702 & ENDIFMACRO 652 @ { 653 @ IFMACRO(!meshN) 654 & IFMACRO(dimension,3) 655 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 656 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 657 & ENDIFMACRO IFMACRO(dimension,3S) 658 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 659 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 660 & ENDIFMACRO IFMACRO(dimension,3L) 661 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 662 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 663 & ENDIFMACRO IFMACRO(!meshN) 664 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 665 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 666 & ENDIFMACRO ENDIFMACRO 667 @ IFMACRO(!thComm) 668 & NewMacro thComm()mpiCommWorld EndMacro ENDIFMACRO 668 @ NewMacro thComm()mpiCommWorld EndMacro 669 @ 669 @ IFMACRO(!privateCreateMatCheckDmesh) 670 & if(th.nv != privateDmeshthkhiDef[0].n || (privateDmeshthkhiDef[1].n && th.nt != privateDmeshthkhiDef[1].n)) { 671 & buildDmesh(th) 672 & } 673 & ENDIFMACRO 670 @ if(th.nv != privateDmeshthkhiDef[0].n || (privateDmeshthkhiDef[1].n && th.nt != privateDmeshthkhiDef[1].n)) { 671 @ buildDmesh(th) 483 @ 484 @ 485 @ 486 @ 487 @ 488 @ 489 @ 490 @ 491 @ 492 @ 493 @ /* three-dimensional problem */ 494 @ /* three-dimensional integral */ 495 @ 496 @ 497 @ /* three-dimensional surface problem */ 498 @ /* two-dimensional integral */ 499 @ 500 @ 501 @ /* three-dimensional line problem */ 502 @ /* one-dimensional integral */ 503 @ 504 @ 505 @ /* two-dimensional problem */ 506 @ /* two-dimensional integral */ 507 @ 508 @ 509 @ 510 @ 511 @ 512 @ 513 @ 514 @ 515 @ 516 @ 517 @ 518 @ 519 @ 520 @ 521 @ 522 @ 523 @ 524 @ 525 @ 526 @ 527 @ 528 @ 529 @ 530 @ 531 @ 532 @ 533 @ 534 @ 535 @ 483 @ IFMACRO(!privateDmeshth) 484 & NewMacro privateDmeshth()privateDmeshth EndMacro NewMacro privateDmeshthkhiDef()privateDmeshthkhiDef EndMacro NewMacro privateDmeshthintersectionDef()privateDmeshthintersectionDef EndMacro real[int][int] privateDmeshthkhiDef(2); 485 & real[int][int] privateDmeshthintersectionDef; 486 & ENDIFMACRO 487 @ { 488 @ IFMACRO(!meshN) 489 & IFMACRO(dimension,3) 490 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 491 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 492 & ENDIFMACRO IFMACRO(dimension,3S) 493 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 494 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 495 & ENDIFMACRO IFMACRO(dimension,3L) 496 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 497 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 498 & ENDIFMACRO IFMACRO(!meshN) 499 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 500 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 501 & ENDIFMACRO ENDIFMACRO 502 @ IFMACRO(!thComm) 503 & NewMacro mpiCommWorld()mpiCommWorld EndMacro ENDIFMACRO 504 @ NewMacro privateBuildDmesh()1 EndMacro 505 @ int[int][int] intersection; 506 @ NewMacro privateDmeshThTab()privateDmeshth EndMacro 507 @ NewMacro privateDmeshThTabkhi()privateDmeshthkhiDef EndMacro 508 @ NewMacro privateDmeshThTabintersection()privateDmeshthintersectionDef EndMacro 509 @ IFMACRO(thN2O) 510 & NewMacro privateDmeshN2O()n2oth EndMacro ENDIFMACRO 510 @ NewMacro privateDmeshN2O()n2oth EndMacro 511 @ 511 @ IFMACRO(thUserPartitioning) 512 & buildWithPartitioning(th, thUserPartitioning, 1, intersection, privateDmeshthkhiDef[0], P1, mpiCommWorld); 513 & ENDIFMACRO 514 @ IFMACRO(thPeriodicity) 515 & buildPeriodic(th, 1, intersection, privateDmeshthkhiDef[0], P1, mpiCommWorld, labPeriodic); 516 & ENDIFMACRO 515 @ buildPeriodic(th, 1, intersection, privateDmeshthkhiDef[0], P1, mpiCommWorld, labPeriodic) 1049 @ 1050 @ 1051 @ 1052 @ 1053 @ 1054 @ 1055 @ 1056 @ { 1049 @ int[int] emptyArray(0); 1050 @ real[int] emptyRealArray(0); 1051 @ meshNmesh ThBorder; 1052 @ int fakeInterface = -111111; 1053 @ int overlap = 1; 1054 @ bool excluded = false; 1055 @ buildOverlapEdgePeriodic(th, ThBorder, fakeInterface, 1, overlap, intersection, privateDmeshthkhiDef[0], P1, mpiCommWorld, excluded, P1, def, init, labPeriodic, emptyRealArray, 1) 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ { 873 @ meshNmesh[int] ThTab(1); 874 @ meshNmesh[int] ThBorderTab(1); 875 @ real[int][int] DTab(1); 876 @ ThTab[0] = th; 877 @ matrix[int] prolongation(0); 878 @ buildOverlapEdgePeriodicRecursive(ThTab, ThBorderTab, fakeInterface, 1, overlap, 1, prolongation, intersection, DTab, P1, mpiCommWorld, excluded, P1, def, init, labPeriodic, emptyRealArray, 1) 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ 748 @ 749 @ 750 @ 751 @ 752 @ 753 @ 754 @ 755 @ 756 @ 757 @ 758 @ 759 @ 760 @ 761 @ 762 @ 763 @ 764 @ 765 @ 766 @ 767 @ 768 @ 769 @ 770 @ 771 @ 772 @ 773 @ 774 @ 775 @ 776 @ 777 @ 778 @ 779 @ 780 @ 781 @ 782 @ 783 @ 784 @ 785 @ 786 @ 787 @ 788 @ 789 @ 790 @ 791 @ 792 @ 793 @ 794 @ 795 @ 796 @ 797 @ 798 @ 799 @ 800 @ 801 @ 802 @ 803 @ 804 @ 805 @ 806 @ 807 @ 808 @ 809 @ 810 @ 811 @ 812 @ 813 @ 814 @ 815 @ 816 @ 817 @ 818 @ 819 @ 820 @ 821 @ 822 @ 823 @ 824 @ 825 @ 826 @ 827 @ 828 @ 829 @ 830 @ 831 @ 832 @ 833 @ 834 @ 835 @ 836 @ 837 @ 838 @ 839 @ 840 @ 841 @ 842 @ 843 @ 844 @ 845 @ 846 @ 847 @ 848 @ 849 @ 850 @ 851 @ 852 @ 853 @ 854 @ 855 @ 856 @ 857 @ 858 @ 859 @ 860 @ 861 @ 862 @ 863 @ 864 @ 865 @ 866 @ 867 @ 868 @ 869 @ 870 @ 871 @ 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ 885 @ 886 @ 887 @ 888 @ 889 @ 890 @ 891 @ 892 @ 893 @ { 731 @ IFMACRO(!def) 732 & NewMacro def(i)i EndMacro ENDIFMACRO 733 @ IFMACRO(!init) 734 & NewMacro init(i)i EndMacro ENDIFMACRO 735 @ ThTab.resize( 1); 736 @ ThBorderTab.resize( 1); 737 @ prolongation.resize( 1 - 1); 738 @ real timerPartition = mpiWtime(); 739 @ if(mpiSize( mpiCommWorld) > 1 && ! excluded) { 740 @ meshNmesh ThGlobal = ThTab[ 1 - 1]; 741 @ fespace PhGlobalPrivate(ThGlobal, P0); 742 @ fespace VhGlobalPrivate(ThGlobal, P1); 743 @ PhGlobalPrivate partGlobal; 744 @ IFMACRO(!privateReconstructDmesh) 745 & IFMACRO(privateDmeshCartesianPartitioning) 746 & { 747 & real[int] bb(2 * dimension); 748 & boundingbox(ThGlobal, bb); 749 & PhGlobalPrivate xx = x / (bb[1] - bb[0]), yy = y / (bb[3] - bb[2]) 750 & IFMACRO(dimension,2) 751 & ; 752 & int i = int(sqrt(mpiSize( mpiCommWorld))); 753 & while(mpiSize( mpiCommWorld) % i != 0) 754 & --i; 755 & int j = mpiSize( mpiCommWorld) / i; 756 & partGlobal = int(j * xx) + int(i * yy) * j; 757 & ENDIFMACRO IFMACRO(dimension,3) 758 & , zz = z / (bb[5] - bb[4]); 759 & i = int(mpiSize( mpiCommWorld)^(0.333333333333333)); 760 & while(mpiSize( mpiCommWorld) % i != 0) 761 & --i; 762 & real p = mpiSize( mpiCommWorld) / i; 763 & j = int(sqrt(p)); 764 & while(p % j != 0) 765 & --j; 766 & real k = int(p / j); 767 & partGlobal = int(i * zz) * k * j + int(j * yy) * k + int(k * xx); 768 & ENDIFMACRO } 769 & ENDIFMACRO IFMACRO(!privateDmeshCartesianPartitioning) 770 & if( emptyRealArray.n != PhGlobalPrivate.ndof || labPeriodic.n > 0) { 771 & timerPartition = mpiWtime(); 772 & meshN ThGlobalPeriodic; 773 & if( labPeriodic.n > 0) { 774 & VhGlobalPrivate marker; 775 & for(int i = 0; i < labPeriodic.n; ++i) { 776 & varf vMarker(u, v) = on( labPeriodic[i], u = 1.0); 777 & marker[] += vMarker(0, VhGlobalPrivate, tgv = -1); 778 & } 779 & PhGlobalPrivate partPeriodic = marker > 0.1; 780 & while(1) { 781 & AddLayers(ThGlobal, partPeriodic[], 1 + overlap, marker[]); 782 & partPeriodic = marker > 0.001; 783 & ThGlobalPeriodic = trunc(ThGlobal, partPeriodic < 0.999); 784 & if(ThGlobal.nt / real(ThGlobalPeriodic.nt) > mpisize / real(mpisize - 1)) 785 & break; 786 & } 787 & } 788 & if(mpiRank( mpiCommWorld) == 0) { 789 & if(verbosity > 0) 790 & cout.scientific << " --- global mesh of " << ThGlobal.nt << " elements (prior to refinement) partitioned with " << Stringification(partitioner); 791 & if( labPeriodic.n > 0) { 792 & fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 793 & PhPeriodicPrivate partPeriodic; 794 & if(mpiSize( mpiCommWorld) > 2) { 795 & partitionerSeq(partPeriodic[], ThGlobalPeriodic, mpiSize( mpiCommWorld) - 1); 796 & partPeriodic[] += 1.0; 797 & } 798 & else partPeriodic[] = 1.0; 799 & partGlobal = partPeriodic; 800 & } 801 & else { 802 & partitionerSeq(partGlobal[], ThGlobal, mpiSize( mpiCommWorld)); 803 & } 804 & } 805 & if( labPeriodic.n > 0 && Stringification(partitioner) != "metis" && Stringification(partitioner) != "scotch") { 806 & fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 807 & PhPeriodicPrivate partPeriodic; 808 & if(mpiSize( mpiCommWorld) > 2) { 809 & partitionerPar(partPeriodic[], ThGlobalPeriodic, mpiCommWorld, mpiSize( mpiCommWorld) - 1); 810 & partPeriodic[] += 1.0; 811 & } 812 & else partPeriodic[] = 1.0; 813 & partGlobal = partPeriodic; 814 & } 815 & else partitionerPar(partGlobal[], ThGlobal, mpiCommWorld, mpiSize( mpiCommWorld)); 816 & if(mpiRank( mpiCommWorld) == 0 && verbosity > 0) 817 & cout.scientific << " (in " << mpiWtime() - timerPartition << ")" << endl; 818 & timerPartition = mpiWtime(); 819 & } 820 & else { 821 & partGlobal[] = emptyRealArray; 822 & } 823 & ENDIFMACRO ENDIFMACRO 745 @ IFMACRO(privateDmeshCartesianPartitioning) 746 & { 747 & real[int] bb(2 * dimension); 748 & boundingbox(ThGlobal, bb); 749 & PhGlobalPrivate xx = x / (bb[1] - bb[0]), yy = y / (bb[3] - bb[2]) 750 & IFMACRO(dimension,2) 751 & ; 752 & int i = int(sqrt(mpiSize( mpiCommWorld))); 753 & while(mpiSize( mpiCommWorld) % i != 0) 754 & --i; 755 & int j = mpiSize( mpiCommWorld) / i; 756 & partGlobal = int(j * xx) + int(i * yy) * j; 757 & ENDIFMACRO IFMACRO(dimension,3) 758 & , zz = z / (bb[5] - bb[4]); 759 & i = int(mpiSize( mpiCommWorld)^(0.333333333333333)); 760 & while(mpiSize( mpiCommWorld) % i != 0) 761 & --i; 762 & real p = mpiSize( mpiCommWorld) / i; 763 & j = int(sqrt(p)); 764 & while(p % j != 0) 765 & --j; 766 & real k = int(p / j); 767 & partGlobal = int(i * zz) * k * j + int(j * yy) * k + int(k * xx); 768 & ENDIFMACRO } 769 & ENDIFMACRO 770 @ IFMACRO(!privateDmeshCartesianPartitioning) 771 & if( emptyRealArray.n != PhGlobalPrivate.ndof || labPeriodic.n > 0) { 772 & timerPartition = mpiWtime(); 773 & meshN ThGlobalPeriodic; 774 & if( labPeriodic.n > 0) { 775 & VhGlobalPrivate marker; 776 & for(int i = 0; i < labPeriodic.n; ++i) { 777 & varf vMarker(u, v) = on( labPeriodic[i], u = 1.0); 778 & marker[] += vMarker(0, VhGlobalPrivate, tgv = -1); 779 & } 780 & PhGlobalPrivate partPeriodic = marker > 0.1; 781 & while(1) { 782 & AddLayers(ThGlobal, partPeriodic[], 1 + overlap, marker[]); 783 & partPeriodic = marker > 0.001; 784 & ThGlobalPeriodic = trunc(ThGlobal, partPeriodic < 0.999); 785 & if(ThGlobal.nt / real(ThGlobalPeriodic.nt) > mpisize / real(mpisize - 1)) 786 & break; 787 & } 788 & } 789 & if(mpiRank( mpiCommWorld) == 0) { 790 & if(verbosity > 0) 791 & cout.scientific << " --- global mesh of " << ThGlobal.nt << " elements (prior to refinement) partitioned with " << Stringification(partitioner); 792 & if( labPeriodic.n > 0) { 793 & fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 794 & PhPeriodicPrivate partPeriodic; 795 & if(mpiSize( mpiCommWorld) > 2) { 796 & partitionerSeq(partPeriodic[], ThGlobalPeriodic, mpiSize( mpiCommWorld) - 1); 797 & partPeriodic[] += 1.0; 798 & } 799 & else partPeriodic[] = 1.0; 800 & partGlobal = partPeriodic; 801 & } 802 & else { 803 & partitionerSeq(partGlobal[], ThGlobal, mpiSize( mpiCommWorld)); 804 & } 805 & } 806 & if( labPeriodic.n > 0 && Stringification(partitioner) != "metis" && Stringification(partitioner) != "scotch") { 807 & fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 808 & PhPeriodicPrivate partPeriodic; 809 & if(mpiSize( mpiCommWorld) > 2) { 810 & partitionerPar(partPeriodic[], ThGlobalPeriodic, mpiCommWorld, mpiSize( mpiCommWorld) - 1); 811 & partPeriodic[] += 1.0; 812 & } 813 & else partPeriodic[] = 1.0; 814 & partGlobal = partPeriodic; 815 & } 816 & else partitionerPar(partGlobal[], ThGlobal, mpiCommWorld, mpiSize( mpiCommWorld)); 817 & if(mpiRank( mpiCommWorld) == 0 && verbosity > 0) 818 & cout.scientific << " (in " << mpiWtime() - timerPartition << ")" << endl; 819 & timerPartition = mpiWtime(); 820 & } 821 & else { 822 & partGlobal[] = emptyRealArray; 823 & } 824 & ENDIFMACRO 771 @ if( emptyRealArray.n != PhGlobalPrivate.ndof || labPeriodic.n > 0) { 772 @ timerPartition = mpiWtime(); 773 @ meshNmesh ThGlobalPeriodic; 774 @ if( labPeriodic.n > 0) { 775 @ VhGlobalPrivate marker; 776 @ for(int i = 0; i < labPeriodic.n; ++i) { 777 @ varf vMarker(u, v) = on( labPeriodic[i], u = 1.0); 778 @ marker[] += vMarker(0, VhGlobalPrivate, tgv = -1); 779 @ } 780 @ PhGlobalPrivate partPeriodic = marker > 0.1; 781 @ while(1) { 782 @ AddLayers(ThGlobal, partPeriodic[], 1 + overlap, marker[]); 783 @ partPeriodic = marker > 0.001; 784 @ ThGlobalPeriodic = trunc(ThGlobal, partPeriodic < 0.999); 785 @ if(ThGlobal.nt / real(ThGlobalPeriodic.nt) > mpisize / real(mpisize - 1)) 786 @ break; 787 @ } 788 @ } 789 @ if(mpiRank( mpiCommWorld) == 0) { 790 @ if(verbosity > 0) 791 @ cout.scientific << " --- global mesh of " << ThGlobal.nt << " elements (prior to refinement) partitioned with ... : " << Stringification((partitionermetismetis)); 792 @ if( labPeriodic.n > 0) { 793 @ fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 794 @ PhPeriodicPrivate partPeriodic; 795 @ if(mpiSize( mpiCommWorld) > 2) { 796 @ partitionerSeq(partPeriodic[], ThGlobalPeriodic, mpiSize( mpiCommWorld) - 1) { if( mpiSize( mpiCommWorld) - 1 <= 1) partPeriodic[] = 0; else metisdual(partPeriodic[], ThGlobalPeriodic, mpiSize( mpiCommWorld) - 1); }; 797 @ partPeriodic[] += 1.0; 798 @ } 799 @ else 800 @ partPeriodic[] = 1.0; 801 @ partGlobal = partPeriodic; 802 @ } 803 @ else { 804 @ partitionerSeq(partGlobal[], ThGlobal, mpiSize( mpiCommWorld)) { if( mpiSize( mpiCommWorld) <= 1) partGlobal[] = 0; else metisdual(partGlobal[], ThGlobal, mpiSize( mpiCommWorld)); }; 805 @ } 806 @ } 807 @ if( labPeriodic.n > 0 && Stringification((partitionermetismetis)) != "metis" && Stringification((partitionermetismetis)) != "scotch") { 808 @ fespace PhPeriodicPrivate(ThGlobalPeriodic, P0); 809 @ PhPeriodicPrivate partPeriodic; 810 @ if(mpiSize( mpiCommWorld) > 2) { 811 @ partitionerPar(partPeriodic[], ThGlobalPeriodic, mpiCommWorld, mpiSize( mpiCommWorld) - 1) broadcast(processor(0, mpiCommWorld), partPeriodic[]); 812 @ partPeriodic[] += 1.0; 813 @ } 814 @ else 815 @ partPeriodic[] = 1.0; 816 @ partGlobal = partPeriodic; 817 @ } 818 @ else 819 @ partitionerPar(partGlobal[], ThGlobal, mpiCommWorld, mpiSize( mpiCommWorld)) broadcast(processor(0, mpiCommWorld), partGlobal[]); 820 @ if(mpiRank( mpiCommWorld) == 0 && verbosity > 0) 821 @ cout.scientific << " (in " << mpiWtime() - timerPartition << ")" << endl; 822 @ timerPartition = mpiWtime(); 823 @ } 824 @ else { 825 @ partGlobal[] = emptyRealArray; 826 @ } 827 @ 825 @ 824 @ IFMACRO(privateReconstructDmesh) 825 & partGlobal[] = emptyRealArray; 826 & ENDIFMACRO 827 @ IFMACRO(!trueRestrict) 828 & bool trueRestrict = usedARGV("-true_restrict") != -1; 829 & ENDIFMACRO 828 @ bool trueRestrict = usedARGV("-true_restrict") != -1; 829 @ 830 @ IFMACRO(!removeZeros) 831 & bool removeZeros = trueRestrict && overlap == 1 && usedARGV("-remove_zeros") != -1; 832 & ENDIFMACRO 831 @ bool removeZeros = trueRestrict && overlap == 1 && usedARGV("-remove_zeros") != -1; 832 @ 833 @ if(verbosity > 0) { 834 @ mpiBarrier( mpiCommWorld); 835 @ timerPartition = mpiWtime(); 836 @ } 837 @ IFMACRO(privateBuildDmesh) 838 & NewMacro defP1(i)i EndMacro NewMacro initP1(i)i EndMacro partitionPrivate(ThTab, ThBorderTab, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank( mpiCommWorld), mpiSize( mpiCommWorld), 1, overlap, 1, prolongation, DTab, P1, intersection, mpiCommWorld, fakeInterface, P1, defP1, initP1, 1) 839 & ENDIFMACRO 838 @ NewMacro defP1(i)i EndMacro ) 839 @ NewMacro initP1(i)i EndMacro ) 840 @ partitionPrivate(ThTab, ThBorderTab, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank( mpiCommWorld), mpiSize( mpiCommWorld), 1, overlap, 1, prolongation, DTab, P1, intersection, mpiCommWorld, fakeInterface, P1, defP1, initP1, 1) 86 @ 87 @ 88 @ 89 @ 90 @ 91 @ 92 @ 93 @ 94 @ 95 @ 96 @ 97 @ 98 @ 99 @ 100 @ 101 @ 102 @ 103 @ 104 @ 105 @ 106 @ 107 @ 108 @ 109 @ 110 @ 111 @ 112 @ 113 @ 114 @ 115 @ 116 @ 117 @ 118 @ 119 @ 120 @ 121 @ 122 @ 123 @ 124 @ 125 @ 126 @ 127 @ 128 @ 129 @ 130 @ 131 @ 132 @ 133 @ 134 @ 135 @ 136 @ 137 @ 138 @ 139 @ 140 @ 141 @ 142 @ 143 @ 144 @ 145 @ 146 @ 147 @ 148 @ 149 @ 150 @ 151 @ 152 @ 153 @ 154 @ 155 @ 156 @ 157 @ 158 @ 159 @ 160 @ 161 @ 162 @ 163 @ 164 @ 165 @ 166 @ 167 @ 168 @ 169 @ 170 @ 171 @ 172 @ 173 @ 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ 186 @ 187 @ 188 @ 189 @ 190 @ 191 @ 192 @ 193 @ 194 @ 195 @ 196 @ 197 @ 198 @ 199 @ 200 @ 201 @ 202 @ 203 @ 204 @ 205 @ 206 @ 207 @ 208 @ 209 @ 210 @ 211 @ 212 @ 213 @ 214 @ 215 @ 216 @ 217 @ 218 @ 219 @ 220 @ 221 @ 222 @ 223 @ 224 @ 225 @ 226 @ 227 @ 228 @ 229 @ 230 @ 231 @ 232 @ 233 @ 234 @ 235 @ 236 @ 237 @ 238 @ 239 @ 240 @ 241 @ 242 @ 243 @ 244 @ 245 @ 246 @ 247 @ 248 @ 249 @ 250 @ 251 @ 252 @ 253 @ 254 @ 255 @ 256 @ 257 @ 258 @ 259 @ 260 @ 261 @ 262 @ 263 @ 264 @ 265 @ 266 @ 267 @ 268 @ 269 @ 270 @ 271 @ 272 @ 273 @ 274 @ 275 @ 276 @ 277 @ 278 @ 279 @ 280 @ 281 @ 282 @ 283 @ 284 @ 285 @ 286 @ 287 @ 288 @ 289 @ 290 @ 291 @ 292 @ 293 @ 294 @ 295 @ 296 @ 297 @ 298 @ 299 @ 300 @ 301 @ 302 @ 303 @ 304 @ 305 @ 306 @ 307 @ 308 @ 309 @ 310 @ 311 @ 312 @ 313 @ 314 @ 315 @ 316 @ 317 @ 318 @ 319 @ 320 @ 321 @ 322 @ 323 @ 324 @ 325 @ 326 @ 327 @ 328 @ 329 @ 330 @ 331 @ 332 @ 333 @ 334 @ 335 @ 336 @ 337 @ 338 @ 339 @ 340 @ 341 @ 342 @ 343 @ 344 @ 345 @ 346 @ 347 @ 348 @ 349 @ 350 @ 351 @ 352 @ 353 @ 354 @ 355 @ 356 @ 357 @ 358 @ 359 @ 360 @ 361 @ 362 @ 363 @ 364 @ 365 @ 366 @ 367 @ 368 @ 369 @ 370 @ 371 @ 372 @ 373 @ 374 @ 375 @ 376 @ 377 @ 378 @ 379 @ 380 @ 381 @ 382 @ 383 @ 384 @ 385 @ 386 @ 387 @ 388 @ 389 @ 390 @ 391 @ 392 @ 393 @ 394 @ 395 @ 396 @ 397 @ 398 @ 399 @ 400 @ 401 @ 402 @ 403 @ 404 @ 405 @ 406 @ 407 @ 408 @ 409 @ 410 @ 411 @ 412 @ 413 @ 414 @ 415 @ 416 @ 417 @ 418 @ 419 @ 420 @ 421 @ 422 @ 423 @ 424 @ 425 @ 426 @ 427 @ 428 @ 429 @ 430 @ 431 @ 432 @ 433 @ 434 @ 435 @ 436 @ 437 @ 438 @ 439 @ 440 @ 441 @ 442 @ 443 @ 444 @ 445 @ 446 @ 447 @ 448 @ 449 @ 450 @ 451 @ 452 @ 453 @ 454 @ 455 @ 456 @ 457 @ 458 @ 459 @ 460 @ 461 @ { 86 @ int backupSM = searchMethod; 87 @ searchMethod = 1; 88 @ assert( 1 >= 1); 89 @ IFMACRO(!privateCreatePartition) 90 & IFMACRO(!privateCreateMat) 91 & intersection.resize(1); 92 & intersection[0].resize(0); 93 & PhGlobalPrivate supp; 94 & VhGlobalPrivate suppSmooth; 95 & { 96 & int constant = mpiRank( mpiCommWorld); 97 & for[i, v : supp[]] v = abs( partGlobal[][i] - constant) < 0.1; 98 & AddLayers( ThGlobal, supp[], 2 * overlap, suppSmooth[]); 99 & int[int] n2o; 100 & meshN neighbors; 101 & bool connected = false; 102 & for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 103 & if(!connected) 104 & n2o.resize(0); 105 & else neighbors = trunc( ThGlobal, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 106 & int[int] partOverlap(n2o.n); 107 & for[i, v : n2o] partOverlap[i] = partGlobal[][v]; 108 & Unique(partOverlap, intersection[0], remove = constant); 109 & if( 1 > 1 && 1 <= 1) { 110 & ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, split = 1); 111 & supp = abs( partGlobal - constant) < 0.1; 112 & suppSmooth = 0; 113 & AddLayers( ThGlobal, supp[], 2 * overlap, suppSmooth[]); 114 & } 115 & } 116 & int[int] n2oNeighbor; 117 & IFMACRO(!privateDmeshCartesianPartitioning) 118 & ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, label = 9999 119 & IFMACRO(privateDmeshN2O) 120 & , new2old = n2oNeighbor ENDIFMACRO ); 121 & ENDIFMACRO real eps = ThGlobal.measure; 122 & real[int] epsTab( intersection[0].n); 123 & mpiRequest[int] rq(2 * intersection[0].n); 124 & if(mpiSize( mpiCommWorld) == mpiSize( mpiCommWorld)) { 125 & for(int j = 0; j < intersection[0].n; ++j) 126 & Irecv(processor( intersection[0][j], mpiCommWorld, rq[j]), epsTab[j]); 127 & for(int j = 0; j < intersection[0].n; ++j) 128 & Isend(processor( intersection[0][j], mpiCommWorld, rq[ intersection[0].n + j]), eps); 129 & } 130 & else epsTab = 1.0e+30; 131 & suppSmooth = suppSmooth; 132 & IFMACRO(!privateDmeshN2O) 133 & ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oNeighbor); 134 & IFMACRO(privateDmeshCartesianPartitioning) 135 & real[int] bb(2 * dimension); 136 & boundingbox(ThTab[ 1 - 1], bb); 137 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 138 & IFMACRO(dimension,3) 139 & && z > bb[4] && z < bb[5] 140 & ENDIFMACRO , label = fakeInterface); 141 & ThGlobal = ThTab[ 1 - 1]; 142 & n2oNeighbor = 0: ThGlobal.nt - 1; 143 & ENDIFMACRO ENDIFMACRO IFMACRO(privateDmeshN2O) 144 & ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oth); 145 & IFMACRO(privateDmeshCartesianPartitioning) 146 & real[int] bb(2 * dimension); 147 & boundingbox(ThTab[ 1 - 1], bb); 148 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 149 & IFMACRO(dimension,3) 150 & && z > bb[4] && z < bb[5] 151 & ENDIFMACRO , label = fakeInterface, new2old = n2oth); 152 & ThGlobal = ThTab[ 1 - 1]; 153 & n2oNeighbor = 0: ThGlobal.nt - 1; 154 & ENDIFMACRO IFMACRO(!privateDmeshCartesianPartitioning) 155 & { 156 & int[int] backup = n2oth; 157 & int[int] new = n2oNeighbor(n2oth); 158 & n2oth.resize(new.n); 159 & n2oth = new; 160 & n2oNeighbor.resize(backup.n); 161 & n2oNeighbor = backup; 162 & } 163 & ENDIFMACRO ENDIFMACRO if( 1 > 1) { 164 & prolongation.resize( 1 - 1); 165 & if( 1 > 1) { 166 & meshN globalNameRefined = ThGlobal; 167 & for(int i = 1 - 1; i > 0; --i) { 168 & globalNameRefined = trunc(globalNameRefined, 1, split = 1); 169 & ThTab[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = fakeInterface); 170 & fespace WhLocalRefinedPrivate(ThTab[i - 1], P1); 171 & fespace WhLocalCoarsePrivate(ThTab[i], P1); 172 & prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 173 & } 174 & } 175 & else for(int i = 1 - 1; i > 0; --i) 176 & ThTab[i - 1] = ThTab[i]; 177 & } 178 & if(!removeZeros && ( fakeInterface != -111111 || overlap != 1)) { 179 & if(suppSmooth[].min < 0.501) { 180 & supp = supp; 181 & ThBorderTab[ 1 - 1] = trunc( ThGlobal, (suppSmooth > ( overlap - 0.999) / real(2 * overlap)) && (suppSmooth < 0.501), label = (abs( fakeInterface) + 1) * 100); 182 & if( 1 > 1) 183 & for(int i = 1 - 2; i >= 0; --i) { 184 & ThBorderTab[i] = trunc( ThBorderTab[i + 1], 1, split = 1, label = (abs( fakeInterface) + 1) * 100); 185 & meshN tempRefined = ThTab[i] + ThBorderTab[i]; 186 & fespace PhRefinedPrivate(tempRefined, P0); 187 & PhRefinedPrivate suppRefined = supp; 188 & fespace VhBorderRefinedPrivate( ThBorderTab[i], P1); 189 & VhBorderRefinedPrivate suppBorder = suppRefined; 190 & ThBorderTab[i] = trunc( ThBorderTab[i], suppBorder > 0.01); 191 & } 192 & else for(int i = 1 - 2; i >= 0; --i) 193 & ThBorderTab[i] = ThBorderTab[i + 1]; 194 & } 195 & } 196 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 197 & VhLocalPrivate[int] partitionIntersection( intersection[0].n); 198 & VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 199 & VhLocalPrivate sum = khi; 200 & VhGlobalPrivate phi; 201 & partGlobal = partGlobal; 202 & int numberIntersection = 0; 203 & { 204 & int[int] restriction = restrict(VhLocalPrivate, VhGlobalPrivate, n2oNeighbor); 205 & n2oNeighbor.resize(0); 206 & mpiWaitAll(rq); 207 & for(int i = 0; i < intersection[0].n; ++i) { 208 & PhGlobalPrivate suppPartition = abs( partGlobal - intersection[0][i]) < 0.1; 209 & AddLayers( ThGlobal, suppPartition[], overlap, phi[]); 210 & if(min(eps, epsTab[i]) > 0.0) { 211 & if(intN( ThGlobal)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 212 & partitionIntersection[numberIntersection][] = phi[](restriction); 213 & if(!trueRestrict) 214 & sum[] += partitionIntersection[numberIntersection][]; 215 & intersection[0][numberIntersection++] = intersection[0][i]; 216 & } 217 & } 218 & } 219 & } 220 & if(numberIntersection != intersection[0].n) 221 & intersection[0].resize(numberIntersection); 222 & intersection.resize(1 + 1 * numberIntersection); 223 & ENDIFMACRO IFMACRO(privateCreateMat) 224 & assert( 1 == 1); 225 & int numberIntersection = privateDmeshthintersectionDef.n - 1; 226 & intersection.resize(1 + 1 * numberIntersection); 227 & intersection[0].resize(numberIntersection); 228 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 229 & VhLocalPrivate[int] partitionIntersection(numberIntersection); 230 & for(int i = 0; i < numberIntersection; ++i) { 231 & intersection[0][i] = privateDmeshthintersectionDef[0][i]; 232 & partitionIntersection[i][] = privateDmeshthintersectionDef[1 + i]; 233 & } 234 & IFMACRO(privateDmeshN2O) 235 & IFMACRO(privateDmeshOriginal) 236 & IFMACRO(privateDmeshRestriction) 237 & { 238 & fespace WhLocalPrivate(ThTab[ 1 - 1], P1); 239 & fespace WhOriginalPrivate(privateDmeshOriginal, P1); 240 & privateDmeshRestriction.resize(WhOriginalPrivate.ndof); 241 & privateDmeshRestriction = restrict(WhLocalPrivate, WhOriginalPrivate, n2oth); 242 & } 243 & ENDIFMACRO ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(privateBuildDmesh) 244 & privateDmeshthintersectionDef.resize(1 + numberIntersection); 245 & privateDmeshthintersectionDef[0].resize(numberIntersection); 246 & for(int i = 0; i < numberIntersection; ++i) { 247 & privateDmeshthintersectionDef[0][i] = intersection[0][i]; 248 & privateDmeshthintersectionDef[1 + i].resize(VhLocalPrivate.ndof); 249 & privateDmeshthintersectionDef[1 + i] = partitionIntersection[i][]; 250 & } 251 & ENDIFMACRO meshN[int] meshIntersection(numberIntersection); 252 & for(int j = 0; j < ( 1 == 1 ? 1 : 1); ++j) { 253 & for(int i = 0; i < numberIntersection; ++i) { 254 & int[int] n2o; 255 & meshIntersection[i] = trunc(ThTab[j], partitionIntersection[i] > 1.0e-6, new2old = n2o, label = 9999); 256 & IFMACRO(privateDmeshCartesianPartitioning) 257 & real[int] bb(2 * dimension); 258 & boundingbox(meshIntersection[i], bb); 259 & meshIntersection[i] = trunc(ThTab[j], x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 260 & IFMACRO(dimension,3) 261 & && z > bb[4] && z < bb[5] 262 & ENDIFMACRO , new2old = n2o, label = 9999); 263 & ENDIFMACRO IFMACRO(!privateCreateMat) 264 & if(!removeZeros) 265 & ENDIFMACRO { 266 & IFMACRO(vectorialfe) 267 & fespace singleComponentWhPrivate(ThTab[j], vectorialfe); 268 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 269 & ENDIFMACRO IFMACRO(!vectorialfe) 270 & fespace singleComponentWhPrivate(ThTab[j], P1); 271 & fespace WhIntersectionPrivate(meshIntersection[i], P1); 272 & ENDIFMACRO intersection[1 + i + j * numberIntersection] = restrict(WhIntersectionPrivate, singleComponentWhPrivate, n2o); 273 & } 274 & } 275 & } 276 & IFMACRO(!privateCreateMat) 277 & if( 1 == 1 && 1 > 1 && !removeZeros) 278 & for(int j = 1; j < 1; ++j) 279 & for(int i = 0; i < numberIntersection; ++i) { 280 & intersection[1 + i + j * numberIntersection].resize( intersection[1 + i].n); 281 & intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 282 & } 283 & partitionIntersection.resize(0); 284 & for(int i = 0; i < (trueRestrict ? 1 : 1 - 1); ++i) { 285 & fespace VhRefinedPrivate(ThTab[i], P1); 286 & fespace PhRefinedPrivate(ThTab[i], P0); 287 & PhRefinedPrivate partRefined = partGlobal; 288 & PhRefinedPrivate supp = abs(partRefined - mpiRank( mpiCommWorld)) < 0.1; 289 & varf vSupp(u, v) = intN(ThTab[i], qforder = 1)(supp * v); 290 & VhRefinedPrivate khiL; 291 & khiL[] = vSupp(0, VhRefinedPrivate); 292 & khiL = khiL > 0.0; 293 & VhRefinedPrivate sum = khiL; 294 & for(int j = 0; j < numberIntersection; ++j) { 295 & supp = abs(partRefined - intersection[0][j]) < 0.1; 296 & VhRefinedPrivate phiL; 297 & phiL[] = vSupp(0, VhRefinedPrivate); 298 & phiL = phiL > 0.0; 299 & sum[] += phiL[]; 300 & } 301 & khiL[] ./= sum[]; 302 & if(i < 1 - 1) { 303 & fespace WhRefinedPrivate(ThTab[i], P1); 304 & WhRefinedPrivate defP1(func2vec); 305 & defP1(func2vec) = initP1(khiL); 306 & DTab[i].resize(WhRefinedPrivate.ndof); 307 & DTab[i] = func2vec[]; 308 & } 309 & else khi[] = khiL[]; 310 & } 311 & if(!trueRestrict) 312 & khi[] = khi[] ./= sum[]; 313 & if(trueRestrict && mpiSize( mpiCommWorld) == mpiSize( mpiCommWorld) && removeZeros) { 314 & assert( 1 == 1); 315 & meshN ThIntersection; 316 & fespace PhIntersectionPrivate(ThIntersection, P0); 317 & PhIntersectionPrivate[int] recv(numberIntersection); 318 & PhIntersectionPrivate[int] send(numberIntersection); 319 & mpiRequest[int] rq(2 * numberIntersection); 320 & for(int i = 0; i < numberIntersection; ++i) { 321 & ThIntersection = meshIntersection[i]; 322 & Irecv(processor( intersection[0][i], mpiCommWorld, rq[i]), recv[i][]); 323 & send[i] = khi; 324 & Isend(processor( intersection[0][i], mpiCommWorld, rq[numberIntersection + i]), send[i][]); 325 & } 326 & ThTab[0] = trunc(ThTab[0], khi > 1.0e-6, label = 9999); 327 & khi = khi; 328 & int[int] skip(0); 329 & for(int k = 0; k < 2 * numberIntersection; ++k) { 330 & int i = mpiWaitAny(rq); 331 & if(i < numberIntersection) { 332 & ThIntersection = meshIntersection[i]; 333 & PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 334 & if( intersection[].l2 > 1.0e-6) 335 & meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 336 & else { 337 & skip.resize(skip.n + 1); 338 & skip[skip.n - 1] = i; 339 & } 340 & } 341 & } 342 & skip.sort; 343 & intersection.resize(1 + numberIntersection - skip.n); 344 & int j = 0; 345 & for(int i = 0; i < numberIntersection; ++i) { 346 & bool skipped = false; 347 & if(j < skip.n) { 348 & if(skip[j] == i) { 349 & ++j; 350 & skipped = true; 351 & } 352 & } 353 & if(!skipped) { 354 & IFMACRO(vectorialfe) 355 & fespace singleComponentWhPrivate(ThTab[0], vectorialfe); 356 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 357 & ENDIFMACRO IFMACRO(!vectorialfe) 358 & fespace singleComponentWhPrivate(ThTab[0], P1); 359 & fespace WhIntersectionPrivate(meshIntersection[i], P1); 360 & ENDIFMACRO matrix ThTabR = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 361 & ThTabR.thresholding(1.0e-10); 362 & real[int] ThTabC; 363 & int[int] ThTabI; 364 & [ThTabI, intersection[1 + i - j], ThTabC] = ThTabR; 365 & intersection[1 + i - j].resize(ThTabR.nbcoef); 366 & intersection[0][i - j] = intersection[0][i]; 367 & } 368 & } 369 & numberIntersection -= skip.n; 370 & intersection[0].resize(numberIntersection); 371 & if( fakeInterface != -111111 || overlap != 1) { 372 & PhGlobalPrivate suppPartition = khi > 0.1; 373 & AddLayers( ThGlobal, suppPartition[], 1, phi[]); 374 & ThBorderTab[0] = trunc( ThGlobal, phi > 0.001 && phi < 0.501, label = (abs( fakeInterface) + 1) * 100); 375 & } 376 & } 377 & ENDIFMACRO IFMACRO(vectorialfe) 378 & if( 1 > 1) 379 & for(int i = 0; i < intersection.n - 1; ++i) { 380 & int n = intersection[1 + i].n; 381 & intersection[1 + i].resize(n * 1); 382 & for(int j = n - 1; j != -1; --j) 383 & for(int k = 1 - 1; k != -1; --k) 384 & intersection[1 + i][j * 1 + k] = intersection[1 + i][j] * 1 + k; 385 & } 386 & ENDIFMACRO ENDIFMACRO 90 @ IFMACRO(!privateCreateMat) 91 & intersection.resize(1); 92 & intersection[0].resize(0); 93 & PhGlobalPrivate supp; 94 & VhGlobalPrivate suppSmooth; 95 & { 96 & int constant = mpiRank( mpiCommWorld); 97 & for[i, v : supp[]] v = abs( partGlobal[][i] - constant) < 0.1; 98 & AddLayers( ThGlobal, supp[], 2 * overlap, suppSmooth[]); 99 & int[int] n2o; 100 & meshN neighbors; 101 & bool connected = false; 102 & for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 103 & if(!connected) 104 & n2o.resize(0); 105 & else neighbors = trunc( ThGlobal, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 106 & int[int] partOverlap(n2o.n); 107 & for[i, v : n2o] partOverlap[i] = partGlobal[][v]; 108 & Unique(partOverlap, intersection[0], remove = constant); 109 & if( 1 > 1 && 1 <= 1) { 110 & ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, split = 1); 111 & supp = abs( partGlobal - constant) < 0.1; 112 & suppSmooth = 0; 113 & AddLayers( ThGlobal, supp[], 2 * overlap, suppSmooth[]); 114 & } 115 & } 116 & int[int] n2oNeighbor; 117 & IFMACRO(!privateDmeshCartesianPartitioning) 118 & ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, label = 9999 119 & IFMACRO(privateDmeshN2O) 120 & , new2old = n2oNeighbor ENDIFMACRO ); 121 & ENDIFMACRO real eps = ThGlobal.measure; 122 & real[int] epsTab( intersection[0].n); 123 & mpiRequest[int] rq(2 * intersection[0].n); 124 & if(mpiSize( mpiCommWorld) == mpiSize( mpiCommWorld)) { 125 & for(int j = 0; j < intersection[0].n; ++j) 126 & Irecv(processor( intersection[0][j], mpiCommWorld, rq[j]), epsTab[j]); 127 & for(int j = 0; j < intersection[0].n; ++j) 128 & Isend(processor( intersection[0][j], mpiCommWorld, rq[ intersection[0].n + j]), eps); 129 & } 130 & else epsTab = 1.0e+30; 131 & suppSmooth = suppSmooth; 132 & IFMACRO(!privateDmeshN2O) 133 & ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oNeighbor); 134 & IFMACRO(privateDmeshCartesianPartitioning) 135 & real[int] bb(2 * dimension); 136 & boundingbox(ThTab[ 1 - 1], bb); 137 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 138 & IFMACRO(dimension,3) 139 & && z > bb[4] && z < bb[5] 140 & ENDIFMACRO , label = fakeInterface); 141 & ThGlobal = ThTab[ 1 - 1]; 142 & n2oNeighbor = 0: ThGlobal.nt - 1; 143 & ENDIFMACRO ENDIFMACRO IFMACRO(privateDmeshN2O) 144 & ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oth); 145 & IFMACRO(privateDmeshCartesianPartitioning) 146 & real[int] bb(2 * dimension); 147 & boundingbox(ThTab[ 1 - 1], bb); 148 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 149 & IFMACRO(dimension,3) 150 & && z > bb[4] && z < bb[5] 151 & ENDIFMACRO , label = fakeInterface, new2old = n2oth); 152 & ThGlobal = ThTab[ 1 - 1]; 153 & n2oNeighbor = 0: ThGlobal.nt - 1; 154 & ENDIFMACRO IFMACRO(!privateDmeshCartesianPartitioning) 155 & { 156 & int[int] backup = n2oth; 157 & int[int] new = n2oNeighbor(n2oth); 158 & n2oth.resize(new.n); 159 & n2oth = new; 160 & n2oNeighbor.resize(backup.n); 161 & n2oNeighbor = backup; 162 & } 163 & ENDIFMACRO ENDIFMACRO if( 1 > 1) { 164 & prolongation.resize( 1 - 1); 165 & if( 1 > 1) { 166 & meshN globalNameRefined = ThGlobal; 167 & for(int i = 1 - 1; i > 0; --i) { 168 & globalNameRefined = trunc(globalNameRefined, 1, split = 1); 169 & ThTab[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = fakeInterface); 170 & fespace WhLocalRefinedPrivate(ThTab[i - 1], P1); 171 & fespace WhLocalCoarsePrivate(ThTab[i], P1); 172 & prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 173 & } 174 & } 175 & else for(int i = 1 - 1; i > 0; --i) 176 & ThTab[i - 1] = ThTab[i]; 177 & } 178 & if(!removeZeros && ( fakeInterface != -111111 || overlap != 1)) { 179 & if(suppSmooth[].min < 0.501) { 180 & supp = supp; 181 & ThBorderTab[ 1 - 1] = trunc( ThGlobal, (suppSmooth > ( overlap - 0.999) / real(2 * overlap)) && (suppSmooth < 0.501), label = (abs( fakeInterface) + 1) * 100); 182 & if( 1 > 1) 183 & for(int i = 1 - 2; i >= 0; --i) { 184 & ThBorderTab[i] = trunc( ThBorderTab[i + 1], 1, split = 1, label = (abs( fakeInterface) + 1) * 100); 185 & meshN tempRefined = ThTab[i] + ThBorderTab[i]; 186 & fespace PhRefinedPrivate(tempRefined, P0); 187 & PhRefinedPrivate suppRefined = supp; 188 & fespace VhBorderRefinedPrivate( ThBorderTab[i], P1); 189 & VhBorderRefinedPrivate suppBorder = suppRefined; 190 & ThBorderTab[i] = trunc( ThBorderTab[i], suppBorder > 0.01); 191 & } 192 & else for(int i = 1 - 2; i >= 0; --i) 193 & ThBorderTab[i] = ThBorderTab[i + 1]; 194 & } 195 & } 196 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 197 & VhLocalPrivate[int] partitionIntersection( intersection[0].n); 198 & VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 199 & VhLocalPrivate sum = khi; 200 & VhGlobalPrivate phi; 201 & partGlobal = partGlobal; 202 & int numberIntersection = 0; 203 & { 204 & int[int] restriction = restrict(VhLocalPrivate, VhGlobalPrivate, n2oNeighbor); 205 & n2oNeighbor.resize(0); 206 & mpiWaitAll(rq); 207 & for(int i = 0; i < intersection[0].n; ++i) { 208 & PhGlobalPrivate suppPartition = abs( partGlobal - intersection[0][i]) < 0.1; 209 & AddLayers( ThGlobal, suppPartition[], overlap, phi[]); 210 & if(min(eps, epsTab[i]) > 0.0) { 211 & if(intN( ThGlobal)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 212 & partitionIntersection[numberIntersection][] = phi[](restriction); 213 & if(!trueRestrict) 214 & sum[] += partitionIntersection[numberIntersection][]; 215 & intersection[0][numberIntersection++] = intersection[0][i]; 216 & } 217 & } 218 & } 219 & } 220 & if(numberIntersection != intersection[0].n) 221 & intersection[0].resize(numberIntersection); 222 & intersection.resize(1 + 1 * numberIntersection); 223 & ENDIFMACRO 91 @ intersection.resize(1); 92 @ intersection[0].resize(0); 93 @ PhGlobalPrivate supp; 94 @ VhGlobalPrivate suppSmooth; 95 @ { 96 @ int constant = mpiRank( mpiCommWorld); 97 @ for[i, v : supp[]] v = abs( partGlobal[][i] - constant) < 0.1; 98 @ AddLayers( ThGlobal, supp[], 2 * overlap, suppSmooth[]); 99 @ int[int] n2o; 100 @ meshNmesh neighbors; 101 @ bool connected = false; 102 @ for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 103 @ if(!connected) 104 @ n2o.resize(0); 105 @ else 106 @ neighbors = trunc( ThGlobal, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 107 @ int[int] partOverlap(n2o.n); 108 @ for[i, v : n2o] partOverlap[i] = partGlobal[][v]; 109 @ Unique(partOverlap, intersection[0], remove = constant); 110 @ if( 1 > 1 && 1 <= 1) { 111 @ ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, split = 1); 112 @ supp = abs( partGlobal - constant) < 0.1; 113 @ suppSmooth = 0; 114 @ AddLayers( ThGlobal, supp[], 2 * overlap, suppSmooth[]); 115 @ } 116 @ } 117 @ int[int] n2oNeighbor; 118 @ IFMACRO(!privateDmeshCartesianPartitioning) 119 & ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, label = 9999 120 & IFMACRO(privateDmeshN2O) 121 & , new2old = n2oNeighbor ENDIFMACRO ); 122 & ENDIFMACRO 119 @ ThGlobal = trunc( ThGlobal, suppSmooth > 0.001, label = 9999 120 @ IFMACRO(privateDmeshN2O) 121 & , new2old = n2oNeighbor ENDIFMACRO 121 @ , new2old = n2oNeighbor 122 @ 122 @ ); 123 @ 123 @ real eps = ThGlobal.measure; 124 @ real[int] epsTab( intersection[0].n); 125 @ mpiRequest[int] rq(2 * intersection[0].n); 126 @ if(mpiSize( mpiCommWorld) == mpiSize( mpiCommWorld)) { 127 @ for(int j = 0; j < intersection[0].n; ++j) 128 @ Irecv(processor( intersection[0][j], mpiCommWorld, rq[j]), epsTab[j]); 129 @ for(int j = 0; j < intersection[0].n; ++j) 130 @ Isend(processor( intersection[0][j], mpiCommWorld, rq[ intersection[0].n + j]), eps); 131 @ } 132 @ else 133 @ epsTab = 1.0e+30; 134 @ suppSmooth = suppSmooth; 135 @ IFMACRO(!privateDmeshN2O) 136 & ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oNeighbor); 137 & IFMACRO(privateDmeshCartesianPartitioning) 138 & real[int] bb(2 * dimension); 139 & boundingbox(ThTab[ 1 - 1], bb); 140 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 141 & IFMACRO(dimension,3) 142 & && z > bb[4] && z < bb[5] 143 & ENDIFMACRO , label = fakeInterface); 144 & ThGlobal = ThTab[ 1 - 1]; 145 & n2oNeighbor = 0: ThGlobal.nt - 1; 146 & ENDIFMACRO ENDIFMACRO 147 @ IFMACRO(privateDmeshN2O) 148 & ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oth); 149 & IFMACRO(privateDmeshCartesianPartitioning) 150 & real[int] bb(2 * dimension); 151 & boundingbox(ThTab[ 1 - 1], bb); 152 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 153 & IFMACRO(dimension,3) 154 & && z > bb[4] && z < bb[5] 155 & ENDIFMACRO , label = fakeInterface, new2old = n2oth); 156 & ThGlobal = ThTab[ 1 - 1]; 157 & n2oNeighbor = 0: ThGlobal.nt - 1; 158 & ENDIFMACRO IFMACRO(!privateDmeshCartesianPartitioning) 159 & { 160 & int[int] backup = n2oth; 161 & int[int] new = n2oNeighbor(n2oth); 162 & n2oth.resize(new.n); 163 & n2oth = new; 164 & n2oNeighbor.resize(backup.n); 165 & n2oNeighbor = backup; 166 & } 167 & ENDIFMACRO ENDIFMACRO 148 @ ThTab[ 1 - 1] = trunc( ThGlobal, suppSmooth > 0.501, label = fakeInterface, new2old = n2oth); 149 @ IFMACRO(privateDmeshCartesianPartitioning) 150 & real[int] bb(2 * dimension); 151 & boundingbox(ThTab[ 1 - 1], bb); 152 & ThTab[ 1 - 1] = trunc( ThGlobal, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 153 & IFMACRO(dimension,3) 154 & && z > bb[4] && z < bb[5] 155 & ENDIFMACRO , label = fakeInterface, new2old = n2oth); 156 & ThGlobal = ThTab[ 1 - 1]; 157 & n2oNeighbor = 0: ThGlobal.nt - 1; 158 & ENDIFMACRO 159 @ IFMACRO(!privateDmeshCartesianPartitioning) 160 & { 161 & int[int] backup = n2oth; 162 & int[int] new = n2oNeighbor(n2oth); 163 & n2oth.resize(new.n); 164 & n2oth = new; 165 & n2oNeighbor.resize(backup.n); 166 & n2oNeighbor = backup; 167 & } 168 & ENDIFMACRO 160 @ { 161 @ int[int] backup = n2oth; 162 @ int[int] new = n2oNeighbor(n2oth); 163 @ n2oth.resize(new.n); 164 @ n2oth = new; 165 @ n2oNeighbor.resize(backup.n); 166 @ n2oNeighbor = backup; 167 @ } 168 @ 169 @ 168 @ if( 1 > 1) { 169 @ prolongation.resize( 1 - 1); 170 @ if( 1 > 1) { 171 @ meshNmesh globalNameRefined = ThGlobal; 172 @ for(int i = 1 - 1; i > 0; --i) { 173 @ globalNameRefined = trunc(globalNameRefined, 1, split = 1); 174 @ ThTab[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = fakeInterface); 175 @ fespace WhLocalRefinedPrivate(ThTab[i - 1], P1); 176 @ fespace WhLocalCoarsePrivate(ThTab[i], P1); 177 @ prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 178 @ } 179 @ } 180 @ else 181 @ for(int i = 1 - 1; i > 0; --i) 182 @ ThTab[i - 1] = ThTab[i]; 183 @ } 184 @ if(!removeZeros && ( fakeInterface != -111111 || overlap != 1)) { 185 @ if(suppSmooth[].min < 0.501) { 186 @ supp = supp; 187 @ ThBorderTab[ 1 - 1] = trunc( ThGlobal, (suppSmooth > ( overlap - 0.999) / real(2 * overlap)) && (suppSmooth < 0.501), label = (abs( fakeInterface) + 1) * 100); 188 @ if( 1 > 1) 189 @ for(int i = 1 - 2; i >= 0; --i) { 190 @ ThBorderTab[i] = trunc( ThBorderTab[i + 1], 1, split = 1, label = (abs( fakeInterface) + 1) * 100); 191 @ meshNmesh tempRefined = ThTab[i] + ThBorderTab[i]; 192 @ fespace PhRefinedPrivate(tempRefined, P0); 193 @ PhRefinedPrivate suppRefined = supp; 194 @ fespace VhBorderRefinedPrivate( ThBorderTab[i], P1); 195 @ VhBorderRefinedPrivate suppBorder = suppRefined; 196 @ ThBorderTab[i] = trunc( ThBorderTab[i], suppBorder > 0.01); 197 @ } 198 @ else 199 @ for(int i = 1 - 2; i >= 0; --i) 200 @ ThBorderTab[i] = ThBorderTab[i + 1]; 201 @ } 202 @ } 203 @ fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 204 @ VhLocalPrivate[int] partitionIntersection( intersection[0].n); 205 @ VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 206 @ VhLocalPrivate sum = khi; 207 @ VhGlobalPrivate phi; 208 @ partGlobal = partGlobal; 209 @ int numberIntersection = 0; 210 @ { 211 @ int[int] restriction = restrict(VhLocalPrivate, VhGlobalPrivate, n2oNeighbor); 212 @ n2oNeighbor.resize(0); 213 @ mpiWaitAll(rq); 214 @ for(int i = 0; i < intersection[0].n; ++i) { 215 @ PhGlobalPrivate suppPartition = abs( partGlobal - intersection[0][i]) < 0.1; 216 @ AddLayers( ThGlobal, suppPartition[], overlap, phi[]); 217 @ if(min(eps, epsTab[i]) > 0.0) { 218 @ if(intNint2d( ThGlobal)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 219 @ partitionIntersection[numberIntersection][] = phi[](restriction); 220 @ if(!trueRestrict) 221 @ sum[] += partitionIntersection[numberIntersection][]; 222 @ intersection[0][numberIntersection++] = intersection[0][i]; 223 @ } 224 @ } 225 @ } 226 @ } 227 @ if(numberIntersection != intersection[0].n) 228 @ intersection[0].resize(numberIntersection); 229 @ intersection.resize(1 + 1 * numberIntersection); 230 @ 224 @ IFMACRO(privateCreateMat) 225 & assert( 1 == 1); 226 & int numberIntersection = privateDmeshthintersectionDef.n - 1; 227 & intersection.resize(1 + 1 * numberIntersection); 228 & intersection[0].resize(numberIntersection); 229 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 230 & VhLocalPrivate[int] partitionIntersection(numberIntersection); 231 & for(int i = 0; i < numberIntersection; ++i) { 232 & intersection[0][i] = privateDmeshthintersectionDef[0][i]; 233 & partitionIntersection[i][] = privateDmeshthintersectionDef[1 + i]; 234 & } 235 & IFMACRO(privateDmeshN2O) 236 & IFMACRO(privateDmeshOriginal) 237 & IFMACRO(privateDmeshRestriction) 238 & { 239 & fespace WhLocalPrivate(ThTab[ 1 - 1], P1); 240 & fespace WhOriginalPrivate(privateDmeshOriginal, P1); 241 & privateDmeshRestriction.resize(WhOriginalPrivate.ndof); 242 & privateDmeshRestriction = restrict(WhLocalPrivate, WhOriginalPrivate, n2oth); 243 & } 244 & ENDIFMACRO ENDIFMACRO ENDIFMACRO ENDIFMACRO 245 @ IFMACRO(privateBuildDmesh) 246 & privateDmeshthintersectionDef.resize(1 + numberIntersection); 247 & privateDmeshthintersectionDef[0].resize(numberIntersection); 248 & for(int i = 0; i < numberIntersection; ++i) { 249 & privateDmeshthintersectionDef[0][i] = intersection[0][i]; 250 & privateDmeshthintersectionDef[1 + i].resize(VhLocalPrivate.ndof); 251 & privateDmeshthintersectionDef[1 + i] = partitionIntersection[i][]; 252 & } 253 & ENDIFMACRO 246 @ privateDmeshthintersectionDef.resize(1 + numberIntersection); 247 @ privateDmeshthintersectionDef[0].resize(numberIntersection); 248 @ for(int i = 0; i < numberIntersection; ++i) { 249 @ privateDmeshthintersectionDef[0][i] = intersection[0][i]; 250 @ privateDmeshthintersectionDef[1 + i].resize(VhLocalPrivate.ndof); 251 @ privateDmeshthintersectionDef[1 + i] = partitionIntersection[i][]; 252 @ } 253 @ 254 @ meshNmesh[int] meshIntersection(numberIntersection); 255 @ for(int j = 0; j < ( 1 == 1 ? 1 : 1); ++j) { 256 @ for(int i = 0; i < numberIntersection; ++i) { 257 @ int[int] n2o; 258 @ meshIntersection[i] = trunc(ThTab[j], partitionIntersection[i] > 1.0e-6, new2old = n2o, label = 9999); 259 @ IFMACRO(privateDmeshCartesianPartitioning) 260 & real[int] bb(2 * dimension); 261 & boundingbox(meshIntersection[i], bb); 262 & meshIntersection[i] = trunc(ThTab[j], x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 263 & IFMACRO(dimension,3) 264 & && z > bb[4] && z < bb[5] 265 & ENDIFMACRO , new2old = n2o, label = 9999); 266 & ENDIFMACRO 267 @ IFMACRO(!privateCreateMat) 268 & if(!removeZeros) 269 & ENDIFMACRO 268 @ if(!removeZeros) 269 @ 270 @ { 271 @ IFMACRO(vectorialfe) 272 & fespace singleComponentWhPrivate(ThTab[j], vectorialfe); 273 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 274 & ENDIFMACRO 275 @ IFMACRO(!vectorialfe) 276 & fespace singleComponentWhPrivate(ThTab[j], P1); 277 & fespace WhIntersectionPrivate(meshIntersection[i], P1); 278 & ENDIFMACRO 276 @ fespace singleComponentWhPrivate(ThTab[j], P1); 277 @ fespace WhIntersectionPrivate(meshIntersection[i], P1); 278 @ 279 @ intersection[1 + i + j * numberIntersection] = restrict(WhIntersectionPrivate, singleComponentWhPrivate, n2o); 280 @ } 281 @ } 282 @ } 283 @ IFMACRO(!privateCreateMat) 284 & if( 1 == 1 && 1 > 1 && !removeZeros) 285 & for(int j = 1; j < 1; ++j) 286 & for(int i = 0; i < numberIntersection; ++i) { 287 & intersection[1 + i + j * numberIntersection].resize( intersection[1 + i].n); 288 & intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 289 & } 290 & partitionIntersection.resize(0); 291 & for(int i = 0; i < (trueRestrict ? 1 : 1 - 1); ++i) { 292 & fespace VhRefinedPrivate(ThTab[i], P1); 293 & fespace PhRefinedPrivate(ThTab[i], P0); 294 & PhRefinedPrivate partRefined = partGlobal; 295 & PhRefinedPrivate supp = abs(partRefined - mpiRank( mpiCommWorld)) < 0.1; 296 & varf vSupp(u, v) = intN(ThTab[i], qforder = 1)(supp * v); 297 & VhRefinedPrivate khiL; 298 & khiL[] = vSupp(0, VhRefinedPrivate); 299 & khiL = khiL > 0.0; 300 & VhRefinedPrivate sum = khiL; 301 & for(int j = 0; j < numberIntersection; ++j) { 302 & supp = abs(partRefined - intersection[0][j]) < 0.1; 303 & VhRefinedPrivate phiL; 304 & phiL[] = vSupp(0, VhRefinedPrivate); 305 & phiL = phiL > 0.0; 306 & sum[] += phiL[]; 307 & } 308 & khiL[] ./= sum[]; 309 & if(i < 1 - 1) { 310 & fespace WhRefinedPrivate(ThTab[i], P1); 311 & WhRefinedPrivate defP1(func2vec); 312 & defP1(func2vec) = initP1(khiL); 313 & DTab[i].resize(WhRefinedPrivate.ndof); 314 & DTab[i] = func2vec[]; 315 & } 316 & else khi[] = khiL[]; 317 & } 318 & if(!trueRestrict) 319 & khi[] = khi[] ./= sum[]; 320 & if(trueRestrict && mpiSize( mpiCommWorld) == mpiSize( mpiCommWorld) && removeZeros) { 321 & assert( 1 == 1); 322 & meshN ThIntersection; 323 & fespace PhIntersectionPrivate(ThIntersection, P0); 324 & PhIntersectionPrivate[int] recv(numberIntersection); 325 & PhIntersectionPrivate[int] send(numberIntersection); 326 & mpiRequest[int] rq(2 * numberIntersection); 327 & for(int i = 0; i < numberIntersection; ++i) { 328 & ThIntersection = meshIntersection[i]; 329 & Irecv(processor( intersection[0][i], mpiCommWorld, rq[i]), recv[i][]); 330 & send[i] = khi; 331 & Isend(processor( intersection[0][i], mpiCommWorld, rq[numberIntersection + i]), send[i][]); 332 & } 333 & ThTab[0] = trunc(ThTab[0], khi > 1.0e-6, label = 9999); 334 & khi = khi; 335 & int[int] skip(0); 336 & for(int k = 0; k < 2 * numberIntersection; ++k) { 337 & int i = mpiWaitAny(rq); 338 & if(i < numberIntersection) { 339 & ThIntersection = meshIntersection[i]; 340 & PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 341 & if( intersection[].l2 > 1.0e-6) 342 & meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 343 & else { 344 & skip.resize(skip.n + 1); 345 & skip[skip.n - 1] = i; 346 & } 347 & } 348 & } 349 & skip.sort; 350 & intersection.resize(1 + numberIntersection - skip.n); 351 & int j = 0; 352 & for(int i = 0; i < numberIntersection; ++i) { 353 & bool skipped = false; 354 & if(j < skip.n) { 355 & if(skip[j] == i) { 356 & ++j; 357 & skipped = true; 358 & } 359 & } 360 & if(!skipped) { 361 & IFMACRO(vectorialfe) 362 & fespace singleComponentWhPrivate(ThTab[0], vectorialfe); 363 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 364 & ENDIFMACRO IFMACRO(!vectorialfe) 365 & fespace singleComponentWhPrivate(ThTab[0], P1); 366 & fespace WhIntersectionPrivate(meshIntersection[i], P1); 367 & ENDIFMACRO matrix ThTabR = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 368 & ThTabR.thresholding(1.0e-10); 369 & real[int] ThTabC; 370 & int[int] ThTabI; 371 & [ThTabI, intersection[1 + i - j], ThTabC] = ThTabR; 372 & intersection[1 + i - j].resize(ThTabR.nbcoef); 373 & intersection[0][i - j] = intersection[0][i]; 374 & } 375 & } 376 & numberIntersection -= skip.n; 377 & intersection[0].resize(numberIntersection); 378 & if( fakeInterface != -111111 || overlap != 1) { 379 & PhGlobalPrivate suppPartition = khi > 0.1; 380 & AddLayers( ThGlobal, suppPartition[], 1, phi[]); 381 & ThBorderTab[0] = trunc( ThGlobal, phi > 0.001 && phi < 0.501, label = (abs( fakeInterface) + 1) * 100); 382 & } 383 & } 384 & ENDIFMACRO 284 @ if( 1 == 1 && 1 > 1 && !removeZeros) 285 @ for(int j = 1; j < 1; ++j) 286 @ for(int i = 0; i < numberIntersection; ++i) { 287 @ intersection[1 + i + j * numberIntersection].resize( intersection[1 + i].n); 288 @ intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 289 @ } 290 @ partitionIntersection.resize(0); 291 @ for(int i = 0; i < (trueRestrict ? 1 : 1 - 1); ++i) { 292 @ fespace VhRefinedPrivate(ThTab[i], P1); 293 @ fespace PhRefinedPrivate(ThTab[i], P0); 294 @ PhRefinedPrivate partRefined = partGlobal; 295 @ PhRefinedPrivate supp = abs(partRefined - mpiRank( mpiCommWorld)) < 0.1; 296 @ varf vSupp(u, v) = intNint2d(ThTab[i], qforder = 1)(supp * v); 297 @ VhRefinedPrivate khiL; 298 @ khiL[] = vSupp(0, VhRefinedPrivate); 299 @ khiL = khiL > 0.0; 300 @ VhRefinedPrivate sum = khiL; 301 @ for(int j = 0; j < numberIntersection; ++j) { 302 @ supp = abs(partRefined - intersection[0][j]) < 0.1; 303 @ VhRefinedPrivate phiL; 304 @ phiL[] = vSupp(0, VhRefinedPrivate); 305 @ phiL = phiL > 0.0; 306 @ sum[] += phiL[]; 307 @ } 308 @ khiL[] ./= sum[]; 309 @ if(i < 1 - 1) { 310 @ fespace WhRefinedPrivate(ThTab[i], P1); 311 @ WhRefinedPrivate defP1(func2vec) func2vec ; 312 @ defP1(func2vec) func2vec = initP1(khiL) khiL ; 313 @ DTab[i].resize(WhRefinedPrivate.ndof); 314 @ DTab[i] = func2vec[]; 315 @ } 316 @ else 317 @ khi[] = khiL[]; 318 @ } 319 @ if(!trueRestrict) 320 @ khi[] = khi[] ./= sum[]; 321 @ if(trueRestrict && mpiSize( mpiCommWorld) == mpiSize( mpiCommWorld) && removeZeros) { 322 @ assert( 1 == 1); 323 @ meshNmesh ThIntersection; 324 @ fespace PhIntersectionPrivate(ThIntersection, P0); 325 @ PhIntersectionPrivate[int] recv(numberIntersection); 326 @ PhIntersectionPrivate[int] send(numberIntersection); 327 @ mpiRequest[int] rq(2 * numberIntersection); 328 @ for(int i = 0; i < numberIntersection; ++i) { 329 @ ThIntersection = meshIntersection[i]; 330 @ Irecv(processor( intersection[0][i], mpiCommWorld, rq[i]), recv[i][]); 331 @ send[i] = khi; 332 @ Isend(processor( intersection[0][i], mpiCommWorld, rq[numberIntersection + i]), send[i][]); 333 @ } 334 @ ThTab[0] = trunc(ThTab[0], khi > 1.0e-6, label = 9999); 335 @ khi = khi; 336 @ int[int] skip(0); 337 @ for(int k = 0; k < 2 * numberIntersection; ++k) { 338 @ int i = mpiWaitAny(rq); 339 @ if(i < numberIntersection) { 340 @ ThIntersection = meshIntersection[i]; 341 @ PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 342 @ if( intersection[].l2 > 1.0e-6) 343 @ meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 344 @ else { 345 @ skip.resize(skip.n + 1); 346 @ skip[skip.n - 1] = i; 347 @ } 348 @ } 349 @ } 350 @ skip.sort; 351 @ intersection.resize(1 + numberIntersection - skip.n); 352 @ int j = 0; 353 @ for(int i = 0; i < numberIntersection; ++i) { 354 @ bool skipped = false; 355 @ if(j < skip.n) { 356 @ if(skip[j] == i) { 357 @ ++j; 358 @ skipped = true; 359 @ } 360 @ } 361 @ if(!skipped) { 362 @ IFMACRO(vectorialfe) 363 & fespace singleComponentWhPrivate(ThTab[0], vectorialfe); 364 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 365 & ENDIFMACRO 366 @ IFMACRO(!vectorialfe) 367 & fespace singleComponentWhPrivate(ThTab[0], P1); 368 & fespace WhIntersectionPrivate(meshIntersection[i], P1); 369 & ENDIFMACRO 367 @ fespace singleComponentWhPrivate(ThTab[0], P1); 368 @ fespace WhIntersectionPrivate(meshIntersection[i], P1); 369 @ 370 @ matrix ThTabR = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 371 @ ThTabR.thresholding(1.0e-10); 372 @ real[int] ThTabC; 373 @ int[int] ThTabI; 374 @ [ThTabI, intersection[1 + i - j], ThTabC] = ThTabR; 375 @ intersection[1 + i - j].resize(ThTabR.nbcoef); 376 @ intersection[0][i - j] = intersection[0][i]; 377 @ } 378 @ } 379 @ numberIntersection -= skip.n; 380 @ intersection[0].resize(numberIntersection); 381 @ if( fakeInterface != -111111 || overlap != 1) { 382 @ PhGlobalPrivate suppPartition = khi > 0.1; 383 @ AddLayers( ThGlobal, suppPartition[], 1, phi[]); 384 @ ThBorderTab[0] = trunc( ThGlobal, phi > 0.001 && phi < 0.501, label = (abs( fakeInterface) + 1) * 100); 385 @ } 386 @ } 387 @ 385 @ IFMACRO(vectorialfe) 386 & if( 1 > 1) 387 & for(int i = 0; i < intersection.n - 1; ++i) { 388 & int n = intersection[1 + i].n; 389 & intersection[1 + i].resize(n * 1); 390 & for(int j = n - 1; j != -1; --j) 391 & for(int k = 1 - 1; k != -1; --k) 392 & intersection[1 + i][j * 1 + k] = intersection[1 + i][j] * 1 + k; 393 & } 394 & ENDIFMACRO 395 @ 387 @ IFMACRO(privateCreatePartition) 388 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 389 & IFMACRO(!privateCreateMat) 390 & VhLocalPrivate khi; 391 & ENDIFMACRO ENDIFMACRO 392 @ IFMACRO(privateCreateMat) 393 & VhLocalPrivate khi; 394 & khi[] = privateDmeshthkhiDef[0]; 395 & ENDIFMACRO 396 @ fespace WhPartPrivate(ThTab[ 1 - 1], P1); 397 @ WhPartPrivate defP1(func2vec) func2vec ; 398 @ DTab[ 1 - 1].resize(WhPartPrivate.ndof); 399 @ if((WhPartPrivate.ndof % ThTab[ 1 - 1].nt) == 0) { 400 @ int constant = mpiRank( mpiCommWorld); 401 @ IFMACRO(privateCreateMat) 402 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 403 & PhLocalPrivate partLocal; 404 & partLocal[] = privateDmeshthkhiDef[1]; 405 & defP1(func2vec) = initP1(abs(partLocal - constant) < 0.1); 406 & ENDIFMACRO 407 @ IFMACRO(!privateCreateMat) 408 & defP1(func2vec) = initP1(abs( partGlobal - constant) < 0.1); 409 & ENDIFMACRO 408 @ defP1(func2vec) func2vec = initP1(abs( partGlobal - constant) < 0.1) abs( partGlobal - constant) < 0.1 ; 409 @ 410 @ } 411 @ else if(WhPartPrivate.ndof == ThTab[ 1 - 1].nv) { 412 @ func2vec[] = khi[]; 413 @ } 414 @ else { 415 @ defP1(func2vec) func2vec = initP1(khi) khi ; 416 @ } 417 @ DTab[ 1 - 1] = func2vec[]; 418 @ IFMACRO(!privateCreatePartition) 419 & IFMACRO(!privateCreateMat) 420 & IFMACRO(privateBuildDmesh) 421 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 422 & PhLocalPrivate partLocal; 423 & partLocal = partGlobal; 424 & privateDmeshthkhiDef[1].resize(partLocal[].n); 425 & privateDmeshthkhiDef[1] = partLocal[]; 426 & ENDIFMACRO ENDIFMACRO ENDIFMACRO 419 @ IFMACRO(!privateCreateMat) 420 & IFMACRO(privateBuildDmesh) 421 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 422 & PhLocalPrivate partLocal; 423 & partLocal = partGlobal; 424 & privateDmeshthkhiDef[1].resize(partLocal[].n); 425 & privateDmeshthkhiDef[1] = partLocal[]; 426 & ENDIFMACRO ENDIFMACRO 420 @ IFMACRO(privateBuildDmesh) 421 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 422 & PhLocalPrivate partLocal; 423 & partLocal = partGlobal; 424 & privateDmeshthkhiDef[1].resize(partLocal[].n); 425 & privateDmeshthkhiDef[1] = partLocal[]; 426 & ENDIFMACRO 421 @ fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 422 @ PhLocalPrivate partLocal; 423 @ partLocal = partGlobal; 424 @ privateDmeshthkhiDef[1].resize(partLocal[].n); 425 @ privateDmeshthkhiDef[1] = partLocal[]; 426 @ 427 @ 427 @ 427 @ searchMethod = backupSM; 428 @ } 841 @ 840 @ IFMACRO(!privateBuildDmesh) 841 & partitionPrivate(ThTab, ThBorderTab, ThGlobal, PhGlobalPrivate, VhGlobalPrivate, partGlobal, mpiRank( mpiCommWorld), mpiSize( mpiCommWorld), 1, overlap, 1, prolongation, DTab, P1, intersection, mpiCommWorld, fakeInterface, P1, def, init, 1) 842 & ENDIFMACRO 843 @ } 844 @ else if(mpiSize( mpiCommWorld) == 1) { 845 @ for(int i = 1 - 1; i > 0; --i) { 846 @ ThTab[i - 1] = trunc(ThTab[i], 1, split = 1); 847 @ fespace WhLocalRefinedPrivate(ThTab[i - 1], P1); 848 @ fespace WhLocalCoarsePrivate(ThTab[i], P1); 849 @ prolongation[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 850 @ DTab[i].resize(WhLocalCoarsePrivate.ndof); 851 @ DTab[i] = 1.0; 852 @ } 853 @ if( 1 == 1) { 854 @ IFMACRO(privateBuildDmesh) 855 & IFMACRO(privateDmeshN2O) 856 & if( 1 > 1) 857 & ThTab[0] = trunc(ThTab[0], 1, split = 1, new2old = n2oth); 858 & else { 859 & n2oth.resize(ThTab[0].nt); 860 & n2oth = 0:ThTab[0].nt-1; 861 & } 862 & ENDIFMACRO IFMACRO(!privateDmeshN2O) 863 & if( 1 > 1) 864 & ThTab[0] = trunc(ThTab[0], 1, split = 1); 865 & ENDIFMACRO ENDIFMACRO 855 @ IFMACRO(privateDmeshN2O) 856 & if( 1 > 1) 857 & ThTab[0] = trunc(ThTab[0], 1, split = 1, new2old = n2oth); 858 & else { 859 & n2oth.resize(ThTab[0].nt); 860 & n2oth = 0:ThTab[0].nt-1; 861 & } 862 & ENDIFMACRO 856 @ if( 1 > 1) -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 857 @ ThTab[0] = trunc(ThTab[0], 1, split = 1, new2old = n2oth); 858 @ else { 859 @ n2oth.resize(ThTab[0].nt); 860 @ n2oth = 0:ThTab[0].nt-1; 861 @ } 862 @ 863 @ IFMACRO(!privateDmeshN2O) 864 & if( 1 > 1) 865 & ThTab[0] = trunc(ThTab[0], 1, split = 1); 866 & ENDIFMACRO 867 @ 866 @ IFMACRO(!privateBuildDmesh) 867 & if( 1 > 1) 868 & ThTab[0] = trunc(ThTab[0], 1, split = 1); 869 & ENDIFMACRO 870 @ } 871 @ fespace WhLocalPrivate(ThTab[0], P1); 872 @ DTab[0].resize(WhLocalPrivate.ndof); 873 @ DTab[0] = 1.0; 874 @ } 875 @ if(verbosity > 0) { 876 @ mpiBarrier( mpiCommWorld); 877 @ if(mpiRank( mpiCommWorld) == 0) 878 @ cout.scientific << " --- partition of unity built (in " << mpiWtime() - timerPartition << ")" << endl; 879 @ } 880 @ } 879 @ th = ThTab[0]; 880 @ ThBorder = ThBorderTab[0]; 881 @ privateDmeshthkhiDef[0].resize(DTab[0].n); 882 @ privateDmeshthkhiDef[0] = DTab[0]; --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 883 @ } 1056 @ }; 516 @ 517 @ IFMACRO(!thUserPartitioning) 518 & IFMACRO(!thPeriodicity) 519 & IFMACRO(thCartesianPartitioning) 520 & NewMacro privateDmeshCartesianPartitioning() EndMacro ENDIFMACRO build(th, 1, intersection, privateDmeshthkhiDef[0], P1, mpiCommWorld); 521 & ENDIFMACRO ENDIFMACRO 518 @ IFMACRO(!thPeriodicity) 519 & IFMACRO(thCartesianPartitioning) 520 & NewMacro privateDmeshCartesianPartitioning() EndMacro ENDIFMACRO build(th, 1, intersection, privateDmeshthkhiDef[0], P1, mpiCommWorld); 521 & ENDIFMACRO 522 @ 522 @ } 523 @ 672 @ } 673 @ 674 @ NewMacro privateCreateMat()1 EndMacro 675 @ int[int][int] intersection; 676 @ real[int][int] DTab(1); 677 @ meshNmesh[int] ThTab(1); 678 @ ThTab[0] = th; 679 @ NewMacro privateDmeshThTab()privateDmeshth EndMacro 680 @ NewMacro privateDmeshThTabkhi()privateDmeshthkhiDef EndMacro 681 @ NewMacro privateDmeshThTabintersection()privateDmeshthintersectionDef EndMacro 682 @ IFMACRO(!def) 683 & NewMacro def(i)i EndMacro ENDIFMACRO 684 @ IFMACRO(!init) 685 & NewMacro init(i)i EndMacro ENDIFMACRO 686 @ if(mpiSize(thComm mpiCommWorld ) > 1) { 687 @ IFMACRO(thN2O) 688 & IFMACRO(thOriginal) 689 & IFMACRO(thRestriction) 690 & NewMacro privateDmeshN2O()n2oth EndMacro NewMacro privateDmeshOriginal()thOriginal EndMacro NewMacro privateDmeshRestriction()thRestriction EndMacro ENDIFMACRO ENDIFMACRO ENDIFMACRO 688 @ IFMACRO(thOriginal) 689 & IFMACRO(thRestriction) 690 & NewMacro privateDmeshN2O()n2oth EndMacro NewMacro privateDmeshOriginal()thOriginal EndMacro NewMacro privateDmeshRestriction()thRestriction EndMacro ENDIFMACRO ENDIFMACRO 691 @ 691 @ IFMACRO(!thPkPart) 692 & NewMacro thPkPart() Pk EndMacro ENDIFMACRO 692 @ NewMacro thPkPart() Pk EndMacro 693 @ 693 @ IFMACRO(thCartesianPartitioning) 694 & NewMacro privateDmeshCartesianPartitioning() EndMacro ENDIFMACRO 695 @ partitionPrivate(ThTab, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, privateCreateMat, mpiRank(thComm), mpiSize(thComm), 1, 1, 1, privateCreateMat, DTab, Pk, intersection, thComm, -111111, thPkPart, def, init, 1) 86 @ 87 @ 88 @ 89 @ 90 @ 91 @ 92 @ 93 @ 94 @ 95 @ 96 @ -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 97 @ 98 @ 99 @ 100 @ 101 @ 102 @ 103 @ 104 @ 105 @ 106 @ 107 @ 108 @ 109 @ 110 @ 111 @ 112 @ 113 @ 114 @ 115 @ 116 @ 117 @ 118 @ 119 @ 120 @ 121 @ 122 @ 123 @ 124 @ 125 @ 126 @ 127 @ 128 @ 129 @ 130 @ 131 @ 132 @ 133 @ 134 @ 135 @ 136 @ 137 @ 138 @ 139 @ 140 @ 141 @ 142 @ 143 @ -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 144 @ 145 @ 146 @ 147 @ 148 @ 149 @ 150 @ 151 @ 152 @ 153 @ 154 @ 155 @ 156 @ 157 @ 158 @ 159 @ 160 @ 161 @ 162 @ 163 @ 164 @ 165 @ 166 @ 167 @ 168 @ 169 @ 170 @ 171 @ 172 @ 173 @ 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ 186 @ 187 @ 188 @ 189 @ 190 @ 191 @ 192 @ 193 @ 194 @ 195 @ 196 @ 197 @ 198 @ 199 @ 200 @ 201 @ 202 @ 203 @ 204 @ 205 @ 206 @ 207 @ 208 @ 209 @ 210 @ 211 @ 212 @ 213 @ 214 @ 215 @ 216 @ 217 @ 218 @ 219 @ 220 @ 221 @ 222 @ 223 @ 224 @ 225 @ 226 @ 227 @ 228 @ 229 @ 230 @ 231 @ 232 @ 233 @ 234 @ 235 @ 236 @ 237 @ 238 @ 239 @ 240 @ 241 @ 242 @ 243 @ 244 @ 245 @ 246 @ 247 @ 248 @ 249 @ 250 @ 251 @ 252 @ 253 @ 254 @ 255 @ 256 @ 257 @ 258 @ 259 @ 260 @ 261 @ 262 @ 263 @ 264 @ 265 @ 266 @ 267 @ 268 @ 269 @ 270 @ 271 @ 272 @ 273 @ 274 @ 275 @ 276 @ 277 @ 278 @ 279 @ 280 @ 281 @ 282 @ 283 @ 284 @ 285 @ 286 @ 287 @ 288 @ 289 @ 290 @ 291 @ 292 @ 293 @ 294 @ 295 @ 296 @ 297 @ 298 @ 299 @ 300 @ 301 @ 302 @ 303 @ 304 @ 305 @ 306 @ 307 @ 308 @ 309 @ 310 @ 311 @ 312 @ 313 @ 314 @ 315 @ 316 @ 317 @ 318 @ 319 @ 320 @ 321 @ 322 @ 323 @ 324 @ 325 @ 326 @ 327 @ 328 @ 329 @ 330 @ 331 @ 332 @ 333 @ 334 @ 335 @ 336 @ 337 @ 338 @ 339 @ 340 @ 341 @ 342 @ 343 @ 344 @ 345 @ 346 @ 347 @ 348 @ 349 @ 350 @ 351 @ 352 @ 353 @ 354 @ 355 @ 356 @ 357 @ 358 @ 359 @ 360 @ 361 @ 362 @ 363 @ 364 @ 365 @ 366 @ 367 @ 368 @ 369 @ 370 @ 371 @ 372 @ 373 @ 374 @ 375 @ 376 @ 377 @ 378 @ 379 @ 380 @ 381 @ 382 @ 383 @ 384 @ 385 @ 386 @ 387 @ 388 @ 389 @ 390 @ 391 @ 392 @ 393 @ 394 @ 395 @ 396 @ 397 @ 398 @ 399 @ 400 @ 401 @ 402 @ 403 @ 404 @ 405 @ 406 @ 407 @ 408 @ 409 @ 410 @ 411 @ 412 @ 413 @ 414 @ 415 @ 416 @ 417 @ 418 @ 419 @ 420 @ 421 @ 422 @ 423 @ 424 @ 425 @ 426 @ 427 @ 428 @ 429 @ 430 @ 431 @ 432 @ 433 @ 434 @ 435 @ 436 @ 437 @ 438 @ 439 @ 440 @ 441 @ 442 @ 443 @ 444 @ 445 @ 446 @ 447 @ 448 @ 449 @ 450 @ 451 @ 452 @ 453 @ 454 @ 455 @ 456 @ 457 @ 458 @ 459 @ 460 @ 461 @ { 86 @ int backupSM = searchMethod; 87 @ searchMethod = 1; 88 @ assert( 1 >= 1); 89 @ IFMACRO(!privateCreatePartition) 90 & IFMACRO(!privateCreateMat) 91 & intersection.resize(1); 92 & intersection[0].resize(0); 93 & privateCreateMat supp; 94 & privateCreateMat suppSmooth; 95 & { 96 & int constant = mpiRank(thComm); 97 & for[i, v : supp[]] v = abs( privateCreateMat[][i] - constant) < 0.1; 98 & AddLayers( privateCreateMat, supp[], 2 * 1, suppSmooth[]); 99 & int[int] n2o; 100 & meshN neighbors; 101 & bool connected = false; 102 & for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 103 & if(!connected) 104 & n2o.resize(0); 105 & else neighbors = trunc( privateCreateMat, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 106 & int[int] partOverlap(n2o.n); 107 & for[i, v : n2o] partOverlap[i] = privateCreateMat[][v]; 108 & Unique(partOverlap, intersection[0], remove = constant); 109 & if( 1 > 1 && 1 <= 1) { 110 & privateCreateMat = trunc( privateCreateMat, suppSmooth > 0.001, split = 1); 111 & supp = abs( privateCreateMat - constant) < 0.1; 112 & suppSmooth = 0; 113 & AddLayers( privateCreateMat, supp[], 2 * 1, suppSmooth[]); 114 & } 115 & } 116 & int[int] n2oNeighbor; 117 & IFMACRO(!privateDmeshCartesianPartitioning) 118 & privateCreateMat = trunc( privateCreateMat, suppSmooth > 0.001, label = 9999 119 & IFMACRO(privateDmeshN2O) 120 & , new2old = n2oNeighbor ENDIFMACRO ); 121 & ENDIFMACRO real eps = privateCreateMat.measure; 122 & real[int] epsTab( intersection[0].n); 123 & mpiRequest[int] rq(2 * intersection[0].n); 124 & if(mpiSize( thComm) == mpiSize(thComm)) { 125 & for(int j = 0; j < intersection[0].n; ++j) 126 & Irecv(processor( intersection[0][j], thComm, rq[j]), epsTab[j]); 127 & for(int j = 0; j < intersection[0].n; ++j) 128 & Isend(processor( intersection[0][j], thComm, rq[ intersection[0].n + j]), eps); 129 & } 130 & else epsTab = 1.0e+30; 131 & suppSmooth = suppSmooth; 132 & IFMACRO(!privateDmeshN2O) 133 & ThTab[ 1 - 1] = trunc( privateCreateMat, suppSmooth > 0.501, label = -111111, new2old = n2oNeighbor); 134 & IFMACRO(privateDmeshCartesianPartitioning) 135 & real[int] bb(2 * dimension); 136 & boundingbox(ThTab[ 1 - 1], bb); 137 & ThTab[ 1 - 1] = trunc( privateCreateMat, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 138 & IFMACRO(dimension,3) 139 & && z > bb[4] && z < bb[5] 140 & ENDIFMACRO , label = -111111); 141 & privateCreateMat = ThTab[ 1 - 1]; 142 & n2oNeighbor = 0: privateCreateMat.nt - 1; 143 & ENDIFMACRO ENDIFMACRO IFMACRO(privateDmeshN2O) 144 & ThTab[ 1 - 1] = trunc( privateCreateMat, suppSmooth > 0.501, label = -111111, new2old = privateDmeshN2O); 145 & IFMACRO(privateDmeshCartesianPartitioning) 146 & real[int] bb(2 * dimension); 147 & boundingbox(ThTab[ 1 - 1], bb); 148 & ThTab[ 1 - 1] = trunc( privateCreateMat, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 149 & IFMACRO(dimension,3) 150 & && z > bb[4] && z < bb[5] 151 & ENDIFMACRO , label = -111111, new2old = privateDmeshN2O); 152 & privateCreateMat = ThTab[ 1 - 1]; 153 & n2oNeighbor = 0: privateCreateMat.nt - 1; 154 & ENDIFMACRO IFMACRO(!privateDmeshCartesianPartitioning) 155 & { 156 & int[int] backup = privateDmeshN2O; 157 & int[int] new = n2oNeighbor(privateDmeshN2O); 158 & privateDmeshN2O.resize(new.n); 159 & privateDmeshN2O = new; 160 & n2oNeighbor.resize(backup.n); 161 & n2oNeighbor = backup; 162 & } 163 & ENDIFMACRO ENDIFMACRO if( 1 > 1) { 164 & privateCreateMat.resize( 1 - 1); 165 & if( 1 > 1) { 166 & meshN globalNameRefined = privateCreateMat; 167 & for(int i = 1 - 1; i > 0; --i) { 168 & globalNameRefined = trunc(globalNameRefined, 1, split = 1); 169 & ThTab[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = -111111); 170 & fespace WhLocalRefinedPrivate(ThTab[i - 1], Pk); 171 & fespace WhLocalCoarsePrivate(ThTab[i], Pk); 172 & privateCreateMat[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 173 & } 174 & } 175 & else for(int i = 1 - 1; i > 0; --i) 176 & ThTab[i - 1] = ThTab[i]; 177 & } 178 & if(!removeZeros && ( -111111 != -111111 || 1 != 1)) { 179 & if(suppSmooth[].min < 0.501) { 180 & supp = supp; 181 & privateCreateMat[ 1 - 1] = trunc( privateCreateMat, (suppSmooth > ( 1 - 0.999) / real(2 * 1)) && (suppSmooth < 0.501), label = (abs( -111111) + 1) * 100); 182 & if( 1 > 1) 183 & for(int i = 1 - 2; i >= 0; --i) { 184 & privateCreateMat[i] = trunc( privateCreateMat[i + 1], 1, split = 1, label = (abs( -111111) + 1) * 100); 185 & meshN tempRefined = ThTab[i] + privateCreateMat[i]; 186 & fespace PhRefinedPrivate(tempRefined, P0); 187 & PhRefinedPrivate suppRefined = supp; 188 & fespace VhBorderRefinedPrivate( privateCreateMat[i], P1); 189 & VhBorderRefinedPrivate suppBorder = suppRefined; 190 & privateCreateMat[i] = trunc( privateCreateMat[i], suppBorder > 0.01); 191 & } 192 & else for(int i = 1 - 2; i >= 0; --i) 193 & privateCreateMat[i] = privateCreateMat[i + 1]; 194 & } 195 & } 196 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 197 & VhLocalPrivate[int] partitionIntersection( intersection[0].n); 198 & VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 199 & VhLocalPrivate sum = khi; 200 & privateCreateMat phi; 201 & privateCreateMat = privateCreateMat; 202 & int numberIntersection = 0; 203 & { 204 & int[int] restriction = restrict(VhLocalPrivate, privateCreateMat, n2oNeighbor); 205 & n2oNeighbor.resize(0); 206 & mpiWaitAll(rq); 207 & for(int i = 0; i < intersection[0].n; ++i) { 208 & privateCreateMat suppPartition = abs( privateCreateMat - intersection[0][i]) < 0.1; 209 & AddLayers( privateCreateMat, suppPartition[], 1, phi[]); 210 & if(min(eps, epsTab[i]) > 0.0) { 211 & if(intN( privateCreateMat)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 212 & partitionIntersection[numberIntersection][] = phi[](restriction); 213 & if(!trueRestrict) 214 & sum[] += partitionIntersection[numberIntersection][]; 215 & intersection[0][numberIntersection++] = intersection[0][i]; 216 & } 217 & } 218 & } 219 & } 220 & if(numberIntersection != intersection[0].n) 221 & intersection[0].resize(numberIntersection); 222 & intersection.resize(1 + 1 * numberIntersection); 223 & ENDIFMACRO IFMACRO(privateCreateMat) 224 & assert( 1 == 1); 225 & int numberIntersection = privateDmeshthintersectionDef.n - 1; 226 & intersection.resize(1 + 1 * numberIntersection); 227 & intersection[0].resize(numberIntersection); 228 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 229 & VhLocalPrivate[int] partitionIntersection(numberIntersection); 230 & for(int i = 0; i < numberIntersection; ++i) { 231 & intersection[0][i] = privateDmeshthintersectionDef[0][i]; 232 & partitionIntersection[i][] = privateDmeshthintersectionDef[1 + i]; 233 & } 234 & IFMACRO(privateDmeshN2O) 235 & IFMACRO(privateDmeshOriginal) 236 & IFMACRO(privateDmeshRestriction) 237 & { 238 & fespace WhLocalPrivate(ThTab[ 1 - 1], Pk); 239 & fespace WhOriginalPrivate(privateDmeshOriginal, Pk); 240 & privateDmeshRestriction.resize(WhOriginalPrivate.ndof); 241 & privateDmeshRestriction = restrict(WhLocalPrivate, WhOriginalPrivate, privateDmeshN2O); 242 & } 243 & ENDIFMACRO ENDIFMACRO ENDIFMACRO ENDIFMACRO IFMACRO(privateBuildDmesh) 244 & privateDmeshthintersectionDef.resize(1 + numberIntersection); 245 & privateDmeshthintersectionDef[0].resize(numberIntersection); 246 & for(int i = 0; i < numberIntersection; ++i) { 247 & privateDmeshthintersectionDef[0][i] = intersection[0][i]; 248 & privateDmeshthintersectionDef[1 + i].resize(VhLocalPrivate.ndof); 249 & privateDmeshthintersectionDef[1 + i] = partitionIntersection[i][]; 250 & } 251 & ENDIFMACRO meshN[int] meshIntersection(numberIntersection); 252 & for(int j = 0; j < ( 1 == 1 ? 1 : 1); ++j) { 253 & for(int i = 0; i < numberIntersection; ++i) { 254 & int[int] n2o; 255 & meshIntersection[i] = trunc(ThTab[j], partitionIntersection[i] > 1.0e-6, new2old = n2o, label = 9999); 256 & IFMACRO(privateDmeshCartesianPartitioning) 257 & real[int] bb(2 * dimension); 258 & boundingbox(meshIntersection[i], bb); 259 & meshIntersection[i] = trunc(ThTab[j], x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 260 & IFMACRO(dimension,3) 261 & && z > bb[4] && z < bb[5] 262 & ENDIFMACRO , new2old = n2o, label = 9999); 263 & ENDIFMACRO IFMACRO(!privateCreateMat) 264 & if(!removeZeros) 265 & ENDIFMACRO { 266 & IFMACRO(vectorialfe) 267 & fespace singleComponentWhPrivate(ThTab[j], vectorialfe); 268 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 269 & ENDIFMACRO IFMACRO(!vectorialfe) 270 & fespace singleComponentWhPrivate(ThTab[j], Pk); 271 & fespace WhIntersectionPrivate(meshIntersection[i], Pk); 272 & ENDIFMACRO intersection[1 + i + j * numberIntersection] = restrict(WhIntersectionPrivate, singleComponentWhPrivate, n2o); 273 & } 274 & } 275 & } 276 & IFMACRO(!privateCreateMat) 277 & if( 1 == 1 && 1 > 1 && !removeZeros) 278 & for(int j = 1; j < 1; ++j) 279 & for(int i = 0; i < numberIntersection; ++i) { 280 & intersection[1 + i + j * numberIntersection].resize( intersection[1 + i].n); 281 & intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 282 & } 283 & partitionIntersection.resize(0); 284 & for(int i = 0; i < (trueRestrict ? 1 : 1 - 1); ++i) { 285 & fespace VhRefinedPrivate(ThTab[i], P1); 286 & fespace PhRefinedPrivate(ThTab[i], P0); 287 & PhRefinedPrivate partRefined = privateCreateMat; 288 & PhRefinedPrivate supp = abs(partRefined - mpiRank(thComm)) < 0.1; 289 & varf vSupp(u, v) = intN(ThTab[i], qforder = 1)(supp * v); 290 & VhRefinedPrivate khiL; 291 & khiL[] = vSupp(0, VhRefinedPrivate); 292 & khiL = khiL > 0.0; 293 & VhRefinedPrivate sum = khiL; 294 & for(int j = 0; j < numberIntersection; ++j) { 295 & supp = abs(partRefined - intersection[0][j]) < 0.1; 296 & VhRefinedPrivate phiL; 297 & phiL[] = vSupp(0, VhRefinedPrivate); 298 & phiL = phiL > 0.0; 299 & sum[] += phiL[]; 300 & } 301 & khiL[] ./= sum[]; 302 & if(i < 1 - 1) { 303 & fespace WhRefinedPrivate(ThTab[i], thPkPart); 304 & WhRefinedPrivate def(func2vec); 305 & def(func2vec) = init(khiL); 306 & DTab[i].resize(WhRefinedPrivate.ndof); 307 & DTab[i] = func2vec[]; 308 & } 309 & else khi[] = khiL[]; 310 & } 311 & if(!trueRestrict) 312 & khi[] = khi[] ./= sum[]; 313 & if(trueRestrict && mpiSize( thComm) == mpiSize(thComm) && removeZeros) { 314 & assert( 1 == 1); 315 & meshN ThIntersection; 316 & fespace PhIntersectionPrivate(ThIntersection, P0); 317 & PhIntersectionPrivate[int] recv(numberIntersection); 318 & PhIntersectionPrivate[int] send(numberIntersection); 319 & mpiRequest[int] rq(2 * numberIntersection); 320 & for(int i = 0; i < numberIntersection; ++i) { 321 & ThIntersection = meshIntersection[i]; 322 & Irecv(processor( intersection[0][i], thComm, rq[i]), recv[i][]); 323 & send[i] = khi; 324 & Isend(processor( intersection[0][i], thComm, rq[numberIntersection + i]), send[i][]); 325 & } 326 & ThTab[0] = trunc(ThTab[0], khi > 1.0e-6, label = 9999); 327 & khi = khi; 328 & int[int] skip(0); 329 & for(int k = 0; k < 2 * numberIntersection; ++k) { 330 & int i = mpiWaitAny(rq); 331 & if(i < numberIntersection) { 332 & ThIntersection = meshIntersection[i]; 333 & PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 334 & if( intersection[].l2 > 1.0e-6) 335 & meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 336 & else { 337 & skip.resize(skip.n + 1); 338 & skip[skip.n - 1] = i; 339 & } 340 & } 341 & } 342 & skip.sort; 343 & intersection.resize(1 + numberIntersection - skip.n); 344 & int j = 0; 345 & for(int i = 0; i < numberIntersection; ++i) { 346 & bool skipped = false; 347 & if(j < skip.n) { 348 & if(skip[j] == i) { 349 & ++j; 350 & skipped = true; 351 & } 352 & } 353 & if(!skipped) { 354 & IFMACRO(vectorialfe) 355 & fespace singleComponentWhPrivate(ThTab[0], vectorialfe); 356 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 357 & ENDIFMACRO IFMACRO(!vectorialfe) 358 & fespace singleComponentWhPrivate(ThTab[0], Pk); 359 & fespace WhIntersectionPrivate(meshIntersection[i], Pk); 360 & ENDIFMACRO matrix ThTabR = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 361 & ThTabR.thresholding(1.0e-10); 362 & real[int] ThTabC; 363 & int[int] ThTabI; 364 & [ThTabI, intersection[1 + i - j], ThTabC] = ThTabR; 365 & intersection[1 + i - j].resize(ThTabR.nbcoef); 366 & intersection[0][i - j] = intersection[0][i]; 367 & } 368 & } 369 & numberIntersection -= skip.n; 370 & intersection[0].resize(numberIntersection); 371 & if( -111111 != -111111 || 1 != 1) { 372 & privateCreateMat suppPartition = khi > 0.1; 373 & AddLayers( privateCreateMat, suppPartition[], 1, phi[]); 374 & privateCreateMat[0] = trunc( privateCreateMat, phi > 0.001 && phi < 0.501, label = (abs( -111111) + 1) * 100); 375 & } 376 & } 377 & ENDIFMACRO IFMACRO(vectorialfe) 378 & if( 1 > 1) 379 & for(int i = 0; i < intersection.n - 1; ++i) { 380 & int n = intersection[1 + i].n; 381 & intersection[1 + i].resize(n * 1); 382 & for(int j = n - 1; j != -1; --j) 383 & for(int k = 1 - 1; k != -1; --k) 384 & intersection[1 + i][j * 1 + k] = intersection[1 + i][j] * 1 + k; 385 & } 386 & ENDIFMACRO ENDIFMACRO 90 @ IFMACRO(!privateCreateMat) 91 & intersection.resize(1); 92 & intersection[0].resize(0); 93 & privateCreateMat supp; 94 & privateCreateMat suppSmooth; 95 & { 96 & int constant = mpiRank(thComm); 97 & for[i, v : supp[]] v = abs( privateCreateMat[][i] - constant) < 0.1; 98 & AddLayers( privateCreateMat, supp[], 2 * 1, suppSmooth[]); 99 & int[int] n2o; 100 & meshN neighbors; 101 & bool connected = false; 102 & for[i, v : suppSmooth[]] if(abs(v - 0.5) < 0.5) connected = true; 103 & if(!connected) 104 & n2o.resize(0); 105 & else neighbors = trunc( privateCreateMat, suppSmooth > 0.001 && suppSmooth < 0.999, new2old = n2o); 106 & int[int] partOverlap(n2o.n); 107 & for[i, v : n2o] partOverlap[i] = privateCreateMat[][v]; 108 & Unique(partOverlap, intersection[0], remove = constant); 109 & if( 1 > 1 && 1 <= 1) { 110 & privateCreateMat = trunc( privateCreateMat, suppSmooth > 0.001, split = 1); 111 & supp = abs( privateCreateMat - constant) < 0.1; 112 & suppSmooth = 0; 113 & AddLayers( privateCreateMat, supp[], 2 * 1, suppSmooth[]); 114 & } 115 & } 116 & int[int] n2oNeighbor; 117 & IFMACRO(!privateDmeshCartesianPartitioning) 118 & privateCreateMat = trunc( privateCreateMat, suppSmooth > 0.001, label = 9999 119 & IFMACRO(privateDmeshN2O) 120 & , new2old = n2oNeighbor ENDIFMACRO ); 121 & ENDIFMACRO real eps = privateCreateMat.measure; 122 & real[int] epsTab( intersection[0].n); 123 & mpiRequest[int] rq(2 * intersection[0].n); 124 & if(mpiSize( thComm) == mpiSize(thComm)) { 125 & for(int j = 0; j < intersection[0].n; ++j) 126 & Irecv(processor( intersection[0][j], thComm, rq[j]), epsTab[j]); 127 & for(int j = 0; j < intersection[0].n; ++j) 128 & Isend(processor( intersection[0][j], thComm, rq[ intersection[0].n + j]), eps); 129 & } 130 & else epsTab = 1.0e+30; 131 & suppSmooth = suppSmooth; 132 & IFMACRO(!privateDmeshN2O) 133 & ThTab[ 1 - 1] = trunc( privateCreateMat, suppSmooth > 0.501, label = -111111, new2old = n2oNeighbor); 134 & IFMACRO(privateDmeshCartesianPartitioning) 135 & real[int] bb(2 * dimension); 136 & boundingbox(ThTab[ 1 - 1], bb); 137 & ThTab[ 1 - 1] = trunc( privateCreateMat, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 138 & IFMACRO(dimension,3) 139 & && z > bb[4] && z < bb[5] 140 & ENDIFMACRO , label = -111111); 141 & privateCreateMat = ThTab[ 1 - 1]; 142 & n2oNeighbor = 0: privateCreateMat.nt - 1; 143 & ENDIFMACRO ENDIFMACRO IFMACRO(privateDmeshN2O) 144 & ThTab[ 1 - 1] = trunc( privateCreateMat, suppSmooth > 0.501, label = -111111, new2old = privateDmeshN2O); 145 & IFMACRO(privateDmeshCartesianPartitioning) 146 & real[int] bb(2 * dimension); 147 & boundingbox(ThTab[ 1 - 1], bb); 148 & ThTab[ 1 - 1] = trunc( privateCreateMat, x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 149 & IFMACRO(dimension,3) 150 & && z > bb[4] && z < bb[5] 151 & ENDIFMACRO , label = -111111, new2old = privateDmeshN2O); 152 & privateCreateMat = ThTab[ 1 - 1]; 153 & n2oNeighbor = 0: privateCreateMat.nt - 1; 154 & ENDIFMACRO IFMACRO(!privateDmeshCartesianPartitioning) 155 & { 156 & int[int] backup = privateDmeshN2O; 157 & int[int] new = n2oNeighbor(privateDmeshN2O); 158 & privateDmeshN2O.resize(new.n); 159 & privateDmeshN2O = new; 160 & n2oNeighbor.resize(backup.n); 161 & n2oNeighbor = backup; 162 & } 163 & ENDIFMACRO ENDIFMACRO if( 1 > 1) { 164 & privateCreateMat.resize( 1 - 1); 165 & if( 1 > 1) { 166 & meshN globalNameRefined = privateCreateMat; 167 & for(int i = 1 - 1; i > 0; --i) { 168 & globalNameRefined = trunc(globalNameRefined, 1, split = 1); 169 & ThTab[i - 1] = trunc(globalNameRefined, suppSmooth > 0.501, label = -111111); 170 & fespace WhLocalRefinedPrivate(ThTab[i - 1], Pk); 171 & fespace WhLocalCoarsePrivate(ThTab[i], Pk); 172 & privateCreateMat[i - 1] = interpolate(WhLocalRefinedPrivate, WhLocalCoarsePrivate); 173 & } 174 & } 175 & else for(int i = 1 - 1; i > 0; --i) 176 & ThTab[i - 1] = ThTab[i]; 177 & } 178 & if(!removeZeros && ( -111111 != -111111 || 1 != 1)) { 179 & if(suppSmooth[].min < 0.501) { 180 & supp = supp; 181 & privateCreateMat[ 1 - 1] = trunc( privateCreateMat, (suppSmooth > ( 1 - 0.999) / real(2 * 1)) && (suppSmooth < 0.501), label = (abs( -111111) + 1) * 100); 182 & if( 1 > 1) 183 & for(int i = 1 - 2; i >= 0; --i) { 184 & privateCreateMat[i] = trunc( privateCreateMat[i + 1], 1, split = 1, label = (abs( -111111) + 1) * 100); 185 & meshN tempRefined = ThTab[i] + privateCreateMat[i]; 186 & fespace PhRefinedPrivate(tempRefined, P0); 187 & PhRefinedPrivate suppRefined = supp; 188 & fespace VhBorderRefinedPrivate( privateCreateMat[i], P1); 189 & VhBorderRefinedPrivate suppBorder = suppRefined; 190 & privateCreateMat[i] = trunc( privateCreateMat[i], suppBorder > 0.01); 191 & } 192 & else for(int i = 1 - 2; i >= 0; --i) 193 & privateCreateMat[i] = privateCreateMat[i + 1]; 194 & } 195 & } 196 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 197 & VhLocalPrivate[int] partitionIntersection( intersection[0].n); 198 & VhLocalPrivate khi = max(2 * suppSmooth - 1.0, 0.0); 199 & VhLocalPrivate sum = khi; 200 & privateCreateMat phi; 201 & privateCreateMat = privateCreateMat; 202 & int numberIntersection = 0; 203 & { 204 & int[int] restriction = restrict(VhLocalPrivate, privateCreateMat, n2oNeighbor); 205 & n2oNeighbor.resize(0); 206 & mpiWaitAll(rq); 207 & for(int i = 0; i < intersection[0].n; ++i) { 208 & privateCreateMat suppPartition = abs( privateCreateMat - intersection[0][i]) < 0.1; 209 & AddLayers( privateCreateMat, suppPartition[], 1, phi[]); 210 & if(min(eps, epsTab[i]) > 0.0) { 211 & if(intN( privateCreateMat)(phi) / min(eps, epsTab[i]) > 1.0e-10) { 212 & partitionIntersection[numberIntersection][] = phi[](restriction); 213 & if(!trueRestrict) 214 & sum[] += partitionIntersection[numberIntersection][]; 215 & intersection[0][numberIntersection++] = intersection[0][i]; 216 & } 217 & } 218 & } 219 & } 220 & if(numberIntersection != intersection[0].n) 221 & intersection[0].resize(numberIntersection); 222 & intersection.resize(1 + 1 * numberIntersection); 223 & ENDIFMACRO 224 @ IFMACRO(privateCreateMat) 225 & assert( 1 == 1); 226 & int numberIntersection = privateDmeshthintersectionDef.n - 1; 227 & intersection.resize(1 + 1 * numberIntersection); 228 & intersection[0].resize(numberIntersection); 229 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 230 & VhLocalPrivate[int] partitionIntersection(numberIntersection); 231 & for(int i = 0; i < numberIntersection; ++i) { 232 & intersection[0][i] = privateDmeshthintersectionDef[0][i]; 233 & partitionIntersection[i][] = privateDmeshthintersectionDef[1 + i]; 234 & } 235 & IFMACRO(privateDmeshN2O) 236 & IFMACRO(privateDmeshOriginal) 237 & IFMACRO(privateDmeshRestriction) 238 & { 239 & fespace WhLocalPrivate(ThTab[ 1 - 1], Pk); 240 & fespace WhOriginalPrivate(privateDmeshOriginal, Pk); 241 & privateDmeshRestriction.resize(WhOriginalPrivate.ndof); 242 & privateDmeshRestriction = restrict(WhLocalPrivate, WhOriginalPrivate, privateDmeshN2O); 243 & } 244 & ENDIFMACRO ENDIFMACRO ENDIFMACRO ENDIFMACRO 225 @ assert( 1 == 1); 226 @ int numberIntersection = privateDmeshthintersectionDef.n - 1; 227 @ intersection.resize(1 + 1 * numberIntersection); 228 @ intersection[0].resize(numberIntersection); 229 @ fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 230 @ VhLocalPrivate[int] partitionIntersection(numberIntersection); 231 @ for(int i = 0; i < numberIntersection; ++i) { 232 @ intersection[0][i] = privateDmeshthintersectionDef[0][i]; 233 @ partitionIntersection[i][] = privateDmeshthintersectionDef[1 + i]; 234 @ } 235 @ IFMACRO(privateDmeshN2O) 236 & IFMACRO(privateDmeshOriginal) 237 & IFMACRO(privateDmeshRestriction) 238 & { 239 & fespace WhLocalPrivate(ThTab[ 1 - 1], Pk); 240 & fespace WhOriginalPrivate(privateDmeshOriginal, Pk); 241 & privateDmeshRestriction.resize(WhOriginalPrivate.ndof); 242 & privateDmeshRestriction = restrict(WhLocalPrivate, WhOriginalPrivate, privateDmeshN2O); 243 & } 244 & ENDIFMACRO ENDIFMACRO ENDIFMACRO 245 @ 245 @ IFMACRO(privateBuildDmesh) 246 & privateDmeshthintersectionDef.resize(1 + numberIntersection); 247 & privateDmeshthintersectionDef[0].resize(numberIntersection); 248 & for(int i = 0; i < numberIntersection; ++i) { 249 & privateDmeshthintersectionDef[0][i] = intersection[0][i]; 250 & privateDmeshthintersectionDef[1 + i].resize(VhLocalPrivate.ndof); 251 & privateDmeshthintersectionDef[1 + i] = partitionIntersection[i][]; 252 & } 253 & ENDIFMACRO 254 @ meshNmesh[int] meshIntersection(numberIntersection); 255 @ for(int j = 0; j < ( 1 == 1 ? 1 : 1); ++j) { 256 @ for(int i = 0; i < numberIntersection; ++i) { 257 @ int[int] n2o; 258 @ meshIntersection[i] = trunc(ThTab[j], partitionIntersection[i] > 1.0e-6, new2old = n2o, label = 9999); 259 @ IFMACRO(privateDmeshCartesianPartitioning) 260 & real[int] bb(2 * dimension); 261 & boundingbox(meshIntersection[i], bb); 262 & meshIntersection[i] = trunc(ThTab[j], x > bb[0] && x < bb[1] && y > bb[2] && y < bb[3] 263 & IFMACRO(dimension,3) 264 & && z > bb[4] && z < bb[5] 265 & ENDIFMACRO , new2old = n2o, label = 9999); 266 & ENDIFMACRO 267 @ IFMACRO(!privateCreateMat) 268 & if(!removeZeros) 269 & ENDIFMACRO 270 @ { 271 @ IFMACRO(vectorialfe) 272 & fespace singleComponentWhPrivate(ThTab[j], vectorialfe); 273 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 274 & ENDIFMACRO 275 @ IFMACRO(!vectorialfe) 276 & fespace singleComponentWhPrivate(ThTab[j], Pk); 277 & fespace WhIntersectionPrivate(meshIntersection[i], Pk); 278 & ENDIFMACRO 276 @ fespace singleComponentWhPrivate(ThTab[j], Pk [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 277 @ fespace WhIntersectionPrivate(meshIntersection[i], Pk [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 278 @ 279 @ intersection[1 + i + j * numberIntersection] = restrict(WhIntersectionPrivate, singleComponentWhPrivate, n2o); 280 @ } 281 @ } 282 @ } 283 @ IFMACRO(!privateCreateMat) 284 & if( 1 == 1 && 1 > 1 && !removeZeros) 285 & for(int j = 1; j < 1; ++j) 286 & for(int i = 0; i < numberIntersection; ++i) { 287 & intersection[1 + i + j * numberIntersection].resize( intersection[1 + i].n); 288 & intersection[1 + i + j * numberIntersection] = intersection[1 + i]; 289 & } 290 & partitionIntersection.resize(0); 291 & for(int i = 0; i < (trueRestrict ? 1 : 1 - 1); ++i) { 292 & fespace VhRefinedPrivate(ThTab[i], P1); 293 & fespace PhRefinedPrivate(ThTab[i], P0); 294 & PhRefinedPrivate partRefined = privateCreateMat; 295 & PhRefinedPrivate supp = abs(partRefined - mpiRank(thComm)) < 0.1; 296 & varf vSupp(u, v) = intN(ThTab[i], qforder = 1)(supp * v); 297 & VhRefinedPrivate khiL; 298 & khiL[] = vSupp(0, VhRefinedPrivate); 299 & khiL = khiL > 0.0; 300 & VhRefinedPrivate sum = khiL; 301 & for(int j = 0; j < numberIntersection; ++j) { 302 & supp = abs(partRefined - intersection[0][j]) < 0.1; 303 & VhRefinedPrivate phiL; 304 & phiL[] = vSupp(0, VhRefinedPrivate); 305 & phiL = phiL > 0.0; 306 & sum[] += phiL[]; 307 & } 308 & khiL[] ./= sum[]; 309 & if(i < 1 - 1) { 310 & fespace WhRefinedPrivate(ThTab[i], thPkPart); 311 & WhRefinedPrivate def(func2vec); 312 & def(func2vec) = init(khiL); 313 & DTab[i].resize(WhRefinedPrivate.ndof); 314 & DTab[i] = func2vec[]; 315 & } 316 & else khi[] = khiL[]; 317 & } 318 & if(!trueRestrict) 319 & khi[] = khi[] ./= sum[]; 320 & if(trueRestrict && mpiSize( thComm) == mpiSize(thComm) && removeZeros) { 321 & assert( 1 == 1); 322 & meshN ThIntersection; 323 & fespace PhIntersectionPrivate(ThIntersection, P0); 324 & PhIntersectionPrivate[int] recv(numberIntersection); 325 & PhIntersectionPrivate[int] send(numberIntersection); 326 & mpiRequest[int] rq(2 * numberIntersection); 327 & for(int i = 0; i < numberIntersection; ++i) { 328 & ThIntersection = meshIntersection[i]; 329 & Irecv(processor( intersection[0][i], thComm, rq[i]), recv[i][]); 330 & send[i] = khi; 331 & Isend(processor( intersection[0][i], thComm, rq[numberIntersection + i]), send[i][]); 332 & } 333 & ThTab[0] = trunc(ThTab[0], khi > 1.0e-6, label = 9999); 334 & khi = khi; 335 & int[int] skip(0); 336 & for(int k = 0; k < 2 * numberIntersection; ++k) { 337 & int i = mpiWaitAny(rq); 338 & if(i < numberIntersection) { 339 & ThIntersection = meshIntersection[i]; 340 & PhIntersectionPrivate intersection = send[i] > 1.0e-6 && recv[i] > 1.0e-6; 341 & if( intersection[].l2 > 1.0e-6) 342 & meshIntersection[i] = trunc(meshIntersection[i], intersection > 1.0e-6, label = 9999); 343 & else { 344 & skip.resize(skip.n + 1); 345 & skip[skip.n - 1] = i; 346 & } 347 & } 348 & } 349 & skip.sort; 350 & intersection.resize(1 + numberIntersection - skip.n); 351 & int j = 0; 352 & for(int i = 0; i < numberIntersection; ++i) { 353 & bool skipped = false; 354 & if(j < skip.n) { 355 & if(skip[j] == i) { 356 & ++j; 357 & skipped = true; 358 & } 359 & } 360 & if(!skipped) { 361 & IFMACRO(vectorialfe) 362 & fespace singleComponentWhPrivate(ThTab[0], vectorialfe); 363 & fespace WhIntersectionPrivate(meshIntersection[i], vectorialfe); 364 & ENDIFMACRO IFMACRO(!vectorialfe) 365 & fespace singleComponentWhPrivate(ThTab[0], Pk); 366 & fespace WhIntersectionPrivate(meshIntersection[i], Pk); 367 & ENDIFMACRO matrix ThTabR = interpolate(WhIntersectionPrivate, singleComponentWhPrivate); 368 & ThTabR.thresholding(1.0e-10); 369 & real[int] ThTabC; 370 & int[int] ThTabI; 371 & [ThTabI, intersection[1 + i - j], ThTabC] = ThTabR; 372 & intersection[1 + i - j].resize(ThTabR.nbcoef); 373 & intersection[0][i - j] = intersection[0][i]; 374 & } 375 & } 376 & numberIntersection -= skip.n; 377 & intersection[0].resize(numberIntersection); 378 & if( -111111 != -111111 || 1 != 1) { 379 & privateCreateMat suppPartition = khi > 0.1; 380 & AddLayers( privateCreateMat, suppPartition[], 1, phi[]); 381 & privateCreateMat[0] = trunc( privateCreateMat, phi > 0.001 && phi < 0.501, label = (abs( -111111) + 1) * 100); 382 & } 383 & } 384 & ENDIFMACRO 385 @ IFMACRO(vectorialfe) 386 & if( 1 > 1) 387 & for(int i = 0; i < intersection.n - 1; ++i) { 388 & int n = intersection[1 + i].n; 389 & intersection[1 + i].resize(n * 1); 390 & for(int j = n - 1; j != -1; --j) 391 & for(int k = 1 - 1; k != -1; --k) 392 & intersection[1 + i][j * 1 + k] = intersection[1 + i][j] * 1 + k; 393 & } 394 & ENDIFMACRO 395 @ 387 @ IFMACRO(privateCreatePartition) 388 & fespace VhLocalPrivate(ThTab[ 1 - 1], P1); 389 & IFMACRO(!privateCreateMat) 390 & VhLocalPrivate khi; 391 & ENDIFMACRO ENDIFMACRO 392 @ IFMACRO(privateCreateMat) 393 & VhLocalPrivate khi; 394 & khi[] = privateDmeshthkhiDef[0]; 395 & ENDIFMACRO 393 @ VhLocalPrivate khi; 394 @ khi[] = privateDmeshthkhiDef[0]; 395 @ 396 @ fespace WhPartPrivate(ThTab[ 1 - 1], thPkPart Pk [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]] ); 397 @ WhPartPrivate def(func2vec) gendef(func2vec) [func2vec, func2vecB, func2vecC, func2vecD] ; 398 @ DTab[ 1 - 1].resize(WhPartPrivate.ndof); 399 @ if((WhPartPrivate.ndof % ThTab[ 1 - 1].nt) == 0) { 400 @ int constant = mpiRank(thComm mpiCommWorld ); 401 @ IFMACRO(privateCreateMat) 402 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 403 & PhLocalPrivate partLocal; 404 & partLocal[] = privateDmeshthkhiDef[1]; 405 & def(func2vec) = init(abs(partLocal - constant) < 0.1); 406 & ENDIFMACRO 402 @ fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 403 @ PhLocalPrivate partLocal; 404 @ partLocal[] = privateDmeshthkhiDef[1]; 405 @ def(func2vec) gendef(func2vec) [func2vec, func2vecB, func2vecC, func2vecD] = init(abs(partLocal - constant) < 0.1) geninit(abs(partLocal - constant) < 0.1)[abs(partLocal - constant) < 0.1,abs(partLocal - constant) < 0.1,abs(partLocal - constant) < 0.1,abs(partLocal - constant) < 0.1] ; 406 @ 407 @ IFMACRO(!privateCreateMat) 408 & def(func2vec) = init(abs( privateCreateMat - constant) < 0.1); 409 & ENDIFMACRO 410 @ } 411 @ else if(WhPartPrivate.ndof == ThTab[ 1 - 1].nv) { 412 @ func2vec[] = khi[]; 413 @ } 414 @ else { 415 @ def(func2vec) gendef(func2vec) [func2vec, func2vecB, func2vecC, func2vecD] = init(khi) geninit(khi)[khi,khi,khi,khi] ; 416 @ } 417 @ DTab[ 1 - 1] = func2vec[]; 418 @ IFMACRO(!privateCreatePartition) 419 & IFMACRO(!privateCreateMat) 420 & IFMACRO(privateBuildDmesh) 421 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 422 & PhLocalPrivate partLocal; 423 & partLocal = privateCreateMat; 424 & privateDmeshthkhiDef[1].resize(partLocal[].n); 425 & privateDmeshthkhiDef[1] = partLocal[]; 426 & ENDIFMACRO ENDIFMACRO ENDIFMACRO 419 @ IFMACRO(!privateCreateMat) 420 & IFMACRO(privateBuildDmesh) 421 & fespace PhLocalPrivate(ThTab[ 1 - 1], P0); 422 & PhLocalPrivate partLocal; 423 & partLocal = privateCreateMat; 424 & privateDmeshthkhiDef[1].resize(partLocal[].n); 425 & privateDmeshthkhiDef[1] = partLocal[]; 426 & ENDIFMACRO ENDIFMACRO 427 @ 427 @ searchMethod = backupSM; 428 @ } 696 @ } 697 @ else { 698 @ fespace WhGlobalPrivate(th, Pk [P2,P2,P2,P1], periodic=[[labPeriodic[0],y], [labPeriodic[1],y]]); 699 @ DTab[0].resize(WhGlobalPrivate.ndof); 700 @ DTab[0] = 1; 701 @ intersection.resize(0); 702 @ IFMACRO(thN2O) 703 & IFMACRO(thOriginal) 704 & IFMACRO(thRestriction) 705 & thRestriction.resize(WhGlobalPrivate.ndof); 706 & thRestriction = 0:WhGlobalPrivate.ndof - 1; 707 & ENDIFMACRO ENDIFMACRO ENDIFMACRO 703 @ IFMACRO(thOriginal) 704 & IFMACRO(thRestriction) 705 & thRestriction.resize(WhGlobalPrivate.ndof); 706 & thRestriction = 0:WhGlobalPrivate.ndof - 1; 707 & ENDIFMACRO ENDIFMACRO 708 @ 708 @ } 709 @ IFMACRO(!privateCreatePartition) 710 & constructor( dJ, DTab[0].n, intersection, DTab[0], communicator = thComm); 711 & ENDIFMACRO 710 @ constructor( dJ, DTab[0].n, intersection, DTab[0], communicator = thComm mpiCommWorld ); 711 @ 712 @ IFMACRO(privateCreatePartition) 713 & privateCreatePartition.resize(DTab[0].n); 714 & privateCreatePartition = DTab[0]; 715 & ENDIFMACRO 716 @ } 717 @ 703 @ IFMACRO(!privateDmeshth) 704 & buildDmesh(th) 705 & { 706 & IFMACRO(!meshN) 707 & IFMACRO(dimension,3) 708 & NewMacro meshN()mesh3 EndMacro /* three-dimensional problem */ 709 & NewMacro intN()int3d EndMacro /* three-dimensional integral */ 710 & ENDIFMACRO IFMACRO(dimension,3S) 711 & NewMacro meshN()meshS EndMacro /* three-dimensional surface problem */ 712 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 713 & ENDIFMACRO IFMACRO(dimension,3L) 714 & NewMacro meshN()meshL EndMacro /* three-dimensional line problem */ 715 & NewMacro intN()int1d EndMacro /* one-dimensional integral */ 716 & ENDIFMACRO IFMACRO(!meshN) 717 & NewMacro meshN()mesh EndMacro /* two-dimensional problem */ 718 & NewMacro intN()int2d EndMacro /* two-dimensional integral */ 719 & ENDIFMACRO ENDIFMACRO NewMacro privateCreateMatCheckDmesh()1 EndMacro createMat(th, dJ, Pk) 720 & } 721 & ENDIFMACRO 722 @ 307 @ 308 @ } 21 : 22 : /* resizing variables becuase they are defined on a dummy mesh */ 23 : resizeFieldVar 336 @ 337 @ 338 @ 339 @ 340 @ 341 @ 342 @ 343 @ 344 @ 345 @ 346 @ 347 @ 348 @ 349 @ 350 @ 351 @ 352 @ 353 @ 354 @ 355 @ 356 @ 357 @ 358 @ 359 @ 360 @ 361 @ 362 @ 363 @ 364 @ 365 @ 366 @ 367 @ 368 @ 369 @ 370 @ 371 @ 372 @ 336 @ 337 @ IFMACRO(BRE) 338 & uLx = uLx; 339 & uLy = uLy; 340 & gendef(usol) = gendef(usol); 341 & gendef(usolprev) = gendef(usolprev); 342 & gendef(usolprevprev) = gendef(usolprevprev); 343 & gendef(uReduce) = gendef(uReduce); 344 & gendef(uGlobal) = gendef(uGlobal); 345 & ENDIFMACRO 346 @ IFMACRO(EV) 347 & uLx = uLx; 348 & uLy = uLy; 349 & gendef(usol) = gendef(usol); 350 & gendef(uReduce) = gendef(uReduce); 351 & gendef(uGlobal) = gendef(uGlobal); 352 & gendef(uBF) = gendef(uBF); 353 & gendef(uBFprev) = gendef(uBFprev); 354 & ENDIFMACRO 355 @ IFMACRO(PSE) 356 & uLx = uLx; 357 & uLy = uLy; 358 & gendef(usol) = gendef(usol); 359 & gendef(usolprev) = gendef(usolprev); 360 & gendef(usolprevprev) = gendef(usolprevprev); 361 & gendef(uReduce) = gendef(uReduce); 362 & gendef(uGlobal) = gendef(uGlobal); 363 & gendef(uBF) = gendef(uBF); 364 & gendef(uBFprev) = gendef(uBFprev); 365 & gendef(uBFx) = gendef(uBFx); 366 & gendef(uBFn) = gendef(uBFn); 367 & gendef(usol2Evalrhs) = gendef(usol2Evalrhs); 368 & gendef(uGlobal2Evalrhs) = gendef(uGlobal2Evalrhs); 369 & rhsvec.resize(VhC.ndof); 370 & ENDIFMACRO 356 @ uLx = uLx; 357 @ uLy = uLy; 358 @ gendef(usol) [usol, usolB, usolC, usolD] = gendef(usol) [usol, usolB, usolC, usolD]; 359 @ gendef(usolprev) [usolprev, usolprevB, usolprevC, usolprevD] = gendef(usolprev) [usolprev, usolprevB, usolprevC, usolprevD]; 360 @ gendef(usolprevprev) [usolprevprev, usolprevprevB, usolprevprevC, usolprevprevD] = gendef(usolprevprev) [usolprevprev, usolprevprevB, usolprevprevC, usolprevprevD]; 361 @ gendef(uReduce) [uReduce, uReduceB, uReduceC, uReduceD] = gendef(uReduce) [uReduce, uReduceB, uReduceC, uReduceD]; 362 @ gendef(uGlobal) [uGlobal, uGlobalB, uGlobalC, uGlobalD] = gendef(uGlobal) [uGlobal, uGlobalB, uGlobalC, uGlobalD]; 363 @ gendef(uBF) [uBF, uBFB, uBFC, uBFD] = gendef(uBF) [uBF, uBFB, uBFC, uBFD]; 364 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD]; 365 @ gendef(uBFx) [uBFx, uBFxB, uBFxC, uBFxD] = gendef(uBFx) [uBFx, uBFxB, uBFxC, uBFxD]; 366 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD]; 367 @ gendef(usol2Evalrhs) [usol2Evalrhs, usol2EvalrhsB, usol2EvalrhsC, usol2EvalrhsD] = gendef(usol2Evalrhs) [usol2Evalrhs, usol2EvalrhsB, usol2EvalrhsC, usol2EvalrhsD]; 368 @ gendef(uGlobal2Evalrhs) [uGlobal2Evalrhs, uGlobal2EvalrhsB, uGlobal2EvalrhsC, uGlobal2EvalrhsD] = gendef(uGlobal2Evalrhs) [uGlobal2Evalrhs, uGlobal2EvalrhsB, uGlobal2EvalrhsC, uGlobal2EvalrhsD]; 369 @ rhsvec.resize(VhC.ndof); 370 @ 371 @ 372 @ 24 : 25 : /* mass-matrices for parallel integration for the criterion and the kinetic energy */ 26 : createMassMatPSE 312 @ 313 @ 314 @ 315 @ 316 @ 317 @ 318 @ 319 @ 320 @ 321 @ 322 @ 323 @ 312 @ 313 @ Mat dM(dJ); 314 @ Mat dMvel(dJ); 315 @ 316 @ { 317 @ varf fullMassMatvarf([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)(u1*v1+u2*v2+u3*v3+p*q); 318 @ dM = fullMassMatvarf(VhC,VhC); 319 @ varf velMassMatvarf([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)(u1*v1+u2*v2+u3*v3); 320 @ dMvel = velMassMatvarf(VhC,VhC); 321 @ } 322 @ 323 @ 27 : 28 : /* variation formulation of the linear equations & functions for the nonlinear problem solution */ 29 : include "../include/PSEsolver_macros.idp" 2 : /* ---------------------------------------------------------------------------------------------------------- */ 3 : /* PSE step size macros */ 4 : /* ---------------------------------------------------------------------------------------------------------- */ 5 : 6 : /* constant for BDF2 stepsize limit*/ 7 : macro BDF2const() 2.201834737520806 //EOM 8 : 9 : /* ---------------------------------------------------------------------------------------------------------- */ 10 : func real stepSizeLimitBDF1(complex alpha){ 11 : real dxLimit; 12 : dxLimit = 1/abs(real(alpha)); 13 : return dxLimit; 14 : } 15 : 16 : /* ---------------------------------------------------------------------------------------------------------- */ 17 : func real stepSizeLimitBDF1nodpdx(complex alpha){ 18 : real dxLimit; 19 : if(imag(alpha)<0){ 20 : dxLimit = (real(alpha) - abs(alpha))/(2*imag(alpha)*real(alpha)); 21 : } else if(imag(alpha)>0){ 22 : dxLimit = 2*imag(alpha)/abs(alpha)^2; 23 : } 24 : return dxLimit; 25 : } 26 : 27 : /* ---------------------------------------------------------------------------------------------------------- */ 28 : func real stepSizeLimitBDF1damped(complex alpha, real s){ 29 : real dxLimit; 30 : dxLimit = 1/abs(real(alpha)) - 2*s; 31 : return dxLimit; 32 : } 33 : 34 : 35 : /* ---------------------------------------------------------------------------------------------------------- */ 36 : func real stepSizeLimitBDF2(complex alpha){ 37 : real dxLimit; 38 : /* non-equidistant or equidistant */ 39 : if(dxtype!=2){ 40 : complex alpha2Scope = alpha; /* so that locally defined functions see alpha */ 41 : int neta = 100; 42 : real[int] etavec; 43 : linspace(etavec,-1,1,neta) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ etavec.resize(neta); 874 @ if(neta>1){ 875 @ real dx = (1 - -1)/(neta - 1.); *** Warning The identifier dx hide a Global identifier 876 @ etavec[0] = -1; 877 @ for(int i=1; i1){ 875 @ real dx = (1 - -1)/(neta - 1.); *** Warning The identifier dx hide a Global identifier 876 @ etavec[0] = -1; 877 @ for(int i=1; i0){ 150 : 151 : if(false){ 152 : func real fun2Minimize(real[int] x) *** Warning The identifier x hide a Global identifier { 153 : real out; 154 : real[int] vecdiff(2); 155 : vecdiff[0] = (cos(x[1]) - 1.)^2 / x[0] - imag(alpha2Scope); 156 : vecdiff[1] = -(sin(x[1])*(cos(x[1]) - 2.)) / x[0] + real(alpha2Scope); 157 : out = vecdiff.l2; 158 : return out; 159 : } 160 : 161 : real[int] lbvec = [dxLowerBound,-pi]; 162 : real[int] ubvec(2); 163 : ubvec[0] = stepSizeLimitBDF2(alpha); 164 : ubvec[1] = pi; 165 : real[int] x0(2); 166 : x0[0] = ubvec[0]*0.9; 167 : x0[1] = -1; 168 : real minval = nloptNelderMead(fun2Minimize,x0,lb=lbvec,ub=ubvec,stopAbsFTol=1e-12,stopRelXTol=1e-12); 169 : dxLimit = x0[0]; 170 : 171 : } else { 172 : 173 : func real fun2Minimize(real[int] inDX){ 174 : real out; 175 : if(dxtype!=2){ 176 : real dx1 = X1 - X0; 177 : out = abs(abs(((2*dx1*inDX[0] + (dx1^4 + 4*dx1^3*inDX[0] - alpha2Scope*dx1^2*inDX[0]^3*4i + 2*dx1^2*inDX[0]^2 - alpha2Scope*dx1*inDX[0]^4*4i - 4*dx1*inDX[0]^3 + inDX[0]^4)^(0.5) + 178 : dx1^2 + inDX[0]^2)*1i)/(2*dx1*(dx1*1i + inDX[0]*2*1i - alpha2Scope*(inDX[0]^2 + dx1*inDX[0]))))-1); 179 : } else { 180 : out = abs(abs(((1 - alpha2Scope*inDX[0]*2*1i)^(0.5) + 2)/(3 + alpha2Scope*inDX[0]*2*1i))-1); 181 : } 182 : return out; 183 : } 184 : real[int] lbvec = [dxLowerBound]; 185 : real[int] ubvec = [BDF2const 2.201834737520806 / abs(real(alpha))]; 186 : real[int] x0(1); 187 : x0[0] = ubvec[0]*0.9; 188 : real minval = nloptNelderMead(fun2Minimize,x0,lb=lbvec,ub=ubvec,stopAbsFTol=1e-12,stopRelXTol=1e-12); 189 : dxLimit = x0[0]; 190 : 191 : } 192 : 193 : } else if(imag(alpha)<0){ 194 : 195 : int neta = 100; 196 : real[int] etavec; 197 : linspace(etavec,0,0.2,neta) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ etavec.resize(neta); 874 @ if(neta>1){ 875 @ real dx = (0.2 - 0)/(neta - 1.); *** Warning The identifier dx hide a Global identifier 876 @ etavec[0] = 0; 877 @ for(int i=1; i dxLimit * dxSafetyFactor; 304 : return condition; 305 : 306 : } 307 : 308 : /* ---------------------------------------------------------------------------------------------------------- */ 309 : /* ---------------------------------------------------------------------------------------------------------- */ 310 : func real dampingFactorBDF1(complex alpha, real dx) *** Warning The identifier dx hide a Global identifier { 311 : real s; 312 : s = 0.5*(1/abs(real(alpha)) - dx); 313 : return s; 314 : } 315 : 316 : /* ---------------------------------------------------------------------------------------------------------- */ 317 : func real dampingFactorBDF2(complex alpha, real dx) *** Warning The identifier dx hide a Global identifier { 318 : 319 : real s; 320 : complex alpha2Scope = alpha; /* so that locally defined functions see alpha */ 321 : real inDX22Scope = dx; /* so that locally defined functions see alpha */ 322 : int neta = 100; 323 : real[int] etavec; 324 : linspace(etavec,-1,1,neta) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ etavec.resize(neta); 874 @ if(neta>1){ 875 @ real dx = (1 - -1)/(neta - 1.); *** Warning The identifier dx hide a Global identifier 876 @ etavec[0] = -1; 877 @ for(int i=1; i1 & BDF2 & !inPreStepFlag & !justExitPreStep ) //EOM 413 : 414 : /* ---------------------------------------------------------------------------------------------------- */ 415 : /* reading PSE base flow at each step */ 416 : macro setPSEBF(xval) 417 # 418 # /* increase BRE index if needed */ 419 # while(XgridBRE[indBRE]<=xval& indBRE < XgridBRE.n-1){ 420 # indBRE++; 421 # } 422 # 423 # /* if index is inceased, read the new data, and shift, depending on the number of skipped cells */ 424 # if(indBRE-3>indBREprev){ 425 # import2DField(uBFn,"BRE",iname,indBRE) 426 # indBREprev = indBRE - 2; 427 # import2DField(uBFprevprev,"BRE",iname,indBREprev) 428 # indBREprev = indBRE - 1; 429 # import2DField(uBFprev,"BRE",iname,indBREprev) 430 # scaleVelBRE2Normal(uBFn,Rey) 431 # scaleVelBRE2Normal(uBFprev,Rey) 432 # scaleVelBRE2Normal(uBFprevprev,Rey) 433 # } else if(indBRE-2>indBREprev){ 434 # uBFprevprev[] = uBFn[]; 435 # import2DField(uBFn,"BRE",iname,indBRE) 436 # indBREprev = indBRE - 1; 437 # import2DField(uBFprev,"BRE",iname,indBREprev) 438 # scaleVelBRE2Normal(uBFn,Rey) 439 # scaleVelBRE2Normal(uBFprev,Rey) 440 # } else if(indBRE-1>indBREprev){ /* read and scale only one */ 441 # uBFprevprev[] = uBFprev[]; 442 # uBFprev[] = uBFn[]; 443 # indBREprev = indBRE - 1; 444 # import2DField(uBFn,"BRE",iname,indBRE) 445 # scaleVelBRE2Normal(uBFn,Rey) 446 # } 447 # /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 # 449 # 450 # /* interpolate the current BF */ 451 # if(indBRE>1){ 452 # real dx2 = XgridBRE[indBRE] - XgridBRE[indBREprev-1]; 453 # real dx1 = XgridBRE[indBREprev] - XgridBRE[indBREprev-1]; 454 # real relx = xval - XgridBRE[indBREprev-1]; 455 # uBF[] = ((dx2 - relx)/dx2 - (relx*(dx2 - relx))/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((relx*(dx2 - relx))/(dx1*dx2) - (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 456 # uBF[] += uBFn[]*(relx/dx2 + (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 457 # uBFx[] = (- 1/dx2 - (dx2 - 2*relx)/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((dx2 - 2*relx)/(dx1*dx2) - (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 458 # uBFx[] += uBFn[]*(1/dx2 + (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 459 # /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 # 461 # } else { 462 # uBFx[] = uBFn[] - uBFprev[]; 463 # uBFx[] *= (1/(XgridBRE[indBRE] - XgridBRE[indBREprev])); 464 # real interdX = (xval - XgridBRE[indBRE-1])/(XgridBRE[indBRE] - XgridBRE[indBREprev]); 465 # if(abs(interdX) < 1e-6){ 466 # uBF[] = uBFprev[]; 467 # } else { 468 # uBF[] = (1-interdX)*uBFprev[] + uBFn[]*interdX; 469 # } 470 # /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 # } 472 # 473 # 474 # 475 # ) //EOM 476 : 477 : /* ---------------------------------------------------------------------------------------------------- */ 478 : /* PSE growth rate calculation */ 479 : /* note: assuming that the solution and the previous solution exist in uGlobal and uGlobal2Evalrhs, respectively */ 480 : macro getPSEGrowth(nstep){ 481 # int locind = -1; 482 # if(growthEnergy==1){ 483 # locind++; 484 # /* first step - calculate the initial energy - the previous value is in the auxiliary RHS vec in PETSc numbering, divided by dX*/ 485 # if(nstep==1){ 486 # integrateParallel(dMvel,usol2EvalrhsPETSc,usol2EvalrhsPETSc,auxvecPETSc,energyvec[nstep-1]) 487 # energyvec[nstep-1] = energyvec[nstep-1] * (0.5 * (X2-X1)^2); 488 # 489 # } 490 # integrateParallel(dMvel,usolPETSc,usolPETSc,auxvecPETSc,energyvec[nstep]) 491 # energyvec[nstep] *= 0.5; 492 # } 493 # 494 # /* if velocity-based growth rate is requested, collect the distributed solution */ 495 # if(growthU==1 || growthV==1) { 496 # sendvecDistributed2Global(usol,uGlobal); 497 # } 498 # 499 # if(growthU==1){ 500 # /* function for max search*/ 501 # func real interp2uOptfun(real[int] zy){ 502 # real out = -abs(uGlobal(zy[0],zy[1])); 503 # return out; 504 # } 505 # 506 # /* first step - search for the maximum*/ 507 # /* TODO TODO - ACCURATE INITIAL GUESS */ 508 # 509 # if(nstep==1){ 510 # VP1Glob uP1, uP1x = x, uP1y = y; 511 # uP1 = abs(uGlobal); 512 # growthUZY[0] = uP1x[][uP1[].imax]; 513 # growthUZY[1] = uP1y[][uP1[].imax]; 514 # } 515 # /* max search */ 516 # complex umax = nloptNelderMead(interp2uOptfun,growthUZY,stopAbsFTol=1e-8,stopRelXTol=1e-8); 517 # complex umaxc = uGlobal(growthUZY[0],growthUZY[1]); 518 # /* calculating the derivative at the maximum location */ 519 # if(nstep>1 & BDF2){ 520 # growthmat(nstep,++locind) = (umaxc*(1/(X2-X0)+1/(X2-X1))-uGlobal2Evalrhs(growthUZY[0],growthUZY[1]))/umaxc; 521 # } else { 522 # growthmat(nstep,++locind) = (umaxc*(1/(X2-X1))-uGlobal2Evalrhs(growthUZY[0],growthUZY[1]))/umaxc; 523 # } 524 # /* first step - derivative is the same */ 525 # if(nstep==1){ 526 # growthmat(nstep-1,locind) = growthmat(nstep,locind); 527 # } 528 # IFMACRO(GROWTHDEBUG) 529 # growthmatDEBUGu(nstep,0) = growthUZY[0]; 530 # growthmatDEBUGu(nstep,1) = growthUZY[1]; 531 # if(nstep==1){ 532 # growthmatDEBUGu(nstep-1,0) = growthmatDEBUGu(nstep,0); 533 # growthmatDEBUGu(nstep-1,1) = growthmatDEBUGu(nstep,1); 534 # } 535 # ENDIFMACRO 536 # } 537 # 538 # if(growthV==1){ 539 # /* function for max search*/ 540 # func real interp2uOptfun(real[int] zy){ 541 # real out = -abs(uGlobalB(zy[0],zy[1])); 542 # return out; 543 # } 544 # if(nstep==1){ 545 # VP1Glob uP1, uP1x = x, uP1y = y; 546 # uP1 = abs(uGlobalB); 547 # growthVZY[0] = uP1x[][uP1[].imax]; 548 # growthVZY[1] = uP1y[][uP1[].imax]; 549 # } 550 # /* max search */ 551 # complex umax = nloptNelderMead(interp2uOptfun,growthVZY,stopAbsFTol=1e-8,stopRelXTol=1e-8); 552 # complex umaxc = uGlobalB(growthVZY[0],growthVZY[1]); 553 # /* calculating the derivative at the maximum location */ 554 # if(nstep>1 & BDF2){ 555 # growthmat(nstep,++locind) = (umaxc*(1/(X2-X0)+1/(X2-X1))-uGlobal2EvalrhsB(growthVZY[0],growthVZY[1]))/umaxc; 556 # } else { 557 # growthmat(nstep,++locind) = (umaxc*(1/(X2-X1))-uGlobal2EvalrhsB(growthVZY[0],growthVZY[1]))/umaxc; 558 # } 559 # /* first step - derivative is the same */ 560 # if(nstep==1){ 561 # growthmat(nstep-1,locind) = growthmat(nstep,locind); 562 # } 563 # IFMACRO(GROWTHDEBUG) 564 # growthmatDEBUGv(nstep,0) = growthVZY[0]; 565 # growthmatDEBUGv(nstep,1) = growthVZY[1]; 566 # if(nstep==1){ 567 # growthmatDEBUGv(nstep-1,0) = growthmatDEBUGv(nstep,0); 568 # growthmatDEBUGv(nstep-1,1) = growthmatDEBUGv(nstep,1); 569 # } 570 # ENDIFMACRO 571 # 572 # } 573 # 574 # } ) //EOM 575 : 576 : /* ---------------------------------------------------------------------------------------------------- */ 577 : /* PSE growth rate calculation */ 578 : macro calcPSEGrowthE(){ 579 # if(growthEnergy==1 & XgridPSE.n>2){ 580 # 581 # /* in-loop integrals are calculated on rank 0 only, broadcast it now*/ 582 # broadcast(processor(0),energyvec); 583 # 584 # /* loadin the data into a matrix - only way to create a spline */ 585 # real[int,int] dummymat(2,XgridPSE.n); 586 # for(int nn=0; nn2){ 599 # if(mpirank==0) cout << "Number of steps is small to calculate the energy growth with spline interpolation" << endl; 600 # } 601 # } 602 # //EOM 603 : 604 : 605 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 606 : /* PSE initial condition setup: read & norm IC, and initialize alpha, resetting BF tracking indices */ 607 : /* Note: variable resizing in stabmacros/setupPSEXgrid if fixgrid and in PSEsolver_macros/PSEadaptiveStepUpdateGrid for !fixGrid */ 608 : macro PSEsetupIC(inIndF) 609 # 610 # import2DField(usol,"BiGlob",inameBiG,inIndF) 611 # alpha = alpha0mat(inIndF,0); 612 # alphavec = 0; 613 # alphavec[0] = alpha; 614 # alphaprev = alpha; 615 # normEV(usol) 616 # 617 # indBRE = 0; 618 # indBREprev = -1; 619 # 620 # ) //EOM 621 : 622 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 623 : /* adaptive step */ 624 : macro PSEadaptiveStepUpdateGrid(inIndx) 625 # 626 # /* increase variable size */ 627 # XgridPSE.resize(XgridPSE.n+1); 628 # alphavec.resize(alphavec.n+1); 629 # energyvec.resize(energyvec.n+1); 630 # growthmat.resize(growthmat.n+1,growthmat.m); 631 # /* add x grid value */ 632 # XgridPSE[XgridPSE.n-1] = XgridPSE[inIndx++]+dX; 633 # 634 # ) //EOM 635 : 636 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 637 : /* adaptive step - TODO OBSOLETE*/ 638 : macro PSEadaptivestepOLD(inIndx) 639 # 640 # /* handle initial step damping */ 641 # if(preStep & nPreStep > inIndx){ 642 # enableDamping = true; 643 # spar = sParPreStep; 644 # } else if(nPreStep==inIndx) { 645 # if(mpirank==0) cout << " ========== Prestepping finished: out of the prestepping range ========== " << endl; 646 # /* turn off damping after prestepping if not requested */ 647 # if(!enableDampingPostPrestep){ 648 # if(mpirank==0) cout << " ========== damping switched off after prestepping ========== " << endl; 649 # enableDamping = false; 650 # spar = 0.; 651 # } 652 # } 653 # /* increase variable size */ 654 # XgridPSE.resize(XgridPSE.n+1); 655 # alphavec.resize(alphavec.n+1); 656 # energyvec.resize(energyvec.n+1); 657 # growthmat.resize(growthmat.n+1,growthmat.m); 658 # /* add x grid value */ 659 # XgridPSE[XgridPSE.n-1] = XgridPSE[inIndx++]+dX; 660 # 661 # if(mpirank==0){ 662 # cout << " ### PSE adaptive step, XgridPSE[i-1]=" << XgridPSE[inIndx-1] << ", XgridPSE[i]=" << XgridPSE[inIndx] << ", dX=" << dX << endl; 663 # } 664 # 665 # ) //EOM 666 : 667 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 668 : /* PSE pre-step calculation: variable updating & printing some info */ 669 : /* justExitPreStep:the first stepsize after the prestepping stage is different */ 670 : macro PSEinitstep(inXgrid,inIndx) 671 # 672 # /* print different for prestep and normal step */ 673 # real looptime = mpiWtime(); 674 # if(mpirank==0){ 675 # if(inPreStepFlag){ 676 # cout << " ======================= PSE prestep #" << inIndx << " started ======================= " << endl; 677 # } else { 678 # cout << " ######################## PSE step #" << inIndx << " started ######################### " << endl; 679 # } 680 # } 681 # 682 # /* calculation of the BF velocity profile */ 683 # setPSEBF(inXgrid[inIndx]) 684 # 685 # /* saving old variables */ 686 # usolprevprev[] = usolprev[]; 687 # usolprev[] = usol[]; 688 # alphaprevprev = alphaprev; 689 # alphaprev = alpha; 690 # 691 # /* x variable, vector setup for efficient RSH evaluation */ 692 # if(allowBDF2(inIndx)){ 693 # X0 = inXgrid[inIndx-2]; 694 # X1 = inXgrid[inIndx-1]; 695 # X2 = inXgrid[inIndx]; 696 # dX = X2 - X1; 697 # /* RHS setup and gathering for integral criterion calculation */ 698 # usol2Evalrhs[] = usolprevprev[] *(1/(X2-X0)-1/(X1-X0)) + usolprev[]*(1/(X2-X1)+1/(X1-X0)); 699 # sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 700 # } else { 701 # /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 # if(justExitPreStep){ 703 # X1 = X2; 704 # justExitPreStep = false; 705 # } else { 706 # X1 = inXgrid[inIndx-1]; 707 # } 708 # X2 = inXgrid[inIndx]; 709 # dX = X2 - X1; 710 # /* RHS setup and gathering for integral criterion calculation */ 711 # usol2Evalrhs[] = usolprev[] *(1. / (X2 - X1)); 712 # sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 713 # } 714 # changeNumbering(dJ, usol2Evalrhs[], usol2EvalrhsPETSc); 715 # 716 # /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 # if(false & inIndx>initcorrind & !inPreStepFlag){ 718 # alpha = (alphaprev - alphaprevprev) ; 719 # alpha = alpha * (1./(X1-X0)*(X2-X1)); 720 # alpha += alphaprev; 721 # } 722 # 723 # /* step size info */ 724 # if(mpirank==0){ 725 # if(inPreStepFlag){ 726 # cout << " ==== PSE pre-step, BDF order=" << (allowBDF2(inIndx) ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << endl; 727 # } else { 728 # cout << " #### PSE " << (fixGrid ? "fix grid" : "adaptive") << " step, BDF order=" << (allowBDF2(inIndx) ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << 729 # ", inital normal admissible stepsize=" << calcNormalStepSizeLimit(alpha,allowBDF2(inIndx)) << endl; 730 # } 731 # 732 # } 733 # 734 # ) //EOM 735 : 736 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 737 : /* PSE step finalization: alpha saving, extracing growth info, output & timing*/ 738 : macro PSEfinalizestep(inIndF,inIndx) 739 # 740 # alphavec[inIndx] = alpha; 741 # getPSEGrowth(inIndx) 742 # 743 # /* txt output */ 744 # if(abs(fmod(inIndx*nF+inIndF+0.,overbfreq+0.))<1e-8){ 745 # string auxname = "j" + inIndF + "_i" + inIndx; 746 # export2DField(usol,"PSE",oname,auxname) 747 # } 748 # 749 # /* VTU output */ 750 # if(abs(fmod(inIndx*nF+inIndF+0.,overbfreqVTU+0.))<1e-8){ 751 # string auxname = "j" + inIndF + "_i" + inIndx; 752 # sendvecDistributed2Global(usol,uGlobal) 753 # VTUexportGendata(uGlobal,"PSE",oname,auxname) 754 # } 755 # 756 # /* timing */ 757 # looptime = mpiWtime() - looptime; 758 # if(mpirank==0){ 759 # cout << " ##### PSE step #" << inIndx << " successfully finished in " << looptime << " seconds ##### " << endl; 760 # cout << " ######################################################################### " << endl; 761 # } 762 # 763 # ) //EOM 764 : 765 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 766 : /* Output after marching is finished: x, alpha, growth, final solution & timing */ 767 : macro PSEoutput() 768 # 769 # calcPSEGrowthE 770 # { 771 # string auxname = "j" + j; 772 # exportVec(XgridPSE,"PSE",oname + "_Xgrid_" + auxname) 773 # exportVec(alphavec,"PSE",oname + "_alphavec_" + auxname) 774 # exportMat(growthmat,"PSE",oname + "_growthmat_" + auxname) 775 # IFMACRO(GROWTHDEBUG) 776 # exportMat(growthmatDEBUGu,"PSE",oname + "_growthmatDEBUGu_" + auxname) 777 # exportMat(growthmatDEBUGv,"PSE",oname + "_growthmatDEBUGv_" + auxname) 778 # ENDIFMACRO 779 # sendvecDistributed2Global(usol,uGlobal) 780 # VTUexportGendata(uGlobal,"PSE",oname,auxname) 781 # } 782 # 783 # runtimeF = mpiWtime() - runtimeF; 784 # if(mpirank==0){ 785 # cout << " -------------------------------------------------------------------------- " << endl; 786 # cout << " ### PSE calculation at F index #" << j << ", F=" << Fvec[j] << ", omega =" << omega << " successfully finished in " << runtimeF << " seconds ##### " << endl; 787 # cout << " -------------------------------------------------------------------------- " << endl; 788 # } 789 # 790 # //EOM 791 : 792 : 30 : include "../include/varf_PSE.idp" 2 : /* ### IMPORTANT: IN these VARF, THE VECTOR 'usol2Evalrhs', PROPERLY MULTIPLIED AND SUMMED ### */ 3 : /* ### WITH THE RIGHT COEFFICIENTS IS EXPECTED ### */ 4 : /* ### usol2EvalrhsB[] = usolprevprev[] *(1/(X2-X0)-1/(X1-X0)) + usolprev[]*(1/(X2-X1)+1/(X1-X0)); ### */ 5 : 6 : IFMACRO(!mAL) 7 & 8 & macro zetaPSE() (1i*(alpha*uBF-omega)+alpha^2*nudelta) //EOM 9 & 10 & 11 & /* ---------------------------------------- no damping ---------------------------------------- */ 12 & 13 & /* incomp. PSE A matrix varf - LHS */ 14 & varf AhatPSE([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 15 & 16 & zetaPSE*u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 17 & uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 18 & 19 & uBFxB*u1*v2 + zetaPSE*u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 20 & uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 21 & 22 & uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE*u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 23 & uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 24 & 25 & 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 26 & 27 & ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 + u1*q))*(1/(X2-X1)) /* F matrix */ 28 & ) 29 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 30 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 31 & 32 & /* incomp. PSE b vector varf - RHS */ 33 & varf bhatPSE([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 34 & (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 +usol2Evalrhs*q) /* F matrix */ 35 & ) 36 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 37 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 38 & 39 & /* -------------------- Higher order scheme -------------------- */ 40 & 41 & /* incomp. PSE A matrix varf - LHS */ 42 & varf AhatPSE2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 43 & 44 & zetaPSE*u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 45 & uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 46 & 47 & uBFxB*u1*v2 + zetaPSE*u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 48 & uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 49 & 50 & uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE*u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 51 & uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 52 & 53 & 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 54 & 55 & ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 +u1*q))*(1/(X2-X0)+1/(X2-X1)) /* F matrix */ 56 & ) 57 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 58 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 59 & 60 & /* incomp. PSE b vector varf - RHS */ 61 & varf bhatPSE2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 62 & (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 +usol2Evalrhs*q) /* F matrix */ 63 & ) 64 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 65 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 66 & 67 & 68 & /* ---------------------------------------- damping via Andersson 1998 ---------------------------------------- */ 69 & 70 & /* -------------------- single varf , first order -------------------- */ 71 & 72 & varf AhatPSEd([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 73 & ( 74 & zetaPSE*u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 75 & uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 76 & 77 & uBFxB*u1*v2 + zetaPSE*u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 78 & uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 79 & 80 & uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE*u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 81 & uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 82 & 83 & 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q /* A+B+C+D+E fourth row */ 84 & )*(1+spar/(X2-X1)) + 85 & 86 & ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 + u1*q))*(1/(X2-X1)) /* F matrix */ 87 & 88 & ) 89 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 90 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 91 & 92 & varf bhatPSEd([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 93 & ( 94 & zetaPSE*usolprev*v1 + uBFx*usolprev*v1 + dy(uBF)*usolprevB*v1 + dx(uBF)*usolprevC*v1 + 1i*alpha*usolprevD*v1 + /* A first row */ 95 & uBFB*dy(usolprev)*v1 + nudelta*dy(usolprev)*dy(v1) + uBFC*dx(usolprev)*v1 + nudelta*dx(usolprev)*dx(v1) + /* B+C+D+E first row */ 96 & 97 & uBFxB*usolprev*v2 + zetaPSE*usolprevB*v2 + dy(uBFB)*usolprevB*v2 + dx(uBFB)*usolprevC*v2 + /* A second row */ 98 & uBFB*dy(usolprevB)*v2 + dy(usolprevD)*v2 + nudelta*dy(usolprevB)*dy(v2) + uBFC*dx(usolprevB)*v2 + nudelta*dx(usolprevB)*dx(v2) + /* B+C+D+E second row */ 99 & 100 & uBFxC*usolprev*v3 + dy(uBFC)*usolprevB*v3 + zetaPSE*usolprevC*v3 + dx(uBFC)*usolprevC*v3 + /* A third row */ 101 & uBFB*dy(usolprevC)*v3 + nudelta*dy(usolprevC)*dy(v3) + uBFC*dx(usolprevC)*v3 + dx(usolprevD)*v3 + nudelta*dx(usolprevC)*dx(v3) + /* B+C+D+E third row */ 102 & 103 & 1i*alpha*usolprev*q + dy(usolprevB)*q + dx(usolprevC)*q /* A+B+C+D+E fourth row */ 104 & )*(spar/(X2-X1)) + 105 & 106 & (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 + usol2Evalrhs*q) /* F matrix */ 107 & 108 & ) 109 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 110 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 111 & 112 & /* -------------------- Higher order scheme -------------------- */ 113 & 114 & varf AhatPSEd2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 115 & ( 116 & zetaPSE*u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 117 & uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 118 & 119 & uBFxB*u1*v2 + zetaPSE*u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 120 & uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 121 & 122 & uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE*u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 123 & uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 124 & 125 & 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q /* A+B+C+D+E fourth row */ 126 & )*(1+spar*(1/(X2-X0)+1/(X2-X1))) + 127 & 128 & ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 + u1*q))*(1/(X2-X0)+1/(X2-X1)) /* F matrix */ 129 & 130 & ) 131 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 132 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 133 & 134 & varf bhatPSEd2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 135 & ( 136 & zetaPSE*usol2Evalrhs*v1 + uBFx*usol2Evalrhs*v1 + dy(uBF)*usol2EvalrhsB*v1 + dx(uBF)*usol2EvalrhsC*v1 + 1i*alpha*usol2EvalrhsD*v1 + /* A first row */ 137 & uBFB*dy(usol2Evalrhs)*v1 + nudelta*dy(usol2Evalrhs)*dy(v1) + uBFC*dx(usol2Evalrhs)*v1 + nudelta*dx(usol2Evalrhs)*dx(v1) + /* B+C+D+E first row */ 138 & 139 & uBFxB*usol2Evalrhs*v2 + zetaPSE*usol2EvalrhsB*v2 + dy(uBFB)*usol2EvalrhsB*v2 + dx(uBFB)*usol2EvalrhsC*v2 + /* A second row */ 140 & uBFB*dy(usol2EvalrhsB)*v2 + dy(usol2EvalrhsD)*v2 + nudelta*dy(usol2EvalrhsB)*dy(v2) + uBFC*dx(usol2EvalrhsB)*v2 + nudelta*dx(usol2EvalrhsB)*dx(v2) + /* B+C+D+E second row */ 141 & 142 & uBFxC*usol2Evalrhs*v3 + dy(uBFC)*usol2EvalrhsB*v3 + zetaPSE*usol2EvalrhsC*v3 + dx(uBFC)*usol2EvalrhsC*v3 + /* A third row */ 143 & uBFB*dy(usol2EvalrhsC)*v3 + nudelta*dy(usol2EvalrhsC)*dy(v3) + uBFC*dx(usol2EvalrhsC)*v3 + dx(usol2EvalrhsD)*v3 + nudelta*dx(usol2EvalrhsC)*dx(v3) + /* B+C+D+E third row */ 144 & 145 & 1i*alpha*usol2Evalrhs*q + dy(usol2EvalrhsB)*q + dx(usol2EvalrhsC)*q /* A+B+C+D+E fourth row */ 146 & )*spar + 147 & (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 + usol2Evalrhs*q) /* F matrix */ 148 & ) 149 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 150 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 151 & 152 & 153 & 154 & /* ---------------------------------------- no dp/dx term ---------------------------------------- */ 155 & 156 & /* incomp. PSE A matrix varf - LHS */ 157 & varf AhatPSEnodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 158 & 159 & zetaPSE*u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 160 & uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 161 & 162 & uBFxB*u1*v2 + zetaPSE*u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 163 & uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 164 & 165 & uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE*u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 166 & uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 167 & 168 & 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 169 & 170 & ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (u1*q))*(1/(X2-X1)) /* F matrix */ 171 & ) 172 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 173 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 174 & 175 & /* incomp. PSE b vector varf - RHS */ 176 & varf bhatPSEnodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 177 & (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2Evalrhs*q) /* F matrix */ 178 & ) 179 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 180 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 181 & 182 & /* -------------------- Higher order scheme -------------------- */ 183 & 184 & /* incomp. PSE A matrix varf - LHS */ 185 & varf AhatPSE2nodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 186 & 187 & zetaPSE*u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 188 & uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 189 & 190 & uBFxB*u1*v2 + zetaPSE*u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 191 & uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 192 & 193 & uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE*u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 194 & uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 195 & 196 & 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 197 & 198 & ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (u1*q))*(1/(X2-X0)+1/(X2-X1)) /* F matrix */ 199 & ) 200 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 201 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 202 & 203 & /* incomp. PSE b vector varf - RHS */ 204 & varf bhatPSE2nodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 205 & (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2Evalrhs*q) /* F matrix */ 206 & ) 207 & + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 208 & + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 209 & 210 & 211 & 212 & ENDIFMACRO 7 @ 8 @ macro zetaPSE() (1i*(alpha*uBF-omega)+alpha^2*nudelta) //EOM 9 @ 10 @ 11 @ /* ---------------------------------------- no damping ---------------------------------------- */ 12 @ 13 @ /* incomp. PSE A matrix varf - LHS */ 14 @ varf AhatPSE([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 15 @ 16 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 17 @ uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 18 @ 19 @ uBFxB*u1*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 20 @ uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 21 @ 22 @ uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 23 @ uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 24 @ 25 @ 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 26 @ 27 @ ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 + u1*q))*(1/(X2-X1)) /* F matrix */ 28 @ ) 29 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 30 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 31 @ 32 @ /* incomp. PSE b vector varf - RHS */ 33 @ varf bhatPSE([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 34 @ (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 +usol2Evalrhs*q) /* F matrix */ 35 @ ) 36 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 37 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 38 @ 39 @ /* -------------------- Higher order scheme -------------------- */ 40 @ 41 @ /* incomp. PSE A matrix varf - LHS */ 42 @ varf AhatPSE2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 43 @ 44 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 45 @ uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 46 @ 47 @ uBFxB*u1*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 48 @ uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 49 @ 50 @ uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 51 @ uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 52 @ 53 @ 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 54 @ 55 @ ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 +u1*q))*(1/(X2-X0)+1/(X2-X1)) /* F matrix */ 56 @ ) 57 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 58 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 59 @ 60 @ /* incomp. PSE b vector varf - RHS */ 61 @ varf bhatPSE2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 62 @ (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 +usol2Evalrhs*q) /* F matrix */ 63 @ ) 64 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 65 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 66 @ 67 @ 68 @ /* ---------------------------------------- damping via Andersson 1998 ---------------------------------------- */ 69 @ 70 @ /* -------------------- single varf , first order -------------------- */ 71 @ 72 @ varf AhatPSEd([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 73 @ ( 74 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 75 @ uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 76 @ 77 @ uBFxB*u1*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 78 @ uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 79 @ 80 @ uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 81 @ uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 82 @ 83 @ 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q /* A+B+C+D+E fourth row */ 84 @ )*(1+spar/(X2-X1)) + 85 @ 86 @ ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 + u1*q))*(1/(X2-X1)) /* F matrix */ 87 @ 88 @ ) 89 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 90 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 91 @ 92 @ varf bhatPSEd([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 93 @ ( 94 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *usolprev*v1 + uBFx*usolprev*v1 + dy(uBF)*usolprevB*v1 + dx(uBF)*usolprevC*v1 + 1i*alpha*usolprevD*v1 + /* A first row */ 95 @ uBFB*dy(usolprev)*v1 + nudelta*dy(usolprev)*dy(v1) + uBFC*dx(usolprev)*v1 + nudelta*dx(usolprev)*dx(v1) + /* B+C+D+E first row */ 96 @ 97 @ uBFxB*usolprev*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *usolprevB*v2 + dy(uBFB)*usolprevB*v2 + dx(uBFB)*usolprevC*v2 + /* A second row */ 98 @ uBFB*dy(usolprevB)*v2 + dy(usolprevD)*v2 + nudelta*dy(usolprevB)*dy(v2) + uBFC*dx(usolprevB)*v2 + nudelta*dx(usolprevB)*dx(v2) + /* B+C+D+E second row */ 99 @ 100 @ uBFxC*usolprev*v3 + dy(uBFC)*usolprevB*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *usolprevC*v3 + dx(uBFC)*usolprevC*v3 + /* A third row */ 101 @ uBFB*dy(usolprevC)*v3 + nudelta*dy(usolprevC)*dy(v3) + uBFC*dx(usolprevC)*v3 + dx(usolprevD)*v3 + nudelta*dx(usolprevC)*dx(v3) + /* B+C+D+E third row */ 102 @ 103 @ 1i*alpha*usolprev*q + dy(usolprevB)*q + dx(usolprevC)*q /* A+B+C+D+E fourth row */ 104 @ )*(spar/(X2-X1)) + 105 @ 106 @ (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 + usol2Evalrhs*q) /* F matrix */ 107 @ 108 @ ) 109 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 110 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 111 @ 112 @ /* -------------------- Higher order scheme -------------------- */ 113 @ 114 @ varf AhatPSEd2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 115 @ ( 116 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 117 @ uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 118 @ 119 @ uBFxB*u1*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 120 @ uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 121 @ 122 @ uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 123 @ uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 124 @ 125 @ 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q /* A+B+C+D+E fourth row */ 126 @ )*(1+spar*(1/(X2-X0)+1/(X2-X1))) + 127 @ 128 @ ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (p*v1 + u1*q))*(1/(X2-X0)+1/(X2-X1)) /* F matrix */ 129 @ 130 @ ) 131 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 132 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 133 @ 134 @ varf bhatPSEd2([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 135 @ ( 136 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *usol2Evalrhs*v1 + uBFx*usol2Evalrhs*v1 + dy(uBF)*usol2EvalrhsB*v1 + dx(uBF)*usol2EvalrhsC*v1 + 1i*alpha*usol2EvalrhsD*v1 + /* A first row */ 137 @ uBFB*dy(usol2Evalrhs)*v1 + nudelta*dy(usol2Evalrhs)*dy(v1) + uBFC*dx(usol2Evalrhs)*v1 + nudelta*dx(usol2Evalrhs)*dx(v1) + /* B+C+D+E first row */ 138 @ 139 @ uBFxB*usol2Evalrhs*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *usol2EvalrhsB*v2 + dy(uBFB)*usol2EvalrhsB*v2 + dx(uBFB)*usol2EvalrhsC*v2 + /* A second row */ 140 @ uBFB*dy(usol2EvalrhsB)*v2 + dy(usol2EvalrhsD)*v2 + nudelta*dy(usol2EvalrhsB)*dy(v2) + uBFC*dx(usol2EvalrhsB)*v2 + nudelta*dx(usol2EvalrhsB)*dx(v2) + /* B+C+D+E second row */ 141 @ 142 @ uBFxC*usol2Evalrhs*v3 + dy(uBFC)*usol2EvalrhsB*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *usol2EvalrhsC*v3 + dx(uBFC)*usol2EvalrhsC*v3 + /* A third row */ 143 @ uBFB*dy(usol2EvalrhsC)*v3 + nudelta*dy(usol2EvalrhsC)*dy(v3) + uBFC*dx(usol2EvalrhsC)*v3 + dx(usol2EvalrhsD)*v3 + nudelta*dx(usol2EvalrhsC)*dx(v3) + /* B+C+D+E third row */ 144 @ 145 @ 1i*alpha*usol2Evalrhs*q + dy(usol2EvalrhsB)*q + dx(usol2EvalrhsC)*q /* A+B+C+D+E fourth row */ 146 @ )*spar + 147 @ (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2EvalrhsD*v1 + usol2Evalrhs*q) /* F matrix */ 148 @ ) 149 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 150 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 151 @ 152 @ 153 @ 154 @ /* ---------------------------------------- no dp/dx term ---------------------------------------- */ 155 @ 156 @ /* incomp. PSE A matrix varf - LHS */ 157 @ varf AhatPSEnodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 158 @ 159 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 160 @ uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 161 @ 162 @ uBFxB*u1*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 163 @ uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 164 @ 165 @ uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 166 @ uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 167 @ 168 @ 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 169 @ 170 @ ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (u1*q))*(1/(X2-X1)) /* F matrix */ 171 @ ) 172 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 173 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 174 @ 175 @ /* incomp. PSE b vector varf - RHS */ 176 @ varf bhatPSEnodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 177 @ (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2Evalrhs*q) /* F matrix */ 178 @ ) 179 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 180 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 181 @ 182 @ /* -------------------- Higher order scheme -------------------- */ 183 @ 184 @ /* incomp. PSE A matrix varf - LHS */ 185 @ varf AhatPSE2nodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 186 @ 187 @ zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u1*v1 + uBFx*u1*v1 + dy(uBF)*u2*v1 + dx(uBF)*u3*v1 + 1i*alpha*p*v1 + /* A first row */ 188 @ uBFB*dy(u1)*v1 + nudelta*dy(u1)*dy(v1) + uBFC*dx(u1)*v1 + nudelta*dx(u1)*dx(v1) + /* B+C+D+E first row */ 189 @ 190 @ uBFxB*u1*v2 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u2*v2 + dy(uBFB)*u2*v2 + dx(uBFB)*u3*v2 + /* A second row */ 191 @ uBFB*dy(u2)*v2 - p*dy(v2) + nudelta*dy(u2)*dy(v2) + uBFC*dx(u2)*v2 + nudelta*dx(u2)*dx(v2) + /* B+C+D+E second row */ 192 @ 193 @ uBFxC*u1*v3 + dy(uBFC)*u2*v3 + zetaPSE (1i*(alpha*uBF-omega)+alpha^2*nudelta) *u3*v3 + dx(uBFC)*u3*v3 + /* A third row */ 194 @ uBFB*dy(u3)*v3 + nudelta*dy(u3)*dy(v3) + uBFC*dx(u3)*v3 - p*dx(v3) + nudelta*dx(u3)*dx(v3) + /* B+C+D+E third row */ 195 @ 196 @ 1i*alpha*u1*q + dy(u2)*q + dx(u3)*q + /* A+B+C+D+E fourth row */ 197 @ 198 @ ((uBF-2*1i*alpha*nudelta)*(u1*v1 + u2*v2 + u3*v3) + (u1*q))*(1/(X2-X0)+1/(X2-X1)) /* F matrix */ 199 @ ) 200 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 201 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 202 @ 203 @ /* incomp. PSE b vector varf - RHS */ 204 @ varf bhatPSE2nodpdx([u1, u2, u3, p], [v1, v2, v3, q]) = int2d(th)( 205 @ (uBF-2*1i*alpha*nudelta)*(usol2Evalrhs*v1 + usol2EvalrhsB*v2 + usol2EvalrhsC*v3) + (usol2Evalrhs*q) /* F matrix */ 206 @ ) 207 @ + on(2, u1 = 0., u2 = 0., u3 = 0.) /* bot wall */ 208 @ + on(4, u1 = 0., u2 = 0., u3 = 0.); /* Free stream */ 209 @ 210 @ 211 @ 212 @ 213 : 214 : /* ----------------------------------------------------------------------------------------------------------------------------- */ 215 : 216 : IFMACRO(mAL) 217 & cout << "TODO" << endl; 218 & ENDIFMACRO 31 : include "../include/mat_icPSE.idp" 2 : /* setting up linear solver parameters - direct solver: TODO: iterative solver */ 3 : IFMACRO(!mAL) 4 & set(dJ, sparams = linsolvePar); 5 & ENDIFMACRO 4 @ set(dJ, sparams = linsolvePar); 5 @ 6 : 7 : 8 : 9 : func complex calcPSEnorm(complex &alpha, int nstep){ 10 : 11 : complex normval; 12 : real loctime = mpiWtime(); 13 : 14 : if(!isStepSizeAdmissible(alpha, allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep )){ 15 : if(enableDamping){ 16 : spar = calcDampingFactor(alpha, allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ); 17 : PetscLogStagePush("damping"); 18 : if(allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 19 : rhsvec = bhatPSEd2(0,VhC); 20 : dJ = AhatPSEd2(VhC,VhC); 21 : } else { 22 : rhsvec = bhatPSEd(0,VhC); 23 : dJ = AhatPSEd(VhC,VhC); 24 : } 25 : fixGridStabilizationFlag = true; 26 : } else if(noDpdx){ 27 : PetscLogStagePush("dropping px"); 28 : if(allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 29 : rhsvec = bhatPSE2nodpdx(0,VhC); 30 : dJ = AhatPSE2nodpdx(VhC,VhC); 31 : } else { 32 : rhsvec = bhatPSEnodpdx(0,VhC); 33 : dJ = AhatPSEnodpdx(VhC,VhC); 34 : } 35 : fixGridStabilizationFlag = true; 36 : } else { 37 : PetscLogStagePush("no stab but needed"); 38 : if(mpirank==0) cout << " ||||||||||||||| WARNING: STABILIZATION REQUIRED, ... : BUT NO STABILIZATION IS ENABLED!; Admissible dx=" << calcNormalStepSizeLimit(alpha, allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ) << " ||||||||||||||| " << endl; 39 : if(allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 40 : rhsvec = bhatPSE2(0,VhC); 41 : dJ = AhatPSE2(VhC,VhC); 42 : } else { 43 : rhsvec = bhatPSE(0,VhC); 44 : dJ = AhatPSE(VhC,VhC); 45 : } 46 : fixGridStabilizationFlag = false; 47 : } 48 : 49 : } else { /* --- no stabilization needed ----- */ 50 : PetscLogStagePush("no stab"); 51 : if(allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 52 : rhsvec = bhatPSE2(0,VhC); 53 : dJ = AhatPSE2(VhC,VhC); 54 : } else { 55 : rhsvec = bhatPSE(0,VhC); 56 : dJ = AhatPSE(VhC,VhC); 57 : } 58 : fixGridStabilizationFlag = false; 59 : } 60 : PetscLogStagePop(); 61 : if(mpirank==0 & linEqSolutionTimer){ 62 : loctime = mpiWtime() - loctime; 63 : cout << " ##### matrix assembly finished in " << loctime << " seconds ##### " << endl; 64 : loctime = mpiWtime(); 65 : } 66 : 67 : /* solving the system */ 68 : changeNumbering(dJ, rhsvec, rhsvecPETSc); 69 : KSPSolve(dJ, rhsvecPETSc, usolPETSc); 70 : ChangeNumbering(dJ, usol[], usolPETSc, inverse = true, exchange = true); 71 : 72 : if(mpirank==0 & linEqSolutionTimer){ 73 : loctime = mpiWtime() - loctime; 74 : cout << " ##### lin eq. solution finished in " << loctime << " seconds ##### " << endl; 75 : loctime = mpiWtime(); 76 : } 77 : 78 : 79 : /* trick: since 'rhsvecPETSc' is not needed anymore, it is used to calculate 80 : the derivative of x for the inner product */ 81 : 82 : rhsvecPETSc = usolPETSc; 83 : if(allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 84 : rhsvecPETSc *= (1/(X2-X0)+1/(X2-X1)); 85 : } else { 86 : rhsvecPETSc *= (1/(X2-X1)); 87 : } 88 : rhsvecPETSc -= usol2EvalrhsPETSc; 89 : /* mass matrix & integration */ 90 : integrateParallel(dM,usolPETSc,rhsvecPETSc,auxvecPETSc,normval) 328 @ 329 @ 330 @ 331 @ { 328 @ MatMult(dM, rhsvecPETSc, auxvecPETSc); 329 @ complex tempDistIntegral = usolPETSc' * auxvecPETSc; 330 @ mpiAllReduce(tempDistIntegral, normval, mpiCommWorld, mpiSUM); 331 @ } 91 : 92 : 93 : if(mpirank==0 & linEqSolutionTimer){ 94 : loctime = mpiWtime() - loctime; 95 : cout << " ##### parallel integation finished in " << loctime << " seconds ##### " << endl; 96 : loctime = mpiWtime(); 97 : } 98 : 99 : return normval; 100 : 101 : } 102 : 103 : 104 : /* ---------------------------------------------------------------------------------------------------- */ 105 : /* PSE stepping - solving for alpha*/ 106 : func int PSEstep(complex &alpha, int nstep){ 107 : 108 : complex fpre, f=1e30, alphapre=100+100i, dalpha = 1e2; 109 : int niter = -1; 110 : 111 : while(niter++intnormtol & abs(dalpha)>dalphatol){ 112 : 113 : f = calcPSEnorm(alpha, nstep); 114 : 115 : 116 : if(secantIterationAlpha & niter>0){ 117 : dalpha = -f*(alphapre - alpha) / (fpre - f); 118 : } else { 119 : /* fixpoint-type method - following Paredes 2014 Dissertation, which relies on the definition given by Herbert 1994 AGARD */ 120 : complex normSquare; 121 : integrateParallel(dM,usolPETSc,usolPETSc,auxvecPETSc,normSquare) 328 @ 329 @ 330 @ 331 @ { 328 @ MatMult(dM, usolPETSc, auxvecPETSc); 329 @ complex tempDistIntegral = usolPETSc' * auxvecPETSc; 330 @ mpiAllReduce(tempDistIntegral, normSquare, mpiCommWorld, mpiSUM); 331 @ } 122 : dalpha = -1i*f/normSquare; 123 : } 124 : if(abs(dalpha)>absstepalpha){ 125 : if(mpirank==0) cout << "|dalpha| > absolute step tolerance, scaling down ... : the step " << endl; 126 : dalpha = dalpha/abs(dalpha)*absstepalpha; 127 : /* 128 : if(mpirank==0) cout << "|dalpha| > absolute step tolerance, freezing alpha for the step " << endl; 129 : dalpha = 0.; 130 : */ 131 : } else if(abs(dalpha)>relstepalpha*abs(alpha)) { 132 : if(mpirank==0) cout << " |dalpha|/|alpha| > relative step tolerance, scal ... : ing down the step " << endl; 133 : dalpha = dalpha/abs(dalpha)*relstepalpha*abs(alpha); 134 : /* 135 : if(mpirank==0) cout << "|dalpha| > relative step tolerance, freezing alpha for the step " << endl; 136 : dalpha = 0.; 137 : */ 138 : } 139 : 140 : fpre = f; 141 : alphapre = alpha; 142 : alpha += dalpha; 143 : if(mpirank==0){ 144 : cout << "alpha iteration: niter = " << niter << (fixGridStabilizationFlag ? (enableDamping ? (", damped step: s=" + spar + " ") : 145 : (", step with dp/dx term neglected, admissible dx=" + calcNodpdxStepSizeLimit(alpha,allowBDF2(nstep) nstep>1 & BDF2 & !inPreStepFlag & !justExitPreStep ))) : ", regular step ") << ", |f| = " << abs(f) << ", |dalpha| = " << abs(dalpha) << ", alpha = " << alpha << endl; 146 : } 147 : 148 : /* initial step correction */ 149 : if(initcorrenabled==1 & initcorrind>nstep){ 150 : bool realtol = abs(real(alphaprev-alpha)/real(alphaprev))>initcorrreltol; 151 : /* TODO */ 152 : /* bool imagtol = abs(imag(alphaprev-alpha)/imag(alphaprev))>initcorrreltol; */ 153 : bool imagtol = false; 154 : if(realtol || imagtol){ 155 : alpha = alphaprev*(1-initcorrweight) + alpha*initcorrweight; 156 : f = calcPSEnorm(alpha, nstep); 157 : if(mpirank==0){ 158 : cout << "Initial step correction: realtol=" << realtol << ", imagtol=" << imagtol << endl; 159 : cout << "Alpha value=" << alpha << ", integral norm=" << abs(f) << endl; 160 : cout << "Exiting iteration" << endl; 161 : } 162 : break; 163 : 164 : } 165 : } 166 : 167 : 168 : } 169 : 170 : return 0; 171 : 172 : } 173 : 174 : /* --------------------------------------------------------------------------------------------------------------------------------------------------- */ 175 : /* pre-stepping at a fix grid: at the first nPreStep steps, smaller (potentially damped, if sParPreStep>0) substeps are taken; these substeps are not saved, only the fixgrid alpha is saved */ 176 : macro PSEprestep(inInd) 177 # 178 # if(preStep & nPreStep > inInd){ 179 # inPreStepFlag = true; 180 # if(mpirank==0) cout << " =================== PSE prestep started for step #" << inInd << " =================== " << endl; 181 # /* initial step size calculation: safety through the safety factor + lower rounding of the steps */ 182 # 183 # /*dX = calcPreStepdx(alphavec[inInd-1]);*/ 184 # dX = calcPreStepdx(alpha); 185 # enableDamping = true; 186 # /* number of steps: if not enough for an intermediate step, no prestepping */ 187 # int nPreStep = floor((XgridPSE[inInd]-XgridPSE[inInd-1])/dX); 188 # 189 # if(nPreStep>1){ 190 # /* recalculating dX: in the undamped case, since 'nPreStep' is rounded to the lower integer, 191 # this is necessary add some robustness regarding the stepsize limit */ 192 # dX = (XgridPSE[inInd]-XgridPSE[inInd-1])/(nPreStep+0.); 193 # /* prestep grid: n+1 because the point number is needed*/ 194 # real[int] XgridPreStep; 195 # linspace(XgridPreStep,XgridPSE[inInd-1],XgridPSE[inInd],nPreStep+1); 196 # 197 # /* actual stepping - last step is done in the outer solver, therefore ipre1){ 59 : setupPSEXgrid(j) 818 @ 819 @ 820 @ 821 @ 822 @ 823 @ 824 @ 825 @ /* nondim with x0 - BRE scale */ 826 @ 827 @ /* for a single x0 grid */ 828 @ 829 @ 830 @ /* for an x0(F) grid, roughly the same stepsize - TODO TEST*/ 831 @ 832 @ 833 @ 834 @ 835 @ 836 @ 837 @ 838 @ 839 @ 840 @ 841 @ 842 @ 843 @ 844 @ 845 @ 846 @ 847 @ 848 @ 849 @ 850 @ 851 @ 852 @ 853 @ 854 @ 818 @ 819 @ if(Fvec.n==XgridBiGlob.n){ 820 @ x0 = XgridBiGlob[j]; 821 @ } else { 822 @ x0 = XgridBiGlob[0]; 823 @ } 824 @ if(fixGrid){ 825 @ /* nondim with x0 - BRE scale */ 826 @ if(j==0){ 827 @ /* for a single x0 grid */ 828 @ setupXgrid(XgridPSE,x0,x1,nX) 859 @ 860 @ 861 @ 862 @ 863 @ 864 @ 865 @ 866 @ 867 @ 859 @ 860 @ if(dxtype==1){ 861 @ linspace(XgridPSE,sqrt(x0),sqrt(x1),nX) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ XgridPSE.resize(nX); 874 @ if(nX>1){ 875 @ real dx = (sqrt(x1) - sqrt(x0))/(nX - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = sqrt(x0); 877 @ for(int i=1; i1){ 875 @ real dx = (x1 - x0)/(nX - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = x0; 877 @ for(int i=1; i1){ 875 @ real dx = (sqrt(x1) - sqrt(x0))/(nXlocal - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = sqrt(x0); 877 @ for(int i=1; i1){ 875 @ real dx = (x1 - x0)/(nXlocal - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = x0; 877 @ for(int i=1; i> usol[]; 184 @ 185 @ } 611 @ alpha = alpha0mat(j,0); 612 @ alphavec = 0; 613 @ alphavec[0] = alpha; 614 @ alphaprev = alpha; 615 @ normEV(usol) 659 @ 660 @ /* real(Umax)=1 */ 661 @ 662 @ /* temporary FE field & condensing solution */ 663 @ 664 @ 665 @ /* gathered x component FE space */ 666 @ 667 @ /* extracting real part, and dividing with it's maximum*/ 668 @ 669 @ 670 @ 671 @ 672 @ 673 @ /* energy norm: consensing solution*/ 674 @ 675 @ 676 @ /* calculation and distribution of the factor */ 677 @ 678 @ 679 @ 680 @ /* because it is a quadratic funciton */ 681 @ 682 @ 683 @ 684 @ 685 @ 686 @ { 659 @ 660 @ /* real(Umax)=1 */ 661 @ if(normType==0){ 662 @ /* temporary FE field & condensing solution */ 663 @ VhCGlob gendef(uGloc) [uGloc, uGlocB, uGlocC, uGlocD]; 664 @ sendvecDistributed2Global(usol,uGloc) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGloc[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 665 @ /* gathered x component FE space */ 666 @ VP2Glob tempu = uGloc; 667 @ /* extracting real part, and dividing with it's maximum*/ 668 @ VP2Glob tempur; 669 @ tempur[] = tempu[].re; 670 @ complex normfac = tempur[] .max; 671 @ usol[] = usol[] / normfac; 672 @ } else if(normType==1){ 673 @ /* energy norm: consensing solution*/ 674 @ VhCGlob gendef(uGloc) [uGloc, uGlocB, uGlocC, uGlocD]; 675 @ sendvecDistributed2Global(usol,uGloc) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGloc[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 676 @ /* calculation and distribution of the factor */ 677 @ complex locKinEnerg; 678 @ if(mpirank==0){ 679 @ locKinEnerg = 0.5*int2d(thGlobal, qforder=3)(conj(uGloc)*uGloc + conj(uGlocB)*uGlocB + conj(uGlocC)*uGlocC); 680 @ locKinEnerg = sqrt(locKinEnerg); /* because it is a quadratic funciton */ 681 @ } 682 @ broadcast(processor(0),locKinEnerg); 683 @ usol[] *= (1./locKinEnerg); 684 @ } 685 @ 686 @ } 616 @ 617 @ indBRE = 0; 618 @ indBREprev = -1; 619 @ 620 @ 63 : 64 : for(int i = 1; i < XgridPSE.n; i++){ 65 : 66 : PSEprestep(i) 177 @ 178 @ 179 @ 180 @ 181 @ /* initial step size calculation: safety through the safety factor + lower rounding of the steps */ 182 @ 183 @ /*dX = calcPreStepdx(alphavec[inInd-1]);*/ 184 @ 185 @ 186 @ /* number of steps: if not enough for an intermediate step, no prestepping */ 187 @ 188 @ 189 @ 190 @ /* recalculating dX: in the undamped case, since 'nPreStep' is rounded to the lower integer, 191 @ this is necessary add some robustness regarding the stepsize limit */ 192 @ 193 @ /* prestep grid: n+1 because the point number is needed*/ 194 @ 195 @ 196 @ 197 @ /* actual stepping - last step is done in the outer solver, therefore ipre i){ 179 @ inPreStepFlag = true; 180 @ if(mpirank==0) cout << " =================== PSE prestep started for step ... : #" << i << " =================== " << endl; 181 @ /* initial step size calculation: safety through the safety factor + lower rounding of the steps */ 182 @ 183 @ /*dX = calcPreStepdx(alphavec[inInd-1]);*/ 184 @ dX = calcPreStepdx(alpha); 185 @ enableDamping = true; 186 @ /* number of steps: if not enough for an intermediate step, no prestepping */ 187 @ int nPreStep = floor((XgridPSE[i]-XgridPSE[i-1])/dX); 188 @ 189 @ if(nPreStep>1){ 190 @ /* recalculating dX: in the undamped case, since 'nPreStep' is rounded to the lower integer, 191 @ this is necessary add some robustness regarding the stepsize limit */ 192 @ dX = (XgridPSE[i]-XgridPSE[i-1])/(nPreStep+0.); 193 @ /* prestep grid: n+1 because the point number is needed*/ 194 @ real[int] XgridPreStep; 195 @ linspace(XgridPreStep,XgridPSE[i-1],XgridPSE[i],nPreStep+1) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ XgridPreStep.resize(nPreStep+1); 874 @ if(nPreStep+1>1){ 875 @ real dx = (XgridPSE[i] - XgridPSE[i-1])/(nPreStep+1 - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPreStep[0] = XgridPSE[i-1]; 877 @ for(int i=1; i> uBFn[]; 184 @ 185 @ } 426 @ indBREprev = indBRE - 2; 427 @ import2DField(uBFprevprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprevprev[]; 184 @ 185 @ } 428 @ indBREprev = indBRE - 1; 429 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 430 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 431 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 432 @ scaleVelBRE2Normal(uBFprevprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprevprev) [uBFprevprev, uBFprevprevB, uBFprevprevC, uBFprevprevD] = [uBFprevprev, uBFprevprevB/sqrt(Rey), uBFprevprevC/sqrt(Rey), uBFprevprevD/Rey]; 637 @ 638 @ } 433 @ } else if(indBRE-2>indBREprev){ 434 @ uBFprevprev[] = uBFn[]; 435 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 436 @ indBREprev = indBRE - 1; 437 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 438 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 439 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 440 @ } else if(indBRE-1>indBREprev){ /* read and scale only one */ 441 @ uBFprevprev[] = uBFprev[]; 442 @ uBFprev[] = uBFn[]; 443 @ indBREprev = indBRE - 1; 444 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 445 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 446 @ } 447 @ /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 @ 449 @ 450 @ /* interpolate the current BF */ 451 @ if(indBRE>1){ 452 @ real dx2 = XgridBRE[indBRE] - XgridBRE[indBREprev-1]; 453 @ real dx1 = XgridBRE[indBREprev] - XgridBRE[indBREprev-1]; 454 @ real relx = XgridPreStep[ipre] - XgridBRE[indBREprev-1]; 455 @ uBF[] = ((dx2 - relx)/dx2 - (relx*(dx2 - relx))/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((relx*(dx2 - relx))/(dx1*dx2) - (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 456 @ uBF[] += uBFn[]*(relx/dx2 + (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 457 @ uBFx[] = (- 1/dx2 - (dx2 - 2*relx)/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((dx2 - 2*relx)/(dx1*dx2) - (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 458 @ uBFx[] += uBFn[]*(1/dx2 + (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 459 @ /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 @ 461 @ } else { 462 @ uBFx[] = uBFn[] - uBFprev[]; 463 @ uBFx[] *= (1/(XgridBRE[indBRE] - XgridBRE[indBREprev])); 464 @ real interdX = (XgridPreStep[ipre] - XgridBRE[indBRE-1])/(XgridBRE[indBRE] - XgridBRE[indBREprev]); 465 @ if(abs(interdX) < 1e-6){ 466 @ uBF[] = uBFprev[]; 467 @ } else { 468 @ uBF[] = (1-interdX)*uBFprev[] + uBFn[]*interdX; 469 @ } 470 @ /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 @ } 472 @ 473 @ 474 @ 475 @ 684 @ 685 @ /* saving old variables */ 686 @ usolprevprev[] = usolprev[]; 687 @ usolprev[] = usol[]; 688 @ alphaprevprev = alphaprev; 689 @ alphaprev = alpha; 690 @ 691 @ /* x variable, vector setup for efficient RSH evaluation */ 692 @ if(allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 693 @ X0 = XgridPreStep[ipre-2]; 694 @ X1 = XgridPreStep[ipre-1]; 695 @ X2 = XgridPreStep[ipre]; 696 @ dX = X2 - X1; 697 @ /* RHS setup and gathering for integral criterion calculation */ 698 @ usol2Evalrhs[] = usolprevprev[] *(1/(X2-X0)-1/(X1-X0)) + usolprev[]*(1/(X2-X1)+1/(X1-X0)); 699 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 700 @ } else { 701 @ /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 @ if(justExitPreStep){ 703 @ X1 = X2; 704 @ justExitPreStep = false; 705 @ } else { 706 @ X1 = XgridPreStep[ipre-1]; 707 @ } 708 @ X2 = XgridPreStep[ipre]; 709 @ dX = X2 - X1; 710 @ /* RHS setup and gathering for integral criterion calculation */ 711 @ usol2Evalrhs[] = usolprev[] *(1. / (X2 - X1)); 712 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 713 @ } 714 @ changeNumbering(dJ, usol2Evalrhs[], usol2EvalrhsPETSc); 715 @ 716 @ /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 @ if(false & ipre>initcorrind & !inPreStepFlag){ 718 @ alpha = (alphaprev - alphaprevprev) ; 719 @ alpha = alpha * (1./(X1-X0)*(X2-X1)); 720 @ alpha += alphaprev; 721 @ } 722 @ 723 @ /* step size info */ 724 @ if(mpirank==0){ 725 @ if(inPreStepFlag){ 726 @ cout << " ==== PSE pre-step, BDF order=" << (allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << endl; 727 @ } else { 728 @ cout << " #### PSE " << (fixGrid ? "fix grid" : "adaptive") << " step, BDF order=" << (allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << 729 @ ", inital normal admissible stepsize=" << calcNormalStepSizeLimit(alpha,allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ) << endl; 730 @ } 731 @ 732 @ } 733 @ 734 @ 201 @ 202 @ PSEstep(alpha,ipre); 203 @ 204 @ } 205 @ /* turn on flag for proper small outer step size*/ 206 @ justExitPreStep = true; 207 @ 208 @ } else { 209 @ if(mpirank==0) cout << " ===== Fix grid prestepping requested; however, p ... : restep size is smaller than the dX limit ===== " << endl; 210 @ if(mpirank==0) cout << " ===== XgridPSE[inInd-1]=" << XgridPSE[i-1] << ", XgridPSE[inInd]=" << XgridPSE[i] << ", dX=" << dX << " ===== " << endl; 211 @ if(!enableDamping & mpirank==0) { 212 @ cout << " ================================================ ... : ================================================== ... : ================================================== ... : == " << endl; 213 @ cout << " ============================== WARNING: NUMERICA ... : L INSTABILITY OF THE MARCHING SCHEME IS POSSIBLE D ... : UE TO SMALL STEP SIZE ============================ ... : == " << endl; 214 @ cout << " ================================================ ... : ================================================== ... : ================================================== ... : == " << endl; 215 @ } 216 @ } 217 @ inPreStepFlag = false; 218 @ /* upon exiting prestepping, turn off damping if needed */ 219 @ } else if(nPreStep==i) { 220 @ if(mpirank==0) cout << " ========== Prestepping finished: out of the pre ... : stepping range ========== " << endl; 221 @ /* turn off damping after prestepping if not requested */ 222 @ if(!enableDampingPostPrestep){ 223 @ if(mpirank==0) cout << " ========== damping switched off after pre ... : stepping ========== " << endl; 224 @ enableDamping = false; 225 @ spar = 0.; 226 @ } 227 @ } 228 @ 229 @ 67 : 68 : PSEinitstep(XgridPSE,i) 671 @ 672 @ /* print different for prestep and normal step */ 673 @ 674 @ 675 @ 676 @ 677 @ 678 @ 679 @ 680 @ 681 @ 682 @ /* calculation of the BF velocity profile */ 683 @ 684 @ 685 @ /* saving old variables */ 686 @ 687 @ 688 @ 689 @ 690 @ 691 @ /* x variable, vector setup for efficient RSH evaluation */ 692 @ 693 @ 694 @ 695 @ 696 @ 697 @ /* RHS setup and gathering for integral criterion calculation */ 698 @ 699 @ 700 @ 701 @ /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 @ 703 @ 704 @ 705 @ 706 @ 707 @ 708 @ 709 @ 710 @ /* RHS setup and gathering for integral criterion calculation */ 711 @ 712 @ 713 @ 714 @ 715 @ 716 @ /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 @ 718 @ 719 @ 720 @ 721 @ 722 @ 723 @ /* step size info */ 724 @ 725 @ 726 @ 727 @ 728 @ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 671 @ 672 @ /* print different for prestep and normal step */ 673 @ real looptime = mpiWtime(); 674 @ if(mpirank==0){ 675 @ if(inPreStepFlag){ 676 @ cout << " ======================= PSE prestep #" << i << " started ======================= " << endl; 677 @ } else { 678 @ cout << " ######################## PSE step #" << i << " started ######################### " << endl; 679 @ } 680 @ } 681 @ 682 @ /* calculation of the BF velocity profile */ 683 @ setPSEBF(XgridPSE[i]) 417 @ 418 @ /* increase BRE index if needed */ 419 @ 420 @ 421 @ 422 @ 423 @ /* if index is inceased, read the new data, and shift, depending on the number of skipped cells */ 424 @ 425 @ 426 @ 427 @ 428 @ 429 @ 430 @ 431 @ 432 @ 433 @ 434 @ 435 @ 436 @ 437 @ 438 @ 439 @ 440 @ /* read and scale only one */ 441 @ 442 @ 443 @ 444 @ 445 @ 446 @ 447 @ /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 @ 449 @ 450 @ /* interpolate the current BF */ 451 @ 452 @ 453 @ 454 @ 455 @ 456 @ 457 @ 458 @ 459 @ /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 @ 461 @ 462 @ 463 @ 464 @ 465 @ 466 @ 467 @ 468 @ 469 @ 470 @ /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 @ 472 @ 473 @ 474 @ 475 @ 417 @ 418 @ /* increase BRE index if needed */ 419 @ while(XgridBRE[indBRE]<=XgridPSE[i]& indBRE < XgridBRE.n-1){ 420 @ indBRE++; 421 @ } 422 @ 423 @ /* if index is inceased, read the new data, and shift, depending on the number of skipped cells */ 424 @ if(indBRE-3>indBREprev){ 425 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 426 @ indBREprev = indBRE - 2; 427 @ import2DField(uBFprevprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprevprev[]; 184 @ 185 @ } 428 @ indBREprev = indBRE - 1; 429 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 430 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 431 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 432 @ scaleVelBRE2Normal(uBFprevprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprevprev) [uBFprevprev, uBFprevprevB, uBFprevprevC, uBFprevprevD] = [uBFprevprev, uBFprevprevB/sqrt(Rey), uBFprevprevC/sqrt(Rey), uBFprevprevD/Rey]; 637 @ 638 @ } 433 @ } else if(indBRE-2>indBREprev){ 434 @ uBFprevprev[] = uBFn[]; 435 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 436 @ indBREprev = indBRE - 1; 437 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 438 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 439 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 440 @ } else if(indBRE-1>indBREprev){ /* read and scale only one */ 441 @ uBFprevprev[] = uBFprev[]; 442 @ uBFprev[] = uBFn[]; 443 @ indBREprev = indBRE - 1; 444 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 445 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 446 @ } 447 @ /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 @ 449 @ 450 @ /* interpolate the current BF */ 451 @ if(indBRE>1){ 452 @ real dx2 = XgridBRE[indBRE] - XgridBRE[indBREprev-1]; 453 @ real dx1 = XgridBRE[indBREprev] - XgridBRE[indBREprev-1]; 454 @ real relx = XgridPSE[i] - XgridBRE[indBREprev-1]; 455 @ uBF[] = ((dx2 - relx)/dx2 - (relx*(dx2 - relx))/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((relx*(dx2 - relx))/(dx1*dx2) - (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 456 @ uBF[] += uBFn[]*(relx/dx2 + (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 457 @ uBFx[] = (- 1/dx2 - (dx2 - 2*relx)/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((dx2 - 2*relx)/(dx1*dx2) - (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 458 @ uBFx[] += uBFn[]*(1/dx2 + (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 459 @ /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 @ 461 @ } else { 462 @ uBFx[] = uBFn[] - uBFprev[]; 463 @ uBFx[] *= (1/(XgridBRE[indBRE] - XgridBRE[indBREprev])); 464 @ real interdX = (XgridPSE[i] - XgridBRE[indBRE-1])/(XgridBRE[indBRE] - XgridBRE[indBREprev]); 465 @ if(abs(interdX) < 1e-6){ 466 @ uBF[] = uBFprev[]; 467 @ } else { 468 @ uBF[] = (1-interdX)*uBFprev[] + uBFn[]*interdX; 469 @ } 470 @ /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 @ } 472 @ 473 @ 474 @ 475 @ 684 @ 685 @ /* saving old variables */ 686 @ usolprevprev[] = usolprev[]; 687 @ usolprev[] = usol[]; 688 @ alphaprevprev = alphaprev; 689 @ alphaprev = alpha; 690 @ 691 @ /* x variable, vector setup for efficient RSH evaluation */ 692 @ if(allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 693 @ X0 = XgridPSE[i-2]; 694 @ X1 = XgridPSE[i-1]; 695 @ X2 = XgridPSE[i]; 696 @ dX = X2 - X1; 697 @ /* RHS setup and gathering for integral criterion calculation */ 698 @ usol2Evalrhs[] = usolprevprev[] *(1/(X2-X0)-1/(X1-X0)) + usolprev[]*(1/(X2-X1)+1/(X1-X0)); 699 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 700 @ } else { 701 @ /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 @ if(justExitPreStep){ 703 @ X1 = X2; 704 @ justExitPreStep = false; 705 @ } else { 706 @ X1 = XgridPSE[i-1]; 707 @ } 708 @ X2 = XgridPSE[i]; 709 @ dX = X2 - X1; 710 @ /* RHS setup and gathering for integral criterion calculation */ 711 @ usol2Evalrhs[] = usolprev[] *(1. / (X2 - X1)); 712 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 713 @ } 714 @ changeNumbering(dJ, usol2Evalrhs[], usol2EvalrhsPETSc); 715 @ 716 @ /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 @ if(false & i>initcorrind & !inPreStepFlag){ 718 @ alpha = (alphaprev - alphaprevprev) ; 719 @ alpha = alpha * (1./(X1-X0)*(X2-X1)); 720 @ alpha += alphaprev; 721 @ } 722 @ 723 @ /* step size info */ 724 @ if(mpirank==0){ 725 @ if(inPreStepFlag){ 726 @ cout << " ==== PSE pre-step, BDF order=" << (allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << endl; 727 @ } else { 728 @ cout << " #### PSE " << (fixGrid ? "fix grid" : "adaptive") << " step, BDF order=" << (allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << 729 @ ", inital normal admissible stepsize=" << calcNormalStepSizeLimit(alpha,allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ) << endl; 730 @ } 731 @ 732 @ } 733 @ 734 @ 69 : 70 : PSEstep(alpha,i); 71 : 72 : PSEfinalizestep(j,i) 739 @ 740 @ 741 @ 742 @ 743 @ /* txt output */ 744 @ 745 @ 746 @ 747 @ 748 @ 749 @ /* VTU output */ 750 @ 751 @ 752 @ 753 @ 754 @ 755 @ 756 @ /* timing */ 757 @ 758 @ 759 @ 760 @ 761 @ 762 @ 763 @ 739 @ 740 @ alphavec[i] = alpha; 741 @ getPSEGrowth(i) 481 @ 482 @ 483 @ 484 @ /* first step - calculate the initial energy - the previous value is in the auxiliary RHS vec in PETSc numbering, divided by dX*/ 485 @ 486 @ 487 @ 488 @ 489 @ 490 @ 491 @ 492 @ 493 @ 494 @ /* if velocity-based growth rate is requested, collect the distributed solution */ 495 @ 496 @ 497 @ 498 @ 499 @ 500 @ /* function for max search*/ 501 @ 502 @ 503 @ 504 @ 505 @ 506 @ /* first step - search for the maximum*/ 507 @ /* TODO TODO - ACCURATE INITIAL GUESS */ 508 @ 509 @ 510 @ 511 @ 512 @ 513 @ 514 @ 515 @ /* max search */ 516 @ 517 @ 518 @ /* calculating the derivative at the maximum location */ 519 @ 520 @ 521 @ 522 @ 523 @ 524 @ /* first step - derivative is the same */ 525 @ 526 @ 527 @ 528 @ 529 @ 530 @ 531 @ 532 @ 533 @ 534 @ 535 @ 536 @ 537 @ 538 @ 539 @ /* function for max search*/ 540 @ 541 @ 542 @ 543 @ 544 @ 545 @ 546 @ 547 @ 548 @ 549 @ 550 @ /* max search */ 551 @ 552 @ 553 @ /* calculating the derivative at the maximum location */ 554 @ 555 @ 556 @ 557 @ 558 @ 559 @ /* first step - derivative is the same */ 560 @ 561 @ 562 @ 563 @ 564 @ 565 @ 566 @ 567 @ 568 @ 569 @ 570 @ 571 @ 572 @ 573 @ 574 @ { 481 @ int locind = -1; 482 @ if(growthEnergy==1){ 483 @ locind++; 484 @ /* first step - calculate the initial energy - the previous value is in the auxiliary RHS vec in PETSc numbering, divided by dX*/ 485 @ if(i==1){ 486 @ integrateParallel(dMvel,usol2EvalrhsPETSc,usol2EvalrhsPETSc,auxvecPETSc,energyvec[i-1]) 328 @ 329 @ 330 @ 331 @ { 328 @ MatMult(dMvel, usol2EvalrhsPETSc, auxvecPETSc); 329 @ complex tempDistIntegral = usol2EvalrhsPETSc' * auxvecPETSc; 330 @ mpiAllReduce(tempDistIntegral, energyvec[i-1], mpiCommWorld, mpiSUM); 331 @ } 487 @ energyvec[i-1] = energyvec[i-1] * (0.5 * (X2-X1)^2); 488 @ 489 @ } 490 @ integrateParallel(dMvel,usolPETSc,usolPETSc,auxvecPETSc,energyvec[i]) 328 @ 329 @ 330 @ 331 @ { 328 @ MatMult(dMvel, usolPETSc, auxvecPETSc); 329 @ complex tempDistIntegral = usolPETSc' * auxvecPETSc; 330 @ mpiAllReduce(tempDistIntegral, energyvec[i], mpiCommWorld, mpiSUM); 331 @ } 491 @ energyvec[i] *= 0.5; 492 @ } 493 @ 494 @ /* if velocity-based growth rate is requested, collect the distributed solution */ 495 @ if(growthU==1 || growthV==1) { 496 @ sendvecDistributed2Global(usol,uGlobal) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal[], mpiCommWorld, mpiSUM); 750 @ 751 @ }; 497 @ } 498 @ 499 @ if(growthU==1){ 500 @ /* function for max search*/ 501 @ func real interp2uOptfun(real[int] zy){ 502 @ real out = -abs(uGlobal(zy[0],zy[1])); 503 @ return out; 504 @ } 505 @ 506 @ /* first step - search for the maximum*/ 507 @ /* TODO TODO - ACCURATE INITIAL GUESS */ 508 @ 509 @ if(i==1){ 510 @ VP1Glob uP1, uP1x = x, uP1y = y; 511 @ uP1 = abs(uGlobal); 512 @ growthUZY[0] = uP1x[][uP1[].imax]; 513 @ growthUZY[1] = uP1y[][uP1[].imax]; 514 @ } 515 @ /* max search */ 516 @ complex umax = nloptNelderMead(interp2uOptfun,growthUZY,stopAbsFTol=1e-8,stopRelXTol=1e-8); 517 @ complex umaxc = uGlobal(growthUZY[0],growthUZY[1]); 518 @ /* calculating the derivative at the maximum location */ 519 @ if(i>1 & BDF2){ 520 @ growthmat(i,++locind) = (umaxc*(1/(X2-X0)+1/(X2-X1))-uGlobal2Evalrhs(growthUZY[0],growthUZY[1]))/umaxc; 521 @ } else { 522 @ growthmat(i,++locind) = (umaxc*(1/(X2-X1))-uGlobal2Evalrhs(growthUZY[0],growthUZY[1]))/umaxc; 523 @ } 524 @ /* first step - derivative is the same */ 525 @ if(i==1){ 526 @ growthmat(i-1,locind) = growthmat(i,locind); 527 @ } 528 @ IFMACRO(GROWTHDEBUG) 529 & growthmatDEBUGu(i,0) = growthUZY[0]; 530 & growthmatDEBUGu(i,1) = growthUZY[1]; 531 & if(i==1){ 532 & growthmatDEBUGu(i-1,0) = growthmatDEBUGu(i,0); 533 & growthmatDEBUGu(i-1,1) = growthmatDEBUGu(i,1); 534 & } 535 & ENDIFMACRO 536 @ } 537 @ 538 @ if(growthV==1){ 539 @ /* function for max search*/ 540 @ func real interp2uOptfun(real[int] zy){ 541 @ real out = -abs(uGlobalB(zy[0],zy[1])); 542 @ return out; 543 @ } 544 @ if(i==1){ 545 @ VP1Glob uP1, uP1x = x, uP1y = y; 546 @ uP1 = abs(uGlobalB); 547 @ growthVZY[0] = uP1x[][uP1[].imax]; 548 @ growthVZY[1] = uP1y[][uP1[].imax]; 549 @ } 550 @ /* max search */ 551 @ complex umax = nloptNelderMead(interp2uOptfun,growthVZY,stopAbsFTol=1e-8,stopRelXTol=1e-8); 552 @ complex umaxc = uGlobalB(growthVZY[0],growthVZY[1]); 553 @ /* calculating the derivative at the maximum location */ 554 @ if(i>1 & BDF2){ 555 @ growthmat(i,++locind) = (umaxc*(1/(X2-X0)+1/(X2-X1))-uGlobal2EvalrhsB(growthVZY[0],growthVZY[1]))/umaxc; 556 @ } else { 557 @ growthmat(i,++locind) = (umaxc*(1/(X2-X1))-uGlobal2EvalrhsB(growthVZY[0],growthVZY[1]))/umaxc; 558 @ } 559 @ /* first step - derivative is the same */ 560 @ if(i==1){ 561 @ growthmat(i-1,locind) = growthmat(i,locind); 562 @ } 563 @ IFMACRO(GROWTHDEBUG) 564 & growthmatDEBUGv(i,0) = growthVZY[0]; 565 & growthmatDEBUGv(i,1) = growthVZY[1]; 566 & if(i==1){ 567 & growthmatDEBUGv(i-1,0) = growthmatDEBUGv(i,0); 568 & growthmatDEBUGv(i-1,1) = growthmatDEBUGv(i,1); 569 & } 570 & ENDIFMACRO 571 @ 572 @ } 573 @ 574 @ } 742 @ 743 @ /* txt output */ 744 @ if(abs(fmod(i*nF+j+0.,overbfreq+0.))<1e-8){ 745 @ string auxname = "j" + j + "_i" + i; 746 @ export2DField(usol,"PSE",oname,auxname) 157 @ 158 @ 159 @ 160 @ 161 @ 162 @ 163 @ 164 @ 165 @ 166 @ 167 @ 168 @ 169 @ { 157 @ 158 @ string ofname; 159 @ if(auxname<0){ 160 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_np" + mpisize + "_" + mpirank + ".dat"; 161 @ } else { 162 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname + "_np" + mpisize + "_" + mpirank + ".dat"; 163 @ } 164 @ 165 @ ofstream ofile(ofname); 166 @ ofile.precision(16); 167 @ ofile << usol[] << endl; 168 @ 169 @ } 747 @ } 748 @ 749 @ /* VTU output */ 750 @ if(abs(fmod(i*nF+j+0.,overbfreqVTU+0.))<1e-8){ 751 @ string auxname = "j" + j + "_i" + i; 752 @ sendvecDistributed2Global(usol,uGlobal) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 753 @ VTUexportGendata(uGlobal,"PSE",oname,auxname) 190 @ 191 @ 192 @ 193 @ 194 @ 195 @ 196 @ 197 @ 198 @ 199 @ 200 @ 201 @ 202 @ 203 @ 204 @ 205 @ 206 @ 207 @ 208 @ { 190 @ IFMACRO(BRE) 191 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,uGlobal,uGlobalB,uGlobalC,uGlobalD, 192 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 193 & ENDIFMACRO 194 @ IFMACRO(EV) 195 & VhCGlob gendef(uGr),gendef(uGi); 196 & uGr[] = uGlobal[].re; 197 & uGi[] = uGlobal[].im; 198 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 199 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 200 & ENDIFMACRO 201 @ IFMACRO(PSE) 202 & VhCGlob gendef(uGr),gendef(uGi); 203 & uGr[] = uGlobal[].re; 204 & uGi[] = uGlobal[].im; 205 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 & ENDIFMACRO 202 @ VhCGlob gendef(uGr) [uGr, uGrB, uGrC, uGrD],gendef(uGi) [uGi, uGiB, uGiC, uGiD]; 203 @ uGr[] = uGlobal[].re; 204 @ uGi[] = uGlobal[].im; 205 @ savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 @ dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 @ 208 @ } 754 @ } 755 @ 756 @ /* timing */ 757 @ looptime = mpiWtime() - looptime; 758 @ if(mpirank==0){ 759 @ cout << " ##### PSE step #" << i << " successfully finished in " << looptime << " seconds ##### " << endl; 760 @ cout << " ################################################ ... : ######################### " << endl; 761 @ } 762 @ 763 @ 73 : 74 : } 75 : 76 : PSEoutput 768 @ 769 @ 770 @ 771 @ 772 @ 773 @ 774 @ 775 @ 776 @ 777 @ 778 @ 779 @ 780 @ 781 @ 782 @ 783 @ 784 @ 785 @ 786 @ 787 @ 788 @ 789 @ 790 @ 768 @ 769 @ calcPSEGrowthE 579 @ 580 @ 581 @ /* in-loop integrals are calculated on rank 0 only, broadcast it now*/ 582 @ 583 @ 584 @ /* loadin the data into a matrix - only way to create a spline */ 585 @ 586 @ 587 @ 588 @ /* dummymat(1,nn) = abs(energyvec[nn]); */ /* alternative calculationmethod? */ 589 @ 590 @ 591 @ /* spline creation */ 592 @ 593 @ /* energy growth calculation using the spline */ 594 @ 595 @ /* growthmat(nn,locind) = splineEnergyvar.d(XgridPSE[nn])/splineEnergy(XgridPSE[nn]); */ /* alternative calculationmethod? */ 596 @ 597 @ 598 @ 599 @ 600 @ 601 @ 602 @ { 579 @ if(growthEnergy==1 & XgridPSE.n>2){ 580 @ 581 @ /* in-loop integrals are calculated on rank 0 only, broadcast it now*/ 582 @ broadcast(processor(0),energyvec); 583 @ 584 @ /* loadin the data into a matrix - only way to create a spline */ 585 @ real[int,int] dummymat(2,XgridPSE.n); 586 @ for(int nn=0; nn2){ 599 @ if(mpirank==0) cout << "Number of steps is small to calculate the energy ... : growth with spline interpolation" << endl; 600 @ } 601 @ } 602 @ 770 @ { 771 @ string auxname = "j" + j; 772 @ exportVec(XgridPSE,"PSE",oname + "_Xgrid_" + auxname) 77 @ 78 @ 79 @ 80 @ 81 @ 82 @ 83 @ 84 @ 85 @ 86 @ 87 @ 88 @ { 77 @ 78 @ if(mpirank==0){ 79 @ string ofname; 80 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_Xgrid_" + auxname + ".dat"; 81 @ 82 @ ofstream ofile(ofname); 83 @ ofile.precision(16); 84 @ ofile << XgridPSE.n << endl; 85 @ ofile << XgridPSE << endl; 86 @ } 87 @ 88 @ } 773 @ exportVec(alphavec,"PSE",oname + "_alphavec_" + auxname) 77 @ 78 @ 79 @ 80 @ 81 @ 82 @ 83 @ 84 @ 85 @ 86 @ 87 @ 88 @ { 77 @ 78 @ if(mpirank==0){ 79 @ string ofname; 80 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_alphavec_" + auxname + ".dat"; 81 @ 82 @ ofstream ofile(ofname); 83 @ ofile.precision(16); 84 @ ofile << alphavec.n << endl; 85 @ ofile << alphavec << endl; 86 @ } 87 @ 88 @ } 774 @ exportMat(growthmat,"PSE",oname + "_growthmat_" + auxname) 115 @ 116 @ 117 @ 118 @ 119 @ 120 @ 121 @ 122 @ 123 @ 124 @ 125 @ 126 @ 127 @ { 115 @ 116 @ if(mpirank==0){ 117 @ string ofname; 118 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_growthmat_" + auxname + ".dat"; 119 @ 120 @ ofstream ofile(ofname); 121 @ ofile.precision(16); 122 @ ofile << growthmat.n << endl; 123 @ ofile << growthmat.m << endl; 124 @ ofile << growthmat << endl; 125 @ } 126 @ 127 @ } 775 @ IFMACRO(GROWTHDEBUG) 776 & exportMat(growthmatDEBUGu,"PSE",oname + "_growthmatDEBUGu_" + auxname) 777 & exportMat(growthmatDEBUGv,"PSE",oname + "_growthmatDEBUGv_" + auxname) 778 & ENDIFMACRO 779 @ sendvecDistributed2Global(usol,uGlobal) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 780 @ VTUexportGendata(uGlobal,"PSE",oname,auxname) 190 @ 191 @ 192 @ 193 @ 194 @ 195 @ 196 @ 197 @ 198 @ 199 @ 200 @ 201 @ 202 @ 203 @ 204 @ 205 @ 206 @ 207 @ 208 @ { 190 @ IFMACRO(BRE) 191 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,uGlobal,uGlobalB,uGlobalC,uGlobalD, 192 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 193 & ENDIFMACRO 194 @ IFMACRO(EV) 195 & VhCGlob gendef(uGr),gendef(uGi); 196 & uGr[] = uGlobal[].re; 197 & uGi[] = uGlobal[].im; 198 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 199 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 200 & ENDIFMACRO 201 @ IFMACRO(PSE) 202 & VhCGlob gendef(uGr),gendef(uGi); 203 & uGr[] = uGlobal[].re; 204 & uGi[] = uGlobal[].im; 205 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 & ENDIFMACRO 202 @ VhCGlob gendef(uGr) [uGr, uGrB, uGrC, uGrD],gendef(uGi) [uGi, uGiB, uGiC, uGiD]; 203 @ uGr[] = uGlobal[].re; 204 @ uGi[] = uGlobal[].im; 205 @ savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 @ dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 @ 208 @ } 781 @ } 782 @ 783 @ runtimeF = mpiWtime() - runtimeF; 784 @ if(mpirank==0){ 785 @ cout << " ------------------------------------------------ ... : -------------------------- " << endl; 786 @ cout << " ### PSE calculation at F index #" << j << ", F=" << Fvec[j] << ", omega =" << omega << " successfully finished in " << runtimeF << " seconds ##### " << endl; 787 @ cout << " ------------------------------------------------ ... : -------------------------- " << endl; 788 @ } 789 @ 790 @ 77 : 78 : } else { 79 : 80 : setupPSEXgrid(j) 818 @ 819 @ 820 @ 821 @ 822 @ 823 @ 824 @ 825 @ /* nondim with x0 - BRE scale */ 826 @ 827 @ /* for a single x0 grid */ 828 @ 829 @ 830 @ /* for an x0(F) grid, roughly the same stepsize - TODO TEST*/ 831 @ 832 @ 833 @ 834 @ 835 @ 836 @ 837 @ 838 @ 839 @ 840 @ 841 @ 842 @ 843 @ 844 @ 845 @ 846 @ 847 @ 848 @ 849 @ 850 @ 851 @ 852 @ 853 @ 854 @ 818 @ 819 @ if(Fvec.n==XgridBiGlob.n){ 820 @ x0 = XgridBiGlob[j]; 821 @ } else { 822 @ x0 = XgridBiGlob[0]; 823 @ } 824 @ if(fixGrid){ 825 @ /* nondim with x0 - BRE scale */ 826 @ if(j==0){ 827 @ /* for a single x0 grid */ 828 @ setupXgrid(XgridPSE,x0,x1,nX) 859 @ 860 @ 861 @ 862 @ 863 @ 864 @ 865 @ 866 @ 867 @ 859 @ 860 @ if(dxtype==1){ 861 @ linspace(XgridPSE,sqrt(x0),sqrt(x1),nX) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ XgridPSE.resize(nX); 874 @ if(nX>1){ 875 @ real dx = (sqrt(x1) - sqrt(x0))/(nX - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = sqrt(x0); 877 @ for(int i=1; i1){ 875 @ real dx = (x1 - x0)/(nX - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = x0; 877 @ for(int i=1; i1){ 875 @ real dx = (sqrt(x1) - sqrt(x0))/(nXlocal - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = sqrt(x0); 877 @ for(int i=1; i1){ 875 @ real dx = (x1 - x0)/(nXlocal - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPSE[0] = x0; 877 @ for(int i=1; i> usol[]; 184 @ 185 @ } 611 @ alpha = alpha0mat(j,0); 612 @ alphavec = 0; 613 @ alphavec[0] = alpha; 614 @ alphaprev = alpha; 615 @ normEV(usol) 659 @ 660 @ /* real(Umax)=1 */ 661 @ 662 @ /* temporary FE field & condensing solution */ 663 @ 664 @ 665 @ /* gathered x component FE space */ 666 @ 667 @ /* extracting real part, and dividing with it's maximum*/ 668 @ 669 @ 670 @ 671 @ 672 @ 673 @ /* energy norm: consensing solution*/ 674 @ 675 @ 676 @ /* calculation and distribution of the factor */ 677 @ 678 @ 679 @ 680 @ /* because it is a quadratic funciton */ 681 @ 682 @ 683 @ 684 @ 685 @ 686 @ { 659 @ 660 @ /* real(Umax)=1 */ 661 @ if(normType==0){ 662 @ /* temporary FE field & condensing solution */ 663 @ VhCGlob gendef(uGloc) [uGloc, uGlocB, uGlocC, uGlocD]; 664 @ sendvecDistributed2Global(usol,uGloc) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGloc[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 665 @ /* gathered x component FE space */ 666 @ VP2Glob tempu = uGloc; 667 @ /* extracting real part, and dividing with it's maximum*/ 668 @ VP2Glob tempur; 669 @ tempur[] = tempu[].re; 670 @ complex normfac = tempur[] .max; 671 @ usol[] = usol[] / normfac; 672 @ } else if(normType==1){ 673 @ /* energy norm: consensing solution*/ 674 @ VhCGlob gendef(uGloc) [uGloc, uGlocB, uGlocC, uGlocD]; 675 @ sendvecDistributed2Global(usol,uGloc) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGloc[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 676 @ /* calculation and distribution of the factor */ 677 @ complex locKinEnerg; 678 @ if(mpirank==0){ 679 @ locKinEnerg = 0.5*int2d(thGlobal, qforder=3)(conj(uGloc)*uGloc + conj(uGlocB)*uGlocB + conj(uGlocC)*uGlocC); 680 @ locKinEnerg = sqrt(locKinEnerg); /* because it is a quadratic funciton */ 681 @ } 682 @ broadcast(processor(0),locKinEnerg); 683 @ usol[] *= (1./locKinEnerg); 684 @ } 685 @ 686 @ } 616 @ 617 @ indBRE = 0; 618 @ indBREprev = -1; 619 @ 620 @ 83 : 84 : int i = 0; 85 : 86 : //dX = (preStep ? getPSEdampedadaptivedX(i, alphavec, adaptiveprestepSF, sParPreStep) : getPSEadaptivedX(i, alphavec, adaptivestepSF)); 87 : dX = calcAdaptiveStepdx(alpha); 88 : 89 : while(XgridPSE[i]+dX < x1){ 90 : 91 : // PSEadaptivestep(i) 92 : PSEadaptiveStepUpdateGrid(i) 625 @ 626 @ /* increase variable size */ 627 @ 628 @ 629 @ 630 @ 631 @ /* add x grid value */ 632 @ 633 @ 634 @ 625 @ 626 @ /* increase variable size */ 627 @ XgridPSE.resize(XgridPSE.n+1); 628 @ alphavec.resize(alphavec.n+1); 629 @ energyvec.resize(energyvec.n+1); 630 @ growthmat.resize(growthmat.n+1,growthmat.m); 631 @ /* add x grid value */ 632 @ XgridPSE[XgridPSE.n-1] = XgridPSE[i++]+dX; 633 @ 634 @ 93 : 94 : PSEprestep(i) 177 @ 178 @ 179 @ 180 @ 181 @ /* initial step size calculation: safety through the safety factor + lower rounding of the steps */ 182 @ 183 @ /*dX = calcPreStepdx(alphavec[inInd-1]);*/ 184 @ 185 @ 186 @ /* number of steps: if not enough for an intermediate step, no prestepping */ 187 @ 188 @ 189 @ 190 @ /* recalculating dX: in the undamped case, since 'nPreStep' is rounded to the lower integer, 191 @ this is necessary add some robustness regarding the stepsize limit */ 192 @ 193 @ /* prestep grid: n+1 because the point number is needed*/ 194 @ 195 @ 196 @ 197 @ /* actual stepping - last step is done in the outer solver, therefore ipre i){ 179 @ inPreStepFlag = true; 180 @ if(mpirank==0) cout << " =================== PSE prestep started for step ... : #" << i << " =================== " << endl; 181 @ /* initial step size calculation: safety through the safety factor + lower rounding of the steps */ 182 @ 183 @ /*dX = calcPreStepdx(alphavec[inInd-1]);*/ 184 @ dX = calcPreStepdx(alpha); 185 @ enableDamping = true; 186 @ /* number of steps: if not enough for an intermediate step, no prestepping */ 187 @ int nPreStep = floor((XgridPSE[i]-XgridPSE[i-1])/dX); 188 @ 189 @ if(nPreStep>1){ 190 @ /* recalculating dX: in the undamped case, since 'nPreStep' is rounded to the lower integer, 191 @ this is necessary add some robustness regarding the stepsize limit */ 192 @ dX = (XgridPSE[i]-XgridPSE[i-1])/(nPreStep+0.); 193 @ /* prestep grid: n+1 because the point number is needed*/ 194 @ real[int] XgridPreStep; 195 @ linspace(XgridPreStep,XgridPSE[i-1],XgridPSE[i],nPreStep+1) 872 @ 873 @ 874 @ 875 @ 876 @ 877 @ 878 @ 879 @ 880 @ 881 @ 882 @ 883 @ 884 @ { 872 @ 873 @ XgridPreStep.resize(nPreStep+1); 874 @ if(nPreStep+1>1){ 875 @ real dx = (XgridPSE[i] - XgridPSE[i-1])/(nPreStep+1 - 1.); *** Warning The identifier dx hide a Global identifier 876 @ XgridPreStep[0] = XgridPSE[i-1]; 877 @ for(int i=1; i> uBFn[]; 184 @ 185 @ } 426 @ indBREprev = indBRE - 2; 427 @ import2DField(uBFprevprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprevprev[]; 184 @ 185 @ } 428 @ indBREprev = indBRE - 1; 429 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 430 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 431 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 432 @ scaleVelBRE2Normal(uBFprevprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprevprev) [uBFprevprev, uBFprevprevB, uBFprevprevC, uBFprevprevD] = [uBFprevprev, uBFprevprevB/sqrt(Rey), uBFprevprevC/sqrt(Rey), uBFprevprevD/Rey]; 637 @ 638 @ } 433 @ } else if(indBRE-2>indBREprev){ 434 @ uBFprevprev[] = uBFn[]; 435 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 436 @ indBREprev = indBRE - 1; 437 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 438 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 439 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 440 @ } else if(indBRE-1>indBREprev){ /* read and scale only one */ 441 @ uBFprevprev[] = uBFprev[]; 442 @ uBFprev[] = uBFn[]; 443 @ indBREprev = indBRE - 1; 444 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 445 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 446 @ } 447 @ /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 @ 449 @ 450 @ /* interpolate the current BF */ 451 @ if(indBRE>1){ 452 @ real dx2 = XgridBRE[indBRE] - XgridBRE[indBREprev-1]; 453 @ real dx1 = XgridBRE[indBREprev] - XgridBRE[indBREprev-1]; 454 @ real relx = XgridPreStep[ipre] - XgridBRE[indBREprev-1]; 455 @ uBF[] = ((dx2 - relx)/dx2 - (relx*(dx2 - relx))/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((relx*(dx2 - relx))/(dx1*dx2) - (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 456 @ uBF[] += uBFn[]*(relx/dx2 + (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 457 @ uBFx[] = (- 1/dx2 - (dx2 - 2*relx)/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((dx2 - 2*relx)/(dx1*dx2) - (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 458 @ uBFx[] += uBFn[]*(1/dx2 + (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 459 @ /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 @ 461 @ } else { 462 @ uBFx[] = uBFn[] - uBFprev[]; 463 @ uBFx[] *= (1/(XgridBRE[indBRE] - XgridBRE[indBREprev])); 464 @ real interdX = (XgridPreStep[ipre] - XgridBRE[indBRE-1])/(XgridBRE[indBRE] - XgridBRE[indBREprev]); 465 @ if(abs(interdX) < 1e-6){ 466 @ uBF[] = uBFprev[]; 467 @ } else { 468 @ uBF[] = (1-interdX)*uBFprev[] + uBFn[]*interdX; 469 @ } 470 @ /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 @ } 472 @ 473 @ 474 @ 475 @ 684 @ 685 @ /* saving old variables */ 686 @ usolprevprev[] = usolprev[]; 687 @ usolprev[] = usol[]; 688 @ alphaprevprev = alphaprev; 689 @ alphaprev = alpha; 690 @ 691 @ /* x variable, vector setup for efficient RSH evaluation */ 692 @ if(allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 693 @ X0 = XgridPreStep[ipre-2]; 694 @ X1 = XgridPreStep[ipre-1]; 695 @ X2 = XgridPreStep[ipre]; 696 @ dX = X2 - X1; 697 @ /* RHS setup and gathering for integral criterion calculation */ 698 @ usol2Evalrhs[] = usolprevprev[] *(1/(X2-X0)-1/(X1-X0)) + usolprev[]*(1/(X2-X1)+1/(X1-X0)); 699 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 700 @ } else { 701 @ /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 @ if(justExitPreStep){ 703 @ X1 = X2; 704 @ justExitPreStep = false; 705 @ } else { 706 @ X1 = XgridPreStep[ipre-1]; 707 @ } 708 @ X2 = XgridPreStep[ipre]; 709 @ dX = X2 - X1; 710 @ /* RHS setup and gathering for integral criterion calculation */ 711 @ usol2Evalrhs[] = usolprev[] *(1. / (X2 - X1)); 712 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 713 @ } 714 @ changeNumbering(dJ, usol2Evalrhs[], usol2EvalrhsPETSc); 715 @ 716 @ /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 @ if(false & ipre>initcorrind & !inPreStepFlag){ 718 @ alpha = (alphaprev - alphaprevprev) ; 719 @ alpha = alpha * (1./(X1-X0)*(X2-X1)); 720 @ alpha += alphaprev; 721 @ } 722 @ 723 @ /* step size info */ 724 @ if(mpirank==0){ 725 @ if(inPreStepFlag){ 726 @ cout << " ==== PSE pre-step, BDF order=" << (allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << endl; 727 @ } else { 728 @ cout << " #### PSE " << (fixGrid ? "fix grid" : "adaptive") << " step, BDF order=" << (allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << 729 @ ", inital normal admissible stepsize=" << calcNormalStepSizeLimit(alpha,allowBDF2(ipre) ipre>1 & BDF2 & !inPreStepFlag & !justExitPreStep ) << endl; 730 @ } 731 @ 732 @ } 733 @ 734 @ 201 @ 202 @ PSEstep(alpha,ipre); 203 @ 204 @ } 205 @ /* turn on flag for proper small outer step size*/ 206 @ justExitPreStep = true; 207 @ 208 @ } else { 209 @ if(mpirank==0) cout << " ===== Fix grid prestepping requested; however, p ... : restep size is smaller than the dX limit ===== " << endl; 210 @ if(mpirank==0) cout << " ===== XgridPSE[inInd-1]=" << XgridPSE[i-1] << ", XgridPSE[inInd]=" << XgridPSE[i] << ", dX=" << dX << " ===== " << endl; 211 @ if(!enableDamping & mpirank==0) { 212 @ cout << " ================================================ ... : ================================================== ... : ================================================== ... : == " << endl; 213 @ cout << " ============================== WARNING: NUMERICA ... : L INSTABILITY OF THE MARCHING SCHEME IS POSSIBLE D ... : UE TO SMALL STEP SIZE ============================ ... : == " << endl; 214 @ cout << " ================================================ ... : ================================================== ... : ================================================== ... : == " << endl; 215 @ } 216 @ } 217 @ inPreStepFlag = false; 218 @ /* upon exiting prestepping, turn off damping if needed */ 219 @ } else if(nPreStep==i) { 220 @ if(mpirank==0) cout << " ========== Prestepping finished: out of the pre ... : stepping range ========== " << endl; 221 @ /* turn off damping after prestepping if not requested */ 222 @ if(!enableDampingPostPrestep){ 223 @ if(mpirank==0) cout << " ========== damping switched off after pre ... : stepping ========== " << endl; 224 @ enableDamping = false; 225 @ spar = 0.; 226 @ } 227 @ } 228 @ 229 @ 95 : 96 : PSEinitstep(XgridPSE,i) 671 @ 672 @ /* print different for prestep and normal step */ 673 @ 674 @ 675 @ 676 @ 677 @ 678 @ 679 @ 680 @ 681 @ 682 @ /* calculation of the BF velocity profile */ 683 @ 684 @ 685 @ /* saving old variables */ 686 @ 687 @ 688 @ 689 @ 690 @ 691 @ /* x variable, vector setup for efficient RSH evaluation */ 692 @ 693 @ 694 @ 695 @ 696 @ 697 @ /* RHS setup and gathering for integral criterion calculation */ 698 @ 699 @ 700 @ 701 @ /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 @ 703 @ 704 @ 705 @ 706 @ 707 @ 708 @ 709 @ 710 @ /* RHS setup and gathering for integral criterion calculation */ 711 @ 712 @ 713 @ 714 @ 715 @ 716 @ /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 @ 718 @ 719 @ 720 @ 721 @ 722 @ 723 @ /* step size info */ 724 @ 725 @ 726 @ 727 @ 728 @ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 671 @ 672 @ /* print different for prestep and normal step */ 673 @ real looptime = mpiWtime(); 674 @ if(mpirank==0){ 675 @ if(inPreStepFlag){ 676 @ cout << " ======================= PSE prestep #" << i << " started ======================= " << endl; 677 @ } else { 678 @ cout << " ######################## PSE step #" << i << " started ######################### " << endl; 679 @ } 680 @ } 681 @ 682 @ /* calculation of the BF velocity profile */ 683 @ setPSEBF(XgridPSE[i]) 417 @ 418 @ /* increase BRE index if needed */ 419 @ 420 @ 421 @ 422 @ 423 @ /* if index is inceased, read the new data, and shift, depending on the number of skipped cells */ 424 @ 425 @ 426 @ 427 @ 428 @ 429 @ 430 @ 431 @ 432 @ 433 @ 434 @ 435 @ 436 @ 437 @ 438 @ 439 @ 440 @ /* read and scale only one */ 441 @ 442 @ 443 @ 444 @ 445 @ 446 @ 447 @ /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 @ 449 @ 450 @ /* interpolate the current BF */ 451 @ 452 @ 453 @ 454 @ 455 @ 456 @ 457 @ 458 @ 459 @ /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 @ 461 @ 462 @ 463 @ 464 @ 465 @ 466 @ 467 @ 468 @ 469 @ 470 @ /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 @ 472 @ 473 @ 474 @ 475 @ 417 @ 418 @ /* increase BRE index if needed */ 419 @ while(XgridBRE[indBRE]<=XgridPSE[i]& indBRE < XgridBRE.n-1){ 420 @ indBRE++; 421 @ } 422 @ 423 @ /* if index is inceased, read the new data, and shift, depending on the number of skipped cells */ 424 @ if(indBRE-3>indBREprev){ 425 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 426 @ indBREprev = indBRE - 2; 427 @ import2DField(uBFprevprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprevprev[]; 184 @ 185 @ } 428 @ indBREprev = indBRE - 1; 429 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 430 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 431 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 432 @ scaleVelBRE2Normal(uBFprevprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprevprev) [uBFprevprev, uBFprevprevB, uBFprevprevC, uBFprevprevD] = [uBFprevprev, uBFprevprevB/sqrt(Rey), uBFprevprevC/sqrt(Rey), uBFprevprevD/Rey]; 637 @ 638 @ } 433 @ } else if(indBRE-2>indBREprev){ 434 @ uBFprevprev[] = uBFn[]; 435 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 436 @ indBREprev = indBRE - 1; 437 @ import2DField(uBFprev,"BRE",iname,indBREprev) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBREprev<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBREprev + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFprev[]; 184 @ 185 @ } 438 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 439 @ scaleVelBRE2Normal(uBFprev,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFprev) [uBFprev, uBFprevB, uBFprevC, uBFprevD] = [uBFprev, uBFprevB/sqrt(Rey), uBFprevC/sqrt(Rey), uBFprevD/Rey]; 637 @ 638 @ } 440 @ } else if(indBRE-1>indBREprev){ /* read and scale only one */ 441 @ uBFprevprev[] = uBFprev[]; 442 @ uBFprev[] = uBFn[]; 443 @ indBREprev = indBRE - 1; 444 @ import2DField(uBFn,"BRE",iname,indBRE) 174 @ 175 @ 176 @ 177 @ 178 @ 179 @ 180 @ 181 @ 182 @ 183 @ 184 @ 185 @ { 174 @ 175 @ string ifname; 176 @ if(indBRE<0){ 177 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_np" + mpisize + "_" + mpirank + ".dat"; 178 @ } else { 179 @ ifname = workDir + "/" + basemeshname + "_" + "BRE" + "_" + iname + "_" + indBRE + "_np" + mpisize + "_" + mpirank + ".dat"; 180 @ } 181 @ 182 @ ifstream ifile(ifname); 183 @ ifile >> uBFn[]; 184 @ 185 @ } 445 @ scaleVelBRE2Normal(uBFn,Rey) 635 @ 636 @ 637 @ 638 @ { 635 @ 636 @ gendef(uBFn) [uBFn, uBFnB, uBFnC, uBFnD] = [uBFn, uBFnB/sqrt(Rey), uBFnC/sqrt(Rey), uBFnD/Rey]; 637 @ 638 @ } 446 @ } 447 @ /* calculation of the BF derivative - first order, constant on the interval; TODO: higher order? */ 448 @ 449 @ 450 @ /* interpolate the current BF */ 451 @ if(indBRE>1){ 452 @ real dx2 = XgridBRE[indBRE] - XgridBRE[indBREprev-1]; 453 @ real dx1 = XgridBRE[indBREprev] - XgridBRE[indBREprev-1]; 454 @ real relx = XgridPSE[i] - XgridBRE[indBREprev-1]; 455 @ uBF[] = ((dx2 - relx)/dx2 - (relx*(dx2 - relx))/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((relx*(dx2 - relx))/(dx1*dx2) - (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 456 @ uBF[] += uBFn[]*(relx/dx2 + (relx*(dx2 - relx))/(dx2*(dx1 - dx2))); 457 @ uBFx[] = (- 1/dx2 - (dx2 - 2*relx)/(dx1*dx2))*uBFprevprev[] + uBFprev[]*((dx2 - 2*relx)/(dx1*dx2) - (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 458 @ uBFx[] += uBFn[]*(1/dx2 + (dx2 - 2*relx)/(dx2*(dx1 - dx2))); 459 @ /* if(mpirank==0) cout << "XgridBRE[indBRE-2]=" << XgridBRE[indBRE-2] << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << ", dx2=" << dx2 << ", dx1=" << dx1 << ", relx=" << relx << endl; */ 460 @ 461 @ } else { 462 @ uBFx[] = uBFn[] - uBFprev[]; 463 @ uBFx[] *= (1/(XgridBRE[indBRE] - XgridBRE[indBREprev])); 464 @ real interdX = (XgridPSE[i] - XgridBRE[indBRE-1])/(XgridBRE[indBRE] - XgridBRE[indBREprev]); 465 @ if(abs(interdX) < 1e-6){ 466 @ uBF[] = uBFprev[]; 467 @ } else { 468 @ uBF[] = (1-interdX)*uBFprev[] + uBFn[]*interdX; 469 @ } 470 @ /* if(mpirank==0) cout << "interdX=" << interdX << ", XgridBRE[indBRE-1]=" << XgridBRE[indBRE-1] << ", xval=" << xval << ", XgridBRE[indBRE]=" << XgridBRE[indBRE] << endl; */ 471 @ } 472 @ 473 @ 474 @ 475 @ 684 @ 685 @ /* saving old variables */ 686 @ usolprevprev[] = usolprev[]; 687 @ usolprev[] = usol[]; 688 @ alphaprevprev = alphaprev; 689 @ alphaprev = alpha; 690 @ 691 @ /* x variable, vector setup for efficient RSH evaluation */ 692 @ if(allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ){ 693 @ X0 = XgridPSE[i-2]; 694 @ X1 = XgridPSE[i-1]; 695 @ X2 = XgridPSE[i]; 696 @ dX = X2 - X1; 697 @ /* RHS setup and gathering for integral criterion calculation */ 698 @ usol2Evalrhs[] = usolprevprev[] *(1/(X2-X0)-1/(X1-X0)) + usolprev[]*(1/(X2-X1)+1/(X1-X0)); 699 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 700 @ } else { 701 @ /* if presteps were taken, then use step size from the previous calculation stored in dX */ 702 @ if(justExitPreStep){ 703 @ X1 = X2; 704 @ justExitPreStep = false; 705 @ } else { 706 @ X1 = XgridPSE[i-1]; 707 @ } 708 @ X2 = XgridPSE[i]; 709 @ dX = X2 - X1; 710 @ /* RHS setup and gathering for integral criterion calculation */ 711 @ usol2Evalrhs[] = usolprev[] *(1. / (X2 - X1)); 712 @ sendvecDistributed2Global(usol2Evalrhs,uGlobal2Evalrhs) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol2Evalrhs[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol2Evalrhs[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol2Evalrhs[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol2Evalrhs[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal2Evalrhs[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 713 @ } 714 @ changeNumbering(dJ, usol2Evalrhs[], usol2EvalrhsPETSc); 715 @ 716 @ /* alpha prediction - only extrapolate after a few steps - TODO own parameter */ 717 @ if(false & i>initcorrind & !inPreStepFlag){ 718 @ alpha = (alphaprev - alphaprevprev) ; 719 @ alpha = alpha * (1./(X1-X0)*(X2-X1)); 720 @ alpha += alphaprev; 721 @ } 722 @ 723 @ /* step size info */ 724 @ if(mpirank==0){ 725 @ if(inPreStepFlag){ 726 @ cout << " ==== PSE pre-step, BDF order=" << (allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << endl; 727 @ } else { 728 @ cout << " #### PSE " << (fixGrid ? "fix grid" : "adaptive") << " step, BDF order=" << (allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ? "2" : "1" ) << ", X[i-1]=" << X1 << ", X[i]=" << X2 << ", dX=" << dX << 729 @ ", inital normal admissible stepsize=" << calcNormalStepSizeLimit(alpha,allowBDF2(i) i>1 & BDF2 & !inPreStepFlag & !justExitPreStep ) << endl; 730 @ } 731 @ 732 @ } 733 @ 734 @ 97 : 98 : PSEstep(alpha,i); 99 : 100 : PSEfinalizestep(j,i) 739 @ 740 @ 741 @ 742 @ 743 @ /* txt output */ 744 @ 745 @ 746 @ 747 @ 748 @ 749 @ /* VTU output */ 750 @ 751 @ 752 @ 753 @ 754 @ 755 @ 756 @ /* timing */ 757 @ 758 @ 759 @ 760 @ 761 @ 762 @ 763 @ 739 @ 740 @ alphavec[i] = alpha; 741 @ getPSEGrowth(i) 481 @ 482 @ 483 @ 484 @ /* first step - calculate the initial energy - the previous value is in the auxiliary RHS vec in PETSc numbering, divided by dX*/ 485 @ 486 @ 487 @ 488 @ 489 @ 490 @ 491 @ 492 @ 493 @ 494 @ /* if velocity-based growth rate is requested, collect the distributed solution */ 495 @ 496 @ 497 @ 498 @ 499 @ 500 @ /* function for max search*/ 501 @ 502 @ 503 @ 504 @ 505 @ 506 @ /* first step - search for the maximum*/ 507 @ /* TODO TODO - ACCURATE INITIAL GUESS */ 508 @ 509 @ 510 @ 511 @ 512 @ 513 @ 514 @ 515 @ /* max search */ 516 @ 517 @ 518 @ /* calculating the derivative at the maximum location */ 519 @ 520 @ 521 @ 522 @ 523 @ 524 @ /* first step - derivative is the same */ 525 @ 526 @ 527 @ 528 @ 529 @ 530 @ 531 @ 532 @ 533 @ 534 @ 535 @ 536 @ 537 @ 538 @ 539 @ /* function for max search*/ 540 @ 541 @ 542 @ 543 @ 544 @ 545 @ 546 @ 547 @ 548 @ 549 @ 550 @ /* max search */ 551 @ 552 @ 553 @ /* calculating the derivative at the maximum location */ 554 @ 555 @ 556 @ 557 @ 558 @ 559 @ /* first step - derivative is the same */ 560 @ 561 @ 562 @ 563 @ 564 @ 565 @ 566 @ 567 @ 568 @ 569 @ 570 @ 571 @ 572 @ 573 @ 574 @ { 481 @ int locind = -1; 482 @ if(growthEnergy==1){ 483 @ locind++; 484 @ /* first step - calculate the initial energy - the previous value is in the auxiliary RHS vec in PETSc numbering, divided by dX*/ 485 @ if(i==1){ 486 @ integrateParallel(dMvel,usol2EvalrhsPETSc,usol2EvalrhsPETSc,auxvecPETSc,energyvec[i-1]) 328 @ 329 @ 330 @ 331 @ { 328 @ MatMult(dMvel, usol2EvalrhsPETSc, auxvecPETSc); 329 @ complex tempDistIntegral = usol2EvalrhsPETSc' * auxvecPETSc; 330 @ mpiAllReduce(tempDistIntegral, energyvec[i-1], mpiCommWorld, mpiSUM); 331 @ } 487 @ energyvec[i-1] = energyvec[i-1] * (0.5 * (X2-X1)^2); 488 @ 489 @ } 490 @ integrateParallel(dMvel,usolPETSc,usolPETSc,auxvecPETSc,energyvec[i]) 328 @ 329 @ 330 @ 331 @ { 328 @ MatMult(dMvel, usolPETSc, auxvecPETSc); 329 @ complex tempDistIntegral = usolPETSc' * auxvecPETSc; 330 @ mpiAllReduce(tempDistIntegral, energyvec[i], mpiCommWorld, mpiSUM); 331 @ } 491 @ energyvec[i] *= 0.5; 492 @ } 493 @ 494 @ /* if velocity-based growth rate is requested, collect the distributed solution */ 495 @ if(growthU==1 || growthV==1) { 496 @ sendvecDistributed2Global(usol,uGlobal) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal[], mpiCommWorld, mpiSUM); 750 @ 751 @ }; 497 @ } 498 @ 499 @ if(growthU==1){ 500 @ /* function for max search*/ 501 @ func real interp2uOptfun(real[int] zy){ 502 @ real out = -abs(uGlobal(zy[0],zy[1])); 503 @ return out; 504 @ } 505 @ 506 @ /* first step - search for the maximum*/ 507 @ /* TODO TODO - ACCURATE INITIAL GUESS */ 508 @ 509 @ if(i==1){ 510 @ VP1Glob uP1, uP1x = x, uP1y = y; 511 @ uP1 = abs(uGlobal); 512 @ growthUZY[0] = uP1x[][uP1[].imax]; 513 @ growthUZY[1] = uP1y[][uP1[].imax]; 514 @ } 515 @ /* max search */ 516 @ complex umax = nloptNelderMead(interp2uOptfun,growthUZY,stopAbsFTol=1e-8,stopRelXTol=1e-8); 517 @ complex umaxc = uGlobal(growthUZY[0],growthUZY[1]); 518 @ /* calculating the derivative at the maximum location */ 519 @ if(i>1 & BDF2){ 520 @ growthmat(i,++locind) = (umaxc*(1/(X2-X0)+1/(X2-X1))-uGlobal2Evalrhs(growthUZY[0],growthUZY[1]))/umaxc; 521 @ } else { 522 @ growthmat(i,++locind) = (umaxc*(1/(X2-X1))-uGlobal2Evalrhs(growthUZY[0],growthUZY[1]))/umaxc; 523 @ } 524 @ /* first step - derivative is the same */ 525 @ if(i==1){ 526 @ growthmat(i-1,locind) = growthmat(i,locind); 527 @ } 528 @ IFMACRO(GROWTHDEBUG) 529 & growthmatDEBUGu(i,0) = growthUZY[0]; 530 & growthmatDEBUGu(i,1) = growthUZY[1]; 531 & if(i==1){ 532 & growthmatDEBUGu(i-1,0) = growthmatDEBUGu(i,0); 533 & growthmatDEBUGu(i-1,1) = growthmatDEBUGu(i,1); 534 & } 535 & ENDIFMACRO 536 @ } 537 @ 538 @ if(growthV==1){ 539 @ /* function for max search*/ 540 @ func real interp2uOptfun(real[int] zy){ 541 @ real out = -abs(uGlobalB(zy[0],zy[1])); 542 @ return out; 543 @ } 544 @ if(i==1){ 545 @ VP1Glob uP1, uP1x = x, uP1y = y; 546 @ uP1 = abs(uGlobalB); 547 @ growthVZY[0] = uP1x[][uP1[].imax]; 548 @ growthVZY[1] = uP1y[][uP1[].imax]; 549 @ } 550 @ /* max search */ 551 @ complex umax = nloptNelderMead(interp2uOptfun,growthVZY,stopAbsFTol=1e-8,stopRelXTol=1e-8); 552 @ complex umaxc = uGlobalB(growthVZY[0],growthVZY[1]); 553 @ /* calculating the derivative at the maximum location */ 554 @ if(i>1 & BDF2){ 555 @ growthmat(i,++locind) = (umaxc*(1/(X2-X0)+1/(X2-X1))-uGlobal2EvalrhsB(growthVZY[0],growthVZY[1]))/umaxc; 556 @ } else { 557 @ growthmat(i,++locind) = (umaxc*(1/(X2-X1))-uGlobal2EvalrhsB(growthVZY[0],growthVZY[1]))/umaxc; 558 @ } 559 @ /* first step - derivative is the same */ 560 @ if(i==1){ 561 @ growthmat(i-1,locind) = growthmat(i,locind); 562 @ } 563 @ IFMACRO(GROWTHDEBUG) 564 & growthmatDEBUGv(i,0) = growthVZY[0]; 565 & growthmatDEBUGv(i,1) = growthVZY[1]; 566 & if(i==1){ 567 & growthmatDEBUGv(i-1,0) = growthmatDEBUGv(i,0); 568 & growthmatDEBUGv(i-1,1) = growthmatDEBUGv(i,1); 569 & } 570 & ENDIFMACRO 571 @ 572 @ } 573 @ 574 @ } 742 @ 743 @ /* txt output */ 744 @ if(abs(fmod(i*nF+j+0.,overbfreq+0.))<1e-8){ 745 @ string auxname = "j" + j + "_i" + i; 746 @ export2DField(usol,"PSE",oname,auxname) 157 @ 158 @ 159 @ 160 @ 161 @ 162 @ 163 @ 164 @ 165 @ 166 @ 167 @ 168 @ 169 @ { 157 @ 158 @ string ofname; 159 @ if(auxname<0){ 160 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_np" + mpisize + "_" + mpirank + ".dat"; 161 @ } else { 162 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname + "_np" + mpisize + "_" + mpirank + ".dat"; 163 @ } 164 @ 165 @ ofstream ofile(ofname); 166 @ ofile.precision(16); 167 @ ofile << usol[] << endl; 168 @ 169 @ } 747 @ } 748 @ 749 @ /* VTU output */ 750 @ if(abs(fmod(i*nF+j+0.,overbfreqVTU+0.))<1e-8){ 751 @ string auxname = "j" + j + "_i" + i; 752 @ sendvecDistributed2Global(usol,uGlobal) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 753 @ VTUexportGendata(uGlobal,"PSE",oname,auxname) 190 @ 191 @ 192 @ 193 @ 194 @ 195 @ 196 @ 197 @ 198 @ 199 @ 200 @ 201 @ 202 @ 203 @ 204 @ 205 @ 206 @ 207 @ 208 @ { 190 @ IFMACRO(BRE) 191 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,uGlobal,uGlobalB,uGlobalC,uGlobalD, 192 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 193 & ENDIFMACRO 194 @ IFMACRO(EV) 195 & VhCGlob gendef(uGr),gendef(uGi); 196 & uGr[] = uGlobal[].re; 197 & uGi[] = uGlobal[].im; 198 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 199 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 200 & ENDIFMACRO 201 @ IFMACRO(PSE) 202 & VhCGlob gendef(uGr),gendef(uGi); 203 & uGr[] = uGlobal[].re; 204 & uGi[] = uGlobal[].im; 205 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 & ENDIFMACRO 202 @ VhCGlob gendef(uGr) [uGr, uGrB, uGrC, uGrD],gendef(uGi) [uGi, uGiB, uGiC, uGiD]; 203 @ uGr[] = uGlobal[].re; 204 @ uGi[] = uGlobal[].im; 205 @ savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 @ dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 @ 208 @ } 754 @ } 755 @ 756 @ /* timing */ 757 @ looptime = mpiWtime() - looptime; 758 @ if(mpirank==0){ 759 @ cout << " ##### PSE step #" << i << " successfully finished in " << looptime << " seconds ##### " << endl; 760 @ cout << " ################################################ ... : ######################### " << endl; 761 @ } 762 @ 763 @ 101 : 102 : dX = calcAdaptiveStepdx(alpha); 103 : //dX = ((preStep & nPreStep > i) ? getPSEdampedadaptivedX(i, alphavec, adaptiveprestepSF, sParPreStep) : getPSEadaptivedX(i, alphavec, adaptivestepSF)); 104 : } 105 : 106 : if(mpirank==0){ 107 : cout << "PSE adaptive stepsize solver exited because the l ... : ast step would exit the specified domain" << endl; 108 : cout << " ### XgridPSE[i]=" << XgridPSE[i] << ", dX=" << dX << ", x1=" << x1 << endl; 109 : } 110 : 111 : PSEoutput 768 @ 769 @ 770 @ 771 @ 772 @ 773 @ 774 @ 775 @ 776 @ 777 @ 778 @ 779 @ 780 @ 781 @ 782 @ 783 @ 784 @ 785 @ 786 @ 787 @ 788 @ 789 @ 790 @ 768 @ 769 @ calcPSEGrowthE 579 @ 580 @ 581 @ /* in-loop integrals are calculated on rank 0 only, broadcast it now*/ 582 @ 583 @ 584 @ /* loadin the data into a matrix - only way to create a spline */ 585 @ 586 @ 587 @ 588 @ /* dummymat(1,nn) = abs(energyvec[nn]); */ /* alternative calculationmethod? */ 589 @ 590 @ 591 @ /* spline creation */ 592 @ 593 @ /* energy growth calculation using the spline */ 594 @ 595 @ /* growthmat(nn,locind) = splineEnergyvar.d(XgridPSE[nn])/splineEnergy(XgridPSE[nn]); */ /* alternative calculationmethod? */ 596 @ 597 @ 598 @ 599 @ 600 @ 601 @ 602 @ { 579 @ if(growthEnergy==1 & XgridPSE.n>2){ 580 @ 581 @ /* in-loop integrals are calculated on rank 0 only, broadcast it now*/ 582 @ broadcast(processor(0),energyvec); 583 @ 584 @ /* loadin the data into a matrix - only way to create a spline */ 585 @ real[int,int] dummymat(2,XgridPSE.n); 586 @ for(int nn=0; nn2){ 599 @ if(mpirank==0) cout << "Number of steps is small to calculate the energy ... : growth with spline interpolation" << endl; 600 @ } 601 @ } 602 @ 770 @ { 771 @ string auxname = "j" + j; 772 @ exportVec(XgridPSE,"PSE",oname + "_Xgrid_" + auxname) 77 @ 78 @ 79 @ 80 @ 81 @ 82 @ 83 @ 84 @ 85 @ 86 @ 87 @ 88 @ { 77 @ 78 @ if(mpirank==0){ 79 @ string ofname; 80 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_Xgrid_" + auxname + ".dat"; 81 @ 82 @ ofstream ofile(ofname); 83 @ ofile.precision(16); 84 @ ofile << XgridPSE.n << endl; 85 @ ofile << XgridPSE << endl; 86 @ } 87 @ 88 @ } 773 @ exportVec(alphavec,"PSE",oname + "_alphavec_" + auxname) 77 @ 78 @ 79 @ 80 @ 81 @ 82 @ 83 @ 84 @ 85 @ 86 @ 87 @ 88 @ { 77 @ 78 @ if(mpirank==0){ 79 @ string ofname; 80 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_alphavec_" + auxname + ".dat"; 81 @ 82 @ ofstream ofile(ofname); 83 @ ofile.precision(16); 84 @ ofile << alphavec.n << endl; 85 @ ofile << alphavec << endl; 86 @ } 87 @ 88 @ } 774 @ exportMat(growthmat,"PSE",oname + "_growthmat_" + auxname) 115 @ 116 @ 117 @ 118 @ 119 @ 120 @ 121 @ 122 @ 123 @ 124 @ 125 @ 126 @ 127 @ { 115 @ 116 @ if(mpirank==0){ 117 @ string ofname; 118 @ ofname = workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_growthmat_" + auxname + ".dat"; 119 @ 120 @ ofstream ofile(ofname); 121 @ ofile.precision(16); 122 @ ofile << growthmat.n << endl; 123 @ ofile << growthmat.m << endl; 124 @ ofile << growthmat << endl; 125 @ } 126 @ 127 @ } 775 @ IFMACRO(GROWTHDEBUG) 776 & exportMat(growthmatDEBUGu,"PSE",oname + "_growthmatDEBUGu_" + auxname) 777 & exportMat(growthmatDEBUGv,"PSE",oname + "_growthmatDEBUGv_" + auxname) 778 & ENDIFMACRO 779 @ sendvecDistributed2Global(usol,uGlobal) 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ 730 @ 731 @ 732 @ 733 @ 734 @ 735 @ 736 @ 737 @ 738 @ 739 @ 740 @ 741 @ 742 @ 743 @ 744 @ 745 @ 746 @ 747 @ /* TODO: description */ 748 @ 749 @ 750 @ 751 @ { 728 @ /* depending on PETSc real/complex: temporary solution, multiplication by partition of unity */ 729 @ IFMACRO(BRE) 730 & VhC gendef(locsol); 731 & locsol[] = usol[]; 732 & locsol[] .*= dJ.D; 733 & ENDIFMACRO 734 @ IFMACRO(EV) 735 & VhC gendef(locsol); 736 & locsol[] = usol[]; 737 & locsol[].re .*= dJ.D; 738 & locsol[].im .*= dJ.D; 739 & ENDIFMACRO 740 @ IFMACRO(PSE) 741 & VhC gendef(locsol); 742 & locsol[] = usol[]; 743 & locsol[].re .*= dJ.D; 744 & locsol[].im .*= dJ.D; 745 & ENDIFMACRO 741 @ VhC gendef(locsol) [locsol, locsolB, locsolC, locsolD]; 742 @ locsol[] = usol[]; 743 @ locsol[].re .*= dJ.D; 744 @ locsol[].im .*= dJ.D; 745 @ 746 @ 747 @ /* TODO: description */ 748 @ for[i, v : rest] uReduce[][v] = locsol[][i]; 749 @ mpiAllReduce(uReduce[], uGlobal[], mpiCommWorld, mpiSUM); 750 @ 751 @ } 780 @ VTUexportGendata(uGlobal,"PSE",oname,auxname) 190 @ 191 @ 192 @ 193 @ 194 @ 195 @ 196 @ 197 @ 198 @ 199 @ 200 @ 201 @ 202 @ 203 @ 204 @ 205 @ 206 @ 207 @ 208 @ { 190 @ IFMACRO(BRE) 191 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,uGlobal,uGlobalB,uGlobalC,uGlobalD, 192 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 193 & ENDIFMACRO 194 @ IFMACRO(EV) 195 & VhCGlob gendef(uGr),gendef(uGi); 196 & uGr[] = uGlobal[].re; 197 & uGi[] = uGlobal[].im; 198 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 199 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 200 & ENDIFMACRO 201 @ IFMACRO(PSE) 202 & VhCGlob gendef(uGr),gendef(uGi); 203 & uGr[] = uGlobal[].re; 204 & uGi[] = uGlobal[].im; 205 & savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 & dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 & ENDIFMACRO 202 @ VhCGlob gendef(uGr) [uGr, uGrB, uGrC, uGrD],gendef(uGi) [uGi, uGiB, uGiC, uGiD]; 203 @ uGr[] = uGlobal[].re; 204 @ uGi[] = uGlobal[].im; 205 @ savevtk(workDir + "/" + basemeshname + "_" + "PSE" + "_" + oname + "_" + auxname,thGlobal,[uGr,uGi],[uGrB,uGiB],[uGrC,uGiC],[uGrD,uGiD], 206 @ dataname = "u v w p", order = VTUOrder, communicator = mpiCommSelf); 207 @ 208 @ } 781 @ } 782 @ 783 @ runtimeF = mpiWtime() - runtimeF; 784 @ if(mpirank==0){ 785 @ cout << " ------------------------------------------------ ... : -------------------------- " << endl; 786 @ cout << " ### PSE calculation at F index #" << j << ", F=" << Fvec[j] << ", omega =" << omega << " successfully finished in " << runtimeF << " seconds ##### " << endl; 787 @ cout << " ------------------------------------------------ ... : -------------------------- " << endl; 788 @ } 789 @ 790 @ 112 : 113 : } 114 : } 115 : 116 : runtime = mpiWtime() - runtime; 117 : if(mpirank==0){ 118 : cout<< " ######################## PSE marching successf ... : ully finished in " << runtime << " seconds ######################### " < exists -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 -- Square mesh : nb vertices =4 , nb triangles = 2 , nb boundary edges 4 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 --- Warning no manifold obj nb:0 adj 8 of dim =1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 -- FESpace: Nb of Nodes 1 Nb of DoF 1 BRE input name=c1, BiGlob input name=c1test PSE param: fixGrid=1, BDF2=0, dxtype=1, noDpdx=0 -- enableDamping=1, adaptivestepSF=1.1 -- dxSafetyFactor=1.01, dampingSafetyFactor=1.1, spar=0, relstepalpha=0.05 -- absstepalpha=0.0125, initcorrenabled=1, initcorrreltol=0.1 -- initcorrweight=0.1, initcorrind=4, maxiter=10 -- intnormtol=1e-07, dalphatol=1e-09, normType=1, linEqSolutionTimer=0 -- requested growth rates: growthEnergy=1, growthU=, growthV=0 -- mesh: Nb of Triangles = 5100, Nb of Vertices 2653 -- mesh: Nb of Triangles = 5147, Nb of Vertices 2675 -- mesh: Nb of Triangles = 5182, Nb of Vertices 2711 -- mesh: Nb of Triangles = 5201, Nb of Vertices 2708 -- mesh: Nb of Triangles = 5548, Nb of Vertices 3050 -- mesh: Nb of Triangles = 24136, Nb of Vertices 12275 read meshL ok 0 , nt 1000, nv 1001 nbe: = 0 -- MeshL : PSE1/PSE1_m0_thLx.mesh, d 3, n Edges 1000, n Vtx 1001 n Border points 2 read meshL ok 0 , nt 1000, nv 1001 nbe: = 0 -- MeshL : PSE1/PSE1_m0_thLy.mesh, d 3, n Edges 1000, n Vtx 1001 n Border points 2 meshes loaded successfully --- global numbering created (in 0.0180018) --- global CSR created (in 0.000692036) -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 -- FESpace: Nb of Nodes 1001 Nb of DoF 1001 --- global CSR created (in 0.000608824) --- global CSR created (in 0.000858999) ######################### PSE marching started ######################### -------------------------------------------------------------------------- ### PSE calculation at F index #0, F=350, omega =0.0579614 started ### -------------------------------------------------------------------------- =================== PSE prestep started for step #1 =================== ======================= PSE prestep #1 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2229.28, X[i]=2238.03, dX=8.74465 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=1.483 , |f| = 0.000179403, |dalpha| = 8.95942e-05, alpha = (0.0874696,0.00838202) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=1.47834 , |f| = 2.64301e-08, |dalpha| = 1.32135e-08, alpha = (0.0874696,0.00838201) ======================= PSE prestep #2 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2238.03, X[i]=2246.77, dX=8.74465 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=1.47834 , |f| = 0.000124598, |dalpha| = 6.23147e-05, alpha = (0.0875283,0.00840274) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=1.47412 , |f| = 2.74442e-08, |dalpha| = 1.37205e-08, alpha = (0.0875283,0.00840273) ======================= PSE prestep #3 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2246.77, X[i]=2255.52, dX=8.74465 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=1.47412 , |f| = 0.000134966, |dalpha| = 6.74988e-05, alpha = (0.0875929,0.0084223) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=1.46949 , |f| = 3.38839e-08, |dalpha| = 1.69401e-08, alpha = (0.0875929,0.00842229) ======================= PSE prestep #4 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2255.52, X[i]=2264.26, dX=8.74465 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=1.46949 , |f| = 0.000138433, |dalpha| = 6.92327e-05, alpha = (0.0876595,0.00844152) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=1.46472 , |f| = 3.81469e-08, |dalpha| = 1.90715e-08, alpha = (0.0876595,0.00844151) ======================= PSE prestep #5 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2264.26, X[i]=2273.01, dX=8.74465 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=1.46472 , |f| = 0.000141543, |dalpha| = 7.07884e-05, alpha = (0.0877277,0.00846023) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=1.45984 , |f| = 4.06429e-08, |dalpha| = 2.03197e-08, alpha = (0.0877277,0.00846021) ######################## PSE step #1 started ######################### #### PSE fix grid step, BDF order=1, X[i-1]=2273.01, X[i]=2281.75, dX=8.74465, inital normal admissible stepsize=11.3989 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=1.45984 , |f| = 0.0001434, |dalpha| = 7.1716e-05, alpha = (0.0877975,0.00847698) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=1.45486 , |f| = 4.08119e-08, |dalpha| = 2.04046e-08, alpha = (0.0877975,0.00847696) ##### PSE step #1 successfully finished in 10.8199 seconds ##### ######################################################################### =================== PSE prestep started for step #2 =================== ======================= PSE prestep #1 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2281.75, X[i]=2289.33, dX=7.5826 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.09399 , |f| = 0.000125957, |dalpha| = 6.29872e-05, alpha = (0.0878592,0.00848959) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.08959 , |f| = 3.59767e-08, |dalpha| = 1.79874e-08, alpha = (0.0878592,0.00848957) ======================= PSE prestep #2 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2289.33, X[i]=2296.92, dX=7.5826 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.08959 , |f| = 0.000122269, |dalpha| = 6.1141e-05, alpha = (0.0879196,0.00849892) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.08529 , |f| = 3.30613e-08, |dalpha| = 1.65301e-08, alpha = (0.0879196,0.0084989) ======================= PSE prestep #3 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2296.92, X[i]=2304.5, dX=7.5826 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.08529 , |f| = 0.000120779, |dalpha| = 6.03945e-05, alpha = (0.0879797,0.00850513) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.08102 , |f| = 3.06524e-08, |dalpha| = 1.53261e-08, alpha = (0.0879797,0.00850511) ======================= PSE prestep #4 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2304.5, X[i]=2312.08, dX=7.5826 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.08102 , |f| = 0.000119032, |dalpha| = 5.95194e-05, alpha = (0.0880391,0.00850766) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.07679 , |f| = 2.85188e-08, |dalpha| = 1.42597e-08, alpha = (0.0880391,0.00850765) ======================= PSE prestep #5 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2312.08, X[i]=2319.66, dX=7.5826 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.07679 , |f| = 0.00011702, |dalpha| = 5.85115e-05, alpha = (0.0880976,0.00850608) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.07265 , |f| = 2.78389e-08, |dalpha| = 1.39201e-08, alpha = (0.0880976,0.00850607) ======================= PSE prestep #6 started ======================= ==== PSE pre-step, BDF order=1, X[i-1]=2319.66, X[i]=2327.25, dX=7.5826 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.07265 , |f| = 0.000115223, |dalpha| = 5.76112e-05, alpha = (0.0881549,0.00849995) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.06859 , |f| = 2.99515e-08, |dalpha| = 1.4977e-08, alpha = (0.0881549,0.00849995) ######################## PSE step #2 started ######################### #### PSE fix grid step, BDF order=1, X[i-1]=2327.25, X[i]=2334.83, dX=7.5826, inital normal admissible stepsize=11.3437 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, damped step: s=2.06859 , |f| = 0.000113863, |dalpha| = 5.69289e-05, alpha = (0.0882107,0.00848883) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, damped step: s=2.06464 , |f| = 3.55496e-08, |dalpha| = 1.7777e-08, alpha = (0.0882107,0.00848883) ##### PSE step #2 successfully finished in 10.774 seconds ##### ######################################################################### ========== Prestepping finished: out of the prestepping range ========== ######################## PSE step #3 started ######################### #### PSE fix grid step, BDF order=1, X[i-1]=2334.83, X[i]=2388.52, dX=53.6885, inital normal admissible stepsize=11.3365 Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 0, regular step , |f| = 0.000880928, |dalpha| = 0.000426509, alpha = (0.0884761,0.00815499) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 1, regular step , |f| = 2.83974e-05, |dalpha| = 1.42722e-05, alpha = (0.0884746,0.00816918) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 2, regular step , |f| = 9.3965e-07, |dalpha| = 4.71518e-07, alpha = (0.0884745,0.00816874) Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. Warning: -- Your set of boundary condition is incompatible with the mesh label. alpha iteration: niter = 3, regular step , |f| = 2.9009e-08, |dalpha| = 1.45574e-08, alpha = (0.0884745,0.00816875) ##### PSE step #3 successfully finished in 18.7589 seconds ##### ######################################################################### 0x5565efb62b00 VTK_FILE 2 0x55954610adc0 VTK_FILE 2 0x55884b150860 VTK_FILE 2 0x55ffe02359d0 VTK_FILE 2 0x5633839d8c20 VTK_FILE 2 -------------------------------------------------------------------------- ### PSE calculation at F index #0, F=350, omega =0.0579614 successfully finished in 159.822 seconds ##### -------------------------------------------------------------------------- ######################## PSE marching successfully finished in 159.823 seconds ######################### times: compile 0.060798s, execution 161.334s, mpirank:4 ######## We forget of deleting -10 Nb pointer, 0Bytes , mpirank 4, memory leak =814496 CodeAlloc : nb ptr 25954, size :1347744 mpirank: 4 times: compile 0.061303s, execution 161.331s, mpirank:1 ######## We forget of deleting -10 Nb pointer, 0Bytes , mpirank 1, memory leak =1006352 CodeAlloc : nb ptr 25954, size :1347744 mpirank: 1 times: compile 0.061389s, execution 161.329s, mpirank:3 ######## We forget of deleting -10 Nb pointer, 0Bytes , mpirank 3, memory leak =850432 CodeAlloc : nb ptr 25954, size :1347744 mpirank: 3 times: compile 0.060827s, execution 161.333s, mpirank:2 ######## We forget of deleting -10 Nb pointer, 0Bytes , mpirank 2, memory leak =975008 CodeAlloc : nb ptr 25954, size :1347744 mpirank: 2 times: compile 0.114762s, execution 161.275s, mpirank:0 ######## We forget of deleting -10 Nb pointer, 0Bytes , mpirank 0, memory leak =959376 CodeAlloc : nb ptr 25954, size :1347744 mpirank: 0 Ok: Normal End ************************************************************************************************************************ *** WIDEN YOUR WINDOW TO 120 CHARACTERS. Use 'enscript -r -fCourier9' to print this document *** ************************************************************************************************************************ ---------------------------------------------- PETSc Performance Summary: ---------------------------------------------- /root/../home/andras/FFinstall/FreeFem-sources/src/mpi/FreeFem++-mpi on a arch-FreeFem-complex named andras-VirtualBox with 5 processors, by root Mon Nov 22 17:43:06 2021 Using Petsc Development GIT revision: v3.16.1-353-g887dddf386 GIT Date: 2021-11-19 20:24:41 +0000 Max Max/Min Avg Total Time (sec): 1.615e+02 1.000 1.615e+02 Objects: 3.700e+02 1.000 3.700e+02 Flop: 1.389e+12 1.817 1.095e+12 5.476e+12 Flop/sec: 8.600e+09 1.817 6.780e+09 3.390e+10 MPI Messages: 1.210e+03 1.301 1.040e+03 5.200e+03 MPI Message Lengths: 3.341e+07 1.737 2.736e+04 1.423e+08 MPI Reductions: 6.070e+02 1.000 Flop counting convention: 1 flop = 1 real number operation of type (multiply/divide/add/subtract) e.g., VecAXPY() for real vectors of length N --> 2N flop and VecAXPY() for complex vectors of length N --> 8N flop Summary of Stages: ----- Time ------ ----- Flop ------ --- Messages --- -- Message Lengths -- -- Reductions -- Avg %Total Avg %Total Count %Total Avg %Total Count %Total 0: Main Stage: 1.1108e+02 68.8% 5.4755e+12 100.0% 5.200e+03 100.0% 2.736e+04 100.0% 5.550e+02 91.4% 1: damping: 4.6175e+01 28.6% 0.0000e+00 0.0% 0.000e+00 0.0% 0.000e+00 0.0% 3.000e+01 4.9% 2: no stab: 4.2512e+00 2.6% 0.0000e+00 0.0% 0.000e+00 0.0% 0.000e+00 0.0% 4.000e+00 0.7% ------------------------------------------------------------------------------------------------------------------------ See the 'Profiling' chapter of the users' manual for details on interpreting output. Phase summary info: Count: number of times phase was executed Time and Flop: Max - maximum over all processors Ratio - ratio of maximum to minimum over all processors Mess: number of messages sent AvgLen: average message length (bytes) Reduct: number of global reductions Global: entire computation Stage: stages of a computation. Set stages with PetscLogStagePush() and PetscLogStagePop(). %T - percent time in this phase %F - percent flop in this phase %M - percent messages in this phase %L - percent message lengths in this phase %R - percent reductions in this phase Total Mflop/s: 10e-6 * (sum of flop over all processors)/(max time over all processors) ------------------------------------------------------------------------------------------------------------------------ Event Count Time (sec) Flop --- Global --- --- Stage ---- Total Max Ratio Max Ratio Max Ratio Mess AvgLen Reduct %T %F %M %L %R %T %F %M %L %R Mflop/s ------------------------------------------------------------------------------------------------------------------------ --- Event Stage 0: Main Stage BuildTwoSided 34 1.0 4.4246e-03 5.1 0.00e+00 0.0 5.7e+02 4.0e+00 3.4e+01 0 0 11 0 6 0 0 11 0 6 0 BuildTwoSidedF 2 1.0 1.1478e-0310.6 0.00e+00 0.0 0.0e+00 0.0e+00 2.0e+00 0 0 0 0 0 0 0 0 0 0 0 MatMult 64 1.0 3.9892e-01 1.0 6.64e+08 1.0 1.1e+03 9.4e+03 2.0e+00 0 0 21 7 0 0 0 21 7 0 8196 MatSolve 30 1.0 1.8953e+00 1.0 1.39e+12 1.8 3.6e+03 3.2e+04 1.5e+02 1100 69 81 25 2100 69 81 27 2882346 MatLUFactorSym 1 1.0 6.3380e-01 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 1 0 0 0 0 0 MatLUFactorNum 30 1.0 1.0529e+02 1.0 2.29e+09 1.8 0.0e+00 0.0e+00 0.0e+00 65 0 0 0 0 95 0 0 0 0 88 MatAssemblyBegin 4 1.0 1.1793e-03 8.5 0.00e+00 0.0 0.0e+00 0.0e+00 2.0e+00 0 0 0 0 0 0 0 0 0 0 0 MatAssemblyEnd 4 1.0 1.0526e-0125.5 0.00e+00 0.0 0.0e+00 0.0e+00 8.0e+00 0 0 0 0 1 0 0 0 0 1 0 VecSet 32 1.0 3.0484e-03 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 VecScatterBegin 94 1.0 2.1370e-02 1.3 0.00e+00 0.0 2.7e+03 3.2e+04 3.2e+01 0 0 52 62 5 0 0 52 62 6 0 VecScatterEnd 94 1.0 3.9781e-02 1.7 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 SFSetGraph 32 1.0 8.9233e-04 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 SFSetUp 32 1.0 1.4963e-02 1.1 0.00e+00 0.0 1.1e+03 1.4e+04 3.2e+01 0 0 22 11 5 0 0 22 11 6 0 SFPack 94 1.0 4.0624e-03 3.2 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 SFUnpack 94 1.0 3.9112e-03 2.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 KSPSetUp 30 1.0 1.8092e-05 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 KSPSolve 30 1.0 1.8986e+00 1.0 1.39e+12 1.8 3.6e+03 3.2e+04 1.5e+02 1100 69 81 25 2100 69 81 27 2877327 PCSetUp 30 1.0 1.0592e+02 1.0 2.29e+09 1.8 0.0e+00 0.0e+00 0.0e+00 66 0 0 0 0 95 0 0 0 0 87 PCApply 30 1.0 1.8954e+00 1.0 1.39e+12 1.8 3.6e+03 3.2e+04 1.5e+02 1100 69 81 25 2100 69 81 27 2882255 --- Event Stage 1: damping BuildTwoSided 26 1.0 2.9516e+003123.4 0.00e+00 0.0 0.0e+00 0.0e+00 2.6e+01 1 0 0 0 4 4 0 0 0 87 0 BuildTwoSidedF 26 1.0 2.9517e+002852.4 0.00e+00 0.0 0.0e+00 0.0e+00 2.6e+01 1 0 0 0 4 4 0 0 0 87 0 MatAssemblyBegin 27 1.0 2.9526e+001784.2 0.00e+00 0.0 0.0e+00 0.0e+00 2.6e+01 1 0 0 0 4 4 0 0 0 87 0 MatAssemblyEnd 27 1.0 1.4714e-0169.7 0.00e+00 0.0 0.0e+00 0.0e+00 4.0e+00 0 0 0 0 1 0 0 0 0 13 0 MatZeroEntries 25 1.0 6.1409e-02 1.6 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 VecSet 1 1.0 4.1920e-06 1.7 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 SFSetGraph 1 1.0 2.8820e-06 1.5 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 --- Event Stage 2: no stab BuildTwoSided 4 1.0 3.1110e-0115.4 0.00e+00 0.0 0.0e+00 0.0e+00 4.0e+00 0 0 0 0 1 4 0 0 0100 0 BuildTwoSidedF 4 1.0 3.1113e-0115.3 0.00e+00 0.0 0.0e+00 0.0e+00 4.0e+00 0 0 0 0 1 4 0 0 0100 0 MatAssemblyBegin 4 1.0 3.1130e-0115.3 0.00e+00 0.0 0.0e+00 0.0e+00 4.0e+00 0 0 0 0 1 4 0 0 0100 0 MatAssemblyEnd 4 1.0 4.6912e-05 1.2 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 MatZeroEntries 4 1.0 1.0261e-02 1.5 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 ------------------------------------------------------------------------------------------------------------------------ Memory usage is given in bytes: Object Type Creations Destructions Memory Descendants' Mem. Reports information only for process 0. --- Event Stage 0: Main Stage Matrix 13 13 99293852 0. Vector 252 253 96351456 0. Index Set 64 64 4462632 0. Star Forest Graph 32 33 40392 0. Krylov Solver 1 1 1600 0. Preconditioner 1 1 1024 0. Viewer 1 0 0 0. --- Event Stage 1: damping Matrix 1 1 3698644 0. Vector 2 1 1760 0. Index Set 2 2 9096 0. Star Forest Graph 1 0 0 0. --- Event Stage 2: no stab ======================================================================================================================== Average time to get PetscTime(): 2.7e-08 Average time for MPI_Barrier(): 4.7344e-06 Average time for zero size MPI_Send(): 1.4008e-06 #PETSc Option Table entries: -basemeshname m0 -BFD2 1 -DwDir=PSE1 -enableDamping 1 -fixGrid 1 -iname c1 -inameBiG c1test -ksp_type preonly -linEqSolutionTimer 0 -log_view -normType 1 -nw ../include/PSEsolver.edp -nX 3 -oname c1_2_test -pc_type lu -x1 0.75 #End of PETSc Option Table entries Compiled without FORTRAN kernels Compiled with full precision matrices (default) sizeof(short) 2 sizeof(int) 4 sizeof(long) 8 sizeof(void*) 8 sizeof(PetscScalar) 16 sizeof(PetscInt) 4 Configure options: --with-mumps-dir=arch-FreeFem-sources --with-parmetis-dir=arch-FreeFem-sources --with-metis-dir=arch-FreeFem-sources --with-superlu-dir=arch-FreeFem-sources --download-slepc --download-hpddm --with-ptscotch-dir=arch-FreeFem-sources --with-suitesparse-dir=arch-FreeFem-sources --with-scalapack-dir=arch-FreeFem-sources --with-tetgen-dir=arch-FreeFem-sources --with-fortran-bindings=no --with-scalar-type=complex --with-debugging=no ----------------------------------------- Libraries compiled on 2021-11-22 15:18:13 on andras-VirtualBox Machine characteristics: Linux-5.4.0-90-generic-x86_64-with-Ubuntu-18.04-bionic Using PETSc directory: /home/andras/FFinstall/petsc Using PETSc arch: arch-FreeFem-complex ----------------------------------------- Using C compiler: mpicc -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fstack-protector -fvisibility=hidden -g -O Using Fortran compiler: mpif90 -fPIC -Wall -ffree-line-length-0 -Wno-unused-dummy-argument -g -O ----------------------------------------- Using include paths: -I/home/andras/FFinstall/petsc/include -I/home/andras/FFinstall/petsc/arch-FreeFem-complex/include -I/home/andras/FFinstall/petsc/arch-FreeFem-sources/include ----------------------------------------- Using C linker: mpicc Using Fortran linker: mpif90 Using libraries: -Wl,-rpath,/home/andras/FFinstall/petsc/arch-FreeFem-complex/lib -L/home/andras/FFinstall/petsc/arch-FreeFem-complex/lib -lpetsc -Wl,-rpath,/home/andras/FFinstall/petsc/arch-FreeFem-sources/lib -L/home/andras/FFinstall/petsc/arch-FreeFem-sources/lib -Wl,-rpath,/usr/lib/x86_64-linux-gnu/openmpi/lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7 -lcmumps -ldmumps -lsmumps -lzmumps -lmumps_common -lpord -lscalapack -lspqr -lumfpack -lklu -lcholmod -lbtf -lccolamd -lcolamd -lcamd -lamd -lsuitesparseconfig -lsuperlu -llapack -lblas -lptesmumps -lptscotchparmetis -lptscotch -lptscotcherr -lesmumps -lscotch -lscotcherr -lparmetis -lmetis -ltet -lm -lX11 -lstdc++ -ldl -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lpthread -lquadmath -lstdc++ -ldl -----------------------------------------