Commit cba26961 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#902 Wrappers/Petsc: AXPY now uses a template parameter, which is an enum...

#902 Wrappers/Petsc: AXPY now uses a template parameter, which is an enum class proposing the different non zero pattern choices. This helps separate the computation arguments to the options during the call.
parent ea2a84ee
......@@ -501,6 +501,9 @@
BE3E664D1ACEB94E00A3F7E2 /* Connectivity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE3E664A1ACEB94E00A3F7E2 /* Connectivity.cpp */; };
BE3E664E1ACEB94E00A3F7E2 /* Connectivity.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE3E664B1ACEB94E00A3F7E2 /* Connectivity.hpp */; };
BE3E664F1ACEB94E00A3F7E2 /* Connectivity.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE3E664C1ACEB94E00A3F7E2 /* Connectivity.hxx */; };
BE3F2EDA1CD259EB00125E90 /* NonZeroPattern.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE3F2ED81CD259E100125E90 /* NonZeroPattern.hpp */; };
BE3F2EDC1CD260FE00125E90 /* NonZeroPattern.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE3F2EDB1CD260FE00125E90 /* NonZeroPattern.hpp */; };
BE3F2EDE1CD2616D00125E90 /* NonZeroPattern.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE3F2EDD1CD2616D00125E90 /* NonZeroPattern.hxx */; };
BE4053EB1AC172580024D5F9 /* FEltSpace.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE4053E81AC172580024D5F9 /* FEltSpace.hpp */; };
BE4053EC1AC172580024D5F9 /* FEltSpace.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE4053E91AC172580024D5F9 /* FEltSpace.hxx */; };
BE4053F71AC1729B0024D5F9 /* FEltSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE4053F41AC1729B0024D5F9 /* FEltSpace.cpp */; };
......@@ -4672,6 +4675,9 @@
BE3E664A1ACEB94E00A3F7E2 /* Connectivity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Connectivity.cpp; sourceTree = "<group>"; };
BE3E664B1ACEB94E00A3F7E2 /* Connectivity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Connectivity.hpp; sourceTree = "<group>"; };
BE3E664C1ACEB94E00A3F7E2 /* Connectivity.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Connectivity.hxx; sourceTree = "<group>"; };
BE3F2ED81CD259E100125E90 /* NonZeroPattern.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NonZeroPattern.hpp; sourceTree = "<group>"; };
BE3F2EDB1CD260FE00125E90 /* NonZeroPattern.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NonZeroPattern.hpp; sourceTree = "<group>"; };
BE3F2EDD1CD2616D00125E90 /* NonZeroPattern.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NonZeroPattern.hxx; sourceTree = "<group>"; };
BE4053E81AC172580024D5F9 /* FEltSpace.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FEltSpace.hpp; sourceTree = "<group>"; };
BE4053E91AC172580024D5F9 /* FEltSpace.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FEltSpace.hxx; sourceTree = "<group>"; };
BE4053F41AC1729B0024D5F9 /* FEltSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FEltSpace.cpp; sourceTree = "<group>"; };
......@@ -8119,6 +8125,8 @@
BE5B6F871C3C16E9004A0284 /* Private */ = {
isa = PBXGroup;
children = (
BE3F2ED81CD259E100125E90 /* NonZeroPattern.hpp */,
BE3F2EDD1CD2616D00125E90 /* NonZeroPattern.hxx */,
BE5B6F881C3C16E9004A0284 /* BaseMatrix.hpp */,
);
path = Private;
......@@ -10633,6 +10641,7 @@
BE5B6F891C3C16E9004A0284 /* ShellMatrix.cpp */,
BE5B6F8A1C3C16E9004A0284 /* ShellMatrix.hpp */,
BE5B6F8B1C3C16E9004A0284 /* ShellMatrix.hxx */,
BE3F2EDB1CD260FE00125E90 /* NonZeroPattern.hpp */,
BE5B6F851C3C16E9004A0284 /* MatrixOperations.hpp */,
BE5B6F861C3C16E9004A0284 /* MatrixOperations.hxx */,
BEEFEF75196ECCC000C80FF1 /* MatrixPattern.cpp */,
......@@ -11289,6 +11298,7 @@
BE90E17B1A24926E00CCAFDE /* Singleton.hpp in Headers */,
BE90E1CD1A2492AA00CCAFDE /* PetscMat.hpp in Headers */,
BE90E1911A24929A00CCAFDE /* Folder.hpp in Headers */,
BE3F2EDC1CD260FE00125E90 /* NonZeroPattern.hpp in Headers */,
BEDEB9241C3C073100B1C71B /* Gmres.hxx in Headers */,
BE90E1721A24926E00CCAFDE /* String.hpp in Headers */,
BE168EA81CC96E020090AC88 /* Hexahedron8.hxx in Headers */,
......@@ -11320,6 +11330,7 @@
BE90E16C1A24926E00CCAFDE /* UnorderedMap.hpp in Headers */,
BE90E1C51A2492AA00CCAFDE /* SubVector_Base.hpp in Headers */,
BE5389FD1C897FE400D80749 /* Mpi.hpp in Headers */,
BE3F2EDE1CD2616D00125E90 /* NonZeroPattern.hxx in Headers */,
BE90E1B01A24929A00CCAFDE /* Vector.hpp in Headers */,
BEDEB9301C3C073100B1C71B /* Snes.hxx in Headers */,
BE90E1D01A2492AA00CCAFDE /* PetscVec.hpp in Headers */,
......@@ -11459,6 +11470,7 @@
BE6FFAD91A399E2200D048BD /* Numeric.hxx in Headers */,
BE90E1A51A24929A00CCAFDE /* Helper.hpp in Headers */,
BE768EAC1B833366009B24CB /* TupleItem.hpp in Headers */,
BE3F2EDA1CD259EB00125E90 /* NonZeroPattern.hpp in Headers */,
BE90E1D81A2492AA00CCAFDE /* Directory.hpp in Headers */,
BE90E1921A24929A00CCAFDE /* UniqueId.hpp in Headers */,
BE90E1D31A2492AA00CCAFDE /* Logs.hpp in Headers */,
......@@ -45,6 +45,7 @@ core_src = Split('''
./InputParameter/Reaction/MitchellSchaeffer.cpp
./InputParameter/Reaction/ReactionCoefficient.cpp
./InputParameter/Result.cpp
./InputParameter/Solver/ConvergenceTest.cpp
./InputParameter/Solver/Private/Petsc.cpp
./InputParameter/TimeManager/TimeManager.cpp
./LinearAlgebra/GlobalDiagonalMatrix.cpp
......@@ -56,7 +57,7 @@ core_src = Split('''
./TimeManager/Policy/ConstantTimeStep.cpp
./TimeManager/TimeManager.cpp
./TimeManager/TimeManagerInstance.cpp
''')
''')
core_lib = custom.HappyHeartLibrary(env, 'happy_heart_core', core_src)
......
......@@ -220,7 +220,7 @@ namespace HappyHeart
AssertSameNumberingSubset(stiffness_matrix, system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, theta, stiffness_matrix, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( theta, stiffness_matrix, system_matrix, __FILE__, __LINE__);
}
......
......@@ -346,9 +346,9 @@ namespace HappyHeart
AssertSameNumberingSubset(system_matrix, mass_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., matrix_bidomain, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., matrix_capacity, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1.e-06, mass_matrix, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., matrix_bidomain, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., matrix_capacity, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1.e-06, mass_matrix, system_matrix, __FILE__, __LINE__);
}
......
......@@ -358,8 +358,8 @@ namespace HappyHeart
AssertSameNumberingSubset(system_matrix, matrix_capacity);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., matrix_bidomain, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., matrix_capacity, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., matrix_bidomain, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., matrix_capacity, system_matrix, __FILE__, __LINE__);
}
......@@ -395,7 +395,7 @@ namespace HappyHeart
rhs.ZeroEntries(__FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., GetVectorTranscellularIonSource(), rhs, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., GetVectorTranscellularIonSource(), rhs, __FILE__, __LINE__);
}
......@@ -412,7 +412,7 @@ namespace HappyHeart
if (time > time_init && time < time_final)
{
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., GetVectorTranscellularCurrentAppliedOnLeftVentricle(), rhs, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., GetVectorTranscellularCurrentAppliedOnLeftVentricle(), rhs, __FILE__, __LINE__);
}
}
......@@ -426,7 +426,7 @@ namespace HappyHeart
if (time > time_init && time < time_final)
{
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., GetVectorTranscellularCurrentAppliedOnRightVentricle(), rhs, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., GetVectorTranscellularCurrentAppliedOnRightVentricle(), rhs, __FILE__, __LINE__);
}
}
}
......@@ -466,7 +466,7 @@ namespace HappyHeart
auto& vector_of_one = GetNonCstVectorOfOneOnExtracellularPotential();
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, -mean, vector_of_one, system_solution, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( -mean, vector_of_one, system_solution, __FILE__, __LINE__);
}
......
......@@ -697,12 +697,12 @@ namespace HappyHeart
AssertSameNumberingSubset(GetMatrixMassPerSquareTimeStep(), system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1.,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1.,
GetMatrixMassPerSquareTimeStep(),
system_matrix, __FILE__, __LINE__);
}
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, coefficient,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( coefficient,
GetMatrixTangentStiffness(),
system_matrix, __FILE__, __LINE__);
......@@ -714,7 +714,7 @@ namespace HappyHeart
AssertSameNumberingSubset(GetMatrixTangentFollowingPressure(), system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, coefficient,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( coefficient,
GetMatrixTangentFollowingPressure(),
system_matrix, __FILE__, __LINE__);
}
......
......@@ -194,7 +194,7 @@ namespace HappyHeart
AssertSameNumberingSubset(mass, system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, coefficient,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( coefficient,
mass,
system_matrix,
__FILE__, __LINE__);
......@@ -214,7 +214,7 @@ namespace HappyHeart
AssertSameNumberingSubset(stiffness, displacement_previous_time_iteration_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, -.5,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( -.5,
stiffness,
displacement_previous_time_iteration_matrix,
__FILE__, __LINE__);
......
......@@ -219,7 +219,7 @@ namespace HappyHeart
AssertSameNumberingSubset(residual_matrix, mass_fluid_velocity);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., mass_fluid_velocity, residual_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., mass_fluid_velocity, residual_matrix, __FILE__, __LINE__);
}
......
......@@ -125,7 +125,7 @@ namespace HappyHeart
AssertSameNumberingSubset(mass, system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, coefficient,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( coefficient,
mass,
system_matrix,
__FILE__, __LINE__);
......@@ -145,7 +145,7 @@ namespace HappyHeart
AssertSameNumberingSubset(stiffness, displacement_previous_time_iteration_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, -.5,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( -.5,
stiffness,
displacement_previous_time_iteration_matrix,
__FILE__, __LINE__);
......
......@@ -238,7 +238,7 @@ namespace HappyHeart
#ifndef NDEBUG
AssertSameNumberingSubset(GetMatrixRobin(), system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., GetMatrixRobin(), system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., GetMatrixRobin(), system_matrix, __FILE__, __LINE__);
}
......@@ -326,7 +326,7 @@ namespace HappyHeart
AssertSameNumberingSubset(capacity_matrix, system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1.,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1.,
capacity_matrix,
system_matrix,
__FILE__, __LINE__);
......
......@@ -66,12 +66,12 @@ namespace HappyHeart
AssertSameNumberingSubset(system_matrix, vm.GetMatrixStiffnessPreviousTimeIteration());
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN,
Wrappers::Petsc::AXPY<NonZeroPattern::same>(
0.5,
vm.GetMatrixNewStiffness(),
system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN,
Wrappers::Petsc::AXPY<NonZeroPattern::same>(
0.5,
vm.GetMatrixStiffnessPreviousTimeIteration(),
system_matrix, __FILE__, __LINE__);
......
......@@ -71,9 +71,9 @@ namespace HappyHeart
AssertSameNumberingSubset(vm.GetMatrixNewStiffness(), system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 0.5,
vm.GetMatrixNewStiffness(),
system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 0.5,
vm.GetMatrixNewStiffness(),
system_matrix, __FILE__, __LINE__);
}
......
......@@ -184,7 +184,7 @@ namespace HappyHeart
#ifndef NDEBUG
AssertSameNumberingSubset(mass_fluid_velocity, residual_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., mass_fluid_velocity, residual_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., mass_fluid_velocity, residual_matrix, __FILE__, __LINE__);
}
......@@ -229,7 +229,7 @@ namespace HappyHeart
residual,
__FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, -1., GetResidualRhs(), residual,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( -1., GetResidualRhs(), residual,
__FILE__, __LINE__);
return residual;
......
......@@ -124,7 +124,7 @@ namespace HappyHeart
AssertSameNumberingSubset(system_matrix, mass);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN,
Wrappers::Petsc::AXPY<NonZeroPattern::same>(
coefficient,
mass,
system_matrix,
......@@ -145,7 +145,7 @@ namespace HappyHeart
AssertSameNumberingSubset(stiffness, displacement_previous_time_iteration_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN,
Wrappers::Petsc::AXPY<NonZeroPattern::same>(
-.5,
stiffness,
displacement_previous_time_iteration_matrix,
......@@ -211,12 +211,12 @@ namespace HappyHeart
const double factor = 2. / parent::GetTimeManager().GetTimeStep();
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, factor,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( factor,
newest_displacement,
velocity_prev_time_it,
__FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, -factor,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( -factor,
former_displacement,
velocity_prev_time_it,
__FILE__, __LINE__);
......
......@@ -263,7 +263,7 @@ namespace HappyHeart
AssertSameNumberingSubset(capacity_matrix, system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., capacity_matrix, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., capacity_matrix, system_matrix, __FILE__, __LINE__);
}
......
......@@ -264,11 +264,11 @@ namespace HappyHeart
AssertSameNumberingSubset(GetMatrixTangentFollowingPressure(), system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1.,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1.,
GetMatrixTangentStiffness(),
system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1.,
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1.,
GetMatrixTangentFollowingPressure(),
system_matrix, __FILE__, __LINE__);
......
......@@ -328,10 +328,10 @@ namespace HappyHeart
AssertSameNumberingSubset(system_matrix, mass_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., matrix_surfacic_bidomain, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1., matrix_capacity, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., matrix_surfacic_bidomain, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1., matrix_capacity, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, 1.e-06, mass_matrix, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( 1.e-06, mass_matrix, system_matrix, __FILE__, __LINE__);
}
......
......@@ -137,7 +137,7 @@ namespace HappyHeart
AssertSameNumberingSubset(mass_matrix_prev, system_matrix);
#endif // NDEBUG
Wrappers::Petsc::AXPY(SAME_NONZERO_PATTERN, -1., mass_matrix_prev, system_matrix, __FILE__, __LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::same>( -1., mass_matrix_prev, system_matrix, __FILE__, __LINE__);
}
......
......@@ -187,11 +187,10 @@ namespace HappyHeart
Wrappers::Petsc::MatrixInfo("System matrix", system_matrix, __FILE__, __LINE__);
// And now add t11 to system matrix.
Wrappers::Petsc::AXPY(SUBSET_NONZERO_PATTERN,
1.,
t11_in_monolithic,
system_matrix, __FILE__,
__LINE__);
Wrappers::Petsc::AXPY<NonZeroPattern::subset>(1.,
t11_in_monolithic,
system_matrix, __FILE__,
__LINE__);
system_matrix.Assembly(__FILE__, __LINE__);
......
......@@ -14,9 +14,12 @@
# include <memory>
# include <vector>
# include "Utilities/Containers/EnumClass.hpp"
# include "ThirdParty/IncludeWithoutWarning/Petsc/PetscSys.hpp"
# include "ThirdParty/IncludeWithoutWarning/Petsc/PetscMat.hpp"
# include "ThirdParty/Wrappers/Petsc/Matrix/NonZeroPattern.hpp"
# include "ThirdParty/Wrappers/Petsc/Vector/Vector.hpp"
# include "ThirdParty/Wrappers/Petsc/Matrix/Private/BaseMatrix.hpp"
# include "ThirdParty/Wrappers/Petsc/Exceptions/Petsc.hpp"
......@@ -43,8 +46,6 @@ namespace HappyHeart
// ============================
namespace Wrappers
{
......@@ -73,24 +74,24 @@ namespace HappyHeart
* \brief \copydoc doxygen_hide_petsc_do_reuse_matrix
*/
enum class DoReuseMatrix { yes, no };
/*!
* \brief Wrapper over MatAXPY, that performs Y = a * X + Y.
*
*
* \param[in] structure Either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN.
* \warning Beware: if X and Y aren't following the same pattern, SAME_NONZERO_PATTERN won't yield what
* \tparam[in] NonZeroPatternT This value indicates the level of similarity between X and Y non zero patterns.
* \warning Beware: if X and Y aren't following the same pattern, 'Same' won't yield what
* you expect! In the case you're considering adding a part computed by a transfert matrix, you should
* use SUBSET_NONZERO_PATTERN. In HappyHeart, I advise you to call in debug mode AssertSameNumberingSubset()
* use 'Subset'. In HappyHeart, I advise you to call in debug mode AssertSameNumberingSubset()
* (defined in Core) just before or after the function call; if the assert is raised it means you can't
* use SAME_NONZERO_PATTERN. \todo This could be enforced by a proper overload (but it mix Utilities and Core
* use 'Same'. \todo This could be enforced by a proper overload (but it mix Utilities and Core
* libraries...), but for the time being the separate assert will do.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template
<
NonZeroPattern NonZeroPatternT,
class MatrixT,
class MatrixU
>
......@@ -100,8 +101,7 @@ namespace HappyHeart
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
AXPY(const MatStructure& structure,
PetscScalar a,
AXPY(PetscScalar a,
const MatrixT& X,
MatrixU& Y,
const char* invoking_file, int invoking_line);
......@@ -490,6 +490,16 @@ namespace HappyHeart
} //namespace Wrappers
/*!
* \brief Convenient alias to avoid repeating the namespaces in each call.
*
* It should be used anyway only as template arguments of functions within this namespaces, such as
* Wrappers::Petsc::AXPY.
*/
using NonZeroPattern = Wrappers::Petsc::NonZeroPattern;
} // namespace HappyHeart
......
......@@ -11,7 +11,6 @@
#ifndef HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_MATRIX_OPERATIONS_HXX_
# define HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_MATRIX_OPERATIONS_HXX_
#include <iostream>
namespace HappyHeart
{
......@@ -215,9 +214,9 @@ namespace HappyHeart
}
template
<
NonZeroPattern NonZeroPatternT,
class MatrixT,
class MatrixU
>
......@@ -227,13 +226,16 @@ namespace HappyHeart
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
AXPY(const MatStructure& structure,
PetscScalar a,
AXPY(PetscScalar a,
const MatrixT& X,
MatrixU& Y,
const char* invoking_file, int invoking_line)
{
int error_code = ::MatAXPY(Y.Internal(), a, X.Internal(), structure);
int error_code = ::MatAXPY(Y.Internal(),
a,
X.Internal(),
Private::NonZeroPatternPetsc<NonZeroPatternT>());
if (error_code)
throw ExceptionNS::Exception(error_code, "MatAXPY", invoking_file, invoking_line);
}
......
//! \file
//
//
// MatrixTOperations.hpp
// HappyHeart
//
// Created by Sebastien Gilles on 30/10/15.
// Copyright © 2015 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_NON_ZERO_PATTERN_HPP_
# define HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_NON_ZERO_PATTERN_HPP_
namespace HappyHeart
{
namespace Wrappers
{
namespace Petsc
{
/*!
* \brief Convenient enum used to typify more strongly Petsc macro values.
*/
enum class NonZeroPattern
{
same,
different,
subset
};
} // namespace Petsc
} // namespace Wrappers
/*!
* \brief Convenient alias to avoid repeating the namespaces in each call.
*
* It should be used anyway only as template arguments of functions within this namespaces, such as
* Wrappers::Petsc::AXPY.
*/
using NonZeroPattern = Wrappers::Petsc::NonZeroPattern;
} // namespace HappyHeart
# include "ThirdParty/Wrappers/Petsc/Matrix/Private/NonZeroPattern.hpp"
#endif // HAPPY_HEART_x_THIRD_PARTY_x_WRAPPERS_x_PETSC_x_MATRIX_x_NON_ZERO_PATTERN_HPP_
//! \file
//
//
// BaseMatrix.hpp
// HappyHeart
//
// Created by Sebastien Gilles on 30/10/15.
// Copyright © 2015 Inria. All rights reserved.
//