本文整理汇总了C++中volume::get_max_corner方法的典型用法代码示例。如果您正苦于以下问题:C++ volume::get_max_corner方法的具体用法?C++ volume::get_max_corner怎么用?C++ volume::get_max_corner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类volume
的用法示例。
在下文中一共展示了volume::get_max_corner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gradient
/* default: simple numerical integration of surfaces/cubes, relative
tolerance 'tol'. This is superseded by the routines in the libctl
interface, which either use a semi-analytical average or can
use a proper adaptive cubature. */
void material_function::eff_chi1inv_row(component c, double chi1inv_row[3],
const volume &v,
double tol, int maxeval) {
field_type ft = type(c);
if (!maxeval) {
trivial:
chi1inv_row[0] = chi1inv_row[1] = chi1inv_row[2] = 0.0;
chi1inv_row[component_direction(c) % 3] = 1/chi1p1(ft,v.center());
return;
}
vec gradient(normal_vector(ft, v));
if (abs(gradient) < 1e-8) goto trivial;
double meps=1, minveps=1;
vec d = v.get_max_corner() - v.get_min_corner();
int ms = 10;
double old_meps=0, old_minveps=0;
int iter = 0;
switch(v.dim) {
case D3:
while ((fabs(meps - old_meps) > tol*fabs(old_meps)) && (fabs(minveps - old_minveps) > tol*fabs(old_minveps))) {
old_meps=meps;
old_minveps=minveps;
meps = minveps = 0;
for (int k=0; k < ms; k++)
for (int j=0; j < ms; j++)
for (int i=0; i < ms; i++) {
double ep = chi1p1(ft,v.get_min_corner() + vec(i*d.x()/ms, j*d.y()/ms, k*d.z()/ms));
if (ep < 0) goto trivial;
meps += ep;
minveps += 1/ep;
}
meps /= ms*ms*ms;
minveps /= ms*ms*ms;
ms *= 2;
if (maxeval && (iter += ms*ms*ms) >= maxeval) goto done;
}
break;
case D2:
while ((fabs(meps-old_meps) > tol*old_meps) && (fabs(minveps-old_minveps) > tol*old_minveps)) {
old_meps=meps;
old_minveps=minveps;
meps = minveps = 0;
for (int j=0; j < ms; j++)
for (int i=0; i < ms; i++) {
double ep = chi1p1(ft,v.get_min_corner() + vec(i*d.x()/ms, j*d.y()/ms));
if (ep < 0) goto trivial;
meps += ep;
minveps += 1/ep;
}
meps /= ms*ms;
minveps /= ms*ms;
ms *= 2;
if (maxeval && (iter += ms*ms) >= maxeval) goto done;
}
break;
case Dcyl:
while ((fabs(meps-old_meps) > tol*old_meps) && (fabs(minveps-old_minveps) > tol*old_minveps)) {
old_meps=meps;
old_minveps=minveps;
meps = minveps = 0;
double sumvol = 0;
for (int j=0; j < ms; j++)
for (int i=0; i < ms; i++) {
double r = v.get_min_corner().r() + i*d.r()/ms;
double ep = chi1p1(ft,v.get_min_corner() + veccyl(i*d.r()/ms, j*d.z()/ms));
if (ep < 0) goto trivial;
sumvol += r;
meps += ep * r;
minveps += r/ep;
}
meps /= sumvol;
minveps /= sumvol;
ms *= 2;
if (maxeval && (iter += ms*ms) >= maxeval) goto done;
}
break;
case D1:
while ((fabs(meps-old_meps) > tol*old_meps) && (fabs(minveps-old_minveps) > tol*old_minveps)) {
old_meps=meps;
old_minveps=minveps;
meps = minveps = 0;
for (int i=0; i < ms; i++) {
double ep = chi1p1(ft,v.get_min_corner() + vec(i*d.z()/ms));
if (ep < 0) {
meps = chi1p1(ft,v.center());
minveps = 1/meps;
goto done;
}
meps += ep;
minveps += 1/ep;
}
meps /= ms;
minveps /= ms;
ms *= 2;
//.........这里部分代码省略.........