2441 {
2442 double **RawInf = NULL;
2444
2446
2447
2448 printf("\ncomputing solution for each element: ");
2449
2451 printf("%6d ...", i);
2453
2454 double sum = 0.0;
2455 int j;
2456#ifdef _OPENMP
2457 #pragma omp parallel for private(j) reduction(+ : sum)
2458#endif
2461 }
2462
2464 printf("\b\b\b\b\b\b\b\b\b\b");
2465 }
2466 fflush(stdout);
2467
2468 printf("\nsolution over for all elements ...\n");
2469 fflush(stdout);
2470
2474 printf("\nsolution over for system charge zero constraint ...\n");
2475 fflush(stdout);
2476 }
2477
2480 printf(
2481 "\nsolution over for floating conductor charge zero constraint "
2482 "...\n");
2483 fflush(stdout);
2484 }
2485 }
2486
2487
2488 char SolnFile[256];
2490 strcat(SolnFile, "/Soln.out");
2491 FILE* fSoln = fopen(SolnFile, "w");
2492 if (fSoln == NULL) {
2494 return -1;
2495 }
2496 fprintf(fSoln, "#EleNb\tX\tY\tZ\tSolution\tAssigned\tTotal\n");
2497 for (
int ele = 1; ele <=
NbElements; ++ele) {
2499 fprintf(fSoln, "%d\t%lg\t%lg\t%lg\t%.16lg\t%.16lg\t%.16lg\n", ele,
2500 (
EleArr + ele - 1)->G.Origin.X, (
EleArr + ele - 1)->G.Origin.Y,
2501 (
EleArr + ele - 1)->G.Origin.Z, (
EleArr + ele - 1)->Solution,
2502 (
EleArr + ele - 1)->Assigned,
2503 ((
EleArr + ele - 1)->Solution + (
EleArr + ele - 1)->Assigned));
2504 }
2505
2508 fprintf(fSoln, "#NbSystemChargeZero\tVSystemChargeZero\n");
2510 }
2512 fprintf(fSoln, "#NbFloatCon\tVFloatCon\n");
2514 }
2515 }
2516
2517 fclose(fSoln);
2518
2519
2520 char PrimSolnFile[256];
2522 strcat(PrimSolnFile, "/PrimSoln.out");
2523 FILE *fPrimSoln = fopen(PrimSolnFile, "w");
2524 if (fPrimSoln == NULL) {
2526 return -1;
2527 }
2528 fprintf(fPrimSoln, "#PrimNb\tEleBgn\tEleEnd\tX\tY\tZ\tAvChDen\tAvAsgndChDen\n");
2529
2531 double area = 0.0;
2534
2536 area += (
EleArr + ele - 1)->G.dA;
2539 (
EleArr + ele - 1)->Assigned * (
EleArr + ele - 1)->G.dA;
2540 }
2541
2544
2545 fprintf(fPrimSoln, "%d\t%d\t%d\t%lg\t%lg\t%lg\t%.16lg\t%.16g\n", prim,
2549 }
2550
2551 fclose(fPrimSoln);
2552
2554
2555
2556
2557
2558
2559
2560
2563 printf("Computing solution at the collocation points for comparison.\n");
2564 fflush(stdout);
2565
2567 printf("Influence matrix in memory ...\n");
2568 }
2569
2570
2571
2572
2575
2576 printf("Influence matrix in memory ...\n");
2577 } else {
2578 printf("Influence matrix NOT in memory ...\n");
2579
2581 printf("repeating influence coefficient matrix computation ...\n");
2582
2584
2585 if (fstatus != 0) {
2587 return -1;
2588 }
2589 }
2590
2592 printf(
2593 "reading influence coefficient matrix from formatted file...\n");
2594
2595 char InflFile[256];
2597 strcat(InflFile, "/Infl.out");
2598 FILE *fInf = fopen(InflFile, "r");
2599
2600 if (fInf == NULL) {
2602 return 1;
2603 }
2604
2605 int chkNbEqns, chkNbUnknowns;
2606 fscanf(fInf, "%d %d\n", &chkNbEqns, &chkNbUnknowns);
2608 neBEMMessage(
"Solve - matrix dimension do not match!");
2609 return (-1);
2610 }
2611
2612 printf("Solve: Matrix dimensions: %d equations, %d unknowns\n",
2614
2616
2617 for (
int elefld = 1; elefld <=
NbEqns; ++elefld)
2618 for (
int elesrc = 1; elesrc <=
NbUnknowns; ++elesrc)
2619 fscanf(fInf,
"%le\n", &
Inf[elefld][elesrc]);
2620 fclose(fInf);
2621 }
2622
2625 "Solve - Binary read of Infl matrix not implemented yet.\n");
2626 return -1;
2627
2629
2630 printf(
2631 "reading influence coefficient matrix from unformatted file "
2632 "...\n");
2633
2634 char InflFile[256];
2636 strcat(InflFile, "/RawInfl.out");
2637 printf("\nread from file %s\n", InflFile);
2638 fflush(stdout);
2639 FILE *fInf = fopen(InflFile, "rb");
2640
2641 if (fInf == NULL) {
2643 return -1;
2644 }
2645 printf("\nfInf: %p\n", (void *)fInf);
2647 fclose(fInf);
2648 printf("\nNb of items successfully read from raw mode in %s is %d\n",
2649 InflFile, rfw);
2650 fflush(stdout);
2651
2652 for (
int unknown = 1; unknown <=
NbUnknowns; ++unknown)
2653 for (
int eqn = 1; eqn <=
NbEqns; ++eqn)
2654 printf(
2655 "Unknown:%d, Eqn:%d => diff Inf: %lg, RawInf: %lg is %lg\n",
2656 unknown, eqn,
Inf[unknown][eqn], RawInf[unknown][eqn],
2657 fabs(
Inf[unknown][eqn] - RawInf[unknown][eqn]));
2658 }
2659 }
2660 }
2661
2662
2663
2664 if (
Inf || RawInf) {
2665 double XChk;
2666 char Chkfile[256];
2668 strcat(Chkfile, "/XChk.out");
2669 FILE *fChk = fopen(Chkfile, "w");
2670 if (fChk == NULL) {
2672 return -1;
2673 }
2674 fprintf(fChk, "#Row\tGivenPot\tError\n");
2675
2676 int ElementOfMaxError = 1;
2677 double *Error, MaxError = 0.0;
2679 int elesrc;
2680#ifdef _OPENMP
2681 #pragma omp parallel for private(elesrc)
2682#endif
2683 for (
int elefld = 1; elefld <=
NbEqns; elefld++) {
2684 XChk = 0.0;
2685 for (elesrc = 1; elesrc <=
NbUnknowns; elesrc++) {
2688 XChk += RawInf[elefld][elesrc] *
Solution[elesrc];
2689 else
2691 }
2692 Error[elefld] =
fabs(
RHS[elefld] - XChk);
2693
2694 if (Error[elefld] > MaxError) {
2695 MaxError = Error[elefld];
2696 ElementOfMaxError = elefld;
2697 }
2698 }
2699 for (
int elefld = 1; elefld <=
NbEqns; elefld++)
2700 fprintf(fChk,
"%d\t%lg\t%lg\n", elefld,
RHS[elefld], Error[elefld]);
2702
2703 printf("Computed values at the collocation points for comparison.\n");
2704 printf("Error maximum on element %d and its magnitude is %lg.\n",
2705 ElementOfMaxError, MaxError);
2706 fflush(stdout);
2707
2708 fprintf(fChk, "#Error maximum on element %d and its magnitude is %lg.\n",
2709 ElementOfMaxError, MaxError);
2710 fclose(fChk);
2711
2718 }
2719 else {
2722 "Solve - Infl matrix not available, re-computation forced.\n");
2723
2725 if (fstatus != 0) {
2726 neBEMMessage(
"Solve - LHMatrix in forced OptRepeatLHMatrix");
2727 return -1;
2728 }
2729
2730 double XChk;
2731 char Chkfile[256];
2732 FILE *fChk;
2734 strcat(Chkfile, "/XChk.out");
2735 fChk = fopen(Chkfile, "w");
2736 if (fChk == NULL) {
2737 neBEMMessage(
"Solve - ChkFile in forced recomputation");
2738 return -1;
2739 }
2740 fprintf(fChk, "#Row\tGivenPot\tComputedPot\tDiff\n");
2741
2742 int ElementOfMaxError = 1;
2743 double Error, MaxError = 0.0;
2744 for (
int elefld = 1; elefld <=
NbEqns; elefld++) {
2745 XChk = 0.0;
2746 for (
int elesrc = 1; elesrc <=
NbUnknowns; elesrc++) {
2748 }
2749 Error =
fabs(
RHS[elefld] - XChk);
2750 fprintf(fChk,
"%d\t%lg\t%lg\t%lg\n", elefld,
RHS[elefld], XChk,
2751 Error);
2752
2753 if (Error > MaxError) {
2754 MaxError = Error;
2755 ElementOfMaxError = elefld;
2756 }
2757 }
2758
2759 printf("Computed values at the collocation points for comparison.\n");
2760 printf("Error maximum on element %d and its magnitude is %lg.\n",
2761 ElementOfMaxError, MaxError);
2762 fflush(stdout);
2763
2764 fprintf(fChk,
2765 "#Error maximum on element %d and its magnitude is %lg.\n",
2766 ElementOfMaxError, MaxError);
2767 fclose(fChk);
2768
2770 } else {
2771 neBEMMessage(
"Solve - Infl matrix not available, no validation.\n");
2772 }
2773 }
2774 }
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2817 printf(
2818 "Properties at non-collocation points on element for estimating "
2819 "error.\n");
2820 fflush(stdout);
2821
2822 double Err;
2823 int PrimitiveOfMaxError = 1;
2824 int ElementOfMaxError = 1;
2825 double MaxError = 0.0;
2826 double xerrMax = 0.0, yerrMax = 0.0, zerrMax = 0.0;
2827
2828 char Errfile[256];
2830 strcat(Errfile, "/Errors.out");
2831 FILE *fErr = fopen(Errfile, "w");
2832 if (fErr == NULL) {
2834 return -1;
2835 }
2836 fprintf(fErr,
2837 "#Prim\tEle\tGType\tIType\txerr\tyerr\tzerr\tGivenBC\tComputVal\tDi"
2838 "ff\n");
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2855 double normdisp = 1.0e-8;
2856
2857 if ((prim == 91) && (ele == 337))
2858 {
2859
2861 } else
2862 {
2864 }
2865
2866
2867
2868 if ((
EleArr + ele - 1)->G.Type == 2)
continue;
2869
2870 if ((
EleArr + ele - 1)->G.Type == 3)
2871 {
2873 double Potential;
2875 double x0 = (
EleArr + ele - 1)->G.Vertex[0].
X;
2876 double y0 = (
EleArr + ele - 1)->G.Vertex[0].Y;
2877 double z0 = (
EleArr + ele - 1)->G.Vertex[0].Z;
2878 double x1 = (
EleArr + ele - 1)->G.Vertex[1].X;
2879 double y1 = (
EleArr + ele - 1)->G.Vertex[1].Y;
2880 double z1 = (
EleArr + ele - 1)->G.Vertex[1].Z;
2881 double x2 = (
EleArr + ele - 1)->G.Vertex[2].X;
2882 double y2 = (
EleArr + ele - 1)->G.Vertex[2].Y;
2883 double z2 = (
EleArr + ele - 1)->G.Vertex[2].Z;
2884 double xb = (x0 + x1 + x2) / 3.0;
2885 double yb = (y0 + y1 + y2) / 3.0;
2886 double zb = (z0 + z1 + z2) / 3.0;
2887
2888
2893 PFAtPoint(&globalP, &Potential, &globalF);
2894 Err =
ApplPot[prim] - Potential;
2895 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
2896 prim, ele, 3, 1, xb, yb, zb,
ApplPot[prim], Potential, Err);
2898 MaxError = Err;
2899 PrimitiveOfMaxError = prim;
2900 ElementOfMaxError = ele;
2901 xerrMax = xb;
2902 yerrMax = yb;
2903 zerrMax = zb;
2904 }
2905 }
2907 4) {
2908 double xplus = xb + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
2909 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
2910 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
2911 double yplus = yb + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
2912 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
2913 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
2914 double zplus = zb + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
2915 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
2916 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
2920 PFAtPoint(&globalP, &Potential, &globalF);
2921 localF
2924 double value1 = -localF.
Y;
2925 double xminus = xb - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
2926 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
2927 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
2928 double yminus = yb - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
2929 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
2930 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
2931 double zminus = zb - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
2932 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
2933 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
2937 PFAtPoint(&globalP, &Potential, &globalF);
2938 localF
2941 double value2 = -localF.
Y;
2943 Err = epsratio - (value1 / value2);
2944 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
2945 prim, ele, 3, 4, xb, yb, zb, epsratio, (value1 / value2),
2946 Err);
2948 MaxError = Err;
2949 PrimitiveOfMaxError = prim;
2950 ElementOfMaxError = ele;
2951 xerrMax = xb;
2952 yerrMax = yb;
2953 zerrMax = zb;
2954 }
2955 }
2956
2957
2958 double xerr =
2959 0.25 * (x0 + 0.5 * (x0 + x1) + 0.5 * (x1 + x2) + 0.5 * (x0 + x2));
2960 double yerr =
2961 0.25 * (y0 + 0.5 * (y0 + y1) + 0.5 * (y1 + y2) + 0.5 * (y0 + y2));
2962 double zerr =
2963 0.25 * (z0 + 0.5 * (z0 + z1) + 0.5 * (z1 + z2) + 0.5 * (z0 + z2));
2967
2968
2969
2971 PFAtPoint(&globalP, &Potential, &globalF);
2972 Err =
ApplPot[prim] - Potential;
2973 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
2974 prim, ele, 3, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
2975 Err);
2977 MaxError = Err;
2978 PrimitiveOfMaxError = prim;
2979 ElementOfMaxError = ele;
2980 xerrMax = xerr;
2981 yerrMax = yerr;
2982 zerrMax = zerr;
2983 }
2984 }
2986 4) {
2987 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
2988 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
2989 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
2990 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
2991 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
2992 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
2993 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
2994 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
2995 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
2999 PFAtPoint(&globalP, &Potential, &globalF);
3000 localF
3003 double value1 = -localF.
Y;
3004 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3005 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3006 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3007 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3008 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3009 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3010 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3011 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3012 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3016 PFAtPoint(&globalP, &Potential, &globalF);
3017 localF
3020 double value2 = -localF.
Y;
3022 Err = epsratio - (value1 / value2);
3023 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3024 prim, ele, 3, 4, xerr, yerr, zerr, epsratio,
3025 (value1 / value2), Err);
3027 MaxError = Err;
3028 PrimitiveOfMaxError = prim;
3029 ElementOfMaxError = ele;
3030 xerrMax = xerr;
3031 yerrMax = yerr;
3032 zerrMax = zerr;
3033 }
3034 }
3035
3036
3037 xerr = (0.5 * (x0 + x1) + 0.5 * (x1 + x2) + x1) / 3.0;
3038 yerr = (0.5 * (y0 + y1) + 0.5 * (y1 + y2) + y1) / 3.0;
3039 zerr = (0.5 * (z0 + z1) + 0.5 * (z1 + z2) + z1) / 3.0;
3043
3044
3045
3047 PFAtPoint(&globalP, &Potential, &globalF);
3048 Err =
ApplPot[prim] - Potential;
3049 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3050 prim, ele, 3, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
3051 Err);
3053 MaxError = Err;
3054 PrimitiveOfMaxError = prim;
3055 ElementOfMaxError = ele;
3056 xerrMax = xerr;
3057 yerrMax = yerr;
3058 zerrMax = zerr;
3059 }
3060 }
3062 4) {
3063 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3064 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3065 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3066 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3067 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3068 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3069 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3070 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3071 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3075 PFAtPoint(&globalP, &Potential, &globalF);
3076 localF
3079 double value1 = -localF.
Y;
3080 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3081 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3082 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3083 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3084 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3085 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3086 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3087 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3088 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3092 PFAtPoint(&globalP, &Potential, &globalF);
3093 localF
3096 double value2 = -localF.
Y;
3098 Err = epsratio - (value1 / value2);
3099 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3100 prim, ele, 3, 4, xerr, yerr, zerr, epsratio,
3101 (value1 / value2), Err);
3103 MaxError = Err;
3104 PrimitiveOfMaxError = prim;
3105 ElementOfMaxError = ele;
3106 xerrMax = xerr;
3107 yerrMax = yerr;
3108 zerrMax = zerr;
3109 }
3110 }
3111
3112
3113 xerr = (0.5 * (x0 + x2) + 0.5 * (x1 + x2) + x2) / 3.0;
3114 yerr = (0.5 * (y0 + y2) + 0.5 * (y1 + y2) + y2) / 3.0;
3115 zerr = (0.5 * (z0 + z2) + 0.5 * (z1 + z2) + z2) / 3.0;
3119
3120
3121
3123 PFAtPoint(&globalP, &Potential, &globalF);
3124 Err =
ApplPot[prim] - Potential;
3125 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3126 prim, ele, 3, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
3127 Err);
3129 MaxError = Err;
3130 PrimitiveOfMaxError = prim;
3131 ElementOfMaxError = ele;
3132 xerrMax = xerr;
3133 yerrMax = yerr;
3134 zerrMax = zerr;
3135 }
3136 }
3138 4) {
3139 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3140 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3141 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3142 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3143 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3144 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3145 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3146 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3147 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3151 PFAtPoint(&globalP, &Potential, &globalF);
3152 localF
3155 double value1 = -localF.
Y;
3156 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3157 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3158 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3159 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3160 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3161 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3162 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3163 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3164 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3168 PFAtPoint(&globalP, &Potential, &globalF);
3169 localF
3172 double value2 = -localF.
Y;
3174 Err = epsratio - (value1 / value2);
3175 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3176 prim, ele, 4, 4, xerr, yerr, zerr, epsratio,
3177 (value1 / value2), Err);
3179 MaxError = Err;
3180 PrimitiveOfMaxError = prim;
3181 ElementOfMaxError = ele;
3182 xerrMax = xerr;
3183 yerrMax = yerr;
3184 zerrMax = zerr;
3185 }
3186 }
3187 }
3188
3189 if ((
EleArr + ele - 1)->G.Type == 4)
3190 {
3192 double Potential;
3194
3195 double x0 = (
EleArr + ele - 1)->G.Vertex[0].
X;
3196 double y0 = (
EleArr + ele - 1)->G.Vertex[0].Y;
3197 double z0 = (
EleArr + ele - 1)->G.Vertex[0].Z;
3198 double x1 = (
EleArr + ele - 1)->G.Vertex[1].X;
3199 double y1 = (
EleArr + ele - 1)->G.Vertex[1].Y;
3200 double z1 = (
EleArr + ele - 1)->G.Vertex[1].Z;
3201 double x2 = (
EleArr + ele - 1)->G.Vertex[2].X;
3202 double y2 = (
EleArr + ele - 1)->G.Vertex[2].Y;
3203 double z2 = (
EleArr + ele - 1)->G.Vertex[2].Z;
3204 double x3 = (
EleArr + ele - 1)->G.Vertex[3].X;
3205 double y3 = (
EleArr + ele - 1)->G.Vertex[3].Y;
3206 double z3 = (
EleArr + ele - 1)->G.Vertex[3].Z;
3207 double xo = 0.25 * (x0 + x1 + x2 + x3);
3208 double yo = 0.25 * (y0 + y1 + y2 + y3);
3209 double zo = 0.25 * (z0 + z1 + z2 + z3);
3210
3211
3216 PFAtPoint(&globalP, &Potential, &globalF);
3217 Err =
ApplPot[prim] - Potential;
3218 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3219 prim, ele, 4, 1, xo, yo, zo,
ApplPot[prim], Potential, Err);
3221 MaxError = Err;
3222 PrimitiveOfMaxError = prim;
3223 ElementOfMaxError = ele;
3224 xerrMax = xo;
3225 yerrMax = yo;
3226 zerrMax = zo;
3227 }
3228 }
3230
3231 double xplus = xo + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3232 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3233 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3234 double yplus = yo + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3235 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3236 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3237 double zplus = zo + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3238 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3239 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3243 PFAtPoint(&globalP, &Potential, &globalF);
3244 localF
3247 double dispfld1 =
Epsilon1[prim] * localF.
Y;
3248 double xminus = xo - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3249 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3250 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3251 double yminus = yo - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3252 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3253 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3254 double zminus = zo - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3255 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3256 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3260 PFAtPoint(&globalP, &Potential, &globalF);
3261 localF
3264 double dispfld2 =
Epsilon2[prim] * localF.
Y;
3268 PFAtPoint(&globalP, &Potential, &globalF);
3269 localF
3272 double dispfldo =
Epsilon1[prim] * localF.
Y;
3273 Err = (dispfld2 - dispfld1) /
3274 dispfldo;
3275 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3276 prim, ele, 4, 4, xo, yo, zo, dispfld1, dispfld2, Err);
3277 if ((prim == 91) && (ele == 337)) {
3278
3279 double TotalInfl = 0.0;
3280 for (
int elesrc = 1; elesrc <=
NbElements; ++elesrc) {
3282 }
3283 printf("TotalInfl: %lg\n", TotalInfl);
3284 printf(
3285 "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\t%"
3286 "lg\n",
3288 dispfld1, dispfld2, dispfldo, Err);
3289 }
3291 MaxError = Err;
3292 PrimitiveOfMaxError = prim;
3293 ElementOfMaxError = ele;
3294 xerrMax = xo;
3295 yerrMax = yo;
3296 zerrMax = zo;
3297 }
3298 }
3299
3300
3301 double xerr = 0.25 * (x0 + 0.5 * (x1 + x0) + xo + 0.5 * (x0 + x3));
3302 double yerr = 0.25 * (y0 + 0.5 * (y1 + y0) + yo + 0.5 * (y0 + y3));
3303 double zerr = 0.25 * (z0 + 0.5 * (z1 + z0) + zo + 0.5 * (z0 + z3));
3308 PFAtPoint(&globalP, &Potential, &globalF);
3309 Err =
ApplPot[prim] - Potential;
3310 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3311 prim, ele, 4, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
3312 Err);
3314 MaxError = Err;
3315 PrimitiveOfMaxError = prim;
3316 ElementOfMaxError = ele;
3317 xerrMax = xerr;
3318 yerrMax = yerr;
3319 zerrMax = zerr;
3320 }
3321 }
3323 4) {
3324 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3325 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3326 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3327 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3328 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3329 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3330 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3331 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3332 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3336 PFAtPoint(&globalP, &Potential, &globalF);
3337 localF
3340 double value1 = -localF.
Y;
3341 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3342 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3343 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3344 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3345 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3346 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3347 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3348 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3349 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3353 PFAtPoint(&globalP, &Potential, &globalF);
3354 localF
3357 double value2 = -localF.
Y;
3359 Err = epsratio - (value1 / value2);
3360 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3361 prim, ele, 4, 4, xerr, yerr, zerr, epsratio,
3362 (value1 / value2), Err);
3364 MaxError = Err;
3365 PrimitiveOfMaxError = prim;
3366 ElementOfMaxError = ele;
3367 xerrMax = xerr;
3368 yerrMax = yerr;
3369 zerrMax = zerr;
3370 }
3371 }
3372
3373
3374 xerr = 0.25 * (0.5 * (x1 + x0) + x1 + 0.5 * (x1 + x2) + xo);
3375 yerr = 0.25 * (0.5 * (y1 + y0) + y1 + 0.5 * (y1 + y2) + yo);
3376 zerr = 0.25 * (0.5 * (z1 + z0) + z1 + 0.5 * (z1 + z2) + zo);
3380
3381
3382
3384 PFAtPoint(&globalP, &Potential, &globalF);
3385 Err =
ApplPot[prim] - Potential;
3386 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3387 prim, ele, 4, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
3388 Err);
3390 MaxError = Err;
3391 PrimitiveOfMaxError = prim;
3392 ElementOfMaxError = ele;
3393 xerrMax = xerr;
3394 yerrMax = yerr;
3395 zerrMax = zerr;
3396 }
3397 }
3399 4) {
3400 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3401 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3402 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3403 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3404 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3405 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3406 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3407 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3408 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3412 PFAtPoint(&globalP, &Potential, &globalF);
3413 localF
3416 double value1 = -localF.
Y;
3417 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3418 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3419 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3420 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3421 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3422 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3423 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3424 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3425 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3429 PFAtPoint(&globalP, &Potential, &globalF);
3430 localF
3433 double value2 = -localF.
Y;
3435 Err = epsratio - (value1 / value2);
3436 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3437 prim, ele, 4, 4, xerr, yerr, zerr, epsratio,
3438 (value1 / value2), Err);
3440 MaxError = Err;
3441 PrimitiveOfMaxError = prim;
3442 ElementOfMaxError = ele;
3443 xerrMax = xerr;
3444 yerrMax = yerr;
3445 zerrMax = zerr;
3446 }
3447 }
3448
3449
3450 xerr = 0.25 * (xo + 0.5 * (x1 + x2) + x2 + 0.5 * (x3 + x2));
3451 yerr = 0.25 * (yo + 0.5 * (y1 + y2) + y2 + 0.5 * (y3 + y2));
3452 zerr = 0.25 * (zo + 0.5 * (z1 + z2) + z2 + 0.5 * (z3 + z2));
3456
3457
3458
3460 PFAtPoint(&globalP, &Potential, &globalF);
3461 Err =
ApplPot[prim] - Potential;
3462 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3463 prim, ele, 4, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
3464 Err);
3466 MaxError = Err;
3467 PrimitiveOfMaxError = prim;
3468 ElementOfMaxError = ele;
3469 xerrMax = xerr;
3470 yerrMax = yerr;
3471 zerrMax = zerr;
3472 }
3473 }
3475 4) {
3476 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3477 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3478 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3479 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3480 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3481 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3482 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3483 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3484 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3488 PFAtPoint(&globalP, &Potential, &globalF);
3489 localF
3492 double value1 = -localF.
Y;
3493 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3494 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3495 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3496 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3497 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3498 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3499 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3500 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3501 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3505 PFAtPoint(&globalP, &Potential, &globalF);
3506 localF
3509 double value2 = -localF.
Y;
3511 Err = epsratio - (value1 / value2);
3512 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3513 prim, ele, 4, 4, xerr, yerr, zerr, epsratio,
3514 (value1 / value2), Err);
3516 MaxError = Err;
3517 PrimitiveOfMaxError = prim;
3518 ElementOfMaxError = ele;
3519 xerrMax = xerr;
3520 yerrMax = yerr;
3521 zerrMax = zerr;
3522 }
3523 }
3524
3525
3526 xerr = 0.25 * (0.5 * (x0 + x3) + xo + 0.5 * (x3 + x2) + x3);
3527 yerr = 0.25 * (0.5 * (y0 + y3) + yo + 0.5 * (y3 + y2) + y3);
3528 zerr = 0.25 * (0.5 * (z0 + z3) + zo + 0.5 * (z3 + z2) + z3);
3532
3533
3534
3536 PFAtPoint(&globalP, &Potential, &globalF);
3537 Err =
ApplPot[prim] - Potential;
3538 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3539 prim, ele, 4, 1, xerr, yerr, zerr,
ApplPot[prim], Potential,
3540 Err);
3542 MaxError = Err;
3543 PrimitiveOfMaxError = prim;
3544 ElementOfMaxError = ele;
3545 xerrMax = xerr;
3546 yerrMax = yerr;
3547 zerrMax = zerr;
3548 }
3549 }
3551 4) {
3552 double xplus = xerr + (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3553 xplus += (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3554 xplus += (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3555 double yplus = yerr + (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3556 yplus += (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3557 yplus += (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3558 double zplus = zerr + (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3559 zplus += (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3560 zplus += (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3564 PFAtPoint(&globalP, &Potential, &globalF);
3565 localF
3568 double value1 = -localF.
Y;
3569 double xminus = xerr - (
EleArr + ele - 1)->G.DC.XUnit.X * normdisp;
3570 xminus -= (
EleArr + ele - 1)->G.DC.YUnit.X * normdisp;
3571 xminus -= (
EleArr + ele - 1)->G.DC.ZUnit.X * normdisp;
3572 double yminus = yerr - (
EleArr + ele - 1)->G.DC.XUnit.Y * normdisp;
3573 yminus -= (
EleArr + ele - 1)->G.DC.YUnit.Y * normdisp;
3574 yminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Y * normdisp;
3575 double zminus = zerr - (
EleArr + ele - 1)->G.DC.XUnit.Z * normdisp;
3576 zminus -= (
EleArr + ele - 1)->G.DC.YUnit.Z * normdisp;
3577 zminus -= (
EleArr + ele - 1)->G.DC.ZUnit.Z * normdisp;
3581 PFAtPoint(&globalP, &Potential, &globalF);
3582 localF
3585 double value2 = -localF.
Y;
3587 Err = epsratio - (value1 / value2);
3588 fprintf(fErr, "%d\t%d\t%d\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n",
3589 prim, ele, 4, 4, xerr, yerr, zerr, epsratio,
3590 (value1 / value2), Err);
3592 MaxError = Err;
3593 PrimitiveOfMaxError = prim;
3594 ElementOfMaxError = ele;
3595 xerrMax = xerr;
3596 yerrMax = yerr;
3597 zerrMax = zerr;
3598 }
3599 }
3600 }
3601
3603 }
3604
3605 fprintf(fErr,
3606 "#Error maximum on element %d on primitive %d with x,y,z %lg, "
3607 "%lg, %lg and its magnitude is %lg.\n",
3608 ElementOfMaxError, PrimitiveOfMaxError, xerrMax, yerrMax, zerrMax,
3609 MaxError);
3610 fclose(fErr);
3611 }
3612
3613 return (0);
3614}
int PFAtPoint(Point3D *globalP, double *Potential, Vector3D *globalF)
neBEMGLOBAL double * ApplPot
neBEMGLOBAL int OptRepeatLHMatrix
neBEMGLOBAL double * PrimOriginZ
neBEMGLOBAL int OptEstimateError
neBEMGLOBAL double * Epsilon1
neBEMGLOBAL double * PrimOriginY
neBEMGLOBAL int * InterfaceType
neBEMGLOBAL double * PrimOriginX
neBEMGLOBAL int OptForceValidation
neBEMGLOBAL double * Epsilon2