本文整理汇总了C++中MESH::edge_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ MESH::edge_begin方法的具体用法?C++ MESH::edge_begin怎么用?C++ MESH::edge_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MESH
的用法示例。
在下文中一共展示了MESH::edge_begin方法的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
// Implement Equation 7 from your pseudocode here.
for(auto i = m.edge_begin(); i != m.edge_end(); ++i){
if ((*i).triangle1().index() != (unsigned) -1 && (*i).triangle2().index() != (unsigned) -1 ){
MeshType::Triangle trik = (*i).triangle1();
MeshType::Triangle trim = (*i).triangle2();
unsigned int edge_k = 0;
unsigned int edge_m = 0;
//which edge (*i) is in trik and trim
while(trik.node(edge_k).index()== (*i).node1().index()
|| trik.node(edge_k).index()== (*i).node2().index() )
++edge_k;
while(trim.node(edge_m).index()== (*i).node1().index()
|| trim.node(edge_m).index()== (*i).node2().index() )
++edge_m;
QVar flux = f(trik.normal(edge_k).x, trik.normal(edge_k).y, dt, trik.value().Q, trim.value().Q);
trik.value().F[edge_k] = flux;
trim.value().F[edge_m] = -flux;
}
else{
MeshType::Triangle trik;
if ((*i).triangle1().index() != (unsigned) -1)
trik = (*i).triangle1();
else
trik = (*i).triangle2();
unsigned int edge_k = 0;
while(trik.node(edge_k).index()== (*i).node1().index()
|| trik.node(edge_k).index()== (*i).node2().index() )
++edge_k;
QVar flux = f(trik.normal(edge_k).x, trik.normal(edge_k).y, dt, trik.value().Q, QVar(trik.value().Q.h, 0, 0));
trik.value().F[edge_k] = flux;
}
}
for(auto i = m.triangle_begin(); i != m.triangle_end(); ++i){
QVar sum = QVar(0, 0, 0);
for (int j = 0; j < 3; ++j){
sum += (*i).value().F[j];
}
(*i).value().Q = (*i).value().Q-dt/(*i).area()*sum;
}
return t + dt;
};