KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
The space adapted for Trilinos vectors and matrices. More...
#include <trilinos_space.h>
Public Member Functions | |
Life Cycle | |
TrilinosSpace () | |
Default constructor. More... | |
virtual | ~TrilinosSpace () |
Destructor. More... | |
Type Definitions | |
using | DataType = double |
Definition of the data type. More... | |
using | MatrixType = TMatrixType |
Definition of the matrix type. More... | |
using | VectorType = TVectorType |
Definition of the vector type. More... | |
using | IndexType = std::size_t |
Definition of the index type. More... | |
using | SizeType = std::size_t |
Definition of the size type. More... | |
using | MatrixPointerType = typename Kratos::shared_ptr< TMatrixType > |
Definition of the pointer types. More... | |
using | VectorPointerType = typename Kratos::shared_ptr< TVectorType > |
using | DofUpdaterType = TrilinosDofUpdater< TrilinosSpace< TMatrixType, TVectorType > > |
Some other definitions. More... | |
using | DofUpdaterPointerType = typename DofUpdater< TrilinosSpace< TMatrixType, TVectorType > >::UniquePointer |
KRATOS_CLASS_POINTER_DEFINITION (TrilinosSpace) | |
Pointer definition of TrilinosSpace. More... | |
Operations | |
MatrixPointerType | ReadMatrixMarket (const std::string FileName, Epetra_MpiComm &rComm) |
Read a matrix from a MatrixMarket file. More... | |
VectorPointerType | ReadMatrixMarketVector (const std::string &rFileName, Epetra_MpiComm &rComm, const int N) |
Read a vector from a MatrixMarket file. More... | |
static MatrixPointerType | CreateEmptyMatrixPointer () |
This method creates an empty pointer to a matrix. More... | |
static VectorPointerType | CreateEmptyVectorPointer () |
This method creates an empty pointer to a vector. More... | |
static MatrixPointerType | CreateEmptyMatrixPointer (Epetra_MpiComm &rComm) |
This method creates an empty pointer to a matrix using epetra communicator. More... | |
static VectorPointerType | CreateEmptyVectorPointer (Epetra_MpiComm &rComm) |
This method creates an empty pointer to a vector using epetra communicator. More... | |
static IndexType | Size (const VectorType &rV) |
Returns size of vector rV. More... | |
static IndexType | Size1 (MatrixType const &rM) |
Returns number of rows of rM. More... | |
static IndexType | Size2 (MatrixType const &rM) |
Returns number of columns of rM. More... | |
static void | GetColumn (const unsigned int j, const MatrixType &rM, VectorType &rX) |
Returns the column of the matrix in the given position. More... | |
static void | Copy (const MatrixType &rX, MatrixType &rY) |
Returns a copy of the matrix rX. More... | |
static void | Copy (const VectorType &rX, VectorType &rY) |
Returns a copy of the vector rX. More... | |
static double | Dot (const VectorType &rX, const VectorType &rY) |
Returns the product of two vectors. More... | |
static double | Max (const VectorType &rX) |
Returns the maximum value of the vector rX. More... | |
static double | Min (const VectorType &rX) |
Returns the minimum value of the vector rX. More... | |
static double | TwoNorm (const VectorType &rX) |
Returns the norm of the vector rX. More... | |
static double | TwoNorm (const MatrixType &rA) |
Returns the Frobenius norm of the matrix rX. More... | |
static void | Mult (const MatrixType &rA, const VectorType &rX, VectorType &rY) |
Returns the multiplication of a matrix by a vector. More... | |
static void | Mult (const MatrixType &rA, const MatrixType &rB, MatrixType &rC, const bool CallFillCompleteOnResult=true, const bool KeepAllHardZeros=false) |
Returns the multiplication matrix-matrix. More... | |
static void | TransposeMult (const MatrixType &rA, const VectorType &rX, VectorType &rY) |
Returns the transpose multiplication of a matrix by a vector. More... | |
static void | TransposeMult (const MatrixType &rA, const MatrixType &rB, MatrixType &rC, const std::pair< bool, bool > TransposeFlag={false, false}, const bool CallFillCompleteOnResult=true, const bool KeepAllHardZeros=false) |
Returns the transpose multiplication matrix-matrix. More... | |
static void | BtDBProductOperation (MatrixType &rA, const MatrixType &rD, const MatrixType &rB, const bool CallFillCompleteOnResult=true, const bool KeepAllHardZeros=false, const bool EnforceInitialGraph=false) |
Calculates the product operation B'DB. More... | |
static void | BDBtProductOperation (MatrixType &rA, const MatrixType &rD, const MatrixType &rB, const bool CallFillCompleteOnResult=true, const bool KeepAllHardZeros=false, const bool EnforceInitialGraph=false) |
Calculates the product operation BDB'. More... | |
static void | InplaceMult (VectorType &rX, const double A) |
Returns the multiplication of a vector by a scalar. More... | |
static void | Assign (VectorType &rX, const double A, const VectorType &rY) |
Returns the multiplication of a vector by a scalar. More... | |
static void | UnaliasedAdd (VectorType &rX, const double A, const VectorType &rY) |
Returns the unaliased addition of a vector by a scalar times a vector. More... | |
static void | ScaleAndAdd (const double A, const VectorType &rX, const double B, const VectorType &rY, VectorType &rZ) |
Returns the unaliased addition of two vectors by a scalar. More... | |
static void | ScaleAndAdd (const double A, const VectorType &rX, const double B, VectorType &rY) |
Returns the unaliased addition of two vectors by a scalar. More... | |
static void | SetValue (VectorType &rX, IndexType i, const double value) |
Sets a value in a vector. More... | |
static void | Set (VectorType &rX, const DataType A) |
assigns a scalar to a vector More... | |
static void | Resize (MatrixType &rA, const SizeType m, const SizeType n) |
Resizes a matrix. More... | |
static void | Resize (VectorType &rX, const SizeType n) |
Resizes a vector. More... | |
static void | Resize (VectorPointerType &pX, const SizeType n) |
Resizes a vector. More... | |
static void | Clear (MatrixPointerType &pA) |
Clears a matrix. More... | |
static void | Clear (VectorPointerType &pX) |
Clears a vector. More... | |
static void | SetToZero (MatrixType &rA) |
Sets a matrix to zero. More... | |
static void | SetToZero (VectorType &rX) |
Sets a vector to zero. More... | |
static void | AssembleLHS (MatrixType &rA, const Matrix &rLHSContribution, const std::vector< std::size_t > &rEquationId) |
TODO: creating the the calculating reaction version. More... | |
static void | AssembleRHS (VectorType &rb, const Vector &rRHSContribution, const std::vector< std::size_t > &rEquationId) |
TODO: creating the the calculating reaction version. More... | |
static constexpr bool | IsDistributed () |
This function returns if we are in a distributed system. More... | |
static double | GetValue (const VectorType &rX, const std::size_t I) |
This function returns a value from a given vector according to a given index. More... | |
static void | GatherValues (const VectorType &rX, const std::vector< int > &IndexArray, double *pValues) |
This function gathers the values of a given vector according to a given index array. More... | |
static Epetra_CrsGraph | CombineMatricesGraphs (const MatrixType &rA, const MatrixType &rB) |
Generates a graph combining the graphs of two matrices. More... | |
static void | CopyMatrixValues (MatrixType &rA, const MatrixType &rB) |
Copy values from one matrix to another. More... | |
static double | CheckAndCorrectZeroDiagonalValues (const ProcessInfo &rProcessInfo, MatrixType &rA, VectorType &rb, const SCALING_DIAGONAL ScalingDiagonal=SCALING_DIAGONAL::NO_SCALING) |
This method checks and corrects the zero diagonal values. More... | |
static double | GetScaleNorm (const ProcessInfo &rProcessInfo, const MatrixType &rA, const SCALING_DIAGONAL ScalingDiagonal=SCALING_DIAGONAL::NO_SCALING) |
This method returns the scale norm considering for scaling the diagonal. More... | |
static double | GetDiagonalNorm (const MatrixType &rA) |
This method returns the diagonal norm considering for scaling the diagonal. More... | |
static double | GetAveragevalueDiagonal (const MatrixType &rA) |
This method returns the diagonal max value. More... | |
static double | GetMaxDiagonal (const MatrixType &rA) |
This method returns the diagonal max value. More... | |
static double | GetMinDiagonal (const MatrixType &rA) |
This method returns the diagonal min value. More... | |
static constexpr bool | IsDistributedSpace () |
Check if the TrilinosSpace is distributed. More... | |
Input and output | |
virtual std::string | Info () const |
Turn back information as a string. More... | |
virtual void | PrintInfo (std::ostream &rOStream) const |
Print information about this object. More... | |
virtual void | PrintData (std::ostream &rOStream) const |
Print object's data. More... | |
template<class TOtherMatrixType > | |
static bool | WriteMatrixMarketMatrix (const char *pFileName, const TOtherMatrixType &rM, const bool Symmetric) |
Writes a matrix to a file in MatrixMarket format. More... | |
template<class VectorType > | |
static bool | WriteMatrixMarketVector (const char *pFileName, const VectorType &rV) |
Writes a vector to a file in MatrixMarket format. More... | |
static DofUpdaterPointerType | CreateDofUpdater () |
Creates a new dof updater. More... | |
The space adapted for Trilinos vectors and matrices.
TMatrixType | The matrix type considered |
TVectorType | the vector type considered |
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::DataType = double |
Definition of the data type.
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::DofUpdaterPointerType = typename DofUpdater<TrilinosSpace<TMatrixType,TVectorType> >::UniquePointer |
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::DofUpdaterType = TrilinosDofUpdater< TrilinosSpace<TMatrixType,TVectorType> > |
Some other definitions.
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::IndexType = std::size_t |
Definition of the index type.
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::MatrixPointerType = typename Kratos::shared_ptr<TMatrixType> |
Definition of the pointer types.
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::MatrixType = TMatrixType |
Definition of the matrix type.
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::SizeType = std::size_t |
Definition of the size type.
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::VectorPointerType = typename Kratos::shared_ptr<TVectorType> |
using Kratos::TrilinosSpace< TMatrixType, TVectorType >::VectorType = TVectorType |
Definition of the vector type.
|
inline |
Default constructor.
|
inlinevirtual |
Destructor.
|
inlinestatic |
TODO: creating the the calculating reaction version.
Assembles the LHS of the system
rA | The LHS matrix |
rLHSContribution | The contribution to the LHS |
rEquationId | The equation ids |
|
inlinestatic |
TODO: creating the the calculating reaction version.
Assembles the RHS of the system
rb | The RHS vector |
rRHSContribution | The RHS contribution |
rEquationId | The equation ids |
|
inlinestatic |
Returns the multiplication of a vector by a scalar.
x = A*y Checks if a multiplication is needed and tries to do otherwise
rX | The resulting vector considered |
A | The scalar considered |
rY | The multiplied vector considered |
|
inlinestatic |
Calculates the product operation BDB'.
rA | The resulting matrix |
rD | The "center" matrix |
rB | The matrices to be transposed |
CallFillCompleteOnResult | Optional argument, defaults to true. Power users may specify this argument to be false if they DON'T want this function to call C.FillComplete. (It is often useful to allow this function to call C.FillComplete, in cases where one or both of the input matrices are rectangular and it is not trivial to know which maps to use for the domain- and range-maps.) |
KeepAllHardZeros | Optional argument, defaults to false. If true, Multiply, keeps all entries in C corresponding to hard zeros. If false, the following happens by case: A*B^T, A^T*B^T - Does not store entries caused by hard zeros in C. A^T*B (unoptimized) - Hard zeros are always stored (this option has no effect) A*B, A^T*B (optimized) - Hard zeros in corresponding to hard zeros in A are not stored, There are certain cases involving reuse of C, where this can be useful. |
TEnforceInitialGraph | If the initial graph is enforced, or a new one is generated |
|
inlinestatic |
Calculates the product operation B'DB.
rA | The resulting matrix |
rD | The "center" matrix |
rB | The matrices to be transposed |
CallFillCompleteOnResult | Optional argument, defaults to true. Power users may specify this argument to be false if they DON'T want this function to call C.FillComplete. (It is often useful to allow this function to call C.FillComplete, in cases where one or both of the input matrices are rectangular and it is not trivial to know which maps to use for the domain- and range-maps.) |
KeepAllHardZeros | Optional argument, defaults to false. If true, Multiply, keeps all entries in C corresponding to hard zeros. If false, the following happens by case: A*B^T, A^T*B^T - Does not store entries caused by hard zeros in C. A^T*B (unoptimized) - Hard zeros are always stored (this option has no effect) A*B, A^T*B (optimized) - Hard zeros in corresponding to hard zeros in A are not stored, There are certain cases involving reuse of C, where this can be useful. |
TEnforceInitialGraph | If the initial graph is enforced, or a new one is generated |
|
inlinestatic |
This method checks and corrects the zero diagonal values.
This method returns the scale norm considering for scaling the diagonal
rProcessInfo | The problem process info |
rA | The LHS matrix |
rb | The RHS vector |
ScalingDiagonal | The type of caling diagonal considered |
|
inlinestatic |
Clears a matrix.
pA | The pointer to the matrix to be cleared |
|
inlinestatic |
Clears a vector.
pX | The pointer to the vector to be cleared |
|
inlinestatic |
Generates a graph combining the graphs of two matrices.
rA | The first matrix |
rB | The second matrix |
|
inlinestatic |
Returns a copy of the matrix rX.
rY = rX
rX | The matrix considered |
rY | The copy of the matrix rX |
|
inlinestatic |
Returns a copy of the vector rX.
rY = rX
rX | The vector considered |
rY | The copy of the vector rX |
|
inlinestatic |
Copy values from one matrix to another.
It is assumed that the sparcity of both matrices is compatible
rA | The matrix where assigning values |
rB | The matrix to be copied |
|
inlinestatic |
Creates a new dof updater.
|
inlinestatic |
This method creates an empty pointer to a matrix.
|
inlinestatic |
This method creates an empty pointer to a matrix using epetra communicator.
rComm | The epetra communicator |
|
inlinestatic |
This method creates an empty pointer to a vector.
|
inlinestatic |
This method creates an empty pointer to a vector using epetra communicator.
rComm | The epetra communicator |
|
inlinestatic |
Returns the product of two vectors.
rX * rY
rX | The first vector considered |
rY | The second vector considered |
|
inlinestatic |
This function gathers the values of a given vector according to a given index array.
rX | The vector from which values are to be gathered |
IndexArray | The array containing the indices of the values to be gathered |
pValues | The array containing the gathered values |
|
inlinestatic |
This method returns the diagonal max value.
rA | The LHS matrix |
|
inlinestatic |
Returns the column of the matrix in the given position.
rXi = rMij
j | The position of the column |
rM | The matrix considered |
rX | The column considered |
|
inlinestatic |
This method returns the diagonal norm considering for scaling the diagonal.
rA | The LHS matrix |
|
inlinestatic |
This method returns the diagonal max value.
rA | The LHS matrix |
|
inlinestatic |
This method returns the diagonal min value.
rA | The LHS matrix |
|
inlinestatic |
This method returns the scale norm considering for scaling the diagonal.
rProcessInfo | The problem process info |
rA | The LHS matrix |
ScalingDiagonal | The type of caling diagonal considered |
|
inlinestatic |
This function returns a value from a given vector according to a given index.
rX | The vector from which values are to be gathered |
I | The index of the value to be gathered |
|
inlinevirtual |
Turn back information as a string.
|
inlinestatic |
Returns the multiplication of a vector by a scalar.
y = A*x Checks if a multiplication is needed and tries to do otherwise
rX | The vector considered |
A | The scalar considered |
|
inlinestaticconstexpr |
This function returns if we are in a distributed system.
|
inlinestaticconstexpr |
Check if the TrilinosSpace is distributed.
This static member function checks whether the TrilinosSpace is distributed or not.
Kratos::TrilinosSpace< TMatrixType, TVectorType >::KRATOS_CLASS_POINTER_DEFINITION | ( | TrilinosSpace< TMatrixType, TVectorType > | ) |
Pointer definition of TrilinosSpace.
|
inlinestatic |
Returns the maximum value of the vector rX.
rX | The vector considered |
|
inlinestatic |
Returns the minimum value of the vector rX.
rX | The vector considered |
|
inlinestatic |
Returns the multiplication matrix-matrix.
C = A*B
rA | The first matrix considered |
rB | The second matrix considered |
rC | The result of the multiplication |
CallFillCompleteOnResult | Optional argument, defaults to true. Power users may specify this argument to be false if they DON'T want this function to call C.FillComplete. (It is often useful to allow this function to call C.FillComplete, in cases where one or both of the input matrices are rectangular and it is not trivial to know which maps to use for the domain- and range-maps.) |
KeepAllHardZeros | Optional argument, defaults to false. If true, Multiply, keeps all entries in C corresponding to hard zeros. If false, the following happens by case: A*B^T, A^T*B^T - Does not store entries caused by hard zeros in C. A^T*B (unoptimized) - Hard zeros are always stored (this option has no effect) A*B, A^T*B (optimized) - Hard zeros in corresponding to hard zeros in A are not stored, There are certain cases involving reuse of C, where this can be useful. |
|
inlinestatic |
Returns the multiplication of a matrix by a vector.
y = A*x
rA | The matrix considered |
rX | The vector considered |
rY | The result of the multiplication |
|
inlinevirtual |
Print object's data.
rOStream | The output stream to print on. |
|
inlinevirtual |
Print information about this object.
rOStream | The output stream to print on. |
|
inline |
Read a matrix from a MatrixMarket file.
rFileName | The name of the file to read |
rComm | The MPI communicator |
|
inline |
Read a vector from a MatrixMarket file.
rFileName | The name of the file to read |
rComm | The MPI communicator |
N | The size of the vector |
|
inlinestatic |
Resizes a matrix.
rA | The matrix to be resized |
m | The new number of rows |
n | The new number of columns |
|
inlinestatic |
Resizes a vector.
pA | The pointer to the vector to be resized |
n | The new size |
|
inlinestatic |
Resizes a vector.
rX | The vector to be resized |
n | The new size |
|
inlinestatic |
Returns the unaliased addition of two vectors by a scalar.
rZ = (A * rX) + (B * rY)
A | The scalar considered |
rX | The first vector considered |
B | The scalar considered |
rY | The second vector considered |
rZ | The resulting vector considered |
|
inlinestatic |
Returns the unaliased addition of two vectors by a scalar.
rY = (A * rX) + (B * rY)
A | The scalar considered |
rX | The first vector considered |
B | The scalar considered |
rY | The resulting vector considered |
|
inlinestatic |
assigns a scalar to a vector
rX = A
rX | The vector considered |
A | The scalar considered |
|
inlinestatic |
Sets a matrix to zero.
rX | The matrix to be set |
|
inlinestatic |
Sets a vector to zero.
rX | The vector to be set |
|
inlinestatic |
Sets a value in a vector.
rX | The vector considered |
i | The index of the value considered |
value | The value considered |
|
inlinestatic |
Returns size of vector rV.
rV | The vector considered |
|
inlinestatic |
Returns number of rows of rM.
rM | The matrix considered |
|
inlinestatic |
Returns number of columns of rM.
rM | The matrix considered |
|
inlinestatic |
Returns the transpose multiplication matrix-matrix.
C = A*B
rA | The first matrix considered |
rB | The second matrix considered |
rC | The result of the multiplication |
TransposeFlag | Flags to transpose the matrices |
CallFillCompleteOnResult | Optional argument, defaults to true. Power users may specify this argument to be false if they DON'T want this function to call C.FillComplete. (It is often useful to allow this function to call C.FillComplete, in cases where one or both of the input matrices are rectangular and it is not trivial to know which maps to use for the domain- and range-maps.) |
KeepAllHardZeros | Optional argument, defaults to false. If true, Multiply, keeps all entries in C corresponding to hard zeros. If false, the following happens by case: A*B^T, A^T*B^T - Does not store entries caused by hard zeros in C. A^T*B (unoptimized) - Hard zeros are always stored (this option has no effect) A*B, A^T*B (optimized) - Hard zeros in corresponding to hard zeros in A are not stored, There are certain cases involving reuse of C, where this can be useful. |
|
inlinestatic |
Returns the transpose multiplication of a matrix by a vector.
y = AT*x
rA | The matrix considered |
rX | The vector considered |
rY | The result of the multiplication |
|
inlinestatic |
Returns the Frobenius norm of the matrix rX.
||rA||2
rA | The matrix considered |
|
inlinestatic |
Returns the norm of the vector rX.
||rX||2
rX | The vector considered |
|
inlinestatic |
Returns the unaliased addition of a vector by a scalar times a vector.
X += A*y; Checks if a multiplication is needed and tries to do otherwise
rX | The resulting vector considered |
A | The scalar considered |
rY | The multiplied vector considered |
|
inlinestatic |
Writes a matrix to a file in MatrixMarket format.
pFileName | The name of the file to be written |
rM | The matrix to be written |
Symmetric | If the matrix is symmetric |
|
inlinestatic |
Writes a vector to a file in MatrixMarket format.
pFileName | The name of the file to be written |
rV | The vector to be written |