-
Notifications
You must be signed in to change notification settings - Fork 279
[GeoMechanicsApplication] Move all non-template code to .cpp files and make sure any .h file does not contain any implementations (elements) #14055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
66a7b60
7116957
1f82dc9
5359752
b1165af
ff96db9
ae894ce
070fd81
af5aa2a
8186d17
b5b4fd6
3e13786
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,235 @@ | ||
| // KRATOS___ | ||
| // // ) ) | ||
| // // ___ ___ | ||
| // // ____ //___) ) // ) ) | ||
| // // / / // // / / | ||
| // ((____/ / ((____ ((___/ / MECHANICS | ||
| // | ||
| // License: geo_mechanics_application/license.txt | ||
| // | ||
| // Main authors: Mohamed Nabi | ||
| // John van Esch | ||
| // Richard Faasse | ||
| // Gennady Markelov | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "calculation_contribution.h" | ||
| #include "compressibility_calculator.hpp" | ||
| #include "custom_retention/retention_law_factory.h" | ||
| #include "custom_utilities/check_utilities.h" | ||
| #include "custom_utilities/constitutive_law_utilities.h" | ||
| #include "custom_utilities/dof_utilities.h" | ||
| #include "custom_utilities/element_utilities.hpp" | ||
| #include "custom_utilities/hydraulic_discharge.h" | ||
| #include "custom_utilities/transport_equation_utilities.hpp" | ||
| #include "custom_utilities/variables_utilities.hpp" | ||
| #include "filter_compressibility_calculator.hpp" | ||
| #include "fluid_body_flow_calculator.hpp" | ||
| #include "geo_mechanics_application_variables.h" | ||
| #include "includes/cfd_variables.h" | ||
| #include "includes/element.h" | ||
| #include "includes/serializer.h" | ||
| #include "integration_coefficients_calculator.hpp" | ||
| #include "permeability_calculator.hpp" | ||
|
|
||
| #include <optional> | ||
|
|
||
| namespace Kratos | ||
| { | ||
|
|
||
| template <unsigned int TDim, unsigned int TNumNodes> | ||
| class KRATOS_API(GEO_MECHANICS_APPLICATION) PwElement : public Element | ||
| { | ||
| public: | ||
| KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(PwElement); | ||
|
|
||
| explicit PwElement(IndexType NewId = 0); | ||
|
|
||
| PwElement(IndexType NewId, | ||
| const GeometryType::Pointer& pGeometry, | ||
| const std::vector<CalculationContribution>& rContributions, | ||
| std::unique_ptr<IntegrationCoefficientModifier> pCoefficientModifier); | ||
|
|
||
| PwElement(IndexType NewId, | ||
| const GeometryType::Pointer& pGeometry, | ||
| const PropertiesType::Pointer& pProperties, | ||
| const std::vector<CalculationContribution>& rContributions, | ||
| std::unique_ptr<IntegrationCoefficientModifier> pCoefficientModifier); | ||
|
|
||
| ~PwElement() override = default; | ||
| PwElement(const PwElement&) = delete; | ||
| PwElement& operator=(const PwElement&) = delete; | ||
| PwElement(PwElement&&) noexcept = delete; | ||
| PwElement& operator=(PwElement&&) noexcept = delete; | ||
|
|
||
| Element::Pointer Create(IndexType NewId, | ||
| const NodesArrayType& rThisNodes, | ||
| PropertiesType::Pointer pProperties) const override; | ||
|
|
||
| Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override; | ||
|
|
||
| void GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo&) const override; | ||
|
|
||
| void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo&) const override; | ||
|
|
||
| void Initialize(const ProcessInfo&) override; | ||
|
|
||
| void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| using Element::CalculateOnIntegrationPoints; | ||
|
|
||
| void CalculateOnIntegrationPoints(const Variable<double>& rVariable, | ||
| std::vector<double>& rOutput, | ||
| const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| void CalculateOnIntegrationPoints(const Variable<array_1d<double, 3>>& rVariable, | ||
| std::vector<array_1d<double, 3>>& rOutput, | ||
| const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix, | ||
| VectorType& rRightHandSideVector, | ||
| const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| void CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| void CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| GeometryData::IntegrationMethod GetIntegrationMethod() const override; | ||
|
|
||
| int Check(const ProcessInfo& rCurrentProcessInfo) const override; | ||
|
|
||
| void CalculateOnIntegrationPoints(const Variable<Matrix>& rVariable, | ||
| std::vector<Matrix>& rOutput, | ||
| const ProcessInfo& rCurrentProcessInfo) override; | ||
|
|
||
| private: | ||
| std::vector<CalculationContribution> mContributions; | ||
| IntegrationCoefficientsCalculator mIntegrationCoefficientsCalculator; | ||
| std::vector<RetentionLaw::Pointer> mRetentionLawVector; | ||
| Vector mIntegrationCoefficients; | ||
| Matrix mNContainer; | ||
| Vector mDetJCcontainer; | ||
| std::vector<double> mFluidPressures; | ||
|
|
||
| std::vector<double> CalculateIntegrationCoefficients(const Vector& rDetJs) const; | ||
|
|
||
| std::vector<Vector> CalculateProjectedGravityAtIntegrationPoints(const Matrix& rNContainer) const; | ||
|
|
||
| std::unique_ptr<IntegrationCoefficientModifier> CloneIntegrationCoefficientModifier() const; | ||
|
|
||
| std::unique_ptr<ContributionCalculator<TNumNodes>> CreateCalculator(const CalculationContribution& rContribution, | ||
| const ProcessInfo& rCurrentProcessInfo); | ||
|
|
||
| void CachingDataForCalculator(); | ||
|
|
||
| typename CompressibilityCalculator<TNumNodes>::InputProvider CreateCompressibilityInputProvider( | ||
| const ProcessInfo& rCurrentProcessInfo); | ||
|
|
||
| typename FilterCompressibilityCalculator<TNumNodes>::InputProvider CreateFilterCompressibilityInputProvider( | ||
| const ProcessInfo& rCurrentProcessInfo); | ||
|
|
||
| typename PermeabilityCalculator<TNumNodes>::InputProvider CreatePermeabilityInputProvider(); | ||
|
|
||
| typename FluidBodyFlowCalculator<TNumNodes>::InputProvider CreateFluidBodyFlowInputProvider(); | ||
|
|
||
| auto MakePropertiesGetter() | ||
| { | ||
| return [this]() -> const Properties& { return GetProperties(); }; | ||
| } | ||
|
|
||
| auto MakeRetentionLawsGetter() | ||
| { | ||
| return [this]() -> const std::vector<RetentionLaw::Pointer>& { return mRetentionLawVector; }; | ||
| } | ||
|
|
||
| auto GetNContainer() | ||
| { | ||
| return [this]() -> const Matrix& { return mNContainer; }; | ||
| } | ||
|
|
||
| Matrix CalculateNContainer() | ||
| { | ||
| return GetGeometry().ShapeFunctionsValues(GetIntegrationMethod()); | ||
| } | ||
|
||
|
|
||
| auto GetIntegrationCoefficients() | ||
| { | ||
| return [this]() -> const Vector& { return mIntegrationCoefficients; }; | ||
| } | ||
|
|
||
| Vector CalculateIntegrationCoefficients() | ||
| { | ||
| GetGeometry().DeterminantOfJacobian(mDetJCcontainer, this->GetIntegrationMethod()); | ||
| return mIntegrationCoefficientsCalculator.Run<Vector>( | ||
| GetGeometry().IntegrationPoints(GetIntegrationMethod()), mDetJCcontainer, this); | ||
| } | ||
|
||
|
|
||
| auto GetFluidPressures() | ||
| { | ||
| return [this]() -> const std::vector<double>& { return mFluidPressures; }; | ||
| } | ||
|
|
||
| std::vector<double> CalculateFluidPressure() | ||
| { | ||
| return GeoTransportEquationUtilities::CalculateFluidPressures( | ||
| mNContainer, VariablesUtilities::GetNodalValuesOf<TNumNodes>(WATER_PRESSURE, this->GetGeometry())); | ||
| } | ||
|
||
|
|
||
| auto MakeProjectedGravityForIntegrationPointsGetter() const | ||
| { | ||
| return [this]() -> std::vector<Vector> { | ||
| return CalculateProjectedGravityAtIntegrationPoints(mNContainer); | ||
| }; | ||
| } | ||
|
|
||
| static auto MakeMatrixScalarFactorGetter(const ProcessInfo& rCurrentProcessInfo) | ||
| { | ||
| return [&rCurrentProcessInfo]() { return rCurrentProcessInfo[DT_PRESSURE_COEFFICIENT]; }; | ||
| } | ||
|
|
||
| auto MakeNodalVariableGetter() const | ||
| { | ||
| return [this](const Variable<double>& rVariable) -> Vector { | ||
| return VariablesUtilities::GetNodalValuesOf<TNumNodes>(rVariable, this->GetGeometry()); | ||
| }; | ||
| } | ||
|
|
||
| auto MakeShapeFunctionLocalGradientsGetter() | ||
| { | ||
| return [this]() { | ||
| GeometryType::ShapeFunctionsGradientsType dN_dX_container; | ||
| if (GetGeometry().LocalSpaceDimension() == 1) { | ||
| dN_dX_container = GetGeometry().ShapeFunctionsLocalGradients(this->GetIntegrationMethod()); | ||
| std::transform(dN_dX_container.begin(), dN_dX_container.end(), | ||
| mDetJCcontainer.begin(), dN_dX_container.begin(), std::divides<>()); | ||
| } else { | ||
| GetGeometry().ShapeFunctionsIntegrationPointsGradients( | ||
| dN_dX_container, mDetJCcontainer, this->GetIntegrationMethod()); | ||
| } | ||
|
|
||
| return dN_dX_container; | ||
| }; | ||
| } | ||
|
|
||
| auto MakeLocalSpaceDimensionGetter() const | ||
| { | ||
| return [this]() -> std::size_t { return this->GetGeometry().LocalSpaceDimension(); }; | ||
| } | ||
|
|
||
| [[nodiscard]] DofsVectorType GetDofs() const | ||
| { | ||
| return Geo::DofUtilities::ExtractDofsFromNodes(GetGeometry(), WATER_PRESSURE); | ||
| } | ||
|
||
|
|
||
| friend class Serializer; | ||
|
|
||
| void save(Serializer& rSerializer) const override; | ||
|
|
||
| void load(Serializer& rSerializer) override; | ||
| }; | ||
|
|
||
| } // namespace Kratos | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite some functions here with auto, so probably that's why you can't move them to the cpp? We might be able to do so by being explicit about the return type (i.e.
std::function<...>) but I'm not sure if that's worth the effort and is beneficial for readability. What do you think? And @avdg81 do you have a preference?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to move them to cpp. They shall be converted to real functions that is a lot of work and may slow down Kratos.