本文整理汇总了C++中MultiFab::minus方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiFab::minus方法的具体用法?C++ MultiFab::minus怎么用?C++ MultiFab::minus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiFab
的用法示例。
在下文中一共展示了MultiFab::minus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
void solve(MultiFab& soln, const MultiFab& anaSoln, MultiFab& gphi,
Real a, Real b, MultiFab& alpha, PArray<MultiFab>& beta, MultiFab& beta_cc,
MultiFab& rhs, const BoxArray& bs, const Geometry& geom,
solver_t solver)
{
BL_PROFILE("solve()");
std::string ss;
soln.setVal(0.0);
const Real run_strt = ParallelDescriptor::second();
if (solver == BoxLib_C) {
ss = "CPP";
solve_with_Cpp(soln, gphi, a, b, alpha, beta, rhs, bs, geom);
}
#ifdef USE_F90_SOLVERS
else if (solver == BoxLib_F) {
ss = "F90";
solve_with_F90(soln, gphi, a, b, alpha, beta, rhs, bs, geom);
}
#endif
#ifdef USEHYPRE
else if (solver == Hypre) {
ss = "Hyp";
solve_with_hypre(soln, a, b, alpha, beta, rhs, bs, geom);
}
#endif
#ifdef USEHPGMG
else if (solver == HPGMG) {
ss = "HPGMG";
solve_with_HPGMG(soln, gphi, a, b, alpha, beta, beta_cc, rhs, bs, geom, n_cell);
}
#endif
else {
BoxLib::Error("Invalid solver");
}
Real run_time = ParallelDescriptor::second() - run_strt;
ParallelDescriptor::ReduceRealMax(run_time, ParallelDescriptor::IOProcessorNumber());
if (ParallelDescriptor::IOProcessor()) {
std::cout << " Run time : " << run_time << std::endl;
}
if (plot_soln) {
writePlotFile("SOLN-"+ss, soln, geom);
writePlotFile("GPHI-"+ss, gphi, geom);
}
if (plot_err || comp_norm) {
soln.minus(anaSoln, 0, Ncomp, 0); // soln contains errors now
MultiFab& err = soln;
if (plot_err) {
writePlotFile("ERR-"+ss, soln, geom);
}
if (comp_norm) {
Real twoNorm = err.norm2();
Real maxNorm = err.norm0();
err.setVal(1.0);
Real vol = err.norm2();
twoNorm /= vol;
if (ParallelDescriptor::IOProcessor()) {
std::cout << " 2 norm error : " << twoNorm << std::endl;
std::cout << " max norm error: " << maxNorm << std::endl;
}
}
}
}
示例2: solve4
void solve4(MultiFab& soln, const MultiFab& anaSoln,
Real a, Real b, MultiFab& alpha, MultiFab& beta,
MultiFab& rhs, const BoxArray& bs, const Geometry& geom)
{
std::string ss = "CPP";
soln.setVal(0.0);
const Real run_strt = ParallelDescriptor::second();
BndryData bd(bs, 1, geom);
set_boundary(bd, rhs, 0);
ABec4 abec_operator(bd, dx);
abec_operator.setScalars(a, b);
MultiFab betaca(bs,1,2);
ABec4::cc2ca(beta,betaca,0,0,1);
MultiFab alphaca(bs,1,2);
ABec4::cc2ca(alpha,alphaca,0,0,1);
abec_operator.setCoefficients(alphaca, betaca);
MultiFab rhsca(bs,1,0);
ABec4::cc2ca(rhs,rhsca,0,0,1);
MultiFab out(bs,1,0);
compute_analyticSolution(soln,Array<Real>(BL_SPACEDIM,0.5));
MultiFab solnca(bs,1,2);
solnca.setVal(0);
MultiGrid mg(abec_operator);
mg.setVerbose(verbose);
mg.solve(solnca, rhsca, tolerance_rel, tolerance_abs);
Real run_time = ParallelDescriptor::second() - run_strt;
ParallelDescriptor::ReduceRealMax(run_time, ParallelDescriptor::IOProcessorNumber());
if (ParallelDescriptor::IOProcessor()) {
std::cout << " Run time : " << run_time << std::endl;
}
if (plot_soln) {
writePlotFile("SOLN-"+ss, solnca, geom);
}
if (plot_err || comp_norm) {
soln.minus(anaSoln, 0, Ncomp, 0); // soln contains errors now
MultiFab& err = soln;
if (plot_err) {
writePlotFile("ERR-"+ss, soln, geom);
}
if (comp_norm) {
Real twoNorm = err.norm2();
Real maxNorm = err.norm0();
err.setVal(1.0);
Real vol = err.norm2();
twoNorm /= vol;
if (ParallelDescriptor::IOProcessor()) {
std::cout << " 2 norm error : " << twoNorm << std::endl;
std::cout << " max norm error: " << maxNorm << std::endl;
}
}
}
}