20#include <fmt/format.h>
22namespace Opm::Pybind {
24template <
class TypeTag>
26PyMaterialState<TypeTag>::
29 Model &model = this->simulator_->model();
30 auto size = model.numGridDof();
31 std::vector<double> array(size);
32 for (
unsigned dof_idx = 0; dof_idx < size; ++dof_idx) {
33 array[dof_idx] = model.dofTotalVolume(dof_idx);
38template <
class TypeTag>
40PyMaterialState<TypeTag>::
43 Problem &problem = this->simulator_->problem();
44 Model &model = this->simulator_->model();
45 auto size = model.numGridDof();
46 std::vector<double> array(size);
47 for (
unsigned dof_idx = 0; dof_idx < size; ++dof_idx) {
48 array[dof_idx] = problem.referencePorosity(dof_idx, 0);
53template <
class TypeTag>
55PyMaterialState<TypeTag>::
56setPorosity(
const double* poro, std::size_t size)
58 Problem& problem = this->simulator_->problem();
59 Model& model = this->simulator_->model();
60 auto model_size = model.numGridDof();
61 if (model_size != size) {
62 const std::string msg = fmt::format(
63 "Cannot set porosity. Expected array of size: {}, got array of size: ",
65 throw std::runtime_error(msg);
67 for (
unsigned dof_idx = 0; dof_idx < size; ++dof_idx) {
68 problem.setPorosity(poro[dof_idx], dof_idx);