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


C++ Triangulation::refine_global方法代码示例

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


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

示例1: main

int main()
{
  const Point<2> p1(-1.0, -1.0), p2(1.0, 1.0);
  Triangulation<2> triangulation;
  GridGenerator::hyper_rectangle(triangulation, p1, p2);
  triangulation.refine_global(num_levels);

  const Discretization<2> discretization(triangulation, 1);

  /**
   * Initialize a FieldType object with the return value from a function; this
   * utilizes the move constructor for FieldType.
   */
  Field<2> u = gaussian(discretization);

  std::cout << norm(u) << std::endl;

  /**
   * Reassign the FieldType object with the return value from another function;
   * this uses the move assignment operator.
   */
  u = parabola(discretization);

  std::cout << norm(u) << std::endl;

  return 0;
}
开发者ID:danshapero,项目名称:icepack,代码行数:27,代码来源:field_move.cpp

示例2: main

int main()
{
  const Point<2> p1(0.0, 0.0), p2(1.0, 1.0);
  Triangulation<2> triangulation;
  GridGenerator::hyper_rectangle(triangulation, p1, p2);
  triangulation.refine_global(num_levels);

  const Discretization<2> discretization(triangulation, 1);

  // Construct finite element fields interpolating two trigonometric functions
  const Field<2> phi1 = interpolate(discretization, Phi1<2>());
  const Field<2> phi2 = interpolate(discretization, Phi2<2>());

  // Check that the finite element fields are approximately orthogonal
  double exact_inner_product = 0.0;
  check_real(inner_product(phi1, phi2), exact_inner_product, dx);

  // Check that the distance between the two fields of unit norm is 1
  const double exact_distance = 1.0;
  check_real(dist(phi1, phi2), exact_distance, dx);

  // Compute the Laplacian of one of the fields; this is a dual field
  SparseMatrix<double> L(discretization.scalar().get_sparsity());
  dealii::MatrixCreator::create_laplace_matrix(
    discretization.scalar().get_dof_handler(),
    discretization.quad(),
    L,
    (const Function<2> *)nullptr,
    discretization.scalar().get_constraints()
  );

  DualField<2> laplacian_phi1(transpose(phi1));
  L.vmult(laplacian_phi1.get_coefficients(), phi1.get_coefficients());

  // Check that the fields are also conjugate w.r.t. the Laplace operator
  exact_inner_product = 0.0;
  check_real(inner_product(laplacian_phi1, phi2), exact_inner_product, dx);

  return 0;
}
开发者ID:danshapero,项目名称:icepack,代码行数:40,代码来源:field_dist.cpp


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