本文整理汇总了C++中MESH::adj_triangle2_index方法的典型用法代码示例。如果您正苦于以下问题:C++ MESH::adj_triangle2_index方法的具体用法?C++ MESH::adj_triangle2_index怎么用?C++ MESH::adj_triangle2_index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MESH
的用法示例。
在下文中一共展示了MESH::adj_triangle2_index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hyperbolic_step
double hyperbolic_step(MESH& m, FLUX& f, double t, double dt) {
// HW4B: YOUR CODE HERE
// Step the finite volume model in time by dt.
// Pseudocode:
// Compute all fluxes. (before updating any triangle Q_bars)
// For each triangle, update Q_bar using the fluxes as in Equation 8.
// NOTE: Much like symp_euler_step, this may require TWO for-loops
/* 1. Initialize a vector temp_Q of size @a m.num_triangles() for storing all temp Q_bar values
* 2. Use a TriangleIterator to iterate through all the triangles, for each tri_it:
* a. Compute the sum of fluxes sum_fluxes
* b. temp_Q[(*it).index()] = sum_fluxes
* 3. Use indices of triangles to do another for loop, for each triangle(i):
* a. triangle_i.value().Q_bar = temp_Q[i]
*/
std::vector<QVar> temp_fluxes(m.num_triangles(), QVar());
for (auto tri_it = m.triangle_begin(); tri_it != m.triangle_end(); ++tri_it) {
auto qk = (*tri_it).value();
QVar F_k(0, 0, 0);
for (size_type i = 0; i < 3; ++i) {
auto edge = (*tri_it).edge(i);
QVar qm(0, 0, 0);
if (m.adj_triangle1_index(edge) == -1 || m.adj_triangle2_index(edge) == -1) {
//set_boundary_conditions
qm = QVar(qk.h, 0, 0);
} else {
size_type adj_tri_idx = m.adj_triangle1_index(edge) == (*tri_it).index() ?
m.adj_triangle2_index(edge) : m.adj_triangle1_index(edge);
auto adj_triangle = m.triangle(adj_tri_idx);
qm = adj_triangle.value();
}
auto norm_ke = m.out_norm((*tri_it), edge);
F_k = F_k + f(norm_ke.x, norm_ke.y, dt, qk, qm);
}
// print_triangle(m, (*tri_it), f, t, dt);
temp_fluxes[(*tri_it).index()] = qk - F_k * (dt / (*tri_it).area());
}
for (auto tri_it = m.triangle_begin(); tri_it != m.triangle_end(); ++tri_it) {
(*tri_it).value() = temp_fluxes[(*tri_it).index()];
}
return t + dt;
}