MoReFEM
|
Class which encapsulates both the Petsc vector and the numbering subset used to described it. More...
#include <GlobalVector.hpp>
Public Types | |
using | unique_ptr = std::unique_ptr<GlobalVector> |
Alias to unique pointer. | |
using | vector_unique_ptr = std::vector<unique_ptr> |
Alias to vector of unique pointers. | |
template<std::size_t N> | |
using | array_unique_ptr = std::array<unique_ptr, N> |
Alias to array of unique pointers. | |
using | parent = Wrappers::Petsc::Vector |
Alias to parent. | |
using | self = GlobalVector |
Alias to the type of the class. | |
enum class | check_non_null_ptr { no , yes } |
Convenient enum class for Internal() and InternalForReadOnly() template argument. | |
using | call_petsc_destroy = Advanced::Wrappers::Petsc::call_petsc_destroy |
Convenient alias. | |
Public Member Functions | |
const NumberingSubset & | GetNumberingSubset () const |
Numbering subset used to describe vector. | |
void | InitSequentialVector (const Mpi &mpi, std::size_t size, const std::source_location location=std::source_location::current()) |
Set the vector as sequential. | |
void | InitMpiVector (const Mpi &mpi, std::size_t processor_wise_size, std::size_t program_wise_size, const std::source_location location=std::source_location::current()) |
Set the vector as sequential. | |
void | InitMpiVectorWithGhost (const Mpi &mpi, std::size_t processor_wise_size, std::size_t program_wise_size, const std::vector< PetscInt > &ghost_padding, const std::source_location location=std::source_location::current()) |
Create a parallel vector with ghost padding. | |
void | InitSequentialFromAsciiFile (const Mpi &mpi, const FilesystemNS::File &file, const std::source_location location=std::source_location::current()) |
Init a sequential vector with the data read in the file. | |
void | InitParallelFromProcessorWiseAsciiFile (const Mpi &mpi, std::size_t processor_wise_size, std::size_t program_wise_size, const std::vector< PetscInt > &ghost_padding, const FilesystemNS::File &ascii_file, const std::source_location location=std::source_location::current()) |
Init a vector from the data read in the file. | |
void | InitParallelFromProcessorWiseBinaryFile (const Mpi &mpi, std::size_t processor_wise_size, std::size_t program_wise_size, const std::vector< PetscInt > &ghost_padding, const FilesystemNS::File &binary_file, const std::source_location location=std::source_location::current()) |
Init a vector from the data read in the file. | |
void | InitFromProgramWiseBinaryFile (const Mpi &mpi, std::size_t processor_wise_size, std::size_t program_wise_size, const std::vector< PetscInt > &ghost_padding, const FilesystemNS::File &binary_file, const std::source_location location=std::source_location::current()) |
Init from a program-wise binary file: load a vector dumped with View() method. | |
template<check_non_null_ptr do_check_non_null_ptr = check_non_null_ptr::yes> | |
Vec | Internal (std::source_location location) |
Handle over the internal Vec object. | |
template<check_non_null_ptr do_check_non_null_ptr = check_non_null_ptr::yes> | |
Vec | InternalForReadOnly (std::source_location location) const |
Handle over the internal Vec object - when you can guarantee the call is only to read the value, not act upon it. | |
void | DuplicateLayout (const Vector &original, const std::source_location location=std::source_location::current()) |
Duplicate layout (in memory, processor repartition, etc...) | |
PetscInt | GetProcessorWiseSize (const std::source_location location=std::source_location::current()) const |
Get the number of elements in the local vector. | |
PetscInt | GetProgramWiseSize (const std::source_location location=std::source_location::current()) const |
Get the number of elements in the global vector. | |
void | ZeroEntries (const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
Set all the entries to zero. | |
void | Assembly (const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
Petsc Assembling of the vector. | |
void | SetValues (const std::vector< PetscInt > &indexing, const PetscScalar *values, InsertMode insertOrAppend, const std::source_location location=std::source_location::current()) |
Add or modify values inside a Petsc vector. | |
template<Utilities::Access AccessT> | |
void | SetValues (const std::vector< PetscInt > &indexing, const AccessVectorContent< AccessT > &local_vec, InsertMode insertOrAppend, const std::source_location location=std::source_location::current()) |
Add or modify values inside a Petsc vector. | |
void | SetFromPetscVec (const Vec &petsc_vector, const std::source_location location=std::source_location::current()) |
Set the values of a vector from a Petsc Vec object. | |
std::vector< PetscScalar > | GetValues (const std::vector< PetscInt > &indexing, const std::source_location location=std::source_location::current()) const |
Get the values of a vector on a current process. | |
void | GetValues (const std::vector< PetscInt > &indexing, std::vector< PetscScalar > &values, const std::source_location location=std::source_location::current()) const |
Get the values of a vector on a current process. | |
PetscScalar | GetValue (PetscInt index, const std::source_location location=std::source_location::current()) const |
Same as GetValues() for a unique index. | |
void | SetValue (PetscInt index, PetscScalar value, InsertMode insertOrAppend, const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
Add or modify one value inside a Petsc vector. | |
void | SetUniformValue (PetscScalar value, const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
Set the same value to all entries of the vector. | |
void | Copy (const Vector &source, const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
A wrapper over VecCopy, which assumed target already gets the right layout. | |
void | CompleteCopy (const Vector &source, const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
A complete copy: layout is copied first and then the values. | |
void | Scale (PetscScalar a, const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
Wrapper over VecScale, that performs Y = a * Y. | |
void | Shift (PetscScalar a, const std::source_location location=std::source_location::current(), update_ghost do_update_ghost=update_ghost::yes) |
Wrapper over VecShift, that performs Y = Y + a * 1. | |
void | View (const Mpi &mpi, const std::source_location location=std::source_location::current()) const |
Wrapper over VecView. | |
void | View (const Mpi &mpi, const FilesystemNS::File &output_file, const std::source_location location=std::source_location::current(), PetscViewerFormat format=PETSC_VIEWER_DEFAULT) const |
Wrapper over VecView in the case the viewer is a file. | |
void | ViewBinary (const Mpi &mpi, const FilesystemNS::File &output_file, const std::source_location location=std::source_location::current()) const |
Wrapper over MatView in the case the viewer is a binary file. | |
template<MpiScale MpiScaleT> | |
void | Print (const Mpi &mpi, const FilesystemNS::File &output_file, binary_or_ascii binary_or_ascii_choice=binary_or_ascii::from_input_data, const std::source_location location=std::source_location::current()) const |
Print the content of a vector in a file. | |
std::pair< PetscInt, PetscReal > | Min (const std::source_location location=std::source_location::current()) const |
Get the minimum. | |
std::pair< PetscInt, PetscReal > | Max (const std::source_location location=std::source_location::current()) const |
Get the maximum. | |
double | Norm (NormType type, const std::source_location location=std::source_location::current()) const |
Wrapper over VecNorm. | |
void | UpdateGhosts (const std::source_location location=std::source_location::current()) |
Update the ghost values. | |
void | UpdateGhosts (const std::source_location location, update_ghost do_update_ghost) |
Update the ghost values if do_update_ghost is set to yes. | |
bool | IsParallel (const std::source_location location) const |
Tells whether a vector is sequential or parallel. | |
bool | IsGhosted (const std::source_location location) const |
Tells whether a vector is ghosted or not. | |
const std::vector< PetscInt > & | GetGhostPadding () const noexcept |
Accessor to the list of program-wise index of values that are ghost. | |
void | SetDoNotDestroyPetscVector () |
Tells the class not to destroy the underlying vector through a call to VecDestroy(). | |
const std::string & | GetName () const noexcept |
Get the name given to the vector at construction. | |
Static Public Attributes | |
static constexpr bool | ConceptIsGlobalLinearAlgebra = true |
Keyword to indicate that this class qualify for the Concept::GlobalLinearAlgebra. | |
Protected Member Functions | |
void | ChangeInternal (Vec new_petsc_vector) |
Change the underlying PETSc pointer . | |
VecType | GetType (const std::source_location location) const |
Tells the type of the current vector. | |
Private Attributes | |
const NumberingSubset & | numbering_subset_ |
Numbering subset used to describe vector. | |
Vec | petsc_vector_ |
Underlying Petsc vector. | |
std::vector< PetscInt > | ghost_padding_ |
List of program-wise index of values that are ghost (i.e. required processor-wise but owned by another processor). | |
call_petsc_destroy | do_call_petsc_destroy_ = call_petsc_destroy::yes |
Whether the underlying Petsc vector will be destroyed upon destruction of the object. | |
std::string | name_ |
Advanced::Wrappers::Petsc::print_linalg_destruction | do_print_linalg_destruction_ |
Whether there is a print on standard output to inform of the deletion of the Matrix. | |
Friends | |
template<class VariationalFormulationT > | |
struct | Internal::SolverNS::SnesInterface |
Friendship (to enable ChangeInternal usage). | |
Special members. | |
GlobalVector (const NumberingSubset &numbering_subset, std::optional< std::string > name=std::nullopt) | |
Constructor. | |
virtual | ~GlobalVector () override |
Destructor. | |
GlobalVector (const GlobalVector &rhs, std::optional< std::string > name=std::nullopt) | |
The copy constructor. | |
GlobalVector (GlobalVector &&rhs)=default | |
The move constructor. | |
GlobalVector & | operator= (const GlobalVector &rhs)=delete |
The (copy) operator=. | |
GlobalVector & | operator= (GlobalVector &&rhs)=delete |
The (move) operator=. | |
GlobalVector (const NumberingSubset &numbering_subset, Internal::WrapPetscVec wrap_petsc_vector) | |
Constructor to provide a thin-wrapper over a Vec object. | |
Class which encapsulates both the Petsc vector and the numbering subset used to described it.
Alias to the type of the class.
|
explicit |
Constructor.
[in] | numbering_subset | NumberingSubset to use to define the numbering of the vector. |
[in] | name | A name that may optionally be given to the vector. |
This name may be used to provide hints in error messages - especially when the error occurs in PetscFinalize() call where all the information we get is given by PETSc error message and is frankly not that useful: knowing a VecDestroy() call fails doesn't tell for which vector it happens. If name is not provided, a default name featuring the numbering subset number is used.
MoReFEM::GlobalVector::GlobalVector | ( | const GlobalVector & | rhs, |
std::optional< std::string > | name = std::nullopt ) |
The copy constructor.
[in] | rhs | The object from which the construction occurs. |
[in] | name | A name that may optionally be given to the vector. |
This name may be used to provide hints in error messages - especially when the error occurs in PetscFinalize() call where all the information we get is given by PETSc error message and is frankly not that useful: knowing a VecDestroy() call fails doesn't tell for which vector it happens. If name is not provided, a default name featuring the numbering subset number is used.
|
explicitprivate |
Constructor to provide a thin-wrapper over a Vec object.
This constructor is not meant to be used widely - hence its private status - : it is used only when defining a Snes interface for a non-linear solver in PETSc. In this case, PETSc provides a Vec object to compute quantities such as residual or evaluation_state; we want to be able to manipulate them with high-level PETSc wrapper defined in MoReFEM. PETSc owns these linear algebra quantities, so we do not call VecDestroy at destruction.
[in] | numbering_subset | NumberingSubset to use to define the numbering of the vector. |
[in] | wrap_petsc_vector | A very thin wrapper object over a Vec . The sole purpose of the class used here is to make apparent at call site that it is really a very special constructor that is used. |
|
default |
The move constructor.
[in] | rhs | The object from which the construction occurs. |
|
delete |
The (copy) operator=.
[in] | rhs | The object from which the affectation occurs. |
|
delete |
The (move) operator=.
[in] | rhs | The object from which the affectation occurs. |
|
inherited |
Set the vector as sequential.
[in] | size | Number of elements in the vector. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Set the vector as sequential.
[in] | processor_wise_size | Number of elements processor-wise (ghosts excluded). |
[in] | program_wise_size | Number of elements program-wise. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Create a parallel vector with ghost padding.
[in] | processor_wise_size | Number of elements processor-wise (ghosts excluded). |
[in] | program_wise_size | Number of elements program-wise. |
[in] | ghost_padding | List of program-wise index of values that are ghost (i.e. required processor-wise but owned by another processor). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Init a sequential vector with the data read in the file.
This file is assumed to have been created with Print() method for a sequential vector.
[in] | file | File from which vector content is read. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Init a vector from the data read in the file.
This file is assumed to have been created with Print() method.
Current method is in fact able to create a sequential vector as well, but use rather InitSequentialFromAsciiFile() with its more friendly API if you need only the sequential case.
[in] | ascii_file | File from which vector content is read. |
[in] | processor_wise_size | Number of elements processor-wise (ghosts excluded). |
[in] | program_wise_size | Number of elements program-wise. |
[in] | ghost_padding | List of program-wise index of values that are ghost (i.e. required processor-wise but owned by another processor). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Init a vector from the data read in the file.
This file is assumed to have been created with Print() method.
[in] | binary_file | File from which vector content is read. |
[in] | processor_wise_size | Number of elements processor-wise (ghosts excluded). |
[in] | program_wise_size | Number of elements program-wise. |
[in] | ghost_padding | List of program-wise index of values that are ghost (i.e. required processor-wise but owned by another processor). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Init from a program-wise binary file: load a vector dumped with View() method.
[in] | binary_file | File from which the vector must be loaded. This file must be in binary format. |
[in] | processor_wise_size | Number of elements processor-wise (ghosts excluded). |
[in] | program_wise_size | Number of elements program-wise. |
[in] | ghost_padding | List of program-wise index of values that are ghost (i.e. required processor-wise but owned by another processor). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Handle over the internal Vec object.
do_check_non_null_ptr | If 'yes', check with an assert in debug mode whether the underlying pointer has been defined or not. 'yes' is really the go to value; 'no' is used only in some low level functions. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
Ideally it shouldn't be used at all except in the implementation of the Petsc Wrapper: a wrapper method should be implemented over the function that might need access to the Vec internal object.
|
inherited |
Handle over the internal Vec object - when you can guarantee the call is only to read the value, not act upon it.
do_check_non_null_ptr | If 'yes', check with an assert in debug mode whether the underlying pointer has been defined or not. 'yes' is really the go to value; 'no' is used only in some low level functions. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
Ideally it shouldn't be used at all except in the implementation of the Petsc Wrapper: a wrapper method should be implemented over the function that might need access to the Vec internal object.
|
inherited |
Duplicate layout (in memory, processor repartition, etc...)
[in] | original | Vector which layout is copied. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Get the number of elements in the local vector.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Get the number of elements in the global vector.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Set all the entries to zero.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
Petsc Assembling of the vector.
You have to call Assembly() method after you're done with all your SetXXX() calls; otherwise you will in all likelihood get error message in parallel about wrong state of the vector (but nothing in sequential run). It has not been put directly inside these SetXXX() methods as usually several of them are called in a row. For more details, see original explanation in Petsc page about vecSetValues: http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetValues.html#VecSetValues
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. This argument must be set to update_ghost::no if you're considering a parallel vector without ghost. |
There is a hidden call to it in boundary condition appliance; so maybe you
|
inherited |
Add or modify values inside a Petsc vector.
You have to call Assembly() method after you're done with all your SetXXX() calls; otherwise you will in all likelihood get error message in parallel about wrong state of the vector (but nothing in sequential run). It has not been put directly inside these SetXXX() methods as usually several of them are called in a row. For more details, see original explanation in Petsc page about vecSetValues: http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetValues.html#VecSetValues
[in] | indexing | All indexes (program-wise) that have to be modified in the vector are stored here. |
[in] | values | Values to put in the vector. This array should be the same size as indexing (unfortunately we can't check that here as it is a C array) |
[in] | insertOrAppend | Petsc ADD_VALUES or INSERT_VALUES (see Petsc documentation). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Add or modify values inside a Petsc vector.
You have to call Assembly() method after you're done with all your SetXXX() calls; otherwise you will in all likelihood get error message in parallel about wrong state of the vector (but nothing in sequential run). It has not been put directly inside these SetXXX() methods as usually several of them are called in a row. For more details, see original explanation in Petsc page about vecSetValues: http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetValues.html#VecSetValues
[in] | indexing | All indexes (program-wise) (program-wise) that have to be modified in the vector are stored here. |
[in] | local_vec | Local vector which values will be put inside vector. |
[in] | insertOrAppend | Petsc ADD_VALUES or INSERT_VALUES (see Petsc documentation). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Set the values of a vector from a Petsc Vec object.
[in] | petsc_vector | Petsc Vec object. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Get the values of a vector on a current process.
This method allocates a vector at each call, another method with the same name does the same thing without the allocation at each time and should be used if the calls happen several times for the same underlying data.
Used to get the values of a sequential vector (see AccessVectorContent for mpi vectors).
[in] | indexing | All program-wise indexes which are required from the vector. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Get the values of a vector on a current process.
Same as the other method with the same name but the vector to contain the values is not allocated at each call. This method should be called if you need to get the values of a vector with the same size a lot of time.
Used to get the values of a sequential vector (see AccessVectorContent for mpi vectors).
[in] | indexing | All program-wise indexes which are required from the vector. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | values | Vector used to contain the values. Should have been allocated before the call. |
|
inherited |
Same as GetValues() for a unique index.
[in] | index | Program-wise index which associated value is sought. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Add or modify one value inside a Petsc vector.
You have to call Assembly() method after you're done with all your SetXXX() calls; otherwise you will in all likelihood get error message in parallel about wrong state of the vector (but nothing in sequential run). It has not been put directly inside these SetXXX() methods as usually several of them are called in a row. For more details, see original explanation in Petsc page about vecSetValues: http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetValues.html#VecSetValues
[in] | index | Index (program-wise) to be modified. |
[in] | value | Value to set. |
[in] | insertOrAppend | Petsc ADD_VALUES or INSERT_VALUES (see Petsc documentation). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
Set the same value to all entries of the vector.
You have to call Assembly() method after you're done with all your SetXXX() calls; otherwise you will in all likelihood get error message in parallel about wrong state of the vector (but nothing in sequential run). It has not been put directly inside these SetXXX() methods as usually several of them are called in a row. For more details, see original explanation in Petsc page about vecSetValues: http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetValues.html#VecSetValues
[in] | value | Value to set. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
A wrapper over VecCopy, which assumed target already gets the right layout.
Doesn't do much except check the return value.
[in] | source | Original vector which content is copied. Layout is assumed to be already the same between object for which the method is called and source. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
A complete copy: layout is copied first and then the values.
[in] | source | Original vector which layout AND content is copied. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
Wrapper over VecScale, that performs Y = a * Y.
[in] | a | Factor by which the vector is scaled. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
Wrapper over VecShift, that performs Y = Y + a * 1.
[in] | a | Factor by which the vector is shifted. |
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Wrapper over VecView.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Wrapper over VecView in the case the viewer is a file.
[in] | format | Format in which the matrix is written. See Petsc manual pages to get all the formats available; relevant ones so far are PETSC_VIEWER_DEFAULT and PETSC_VIEWER_ASCII_MATLAB. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
[in] | output_file | File into which the vector content will be written. |
|
inherited |
Wrapper over MatView in the case the viewer is a binary file.
[in] | output_file | File into which the vector content will be written. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
inherited |
Print the content of a vector in a file.
MpiScaleT | Whether we want to print program-wise (in which case View function above is called) or processor-wise data. If processor-wise is chosen, this function does not rely on VecView: what I want to achieve is write to a different file for each processor and VecView doesn't seem to be able to do so. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
[in] | output_file | File into which the vector content will be written. |
[in] | binary_or_ascii_choice | Whether the vector should be printed as binary or ascii. Default value takes its cue from the choice written in the input data file. |
|
inherited |
Get the minimum.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Get the maximum.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Wrapper over VecNorm.
Available norms are NORM_1, NORM_2 and NORM_INFINITY.
[in] | type | NORM_1, NORM_2 or NORM_INFINITY. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Update the ghost values.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
Prior to 2024, behaviour when applied upon a vector without ghost was left to PETSc. I have now changed that: when it is unduly called (i.e. when IsGhosted()
returns false) it just does nothing.
Beware: all processor must make the call to this method! If for instance you're in a loop and one processor leaves it before the other, the code will be deadlocked...
|
inherited |
Update the ghost values if do_update_ghost is set to yes.
This convenient method should be used only in Vector or Matrix related functions that provides the possibility to automatically update ghosts through an ad hoc argument (see for instance Copy() method).
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
Prior to 2024, behaviour when applied upon a vector without ghost was left to PETSc. I have now changed that: when it is unduly called (i.e. when IsGhosted()
returns false) it just does nothing.
Beware: all processor must make the call to this method! If for instance you're in a loop and one processor leaves it before the other, the code will be deadlocked...
[in] | do_update_ghost | Whether the target gets its ghost automatically updated or not. Default is yes. |
|
inherited |
Tells whether a vector is sequential or parallel.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
inherited |
Tells whether a vector is ghosted or not.
PETSc does not provide a direct function to do so by choice (see this discussion).
However they provide nonetheless a way: VecGhostGetLocalForm
provides a null pointer if invoked on ghost element.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
noexceptinherited |
Accessor to the list of program-wise index of values that are ghost.
(i.e. required processor-wise but owned by another processor).
Shouldn't be called if not a vector with ghost (an assert checks that).
|
inherited |
Tells the class not to destroy the underlying vector through a call to VecDestroy().
|
noexceptinherited |
Get the name given to the vector at construction.
This is intended as a developer tool for debug, especially when something goes awry with PetscFinalize().
It should be noticed that inherited class GlobalVector may provide a default name if none was given; no default name however is foreseen in current base class.
|
protectedinherited |
Change the underlying PETSc pointer .
[in] | new_petsc_vector | The new underlying PETSc Vec (which is a typedef to a pointer). |
This functionality was introduced after version 3.12 of PETSc: I realized after the non linear code failed that I didn't set it up properly. The functions given to SNESSetFunction and SNESSetJacobian must work on Vec and Mat objects handled completely by PETSc; it just happened in prior versions of the library it used up the system matrices and vectors given to SolveNonLinear. So these functions now start by creating on the stack respectively a GlobalVector and a GlobalMatrix; ChangeInternal is then called so that these temporary objects handle internally the objects provided by PETSc API.
|
protectedinherited |
Tells the type of the current vector.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
This is a thin wrapper over VecGetType.
As the API is not great (returns VecType that is a pointer so comparison to a VecType such as VECSEQ could yield unexpected result) I make it provate. More sugary methods such as IsSequential
or IsParallel
will be introduced instead.
|
inlinestaticconstexpr |
Keyword to indicate that this class qualify for the Concept::GlobalLinearAlgebra.
|
privateinherited |
List of program-wise index of values that are ghost (i.e. required processor-wise but owned by another processor).
Left empty if sequential or mpi without ghost.
|
privateinherited |
Whether the underlying Petsc vector will be destroyed upon destruction of the object.
Default behaviour is to do so, but in some cases (for instance when vector has been built from an existing Petsc Vec) it is wiser not to.
|
privateinherited |
This name may be used to provide hints in error messages - especially when the error occurs in PetscFinalize() call where all the information we get is given by PETSc error message and is frankly not that useful: knowing a VecDestroy() call fails doesn't tell for which vector it happens.
|
privateinherited |
Whether there is a print on standard output to inform of the deletion of the Matrix.