Пример #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->showRadarButton->setEnabled(false);

///                 CHECK FOR PREVIOUS COORDINATES
    if (settings.value("mylat") != 0 && settings.value("mylong") != 0)
    {
        mycoordinates.x = settings.value("myLat").toDouble();
        mycoordinates.y = settings.value("myLong").toDouble();


        ui->myLat_info->setText(QString::number(mycoordinates.x));
        ui->myLong_info->setText(QString::number(mycoordinates.y));

    }

    if (mycoordinates.x !=0 && mycoordinates.y != 0)
    {
        //ui->showRadarButton->setEnabled(true);
        isRadarOn = true;
    }

///                  HIDE RADAR FORM
    isRadarOn = false;
    isRadarVisible = false;
    ui->radar->hide();
    setMinimumWidth(230);
    setGeometry(0,0,230,650);
    setMaximumWidth(230);

    ui->LocMenu_1->hide();
    ui->LocMenu_2->hide();

///                     CREATE TABLE AND ADD HEADER LABELS
    labels<<"ICAO"<<"Callsign"<<"Latitude"<<"Longitude"<<"Altitude"<<"Headingr"<<"Speed"<<"Vertical speed";
    ui->AircraftsTable->setColumnCount(8);
    ui->AircraftsTable->setHorizontalHeaderLabels(labels);
    ui->AircraftsTable->setRowCount(25);
    tableRows = ui->AircraftsTable->rowCount();

    ui->AircraftsTable->setItem(1,1,new QTableWidgetItem("dsd"));

///                     TIMER 1~5 SEC PRINT, 6ST SEND
///                     SetSourses get Aircrafts form datareader and send them to radar
    DB_reader = new dataReader(this);

    timer = new QTimer(this);
    timer->start(1000);

    connect(timer,SIGNAL(timeout()),this,SLOT(SetSources()));
}
int main(int argc, char *argv[]) {
    /**********************************************************/
    /*                                                        */
    /*              Initializing the problem                  */
    /*                                                        */
    /**********************************************************/
    
    double L;       // Length of simulation cell (assumed to be a cube)
    int n;          // Number of Chebyshev nodes per dimension
    doft dof;
    int Ns;         // Number of sources in simulation cell
    int Nf;         // Number of field points in simulation cell
    int m;
    int level;
    double eps;
    int use_chebyshev = 1;
    
    SetMetaData(L, n, dof, Ns, Nf, m, level, eps);
    
    vector3* source = new vector3[Ns];    // Position array for the source points
    vector3* field = new vector3[Nf];     // Position array for the field points
    double *q = new double[Ns*dof.s*m];  // Source array
    
    SetSources(field,Nf,source,Ns,q,m,&dof,L);
    
    double err;
    double *stress      =  new double[Nf*dof.f*m];// Field array (BBFMM calculation)
    double *stress_dir  =  new double[Nf*dof.f*m];// Field array (direct O(N^2) calculation)
    
    
    
    /**********************************************************/
    /*                                                        */
    /*                 Fast matrix vector product             */
    /*                                                        */
    /**********************************************************/
    
    /*****      Pre Computation     ******/
    clock_t  t0 = clock();
    myKernel Atree(&dof,L,level, n, eps, use_chebyshev);
    Atree.buildFMMTree();
    clock_t t1 = clock();
    double tPre = t1 - t0;
    
    /*****      FMM Computation     *******/
    t0 = clock();
    H2_3D_Compute<myKernel> compute(&Atree, field, source, Ns, Nf, q,m, stress);
    t1 = clock();
    double tFMM = t1 - t0;
    
    /*****      output result to binary file    ******/
    // string outputfilename = "../output/stress.bin";
    // write_Into_Binary_File(outputfilename, stress, m*Nf*dof.f);
    
    /**********************************************************/
    /*                                                        */
    /*              Exact matrix vector product               */
    /*                                                        */
    /**********************************************************/
    t0 = clock();
    DirectCalc3D(&Atree, field, Nf, source, q, m, Ns, &dof,0 , L, stress_dir);
    t1 = clock();
    double tExact = t1 - t0;
    
    cout << "Pre-computation time: " << double(tPre) / double(CLOCKS_PER_SEC) << endl;
    cout << "FMM computing time:   " << double(tFMM) / double(CLOCKS_PER_SEC)  << endl;
    cout << "FMM total time:   " << double(tFMM+tPre) / double(CLOCKS_PER_SEC)  << endl;
    cout << "Exact computing time: " << double(tExact) / double(CLOCKS_PER_SEC)  << endl;
    
    //Compute the 2-norm error
    err = ComputeError(stress,stress_dir,Nf,&dof,m);
    cout << "Relative Error: "  << err << endl;
    
    /*******            Clean Up        *******/
    
    delete []stress;
    delete []stress_dir;
    delete []q;
    delete []source;
    delete []field;
    return 0;
}
int main(int argc, char *argv[]) {
    /**********************************************************/
    /*                                                        */
    /*              Initializing the problem                  */
    /*                                                        */
    /**********************************************************/
    
    double L;       // Length of simulation cell (assumed to be a cube)
    int n;          // Number of Chebyshev nodes per dimension
    doft dof;
    int Ns;         // Number of sources in simulation cell
    int Nf;         // Number of field points in simulation cell
    int m;
    int level;
    double eps;
    int use_chebyshev = 1;
    
    SetMetaData(L, n, dof, Ns, Nf, m, level, eps);
    
    
    vector3* source = new vector3[Ns];    // Position array for the source points
    vector3* field = new vector3[Nf];     // Position array for the field points
    double *q = new double[Ns*dof.s*m];  // Source array
    
    SetSources(field,Nf,source,Ns,q,m,&dof,L);
    
    double err;
    double *stress      =  new double[Nf*dof.f*m];// Field array (BBFMM calculation)
    double *stress_dir  =  new double[Nf*dof.f*m];// Field array (direct O(N^2) calculation)*/


    
    /**********************************************************/
    /*                                                        */
    /*                 Fast matrix vector product             */
    /*                                                        */
    /**********************************************************/
    
    /*****      Pre Computation     ******/
    clock_t  t0 = clock();
    kernel_Gaussian Atree(&dof,L,level, n, eps, use_chebyshev);
    Atree.buildFMMTree();
    clock_t t1 = clock();
    double tPre = t1 - t0;

    /*****      FMM Computation     *******/
    t0 = clock();
    H2_3D_Compute<kernel_Gaussian> compute(&Atree, field, source, Ns, Nf, q,m, stress);
    t1 = clock();
    double tFMM = t1 - t0;
    
    /*****   You can repeat this part with different source, field points and charges *****/
    
    /*vector3* source1 = new vector3[Ns];    // Position array for the source points
    vector3* field1 = new vector3[Nf];     // Position array for the field points
    double *q1 = new double[Ns*dof.s*m];  // Source array
     
    SetSources(field1,Nf,source1,Ns,q1,m,&dof,L);
     
    double *stress1      =  new double[Nf*dof.f*m];// Field array (BBFMM calculation)
    H2_3D_Compute<kernel_LaplacianForce> compute1(&Atree, field1, source1, Ns, Nf, q1,m, stress1);*/
    
    /****   Test interplation error   *****/
    
//    kernel_Gaussian testTree(&dof,1.0/4 ,2, n, eps, use_chebyshev);
//    double errtest = testInterplationErr(&testTree, 100, 100);
    

    
    /*****      output result to binary file    ******/
    // string outputfilename = "../output/stress.bin";
    // write_Into_Binary_File(outputfilename, stress, m*Nf*dof.f);
    
    /**********************************************************/
    /*                                                        */
    /*              Exact matrix vector product               */
    /*                                                        */
    /**********************************************************/
    // string inputfilename = "../output/stress_dir05gaussian.bin";
    // read_Stress(inputfilename, stress_dir, Nf*dof.f*m);

    t0 = clock();
    DirectCalc3D(&Atree, field, Nf, source, q, m, Ns, &dof,0 , L, stress_dir);
    t1 = clock();
    double tExact = t1 - t0;

    string outputfilename = "../output/stress_dir06gaussian.bin";
    write_Into_Binary_File(outputfilename, stress, m*Nf*dof.f);
    
    cout << "Pre-computation time: " << double(tPre) / double(CLOCKS_PER_SEC) << endl;
    cout << "FMM computing time:   " << double(tFMM) / double(CLOCKS_PER_SEC)  << endl;
    cout << "FMM total time:   "  << double(tPre+tFMM) / double(CLOCKS_PER_SEC)  << endl;
    cout << "Exact computing time: " << double(tExact) / double(CLOCKS_PER_SEC)  << endl;
    
    // Compute the 2-norm error
    err = ComputeError(stress,stress_dir,Nf,&dof,m);
    cout << "Relative Error: "  << err << endl;
    
    /*******            Clean Up        *******/
    
    delete []stress;
    delete []stress_dir;
    delete []source;
    delete []field;
    delete []q;
    //delete []stress1;
    return 0;
}