setiv.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // Copyright 2010 Intel Corporation
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include "applu_share.h"
  17. #include "applu_macros.h"
  18. #define ue_1jk(m) ue_1jk[m-1]
  19. #define ue_nx0jk(m) ue_nx0jk[m-1]
  20. #define ue_i1k(m) ue_i1k[m-1]
  21. #define ue_iny0k(m) ue_iny0k[m-1]
  22. #define ue_ij1(m) ue_ij1[m-1]
  23. #define ue_ijnz(m) ue_ijnz[m-1]
  24. void setiv() {
  25. //c---------------------------------------------------------------------
  26. //c
  27. //c set the initial values of independent variables based on tri-linear
  28. //c interpolation of boundary values in the computational space.
  29. //c
  30. //c---------------------------------------------------------------------
  31. //c---------------------------------------------------------------------
  32. //c local variables
  33. //c---------------------------------------------------------------------
  34. int i, j, k, m;
  35. int iglob, jglob;
  36. double xi, eta, zeta;
  37. double pxi, peta, pzeta;
  38. double ue_1jk[5],ue_nx0jk[5],ue_i1k[5],
  39. ue_iny0k[5],ue_ij1[5],ue_ijnz[5];
  40. int one = 1;
  41. for ( k = 2; k <= nz - 1; k++) {
  42. zeta = ( (double) (k-1) ) / (nz-1);
  43. for ( j = 1; j <= ny; j++) {
  44. jglob = jpt + j;
  45. if (jglob != 1 && jglob != ny0) {
  46. eta = ( (double) (jglob-1) ) / (ny0-1);
  47. for ( i = 1; i <= nx; i++) {
  48. iglob = ipt + i;
  49. if (iglob != 1 && iglob != nx0) {
  50. xi = ( (double) (iglob-1) ) / (nx0-1);
  51. exact(one,jglob,k,ue_1jk);
  52. exact(nx0,jglob,k,ue_nx0jk);
  53. exact(iglob,one,k,ue_i1k);
  54. exact(iglob,ny0,k,ue_iny0k);
  55. exact(iglob,jglob,one,ue_ij1);
  56. exact(iglob,jglob,nz,ue_ijnz);
  57. for ( m = 1; m <= 5; m++) {
  58. pxi = (1.0 - xi ) * ue_1jk(m) + xi * ue_nx0jk(m);
  59. peta = (1.0 - eta ) * ue_i1k(m) + eta * ue_iny0k(m);
  60. pzeta = (1.0 - zeta) * ue_ij1(m) + zeta * ue_ijnz(m);
  61. u( m, i, j, k ) = pxi + peta + pzeta
  62. - pxi * peta - peta * pzeta - pzeta * pxi
  63. + pxi * peta * pzeta;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. // for ( k = 1; k <= nz; k++) {
  71. // for ( j = -1; j <= ny+2; j++) {
  72. // for ( i = -1; i <= nx+2; i++) {
  73. // for ( m = 1; m <= 5; m++) {
  74. // u( m, i, j, k ) = (double) (id*100 + m);
  75. // }
  76. // }
  77. // }
  78. // }
  79. return;
  80. }