https://mooseframework.inl.gov
PetscVectorReader.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "PetscVectorReader.h"
11 
12 PetscVectorReader::PetscVectorReader(PetscVector<Number> & vec)
13  : _vec(vec), _raw_value(vec.get_array_read())
14 {
15 }
16 
18  : _vec(libMesh::cast_ref<PetscVector<Number> &>(vec)), _raw_value(_vec.get_array_read())
19 {
20 }
21 
23 
24 void
26 {
27  mooseAssert(readable(), "Array not retrieved");
28  _vec.restore_array();
29  _raw_value = nullptr;
30 }
Tnew cast_ref(Told &oldvar)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
~PetscVectorReader()
Destructor to make sure the vector is restored every time this goes out of scope. ...
PetscVectorReader(PetscVector< Number > &vec)
Construct using a pets vector.
Real Number
void restore()
Restore the array, usually upon going out of scope.