226 UserCtx *user,
const DMDALocalInfo *info,
227 PetscInt xs_gnode_rank, PetscInt ys_gnode_rank, PetscInt zs_gnode_rank,
228 PetscInt IM_nodes_global, PetscInt JM_nodes_global, PetscInt KM_nodes_global,
229 PetscRandom *rand_logic_i_ptr, PetscRandom *rand_logic_j_ptr, PetscRandom *rand_logic_k_ptr,
230 PetscInt *ci_metric_lnode_out, PetscInt *cj_metric_lnode_out, PetscInt *ck_metric_lnode_out,
231 PetscReal *xi_metric_logic_out, PetscReal *eta_metric_logic_out, PetscReal *zta_metric_logic_out)
233 PetscErrorCode ierr = 0;
234 PetscReal r_val_i_sel, r_val_j_sel, r_val_k_sel;
235 PetscInt local_cell_idx_on_face_dim1 = 0;
236 PetscInt local_cell_idx_on_face_dim2 = 0;
237 PetscMPIInt rank_for_logging;
239 PetscFunctionBeginUser;
240 ierr = MPI_Comm_rank(PETSC_COMM_WORLD, &rank_for_logging); CHKERRQ(ierr);
243 *ci_metric_lnode_out = xs_gnode_rank; *cj_metric_lnode_out = ys_gnode_rank; *ck_metric_lnode_out = zs_gnode_rank;
245 *xi_metric_logic_out = 0.5; *eta_metric_logic_out = 0.5; *zta_metric_logic_out = 0.5;
248 PetscInt owned_start_cell_i, num_owned_cells_on_rank_i;
249 PetscInt owned_start_cell_j, num_owned_cells_on_rank_j;
250 PetscInt owned_start_cell_k, num_owned_cells_on_rank_k;
252 ierr =
GetOwnedCellRange(info, 0, &owned_start_cell_i, &num_owned_cells_on_rank_i); CHKERRQ(ierr);
253 ierr =
GetOwnedCellRange(info, 1, &owned_start_cell_j, &num_owned_cells_on_rank_j); CHKERRQ(ierr);
254 ierr =
GetOwnedCellRange(info, 2, &owned_start_cell_k, &num_owned_cells_on_rank_k); CHKERRQ(ierr);
257 PetscInt last_global_cell_idx_i = (IM_nodes_global > 1) ? (IM_nodes_global - 2) : -1;
258 PetscInt last_global_cell_idx_j = (JM_nodes_global > 1) ? (JM_nodes_global - 2) : -1;
259 PetscInt last_global_cell_idx_k = (KM_nodes_global > 1) ? (KM_nodes_global - 2) : -1;
261 LOG_ALLOW(
LOCAL,
LOG_DEBUG,
"Rank %d: Inlet face %d. Owned cells(i,j,k):(%d,%d,%d). GlobNodes(I,J,K):(%d,%d,%d). Rank's DA node starts (xs_g,ys_g,zs_g): (%d,%d,%d).\n",
262 rank_for_logging, user->
identifiedInletBCFace, num_owned_cells_on_rank_i,num_owned_cells_on_rank_j,num_owned_cells_on_rank_k,
263 IM_nodes_global,JM_nodes_global,KM_nodes_global, xs_gnode_rank,ys_gnode_rank,zs_gnode_rank);
270 *ci_metric_lnode_out = xs_gnode_rank;
271 *xi_metric_logic_out = 1.0e-6;
275 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, &r_val_j_sel); CHKERRQ(ierr);
276 local_cell_idx_on_face_dim1 = (PetscInt)(r_val_j_sel * num_owned_cells_on_rank_j);
277 local_cell_idx_on_face_dim1 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim1), num_owned_cells_on_rank_j - 1);
278 *cj_metric_lnode_out = ys_gnode_rank + local_cell_idx_on_face_dim1;
280 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, &r_val_k_sel); CHKERRQ(ierr);
281 local_cell_idx_on_face_dim2 = (PetscInt)(r_val_k_sel * num_owned_cells_on_rank_k);
282 local_cell_idx_on_face_dim2 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim2), num_owned_cells_on_rank_k - 1);
283 *ck_metric_lnode_out = zs_gnode_rank + local_cell_idx_on_face_dim2;
285 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, eta_metric_logic_out); CHKERRQ(ierr);
286 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, zta_metric_logic_out); CHKERRQ(ierr);
292 *ci_metric_lnode_out = xs_gnode_rank + (last_global_cell_idx_i - info->xs);
293 *xi_metric_logic_out = 1.0 - 1.0e-6;
295 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, &r_val_j_sel); CHKERRQ(ierr);
296 local_cell_idx_on_face_dim1 = (PetscInt)(r_val_j_sel * num_owned_cells_on_rank_j);
297 local_cell_idx_on_face_dim1 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim1), num_owned_cells_on_rank_j - 1);
298 *cj_metric_lnode_out = ys_gnode_rank + local_cell_idx_on_face_dim1;
300 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, &r_val_k_sel); CHKERRQ(ierr);
301 local_cell_idx_on_face_dim2 = (PetscInt)(r_val_k_sel * num_owned_cells_on_rank_k);
302 local_cell_idx_on_face_dim2 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim2), num_owned_cells_on_rank_k - 1);
303 *ck_metric_lnode_out = zs_gnode_rank + local_cell_idx_on_face_dim2;
305 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, eta_metric_logic_out); CHKERRQ(ierr);
306 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, zta_metric_logic_out); CHKERRQ(ierr);
310 *cj_metric_lnode_out = ys_gnode_rank;
311 *eta_metric_logic_out = 1.0e-6;
312 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, &r_val_i_sel); CHKERRQ(ierr);
313 local_cell_idx_on_face_dim1 = (PetscInt)(r_val_i_sel * num_owned_cells_on_rank_i);
314 local_cell_idx_on_face_dim1 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim1), num_owned_cells_on_rank_i - 1);
315 *ci_metric_lnode_out = xs_gnode_rank + local_cell_idx_on_face_dim1;
316 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, &r_val_k_sel); CHKERRQ(ierr);
317 local_cell_idx_on_face_dim2 = (PetscInt)(r_val_k_sel * num_owned_cells_on_rank_k);
318 local_cell_idx_on_face_dim2 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim2), num_owned_cells_on_rank_k - 1);
319 *ck_metric_lnode_out = zs_gnode_rank + local_cell_idx_on_face_dim2;
320 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, xi_metric_logic_out); CHKERRQ(ierr);
321 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, zta_metric_logic_out); CHKERRQ(ierr);
324 *cj_metric_lnode_out = ys_gnode_rank + (last_global_cell_idx_j - info->ys);
325 *eta_metric_logic_out = 1.0 - 1.0e-6;
326 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, &r_val_i_sel); CHKERRQ(ierr);
327 local_cell_idx_on_face_dim1 = (PetscInt)(r_val_i_sel * num_owned_cells_on_rank_i);
328 local_cell_idx_on_face_dim1 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim1), num_owned_cells_on_rank_i - 1);
329 *ci_metric_lnode_out = xs_gnode_rank + local_cell_idx_on_face_dim1;
330 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, &r_val_k_sel); CHKERRQ(ierr);
331 local_cell_idx_on_face_dim2 = (PetscInt)(r_val_k_sel * num_owned_cells_on_rank_k);
332 local_cell_idx_on_face_dim2 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim2), num_owned_cells_on_rank_k - 1);
333 *ck_metric_lnode_out = zs_gnode_rank + local_cell_idx_on_face_dim2;
334 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, xi_metric_logic_out); CHKERRQ(ierr);
335 ierr = PetscRandomGetValueReal(*rand_logic_k_ptr, zta_metric_logic_out); CHKERRQ(ierr);
338 *ck_metric_lnode_out = zs_gnode_rank;
339 *zta_metric_logic_out = 1.0e-6;
341 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, &r_val_i_sel); CHKERRQ(ierr);
342 local_cell_idx_on_face_dim1 = (PetscInt)(r_val_i_sel * num_owned_cells_on_rank_i);
343 local_cell_idx_on_face_dim1 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim1), num_owned_cells_on_rank_i - 1);
344 *ci_metric_lnode_out = xs_gnode_rank + local_cell_idx_on_face_dim1;
346 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, &r_val_j_sel); CHKERRQ(ierr);
347 local_cell_idx_on_face_dim2 = (PetscInt)(r_val_j_sel * num_owned_cells_on_rank_j);
348 local_cell_idx_on_face_dim2 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim2), num_owned_cells_on_rank_j - 1);
349 *cj_metric_lnode_out = ys_gnode_rank + local_cell_idx_on_face_dim2;
351 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, xi_metric_logic_out); CHKERRQ(ierr);
352 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, eta_metric_logic_out); CHKERRQ(ierr);
355 *ck_metric_lnode_out = zs_gnode_rank + (last_global_cell_idx_k - info->zs);
356 *zta_metric_logic_out = 1.0 - 1.0e-6;
357 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, &r_val_i_sel); CHKERRQ(ierr);
358 local_cell_idx_on_face_dim1 = (PetscInt)(r_val_i_sel * num_owned_cells_on_rank_i);
359 local_cell_idx_on_face_dim1 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim1), num_owned_cells_on_rank_i - 1);
360 *ci_metric_lnode_out = xs_gnode_rank + local_cell_idx_on_face_dim1;
361 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, &r_val_j_sel); CHKERRQ(ierr);
362 local_cell_idx_on_face_dim2 = (PetscInt)(r_val_j_sel * num_owned_cells_on_rank_j);
363 local_cell_idx_on_face_dim2 = PetscMin(PetscMax(0, local_cell_idx_on_face_dim2), num_owned_cells_on_rank_j - 1);
364 *cj_metric_lnode_out = ys_gnode_rank + local_cell_idx_on_face_dim2;
365 ierr = PetscRandomGetValueReal(*rand_logic_i_ptr, xi_metric_logic_out); CHKERRQ(ierr);
366 ierr = PetscRandomGetValueReal(*rand_logic_j_ptr, eta_metric_logic_out); CHKERRQ(ierr);
369 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
"GetRandomCellAndLogicOnInletFace: Invalid user->identifiedInletBCFace %d. \n", user->
identifiedInletBCFace);
372 PetscReal eps = 1.0e-7;
374 *eta_metric_logic_out = PetscMin(PetscMax(0.0, *eta_metric_logic_out), 1.0 - eps);
375 *zta_metric_logic_out = PetscMin(PetscMax(0.0, *zta_metric_logic_out), 1.0 - eps);
377 *xi_metric_logic_out = PetscMin(PetscMax(0.0, *xi_metric_logic_out), 1.0 - eps);
378 *zta_metric_logic_out = PetscMin(PetscMax(0.0, *zta_metric_logic_out), 1.0 - eps);
380 *xi_metric_logic_out = PetscMin(PetscMax(0.0, *xi_metric_logic_out), 1.0 - eps);
381 *eta_metric_logic_out = PetscMin(PetscMax(0.0, *eta_metric_logic_out), 1.0 - eps);
384 LOG_ALLOW(
LOCAL,
LOG_DEBUG,
"Rank %d: Target CellNode(loc lnode idx)=(%d,%d,%d). Logic(xi,et,zt)=(%.2e,%.2f,%.2f). \n",
385 rank_for_logging, *ci_metric_lnode_out, *cj_metric_lnode_out, *ck_metric_lnode_out,
386 *xi_metric_logic_out, *eta_metric_logic_out, *zta_metric_logic_out);
388 PetscFunctionReturn(0);
821 PetscInt i, j, k, rank, fn;
822 PetscReal FluxIn, r, uin, uin_max, xc, yc, zc, d, H=4.1, Umax=1.5;
823 PetscReal lAreaIn, AreaSumIn;
825 Cmpnts ***ucont, ***ubcs, ***ucat, ***coor, ***csi, ***eta, ***zet, ***cent;
827 DM da = user->
da, fda = user->
fda;
828 DMDALocalInfo info = user->
info;
829 PetscInt xs = info.xs, xe = info.xs + info.xm;
830 PetscInt ys = info.ys, ye = info.ys + info.ym;
831 PetscInt zs = info.zs, ze = info.zs + info.zm;
832 PetscInt mx = info.mx, my = info.my, mz = info.mz;
833 PetscInt lxs, lxe, lys, lye, lzs, lze;
834 PetscReal ***nvert, ***RR;
839 PetscReal CMx_c = simCtx->
CMx_c;
840 PetscReal CMy_c = simCtx->
CMy_c;
841 PetscReal CMz_c = simCtx->
CMz_c;
843 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
846 VecDuplicate(user->
lNvert, &RFC);
852 if (xs==0) lxs = xs+1;
853 if (ys==0) lys = ys+1;
854 if (zs==0) lzs = zs+1;
856 if (xe==mx) lxe = xe-1;
857 if (ye==my) lye = ye-1;
858 if (ze==mz) lze = ze-1;
860 DMGetCoordinatesLocal(da, &Coor);
861 DMDAVecGetArray(fda, Coor, &coor);
862 DMDAVecGetArray(fda, user->
Ucont, &ucont);
863 DMDAVecGetArray(fda, user->
Bcs.
Ubcs, &ubcs);
864 DMDAVecGetArray(fda, user->
Ucat, &ucat);
865 DMDAVecGetArray(da, user->
lNvert, &nvert);
866 DMDAVecGetArray(da, RFC, &RR);
867 DMDAVecGetArray(fda, user->
Cent, ¢);
868 DMDAVecGetArray(fda, user->
lCsi, &csi);
869 DMDAVecGetArray(fda, user->
lEta, &eta);
870 DMDAVecGetArray(fda, user->
lZet, &zet);
896 if (inletprofile == 3) {
898 for (fn=0; fn<6; fn++) {
901 if (fn==0 && xs==0) { i=xs;
for(k=lzs;k<lze;k++)
for(j=lys;j<lye;j++)
if(nvert[k][j][i+1]<0.1) lAreaIn+=sqrt(csi[k][j][i].x*csi[k][j][i].x+csi[k][j][i].y*csi[k][j][i].y+csi[k][j][i].z*csi[k][j][i].z); }
902 if (fn==1 && xe==mx) { i=mx-2;
for(k=lzs;k<lze;k++)
for(j=lys;j<lye;j++)
if(nvert[k][j][i]<0.1) lAreaIn+=sqrt(csi[k][j][i].x*csi[k][j][i].x+csi[k][j][i].y*csi[k][j][i].y+csi[k][j][i].z*csi[k][j][i].z); }
903 if (fn==2 && ys==0) { j=ys;
for(k=lzs;k<lze;k++)
for(i=lxs;i<lxe;i++)
if(nvert[k][j+1][i]<0.1) lAreaIn+=sqrt(eta[k][j][i].x*eta[k][j][i].x+eta[k][j][i].y*eta[k][j][i].y+eta[k][j][i].z*eta[k][j][i].z); }
904 if (fn==3 && ye==my) { j=my-2;
for(k=lzs;k<lze;k++)
for(i=lxs;i<lxe;i++)
if(nvert[k][j][i]<0.1) lAreaIn+=sqrt(eta[k][j][i].x*eta[k][j][i].x+eta[k][j][i].y*eta[k][j][i].y+eta[k][j][i].z*eta[k][j][i].z); }
905 if (fn==4 && zs==0) { k=zs;
for(j=lys;j<lye;j++)
for(i=lxs;i<lxe;i++)
if(nvert[k+1][j][i]<0.1) lAreaIn+=sqrt(zet[k][j][i].x*zet[k][j][i].x+zet[k][j][i].y*zet[k][j][i].y+zet[k][j][i].z*zet[k][j][i].z); }
906 if (fn==5 && ze==mz) { k=mz-2;
for(j=lys;j<lye;j++)
for(i=lxs;i<lxe;i++)
if(nvert[k][j][i]<0.1) lAreaIn+=sqrt(zet[k][j][i].x*zet[k][j][i].x+zet[k][j][i].y*zet[k][j][i].y+zet[k][j][i].z*zet[k][j][i].z); }
909 MPI_Allreduce(&lAreaIn, &AreaSumIn, 1, MPI_DOUBLE, MPI_SUM, PETSC_COMM_WORLD);
914 else if (inletprofile == 4) {
915 for (fn=0; fn<6; fn++) {
918 for(j=lys;j<lye;j++){
919 for(i=lxs;i<lxe;i++){
920 xc = cent[k+1][j][i].
x - CMx_c;
921 yc = cent[k+1][j][i].
y - CMy_c;
922 RR[k][j][i] = sqrt(xc*xc + yc*yc);
931 if (inletprofile == 1 || inletprofile == 2 || inletprofile == 4 || inletprofile == 7) {
932 PetscOptionsGetReal(NULL,NULL,
"-uin", &uin_max, NULL);
937 for (fn=0; fn<6; fn++) {
944 for (k=lzs; k<lze; k++) {
945 for (j=lys; j<lye; j++) {
946 if (nvert[k][j][i+1]<0.1) {
949 if (inletprofile == 1) uin = 1.0;
952 d = sqrt(csi[k][j][i].z*csi[k][j][i].z + csi[k][j][i].y*csi[k][j][i].y + csi[k][j][i].x*csi[k][j][i].x);
954 ucont[k][j][i].
x = uin*d;
955 ubcs[k][j][i].
x = uin*csi[k][j][i].
x/d;
956 ubcs[k][j][i].
y = uin*csi[k][j][i].
y/d;
957 ubcs[k][j][i].
z = uin*csi[k][j][i].
z/d;
958 ucat[k][j][i+1] = ubcs[k][j][i];
959 FluxIn += ucont[k][j][i].
x;
968 for (k=lzs; k<lze; k++) {
969 for (j=lys; j<lye; j++) {
970 if (nvert[k][j][i]<0.1) {
972 if (inletprofile == 1) uin = 1.0;
975 d = sqrt(csi[k][j][i].z*csi[k][j][i].z + csi[k][j][i].y*csi[k][j][i].y + csi[k][j][i].x*csi[k][j][i].x);
977 ucont[k][j][i].
x = -uin*d;
978 ubcs[k][j][i+1].
x = -uin*csi[k][j][i].
x/d;
979 ubcs[k][j][i+1].
y = -uin*csi[k][j][i].
y/d;
980 ubcs[k][j][i+1].
z = -uin*csi[k][j][i].
z/d;
981 ucat[k][j][i] = ubcs[k][j][i+1];
982 FluxIn += ucont[k][j][i].
x;
991 for (k=lzs; k<lze; k++) {
992 for (i=lxs; i<lxe; i++) {
993 if (nvert[k][j+1][i]<0.1) {
995 if (inletprofile == 1) uin = 1.0;
998 d = sqrt(eta[k][j][i].z*eta[k][j][i].z + eta[k][j][i].y*eta[k][j][i].y + eta[k][j][i].x*eta[k][j][i].x);
1000 ucont[k][j][i].
y = uin*d;
1001 ubcs[k][j][i].
x = uin*eta[k][j][i].
x/d;
1002 ubcs[k][j][i].
y = uin*eta[k][j][i].
y/d;
1003 ubcs[k][j][i].
z = uin*eta[k][j][i].
z/d;
1004 ucat[k][j+1][i] = ubcs[k][j][i];
1005 FluxIn += ucont[k][j][i].
y;
1014 for (k=lzs; k<lze; k++) {
1015 for (i=lxs; i<lxe; i++) {
1016 if (nvert[k][j][i]<0.1) {
1018 if (inletprofile == 1) uin = 1.0;
1021 d = sqrt(eta[k][j][i].z*eta[k][j][i].z + eta[k][j][i].y*eta[k][j][i].y + eta[k][j][i].x*eta[k][j][i].x);
1023 ucont[k][j][i].
y = -uin*d;
1024 ubcs[k][j+1][i].
x = -uin*eta[k][j][i].
x/d;
1025 ubcs[k][j+1][i].
y = -uin*eta[k][j][i].
y/d;
1026 ubcs[k][j+1][i].
z = -uin*eta[k][j][i].
z/d;
1027 ucat[k][j][i] = ubcs[k][j+1][i];
1028 FluxIn += ucont[k][j][i].
y;
1037 for (j=lys; j<lye; j++) {
1038 for (i=lxs; i<lxe; i++) {
1039 if (nvert[k+1][j][i]<0.1) {
1042 xc = (coor[k][j][i].
x + coor[k][j-1][i].
x + coor[k][j][i-1].
x + coor[k][j-1][i-1].
x) * 0.25 - CMx_c;
1043 yc = (coor[k][j][i].
y + coor[k][j-1][i].
y + coor[k][j][i-1].
y + coor[k][j-1][i-1].
y) * 0.25 - CMy_c;
1045 r = sqrt(xc*xc + yc*yc);
1048 if (inletprofile == 0 || inletprofile == 6 || inletprofile == 8) {
1050 }
else if (inletprofile == 1) {
1052 }
else if (inletprofile == -1) {
1054 }
else if (inletprofile == 2) {
1055 uin = 4.0 * uin_max * yc * (H - yc) / (H * H);
1056 }
else if (inletprofile == 3) {
1058 }
else if (inletprofile == 4) {
1060 uin = uin_max * (1.0 - 4.0 * r * r);
1061 if (r > 0.5) uin=0.;
1062 }
else if (inletprofile == 5) {
1064 }
else if (inletprofile == 7) {
1065 uin = uin_max * (1.0 - 4.0 * yc * yc);
1066 }
else if (inletprofile == 10) {
1067 double _y = (yc-1.5)*2., _x=xc-0.5;
1070 #define M_PI 3.14159265358979323846264338327950288
1074 for(n=0; n<20; n++) {
1075 uin -= 4.*pow(2./
M_PI,3) * pow(-1., n) / pow(2*n+1.,3.) * cosh((2*n+1)*
M_PI*_x/2.) * cos((2.*n+1)*
M_PI*_y/2.) / cosh((2*n+1)*
M_PI*A/2.);
1077 }
else if (inletprofile == 11) {
1084 d = sqrt(zet[k][j][i].z*zet[k][j][i].z + zet[k][j][i].y*zet[k][j][i].y + zet[k][j][i].x*zet[k][j][i].x);
1086 ucont[k][j][i].
z = uin*d;
1087 ubcs[k][j][i].
x = uin*zet[k][j][i].
x/d;
1088 ubcs[k][j][i].
y = uin*zet[k][j][i].
y/d;
1089 ubcs[k][j][i].
z = uin*zet[k][j][i].
z/d;
1090 ucat[k+1][j][i] = ubcs[k][j][i];
1091 FluxIn += ucont[k][j][i].
z;
1102 for (j=lys; j<lye; j++) {
1103 for (i=lxs; i<lxe; i++) {
1104 if (nvert[k][j][i]<0.1) {
1106 if (inletprofile == 1) uin = 1.0;
1109 d = sqrt(zet[k][j][i].z*zet[k][j][i].z + zet[k][j][i].y*zet[k][j][i].y + zet[k][j][i].x*zet[k][j][i].x);
1111 ucont[k][j][i].
z = -uin*d;
1112 ubcs[k+1][j][i].
x = -uin*zet[k][j][i].
x/d;
1113 ubcs[k+1][j][i].
y = -uin*zet[k][j][i].
y/d;
1114 ubcs[k+1][j][i].
z = -uin*zet[k][j][i].
z/d;
1115 ucat[k][j][i] = ubcs[k+1][j][i];
1116 FluxIn += ucont[k][j][i].
z;
1138 MPI_Allreduce(&FluxIn, &simCtx->
FluxInSum, 1, MPI_DOUBLE, MPI_SUM, PETSC_COMM_WORLD);
1139 if (inletprofile != 3) {
1140 MPI_Allreduce(&lAreaIn, &AreaSumIn, 1, MPI_DOUBLE, MPI_SUM, PETSC_COMM_WORLD);
1146 DMDAVecRestoreArray(fda, Coor, &coor);
1147 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
1148 DMDAVecRestoreArray(fda, user->
Bcs.
Ubcs, &ubcs);
1149 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
1150 DMDAVecRestoreArray(da, user->
lNvert, &nvert);
1151 DMDAVecRestoreArray(da, RFC, &RR);
1152 DMDAVecRestoreArray(fda, user->
Cent, ¢);
1153 DMDAVecRestoreArray(fda, user->
lCsi, &csi);
1154 DMDAVecRestoreArray(fda, user->
lEta, &eta);
1155 DMDAVecRestoreArray(fda, user->
lZet, &zet);
1159 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
1160 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
1263 DM da = user->
da, fda = user->
fda;
1264 DMDALocalInfo info = user->
info;
1265 PetscInt xs = info.xs, xe = info.xs + info.xm;
1266 PetscInt ys = info.ys, ye = info.ys + info.ym;
1267 PetscInt zs = info.zs, ze = info.zs + info.zm;
1268 PetscInt mx = info.mx, my = info.my, mz = info.mz;
1269 PetscInt lxs, lxe, lys, lye, lzs, lze;
1272 PetscReal ***nvert,***lnvert;
1274 PetscReal ***p,***lp;
1275 Cmpnts ***ucont, ***ubcs, ***ucat,***lucat, ***csi, ***eta, ***zet;
1276 Cmpnts ***cent,***centx,***centy,***centz,***coor;
1277 PetscScalar FluxIn, FluxOut,ratio;
1278 PetscScalar lArea, AreaSum;
1280 PetscScalar FarFluxIn=0., FarFluxOut=0., FarFluxInSum, FarFluxOutSum;
1281 PetscScalar FarAreaIn=0., FarAreaOut=0., FarAreaInSum, FarAreaOutSum;
1282 PetscScalar FluxDiff, VelDiffIn, VelDiffOut;
1285 PetscReal Un, nx,ny,nz,A;
1293 PetscInt gxs, gxe, gys, gye, gzs, gze;
1295 gxs = info.gxs; gxe = gxs + info.gxm;
1296 gys = info.gys; gye = gys + info.gym;
1297 gzs = info.gzs; gze = gzs + info.gzm;
1299 if (xs==0) lxs = xs+1;
1300 if (ys==0) lys = ys+1;
1301 if (zs==0) lzs = zs+1;
1303 if (xe==mx ) lxe = xe-1;
1304 if (ye==my ) lye = ye-1;
1305 if (ze==mz ) lze = ze-1;
1308 DMDAVecGetArray(fda, user->
Bcs.
Ubcs, &ubcs);
1310 DMDAVecGetArray(fda, user->
lCsi, &csi);
1311 DMDAVecGetArray(fda, user->
lEta, &eta);
1312 DMDAVecGetArray(fda, user->
lZet, &zet);
1315 for (ttemp=0; ttemp<3; ttemp++) {
1316 DMDAVecGetArray(da, user->
Nvert, &nvert);
1317 DMDAVecGetArray(fda, user->
lUcat, &ucat);
1318 DMDAVecGetArray(fda, user->
Ucont, &ucont);
1325 FarFluxIn = 0.; FarFluxOut=0.;
1326 FarAreaIn = 0.; FarAreaOut=0.;
1328 PetscReal lFlux_abs=0.0,FluxSum_abs=0.0,ratio=0.0;
1336 if (user->
bctype[0]==6) {
1339 for (k=lzs; k<lze; k++) {
1340 for (j=lys; j<lye; j++) {
1341 ubcs[k][j][i].
x = ucat[k][j][i+1].
x;
1342 ubcs[k][j][i].
y = ucat[k][j][i+1].
y;
1343 ubcs[k][j][i].
z = ucat[k][j][i+1].
z;
1344 ucont[k][j][i].
x = ubcs[k][j][i].
x * csi[k][j][i].
x;
1345 FarFluxIn += ucont[k][j][i].
x;
1346 lFlux_abs += fabs(ucont[k][j][i].x);
1347 FarAreaIn += csi[k][j][i].
x;
1353 if (user->
bctype[1]==6) {
1356 for (k=lzs; k<lze; k++) {
1357 for (j=lys; j<lye; j++) {
1358 ubcs[k][j][i].
x = ucat[k][j][i-1].
x;
1359 ubcs[k][j][i].
y = ucat[k][j][i-1].
y;
1360 ubcs[k][j][i].
z = ucat[k][j][i-1].
z;
1361 ucont[k][j][i-1].
x = ubcs[k][j][i].
x * csi[k][j][i-1].
x;
1362 FarFluxOut += ucont[k][j][i-1].
x;
1363 lFlux_abs += fabs(ucont[k][j][i-1].x);
1364 FarAreaOut += csi[k][j][i-1].
x;
1370 if (user->
bctype[2]==6) {
1373 for (k=lzs; k<lze; k++) {
1374 for (i=lxs; i<lxe; i++) {
1375 ubcs[k][j][i].
x = ucat[k][j+1][i].
x;
1376 ubcs[k][j][i].
y = ucat[k][j+1][i].
y;
1377 ubcs[k][j][i].
z = ucat[k][j+1][i].
z;
1378 ucont[k][j][i].
y = ubcs[k][j][i].
y * eta[k][j][i].
y;
1379 FarFluxIn += ucont[k][j][i].
y;
1380 lFlux_abs += fabs(ucont[k][j][i].y);
1381 FarAreaIn += eta[k][j][i].
y;
1387 if (user->
bctype[3]==6) {
1390 for (k=lzs; k<lze; k++) {
1391 for (i=lxs; i<lxe; i++) {
1392 ubcs[k][j][i].
x = ucat[k][j-1][i].
x;
1393 ubcs[k][j][i].
y = ucat[k][j-1][i].
y;
1394 ubcs[k][j][i].
z = ucat[k][j-1][i].
z;
1395 ucont[k][j-1][i].
y = ubcs[k][j][i].
y * eta[k][j-1][i].
y;
1396 FarFluxOut += ucont[k][j-1][i].
y;
1397 lFlux_abs += fabs(ucont[k][j-1][i].y);
1398 FarAreaOut += eta[k][j-1][i].
y;
1407 for (j=lys; j<lye; j++) {
1408 for (i=lxs; i<lxe; i++) {
1409 ubcs[k][j][i].
x = ucat[k+1][j][i].
x;
1410 ubcs[k][j][i].
y = ucat[k+1][j][i].
y;
1411 ubcs[k][j][i].
z = ucat[k+1][j][i].
z;
1412 ucont[k][j][i].
z = ubcs[k][j][i].
z * zet[k][j][i].
z;
1413 FarFluxIn += ucont[k][j][i].
z;
1414 lFlux_abs += fabs(ucont[k][j][i].z);
1415 FarAreaIn += zet[k][j][i].
z;
1424 for (j=lys; j<lye; j++) {
1425 for (i=lxs; i<lxe; i++) {
1426 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1427 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1428 ubcs[k][j][i].
z = ucat[k-1][j][i].
z;
1429 ucont[k-1][j][i].
z = ubcs[k][j][i].
z * zet[k-1][j][i].
z;
1430 FarFluxOut += ucont[k-1][j][i].
z;
1431 lFlux_abs += fabs(ucont[k-1][j][i].z);
1432 FarAreaOut += zet[k-1][j][i].
z;
1438 MPI_Allreduce(&FarFluxIn,&FarFluxInSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1439 MPI_Allreduce(&FarFluxOut,&FarFluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1440 MPI_Allreduce(&lFlux_abs,&FluxSum_abs,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1441 MPI_Allreduce(&FarAreaIn,&FarAreaInSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1442 MPI_Allreduce(&FarAreaOut,&FarAreaOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1446 ratio=(FarFluxInSum - FarFluxOutSum)/FluxSum_abs;
1447 if (fabs(FluxSum_abs) <1.e-10) ratio = 0.;
1451 FluxDiff = 0.5*(FarFluxInSum - FarFluxOutSum) ;
1452 VelDiffIn = FluxDiff / FarAreaInSum ;
1454 if (fabs(FarAreaInSum) <1.e-6) VelDiffIn = 0.;
1456 VelDiffOut = FluxDiff / FarAreaOutSum ;
1458 if (fabs(FarAreaOutSum) <1.e-6) VelDiffOut = 0.;
1460 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"Far Flux Diff %d %le %le %le %le %le %le %le\n", simCtx->
step, FarFluxInSum, FarFluxOutSum, FluxDiff, FarAreaInSum, FarAreaOutSum, VelDiffIn, VelDiffOut);
1464 if (user->
bctype[5]==10) {
1465 FluxDiff = simCtx->
FluxInSum -( FarFluxOutSum -FarFluxInSum) ;
1466 VelDiffIn = 1/3.*FluxDiff / (FarAreaInSum);
1467 if (fabs(FarAreaInSum) <1.e-6) VelDiffIn = 0.;
1469 VelDiffOut = 2./3.* FluxDiff / (FarAreaOutSum) ;
1471 if (fabs(FarAreaOutSum) <1.e-6) VelDiffOut = 0.;
1473 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"Far Flux Diff %d %le %le %le %le %le %le %le\n", simCtx->
step, FarFluxInSum, FarFluxOutSum, FluxDiff, FarAreaInSum, FarAreaOutSum, VelDiffIn, VelDiffOut);
1483 for (j=lys; j<lye; j++) {
1484 for (i=lxs; i<lxe; i++) {
1485 ucont[k-1][j][i].
z += ratio*fabs(ucont[k-1][j][i].z);
1486 ubcs[k][j][i].
z = ucont[k-1][j][i].
z/zet[k-1][j][i].
z;
1494 if (user->
bctype[3]==6) {
1497 for (k=lzs; k<lze; k++) {
1498 for (i=lxs; i<lxe; i++) {
1500 ucont[k][j-1][i].
y +=ratio*fabs(ucont[k][j-1][i].y);
1501 ubcs[k][j][i].
y = ucont[k][j-1][i].
y /eta[k][j-1][i].
y;
1510 if (user->
bctype[1]==6) {
1513 for (k=lzs; k<lze; k++) {
1514 for (j=lys; j<lye; j++) {
1515 ucont[k][j][i-1].
x +=ratio*fabs(ucont[k][j][i-1].x);
1516 ubcs[k][j][i].
x = ucont[k][j][i-1].
x / csi[k][j][i-1].
x ;
1525 if (user->
bctype[0]==6) {
1528 for (k=lzs; k<lze; k++) {
1529 for (j=lys; j<lye; j++) {
1530 ucont[k][j][i].
x -=ratio*fabs(ucont[k][j][i].x);
1531 ubcs[k][j][i].
x = ucont[k][j][i].
x / csi[k][j][i].
x;
1540 if (user->
bctype[2]==6) {
1543 for (k=lzs; k<lze; k++) {
1544 for (i=lxs; i<lxe; i++) {
1545 ucont[k][j][i].
y -=ratio*fabs(ucont[k][j][i].y);
1546 ubcs[k][j][i].
y = ucont[k][j][i].
y / eta[k][j][i].
y;
1558 for (j=lys; j<lye; j++) {
1559 for (i=lxs; i<lxe; i++) {
1560 ucont[k][j][i].
z -=ratio*fabs(ucont[k][j][i].z);
1561 ubcs[k][j][i].
z =ucont[k][j][i].
z / zet[k][j][i].
z;
1575 for (k=lzs; k<lze; k++) {
1576 for (i=lxs; i<lxe; i++) {
1577 A=sqrt(eta[k][j][i].z*eta[k][j][i].z +
1578 eta[k][j][i].y*eta[k][j][i].y +
1579 eta[k][j][i].x*eta[k][j][i].x);
1580 nx=eta[k][j][i].
x/A;
1581 ny=eta[k][j][i].
y/A;
1582 nz=eta[k][j][i].
z/A;
1583 Un=ucat[k][j+1][i].
x*nx+ucat[k][j+1][i].
y*ny+ucat[k][j+1][i].
z*nz;
1584 ubcs[k][j][i].
x = 0.0;
1585 ubcs[k][j][i].
y = 0.0;
1586 ubcs[k][j][i].
z = 0.0;
1587 ucont[k][j][i].
y = 0.;
1605 for (k=lzs; k<lze; k++) {
1606 for (j=lys; j<lye; j++) {
1607 ubcs[k][j][i].
x = 0.0;
1608 ubcs[k][j][i].
y = 0.0;
1609 ubcs[k][j][i].
z = 0.0;
1610 ucont[k][j][i].
x = 0.0;
1620 for (k=lzs; k<lze; k++) {
1621 for (j=lys; j<lye; j++) {
1622 ubcs[k][j][i].
x = 0.0;
1623 ubcs[k][j][i].
y = 0.0;
1624 ubcs[k][j][i].
z = 0.0;
1626 ucont[k][j][i-1].
x = 0.0;
1636 for (k=lzs; k<lze; k++) {
1637 for (i=lxs; i<lxe; i++) {
1638 ubcs[k][j][i].
x = 0.0;
1639 ubcs[k][j][i].
y = 0.0;
1640 ubcs[k][j][i].
z = 0.0;
1641 ucont[k][j][i].
y = 0.0;
1651 for (k=lzs; k<lze; k++) {
1652 for (i=lxs; i<lxe; i++) {
1653 ubcs[k][j][i].
x = 0.0;
1654 ubcs[k][j][i].
y = 0.0;
1655 ubcs[k][j][i].
z = 0.0;
1657 ucont[k][j-1][i].
y = 0.0;
1672 if (user->
bctype[0]==3) {
1676 for (k=lzs; k<lze; k++) {
1677 for (j=lys; j<lye; j++) {
1678 A=sqrt(csi[k][j][i].z*csi[k][j][i].z +
1679 csi[k][j][i].y*csi[k][j][i].y +
1680 csi[k][j][i].x*csi[k][j][i].x);
1681 nx=csi[k][j][i].
x/A;
1682 ny=csi[k][j][i].
y/A;
1683 nz=csi[k][j][i].
z/A;
1684 Un=ucat[k][j][i+1].
x*nx+ucat[k][j][i+1].
y*ny+ucat[k][j][i+1].
z*nz;
1685 ubcs[k][j][i].
x = ucat[k][j][i+1].
x-Un*nx;
1686 ubcs[k][j][i].
y = ucat[k][j][i+1].
y-Un*ny;
1687 ubcs[k][j][i].
z = ucat[k][j][i+1].
z-Un*nz;
1688 ucont[k][j][i].
x = 0.;
1694 if (user->
bctype[1]==3) {
1698 for (k=lzs; k<lze; k++) {
1699 for (j=lys; j<lye; j++) {
1700 A=sqrt(csi[k][j][i-1].z*csi[k][j][i-1].z +
1701 csi[k][j][i-1].y*csi[k][j][i-1].y +
1702 csi[k][j][i-1].x*csi[k][j][i-1].x);
1703 nx=csi[k][j][i-1].
x/A;
1704 ny=csi[k][j][i-1].
y/A;
1705 nz=csi[k][j][i-1].
z/A;
1706 Un=ucat[k][j][i-1].
x*nx+ucat[k][j][i-1].
y*ny+ucat[k][j][i-1].
z*nz;
1707 ubcs[k][j][i].
x = ucat[k][j][i-1].
x-Un*nx;
1708 ubcs[k][j][i].
y = ucat[k][j][i-1].
y-Un*ny;
1709 ubcs[k][j][i].
z = ucat[k][j][i-1].
z-Un*nz;
1710 ucont[k][j][i-1].
x = 0.;
1716 if (user->
bctype[2]==3) {
1720 for (k=lzs; k<lze; k++) {
1721 for (i=lxs; i<lxe; i++) {
1722 A=sqrt(eta[k][j][i].z*eta[k][j][i].z +
1723 eta[k][j][i].y*eta[k][j][i].y +
1724 eta[k][j][i].x*eta[k][j][i].x);
1725 nx=eta[k][j][i].
x/A;
1726 ny=eta[k][j][i].
y/A;
1727 nz=eta[k][j][i].
z/A;
1728 Un=ucat[k][j+1][i].
x*nx+ucat[k][j+1][i].
y*ny+ucat[k][j+1][i].
z*nz;
1729 ubcs[k][j][i].
x = ucat[k][j+1][i].
x-Un*nx;
1730 ubcs[k][j][i].
y = ucat[k][j+1][i].
y-Un*ny;
1731 ubcs[k][j][i].
z = ucat[k][j+1][i].
z-Un*nz;
1732 ucont[k][j][i].
y = 0.;
1738 if (user->
bctype[3]==3) {
1742 for (k=lzs; k<lze; k++) {
1743 for (i=lxs; i<lxe; i++) {
1744 A=sqrt(eta[k][j-1][i].z*eta[k][j-1][i].z +
1745 eta[k][j-1][i].y*eta[k][j-1][i].y +
1746 eta[k][j-1][i].x*eta[k][j-1][i].x);
1747 nx=eta[k][j-1][i].
x/A;
1748 ny=eta[k][j-1][i].
y/A;
1749 nz=eta[k][j-1][i].
z/A;
1750 Un=ucat[k][j-1][i].
x*nx+ucat[k][j-1][i].
y*ny+ucat[k][j-1][i].
z*nz;
1751 ubcs[k][j][i].
x = ucat[k][j-1][i].
x-Un*nx;
1752 ubcs[k][j][i].
y = ucat[k][j-1][i].
y-Un*ny;
1753 ubcs[k][j][i].
z = ucat[k][j-1][i].
z-Un*nz;
1754 ucont[k][j-1][i].
y = 0.;
1761 if (user->
bctype[4]==3) {
1764 for (j=lys; j<lye; j++) {
1765 for (i=lxs; i<lxe; i++) {
1766 A=sqrt(zet[k][j][i].z*zet[k][j][i].z +
1767 zet[k][j][i].y*zet[k][j][i].y +
1768 zet[k][j][i].x*zet[k][j][i].x);
1769 nx=zet[k][j][i].
x/A;
1770 ny=zet[k][j][i].
y/A;
1771 nz=zet[k][j][i].
z/A;
1772 Un=ucat[k+1][j][i].
x*nx+ucat[k+1][j][i].
y*ny+ucat[k+1][j][i].
z*nz;
1773 ubcs[k][j][i].
x = ucat[k+1][j][i].
x-Un*nx;
1774 ubcs[k][j][i].
y = ucat[k+1][j][i].
y-Un*ny;
1775 ubcs[k][j][i].
z = ucat[k+1][j][i].
z-Un*nz;
1776 ucont[k][j][i].
z = 0.;
1782 if (user->
bctype[5]==3) {
1785 for (j=lys; j<lye; j++) {
1786 for (i=lxs; i<lxe; i++) {
1787 A=sqrt(zet[k-1][j][i].z*zet[k-1][j][i].z +
1788 zet[k-1][j][i].y*zet[k-1][j][i].y +
1789 zet[k-1][j][i].x*zet[k-1][j][i].x);
1790 nx=zet[k-1][j][i].
x/A;
1791 ny=zet[k-1][j][i].
y/A;
1792 nz=zet[k-1][j][i].
z/A;
1793 Un=ucat[k-1][j][i].
x*nx+ucat[k-1][j][i].
y*ny+ucat[k-1][j][i].
z*nz;
1794 ubcs[k][j][i].
x = ucat[k-1][j][i].
x-Un*nx;
1795 ubcs[k][j][i].
y = ucat[k-1][j][i].
y-Un*ny;
1796 ubcs[k][j][i].
z = ucat[k-1][j][i].
z-Un*nz;
1797 ucont[k-1][j][i].
z = 0.;
1807 if (user->
bctype[5]==8) {
1811 for (j=lys; j<lye; j++) {
1812 for (i=lxs; i<lxe; i++) {
1813 FluxOut += ucont[k][j][i].
z;
1821 FluxIn = simCtx->
FluxInSum + FarFluxInSum;
1823 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1828 if (fabs(simCtx->
FluxOutSum) < 1.e-6) ratio = 1.;
1830 if (fabs(FluxIn) <1.e-6) ratio = 0.;
1835 for (j=lys; j<lye; j++) {
1836 for (i=lxs; i<lxe; i++) {
1837 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1838 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1839 if (simCtx->
step==0 || simCtx->
step==1)
1841 ubcs[k][j][i].
z = -1.;
1842 else if (user->
bctype[4]==6)
1843 ubcs[k][j][i].
z = 0.;
1845 ubcs[k][j][i].
z = 1.;
1848 ucont[k-1][j][i].
z = ucont[k-1][j][i].
z*ratio;
1850 ubcs[k][j][i].
z = ucont[k-1][j][i].
z / zet[k-1][j][i].
z;
1870 for (j=lys; j<lye; j++) {
1871 for (i=lxs; i<lxe; i++) {
1873 if ((nvert[k-1][j][i])<0.1) {
1874 FluxOut += (ucat[k-1][j][i].
x * (zet[k-1][j][i].
x) +
1875 ucat[k-1][j][i].y * (zet[k-1][j][i].y) +
1876 ucat[k-1][j][i].
z * (zet[k-1][j][i].
z));
1878 lArea += sqrt( (zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1879 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1880 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1890 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1891 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1906 ratio = (FluxIn - simCtx->
FluxOutSum) / AreaSum;
1915 for (j=lys; j<lye; j++) {
1916 for (i=lxs; i<lxe; i++) {
1917 if ((nvert[k-1][j][i])<0.1) {
1919 ubcs[k][j][i].
x = ucat[k-1][j][i].
x;
1920 ubcs[k][j][i].
y = ucat[k-1][j][i].
y;
1921 ubcs[k][j][i].
z = ucat[k-1][j][i].
z;
1925 ucont[k-1][j][i].
z = (ubcs[k][j][i].
x * (zet[k-1][j][i].
x ) +
1926 ubcs[k][j][i].y * (zet[k-1][j][i].y ) +
1927 ubcs[k][j][i].
z * (zet[k-1][j][i].
z ))*ratio;
1930 ucont[k-1][j][i].
z = (ubcs[k][j][i].
x * (zet[k-1][j][i].
x ) +
1931 ubcs[k][j][i].y * (zet[k-1][j][i].y ) +
1932 ubcs[k][j][i].
z * (zet[k-1][j][i].
z ))
1933 + ratio * sqrt( (zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
1934 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
1935 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
1937 FluxOut += ucont[k-1][j][i].
z;
1944 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1947 }
else if (user->
bctype[5]==2) {
1952 for (j=lys; j<lye; j++) {
1953 for (i=lxs; i<lxe; i++) {
1954 ubcs[k][j][i].
x = 0.;
1955 ubcs[k][j][i].
y = 1;
1956 ubcs[k][j][i].
z = 0.;
1970 for (j=lys; j<lye; j++) {
1971 for (i=lxs; i<lxe; i++) {
1974 FluxOut += ucat[k+1][j][i].
z * zet[k][j][i].
z ;
1976 lArea += zet[k][j][i].
z;
1987 FluxIn = simCtx->
FluxInSum + FarFluxInSum;
1989 MPI_Allreduce(&FluxOut,&simCtx->
FluxOutSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1990 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
1998 for (j=lys; j<lye; j++) {
1999 for (i=lxs; i<lxe; i++) {
2001 ubcs[k][j][i].
x = ucat[k+1][j][i].
x;
2002 ubcs[k][j][i].
y = ucat[k+1][j][i].
y;
2003 ubcs[k][j][i].
z = ucat[k+1][j][i].
z;
2004 ucont[k][j][i].
z = (ubcs[k][j][i].
z+ratio) * zet[k][j][i].z;
2086 Vec Coor; DMGetCoordinatesLocal(da, &Coor);
2087 DMDAVecGetArray(fda,Coor,&coor);
2089 DMDAVecGetArray(fda, user->
Bcs.
Uch, &uch);
2096 double Fluxbcs=0.0, Fluxbcssum,ratiobcs;
2101 for (j=lys; j<lye; j++) {
2102 for (i=lxs; i<lxe; i++) {
2103 if (nvert[k][j][i]<0.1){
2104 Fluxbcs += ucont[k][j][i].
z;
2106 lArea += sqrt((zet[k][j][i].x) * (zet[k][j][i].x) +
2107 (zet[k][j][i].y) * (zet[k][j][i].y) +
2108 (zet[k][j][i].z) * (zet[k][j][i].z));
2117 for (k=zs;k<lze;k++){
2118 for (j=lys; j<lye; j++) {
2119 for (i=lxs; i<lxe; i++) {
2120 if (nvert[k][j][i]<0.1){
2121 FluxIn += ucont[k][j][i].
z /((mz)-1);
2130 MPI_Allreduce(&FluxIn,&simCtx->
Fluxsum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
2131 MPI_Allreduce(&lArea,&AreaSum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
2132 MPI_Allreduce(&Fluxbcs,&Fluxbcssum,1,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD);
2143 simCtx->
ratio=ratio;
2144 ratiobcs=(simCtx->
FluxInSum-Fluxbcssum)/AreaSum;
2148 for (j=lys; j<lye; j++) {
2149 for (i=lxs; i<lxe; i++) {
2150 if (nvert[k+1][j][i]<0.1){
2152 ucont[k][j][i].
z+=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
2153 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
2154 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
2157 uch[k][j][i].
z=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
2158 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
2159 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
2167 for (j=lys; j<lye; j++) {
2168 for (i=lxs; i<lxe; i++) {
2169 if (nvert[k-1][j][i]<0.1){
2171 ucont[k-1][j][i].
z+=ratiobcs * sqrt((zet[k-1][j][i].x) * (zet[k-1][j][i].x) +
2172 (zet[k-1][j][i].y) * (zet[k-1][j][i].y) +
2173 (zet[k-1][j][i].z) * (zet[k-1][j][i].z));
2175 uch[k][j][i].
z=ratiobcs * sqrt( (zet[k+1][j][i].x) * (zet[k+1][j][i].x) +
2176 (zet[k+1][j][i].y) * (zet[k+1][j][i].y) +
2177 (zet[k+1][j][i].z) * (zet[k+1][j][i].z));
2182 DMDAVecRestoreArray(fda, user->
Bcs.
Uch, &uch);
2184 DMDAVecRestoreArray(fda,Coor,&coor);
2223 if (user->
bctype[3]==12) {
2228 for (k=lzs; k<lze; k++) {
2229 for (i=lxs; i<lxe; i++) {
2230 ubcs[k][j][i].
x = 0.;
2231 ubcs[k][j][i].
y = 0.;
2232 ubcs[k][j][i].
z = 1.;
2241 DMDAVecGetArray(fda, user->
Cent, ¢);
2242 if (user->
bctype[2]==11) {
2245 for (k=lzs; k<lze; k++) {
2246 for (i=lxs; i<lxe; i++) {
2253 ubcs[k][j][i].
x = cent[k][j+1][i].
y/sqrt(cent[k][j+1][i].x*cent[k][j+1][i].x+cent[k][j+1][i].y*cent[k][j+1][i].y);;
2254 ubcs[k][j][i].
y =-cent[k][j+1][i].
x/sqrt(cent[k][j+1][i].x*cent[k][j+1][i].x+cent[k][j+1][i].y*cent[k][j+1][i].y);
2255 ubcs[k][j][i].
z =0.0;
2266 PetscOptionsGetReal(NULL,NULL,
"-simCtx->U_bc", &(simCtx->
U_bc), NULL);
2269 if (user->
bctype[2]==13){
2272 for (k=lzs; k<lze; k++) {
2273 for (i=lxs; i<lxe; i++) {
2274 ubcs[k][j][i].
x = 0.;
2276 ubcs[k][j][i].
y = 0.;
2277 ubcs[k][j][i].
z = -simCtx->
U_bc;
2283 if (user->
bctype[3]==13){
2286 for (k=lzs; k<lze; k++) {
2287 for (i=lxs; i<lxe; i++) {
2288 ubcs[k][j][i].
x = 0.;
2290 ubcs[k][j][i].
y = 0.;
2291 ubcs[k][j][i].
z = simCtx->
U_bc;
2298 if (user->
bctype[4]==13){
2301 for (j=lys; j<lye; j++) {
2302 for (i=lxs; i<lxe; i++) {
2303 ubcs[k][j][i].
x =-simCtx->
U_bc;
2304 ubcs[k][j][i].
y = 0.;
2305 ubcs[k][j][i].
z = 0.;
2310 if (user->
bctype[5]==13){
2313 for (j=lys; j<lye; j++) {
2314 for (i=lxs; i<lxe; i++) {
2315 ubcs[k][j][i].
x = simCtx->
U_bc;
2316 ubcs[k][j][i].
y = 0.;
2317 ubcs[k][j][i].
z = 0.;
2322 DMDAVecRestoreArray(fda, user->
Cent, ¢);
2323 DMDAVecRestoreArray(fda, user->
lUcat, &ucat);
2324 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2325 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2326 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2327 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
2338 PetscReal ***ustar, ***aj;
2341 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2342 DMDAVecGetArray(fda, user->
Ucont, &ucont);
2343 DMDAVecGetArray(da, Aj, &aj);
2345 DMDAVecGetArray(da, user->
lUstar, &ustar);
2348 for (k=lzs; k<lze; k++)
2349 for (j=lys; j<lye; j++)
2350 for (i=lxs; i<lxe; i++) {
2352 if( nvert[k][j][i]<1.1 && user->
bctype[2]==-1 && j==1 )
2354 double area = sqrt( eta[k][j][i].x*eta[k][j][i].x + eta[k][j][i].y*eta[k][j][i].y + eta[k][j][i].z*eta[k][j][i].z );
2356 double ni[3], nj[3], nk[3];
2359 Ua.
x = Ua.
y = Ua.
z = 0;
2360 sb = 0.5/aj[k][j][i]/area;
2363 sc = 2*sb + 0.5/aj[k][j+1][i]/area;
2364 Uc = ucat[k][j+1][i];
2370 double AA=sqrt(eta[k][j][i].z*eta[k][j][i].z +
2371 eta[k][j][i].y*eta[k][j][i].y +
2372 eta[k][j][i].x*eta[k][j][i].x);
2373 nj[0]=eta[k][j][i].
x/AA;
2374 nj[1]=eta[k][j][i].
y/AA;
2375 nj[2]=eta[k][j][i].
z/AA;
2376 noslip (user, sc, sb, Ua, Uc, &ucat[k][j][i], nj[0], nj[1], nj[2]);
2377 wall_function_loglaw(user, 1.e-16, sc, sb, Ua, Uc, &ucat[k][j][i], &ustar[k][j][i], nj[0], nj[1], nj[2]);
2388 for (k=lzs; k<lze; k++) {
2389 for (i=lxs; i<lxe; i++) {
2390 ubcs[k][j][i].
x = 0.0;
2391 ubcs[k][j][i].
y = 0.0;
2392 ubcs[k][j][i].
z = 0.0;
2393 ucont[k][j][i].
y = 0.;
2398 DMDAVecRestoreArray(da, Aj, &aj);
2399 DMDAVecRestoreArray(da, user->
lUstar, &ustar);
2400 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2401 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
2406 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2407 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2416 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2421 if (xs==0 && user->
bctype[0]!=7) {
2423 for (k=lzs; k<lze; k++) {
2424 for (j=lys; j<lye; j++) {
2425 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j][i+1].
x;
2426 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j][i+1].
y;
2427 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j][i+1].
z;
2432 if (xe==mx && user->
bctype[0]!=7) {
2434 for (k=lzs; k<lze; k++) {
2435 for (j=lys; j<lye; j++) {
2436 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j][i-1].
x;
2437 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j][i-1].
y;
2438 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j][i-1].
z;
2444 if (ys==0 && user->
bctype[2]!=7) {
2446 for (k=lzs; k<lze; k++) {
2447 for (i=lxs; i<lxe; i++) {
2448 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j+1][i].
x;
2449 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j+1][i].
y;
2450 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j+1][i].
z;
2455 if (ye==my && user->
bctype[2]!=7) {
2457 for (k=lzs; k<lze; k++) {
2458 for (i=lxs; i<lxe; i++) {
2459 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k][j-1][i].
x;
2460 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k][j-1][i].
y;
2461 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k][j-1][i].
z;
2466 if (zs==0 && user->
bctype[4]!=7) {
2468 for (j=lys; j<lye; j++) {
2469 for (i=lxs; i<lxe; i++) {
2470 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k+1][j][i].
x;
2471 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k+1][j][i].
y;
2472 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k+1][j][i].
z;
2477 if (ze==mz && user->
bctype[4]!=7) {
2479 for (j=lys; j<lye; j++) {
2480 for (i=lxs; i<lxe; i++) {
2481 ucat[k][j][i].
x = 2 * ubcs[k][j][i].
x - ucat[k-1][j][i].
x;
2482 ucat[k][j][i].
y = 2 * ubcs[k][j][i].
y - ucat[k-1][j][i].
y;
2483 ucat[k][j][i].
z = 2 * ubcs[k][j][i].
z - ucat[k-1][j][i].
z;
2488 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2493 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2494 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2495 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2496 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2500 DMDAVecGetArray(da, user->
lP, &lp);
2501 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2502 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2503 DMDAVecGetArray(da, user->
P, &p);
2504 DMDAVecGetArray(da, user->
Nvert, &nvert);
2505 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2510 for (k=zs; k<ze; k++) {
2511 for (j=ys; j<ye; j++) {
2512 if(j>0 && k>0 && j<user->JM && k<user->KM){
2513 ucat[k][j][i]=lucat[k][j][i-2];
2514 p[k][j][i]=lp[k][j][i-2];
2515 nvert[k][j][i]=lnvert[k][j][i-2];
2524 for (k=zs; k<ze; k++) {
2525 for (i=xs; i<xe; i++) {
2526 if(i>0 && k>0 && i<user->IM && k<user->KM){
2527 ucat[k][j][i]=lucat[k][j-2][i];
2528 p[k][j][i]=lp[k][j-2][i];
2529 nvert[k][j][i]=lnvert[k][j-2][i];
2538 for (j=ys; j<ye; j++) {
2539 for (i=xs; i<xe; i++) {
2540 if(i>0 && j>0 && i<user->IM && j<user->JM){
2541 ucat[k][j][i]=lucat[k-2][j][i];
2542 nvert[k][j][i]=lnvert[k-2][j][i];
2544 p[k][j][i]=lp[k-2][j][i];
2553 for (k=zs; k<ze; k++) {
2554 for (j=ys; j<ye; j++) {
2555 if(j>0 && k>0 && j<user->JM && k<user->KM){
2556 ucat[k][j][i]=lucat[k][j][i+2];
2557 p[k][j][i]=lp[k][j][i+2];
2558 nvert[k][j][i]=lnvert[k][j][i+2];
2567 for (k=zs; k<ze; k++) {
2568 for (i=xs; i<xe; i++) {
2569 if(i>0 && k>0 && i<user->IM && k<user->KM){
2570 ucat[k][j][i]=lucat[k][j+2][i];
2571 p[k][j][i]=lp[k][j+2][i];
2572 nvert[k][j][i]=lnvert[k][j+2][i];
2582 for (j=ys; j<ye; j++) {
2583 for (i=xs; i<xe; i++) {
2584 if(i>0 && j>0 && i<user->IM && j<user->JM){
2585 ucat[k][j][i]=lucat[k+2][j][i];
2586 nvert[k][j][i]=lnvert[k+2][j][i];
2588 p[k][j][i]=lp[k+2][j][i];
2599 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2600 DMDAVecRestoreArray(da, user->
lP, &lp);
2601 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2602 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2603 DMDAVecRestoreArray(da, user->
P, &p);
2604 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2615 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2616 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2618 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2619 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2621 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2622 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2626 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2627 DMDAVecGetArray(da, user->
P, &p);
2633 for (j=ys; j<ye; j++) {
2634 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j][i+1].
x);
2635 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j][i+1].
y);
2636 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j][i+1].
z);
2637 p[k][j][i]= 0.5*(p[k+1][j][i]+p[k][j][i+1]);
2642 for (j=ys; j<ye; j++) {
2643 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j][i-1].
x);
2644 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j][i-1].
y);
2645 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j][i-1].
z);
2646 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j][i-1]);
2652 for (i=xs; i<xe; i++) {
2653 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j+1][i].
x);
2654 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j+1][i].
y);
2655 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j+1][i].
z);
2656 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j+1][i]);
2662 for (i=xs; i<xe; i++) {
2663 ucat[k][j][i].
x = 0.5*(ucat[k+1][j][i].
x+ucat[k][j-1][i].
x);
2664 ucat[k][j][i].
y = 0.5*(ucat[k+1][j][i].
y+ucat[k][j-1][i].
y);
2665 ucat[k][j][i].
z = 0.5*(ucat[k+1][j][i].
z+ucat[k][j-1][i].
z);
2666 p[k][j][i] = 0.5*(p[k+1][j][i]+p[k][j-1][i]);
2675 for (j=ys; j<ye; j++) {
2676 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j][i+1].
x);
2677 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j][i+1].
y);
2678 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j][i+1].
z);
2679 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j][i+1]);
2684 for (j=ys; j<ye; j++) {
2685 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j][i-1].
x);
2686 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j][i-1].
y);
2687 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j][i-1].
z);
2688 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j][i-1]);
2694 for (i=xs; i<xe; i++) {
2695 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j+1][i].
x);
2696 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j+1][i].
y);
2697 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j+1][i].
z);
2698 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j+1][i]);
2704 for (i=xs; i<xe; i++) {
2705 ucat[k][j][i].
x = 0.5*(ucat[k-1][j][i].
x+ucat[k][j-1][i].
x);
2706 ucat[k][j][i].
y = 0.5*(ucat[k-1][j][i].
y+ucat[k][j-1][i].
y);
2707 ucat[k][j][i].
z = 0.5*(ucat[k-1][j][i].
z+ucat[k][j-1][i].
z);
2708 p[k][j][i] = 0.5*(p[k-1][j][i]+p[k][j-1][i]);
2717 for (k=zs; k<ze; k++) {
2718 ucat[k][j][i].
x = 0.5*(ucat[k][j+1][i].
x+ucat[k][j][i+1].
x);
2719 ucat[k][j][i].
y = 0.5*(ucat[k][j+1][i].
y+ucat[k][j][i+1].
y);
2720 ucat[k][j][i].
z = 0.5*(ucat[k][j+1][i].
z+ucat[k][j][i+1].
z);
2721 p[k][j][i]= 0.5*(p[k][j+1][i]+p[k][j][i+1]);
2727 for (k=zs; k<ze; k++) {
2728 ucat[k][j][i].
x = 0.5*(ucat[k][j+1][i].
x+ucat[k][j][i-1].
x);
2729 ucat[k][j][i].
y = 0.5*(ucat[k][j+1][i].
y+ucat[k][j][i-1].
y);
2730 ucat[k][j][i].
z = 0.5*(ucat[k][j+1][i].
z+ucat[k][j][i-1].
z);
2731 p[k][j][i] = 0.5*(p[k][j+1][i]+p[k][j][i-1]);
2740 for (k=zs; k<ze; k++) {
2741 ucat[k][j][i].
x = 0.5*(ucat[k][j-1][i].
x+ucat[k][j][i+1].
x);
2742 ucat[k][j][i].
y = 0.5*(ucat[k][j-1][i].
y+ucat[k][j][i+1].
y);
2743 ucat[k][j][i].
z = 0.5*(ucat[k][j-1][i].
z+ucat[k][j][i+1].
z);
2744 p[k][j][i] = 0.5*(p[k][j-1][i]+p[k][j][i+1]);
2750 for (k=zs; k<ze; k++) {
2751 ucat[k][j][i].
x = 0.5*(ucat[k][j-1][i].
x+ucat[k][j][i-1].
x);
2752 ucat[k][j][i].
y = 0.5*(ucat[k][j-1][i].
y+ucat[k][j][i-1].
y);
2753 ucat[k][j][i].
z = 0.5*(ucat[k][j-1][i].
z+ucat[k][j][i-1].
z);
2754 p[k][j][i] = 0.5*(p[k][j-1][i]+p[k][j][i-1]);
2759 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2760 DMDAVecRestoreArray(da, user->
P, &p);
2762 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2763 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2765 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2766 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2774 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2775 DMDAVecGetArray(da, user->
lP, &lp);
2776 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2777 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2778 DMDAVecGetArray(da, user->
P, &p);
2779 DMDAVecGetArray(da, user->
Nvert, &nvert);
2784 for (k=zs; k<ze; k++) {
2785 for (j=ys; j<ye; j++) {
2786 ucat[k][j][i]=lucat[k][j][i-2];
2787 p[k][j][i]=lp[k][j][i-2];
2788 nvert[k][j][i]=lnvert[k][j][i-2];
2796 for (k=zs; k<ze; k++) {
2797 for (j=ys; j<ye; j++) {
2798 ucat[k][j][i].
x=lucat[k][j][i+2].
x;
2799 p[k][j][i]=lp[k][j][i+2];
2800 nvert[k][j][i]=lnvert[k][j][i+2];
2805 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2806 DMDAVecRestoreArray(da, user->
lP, &lp);
2807 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2808 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2809 DMDAVecRestoreArray(da, user->
P, &p);
2810 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2821 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2822 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2824 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2825 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2827 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2828 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2831 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2832 DMDAVecGetArray(da, user->
lP, &lp);
2833 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2834 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2835 DMDAVecGetArray(da, user->
P, &p);
2836 DMDAVecGetArray(da, user->
Nvert, &nvert);
2841 for (k=zs; k<ze; k++) {
2842 for (i=xs; i<xe; i++) {
2843 ucat[k][j][i]=lucat[k][j-2][i];
2844 p[k][j][i]=lp[k][j-2][i];
2845 nvert[k][j][i]=lnvert[k][j-2][i];
2854 for (k=zs; k<ze; k++) {
2855 for (i=xs; i<xe; i++) {
2856 ucat[k][j][i]=lucat[k][j+2][i];
2857 p[k][j][i]=lp[k][j+2][i];
2858 nvert[k][j][i]=lnvert[k][j+2][i];
2864 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2865 DMDAVecRestoreArray(da, user->
lP, &lp);
2866 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2867 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2868 DMDAVecRestoreArray(da, user->
P, &p);
2869 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2880 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2881 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2883 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2884 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2886 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2887 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2890 DMDAVecGetArray(fda, user->
lUcat, &lucat);
2891 DMDAVecGetArray(da, user->
lP, &lp);
2892 DMDAVecGetArray(da, user->
lNvert, &lnvert);
2893 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2894 DMDAVecGetArray(da, user->
P, &p);
2895 DMDAVecGetArray(da, user->
Nvert, &nvert);
2900 for (j=ys; j<ye; j++) {
2901 for (i=xs; i<xe; i++) {
2902 ucat[k][j][i]=lucat[k-2][j][i];
2903 nvert[k][j][i]=lnvert[k-2][j][i];
2905 p[k][j][i]=lp[k-2][j][i];
2913 for (j=ys; j<ye; j++) {
2914 for (i=xs; i<xe; i++) {
2915 ucat[k][j][i]=lucat[k+2][j][i];
2916 nvert[k][j][i]=lnvert[k+2][j][i];
2917 p[k][j][i]=lp[k+2][j][i];
2923 DMDAVecRestoreArray(fda, user->
lUcat, &lucat);
2924 DMDAVecRestoreArray(da, user->
lP, &lp);
2925 DMDAVecRestoreArray(da, user->
lNvert, &lnvert);
2926 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
2927 DMDAVecRestoreArray(da, user->
P, &p);
2928 DMDAVecRestoreArray(da, user->
Nvert, &nvert);
2939 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2940 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
2942 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
2943 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
2945 DMGlobalToLocalBegin(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2946 DMGlobalToLocalEnd(da, user->
Nvert, INSERT_VALUES, user->
lNvert);
2952 DMDAVecGetArray(fda, user->
Ucat, &ucat);
2953 DMDAVecGetArray(fda, user->
Ucont, &ucont);
2954 DMDAVecGetArray(fda, user->
Cent, ¢);
2955 DMDAVecGetArray(fda, user->
Centx, ¢x);
2956 DMDAVecGetArray(fda, user->
Centy, ¢y);
2957 DMDAVecGetArray(fda, user->
Centz, ¢z);
2959 if (user->
bctype[0]==9) {
2962 for (k=lzs; k<lze; k++) {
2963 for (j=lys; j<lye; j++) {
2964 ucat[k][j][i].
x=-cos(cent[k][j][i+1].x)*sin(cent[k][j][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2965 ucat[k][j][i].
y=-sin(cent[k][j][i+1].x)*cos(cent[k][j][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2966 ucat[k][j][i].
z =0.0;
2968 ucont[k][j][i].
x =-(cos(centx[k][j][i].x)*sin(centx[k][j][i].y)*csi[k][j][i].
x)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2973 for (k=lzs; k<lze; k++) {
2974 ucat[k][j][i].
x=cos(cent[k][j+1][i+1].x)*sin(cent[k][j+1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2975 ucat[k][j][i].
y=-sin(cent[k][j+1][i+1].x)*cos(cent[k][j+1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2976 ucat[k][j][i].
z =0.0;
2981 for (k=lzs; k<lze; k++) {
2982 ucat[k][j][i].
x=cos(cent[k][j-1][i+1].x)*sin(cent[k][j-1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2983 ucat[k][j][i].
y=-sin(cent[k][j-1][i+1].x)*cos(cent[k][j-1][i+1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2984 ucat[k][j][i].
z =0.0;
2989 if (user->
bctype[1]==9) {
2992 for (k=lzs; k<lze; k++) {
2993 for (j=lys; j<lye; j++) {
2994 ucat[k][j][i].
x=-cos(cent[k][j][i-1].x)*sin(cent[k][j][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2995 ucat[k][j][i].
y=-sin(cent[k][j][i-1].x)*cos(cent[k][j][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
2996 ucat[k][j][i].
z =0.0;
2998 ucont[k][j][i-1].
x =(-cos(centx[k][j][i-1].x)*sin(centx[k][j][i-1].y)*csi[k][j][i-1].
x)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3003 for (k=lzs; k<lze; k++) {
3004 ucat[k][j][i].
x=cos(cent[k][j+1][i-1].x)*sin(cent[k][j+1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3005 ucat[k][j][i].
y=-sin(cent[k][j+1][i-1].x)*cos(cent[k][j+1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3006 ucat[k][j][i].
z =0.0;
3011 for (k=lzs; k<lze; k++) {
3012 ucat[k][j][i].
x=cos(cent[k][j-1][i-1].x)*sin(cent[k][j-1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3013 ucat[k][j][i].
y=-sin(cent[k][j-1][i-1].x)*cos(cent[k][j-1][i-1].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3014 ucat[k][j][i].
z =0.0;
3020 if (user->
bctype[2]==9) {
3023 for (k=lzs; k<lze; k++) {
3024 for (i=lxs; i<lxe; i++) {
3025 ucat[k][j][i].
x=cos(cent[k][j+1][i].x)*sin(cent[k][j+1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3026 ucat[k][j][i].
y=sin(cent[k][j+1][i].x)*cos(cent[k][j+1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3027 ucat[k][j][i].
z =0.0;
3029 ucont[k][j][i].
y=(sin(centy[k][j][i].x)*cos(centy[k][j][i].y)*eta[k][j][i].
y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3036 if (user->
bctype[3]==9) {
3039 for (k=lzs; k<lze; k++) {
3040 for (i=lxs; i<lxe; i++) {
3041 ucat[k][j][i].
x=cos(cent[k][j-1][i].x)*sin(cent[k][j-1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3042 ucat[k][j][i].
y=sin(cent[k][j-1][i].x)*cos(cent[k][j-1][i].y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3043 ucat[k][j][i].
z =0.0;
3045 ucont[k][j-1][i].
y=(sin(centy[k][j-1][i].x)*cos(centy[k][j-1][i].y)*eta[k][j-1][i].
y)*exp(-2.0*simCtx->
dt*(simCtx->
step+1)/simCtx->
ren);
3050 if (user->
bctype[4]==9) {
3053 for (j=ys; j<ye; j++) {
3054 for (i=xs; i<xe; i++) {
3055 ucat[k][j][i].
x=ucat[k+1][j][i].
x;
3056 ucat[k][j][i].
y=ucat[k+1][j][i].
y;
3057 ucat[k][j][i].
z=ucat[k+1][j][i].
z;
3059 ucont[k][j][i].
z=0.0;
3064 if (user->
bctype[5]==9) {
3067 for (j=ys; j<ye; j++) {
3068 for (i=xs; i<xe; i++) {
3069 ucat[k][j][i].
x=ucat[k-1][j][i].
x;
3070 ucat[k][j][i].
y=ucat[k-1][j][i].
y;
3071 ucat[k][j][i].
z=ucat[k-1][j][i].
z;
3073 ucont[k-1][j][i].
z=0.0;
3079 DMDAVecRestoreArray(fda, user->
Cent, ¢);
3080 DMDAVecRestoreArray(fda, user->
Centx, ¢x);
3081 DMDAVecRestoreArray(fda, user->
Centy, ¢y);
3082 DMDAVecRestoreArray(fda, user->
Centz, ¢z);
3084 DMDAVecRestoreArray(fda, user->
Ucat, &ucat);
3085 DMDAVecRestoreArray(fda, user->
Ucont, &ucont);
3090 DMDAVecRestoreArray(fda, user->
Bcs.
Ubcs, &ubcs);
3091 DMDAVecRestoreArray(fda, user->
lCsi, &csi);
3092 DMDAVecRestoreArray(fda, user->
lEta, &eta);
3093 DMDAVecRestoreArray(fda, user->
lZet, &zet);
3095 DMGlobalToLocalBegin(da, user->
P, INSERT_VALUES, user->
lP);
3096 DMGlobalToLocalEnd(da, user->
P, INSERT_VALUES, user->
lP);
3097 DMGlobalToLocalBegin(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
3098 DMGlobalToLocalEnd(fda, user->
Ucat, INSERT_VALUES, user->
lUcat);
3099 DMGlobalToLocalBegin(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);
3100 DMGlobalToLocalEnd(fda, user->
Ucont, INSERT_VALUES, user->
lUcont);