Add methods sequence() and components().

This commit is contained in:
Atgeirr Flø Rasmussen 2013-01-08 11:04:07 +01:00
parent db7fe12a45
commit 6a23ebe449
2 changed files with 30 additions and 7 deletions

View File

@ -29,15 +29,18 @@
void Opm::TransportModelInterface::reorderAndTransport(const UnstructuredGrid& grid, const double* darcyflux)
{
// Compute reordered sequence of single-cell problems
std::vector<int> sequence(grid.number_of_cells);
std::vector<int> components(grid.number_of_cells + 1);
sequence_.resize(grid.number_of_cells);
components_.resize(grid.number_of_cells + 1);
int ncomponents;
time::StopWatch clock;
clock.start();
compute_sequence(&grid, darcyflux, &sequence[0], &components[0], &ncomponents);
compute_sequence(&grid, darcyflux, &sequence_[0], &components_[0], &ncomponents);
clock.stop();
std::cout << "Topological sort took: " << clock.secsSinceStart() << " seconds." << std::endl;
// Make vector's size match actual used data.
components_.resize(ncomponents + 1);
// Invoke appropriate solve method for each interdependent component.
for (int comp = 0; comp < ncomponents; ++comp) {
#if 0
@ -50,11 +53,23 @@ void Opm::TransportModelInterface::reorderAndTransport(const UnstructuredGrid& g
}
#endif
#endif
const int comp_size = components[comp + 1] - components[comp];
const int comp_size = components_[comp + 1] - components_[comp];
if (comp_size == 1) {
solveSingleCell(sequence[components[comp]]);
solveSingleCell(sequence_[components_[comp]]);
} else {
solveMultiCell(comp_size, &sequence[components[comp]]);
solveMultiCell(comp_size, &sequence_[components_[comp]]);
}
}
}
const std::vector<int>& Opm::TransportModelInterface::sequence() const
{
return sequence_;
}
const std::vector<int>& Opm::TransportModelInterface::components() const
{
return components_;
}

View File

@ -20,6 +20,8 @@
#ifndef OPM_TRANSPORTMODELINTERFACE_HEADER_INCLUDED
#define OPM_TRANSPORTMODELINTERFACE_HEADER_INCLUDED
#include <vector>
struct UnstructuredGrid;
namespace Opm
@ -31,7 +33,8 @@ namespace Opm
/// method that will have an interface geared to the model's
/// needs. (The solve() method is therefore not virtual in this
/// class.) The reorderAndTransport() method is provided as an aid
/// to implementing solve() in subclasses.
/// to implementing solve() in subclasses, together with the
/// sequence() and components() methods for accessing the ordering.
class TransportModelInterface
{
public:
@ -41,6 +44,11 @@ namespace Opm
virtual void solveMultiCell(const int num_cells, const int* cells) = 0;
protected:
void reorderAndTransport(const UnstructuredGrid& grid, const double* darcyflux);
const std::vector<int>& sequence() const;
const std::vector<int>& components() const;
private:
std::vector<int> sequence_;
std::vector<int> components_;
};