8 OutPut(
"Example: Hemker1996.h" << endl) ;
12 void Exact(
double x,
double y,
double *values)
20 void BoundCondition(
int BdComp,
double t, BoundCond &cond)
36 void BoundValue(
int BdComp,
double Param,
double &value)
52 void InitialCondition(
double x,
double y,
double *values)
57 void BoundConditionAdjoint(
int BdComp,
double t, BoundCond &cond)
73 void BoundValueAdjoint(
int BdComp,
double Param,
double &value)
78 void BilinearCoeffs(
int n_points,
double *x,
double *y,
79 double **parameters,
double **coeffs)
82 double angle = 0, v1, v2;
89 for(i=0;i<n_points;i++)
102 void ComputeExtremalValues(
int N,
double *sol,
double *values)
125 double h, x=4,values[3],y;
126 int i, bound_points = 401;
127 h = 6.0/(bound_points-1);
128 for (i=0;i<bound_points; i++)
132 OutPut(
"cutline " << x <<
" " << y <<
133 " " << values[0] << endl);
147 void ComputeLocalExtrema(
TFEFunction2D *ufct,
double *values)
158 double *uorig, *uxorig, *uyorig, *uref, *uxiref, *uetaref, u;
159 double *Values, x, y, val;
160 int *GlobalNumbers, *BeginIndex, N_Cells, N_Edges;
161 int i, j, k, *Numbers;
178 for(i=0;i<N_Cells;i++)
184 FE_ID = FESpace2D->
GetFE2D(i, cell);
192 uorig =
new double[N_BaseFunct];
193 uxorig =
new double[N_BaseFunct];
194 uyorig =
new double[N_BaseFunct];
196 uref =
new double[N_BaseFunct];
197 uxiref =
new double[N_BaseFunct];
198 uetaref =
new double[N_BaseFunct];
202 for (j=0;j<N_Edges;j++)
221 uref, uxiref, uetaref, uorig, uxorig, uyorig);
224 Numbers = GlobalNumbers + BeginIndex[i];
225 for(k=0;k<N_BaseFunct;k++)
227 val = Values[Numbers[k]];
232 if ((x>-1.5)&&(x<1.5))
234 if ((u<=0)&&(fabs(u)>extr[0]))
236 if ((u>=1)&&(fabs(u-1)>extr[1]))
241 if ((u<=0)&&(fabs(u)>extr[2]))
243 if ((u>=1)&&(fabs(u-1)>extr[3]))
269 int &N_neum_to_diri,
int* &neum_to_diri,
270 int* &neum_to_diri_bdry,
271 double* &neum_to_diri_param)
273 const int max_entries = 50000;
274 int i, j, min_val, type;
275 int N_Cells, N_V, diri_counter = 0, found, diri_counter_1 = 0;
276 int *global_numbers, *begin_index, *dof;
277 int boundary_vertices[4], tmp_diri[max_entries], tmp_bdry[max_entries];
278 double x[4], y[4], eps = 1e-6, tmp_param[max_entries];
292 for(i=0;i<N_Cells;i++)
300 boundary_vertices[j] = 0;
303 if ((fabs(x[j]+3)<eps)
304 || (fabs(sqrt(x[j]*x[j]+y[j]*y[j])-1)<eps))
306 boundary_vertices[j] = 1;
314 CurrentElement = fespace->
GetFE2D(i, cell);
318 dof = global_numbers+begin_index[i];
319 switch(CurrentElement)
328 if (boundary_vertices[j])
330 if (CurrentElement==C_P1_2D_T_A)
331 tmp_diri[diri_counter] = dof[j];
335 tmp_diri[diri_counter] = dof[j];
340 tmp_diri[diri_counter] = dof[3];
342 tmp_diri[diri_counter] = dof[2];
345 if (diri_counter > max_entries)
347 OutPut(
"tmp_diri too short !!!"<<endl);
351 if (fabs(x[j]+3)<eps)
353 tmp_bdry[diri_counter] = 3;
354 tmp_param[diri_counter] = (-y[j]+3)/6.0;
357 if (fabs(sqrt(x[j]*x[j]+y[j]*y[j])-1)<eps)
359 tmp_bdry[diri_counter] = 4;
361 tmp_param[diri_counter] = 0;
375 if (boundary_vertices[j] && boundary_vertices[(j+1)%N_V])
379 if (!((type == BoundaryEdge)||(type == IsoBoundEdge)))
384 tmp_diri[diri_counter] = dof[0];
385 tmp_diri[diri_counter+1] = dof[1];
386 tmp_diri[diri_counter+2] = dof[2];
391 tmp_diri[diri_counter] = dof[2];
392 tmp_diri[diri_counter+1] = dof[4];
393 tmp_diri[diri_counter+2] = dof[5];
397 tmp_diri[diri_counter] = dof[2];
398 tmp_diri[diri_counter+1] = dof[5];
399 tmp_diri[diri_counter+2] = dof[8];
405 tmp_diri[diri_counter] = dof[5];
406 tmp_diri[diri_counter+1] = dof[3];
407 tmp_diri[diri_counter+2] = dof[0];
411 tmp_diri[diri_counter] = dof[8];
412 tmp_diri[diri_counter+1] = dof[7];
413 tmp_diri[diri_counter+2] = dof[6];
417 tmp_diri[diri_counter] = dof[6];
418 tmp_diri[diri_counter+1] = dof[3];
419 tmp_diri[diri_counter+2] = dof[0];
424 if (diri_counter+2 > max_entries)
426 OutPut(
"tmp_diri too short !!!"<<endl);
431 if ((fabs(x[j]+3)<eps)&&(fabs(x[(j+1)%N_V]+3)<eps))
433 tmp_bdry[diri_counter] = 3;
434 tmp_bdry[diri_counter+1] = 3;
435 tmp_bdry[diri_counter+2] = 3;
436 tmp_param[diri_counter] = (-y[j]+3)/6.0;
437 tmp_param[diri_counter+2] = (-y[(j+1)%N_V]+3)/6.0;
438 tmp_param[diri_counter+1] = (tmp_param[diri_counter] + tmp_param[diri_counter+2])/2.0;
441 if ((fabs(sqrt(x[j]*x[j]+y[j]*y[j])-1)<eps) &&
442 (fabs(sqrt(x[(j+1)%N_V]*x[(j+1)%N_V]+y[(j+1)%N_V]*y[(j+1)%N_V])-1)<eps))
444 tmp_bdry[diri_counter] = 4;
445 tmp_bdry[diri_counter+1] = 4;
446 tmp_bdry[diri_counter+2] = 4;
448 tmp_param[diri_counter] = 0;
449 tmp_param[diri_counter+1] = 0;
450 tmp_param[diri_counter+2] = 0;
464 if (boundary_vertices[j] && boundary_vertices[(j+1)%N_V])
468 if (!((type == BoundaryEdge)||(type == IsoBoundEdge)))
476 tmp_diri[diri_counter] = dof[0];
477 tmp_diri[diri_counter+1] = dof[1];
478 tmp_diri[diri_counter+2] = dof[2];
479 tmp_diri[diri_counter+3] = dof[3];
484 tmp_diri[diri_counter] = dof[3];
485 tmp_diri[diri_counter+1] = dof[6];
486 tmp_diri[diri_counter+2] = dof[8];
487 tmp_diri[diri_counter+3] = dof[9];
491 tmp_diri[diri_counter] = dof[3];
492 tmp_diri[diri_counter+1] = dof[7];
493 tmp_diri[diri_counter+2] = dof[11];
494 tmp_diri[diri_counter+3] = dof[15];
500 tmp_diri[diri_counter] = dof[9];
501 tmp_diri[diri_counter+1] = dof[7];
502 tmp_diri[diri_counter+2] = dof[4];
503 tmp_diri[diri_counter+3] = dof[0];
507 tmp_diri[diri_counter] = dof[15];
508 tmp_diri[diri_counter+1] = dof[14];
509 tmp_diri[diri_counter+2] = dof[13];
510 tmp_diri[diri_counter+3] = dof[12];
514 tmp_diri[diri_counter] = dof[12];
515 tmp_diri[diri_counter+1] = dof[8];
516 tmp_diri[diri_counter+2] = dof[4];
517 tmp_diri[diri_counter+3] = dof[0];
521 if (diri_counter+3 > max_entries)
523 OutPut(
"tmp_diri too short !!!"<<endl);
528 if ((fabs(x[j]+3)<eps)&&(fabs(x[(j+1)%N_V]+3)<eps))
530 tmp_bdry[diri_counter] = 3;
531 tmp_bdry[diri_counter+1] = 3;
532 tmp_bdry[diri_counter+2] = 3;
533 tmp_bdry[diri_counter+3] = 3;
534 tmp_param[diri_counter] = (-y[j]+3)/6.0;
535 tmp_param[diri_counter+3] = (-y[(j+1)%N_V]+3)/6.0;
536 tmp_param[diri_counter+1] = (2*tmp_param[diri_counter] + tmp_param[diri_counter+3])/3.0;
537 tmp_param[diri_counter+2] = (tmp_param[diri_counter] + 2*tmp_param[diri_counter+3])/2.0;
540 if ((fabs(sqrt(x[j]*x[j]+y[j]*y[j])-1)<eps) &&
541 (fabs(sqrt(x[(j+1)%N_V]*x[(j+1)%N_V]+y[(j+1)%N_V]*y[(j+1)%N_V])-1)<eps))
543 tmp_bdry[diri_counter] = 4;
544 tmp_bdry[diri_counter+1] = 4;
545 tmp_bdry[diri_counter+2] = 4;
546 tmp_bdry[diri_counter+3] = 4;
548 tmp_param[diri_counter] = 0;
549 tmp_param[diri_counter+1] = 0;
550 tmp_param[diri_counter+2] = 0;
551 tmp_param[diri_counter+3] = 0;
558 OutPut(
"CheckNeumannNodesForVelocity not implemented for element "
559 << CurrentElement << endl);
560 OutPut(
"code can be run without CheckNeumannNodesForVelocity, just delete the exit" << endl);
566 for (i=0;i<diri_counter;i++)
568 if (tmp_diri[i] == -1)
571 for (j=i+1;j<diri_counter;j++)
573 if (tmp_diri[i] == tmp_diri[j])
581 N_neum_to_diri = diri_counter_1;
583 neum_to_diri =
new int[diri_counter_1];
585 neum_to_diri_bdry =
new int[diri_counter_1];
587 neum_to_diri_param =
new double[diri_counter_1];
589 for (i=0;i<diri_counter_1;i++)
591 min_val = tmp_diri[0];
593 for (j=1;j<diri_counter;j++)
595 if ((tmp_diri[j]>0) && ((tmp_diri[j] < min_val) ||
598 min_val = tmp_diri[j];
602 neum_to_diri[i] = tmp_diri[found];
603 neum_to_diri_bdry[i] = tmp_bdry[found];
604 neum_to_diri_param[i] = tmp_param[found];
605 tmp_diri[found] = -1;
620 int *neum_to_diri_bdry,
621 double *neum_to_diri_param)
625 int i, l, l0, l1, index, *RowPtr_A, *KCol_A;
627 MatrixA = SQMATRICES[0];
632 for (i=0;i<N_neum_to_diri;i++)
634 index = neum_to_diri[i];
635 l0 = RowPtr_A[index];
636 l1 = RowPtr_A[index+1];
640 if (KCol_A[l]==index)
646 BoundValue(neum_to_diri_bdry[i], neum_to_diri_param[i], rhs[index]);
650 void ComputeDifferenceToCoarseLevel(
TCollection *Coll_fine,
655 int i, j, k, N_Cells, N_Edges, coarse_no;
656 double x, y, x_c, y_c, val_fine[4], val_coarse[4], c1err = -1, c1err_coarse = -1;
657 double x_err, y_err, x_err_c, y_err_c;
664 for(i=0;i<N_Cells;i++)
670 coarse_no = Coll_coarse->
GetIndex(parent);
674 for (j=0;j<N_Edges;j++)
679 if (fabs(val_fine[0] - val_coarse[0]) > c1err)
681 c1err = fabs(val_fine[0] - val_coarse[0]);
685 for (k=0;k<N_Edges;k++)
688 if ((fabs(x_c -x ) < 1e-6) && (fabs(y_c -y ) < 1e-6))
690 if (fabs(val_fine[0] - val_coarse[0]) > c1err_coarse)
692 c1err_coarse = fabs(val_fine[0] - val_coarse[0]);
704 OutPut(
"C1 error f "<<
" & " << c1err <<
" & ( " << x_err <<
"," << y_err <<
")"<<
"\\\\\\hline" << endl);
705 OutPut(
"C1 error c "<<
" & "<< c1err_coarse <<
" & ( " << x_err_c <<
"," << y_err_c <<
")" <<
"\\\\\\hline"<< endl);
709 double h, val[3], x, y, *cutvalues, y0=0;
710 int i, j, N_Cells, bound_points = 10001;
713 h = 3.0/(bound_points-1);
715 cutvalues =
new double[6*bound_points];
716 memset(cutvalues , 0 , 6*bound_points*SizeOfDouble);
719 for(i=0;i<N_Cells;i++)
723 for (j=0;j<bound_points;j++)
730 cutvalues[j+bound_points] = val[0];
734 for (j=0;j<bound_points;j++)
740 cutvalues[j+2*bound_points] = val[0];
744 for (j=0;j<bound_points;j++)
750 cutvalues[j+3*bound_points] = val[0];
754 for (j=0;j<bound_points;j++)
760 cutvalues[j+4*bound_points] = val[0];
764 for (j=0;j<bound_points;j++)
770 cutvalues[j+5*bound_points] = val[0];
775 for (j=0;j<bound_points;j++)
777 OutPut(
"cutx"<< level <<
" " << cutvalues[j] <<
" " << cutvalues[j+bound_points]
778 <<
" " << cutvalues[j+2*bound_points] <<
" " << cutvalues[j+3*bound_points] <<
" "
779 << cutvalues[j+4*bound_points] <<
" " << cutvalues[j+5*bound_points] << endl);
785 double h, val[3], x, y, *cutvalues;
786 int i, j, N_Cells, bound_points = 20001;
789 h = 10.0/(bound_points-1);
791 cutvalues =
new double[3*bound_points];
792 memset(cutvalues , 0 , 3*bound_points*SizeOfDouble);
795 for(i=0;i<N_Cells;i++)
799 for (j=0;j<bound_points;j++)
806 cutvalues[j+bound_points] = val[0];
810 for (j=0;j<bound_points;j++)
822 cutvalues[j+2*bound_points] = val[0];
827 for (j=0;j<bound_points;j++)
829 OutPut(
"cuty"<< level <<
" " << cutvalues[j] <<
" " << cutvalues[j+bound_points]
830 <<
" " << cutvalues[j+2*bound_points] << endl);
836 double h, val[3], x, y, *cutvalues;
837 int i, j, N_Cells, bound_points = 20001;
841 h = 10.0/(bound_points-1);
843 cutvalues =
new double[3*bound_points];
844 memset(cutvalues , 0 , 3*bound_points*SizeOfDouble);
847 for(i=0;i<N_Cells;i++)
851 for (j=0;j<bound_points;j++)
858 cutvalues[j+bound_points] = val[0];
862 for (j=0;j<bound_points;j++)
868 cutvalues[j+2*bound_points] = val[0];
873 for (j=0;j<bound_points;j++)
875 OutPut(
"cutyeps"<< level <<
" " << cutvalues[j] <<
" " << cutvalues[j+bound_points]
876 <<
" " << cutvalues[j+2*bound_points] << endl);
881 double h, val[3], x, y, *cutvalues, tmp, r;
882 int i, j, N_Cells, bound_points = 10001;
886 h = 2*Pi/(bound_points-1);
888 cutvalues =
new double[10*bound_points];
889 memset(cutvalues , 0 , 10*bound_points*SizeOfDouble);
892 for(i=0;i<N_Cells;i++)
896 for (j=0;j<bound_points;j++)
900 cutvalues[j] = h*j -Pi;
901 cutvalues[j+bound_points] = x;
902 cutvalues[j+2*bound_points] = y;
906 cutvalues[j+3*bound_points] = val[0];
909 tmp=pow(eps,2.0/3.0);
911 for (j=0;j<bound_points;j++)
915 cutvalues[j+4*bound_points] = x;
916 cutvalues[j+5*bound_points] = y;
920 cutvalues[j+6*bound_points] = val[0];
925 for (j=0;j<bound_points;j++)
929 cutvalues[j+7*bound_points] = x;
930 cutvalues[j+8*bound_points] = y;
934 cutvalues[j+9*bound_points] = val[0];
940 for (j=0;j<bound_points;j++)
942 OutPut(
"cutradeps"<< level <<
" " << cutvalues[j] <<
" " << cutvalues[j+bound_points]
943 <<
" " << cutvalues[j+2*bound_points] <<
" " << cutvalues[j+3*bound_points]
944 <<
" " << cutvalues[j+4*bound_points] <<
" " << cutvalues[j+5*bound_points]
945 <<
" " << cutvalues[j+6*bound_points] <<
" " << cutvalues[j+7*bound_points]
946 <<
" " << cutvalues[j+8*bound_points] <<
" " << cutvalues[j+9*bound_points] << endl);
double * GetValues()
Definition: FEFunction2D.h:67
void FindGradientLocal(TBaseCell *cell, int cell_no, double x, double y, double *values)
Definition: FEFunction2D.C:1188
TBaseFunct2D * GetBaseFunct2D() const
Definition: FE2D.h:67
static TFE2D * GetFE2D(FE2D FE)
Definition: FEDatabase2D.h:353
TCollection * GetCollection() const
Definition: FESpace.h:131
JointType GetType()
Definition: Joint.h:75
TBaseCell * GetCell(int i) const
return Cell with index i in Cells-array
Definition: Collection.h:50
Definition: SquareMatrix2D.h:20
Definition: FESpace2D.h:28
double RE_NR
Definition: Database.h:313
static void SetCellForRefTrans(TBaseCell *cell, RefTrans2D reftrans)
Definition: FEDatabase2D.C:2300
static void GetOrigValues(RefTrans2D RefTrans, double xi, double eta, TBaseFunct2D *bf, TCollection *Coll, TGridCell *cell, double *uref, double *uxiref, double *uetaref, double *uorig, double *uxorig, double *uyorig)
Definition: FEDatabase2D.C:2150
double * GetEntries() const
Definition: Matrix.h:87
int GetDimension() const
Definition: BaseFunct2D.h:119
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 GetIndex(TBaseCell *cell)
return Index of cell in Cells-array
Definition: Collection.C:115
int GetN_Cells() const
return number of cells
Definition: Collection.h:46
TJoint * GetJoint(int J_i)
return the pointer to face with number i
Definition: BaseCell.h:175
int * GetRowPtr() const
Definition: Matrix.h:79
RefTrans2D GetRefTransID() const
Definition: FE2D.h:89
TFESpace2D * GetFESpace2D()
Definition: FEFunction2D.h:59
void GetCoords(double &x, double &y, double &z) const
Definition: Vertex.h:106
FE2D GetFE2D(int i, TBaseCell *cell)
Definition: FESpace2D.C:1184
double GetY() const
Definition: Vertex.h:99
int GetN_Vertices()
return the number of vertices of the cell
Definition: BaseCell.h:179
virtual TBaseCell * GetParent()=0
return the parent cell
information for finite element data structure
Definition: BaseCell.h:25
virtual bool PointInCell(double X, double Y)=0
return whether a point is inside a cell
int * GetGlobalNumbers() const
Definition: FESpace.h:135
int GetN_Edges()
return the number of edges of the cell
Definition: BaseCell.h:182
int * GetKCol() const
Definition: Matrix.h:67
Definition: BaseFunct2D.h:27
void FindGradient(double x, double y, double *values)
Definition: FEFunction2D.C:1078
static void GetRefFromOrig(RefTrans2D RefTrans, double X, double Y, double &xi, double &eta)
Definition: FEDatabase2D.C:2269
double GetX() const
Definition: Vertex.h:96
represent geometric information of the cell
Definition: GridCell.h:15
int * GetBeginIndex() const
Definition: FESpace.h:142
static TParamDB * ParamDB
Definition: Database.h:1134
void GetDerivatives(MultiIndex2D MultiIndex, double xi, double eta, double *values)
Definition: BaseFunct2D.h:127
Definition: FEFunction2D.h:24