本文整理汇总了C++中CI::faceend方法的典型用法代码示例。如果您正苦于以下问题:C++ CI::faceend方法的具体用法?C++ CI::faceend怎么用?C++ CI::faceend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI
的用法示例。
在下文中一共展示了CI::faceend方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_flowsolver
void test_flowsolver(const GI& g, const RI& r)
{
typedef typename GI::CellIterator CI;
typedef typename CI::FaceIterator FI;
typedef Opm::BasicBoundaryConditions<true, false> FBC;
typedef Opm::IncompFlowSolverHybrid<GI, RI, FBC,
Opm::MimeticIPAnisoRelpermEvaluator> FlowSolver;
FlowSolver solver;
typedef Opm::FlowBC BC;
FBC flow_bc(7);
//flow_bc.flowCond(1) = BC(BC::Dirichlet, 1.0*Opm::unit::barsa);
//flow_bc.flowCond(2) = BC(BC::Dirichlet, 0.0*Opm::unit::barsa);
flow_bc.flowCond(5) = BC(BC::Dirichlet, 100.0*Opm::unit::barsa);
typename CI::Vector gravity;
gravity[0] = gravity[1] = 0.0;
gravity[2] = Opm::unit::gravity;
solver.init(g, r, gravity, flow_bc);
// solver.printStats(std::cout);
//solver.assembleStatic(g, r);
//solver.printIP(std::cout);
std::vector<double> src(g.numberOfCells(), 0.0);
std::vector<double> sat(g.numberOfCells(), 0.0);
#if 0
if (g.numberOfCells() > 1) {
src[0] = 1.0;
src.back() = -1.0;
}
#endif
solver.solve(r, sat, flow_bc, src);
#if 0
solver.printSystem("system");
typedef typename FlowSolver::SolutionType FlowSolution;
FlowSolution soln = solver.getSolution();
std::cout << "Cell Pressure:\n" << std::scientific << std::setprecision(15);
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
std::cout << '\t' << soln.pressure(c) << '\n';
}
std::cout << "Cell (Out) Fluxes:\n";
std::cout << "flux = [\n";
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
for (FI f = c->facebegin(); f != c->faceend(); ++f) {
std::cout << soln.outflux(f) << ' ';
}
std::cout << "\b\n";
}
std::cout << "]\n";
#endif
}
示例2: test_evaluator
void test_evaluator(const Interface& g)
{
typedef typename Interface::CellIterator CI;
typedef typename CI ::FaceIterator FI;
typedef typename CI ::Scalar Scalar;
typedef Dune::SharedFortranMatrix FMat;
std::cout << "Called test_evaluator()" << std::endl;
std::vector<int> numf; numf.reserve(g.numberOfCells());
int max_nf = -1;
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
numf.push_back(0);
int& nf = numf.back();
for (FI f = c->facebegin(); f != c->faceend(); ++f)
++nf;
max_nf = std::max(max_nf, nf);
}
typedef int DummyClass;
Dune::MimeticIPEvaluator<Interface, DummyClass> ip(max_nf);
// Set dummy permeability K=diag(10,1,...,1,0.1).
std::vector<Scalar> perm(dim * dim, Scalar(0.0));
Dune::SharedCMatrix K(dim, dim, &perm[0]);
for (int i = 0; i < dim; ++i)
K(i,i) = 1.0;
K(0 ,0 ) *= 10.0;
K(dim-1,dim-1) /= 10.0;
// Storage for inverse ip.
std::vector<Scalar> ip_store(max_nf * max_nf, Scalar(0.0));
// Loop grid whilst building (and outputing) the inverse IP matrix.
int count = 0;
for (CI c = g.cellbegin(); c != g.cellend(); ++c, ++count) {
FMat Binv(numf[count], numf[count], &ip_store[0]);
ip.evaluate(c, K, Binv);
std::cout << count << " -> Binv = [\n" << Binv << "]\n";
}
}
示例3: assign_bc
void assign_bc(const GI& g, BCS& bcs)
{
typedef Dune::FlowBC BC;
typedef typename GI::CellIterator CI;
typedef typename CI::FaceIterator FI;
int max_bid = 0;
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
for (FI f = c->facebegin(); f != c->faceend(); ++f) {
int bid = f->boundaryId();
if (bid > max_bid) {
max_bid = bid;
bcs.resize(bid + 1);
}
bcs.flowCond(bid) = BC(BC::Dirichlet, u(f->centroid()));
}
}
}
示例4: setupRegionBasedConditions
inline void setupRegionBasedConditions(const Opm::parameter::ParameterGroup& param,
const GridInterface& g,
BCs& bcs)
{
// Extract region and pressure value for Dirichlet bcs.
typedef typename GridInterface::Vector Vector;
Vector low;
low[0] = param.getDefault("dir_block_low_x", 0.0);
low[1] = param.getDefault("dir_block_low_y", 0.0);
low[2] = param.getDefault("dir_block_low_z", 0.0);
Vector high;
high[0] = param.getDefault("dir_block_high_x", 1.0);
high[1] = param.getDefault("dir_block_high_y", 1.0);
high[2] = param.getDefault("dir_block_high_z", 1.0);
double dir_block_pressure = param.get<double>("dir_block_pressure");
// Set flow conditions for that region.
// For this to work correctly, unique boundary ids should be used,
// otherwise conditions may spread outside the given region, to all
// faces with the same bid as faces inside the region.
typedef typename GridInterface::CellIterator CI;
typedef typename CI::FaceIterator FI;
int max_bid = 0;
std::vector<int> dir_bids;
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
for (FI f = c->facebegin(); f != c->faceend(); ++f) {
int bid = f->boundaryId();
max_bid = std::max(bid, max_bid);
if (bid != 0 && isInside(low, high, f->centroid())) {
dir_bids.push_back(bid);
}
}
}
bcs.resize(max_bid + 1);
for (std::vector<int>::const_iterator it = dir_bids.begin(); it != dir_bids.end(); ++it) {
bcs.flowCond(*it) = FlowBC(FlowBC::Dirichlet, dir_block_pressure);
}
// Transport BCs are defaulted.
}
示例5: buildFaceIndices
void buildFaceIndices()
{
#ifdef VERBOSE
std::cout << "Building unique face indices... " << std::flush;
Opm::time::StopWatch clock;
clock.start();
#endif
typedef CellIterator CI;
typedef typename CI::FaceIterator FI;
// We build the actual cell to face mapping in two passes.
// [code mostly lifted from IncompFlowSolverHybrid::enumerateGridDof(),
// but with a twist: This code builds a mapping from cells in index
// order to unique face numbers, while the mapping built in the
// enumerateGridDof() method was ordered by cell iterator order]
// Allocate and reserve structures.
const int nc = numberOfCells();
std::vector<int> cell(nc, -1);
std::vector<int> num_faces(nc); // In index order.
std::vector<int> fpos; fpos .reserve(nc + 1);
std::vector<int> num_cf; num_cf.reserve(nc); // In iterator order.
std::vector<int> faces ;
// First pass: enumerate internal faces.
int cellno = 0; fpos.push_back(0);
int tot_ncf = 0, tot_ncf2 = 0, max_ncf = 0;
for (CI c = cellbegin(); c != cellend(); ++c, ++cellno) {
const int c0 = c->index();
ASSERT((0 <= c0) && (c0 < nc) && (cell[c0] == -1));
cell[c0] = cellno;
num_cf.push_back(0);
int& ncf = num_cf.back();
for (FI f = c->facebegin(); f != c-> faceend(); ++f) {
if (!f->boundary()) {
const int c1 = f->neighbourCellIndex();
ASSERT((0 <= c1) && (c1 < nc) && (c1 != c0));
if (cell[c1] == -1) {
// Previously undiscovered internal face.
faces.push_back(c1);
}
}
++ncf;
}
num_faces[c0] = ncf;
fpos.push_back(int(faces.size()));
max_ncf = std::max(max_ncf, ncf);
tot_ncf += ncf;
tot_ncf2 += ncf * ncf;
}
ASSERT(cellno == nc);
// Build cumulative face sizes enabling direct insertion of
// face indices into cfdata later.
std::vector<int> cumul_num_faces(numberOfCells() + 1);
cumul_num_faces[0] = 0;
std::partial_sum(num_faces.begin(), num_faces.end(), cumul_num_faces.begin() + 1);
// Avoid (most) allocation(s) inside 'c' loop.
std::vector<int> l2g;
l2g.reserve(max_ncf);
std::vector<double> cfdata(tot_ncf);
int total_num_faces = int(faces.size());
// Second pass: build cell-to-face mapping, including boundary.
typedef std::vector<int>::iterator VII;
for (CI c = cellbegin(); c != cellend(); ++c) {
const int c0 = c->index();
ASSERT ((0 <= c0 ) && ( c0 < nc) &&
(0 <= cell[c0]) && (cell[c0] < nc));
const int ncf = num_cf[cell[c0]];
l2g.resize(ncf, 0);
for (FI f = c->facebegin(); f != c->faceend(); ++f) {
if (f->boundary()) {
// External, not counted before. Add new face...
l2g[f->localIndex()] = total_num_faces++;
} else {
// Internal face. Need to determine during
// traversal of which cell we discovered this
// face first, and extract the face number
// from the 'faces' table range of that cell.
// Note: std::find() below is potentially
// *VERY* expensive (e.g., large number of
// seeks in moderately sized data in case of
// faulted cells).
const int c1 = f->neighbourCellIndex();
ASSERT ((0 <= c1 ) && ( c1 < nc) &&
(0 <= cell[c1]) && (cell[c1] < nc));
int t = c0, seek = c1;
if (cell[seek] < cell[t])
std::swap(t, seek);
int s = fpos[cell[t]], e = fpos[cell[t] + 1];
VII p = std::find(faces.begin() + s, faces.begin() + e, seek);
ASSERT(p != faces.begin() + e);
l2g[f->localIndex()] = p - faces.begin();
}
}
//.........这里部分代码省略.........
示例6: test_flowsolver
void test_flowsolver(const GI& g, const RI& r)
{
typedef typename GI::CellIterator CI;
typedef typename CI::FaceIterator FI;
typedef Opm::BasicBoundaryConditions<true, false> FBC;
typedef Opm::IncompFlowSolverHybrid<GI, RI, FBC,
Opm::MimeticIPEvaluator> FlowSolver;
FlowSolver solver;
typedef Opm::FlowBC BC;
FBC flow_bc(7);
#if !USE_ALUGRID
flow_bc.flowCond(5) = BC(BC::Dirichlet, 100.0*Opm::unit::barsa);
flow_bc.flowCond(6) = BC(BC::Dirichlet, 0.0*Opm::unit::barsa);
#endif
typename CI::Vector gravity(0.0);
// gravity[2] = Dune::unit::gravity;
solver.init(g, r, gravity, flow_bc);
std::vector<double> src(g.numberOfCells(), 0.0);
std::vector<double> sat(g.numberOfCells(), 0.0);
// if (g.numberOfCells() > 1) {
// src[0] = 1.0;
// src.back() = -1.0;
// }
solver.solve(r, sat, flow_bc, src, 5e-9, 3, 1);
#if 1
typedef typename FlowSolver::SolutionType FlowSolution;
FlowSolution soln = solver.getSolution();
std::vector<typename GI::Vector> cell_velocity;
estimateCellVelocity(cell_velocity, g, soln);
// Dune's vtk writer wants multi-component data to be flattened.
std::vector<double> cell_velocity_flat(&*cell_velocity.front().begin(),
&*cell_velocity.back().end());
std::vector<double> cell_pressure;
getCellPressure(cell_pressure, g, soln);
Dune::VTKWriter<typename GI::GridType::LeafGridView> vtkwriter(g.grid().leafView());
vtkwriter.addCellData(cell_velocity_flat, "velocity", dim);
vtkwriter.addCellData(cell_pressure, "pressure");
vtkwriter.write("testsolution-" + boost::lexical_cast<std::string>(0),
Dune::VTKOptions::ascii);
#else
solver.printSystem("system");
typedef typename FlowSolver::SolutionType FlowSolution;
FlowSolution soln = solver.getSolution();
std::cout << "Cell Pressure:\n" << std::scientific << std::setprecision(15);
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
std::cout << '\t' << soln.pressure(c) << '\n';
}
std::cout << "Cell (Out) Fluxes:\n";
std::cout << "flux = [\n";
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
for (FI f = c->facebegin(); f != c->faceend(); ++f) {
std::cout << soln.outflux(f) << ' ';
}
std::cout << "\b\n";
}
std::cout << "]\n";
#endif
}