//! Wipe out stored data.
 void clear()
 {
    set_x(Teuchos::null);
    set_dxdt(Teuchos::null);
    set_f(Teuchos::null);
    set_A(Teuchos::null);
 }
Exemple #2
0
void reset(void)
{
    debut = 1;

    set_f();
    set_abn();
    debut = 0;

    menu();
}
Exemple #3
0
int main(void)
{	
    titre("RESOLUTION NUMERIQUE D\'EQUATION DIFFERENTIELLE");

    info("On cherche à résoudre une équation différentielle\n\
            de la forme y\' = f(x,y) sur l\'intervalle [a,b] avec n points");

    info("Saisie des données:\n");
    set_f();
    set_abn();
    debut = 0;

    info("y0 = y(x0)  a été arbitrairement fixé à %d",y_zero);
    info("Choix de la méthode d'interpolation");
    menu();

    info("Bonne journée\n\n");

    return EXIT_SUCCESS;	
}
int main(int argc, char **argv)
{
  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &np);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  init();
  
  if(rank == 0)
    set_f();

  // distribute_f();
  MPI_Scatter(&f[rank * length], length, MPI_FLOAT, &f[begin], length , MPI_FLOAT, 0, 
MPI_COMM_WORLD);
  calc_g();
  // collect_g();
  MPI_Gather(&g[begin], length, MPI_FLOAT, &g[rank * length], length, MPI_FLOAT, 0, 
MPI_COMM_WORLD);  

  if(rank == 0)
    show_g();
  
  MPI_Finalize();
  return 0;
}
int param_get_copied_div1() {
  X x(1);
  set_f(x, 0); // this won't change x
  return 1 / x.f;
}
int ompi_attr_create_predefined(void)
{
    int ret;
    char *univ_size;
    int usize;

    /* Create all the keyvals */

    /* DO NOT CHANGE THE ORDER OF CREATING THESE KEYVALS!  This order
       strictly adheres to the order in mpi.h.  If you change the
       order here, you must change the order in mpi.h as well! */

    if (OMPI_SUCCESS != (ret = create_comm(MPI_TAG_UB, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_HOST, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_IO, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_WTIME_IS_GLOBAL, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_APPNUM, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_LASTUSEDCODE, false)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_UNIVERSE_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_BASE)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_SIZE)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_DISP_UNIT)) ||
#if 0
        /* JMS For when we implement IMPI */
        OMPI_SUCCESS != (ret = create_comm(IMPI_CLIENT_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_CLIENT_COLOR, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_HOST_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_HOST_COLOR, true)) ||
#endif
        0) {
        return ret;
    }

    /* Set default values for everything except MPI_UNIVERSE_SIZE */

    if (OMPI_SUCCESS != (ret = set_f(MPI_TAG_UB, mca_pml.pml_max_tag)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_HOST, MPI_PROC_NULL)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_IO, MPI_ANY_SOURCE)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_WTIME_IS_GLOBAL, 0)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_LASTUSEDCODE,
                                     ompi_mpi_errcode_lastused)) ||
#if 0
        /* JMS For when we implement IMPI */
        OMPI_SUCCESS != (ret = set(IMPI_CLIENT_SIZE,
                                   &attr_impi_client_size)) ||
        OMPI_SUCCESS != (ret = set(IMPI_CLIENT_COLOR,
                                   &attr_impi_client_color)) ||
        OMPI_SUCCESS != (ret = set(IMPI_HOST_SIZE,
                                   &attr_impi_host_size)) ||
        OMPI_SUCCESS != (ret = set(IMPI_HOST_COLOR,
                                   &attr_impi_host_color)) ||
#endif
        0) {
        return ret;
    }

    /* If the universe size is set, then use it. Otherwise default
     * to the size of MPI_COMM_WORLD */
    univ_size = getenv("OMPI_UNIVERSE_SIZE");
    if (NULL == univ_size || (usize = strtol(univ_size, NULL, 0)) <= 0) {
        ret = set_f(MPI_UNIVERSE_SIZE, ompi_comm_size(MPI_COMM_WORLD));
    } else {
        ret = set_f(MPI_UNIVERSE_SIZE, usize);
    }
    if (OMPI_SUCCESS != ret) {
        return ret;
    }
    
    /* check the app_num - if it was set, then define it - otherwise, don't */
    if (orte_process_info.app_num >= 0) {
        ret = set_f(MPI_APPNUM, orte_process_info.app_num);
    }
    
    return ret;
}
Exemple #7
0
// =============================================================================
void
testComputeF(
    const std::string & input_filename_base,
    const double mu,
    const double control_norm_1,
    const double control_norm_2,
    const double control_norm_inf
)
{
    // Read the data from the file.
    auto comm =  Teuchos::DefaultComm<int>::getComm();
    const int size = comm->getSize();
    const std::string input_filename = (size == 1) ?
                                       "data/" + input_filename_base + ".h5m" :
                                       "data/" + input_filename_base + "-" + std::to_string(size) + ".h5m"
                                       ;

    // Read the data from the file.
    auto mesh = nosh::read(input_filename);

    // Cast the data into something more accessible.
    auto z = mesh->get_complex_vector("psi");

    // Set the thickness field.
    auto thickness = std::make_shared<nosh::scalar_field::constant>(*mesh, 1.0);
    auto mvp = std::make_shared<nosh::vector_field::explicit_values>(*mesh, "A", mu);
    auto sp = std::make_shared<nosh::scalar_field::constant>(*mesh, -1.0);

    auto model_eval = Teuchos::rcp(new nosh::model_evaluator::nls(
                                       mesh,
                                       mvp,
                                       sp,
                                       1.0,
                                       thickness,
                                       z,
                                       "mu"
                                   ));

    // Create in_args.x
    auto in_args = model_eval->createInArgs();
    in_args.set_x(Thyra::createVector(Teuchos::rcp(z), model_eval->get_f_space()));
    // in_args.p
    auto p = Thyra::createMember(model_eval->get_p_space(0));
    Thyra::set_ele(0, 1.0, p()); // g
    Thyra::set_ele(1, 0.01, p()); // mu
    in_args.set_p(0, p);

    // Create out_args.
    auto out_args = model_eval->createOutArgs();
    auto f = Thyra::createMember(model_eval->get_f_space());
    out_args.set_f(f);

    // Fetch.
    model_eval->evalModel(in_args, out_args);

    // check the norms
    REQUIRE(Thyra::norm_1(*f) == Approx(control_norm_1));
    REQUIRE(Thyra::norm_2(*f) == Approx(control_norm_2));
    REQUIRE(Thyra::norm_inf(*f) == Approx(control_norm_inf));

    return;
}
void MainWindow::choose_file_button_clicked()
{   try {
        QString fileName = QFileDialog::getOpenFileName(this,QString::fromUtf8("Choose File"),QDir::currentPath(),"Text(*.txt)");
        if (fileName.length() != 0) {
            // ДАЛЕЕ ОЧИСТКА ЗНАЧЕНИЙ!!!
            clear_data();
            clear_lines();

            ui->fileName->setText(fileName);
            QFile my_file(fileName);
            my_file.open(QIODevice::ReadOnly);
            if (my_file.isOpen())
                while (!my_file.atEnd()) {
                    QString exmpl = changeOnDoTA(my_file.readLine());
                    double obj = exmpl.toDouble();
                    started_data.push_back(obj);
                }

            try {

                set_average_data();

               // qDebug() << max_x << " " << min_x;
                set_square_deviation();
                set_Sx();
    //            for (int i = 0; i < started_data.size(); i++)
    //                qDebug() << started_data[i];
                set_r(); //  КИДАЕТ ВНУТРЕННИЙ ЭКСЕПШЕН!
                set_h();

                fill_intervals();
                set_f();
                set_middle_value();
                set_middle_value2();
                set_average_of_intervals();
                set_si();
                set_n_i();
                set_xi_sq();

                choose_quantile();

//                qDebug() << "BEgin";
//                for (int i = 0;i < started_data.size();i++)
//                    qDebug() << started_data[i];
//                qDebug() << "END";

                set_lines();
                for (int i = 0; i < intervals.size();i++) {
                    for (int j = 0; j < intervals[i].size();j++)
                        qDebug() << intervals[i][j];
                    qDebug() << "end_line";
                }

              //  check_result();

                is_chButton_clicked_flag = true;
                my_file.close();
            } catch(std::exception &e){
                clear_data();
                clear_lines();
                is_chButton_clicked_flag = false;
                QMessageBox::critical(this,"Not Valid!!!",e.what());
            }
        }
        else {
            throw (std::invalid_argument("Choose txt File!"));
        }
    } catch(std::exception& e) {
        clear_data();
        clear_lines();
        is_chButton_clicked_flag = false;
       // QMessageBox::critical(this, "Error!",e.what());
    }

}