当前位置: 首页>>代码示例>>C++>>正文


C++ H2DReader::load_str方法代码示例

本文整理汇总了C++中H2DReader::load_str方法的典型用法代码示例。如果您正苦于以下问题:C++ H2DReader::load_str方法的具体用法?C++ H2DReader::load_str怎么用?C++ H2DReader::load_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在H2DReader的用法示例。


在下文中一共展示了H2DReader::load_str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: create_mesh_space_forms

void ModuleBasic::create_mesh_space_forms() 
{
  /* SANITY CHECKS */

  // Consistency check of boundary conditions.
  this->bc_types.check_consistency();

  // Sanity check of material markers and material constants.
  this->materials_sanity_check();

  /* BEGIN THE COMPUTATION */

  // Load the mesh.
  H2DReader mloader;
  mloader.load_str(this->get_mesh_string(), this->mesh);

  // Clear the mesh string.
  this->clear_mesh_string();

  // Debug.
  /*
  MeshView m("", 0, 0, 400, 400);
  m.show(this->mesh);
  View::wait();
  */

  // Perform initial uniform mesh refinements.
  for (int i = 0; i < this->init_ref_num; i++) this->mesh->refine_all_elements();

  // Create an H1 space with default shapeset.
  this->space = new H1Space(this->mesh, &(this->bc_types), &(this->bc_values), this->init_p);
  int ndof = Space::get_num_dofs(this->space);
  info("ndof = %d", ndof);

  // Debug.
  /*
  BaseView b("", new WinGeom(0, 0, 400, 400));
  b.show(this->space);
  View::wait();
  */

  // Initialize the weak formulation.
  this->wf = new WeakForm();
  this->wf->add_matrix_form(callback(bilinear_form_vol));
  this->wf->add_vector_form(callback(linear_form_vol));
  for (unsigned int i=0; i < this->bdy_values_neumann.size(); i++) {
    this->wf->add_vector_form_surf(callback(linear_form_surf_neumann), this->bdy_markers_neumann[i]);
  }
  for (unsigned int i=0; i < this->bdy_values_newton.size(); i++) {
    this->wf->add_matrix_form_surf(callback(bilinear_form_surf_newton), this->bdy_markers_newton[i]);
    this->wf->add_vector_form_surf(callback(linear_form_surf_newton), this->bdy_markers_newton[i]);
  }
}
开发者ID:sajedi,项目名称:hermes,代码行数:53,代码来源:basic.cpp

示例2: main

int main(int argc, char* argv[])
{
  int ret = ERROR_FAILURE;

  if (argc < 2)
  {
    printf("please input as this format: <mesh type> <meshfile> [meshfiledump] \n");
    return ERROR_FAILURE;
  }

  char *mtype = argv[1];
  char *file_name = argv[2];
  char *file_name_dump = NULL;
  if (argc > 2)
    file_name_dump = argv[3];

  // load the mesh file
  Mesh mesh;
  MeshLoader *mloader = NULL;
  if (strcmp(mtype, "exII") == 0) mloader = new ExodusIIReader();
  else if (strcmp(mtype, "h2d") == 0) mloader = new H2DReader();
  else if (strcmp(mtype, "h2d-str") == 0) {
    // load the file into a string
    FILE *file = fopen(file_name , "rb");
    error_if(file == NULL, "unable to open file '%s'", file_name);

    // obtain file size:
    fseek(file, 0, SEEK_END);
    long size = ftell(file);
    rewind(file);

    // allocate memory to contain the whole file:
    char *buffer = (char *) malloc (sizeof(char) * size);
    error_if(buffer == NULL, "memory error");

    // copy the file into the buffer:
    size_t result = fread(buffer, 1, size, file);
    error_if(result != size, "reading error");

    fclose(file);

    //
    H2DReader *hloader = new H2DReader();
    hloader->load_str(buffer, &mesh);
    ret = dump_compare(mesh, file_name_dump);
    delete hloader;
    free(buffer);
    return ret;
  }
  else if (strcmp(mtype, "h2d-old") == 0) {
    H2DReader *hloader = new H2DReader();
    hloader->load_old(file_name, &mesh);
    ret = dump_compare(mesh, file_name_dump);
    delete hloader;
    return ret;
  }
  else {
    error("unknown mesh loader type");
  }

  if (mloader->load(file_name, &mesh))
  {
    ret = dump_compare(mesh, file_name_dump);
  }
  else
  {
    error("failed");
    ret = ERROR_FAILURE;
  }

  delete mloader;

  return ret;
}
开发者ID:MathPhys,项目名称:hermes2d,代码行数:74,代码来源:main.cpp


注:本文中的H2DReader::load_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。