Commit 50e0e0c1 authored by Gautier Bureau's avatar Gautier Bureau Committed by GILLES Sebastien
Browse files

#884 New formulation working in sequential. Parallel still not sure.

parent 3db6e306
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1343EC271CC4D942009F854F"
BuildableName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
BlueprintName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
ReferencedContainer = "container:HappyHeart.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1343EC271CC4D942009F854F"
BuildableName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
BlueprintName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
ReferencedContainer = "container:HappyHeart.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Users/Shared/LibraryVersions/clang/Openmpi/bin/orterun">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1343EC271CC4D942009F854F"
BuildableName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
BlueprintName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
ReferencedContainer = "container:HappyHeart.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
<CommandLineArgument
argument = "-np 4"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "$(BUILT_PRODUCTS_DIR)/CardiacMechanicsPrestressDisplacementVelocityFormulation"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--input_parameters ${HOME}/Codes/HappyHeart/Data/Lua/demo_input_cardiac_mechanics_prestress_displacement_velocity_formulation.lua"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1343EC271CC4D942009F854F"
BuildableName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
BlueprintName = "CardiacMechanicsPrestressDisplacementVelocityFormulation"
ReferencedContainer = "container:HappyHeart.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -42,7 +42,7 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......
......@@ -87,9 +87,12 @@ namespace HappyHeart
HyperelasticLawNS::CiarletGeymonat
>;
//! Alias to the viscoelasticity derivate policy used.
using ViscoelasticityDerivate = LocalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ViscoelasticityPolicyNS::DerivatesWithRespectTo;
//! Alias to the viscoelasticity policy used.
using ViscoelasticityPolicy =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ViscoelasticityPolicyNS::Viscoelasticity;
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ViscoelasticityPolicyNS::Viscoelasticity<ViscoelasticityDerivate::displacement_and_velocity>;
//! Alias to the active stress policy used.
using ActiveStressPolicy =
......
......@@ -85,10 +85,10 @@ namespace HappyHeart
using HyperelasticityLaw =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::HyperelasticLawNS::CiarletGeymonat;
//!
//! Alias to the viscoelasticity derivate policy used.
using ViscoelasticityDerivate = LocalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ViscoelasticityPolicyNS::DerivatesWithRespectTo;
//! Alias to the viscoelasticity policy used.
//! Alias to the viscoelasticity in displacement policy used.
using ViscoelasticityDisplacementPolicy =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ViscoelasticityPolicyNS::Viscoelasticity<ViscoelasticityDerivate::displacement>;
......@@ -99,7 +99,7 @@ namespace HappyHeart
//! Alias to the stiffness operator type used.
using StiffnessOperatorType =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensor<HyperelasticityLaw, ViscoelasticityDisplacementPolicy, ActiveStressPolicy>;
//! Alias to the none hyperelasticity law.
using HyperelasticityNone =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::HyperelasticityPolicyNS::None;
......@@ -108,7 +108,7 @@ namespace HappyHeart
using ActiveStressNone =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ActiveStressPolicyNS::None;
//! Alias to the viscoelasticity policy used.
//! Alias to the viscoelasticity in velocity policy used.
using ViscoelasticityVelocityPolicy =
GlobalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ViscoelasticityPolicyNS::Viscoelasticity<ViscoelasticityDerivate::velocity>;
......@@ -444,16 +444,16 @@ namespace HappyHeart
//! Get the find coords of global vector operator.
const FindCoordsOfGlobalVector& GetFindCoordsOfGlobalVectorOperator() const noexcept;
//!
//! Constant accessor to the monolithic to displacement interpolator.
const ConformInterpolatorNS::SubsetOrSuperset& GetMonolithicDisplacementVelocityToDisplacementInterpolator() const noexcept;
//! Constant accessor to
//! Constant accessor to the monolithic to velocity interpolator.
const ConformInterpolatorNS::SubsetOrSuperset& GetMonolithicDisplacementVelocityToVelocityInterpolator() const noexcept;
//! Constant accessor to
//! Constant accessor to the displacement to monolithic interpolator.
const ConformInterpolatorNS::SubsetOrSuperset& GetDisplacementToMonolithicDisplacementVelocityInterpolator() const noexcept;
//! Constant accessor to
//! Constant accessor to the velocity to monolithic interpolator.
const ConformInterpolatorNS::SubsetOrSuperset& GetVelocityToMonolithicDisplacementVelocityInterpolator() const noexcept;
private:
......@@ -486,7 +486,6 @@ namespace HappyHeart
/// \name Global interpolation operators.
///@{
ConformInterpolatorNS::SubsetOrSuperset::unique_ptr
monolithic_displacement_velocity_to_displacement_interpolator_ = nullptr;
......@@ -556,10 +555,18 @@ namespace HappyHeart
GlobalMatrix& GetNonCstMatrixIntermediateDisplacementToMonolithic() noexcept;
const GlobalMatrix& GetMatrixIntermediateDisplacementToMonolithic2() const noexcept;
GlobalMatrix& GetNonCstMatrixIntermediateDisplacementToMonolithic2() noexcept;
const GlobalMatrix& GetMatrixIntermediateVelocityToMonolithic() const noexcept;
GlobalMatrix& GetNonCstMatrixIntermediateVelocityToMonolithic() noexcept;
const GlobalMatrix& GetMatrixIntermediateVelocityToMonolithic2() const noexcept;
GlobalMatrix& GetNonCstMatrixIntermediateVelocityToMonolithic2() noexcept;
const GlobalVector& GetVectorFollowingPressureResidual() const noexcept;
......@@ -605,10 +612,6 @@ namespace HappyHeart
GlobalVector& GetNonCstVectorDiffDisplacement() noexcept;
const GlobalVector& GetVectorNewmarkResidual() const noexcept;
GlobalVector& GetNonCstVectorNewmarkResidual() noexcept;
const GlobalVector& GetVectorMonolithicDisplacementVelocityAtNewtonIteration() const noexcept;
GlobalVector& GetNonCstVectorMonolithicDisplacementVelocityAtNewtonIteration() noexcept;
......@@ -650,6 +653,11 @@ namespace HappyHeart
//! Constant accessor to velocity_.
double GetVelocity() const noexcept;
private:
//! Non constant accessor to the static solver.
Wrappers::Petsc::Snes& GetNonCstDisplacementSolver() noexcept;
private:
/*!
......@@ -714,32 +722,34 @@ namespace HappyHeart
//! Matrix displacement linear stiffness.
GlobalMatrix::unique_ptr matrix_velocity_linear_stiffness_ = nullptr;
//!
//! Matrix monolithic used for intermediate computation.
GlobalMatrix::unique_ptr matrix_monolithic_global_ = nullptr;
//!
//! Matrix monolithic used for intermediate computation.
GlobalMatrix::unique_ptr matrix_monolithic_global_2_ = nullptr;
//!
GlobalMatrix::unique_ptr matrix_monolithic_mass_per_square_time_step_velocity_velocity_ = nullptr;
//!
//! Matrix linear stiffness in monolithic in displacement displacement position.
GlobalMatrix::unique_ptr matrix_monolithic_linear_stiffness_displacement_displacement_ = nullptr;
//!
//! Matrix linear stiffness in monolithic in displacement velocity position.
GlobalMatrix::unique_ptr matrix_monolithic_linear_stiffness_displacement_velocity_ = nullptr;
//!
//! Matrix intermediate from displacement to monolithic.
GlobalMatrix::unique_ptr matrix_intermediate_displacement_to_monolithic_ = nullptr;
//!
//! Matrix intermediate from displacement to monolithic.
GlobalMatrix::unique_ptr matrix_intermediate_displacement_to_monolithic_2_ = nullptr;
//! Matrix intermediate from velocity to monolithic.
GlobalMatrix::unique_ptr matrix_intermediate_velocity_to_monolithic_ = nullptr;
//! Matrix intermediate from divelocitysplacement to monolithic.
GlobalMatrix::unique_ptr matrix_intermediate_velocity_to_monolithic_2_ = nullptr;
//! Evaluation state of the residual of the problem (only useful in SNES method)
//! Vector displacement at newton iteration.
GlobalVector::unique_ptr vector_displacement_at_newton_iteration_ = nullptr;
//! Evaluation state of the residual of the problem (only useful in SNES method)
//! Vector velocity at newton iteration.
GlobalVector::unique_ptr vector_velocity_at_newton_iteration_ = nullptr;
//! Velocity from previous time iteration.
......@@ -748,13 +758,13 @@ namespace HappyHeart
//! Displacement from previous time iteration.
GlobalVector::unique_ptr vector_displacement_previous_time_iteration_ = nullptr;
//!
//! Vector monolithic displacement and velocity from previous time iteration.
GlobalVector::unique_ptr vector_monolithic_displacement_velocity_previous_time_iteration_ = nullptr;
//! Midpoint position.
GlobalVector::unique_ptr vector_midpoint_position_ = nullptr;
//!
//! Midpoint position in velocity numbering subset used for assembling an operator not in the same NS.
GlobalVector::unique_ptr vector_midpoint_position_in_velocity_numbering_subset_ = nullptr;
//! Difference displacement Yn+1 - Yn. Here just to avoid allocate it every time step.
......@@ -763,19 +773,16 @@ namespace HappyHeart
//! Midpoint velocity.
GlobalVector::unique_ptr vector_midpoint_velocity_ = nullptr;
//!
//! Midpoint velocity in displacement numbering subset used for assembling an operator not in the same NS.
GlobalVector::unique_ptr vector_midpoint_velocity_in_displacement_numbering_subset_ = nullptr;
//!
//! Vector midpoint monolithic.
GlobalVector::unique_ptr vector_midpoint_monolithic_displacement_velocity_ = nullptr;
//!
GlobalVector::unique_ptr vector_newmark_residual_ = nullptr;
//!
//! Vector monolithic at newton iteration.
GlobalVector::unique_ptr vector_monolithic_displacement_velocity_at_newton_iteration_ = nullptr;
//!
//! Vector monolithic used for intermdediate computation.
GlobalVector::unique_ptr vector_monolithic_global_ = nullptr;
///@}
......@@ -858,6 +865,11 @@ namespace HappyHeart
//! Velocity of the electrical activation. See ComputeElectricalActivationAtTime().
double velocity_;
private:
//! Static solver on the displacement.
Wrappers::Petsc::Snes::unique_ptr displacement_solver_ = nullptr;
private:
//! Enum class to define electrical activation parameters.
......@@ -876,15 +888,8 @@ namespace HappyHeart
//! Constant accessor to all the electrical parameters.
double GetElectricalActivationParameter(electrical_activation_parameter_index index) const noexcept;
private:
//!
Wrappers::Petsc::Snes& GetNonCstDisplacementSolver() noexcept;
//!
Wrappers::Petsc::Snes::unique_ptr displacement_solver_ = nullptr;
};
......
......@@ -210,7 +210,7 @@ namespace HappyHeart
return const_cast<GlobalMatrix&>(GetMatrixMonolithicGlobal2());
}
inline const GlobalMatrix& VariationalFormulation::GetMatrixMonolithicLinearStiffnessDisplacementDisplacement() const noexcept
{
assert(!(!matrix_monolithic_linear_stiffness_displacement_displacement_));
......@@ -250,6 +250,19 @@ namespace HappyHeart
}
inline const GlobalMatrix& VariationalFormulation::GetMatrixIntermediateDisplacementToMonolithic2() const noexcept
{
assert(!(!matrix_intermediate_displacement_to_monolithic_2_));
return *matrix_intermediate_displacement_to_monolithic_2_;
}
inline GlobalMatrix& VariationalFormulation::GetNonCstMatrixIntermediateDisplacementToMonolithic2() noexcept
{
return const_cast<GlobalMatrix&>(GetMatrixIntermediateDisplacementToMonolithic2());
}
inline const GlobalMatrix& VariationalFormulation::GetMatrixIntermediateVelocityToMonolithic() const noexcept
{
assert(!(!matrix_intermediate_velocity_to_monolithic_));
......@@ -263,6 +276,19 @@ namespace HappyHeart
}
inline const GlobalMatrix& VariationalFormulation::GetMatrixIntermediateVelocityToMonolithic2() const noexcept
{
assert(!(!matrix_intermediate_velocity_to_monolithic_2_));
return *matrix_intermediate_velocity_to_monolithic_2_;
}
inline GlobalMatrix& VariationalFormulation::GetNonCstMatrixIntermediateVelocityToMonolithic2() noexcept
{
return const_cast<GlobalMatrix&>(GetMatrixIntermediateVelocityToMonolithic2());
}
inline const GlobalVector& VariationalFormulation::GetVectorStiffnessResidual() const noexcept
{
assert(!(!vector_stiffness_residual_));
......@@ -418,19 +444,6 @@ namespace HappyHeart
}
inline const GlobalVector& VariationalFormulation::GetVectorNewmarkResidual() const noexcept
{
assert(!(!vector_newmark_residual_));
return *vector_newmark_residual_;
}
inline GlobalVector& VariationalFormulation::GetNonCstVectorNewmarkResidual() noexcept
{
return const_cast<GlobalVector&>(GetVectorNewmarkResidual());
}
inline const GlobalVector& VariationalFormulation::GetVectorMonolithicDisplacementVelocityAtNewtonIteration() const noexcept
{
assert(!(!vector_monolithic_displacement_velocity_at_newton_iteration_));
......
......@@ -526,7 +526,6 @@ namespace HappyHeart
// Complete the tangent matrix with the linear part!
Seldon::Add(1., linear_part, tangent_matrix);
break;
}
case OperatorNS::Nature::linear:
......
......@@ -193,17 +193,17 @@ namespace HappyHeart
* \attention In Petsc, matrix-matrix multiplication functions compute on the fly the
* pattern for the resulting matrix. However, it is possible this pattern isn't the one expected;
* in the richer HappyHeart interface you should call in debug mode \a AssertMatrixRespectPattern()
* to make sure the resulting matrix respects the pattern defined for the \a GlobalMatrix pair
* to make sure the resulting matrix respects the pattern defined for the \a GlobalMatrix pair
* of \a NumberingSubset.
*
* \internal <b><tt>[internal]</tt></b> If you know Petsc, you might see I didn't give access to
* argument MatReuse, setting it each time to MAT_INITIAL_MATRIX and skipping entirely MAT_REUSE_MATRIX.
* This is because at the time being MatMatMult operations are seldom in the code (only Poromechanics so
* far) and using Symbolic/Numeric seems more elegant. Of course, reintroducing the argument is really easy;
* feel free to do so if you need it (for instance for MatMatMatMult support: Symbolic/Numeric doesn't
* feel free to do so if you need it (for instance for MatMatMatMult support: Symbolic/Numeric doesn't
* work for them and Petsc guys seemed unlikely to fix that in our exchanges).
*
* \internal <b><tt>[internal]</tt></b> \todo #684 Investigate to use the argument fill, which provides an
* \internal <b><tt>[internal]</tt></b> \todo #684 Investigate to use the argument fill, which provides an
* estimation of the non zero of the resulting matrix. Currently PETSC_DEFAULT is used.
*/
......@@ -216,7 +216,7 @@ namespace HappyHeart
*
* If the operation is performed many times with each time the same non zero pattern for the matrices,
* rather use MatMatMultSymbolic/MatMatMultNumeric to improve efficiency.
* One can also reuse a pattern for several matrices, but so far I do not need that in HappyHeart so
* I equally use the default setting.
* \param[in] m1 See formula above.
......@@ -228,8 +228,8 @@ namespace HappyHeart
*/
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -256,8 +256,8 @@ namespace HappyHeart
*/
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -272,15 +272,14 @@ namespace HappyHeart
const char* invoking_file, int invoking_line,
DoReuseMatrix do_reuse_matrix = DoReuseMatrix::no);
/*!
* \brief Creates a new matrix object that behaves like A'.
*
* The transpose A' is NOT actually formed! Rather the new matrix object performs the matrix-vector product
* The transpose A' is NOT actually formed! Rather the new matrix object performs the matrix-vector product
* by using the MatMultTranspose() on the original matrix.
*
* \param[in] A matrix to transpose.
* \param[out] transpose The matrix that figuratively represents A'. This matrix must not have been
* \param[out] transpose The matrix that figuratively represents A'. This matrix must not have been
* allocated!
* \copydoc doxygen_hide_invoking_file_and_line
*/
......@@ -322,8 +321,8 @@ namespace HappyHeart
*/
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -338,7 +337,7 @@ namespace HappyHeart
DoReuseMatrix do_reuse_matrix = DoReuseMatrix::no);
/*!
* \brief Performs Matrix-Matrix Multiplication C = A * B^T.
*
......@@ -352,8 +351,8 @@ namespace HappyHeart
*/
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -371,12 +370,12 @@ namespace HappyHeart
/*!
* \class doxygen_hide_mat_pt_a_p
*
* \warning Unfortunately a simple test with P = I leads to error
* \warning Unfortunately a simple test with P = I leads to error
* \verbatim
* [0]PETSC ERROR: Nonconforming object sizes
* [0]PETSC ERROR: Expected fill=-2 must be >= 1.0
* \endverbatim
* The reason is that PETSC_DEFAULT may not be supported (I've asked Petsc developers); but even with
* The reason is that PETSC_DEFAULT may not be supported (I've asked Petsc developers); but even with
* hand-tailored fill it doesn't seem to work...
* So unfortunately I have to advise instead MatMatMult followed by MatTransposeMatMult instead...
*
......@@ -398,8 +397,8 @@ namespace HappyHeart
*/
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......
......@@ -60,8 +60,8 @@ namespace HappyHeart
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -109,8 +109,8 @@ namespace HappyHeart
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -246,8 +246,8 @@ namespace HappyHeart
template
<
class MatrixT,
class MatrixU
class MatrixT,
class MatrixU
>
std::enable_if_t
<
......@@ -297,11 +297,11 @@ namespace HappyHeart
throw ExceptionNS::Exception(error_code