ParMooN
 All Classes Functions Variables Friends Pages
Sin4.h
1 // ==========================================================================
2 // instationary problem
3 // ==========================================================================
4 
5 //===========================================================================
6 // example file
7 // =========================================================================
8 #define __SIN4__
9 
10 void ExampleFile()
11 {
12  OutPut("Example: Sin4.h" << endl);
13 }
14 
15 // exact solution
16 void Exact(double x, double y, double z, double *values)
17 {
18  double t;
19 
20  t = TDatabase::TimeDB->CURRENTTIME;
21  values[0] = sin(t)*(sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)+1);
22  values[1] = sin(t)*2*Pi*(cos(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z));
23  values[2] = sin(t)*2*Pi*(sin(2*Pi*x)*cos(2*Pi*y)*sin(2*Pi*z));
24  values[3] = sin(t)*2*Pi*(sin(2*Pi*x)*sin(2*Pi*y)*cos(2*Pi*z));
25  values[4] = sin(t)*4*Pi*Pi*(-sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)
26  -sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)
27  -sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z));
28 }
29 
30 // initial conditon
31 void InitialCondition(double x, double y, double z, double *values)
32 {
33  values[0] = 0;
34 }
35 
36 // kind of boundary condition
37 void BoundCondition(double x, double y, double z, BoundCond &cond)
38 {
39  if (TDatabase::ParamDB->SOLD_PARAMETER_TYPE== FEM_FCT)
40  cond = NEUMANN;
41  else
42  cond = DIRICHLET;
43 }
44 
45 // value of boundary condition
46 void BoundValue(double x, double y, double z, double &value)
47 {
48  double t;
49 
50  t = TDatabase::TimeDB->CURRENTTIME;
51  value = sin(t);
52 }
53 
54 void BilinearCoeffs(int n_points, double *X, double *Y, double *Z,
55  double **parameters, double **coeffs)
56 {
57  double eps = 1.0/TDatabase::ParamDB->RE_NR;
58  int i;
59  double *coeff; // *param;
60  double x, y, z, c, a[3], b[3], s[3], h;
61  double t = TDatabase::TimeDB->CURRENTTIME;
62 
63  b[0] = 1;
64  b[1] = 1;
65  b[2] = 1;
66  c = 0;
67 
68  for(i=0;i<n_points;i++)
69  {
70  coeff = coeffs[i];
71  // param = parameters[i];
72 
73  x = X[i];
74  y = Y[i];
75  z = Z[i];
76 
77  // diffusion
78  coeff[0] = eps;
79  // convection in x direction
80  coeff[1] = b[0];
81  // convection in y direction
82  coeff[2] = b[1];
83  // convection in z direction
84  coeff[3] = b[2];
85  // reaction
86  coeff[4] = c;
87  // rhs
88  coeff[5] = cos(t)*(sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)+1)
89  -coeff[0] * (sin(t)*4*Pi*Pi*(-sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)
90  -sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)
91  -sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)))
92  +coeff[1] * sin(t)*2*Pi*(cos(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z))
93  +coeff[2] * sin(t)*2*Pi*(sin(2*Pi*x)*cos(2*Pi*y)*sin(2*Pi*z))
94  +coeff[3] * sin(t)*2*Pi*(sin(2*Pi*x)*sin(2*Pi*y)*cos(2*Pi*z))
95  +coeff[4] * sin(t)*(sin(2*Pi*x)*sin(2*Pi*y)*sin(2*Pi*z)+1);
96  // rhs from previous time step
97  coeff[6] = 0;
98  }
99 }
100 
101 /****************************************************************/
102 //
103 // for FEM_TVD
104 //
105 /****************************************************************/
106 void CheckWrongNeumannNodes(TCollection *Coll, TFESpace3D *fespace,
107 int &N_neum_to_diri, int* &neum_to_diri,
108  double* &neum_to_diri_x, double* &neum_to_diri_y, double* &neum_to_diri_z)
109 {
110  const int max_entries = 50000;
111  int i, j, N_, min_val;
112  int N_Cells, N_V, diri_counter = 0, found, diri_counter_1 = 0;
113  int *global_numbers, *begin_index, *dof;
114  int boundary_vertices[8], tmp_diri[max_entries];
115  double x[8], y[8], z[8], eps = 1e-6, tmp_x[max_entries], tmp_y[max_entries], tmp_z[max_entries];
116  TBaseCell *cell;
117  TVertex *vertex;
118  FE3D CurrentElement;
119 
120  // number of mesh cells
121  N_Cells = Coll->GetN_Cells();
122  // array with global numbers of d.o.f.
123  global_numbers = fespace->GetGlobalNumbers();
124  // array which points to the beginning of the global numbers in
125  // global_numbers for each mesh cell
126  begin_index = fespace->GetBeginIndex();
127 
128  diri_counter = 0;
129  for(i=0;i<N_Cells;i++)
130  {
131  cell = Coll->GetCell(i);
132  N_V = cell->GetN_Vertices();
133  found = 0;
134  for (j=0;j<N_V;j++)
135  {
136  // read coordinates of the mesh cell
137  boundary_vertices[j] = 0;
138  vertex = cell->GetVertex(j);
139  vertex->GetCoords(x[j], y[j], z[j]);
140  // vertex on the upper lid
141  if ((fabs(x[j])<eps)||(fabs(y[j])<eps)||(fabs(x[j]-1)<eps)||(fabs(y[j]-1)<eps)
142  ||(fabs(z[j])<eps)||(fabs(z[j]-1)<eps))
143  {
144  // Dirichlet boundary
145  boundary_vertices[j] = 1;
146  found++;
147  }
148  }
149 
150  // no cell with face with vertex on the boundary
151  if (found<3)
152  continue;
153  // finite element on the mesh cell
154  CurrentElement = fespace->GetFE3D(i, cell);
155  // number of basis functions (= number of d.o.f.)
156  N_ = TFEDatabase3D::GetN_BaseFunctFromFE3D(CurrentElement);
157  // the array which gives the mapping of the local to the global d.o.f.
158  dof = global_numbers+begin_index[i];
159  switch(CurrentElement)
160  {
161  // P_1, Q_1
162  case C_P1_3D_T_A:
163  case C_Q1_3D_H_A:
164  case C_Q1_3D_H_M:
165  for (j=0;j<N_V;j++)
166  {
167  // vertex on the boundary
168  if (boundary_vertices[j])
169  {
170  if (CurrentElement==C_P1_3D_T_A)
171  tmp_diri[diri_counter] = dof[j];
172  else
173  {
174  if ((j==0)||(j==1)||(j==4)||(j==5))
175  {
176  tmp_diri[diri_counter] = dof[j];
177  }
178  else
179  {
180  if (j==2)
181  tmp_diri[diri_counter] = dof[3];
182  if (j==3)
183  tmp_diri[diri_counter] = dof[2];
184  if (j==6)
185  tmp_diri[diri_counter] = dof[7];
186  if (j==7)
187  tmp_diri[diri_counter] = dof[6];
188  }
189  }
190  if (diri_counter > max_entries)
191  {
192  OutPut("tmp_diri too short !!!"<<endl);
193  exit(4711);
194  }
195  tmp_x[diri_counter] = x[j];
196  tmp_y[diri_counter] = y[j];
197  tmp_z[diri_counter] = z[j];
198  diri_counter++;
199  OutPut(j<< " " << tmp_x[diri_counter-1] << " " << x[j] << endl);
200  }
201  }
202  break;
203  default:
204  OutPut("CheckNeumannNodesForVelocity not implemented for element "
205  << CurrentElement << endl);
206  OutPut("code can be run without CheckNeumannNodesForVelocity, just delete the exit" << endl);
207  exit(4711);
208  }
209  }
210 
211  // condense
212  for (i=0;i<diri_counter;i++)
213  {
214  if (tmp_diri[i] == -1)
215  continue;
216  diri_counter_1++;
217  for (j=i+1;j<diri_counter;j++)
218  {
219  if (tmp_diri[i] == tmp_diri[j])
220  {
221  tmp_diri[j] = -1;
222  }
223  }
224  }
225 
226  OutPut("CheckNeumannNodesForVelocity: N_neum_to_diri " << diri_counter_1 << endl);
227  N_neum_to_diri = diri_counter_1;
228  // allocate array for the indices
229  neum_to_diri = new int[diri_counter_1];
230  // allocate array for the corresponding boundary coordinates
231  neum_to_diri_x = new double[diri_counter_1];
232  neum_to_diri_y = new double[diri_counter_1];
233  neum_to_diri_z = new double[diri_counter_1];
234  // fill array and sort
235  for (i=0;i<diri_counter_1;i++)
236  {
237  min_val = tmp_diri[0];
238  found = 0;
239  for (j=1;j<diri_counter;j++)
240  {
241  if ((tmp_diri[j]>0) && ((tmp_diri[j] < min_val) ||
242  (min_val == -1)))
243  {
244  min_val = tmp_diri[j];
245  found = j;
246  }
247  }
248  neum_to_diri[i] = tmp_diri[found];
249  neum_to_diri_x[i] = tmp_x[found];
250  neum_to_diri_y[i] = tmp_y[found];
251  neum_to_diri_z[i] = tmp_z[found];
252  tmp_diri[found] = -1;
253  }
254 
255  for (i=0;i<diri_counter_1;i++)
256  {
257  OutPut(i << " " << neum_to_diri[i] << " " << neum_to_diri_x[i] <<
258  " " << neum_to_diri_y[i] << " " << neum_to_diri_z[i] << endl);
259  }
260 }
261 
262 
FE3D GetFE3D(int i, TBaseCell *cell)
Definition: FESpace3D.C:412
TBaseCell * GetCell(int i) const
return Cell with index i in Cells-array
Definition: Collection.h:50
static int * GetN_BaseFunctFromFE3D()
Definition: FEDatabase3D.h:369
static TTimeDB * TimeDB
Definition: Database.h:1137
Definition: FESpace3D.h:22
double RE_NR
Definition: Database.h:313
store cells in an array, used by cell iterators
Definition: Collection.h:18
virtual TVertex * GetVertex(int Vert_i)=0
return the pointer to vertex with number i
int GetN_Cells() const
return number of cells
Definition: Collection.h:46
void GetCoords(double &x, double &y, double &z) const
Definition: Vertex.h:106
int GetN_Vertices()
return the number of vertices of the cell
Definition: BaseCell.h:179
information for finite element data structure
Definition: BaseCell.h:25
int * GetGlobalNumbers() const
Definition: FESpace.h:135
Definition: Vertex.h:19
int * GetBeginIndex() const
Definition: FESpace.h:142
static TParamDB * ParamDB
Definition: Database.h:1134