Example #1
0
void integrate_2mnp(const double tau, const int S, const int halfstep) {
    int i;
    integrator * itgr = &Integrator;
    double eps = tau/((double)itgr->n_int[S]);
    double oneminus2lambda = (1.-2.*itgr->lambda[S]);

    if(S == 0) {
        update_gauge(itgr->lambda[0]*eps, &itgr->hf);
        for(i = 1; i < itgr->n_int[0]; i++) {
            update_momenta(itgr->mnls_per_ts[0], 0.5*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge(oneminus2lambda*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], 0.5*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge(2*itgr->lambda[0]*eps, &itgr->hf);
        }
        update_momenta(itgr->mnls_per_ts[0], 0.5*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge(oneminus2lambda*eps, &itgr->hf);
        update_momenta(itgr->mnls_per_ts[0], 0.5*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge(itgr->lambda[0]*eps, &itgr->hf);
    }
    else {
        for(i = 0; i < itgr->n_int[S]; i++) {
            integrate_2mnp(itgr->lambda[S]*eps, S-1, halfstep);
            update_momenta(itgr->mnls_per_ts[S], 0.5*eps, itgr->no_mnls_per_ts[S], &itgr->hf);

            integrate_2mnp(oneminus2lambda*eps, S-1, halfstep);
            update_momenta(itgr->mnls_per_ts[S], 0.5*eps, itgr->no_mnls_per_ts[S], &itgr->hf);

            integrate_2mnp(itgr->lambda[S]*eps, S-1, halfstep);
        }
    }
}
Example #2
0
void LF_inner_update(const int n2, const double tau) {
  int j;
  double dtau = tau/((double)n2);
  
  update_momenta_gauge(0.5*dtau);

  for(j = 1; j < n2; j++) {
    update_gauge(dtau);
    update_momenta_gauge(dtau);
  }
  update_gauge(dtau);

  update_momenta_gauge(0.5*dtau);
  return;
}
Example #3
0
void integrate_2mn(const double tau, const int S, const int halfstep) {
    int i,j=0;
    integrator * itgr = &Integrator;
    double eps,
           oneminus2lambda = (1.-2.*itgr->lambda[S]);

    if(S == itgr->no_timescales-1) {
        dohalfstep(tau, S);
    }

    eps = tau/((double)itgr->n_int[S]);
    if(S == 0) {

        for(j = 1; j < itgr->n_int[0]; j++) {
            update_gauge(0.5*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], oneminus2lambda*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge(0.5*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], 2.*itgr->lambda[0]*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        }
        update_gauge(0.5*eps, &itgr->hf);
        update_momenta(itgr->mnls_per_ts[0], oneminus2lambda*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge(0.5*eps, &itgr->hf);
        if(halfstep != 1) {
            update_momenta(itgr->mnls_per_ts[0], 2*itgr->lambda[0]*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        }
    }
    else {
        for(i = 1; i < itgr->n_int[S]; i++) {
            itgr->integrate[S-1](eps/2., S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], oneminus2lambda*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
            itgr->integrate[S-1](eps/2., S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], 2*itgr->lambda[S]*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        }
        itgr->integrate[S-1](eps/2., S-1, 0);
        update_momenta(itgr->mnls_per_ts[S], oneminus2lambda*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        if(S == itgr->no_timescales-1) {
            itgr->integrate[S-1](eps/2., S-1, 1);
        }
        else itgr->integrate[S-1](eps/2., S-1, halfstep);
        if(halfstep != 1 && S != itgr->no_timescales-1) {
            update_momenta(itgr->mnls_per_ts[S], 2*itgr->lambda[S]*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        }
    }

    if(S == itgr->no_timescales-1) {
        dohalfstep(tau, S);
    }
}
Example #4
0
void
mux_dialog::on_output_available(wxCommandEvent &evt) {
    wxString line = evt.GetString();

    log += line;
    if (line.Right(1) != wxT("\r"))
        log += wxT("\n");

    if (line.Find(Z("Warning:")) == 0)
        tc_warnings->AppendText(line + wxT("\n"));

    else if (line.Find(Z("Error:")) == 0)
        tc_errors->AppendText(line + wxT("\n"));

    else if (line.Find(Z("Progress")) == 0) {
        if (line.Find(wxT("%")) != 0) {
            line.Remove(line.Find(wxT("%")));
            auto tmp   = line.AfterLast(wxT(' '));
            long value = 0;
            tmp.ToLong(&value);
            if ((value >= 0) && (value <= 100))
                update_gauge(value);
        }

    } else if (line.Length() > 0)
        tc_output->AppendText(line + wxT("\n"));

    update_remaining_time();
}
Example #5
0
/*  leap frog */
void leapfrog(const int nsteps, const double dtau) {
  int l;

  /* first phase: \Delta\Tau / 2 step for p */
  update_momenta(0.5*dtau); 

  /*  second phase: iterate with steps of \Delta\Tau */
  for(l = 0; l < nsteps-1; l++) {
    update_gauge(dtau);
    update_momenta(dtau);
  }
  /* a last one for the fields (because N steps for fields, */
  /*      and N-1 steps for impulses) */
  update_gauge(dtau);

  /*  last phase: \Delta\Tau / 2 step for p */
  update_momenta(dtau*0.5);
}
Example #6
0
void integrate_leap_frog(const double tau, const int S, const int halfstep) {
    int i;
    integrator * itgr = &Integrator;
    double eps, eps0;

    if(S == itgr->no_timescales-1) {
        dohalfstep(tau, S);
    }

    eps = tau/((double)itgr->n_int[S]);
    if(S == 0) {
        eps0 = tau/((double)itgr->n_int[0]);
        for(i = 1; i < itgr->n_int[0]; i++) {
            update_gauge(eps0, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], eps0, itgr->no_mnls_per_ts[0], &itgr->hf);
        }
        update_gauge(eps0, &itgr->hf);
        if(halfstep != 1) {
            update_momenta(itgr->mnls_per_ts[0], eps0, itgr->no_mnls_per_ts[0], &itgr->hf);
        }
    }
    else {
        for(i = 1; i < itgr->n_int[S]; i++) {
            itgr->integrate[S-1](eps, S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        }
        if(S == itgr->no_timescales-1) {
            itgr->integrate[S-1](eps, S-1, 1);
        }
        else itgr->integrate[S-1](eps, S-1, halfstep);
        if(halfstep != 1 && S != itgr->no_timescales-1) {
            update_momenta(itgr->mnls_per_ts[S], eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        }
    }

    if(S == itgr->no_timescales-1) {
        dohalfstep(tau, S);
    }
}
void
scanning_for_playlists_dlg::on_progress_changed(wxCommandEvent &evt) {
  update_gauge(evt.GetInt());

  uint64_t now = get_current_time_millis();

  if ((0 == m_progress) || (now < m_next_remaining_time_update))
    return;

  int64_t total_time     = (now - m_start_time) * m_max_progress / m_progress;
  int64_t remaining_time = total_time - now + m_start_time;
  m_st_remaining_time->SetLabel(wxU(create_minutes_seconds_time_string(static_cast<unsigned int>(remaining_time / 1000))));

  m_next_remaining_time_update = now + 500;
}
Example #8
0
update_gauge_t instrumentation::add_gauge(const std::string service,
                                        const std::string description)
{

  CHECK(gauges_id_.load() < k_max_gauges) << "max number of gauges reached";

  int id = gauges_id_.fetch_add(1);

  gauges_[id].service = service;
  gauges_[id].description = description;

  return {
    [=](const unsigned int v) { update_gauge(id, v);  },
    [=](const unsigned int v) { incr_gauge(id, v);  },
    [=](const unsigned int v) { decr_gauge(id, v);  }
  };

}
Example #9
0
void
mux_dialog::on_output_available(wxCommandEvent &evt) {
  wxString line = evt.GetString();

  log += line;
  if (line.Right(1) != wxT("\r"))
    log += wxT("\n");

  if (line.Find(Z("Warning:")) == 0)
    tc_warnings->AppendText(line + wxT("\n"));

  else if (line.Find(Z("Error:")) == 0)
    tc_errors->AppendText(line + wxT("\n"));

  else if (line.Find(wxT("#GUI#begin_scanning_playlists")) == 0)
    m_scanning_playlists = true;

  else if (line.Find(wxT("#GUI#end_scanning_playlists")) == 0) {
    m_scanning_playlists         = false;

    m_start_time                 = mtx::sys::get_current_time_millis();
    m_next_remaining_time_update = m_start_time + 8000;

  } else if (line.Find(wxT("#GUI#progress ")) == 0) {
    if (line.Find(wxT("%")) != 0) {
      line.Remove(line.Find(wxT("%")));
      auto tmp   = line.AfterLast(wxT(' '));
      long value = 0;
      tmp.ToLong(&value);
      if ((value >= 0) && (value <= 100))
        update_gauge(value);
    }

  } else if (line.Length() > 0)
    tc_output->AppendText(line + wxT("\n"));

  update_remaining_time();
}
Example #10
0
mux_dialog::mux_dialog(wxWindow *parent):
    wxDialog(parent, -1, Z("mkvmerge is running"), wxDefaultPosition,
#ifdef SYS_WINDOWS
             wxSize(700, 560),
#else
             wxSize(700, 520),
#endif
             wxDEFAULT_FRAME_STYLE)
#if defined(SYS_WINDOWS)
    , pid(0)
    , m_taskbar_progress(NULL)
    , m_abort_button_changed(false)
#endif  // SYS_WINDOWS
    , m_exit_code(0)
    , m_progress(0)
{
    char c;
    std::string arg_utf8, line;
    long value;
    wxString wx_line, tmp;
    wxInputStream *out;
    wxFile *opt_file;
    uint32_t i;
    wxArrayString *arg_list;
    wxBoxSizer *siz_all, *siz_buttons, *siz_line;
    wxStaticBoxSizer *siz_status, *siz_output;

    m_window_disabler = new wxWindowDisabler(this);

    c = 0;
    siz_status = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Status and progress")), wxVERTICAL);
    st_label = new wxStaticText(this, -1, wxEmptyString);
    st_remaining_time_label = new wxStaticText(this, -1, Z("Remaining time:"));
    st_remaining_time       = new wxStaticText(this, -1, Z("is being estimated"));
    siz_line = new wxBoxSizer(wxHORIZONTAL);
    siz_line->Add(st_label);
    siz_line->AddSpacer(5);
    siz_line->Add(st_remaining_time_label);
    siz_line->AddSpacer(5);
    siz_line->Add(st_remaining_time);
    siz_status->Add(siz_line, 0, wxGROW | wxALIGN_LEFT | wxALL, 5);
    g_progress = new wxGauge(this, -1, 100, wxDefaultPosition, wxSize(250, 15));
    siz_status->Add(g_progress, 1, wxALL | wxGROW, 5);

    siz_output = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Output")), wxVERTICAL);
    siz_output->Add(new wxStaticText(this, -1, Z("mkvmerge output:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_output = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_output, 2, wxGROW | wxALL, 5);
    siz_output->Add(new wxStaticText(this, -1, Z("Warnings:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_warnings = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_warnings, 1, wxGROW | wxALL, 5);
    siz_output->Add(new wxStaticText(this, -1, Z("Errors:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_errors = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_errors, 1, wxGROW | wxALL, 5);

    siz_buttons = new wxBoxSizer(wxHORIZONTAL);
    siz_buttons->AddStretchSpacer();
    b_ok = new wxButton(this, ID_B_MUX_OK, Z("Ok"));
    b_ok->Enable(false);
    siz_buttons->Add(b_ok, 0, wxGROW);
    siz_buttons->AddStretchSpacer();
    b_abort = new wxButton(this, ID_B_MUX_ABORT, Z("Abort"));
    siz_buttons->Add(b_abort, 0, wxGROW);
    siz_buttons->AddStretchSpacer();
    b_save_log = new wxButton(this, ID_B_MUX_SAVELOG, Z("Save log"));
    siz_buttons->Add(b_save_log, 0, wxGROW);
    siz_buttons->AddStretchSpacer();

    siz_all = new wxBoxSizer(wxVERTICAL);
    siz_all->Add(siz_status, 0, wxGROW | wxALL, 5);
    siz_all->Add(siz_output, 1, wxGROW | wxALL, 5);
    siz_all->Add(siz_buttons, 0, wxGROW | wxALL, 10);
    SetSizer(siz_all);

    update_window(Z("Muxing in progress."));
    Show(true);

    process = new mux_process(this);

    opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), get_temp_dir().c_str(), (int)wxGetProcessId(), (int)wxGetUTCTime());
    try {
        const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
        opt_file = new wxFile(opt_file_name, wxFile::write);
        opt_file->Write(utf8_bom, 3);
    } catch (...) {
        wxString error;
        error.Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."), opt_file_name.c_str(), errno, wxUCS(strerror(errno)));
        wxMessageBox(error, Z("File creation failed"), wxOK | wxCENTER | wxICON_ERROR);
        throw 0;
    }
    arg_list = &static_cast<mmg_dialog *>(parent)->get_command_line_args();
    for (i = 1; i < arg_list->Count(); i++) {
        if ((*arg_list)[i].Length() == 0)
            opt_file->Write(wxT("#EMPTY#"));
        else {
            arg_utf8 = escape(wxMB((*arg_list)[i]));
            opt_file->Write(arg_utf8.c_str(), arg_utf8.length());
        }
        opt_file->Write(wxT("\n"));
    }
    delete opt_file;

#if defined(SYS_WINDOWS)
    if (get_windows_version() >= WINDOWS_VERSION_7) {
        m_taskbar_progress = new taskbar_progress_c(mdlg);
        m_taskbar_progress->set_state(TBPF_NORMAL);
        m_taskbar_progress->set_value(0, 100);
    }
#endif  // SYS_WINDOWS

    m_start_time                 = get_current_time_millis();
    m_next_remaining_time_update = m_start_time + 8000;

    wxString command_line = wxString::Format(wxT("\"%s\" \"@%s\""), (*arg_list)[0].c_str(), opt_file_name.c_str());
    pid = wxExecute(command_line, wxEXEC_ASYNC, process);
    if (0 == pid) {
        wxLogError(wxT("Execution of '%s' failed."), command_line.c_str());
        done(2);
        return;
    }
    out = process->GetInputStream();

    line = "";
    log = wxEmptyString;
    while (1) {
        while (app->Pending())
            app->Dispatch();

        if (!out->CanRead() && !out->Eof()) {
            wxMilliSleep(5);
            continue;
        }

        if (!out->Eof())
            c = out->GetC();
        else
            c = '\n';

        if ((c == '\n') || (c == '\r') || out->Eof()) {
            wx_line = wxU(line);
            log += wx_line;
            if (c != '\r')
                log += wxT("\n");
            if (wx_line.Find(Z("Warning:")) == 0)
                tc_warnings->AppendText(wx_line + wxT("\n"));
            else if (wx_line.Find(Z("Error:")) == 0)
                tc_errors->AppendText(wx_line + wxT("\n"));
            else if (wx_line.Find(Z("Progress")) == 0) {
                if (wx_line.Find(wxT("%")) != 0) {
                    wx_line.Remove(wx_line.Find(wxT("%")));
                    tmp = wx_line.AfterLast(wxT(' '));
                    tmp.ToLong(&value);
                    if ((value >= 0) && (value <= 100))
                        update_gauge(value);
                }
            } else if (wx_line.Length() > 0)
                tc_output->AppendText(wx_line + wxT("\n"));
            line = "";

            update_remaining_time();

        } else if ((unsigned char)c != 0xff)
            line += c;

        if (out->Eof())
            break;
    }
}
Example #11
0
void integrate_omf4(const double tau, const int S, const int halfstep) {
    int i,j=0;
    integrator * itgr = &Integrator;
    double eps;

    if(S == itgr->no_timescales-1) {
        dohalfstep(tau, S);
    }
    eps = tau/((double)itgr->n_int[S]);

    if(S == 0) {

        for(j = 1; j < itgr->n_int[0]; j++) {
            update_gauge(omf4_rho*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], omf4_lamb*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge(omf4_theta*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge((1-2.*(omf4_theta+omf4_rho))*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge(omf4_theta*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], omf4_lamb*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
            update_gauge(omf4_rho*eps, &itgr->hf);
            update_momenta(itgr->mnls_per_ts[0], 2*omf4_vartheta*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        }
        update_gauge(omf4_rho*eps, &itgr->hf);
        update_momenta(itgr->mnls_per_ts[0], omf4_lamb*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge(omf4_theta*eps, &itgr->hf);
        update_momenta(itgr->mnls_per_ts[0], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge((1-2.*(omf4_theta+omf4_rho))*eps, &itgr->hf);
        update_momenta(itgr->mnls_per_ts[0], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge(omf4_theta*eps, &itgr->hf);
        update_momenta(itgr->mnls_per_ts[0], omf4_lamb*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        update_gauge(omf4_rho*eps, &itgr->hf);
        if(halfstep != 1) {
            update_momenta(itgr->mnls_per_ts[0], 2*omf4_vartheta*eps, itgr->no_mnls_per_ts[0], &itgr->hf);
        }
    }
    else {
        for(i = 1; i < itgr->n_int[S]; i++) {
            itgr->integrate[S-1](omf4_rho*eps, S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], omf4_lamb*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
            itgr->integrate[S-1](omf4_theta*eps, S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
            itgr->integrate[S-1]((1-2.*(omf4_theta+omf4_rho))*eps, S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
            itgr->integrate[S-1](omf4_theta*eps, S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], omf4_lamb*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
            itgr->integrate[S-1](omf4_rho*eps, S-1, 0);
            update_momenta(itgr->mnls_per_ts[S], 2*omf4_vartheta*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        }
        itgr->integrate[S-1](omf4_rho*eps, S-1, 0);
        update_momenta(itgr->mnls_per_ts[S], omf4_lamb*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        itgr->integrate[S-1](omf4_theta*eps, S-1, 0);
        update_momenta(itgr->mnls_per_ts[S], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        itgr->integrate[S-1]((1-2.*(omf4_theta+omf4_rho))*eps, S-1, 0);
        update_momenta(itgr->mnls_per_ts[S], 0.5*(1-2.*(omf4_lamb+omf4_vartheta))*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        itgr->integrate[S-1](omf4_theta*eps, S-1, 0);
        update_momenta(itgr->mnls_per_ts[S], omf4_lamb*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        if(S == itgr->no_timescales-1) {
            itgr->integrate[S-1](omf4_rho*eps, S-1, 1);
        }
        else itgr->integrate[S-1](omf4_rho*eps, S-1, halfstep);
        if(halfstep != 1 && S != itgr->no_timescales-1) {
            update_momenta(itgr->mnls_per_ts[S], 2*omf4_vartheta*eps, itgr->no_mnls_per_ts[S], &itgr->hf);
        }
    }

    if(S == itgr->no_timescales-1) {
        dohalfstep(tau, S);
    }
    return;
}