예제 #1
0
파일: rmhd.cpp 프로젝트: darien0/Mara
int Rmhd::ConsToPrim(const double *U, double *P) const
{
  int error = 1;

  // This piece of code drives cons to prim inversions for an arbitrary equation
  // of state.
  // ---------------------------------------------------------------------------
  if (typeid(*EOS) != typeid(AdiabaticEos)) {

    rmhd_c2p_eos_set_eos(EOS);
    rmhd_c2p_eos_new_state(U);

    if (error) {
      rmhd_c2p_eos_set_starting_prim(P);
      error = rmhd_c2p_eos_solve_noble2dzt(P);
    }
    if (error) {
      //      printf("c2p failed once. using reset.\n");
      rmhd_c2p_eos_estimate_from_cons();
      error = rmhd_c2p_eos_solve_noble2dzt(P);
    }
    if (error) {
      //      printf("c2p failed twice. using duffell3d.\n");
      rmhd_c2p_eos_set_starting_prim(P);
      error = rmhd_c2p_eos_solve_duffell3d(P);
    }

    return error;
  }

  // This piece of code drives cons to prim inversions for a gamma-law equation
  // of state.
  // ---------------------------------------------------------------------------
  rmhd_c2p_set_gamma(Mara->GetEos<AdiabaticEos>().Gamma);
  rmhd_c2p_new_state(U);

  if (error) {
    rmhd_c2p_set_starting_prim(P);
    error = rmhd_c2p_solve_anton2dzw(P);
  }
  if (error) {
    rmhd_c2p_estimate_from_cons();
    error = rmhd_c2p_solve_anton2dzw(P);
  }
  if (error) {
    rmhd_c2p_set_starting_prim(P);
    error = rmhd_c2p_solve_noble1dw(P);
  }
  if (error) {
    rmhd_c2p_estimate_from_cons();
    error = rmhd_c2p_solve_noble1dw(P);
  }

  return error;
}
예제 #2
0
파일: rmhd.cpp 프로젝트: jzrake/ctf
int Rmhd::ConsToPrim(const double *U, double *P) const
{
  int error = rmhd_c2p_check_cons(U);

  if (error) {
    fprintf(stderr, "[0] %s\n", rmhd_c2p_get_error(error));
    std::cerr << PrintCons(U) << std::endl;
    return error;
  }
  else {
    error = 1;
  }

  // This piece of code drives cons to prim inversions for an arbitrary equation
  // of state.
  // ---------------------------------------------------------------------------
  if (typeid(*EOS) != typeid(AdiabaticEos)) {

    rmhd_c2p_eos_set_eos(EOS);
    rmhd_c2p_eos_new_state(U);

    //    std::cout << PrintPrim(P) << std::endl;
    //    std::cout << PrintCons(U) << std::endl;

    if (error) {
      rmhd_c2p_eos_set_starting_prim(P);
      error = rmhd_c2p_eos_solve_duffell3d(P);
    }
    if (error) {

      // NOTE: disregarding further c2p trials for debugging purposes
      return error;
      // ------------------------------------------------------------

      rmhd_c2p_eos_set_starting_prim(P);
      error = rmhd_c2p_eos_solve_noble2dzt(P);
    }
    if (error) {
      rmhd_c2p_eos_estimate_from_cons();
      error = rmhd_c2p_eos_solve_noble2dzt(P);
    }

    return error;
  }

  // This piece of code drives cons to prim inversions for a gamma-law equation
  // of state.
  // ---------------------------------------------------------------------------
  rmhd_c2p_set_gamma(Mara->GetEos<AdiabaticEos>().Gamma);
  rmhd_c2p_new_state(U);

  if (error) {
    rmhd_c2p_estimate_from_cons();
    error = rmhd_c2p_solve_anton2dzw(P);
    //    if (error) fprintf(stderr, "[1] %s\n", rmhd_c2p_get_error(error));
  }
  if (error) {
    rmhd_c2p_set_starting_prim(P);
    error = rmhd_c2p_solve_anton2dzw(P);
    //    if (error) fprintf(stderr, "[2] %s\n", rmhd_c2p_get_error(error));
  }
  if (error) {
    rmhd_c2p_estimate_from_cons();
    error = rmhd_c2p_solve_noble1dw(P);
    //    if (error) fprintf(stderr, "[3] %s\n", rmhd_c2p_get_error(error));
  }
  if (error) {
    rmhd_c2p_set_starting_prim(P);
    error = rmhd_c2p_solve_noble1dw(P);
    //    if (error) fprintf(stderr, "[4] %s\n", rmhd_c2p_get_error(error));
  }

  return error;
}