Changed some function signatures to take const UnstructuredGrid& instead of ptr.

This commit is contained in:
Atgeirr Flø Rasmussen 2012-03-12 13:44:05 +01:00
parent dd85dc522c
commit f5ad161409
3 changed files with 25 additions and 26 deletions

View File

@ -159,9 +159,8 @@ private:
template <class State> void outputState(const UnstructuredGrid& grid,
void outputState(const UnstructuredGrid* grid, const ReservoirState& state,
const State& state,
const int step, const int step,
const std::string& output_dir) const std::string& output_dir)
{ {
@ -176,7 +175,7 @@ void outputState(const UnstructuredGrid* grid,
dm["saturation"] = &state.saturation(); dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure(); dm["pressure"] = &state.pressure();
std::vector<double> cell_velocity; std::vector<double> cell_velocity;
Opm::estimateCellVelocity(*grid, state.faceflux(), cell_velocity); Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
dm["velocity"] = &cell_velocity; dm["velocity"] = &cell_velocity;
Opm::writeVtkData(grid, dm, vtkfile); Opm::writeVtkData(grid, dm, vtkfile);
@ -592,7 +591,7 @@ main(int argc, char** argv)
<< "\n" << std::endl; << "\n" << std::endl;
if (output) { if (output) {
outputState(grid->c_grid(), state, pstep, output_dir); outputState(*grid->c_grid(), state, pstep, output_dir);
} }
// Solve pressure. // Solve pressure.
@ -661,7 +660,7 @@ main(int argc, char** argv)
<< "\n Transport time: " << ttime << std::endl; << "\n Transport time: " << ttime << std::endl;
if (output) { if (output) {
outputState(grid->c_grid(), state, num_psteps, output_dir); outputState(*grid->c_grid(), state, num_psteps, output_dir);
} }
destroy_transport_source(tsrc); destroy_transport_source(tsrc);

View File

@ -137,11 +137,11 @@ namespace Opm
int Tag::indent_ = 0; int Tag::indent_ = 0;
void writeVtkData(const UnstructuredGrid* grid, void writeVtkData(const UnstructuredGrid& grid,
const DataMap& data, const DataMap& data,
std::ostream& os) std::ostream& os)
{ {
if (grid->dimensions != 3) { if (grid.dimensions != 3) {
THROW("Vtk output for 3d grids only"); THROW("Vtk output for 3d grids only");
} }
os.precision(12); os.precision(12);
@ -150,8 +150,8 @@ namespace Opm
pm["type"] = "UnstructuredGrid"; pm["type"] = "UnstructuredGrid";
Tag vtkfiletag("VTKFile", pm, os); Tag vtkfiletag("VTKFile", pm, os);
Tag ugtag("UnstructuredGrid", os); Tag ugtag("UnstructuredGrid", os);
int num_pts = grid->number_of_nodes; int num_pts = grid.number_of_nodes;
int num_cells = grid->number_of_cells; int num_cells = grid.number_of_cells;
pm.clear(); pm.clear();
pm["NumberOfPoints"] = boost::lexical_cast<std::string>(num_pts); pm["NumberOfPoints"] = boost::lexical_cast<std::string>(num_pts);
pm["NumberOfCells"] = boost::lexical_cast<std::string>(num_cells); pm["NumberOfCells"] = boost::lexical_cast<std::string>(num_cells);
@ -166,9 +166,9 @@ namespace Opm
Tag datag("DataArray", pm, os); Tag datag("DataArray", pm, os);
for (int i = 0; i < num_pts; ++i) { for (int i = 0; i < num_pts; ++i) {
Tag::indent(os); Tag::indent(os);
os << grid->node_coordinates[3*i + 0] << ' ' os << grid.node_coordinates[3*i + 0] << ' '
<< grid->node_coordinates[3*i + 1] << ' ' << grid.node_coordinates[3*i + 1] << ' '
<< grid->node_coordinates[3*i + 2] << '\n'; << grid.node_coordinates[3*i + 2] << '\n';
} }
} }
{ {
@ -185,10 +185,10 @@ namespace Opm
int hf = 0; int hf = 0;
for (int c = 0; c < num_cells; ++c) { for (int c = 0; c < num_cells; ++c) {
std::set<int> cell_pts; std::set<int> cell_pts;
for (; hf < grid->cell_facepos[c+1]; ++hf) { for (; hf < grid.cell_facepos[c+1]; ++hf) {
int f = grid->cell_faces[hf]; int f = grid.cell_faces[hf];
const int* fnbeg = grid->face_nodes + grid->face_nodepos[f]; const int* fnbeg = grid.face_nodes + grid.face_nodepos[f];
const int* fnend = grid->face_nodes + grid->face_nodepos[f+1]; const int* fnend = grid.face_nodes + grid.face_nodepos[f+1];
cell_pts.insert(fnbeg, fnend); cell_pts.insert(fnbeg, fnend);
} }
cell_numpts.push_back(cell_pts.size()); cell_numpts.push_back(cell_pts.size());
@ -220,21 +220,21 @@ namespace Opm
{ {
pm["Name"] = "faces"; pm["Name"] = "faces";
Tag t("DataArray", pm, os); Tag t("DataArray", pm, os);
const int* fp = grid->cell_facepos; const int* fp = grid.cell_facepos;
int offset = 0; int offset = 0;
for (int c = 0; c < num_cells; ++c) { for (int c = 0; c < num_cells; ++c) {
Tag::indent(os); Tag::indent(os);
os << fp[c+1] - fp[c] << '\n'; os << fp[c+1] - fp[c] << '\n';
++offset; ++offset;
for (int hf = fp[c]; hf < fp[c+1]; ++hf) { for (int hf = fp[c]; hf < fp[c+1]; ++hf) {
int f = grid->cell_faces[hf]; int f = grid.cell_faces[hf];
const int* np = grid->face_nodepos; const int* np = grid.face_nodepos;
int f_num_pts = np[f+1] - np[f]; int f_num_pts = np[f+1] - np[f];
Tag::indent(os); Tag::indent(os);
os << f_num_pts << ' '; os << f_num_pts << ' ';
++offset; ++offset;
std::copy(grid->face_nodes + np[f], std::copy(grid.face_nodes + np[f],
grid->face_nodes + np[f+1], grid.face_nodes + np[f+1],
std::ostream_iterator<int>(os, " ")); std::ostream_iterator<int>(os, " "));
os << '\n'; os << '\n';
offset += f_num_pts; offset += f_num_pts;
@ -290,7 +290,7 @@ namespace Opm
for (DataMap::const_iterator dit = data.begin(); dit != data.end(); ++dit) { for (DataMap::const_iterator dit = data.begin(); dit != data.end(); ++dit) {
pm["Name"] = dit->first; pm["Name"] = dit->first;
const std::vector<double>& field = *(dit->second); const std::vector<double>& field = *(dit->second);
const int num_comps = field.size()/grid->number_of_cells; const int num_comps = field.size()/grid.number_of_cells;
pm["NumberOfComponents"] = boost::lexical_cast<std::string>(num_comps); pm["NumberOfComponents"] = boost::lexical_cast<std::string>(num_comps);
Tag ptag("DataArray", pm, os); Tag ptag("DataArray", pm, os);
const int num_per_line = num_comps == 1 ? 5 : num_comps; const int num_per_line = num_comps == 1 ? 5 : num_comps;

View File

@ -42,7 +42,7 @@ namespace Opm
std::ostream& os); std::ostream& os);
/// Vtk output for general grids. /// Vtk output for general grids.
void writeVtkData(const UnstructuredGrid* grid, void writeVtkData(const UnstructuredGrid& grid,
const DataMap& data, const DataMap& data,
std::ostream& os); std::ostream& os);
} // namespace Opm } // namespace Opm