1300
1301
1302 class(SwfDfwType) :: this
1303 real(DP), intent(in), dimension(:) :: flowja
1304
1305 integer(I4B) :: n
1306 integer(I4B) :: m
1307 integer(I4B) :: ipos
1308 integer(I4B) :: isympos
1309 integer(I4B) :: ihc
1310 integer(I4B) :: ic
1311 integer(I4B) :: iz
1312 integer(I4B) :: nc
1313 integer(I4B) :: ncz
1314 real(DP) :: vx
1315 real(DP) :: vy
1316 real(DP) :: vz
1317 real(DP) :: xn
1318 real(DP) :: yn
1319 real(DP) :: zn
1320 real(DP) :: xc
1321 real(DP) :: yc
1322 real(DP) :: zc
1323 real(DP) :: cl1
1324 real(DP) :: cl2
1325 real(DP) :: dltot
1326 real(DP) :: ooclsum
1327 real(DP) :: dsumx
1328 real(DP) :: dsumy
1329 real(DP) :: dsumz
1330 real(DP) :: denom
1331 real(DP) :: area
1332 real(DP) :: axy
1333 real(DP) :: ayx
1334 real(DP), allocatable, dimension(:) :: vi
1335 real(DP), allocatable, dimension(:) :: di
1336 real(DP), allocatable, dimension(:) :: viz
1337 real(DP), allocatable, dimension(:) :: diz
1338 real(DP), allocatable, dimension(:) :: nix
1339 real(DP), allocatable, dimension(:) :: niy
1340 real(DP), allocatable, dimension(:) :: wix
1341 real(DP), allocatable, dimension(:) :: wiy
1342 real(DP), allocatable, dimension(:) :: wiz
1343 real(DP), allocatable, dimension(:) :: bix
1344 real(DP), allocatable, dimension(:) :: biy
1345 logical :: nozee = .true.
1346
1347
1348
1349 if (this%icalcvelocity /= 0 .and. this%dis%con%ianglex == 0) then
1350 call store_error('Error. ANGLDEGX not provided in '// &
1351 'discretization file. ANGLDEGX required for '// &
1352 'calculation of velocity.', terminate=.true.)
1353 end if
1354
1355
1356 nc = 0
1357 do n = 1, this%dis%nodes
1358
1359
1360 ic = this%dis%con%ia(n + 1) - this%dis%con%ia(n) - 1
1361
1362
1363 do m = 1, this%nedges
1364 if (this%nodedge(m) == n) then
1365 ic = ic + 1
1366 end if
1367 end do
1368
1369
1370 if (ic > nc) nc = ic
1371 end do
1372
1373
1374 allocate (vi(nc))
1375 allocate (di(nc))
1376 allocate (viz(nc))
1377 allocate (diz(nc))
1378 allocate (nix(nc))
1379 allocate (niy(nc))
1380 allocate (wix(nc))
1381 allocate (wiy(nc))
1382 allocate (wiz(nc))
1383 allocate (bix(nc))
1384 allocate (biy(nc))
1385
1386
1387 do n = 1, this%dis%nodes
1388
1389
1390
1391 ic = 0
1392 iz = 0
1393 vi(:) = dzero
1394 di(:) = dzero
1395 viz(:) = dzero
1396 diz(:) = dzero
1397 nix(:) = dzero
1398 niy(:) = dzero
1399 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
1400 m = this%dis%con%ja(ipos)
1401 isympos = this%dis%con%jas(ipos)
1402 ihc = this%dis%con%ihc(isympos)
1403 ic = ic + 1
1404 call this%dis%connection_normal(n, m, ihc, xn, yn, zn, ipos)
1405 call this%dis%connection_vector(n, m, nozee, done, done, &
1406 ihc, xc, yc, zc, dltot)
1407 cl1 = this%dis%con%cl1(isympos)
1408 cl2 = this%dis%con%cl2(isympos)
1409 if (m < n) then
1410 cl1 = this%dis%con%cl2(isympos)
1411 cl2 = this%dis%con%cl1(isympos)
1412 end if
1413 ooclsum = done / (cl1 + cl2)
1414 nix(ic) = -xn
1415 niy(ic) = -yn
1416 di(ic) = dltot * cl1 * ooclsum
1417 area = this%get_flow_area_nm(n, m, this%hnew(n), this%hnew(m), &
1418 cl1, cl2, ipos)
1419 if (area > dzero) then
1420 vi(ic) = flowja(ipos) / area
1421 else
1422 vi(ic) = dzero
1423 end if
1424
1425 end do
1426
1427
1428
1429 do m = 1, this%nedges
1430 if (this%nodedge(m) == n) then
1431
1432
1433 ihc = this%ihcedge(m)
1434 area = this%propsedge(2, m)
1435
1436 ic = ic + 1
1437 nix(ic) = -this%propsedge(3, m)
1438 niy(ic) = -this%propsedge(4, m)
1439 di(ic) = this%propsedge(5, m)
1440 if (area > dzero) then
1441 vi(ic) = this%propsedge(1, m) / area
1442 else
1443 vi(ic) = dzero
1444 end if
1445
1446 end if
1447 end do
1448
1449
1450 ncz = iz
1451 nc = ic
1452
1453
1454 if (ncz == 1) then
1455 wiz(1) = done
1456 else
1457 dsumz = dzero
1458 do iz = 1, ncz
1459 dsumz = dsumz + diz(iz)
1460 end do
1461 denom = (ncz - done)
1462 if (denom < dzero) denom = dzero
1463 dsumz = dsumz + dem10 * dsumz
1464 do iz = 1, ncz
1465 if (dsumz > dzero) wiz(iz) = done - diz(iz) / dsumz
1466 if (denom > 0) then
1467 wiz(iz) = wiz(iz) / denom
1468 else
1469 wiz(iz) = dzero
1470 end if
1471 end do
1472 end if
1473 vz = dzero
1474 do iz = 1, ncz
1475 vz = vz + wiz(iz) * viz(iz)
1476 end do
1477
1478
1479 nc = ic
1480 dsumx = dzero
1481 dsumy = dzero
1482 dsumz = dzero
1483 do ic = 1, nc
1484 wix(ic) = di(ic) * abs(nix(ic))
1485 wiy(ic) = di(ic) * abs(niy(ic))
1486 dsumx = dsumx + wix(ic)
1487 dsumy = dsumy + wiy(ic)
1488 end do
1489
1490
1491
1492
1493
1494 dsumx = dsumx + dem10 * dsumx
1495 dsumy = dsumy + dem10 * dsumy
1496 do ic = 1, nc
1497 wix(ic) = (dsumx - wix(ic)) * abs(nix(ic))
1498 wiy(ic) = (dsumy - wiy(ic)) * abs(niy(ic))
1499 end do
1500
1501
1502 dsumx = dzero
1503 dsumy = dzero
1504 do ic = 1, nc
1505 bix(ic) = wix(ic) * sign(done, nix(ic))
1506 biy(ic) = wiy(ic) * sign(done, niy(ic))
1507 dsumx = dsumx + wix(ic) * abs(nix(ic))
1508 dsumy = dsumy + wiy(ic) * abs(niy(ic))
1509 end do
1510 if (dsumx > dzero) dsumx = done / dsumx
1511 if (dsumy > dzero) dsumy = done / dsumy
1512 axy = dzero
1513 ayx = dzero
1514 do ic = 1, nc
1515 bix(ic) = bix(ic) * dsumx
1516 biy(ic) = biy(ic) * dsumy
1517 axy = axy + bix(ic) * niy(ic)
1518 ayx = ayx + biy(ic) * nix(ic)
1519 end do
1520
1521
1522
1523
1524
1525
1526
1527
1528 vx = dzero
1529 vy = dzero
1530 do ic = 1, nc
1531 vx = vx + (bix(ic) - axy * biy(ic)) * vi(ic)
1532 vy = vy + (biy(ic) - ayx * bix(ic)) * vi(ic)
1533 end do
1534 denom = done - axy * ayx
1535 if (denom /= dzero) then
1536 vx = vx / denom
1537 vy = vy / denom
1538 end if
1539
1540 this%vcomp(1, n) = vx
1541 this%vcomp(2, n) = vy
1542 this%vcomp(3, n) = vz
1543 this%vmag(n) = sqrt(vx**2 + vy**2 + vz**2)
1544
1545 end do
1546
1547
1548 deallocate (vi)
1549 deallocate (di)
1550 deallocate (nix)
1551 deallocate (niy)
1552 deallocate (wix)
1553 deallocate (wiy)
1554 deallocate (wiz)
1555 deallocate (bix)
1556 deallocate (biy)
1557