本文整理汇总了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;
}
示例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;
}