void laplace2d() { double nx = 31; double ny = 31; double c = 1; double dx = 2/(nx-1); double dy = 2/(ny-1); double linorm_target = .01; double linorm = 1; // Make an output folder std::string dir = "step9/"; Eigen::ArrayXd x; // Array containing our x values x.setLinSpaced(nx,0,2); // Array is linearly spaced values from 0 to 2 Eigen::ArrayXd y; // Array containing our x values y.setLinSpaced(ny,0,1); // Arrays containing our calculated values Eigen::ArrayXXd p; Eigen::ArrayXXd pn; // Initial Conditions p.setZero(ny,nx); pn.setZero(ny,nx); //Set Boundary Conditions p.block(0,0,ny,1) = Eigen::ArrayXXd::Constant(ny,1,0); p.block(0,nx-1,ny,1) = y.block(0,0,ny,1); p.block(0,0,1,nx) = p.block(1,0,1,nx); p.block(ny-1,0,1,nx) = p.block(ny-2,0,1,nx); while(linorm>linorm_target) { pn << p; p.block(1,1,ny-2,nx-2) = (pow(dy,2)*(pn.block(2,1,ny-2,nx-2)+pn.block(0,1,ny-2,nx-2))+pow(dx,2)*(pn.block(1,2,ny-2,nx-2)+pn.block(1,0,ny-2,nx-2)))/(2*(pow(dx,2)+pow(dy,2))); p(0,0) = (pow(dy,2)*(pn(1,0)+pn(ny-1,0))+pow(dx,2)*(pn(0,1)+pn(0,nx-1)))/(2*(pow(dx,2)+pow(dy,2))); p(ny-1,nx-1) = (pow(dy,2)*(pn(0,nx-1)+pn(ny-2,nx-1))+pow(dx,2)*(pn(ny-1,0)+pn(ny-1,nx-2)))/(2*(pow(dx,2)+pow(dy,2))); //Set Boundary Conditions p.block(0,0,ny,1) = Eigen::ArrayXXd::Constant(ny,1,0); p.block(0,nx-1,ny,1) = y.block(0,0,ny,1); p.block(0,0,1,nx) = p.block(1,0,1,nx); p.block(ny-1,0,1,nx) = p.block(ny-2,0,1,nx); linorm = (p.cwiseAbs()-pn.cwiseAbs()).sum()/(pn.cwiseAbs()).sum(); } ofstream writexdata((dir + "output.dat").c_str(), ios::out | ios::trunc); writexdata << p << endl; writexdata.close(); }
void channelns() { double nx = 41; double ny = 41; double nt = 10; double nit = 50; double c = 1; double dx = 2/(nx-1); double dy = 2/(ny-1); double rho = 1; double nu =.1; double F = 1; double dt = .01; std::string dir = "step11/"; Eigen::ArrayXd x; // Array containing our x values x.setLinSpaced(nx,0,2); // Array is linearly spaced values from 0 to 2 Eigen::ArrayXd y; // Array containing our x values y.setLinSpaced(ny,0,2); Eigen::ArrayXXd X; Eigen::ArrayXXd Y; X = x.transpose().replicate(nx,1); // Need to transpose this because the type we declared, ArrayXd, is row-major (and we need column-major for a proper meshgrid) Y = y.replicate(1,ny); Eigen::ArrayXXd u; u.setZero(ny,nx); Eigen::ArrayXXd un; un.setZero(ny,nx); Eigen::ArrayXXd v; v.setZero(ny,nx); Eigen::ArrayXXd vn; vn.setZero(ny,nx); Eigen::ArrayXXd b; b.setZero(ny,nx); Eigen::ArrayXXd p; p.setZero(ny,nx); Eigen::ArrayXXd pn; pn.setZero(ny,nx); }
/** * Compute maximum dissolution and evaporation ratios at * average hydrocarbon pressure. * * Uses the pressure value computed by averagePressure() * and must therefore be called *after* that method. */ void calcRmax() { Rmax_.setZero(); const PhaseUsage& pu = props_.phaseUsage(); if (Details::PhaseUsed::oil(pu) && Details::PhaseUsed::gas(pu)) { const Eigen::ArrayXXd::Index io = Details::PhasePos::oil(pu), ig = Details::PhasePos::gas(pu); // Note: Intentionally does not take capillary // pressure into account. This facility uses the // average *hydrocarbon* pressure rather than // average phase pressure. typedef BlackoilPropsAdInterface::ADB ADB; Rmax_.col(io) = props_.rsSat(ADB::constant(p_avg_), ADB::constant(T_avg_), repcells_).value(); Rmax_.col(ig) = props_.rvSat(ADB::constant(p_avg_), ADB::constant(T_avg_), repcells_).value(); } }