File: ff2.c.html

package info (click to toggle)
petsc 3.1.dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 131,360 kB
  • ctags: 491,710
  • sloc: ansic: 288,064; cpp: 66,909; python: 28,799; fortran: 19,153; makefile: 13,945; sh: 3,502; f90: 1,655; xml: 620; csh: 230; java: 13
file content (124 lines) | stat: -rw-r--r-- 8,664 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
<center><a href="ff2.c">Actual source code: ff2.c</a></center><br>

<html>
<head>
<title></title>
<meta name="generator" content="c2html 0.9.5">
<meta name="date" content="2010-04-08T19:58:02+00:00">
</head>

<body bgcolor="#FFFFFF">
<pre width="80"><a name="line1">  1: </a><font color="#A020F0">#include </font><font color="#666666">"mp.h"</font><font color="#A020F0"></font>
<a name="line2">  2: </a><font color="#B22222">/*</font>
<a name="line3">  3: </a><font color="#B22222">         Defines the tempature physics for a given u, v, omega</font>
<a name="line4">  4: </a><font color="#B22222">*/</font>

<a name="line8">  8: </a><strong><font color="#4169E1"><a name="FormInitialGuessLocal2"></a><A href="tutorials/../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> FormInitialGuessLocal2(<A href="tutorials/../../docs/manualpages/DA/DALocalInfo.html#DALocalInfo">DALocalInfo</A> *info,Field2 **x,AppCtx *user)</font></strong>
<a name="line9">  9: </a>{
<a name="line10"> 10: </a>  <A href="tutorials/../../docs/manualpages/Sys/PetscInt.html#PetscInt">PetscInt</A>       i,j;
<a name="line11"> 11: </a>  <A href="tutorials/../../docs/manualpages/Sys/PetscScalar.html#PetscScalar">PetscScalar</A>    dx;

<a name="line13"> 13: </a>  dx  = 1.0/(info-&gt;mx-1);
<a name="line14"> 14: </a>  <font color="#4169E1">for</font> (j=info-&gt;ys; j&lt;info-&gt;ys+info-&gt;ym; j++) {
<a name="line15"> 15: </a>    <font color="#4169E1">for</font> (i=info-&gt;xs; i&lt;info-&gt;xs+info-&gt;xm; i++) {
<a name="line16"> 16: </a>      x[j][i].temp  = .1 + ((<A href="tutorials/../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>)(user-&gt;grashof&gt;0))*i*dx;
<a name="line17"> 17: </a>    }
<a name="line18"> 18: </a>  }
<a name="line19"> 19: </a>  <font color="#4169E1">return</font> 0;
<a name="line20"> 20: </a>}

<a name="line22"> 22: </a><A href="tutorials/../../docs/manualpages/Sys/PetscLogEvent.html#PetscLogEvent">PetscLogEvent</A> EVENT_FORMFUNCTIONLOCAL2;

<a name="line26"> 26: </a><font color="#B22222">/* </font>
<a name="line27"> 27: </a><font color="#B22222">      </font>
<a name="line28"> 28: </a><font color="#B22222">     x1 contains given velocity field</font>

<a name="line30"> 30: </a><font color="#B22222">*/</font>
<a name="line31"> 31: </a><strong><font color="#4169E1"><a name="FormFunctionLocal2"></a><A href="tutorials/../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> FormFunctionLocal2(<A href="tutorials/../../docs/manualpages/DA/DALocalInfo.html#DALocalInfo">DALocalInfo</A> *info,Field1**x1,Field2 **x,Field2 **f,void *ptr)</font></strong>
<a name="line32"> 32: </a> {
<a name="line33"> 33: </a>  AppCtx         *user = (AppCtx*)ptr;
<a name="line34"> 34: </a>  <A href="tutorials/../../docs/manualpages/Sys/PetscInt.html#PetscInt">PetscInt</A>       xints,xinte,yints,yinte,i,j;
<a name="line35"> 35: </a>  <A href="tutorials/../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>      hx,hy,dhx,dhy,hxdhy,hydhx;
<a name="line36"> 36: </a>  <A href="tutorials/../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>      grashof,prandtl,lid;
<a name="line37"> 37: </a>  <A href="tutorials/../../docs/manualpages/Sys/PetscScalar.html#PetscScalar">PetscScalar</A>    u,uxx,uyy,vx,vy,avx,avy,vxp,vxm,vyp,vym;

<a name="line41"> 41: </a>  <A href="tutorials/../../docs/manualpages/Profiling/PetscLogEventBegin.html#PetscLogEventBegin">PetscLogEventBegin</A>(EVENT_FORMFUNCTIONLOCAL2,0,0,0,0);
<a name="line42"> 42: </a>  grashof = user-&gt;grashof;
<a name="line43"> 43: </a>  prandtl = user-&gt;prandtl;
<a name="line44"> 44: </a>  lid     = user-&gt;lidvelocity;

<a name="line46"> 46: </a>  dhx = (<A href="tutorials/../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>)(info-&gt;mx-1);  dhy = (<A href="tutorials/../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>)(info-&gt;my-1);
<a name="line47"> 47: </a>  hx = 1.0/dhx;                   hy = 1.0/dhy;
<a name="line48"> 48: </a>  hxdhy = hx*dhy;                 hydhx = hy*dhx;

<a name="line50"> 50: </a>  xints = info-&gt;xs; xinte = info-&gt;xs+info-&gt;xm; yints = info-&gt;ys; yinte = info-&gt;ys+info-&gt;ym;

<a name="line52"> 52: </a>  <font color="#B22222">/* Test whether we are on the bottom edge of the global array */</font>
<a name="line53"> 53: </a>  <font color="#4169E1">if</font> (yints == 0) {
<a name="line54"> 54: </a>    j = 0;
<a name="line55"> 55: </a>    yints = yints + 1;
<a name="line56"> 56: </a>    <font color="#B22222">/* bottom edge */</font>
<a name="line57"> 57: </a>    <font color="#4169E1">for</font> (i=info-&gt;xs; i&lt;info-&gt;xs+info-&gt;xm; i++) {
<a name="line58"> 58: </a>      f[j][i].temp  = x[j][i].temp-x[j+1][i].temp;
<a name="line59"> 59: </a>    }
<a name="line60"> 60: </a>  }

<a name="line62"> 62: </a>  <font color="#B22222">/* Test whether we are on the top edge of the global array */</font>
<a name="line63"> 63: </a>  <font color="#4169E1">if</font> (yinte == info-&gt;my) {
<a name="line64"> 64: </a>    j = info-&gt;my - 1;
<a name="line65"> 65: </a>    yinte = yinte - 1;
<a name="line66"> 66: </a>    <font color="#B22222">/* top edge */</font>
<a name="line67"> 67: </a>    <font color="#4169E1">for</font> (i=info-&gt;xs; i&lt;info-&gt;xs+info-&gt;xm; i++) {
<a name="line68"> 68: </a>      f[j][i].temp  = x[j][i].temp-x[j-1][i].temp;
<a name="line69"> 69: </a>    }
<a name="line70"> 70: </a>  }

<a name="line72"> 72: </a>  <font color="#B22222">/* Test whether we are on the left edge of the global array */</font>
<a name="line73"> 73: </a>  <font color="#4169E1">if</font> (xints == 0) {
<a name="line74"> 74: </a>    i = 0;
<a name="line75"> 75: </a>    xints = xints + 1;
<a name="line76"> 76: </a>    <font color="#B22222">/* left edge */</font>
<a name="line77"> 77: </a>    <font color="#4169E1">for</font> (j=info-&gt;ys; j&lt;info-&gt;ys+info-&gt;ym; j++) {
<a name="line78"> 78: </a>      f[j][i].temp  = x[j][i].temp;
<a name="line79"> 79: </a>    }
<a name="line80"> 80: </a>  }

<a name="line82"> 82: </a>  <font color="#B22222">/* Test whether we are on the right edge of the global array */</font>
<a name="line83"> 83: </a>  <font color="#4169E1">if</font> (xinte == info-&gt;mx) {
<a name="line84"> 84: </a>    i = info-&gt;mx - 1;
<a name="line85"> 85: </a>    xinte = xinte - 1;
<a name="line86"> 86: </a>    <font color="#B22222">/* right edge */</font>
<a name="line87"> 87: </a>    <font color="#4169E1">for</font> (j=info-&gt;ys; j&lt;info-&gt;ys+info-&gt;ym; j++) {
<a name="line88"> 88: </a>      f[j][i].temp  = x[j][i].temp - (<A href="tutorials/../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>)(grashof&gt;0);
<a name="line89"> 89: </a>    }
<a name="line90"> 90: </a>  }

<a name="line92"> 92: </a>  <font color="#B22222">/* Compute over the interior points */</font>
<a name="line93"> 93: </a>  <font color="#4169E1">for</font> (j=yints; j&lt;yinte; j++) {
<a name="line94"> 94: </a>    <font color="#4169E1">for</font> (i=xints; i&lt;xinte; i++) {
<a name="line95"> 95: </a>      <font color="#B22222">/* convective coefficients for upwinding */</font>
<a name="line96"> 96: </a>      <font color="#4169E1">if</font> (x1) {
<a name="line97"> 97: </a>        vx = x1[j][i].u; vy = x1[j][i].v;
<a name="line98"> 98: </a>      } <font color="#4169E1">else</font> {
<a name="line99"> 99: </a>        vx = vy = 0;
<a name="line100">100: </a>      }
<a name="line101">101: </a>      avx = PetscAbsScalar(vx);
<a name="line102">102: </a>      vxp = .5*(vx+avx); vxm = .5*(vx-avx);
<a name="line103">103: </a>      avy = PetscAbsScalar(vy);
<a name="line104">104: </a>      vyp = .5*(vy+avy);
<a name="line105">105: </a>      vym = .5*(vy-avy);

<a name="line107">107: </a>      <font color="#B22222">/* Temperature */</font>
<a name="line108">108: </a>      u             = x[j][i].temp;
<a name="line109">109: </a>      uxx           = (2.0*u - x[j][i-1].temp - x[j][i+1].temp)*hydhx;
<a name="line110">110: </a>      uyy           = (2.0*u - x[j-1][i].temp - x[j+1][i].temp)*hxdhy;
<a name="line111">111: </a>      f[j][i].temp  =  uxx + uyy + prandtl * ((vxp*(u - x[j][i-1].temp) + vxm*(x[j][i+1].temp - u))*hy + (vyp*(u - x[j-1][i].temp) + vym*(x[j+1][i].temp - u))*hx);
<a name="line112">112: </a>    }
<a name="line113">113: </a>  }
<a name="line114">114: </a>  <A href="tutorials/../../docs/manualpages/Profiling/PetscLogEventEnd.html#PetscLogEventEnd">PetscLogEventEnd</A>(EVENT_FORMFUNCTIONLOCAL2,0,0,0,0);
<a name="line115">115: </a>  <font color="#4169E1">return</font>(0);
<a name="line116">116: </a>}
</pre>
</body>

</html>