ParMooN
 All Classes Functions Variables Friends Pages
MinSurfVislovich.h
1 // =====================================================================
2 // for 2D part
3 // =====================================================================
4 // part for standard Galerkin
5 int N_Terms2d = 3;
6 MultiIndex2D Derivatives2d[3] = { D10, D01, D00 };
7 int SpacesNumbers2d[3] = { 0, 0, 0 };
8 int N_Matrices2d = 1;
9 int RowSpace2d[2] = { 0 };
10 int ColumnSpace2d[2] = { 0 };
11 int N_Rhs2d = 1;
12 int RhsSpace2d[1] = { 0 };
13 
14 MultiIndex2D AllDerivatives2d[3] = { D00, D10, D01 };
15 
16 void L2H1Errors2d(int N_Points, double *X, double *Y, double *AbsDetjk,
17  double *Weights, double hK,
18  double **Der, double **Exact,
19  double **coeffs, double *LocError)
20 {
21  int i;
22  double *deriv, *exactval, w, t;
23 
24  LocError[0] = 0.0;
25  LocError[1] = 0.0;
26 
27  for(i=0;i<N_Points;i++)
28  {
29  deriv = Der[i];
30  exactval = Exact[i];
31  w = Weights[i]*AbsDetjk[i];
32 
33  t = deriv[0]-exactval[0];
34  LocError[0] += w*t*t;
35 
36  t = deriv[1]-exactval[1];
37  LocError[1] += w*t*t;
38  t = deriv[2]-exactval[2];
39  LocError[1] += w*t*t;
40  } // endfor i
41 
42  // cout << "LocError[0]: " << LocError[0] << endl;
43  // cout << "LocError[1]: " << LocError[1] << endl;
44 }
45 
46 void BilinearAssemble2d(double Mult, double *coeff, double hK,
47  double **OrigValues, int *N_BaseFuncts,
48  double ***LocMatrices, double **LocRhs)
49 {
50  double **Matrix, *Rhs, val, *MatrixRow;
51  double ansatz00, ansatz10, ansatz01;
52  double test00, test10, test01;
53  double *Orig0, *Orig1, *Orig2;
54  int i,j, N_;
55  double c0, c1, c2, c3, c4;
56 
57  Matrix = LocMatrices[0];
58  Rhs = LocRhs[0];
59 
60  N_ = N_BaseFuncts[0];
61 
62  Orig0 = OrigValues[0];
63  Orig1 = OrigValues[1];
64  Orig2 = OrigValues[2];
65 
66  // coefficients
67  c0 = coeff[0]; // eps
68  c1 = coeff[1]; // b_1
69  c2 = coeff[2]; // b_2
70  c3 = coeff[3]; // c
71  c4 = coeff[4]; // f
72 
73  for(i=0;i<N_;i++)
74  {
75  MatrixRow = Matrix[i];
76  // test function
77  test10 = Orig0[i]; // xi derivative
78  test01 = Orig1[i]; // eta derivative
79  test00 = Orig2[i]; // function
80 
81  // assemble rhs
82  // quad_weigth * test_function * f
83  Rhs[i] += Mult*test00*c4;
84 
85  for(j=0;j<N_;j++)
86  {
87  ansatz10 = Orig0[j]; // xi derivative
88  ansatz01 = Orig1[j]; // eta derivative
89  ansatz00 = Orig2[j]; // function
90 
91  // assemble viscous term
92  // eps (test_x ansatz_x + test_y ansatz_y)
93  val = c0*(test10*ansatz10+test01*ansatz01);
94  // assemble convective term
95  // (b_1 ansatz_x + b_2 ansatz_y) test
96  val += (c1*ansatz10+c2*ansatz01)*test00;
97  // assembel reactive term
98  // c ansatz test
99  val += c3*ansatz00*test00;
100 
101  // quad weigth
102  val *= Mult;
103 
104  // update matrix entry
105  MatrixRow[j] += val;
106  } // endfor j
107  } // endfor i
108 }
109 
110 // exact solution
111 void Exact2d(double x, double y, double *values)
112 {
113  values[0] = sin(Pi*x)*sin(2*Pi*y);
114  values[1] = Pi*cos(Pi*x)*sin(2*Pi*y);
115  values[2] = 2*Pi*sin(Pi*x)*cos(2*Pi*y);
116  values[3] = 0;
117 }
118 
119 void ExactX(double x, double y, double *values)
120 {
121  values[0] = x;
122  values[1] = 1;
123  values[2] = 0;
124  values[3] = 0;
125 }
126 
127 void ExactY(double x, double y, double *values)
128 {
129  values[0] = y;
130  values[1] = 0;
131  values[2] = 1;
132  values[3] = 0;
133 }
134 
135 void Exact3D(double x, double y, double z, double *values)
136 {
137  values[0] = 4*x*y*z*z;
138  values[1] = 4*y*z*z;
139  values[2] = 4*x*z*z;
140  values[3] = 8*x*y*z;
141  values[4] = 0;
142 }
143 
144 // kind of boundary condition (for FE space needed)
145 void BoundCondition2d(int i, double t, BoundCond &cond)
146 {
147  cond = NEUMANN;
148 }
149 
150 // value of boundary condition
151 void BoundValue2d(int BdComp, double Param, double &value)
152 {
153  value = 0;
154 }
155 
156 void BilinearCoeffs2d(int n_points, double *x, double *y,
157  double **parameters, double **coeffs)
158 {
159  double eps=1/TDatabase::ParamDB->RE_NR;
160  int i;
161  double *coeff, *param;
162  static int first = 1;
163 
164  double phin;
165  double chi = TDatabase::ParamDB->P2 - 1;
166  double H0 = TDatabase::ParamDB->P4;
167  double a = TDatabase::ParamDB->P6;
168  double sigma = TDatabase::ParamDB->P7;
169  double g = TDatabase::ParamDB->P8;
170  double rho = TDatabase::ParamDB->P9;
171 
172  double lambda = a*sqrt(rho*g/sigma);
173  double Si = 4*Pi*0.1*chi*chi*H0*H0/(2*sqrt(sigma*g*rho));
174 
175  if(first)
176  {
177  OutPut("lambda: " << lambda << endl);
178  OutPut("Si: " << Si << endl);
179 
180  first = 0;
181  }
182 
183  for(i=0;i<n_points;i++)
184  {
185  coeff = coeffs[i];
186  param = parameters[i];
187 
188  coeff[0] = param[0];
189  coeff[1] = 0;
190  coeff[2] = 0;
191  coeff[3] = lambda*lambda;
192 
193  phin = param[2]*param[5] + param[3]*param[6] + param[4]*param[7];
194  coeff[4] = lambda*Si/chi*( param[2]*param[2] + param[3]*param[3]
195  +param[4]*param[4])
196  +lambda*Si * phin*phin;
197  }
198 }
199 
200 // for nonlinear magnetisation law
201 void BilinearCoeffs2dNL(int n_points, double *x, double *y,
202  double **parameters, double **coeffs)
203 {
204  const double Lhalf = 1.796755984723713041136085;
205 
206  double eps=1/TDatabase::ParamDB->RE_NR;
207  int i;
208  double *coeff, *param;
209  static int first = 1;
210 
211  double phin, Im, H, L, arg;
212 
213  double chi = TDatabase::ParamDB->P2 - 1;
214  double H0 = TDatabase::ParamDB->P4;
215  double Ms = TDatabase::ParamDB->P5;
216  double a = TDatabase::ParamDB->P6;
217  double sigma = TDatabase::ParamDB->P7;
218  double g = TDatabase::ParamDB->P8;
219  double rho = TDatabase::ParamDB->P9;
220 
221  double gamma = 3*chi*H0/Ms;
222 
223  double lambda = a*sqrt(rho*g/sigma);
224  double Si = 4*Pi*0.1*Ms*Ms/(3*chi*sqrt(sigma*g*rho));
225 
226  static double HT = Ms/H0 * Lhalf / (3*chi);
227 
228  if(first)
229  {
230  OutPut("lambda: " << lambda << endl);
231  OutPut("Si: " << Si << endl);
232  OutPut("gamma: " << gamma << endl);
233 
234  first = 0;
235  }
236 
237  for(i=0;i<n_points;i++)
238  {
239  coeff = coeffs[i];
240  param = parameters[i];
241 
242  coeff[0] = param[0];
243  coeff[1] = 0;
244  coeff[2] = 0;
245  coeff[3] = lambda*lambda;
246 
247  H = sqrt(param[2]*param[2] + param[3]*param[3] + param[4]*param[4]);
248  arg = gamma*H;
249  Im = log( sinh(arg) / arg );
250 
251  L = 1/tanh(arg) - 1/arg;
252 
253  phin = (param[2]*param[5] + param[3]*param[6] + param[4]*param[7])/H;
254 
255  coeff[4] = 4*Pi*0.1*a/sigma
256  *Ms * ( H0*(H-HT*log((H+HT)/HT) )
257  + Ms*0.5*(H/(H+HT))*(H/(H+HT))*phin*phin );
258  }
259 }
260 // =====================================================================
261 // for 2D part (END)
262 // =====================================================================
263 
264 // Only the fe values are correct, the 3d parameters can be only used
265 // in the bilinearcoeff subroutine
266 void MinSurfParams(double *in, double *out)
267 {
268  double n1, n2, n3;
269  out[0] = 1/sqrt(1+in[2]*in[2]+in[3]*in[3]); // 1/sqrt(1+|grad u|^2)
270 }
271 
272 int N_FESpaceMS = 1;
273 int N_FEFunctionsMS = 1;
274 int N_ParamFctMS = 1;
275 int N_FEValuesMS = 2;
276 int FEValuesFctIndexMS[2] = { 0, 0 };
277 MultiIndex2D FEValuesMultiIndexMS[2] = { D10, D01 };
278 int N_ParametersMS = 1;
279 int BeginParameterMS[1] = { 0 };
280 ParamFct *ParameterFctMS[1] = { MinSurfParams };
281 
282 // generate undisturbed interface at z = height/2
283 void UnDisturbed(double x, double y, double *values)
284 {
285  static double middle = 0.5*TDatabase::ParamDB->DRIFT_Z;
286 
287  values[0] = middle;
288  values[1] = 0;
289  values[2] = 0;
290  values[3] = 0;
291 }
292 
double RE_NR
Definition: Database.h:313
static TParamDB * ParamDB
Definition: Database.h:1134