The following code issues an the subsequent error:
// Just in case
petsc_solution->restore_array();
// Just print the vector using ::operator()
for (numeric_index_type i = petsc_solution->first_local_index(); i < petsc_solution->last_local_index(); ++i)
std::cout << "u(" << i << ") = " << (*petsc_solution)(i) << std::endl;
// Get array
PetscScalar * petsc_array = petsc_solution->get_array();
// restore
petsc_solution->restore_array();
petsc_solution->close();
libMesh terminating:
PetscVector values were manually retrieved but are being automatically restored!
Stack frames: 18
0: libMesh::print_trace(std::ostream&)
1: libMesh::MacroFunctions::report_error(char const*, int, char const*, char const*, std::ostream&)
2: libMesh::PetscVector<double>::_restore_array() const
3: libMesh::PetscVector<double>::_get_array(bool) const
This operation should be allowed ::operator() should not restricting access to the raw array.
get_array() +should+ error out if:
- There is another request that hasn't been restored yet
- Other operations like
operator() or set are being used before calling restore_array()
get_array_read() should error if:
- There is a
get_array() that hasn't been restored yet
- Non-
const operations are being performed before it's been restored.
The following code issues an the subsequent error:
This operation should be allowed
::operator()should not restricting access to the raw array.get_array()+should+ error out if:operator()orsetare being used before callingrestore_array()get_array_read()should error if:get_array()that hasn't been restored yetconstoperations are being performed before it's been restored.