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


C++ EquationSystems::init方法代码示例

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


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

示例1: setUp

  void setUp()
  {
    this->build_mesh();

    // libMesh *should* renumber now, or a ParallelMesh might not have
    // contiguous ids, which is a requirement to write xda files.
    _mesh->allow_renumbering(true);

    _es = new EquationSystems(*_mesh);
    _sys = &_es->add_system<System> ("SimpleSystem");
    _sys->add_variable("u", FIRST);

    _es->init();
    SlitFunc slitfunc;
    _sys->project_solution(&slitfunc);

#ifdef LIBMESH_ENABLE_AMR
    MeshRefinement(*_mesh).uniformly_refine(1);
    _es->reinit();
    MeshRefinement(*_mesh).uniformly_refine(1);
    _es->reinit();
#endif
  }
开发者ID:coreymbryant,项目名称:libmesh,代码行数:23,代码来源:slit_mesh_test.C

示例2: setup

void setup(EquationSystems& systems, Mesh& mesh, GetPot& args)
{
    const unsigned int dim = mesh.mesh_dimension();
    // We currently invert tensors with the assumption that they're 3x3
    libmesh_assert (dim == 3);

    // Generating Mesh
    ElemType eltype = Utility::string_to_enum<ElemType>(args("mesh/generation/element_type", "hex8"));
    int nx = args("mesh/generation/num_elem", 4, 0);
    int ny = args("mesh/generation/num_elem", 4, 1);
    int nz = dim > 2 ? args("mesh/generation/num_elem", 4, 2) : 0;
    double origx = args("mesh/generation/origin", -1.0, 0);
    double origy = args("mesh/generation/origin", -1.0, 1);
    double origz = args("mesh/generation/origin", 0.0, 2);
    double sizex = args("mesh/generation/size", 2.0, 0);
    double sizey = args("mesh/generation/size", 2.0, 1);
    double sizez = args("mesh/generation/size", 2.0, 2);
    MeshTools::Generation::build_cube(mesh, nx, ny, nz,
                                      origx, origx+sizex, origy, origy+sizey, origz, origz+sizez, eltype);

    // Creating Systems
    SolidSystem& imms = systems.add_system<SolidSystem> ("solid");
    imms.args = args;

    // Build up auxiliary system
    ExplicitSystem& aux_sys = systems.add_system<TransientExplicitSystem>("auxiliary");

    // Initialize the system
    systems.parameters.set<unsigned int>("phase") = 0;
    systems.init();

    imms.save_initial_mesh();

    // Fill global solution vector from local ones
    aux_sys.reinit();
}
开发者ID:phcao,项目名称:libmesh,代码行数:36,代码来源:fem_system_ex2.C

示例3: main

int main (int argc, char** argv)
{
  LibMeshInit init(argc, argv);

  if (argc < 4)
    libMesh::out << "Usage: ./prog -d DIM filename" << std::endl;

  // Variables to get us started
  const unsigned int dim = atoi(argv[2]);

  std::string meshname  (argv[3]);

  // declare a mesh...
  Mesh mesh(init.comm(), dim);

  // Read a mesh
  mesh.read(meshname);

  GMVIO(mesh).write ("out_0.gmv");

  mesh.elem(0)->set_refinement_flag (Elem::REFINE);

  MeshRefinement mesh_refinement (mesh);

  mesh_refinement.refine_and_coarsen_elements ();
  mesh_refinement.uniformly_refine (2);

  mesh.print_info();


  // Set up the equation system(s)
  EquationSystems es (mesh);

  LinearImplicitSystem& primary =
    es.add_system<LinearImplicitSystem>("primary");

  primary.add_variable ("U", FIRST);
  primary.add_variable ("V", FIRST);

  primary.get_dof_map()._dof_coupling->resize(2);
  (*primary.get_dof_map()._dof_coupling)(0,0) = 1;
  (*primary.get_dof_map()._dof_coupling)(1,1) = 1;

  primary.attach_assemble_function(assemble);

  es.init ();

  es.print_info ();
  primary.get_dof_map().print_dof_constraints ();

  // call the solver.
  primary.solve ();

  GMVIO(mesh).write_equation_systems ("out_1.gmv",
                                      es);



  // Refine uniformly
  mesh_refinement.uniformly_refine (1);
  es.reinit ();

  // Write out the projected solution
  GMVIO(mesh).write_equation_systems ("out_2.gmv",
                                      es);

  // Solve again. Output the refined solution
  primary.solve ();
  GMVIO(mesh).write_equation_systems ("out_3.gmv",
                                      es);

  return 0;
}
开发者ID:GENGCHN,项目名称:libmesh,代码行数:73,代码来源:amr.C

示例4: assemble_and_solve

void assemble_and_solve(MeshBase & mesh,
                        EquationSystems & equation_systems)
{
  mesh.print_info();

  LinearImplicitSystem & system =
    equation_systems.add_system<LinearImplicitSystem> ("Poisson");

  unsigned int u_var = system.add_variable("u", FIRST, LAGRANGE);

  system.attach_assemble_function (assemble_poisson);

  // the cube has boundaries IDs 0, 1, 2, 3, 4 and 5
  std::set<boundary_id_type> boundary_ids;
  for (int j = 0; j<6; ++j)
    boundary_ids.insert(j);

  // Create a vector storing the variable numbers which the BC applies to
  std::vector<unsigned int> variables(1);
  variables[0] = u_var;

  ZeroFunction<> zf;
  DirichletBoundary dirichlet_bc(boundary_ids,
                                 variables,
                                 &zf);
  system.get_dof_map().add_dirichlet_boundary(dirichlet_bc);

  equation_systems.init();
  equation_systems.print_info();

#ifdef LIBMESH_ENABLE_AMR
  MeshRefinement mesh_refinement(mesh);

  mesh_refinement.refine_fraction()  = 0.7;
  mesh_refinement.coarsen_fraction() = 0.3;
  mesh_refinement.max_h_level()      = 5;

  const unsigned int max_r_steps = 2;

  for (unsigned int r_step=0; r_step<=max_r_steps; r_step++)
    {
      system.solve();
      if (r_step != max_r_steps)
        {
          ErrorVector error;
          KellyErrorEstimator error_estimator;

          error_estimator.estimate_error(system, error);

          libMesh::out << "Error estimate\nl2 norm = "
                       << error.l2_norm()
                       << "\nmaximum = "
                       << error.maximum()
                       << std::endl;

          mesh_refinement.flag_elements_by_error_fraction (error);

          mesh_refinement.refine_and_coarsen_elements();

          equation_systems.reinit();
        }
    }
#else
  system.solve();
#endif
}
开发者ID:YSB330,项目名称:libmesh,代码行数:66,代码来源:miscellaneous_ex10.C


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