Esempio n. 1
0
std::string Exo_Entity::Load_Results(int time_step, int var_index)
{
  SMART_ASSERT(Check_State());

  if (fileId < 0)
    return "exodiff: ERROR:  Invalid file id!";
  if (id_ == EX_INVALID_ID)
    return "exodiff: ERROR:  Must initialize block parameters first!";
  if (var_index < 0 || var_index >= numVars) {
    ERROR("Exo_Entity::Load_Results(): var_index is invalid. Aborting...\n");
    exit(1);
  }
  SMART_ASSERT(time_step >= 1 && time_step <= (int)get_num_timesteps(fileId));

  if (time_step != currentStep) {
    Free_Results();
    currentStep = time_step;
  }

  if (truth_ == nullptr) {
    get_truth_table();
  }

  if (truth_[var_index]) {
    if (!results_[var_index] && numEntity) {
      results_[var_index] = new double[numEntity];
      SMART_ASSERT(results_[var_index] != nullptr);
    }
    if (numEntity) {
      int err = 0;
      err     = ex_get_var(fileId, time_step, exodus_type(), var_index + 1, id_, numEntity,
                       results_[var_index]);

      if (err < 0) {
        ERROR("Exo_Entity::Load_Results(): Call to exodus routine"
              << " returned error value! " << label() << " id = " << id_ << '\n'
              << "Aborting...\n");
        exit(1);
      }
      else if (err > 0) {
        std::ostringstream oss;
        oss << "WARNING:  Number " << err << " returned from call to exodus get variable routine.";
        return oss.str();
      }
    }
    else
      return std::string("WARNING:  No items in this ") + label();
  }
  else {
    return std::string("WARNING: Variable not stored in this ") + label();
  }
  return "";
}
Esempio n. 2
0
int main() {
    // Model, Domain and Boundary
    const auto flow = std::make_unique<Flow>("Couette3D");
    const auto lbmodel = flow->get_lbmodel();
    const auto domain = flow->get_domain();
    const auto boundary = flow->get_boundary();

    // Define problem and its data
    const auto problem = std::make_unique<PLBPD>(lbmodel, domain, boundary);
    auto simdata =
        SimData(domain->get_dimensions(), lbmodel->get_num_directions());

    // Solve problem
    problem->initialize(simdata);
    simdata.write_state("init_state.h5");
    problem->march_in_time(flow->get_num_timesteps(), simdata);
    simdata.write_state("final_state.h5");
    problem->print_times();
}
Esempio n. 3
0
std::string Exo_Entity::Load_Results(int t1, int t2, double proportion, int var_index)
{
  static std::vector<double> results2;

  SMART_ASSERT(Check_State());

  if (fileId < 0)
    return "exodiff: ERROR:  Invalid file id!";
  if (id_ == EX_INVALID_ID)
    return "exodiff: ERROR:  Must initialize block parameters first!";
  SMART_ASSERT(var_index >= 0 && var_index < numVars);
  SMART_ASSERT(t1 >= 1 && t1 <= (int)get_num_timesteps(fileId));
  SMART_ASSERT(t2 >= 1 && t2 <= (int)get_num_timesteps(fileId));

  if (t1 != currentStep) {
    Free_Results();
    currentStep = t1;
  }

  if (truth_ == nullptr) {
    get_truth_table();
  }

  if (truth_[var_index]) {
    if (!results_[var_index] && numEntity) {
      results_[var_index] = new double[numEntity];
      SMART_ASSERT(results_[var_index] != nullptr);
    }
    if (numEntity) {
      int err =
          ex_get_var(fileId, t1, exodus_type(), var_index + 1, id_, numEntity, results_[var_index]);

      if (err < 0) {
        ERROR("Exo_Entity::Load_Results(): Call to exodus routine"
              << " returned error value! " << label() << " id = " << id_ << '\n'
              << "Aborting...\n");
        exit(1);
      }
      else if (err > 0) {
        std::ostringstream oss;
        oss << "WARNING:  Number " << err << " returned from call to exodus get variable routine.";
        return oss.str();
      }

      if (t1 != t2) {
        results2.resize(numEntity);
        err = ex_get_var(fileId, t2, exodus_type(), var_index + 1, id_, numEntity, &results2[0]);

        if (err < 0) {
          ERROR("Exo_Entity::Load_Results(): Call to exodus routine"
                << " returned error value! " << label() << " id = " << id_ << '\n'
                << "Aborting...\n");
          exit(1);
        }

        double *results1 = results_[var_index];
        for (size_t i = 0; i < numEntity; i++) {
          results1[i] = (1.0 - proportion) * results1[i] + proportion * results2[i];
        }
      }
    }
    else
      return std::string("WARNING:  No items in this ") + label();
  }
  else {
    return std::string("WARNING: Variable not stored in this ") + label();
  }
  return "";
}