Skip to content
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

[Fluid] Div-stable P2P1 element #12331

Merged
merged 45 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b7a9757
Preliminary implementation
rubenzorrilla Feb 2, 2024
3b0fbcd
Advances...
rubenzorrilla Feb 2, 2024
f28ea7e
Minor in sympy utils
rubenzorrilla Feb 5, 2024
58bbb9a
Compiling version (not tested yet)
rubenzorrilla Feb 5, 2024
e27e2c3
Merge branch 'master' into fluid/div-stable-element-test
rubenzorrilla Feb 5, 2024
242808b
Compiling version (no stab)
rubenzorrilla Feb 5, 2024
0fb62b9
Adding stabilization (no viscous terms)
rubenzorrilla Feb 6, 2024
69678f4
Enrichment implementation (not working yet)
rubenzorrilla Feb 7, 2024
6caa987
Working version
rubenzorrilla Feb 7, 2024
c054637
Advances (unstable yet)
rubenzorrilla Feb 13, 2024
678bb24
Merge branch 'fluid/div-stable-element-test' into fluid/div-stable-el…
rubenzorrilla Feb 14, 2024
70320ed
Working version
rubenzorrilla Feb 14, 2024
6520111
Pressure subscale
rubenzorrilla Feb 15, 2024
929b195
Rename element
rubenzorrilla Feb 15, 2024
0ce6a01
Rename and documentation
rubenzorrilla Feb 15, 2024
b95e428
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Feb 16, 2024
44a43f8
Merge branch 'core/minor-in-sympy-utils-shape-functions' into fluid/d…
rubenzorrilla Feb 16, 2024
fbeeafc
Shape functions minor
rubenzorrilla Feb 16, 2024
18ae787
Test (missing tetrahedra)
rubenzorrilla Feb 16, 2024
a8c4e27
Merge branch 'core/tetrahedra3d10-second-derivatives' into fluid/div-…
rubenzorrilla Feb 19, 2024
336ceea
Merge branch 'core/tetrahedra3d10-second-derivatives' into fluid/div-…
rubenzorrilla Feb 19, 2024
944ae47
Add 3D test
rubenzorrilla Feb 19, 2024
a47eb41
Merge branch 'core/normal-calculation-in-assign-by-direction-process'…
rubenzorrilla Feb 19, 2024
a8f9ca3
Merge branch 'core/normal-calculation-in-assign-by-direction-process'…
rubenzorrilla Feb 19, 2024
f2d5dfe
Skip replace if geometry-based input modeler is used
rubenzorrilla Feb 19, 2024
ac25479
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Feb 21, 2024
afb9d7b
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Feb 22, 2024
cc6e9bf
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Apr 2, 2024
6b0667b
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Apr 19, 2024
4ce7809
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Apr 26, 2024
fa6e76b
Enabling solve usage and postprocessing PRESSURE (MPI working too)
rubenzorrilla Apr 26, 2024
fed9650
P2P1 condition
rubenzorrilla Apr 29, 2024
2d18c0b
P2P1 condition
rubenzorrilla Apr 29, 2024
e603a36
Merge branch 'fluid/div-stable-element-p2-p1' of /~https://github.com/K…
rubenzorrilla Apr 29, 2024
caefaa2
Add wall models
rubenzorrilla Apr 29, 2024
f425948
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla Apr 29, 2024
4bf3ffa
Reverting wall law stuff
rubenzorrilla Apr 29, 2024
37addff
cpp test
rubenzorrilla Apr 29, 2024
38bcbf3
Final aesthetics and documentation
rubenzorrilla Apr 30, 2024
6dea908
Removing unused variables
rubenzorrilla Apr 30, 2024
bdfc6c8
Skip pressure postprocess
rubenzorrilla Apr 30, 2024
04d97a2
Temporary to avoid breaking derived solvers
rubenzorrilla Apr 30, 2024
4de8214
Navier-Stokes wall condition DOF position hotfix
rubenzorrilla Apr 30, 2024
35e5cf8
Using std::inner_product
rubenzorrilla May 1, 2024
ba4589e
Merge branch 'master' into fluid/div-stable-element-p2-p1
rubenzorrilla May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,380 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main author: Ruben Zorrilla
//

#pragma once

// System includes


// External indludes


// Project includes
#include "geometries/geometry.h"
#include "includes/cfd_variables.h"
#include "includes/define.h"
#include "includes/element.h"
#include "includes/serializer.h"

// Application includes
#include "custom_elements/fluid_element.h"
#include "custom_utilities/fluid_element_utilities.h"
#include "fluid_dynamics_application_variables.h"

namespace Kratos
{

///@addtogroup FluidDynamicsApplication
///@{

///@name Kratos Globals
///@{

///@}
///@name Type Definitions
///@{

///@}
///@name Enum's
///@{

///@}
///@name Functions
///@{

///@}
///@name Kratos Classes
///@{

template< unsigned int TDim >
class IncompressibleNavierStokesP2P1Continuous : public Element
{
public:
///@name Type Definitions
///@{

static constexpr std::size_t StrainSize = 3*(TDim-1);

static constexpr std::size_t VelocityNumNodes = TDim == 2 ? 6 : 10;

static constexpr std::size_t PressureNumNodes = TDim == 2 ? 3 : 4;

static constexpr std::size_t LocalSize = VelocityNumNodes*TDim + PressureNumNodes;

static constexpr IntegrationMethod IntegrationMethod = GeometryData::IntegrationMethod::GI_GAUSS_4;

KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(IncompressibleNavierStokesP2P1Continuous);

using BaseType = Element;

using NodeType = BaseType::NodeType;

using GeometryType = BaseType::GeometryType;

using NodesArrayType = BaseType::NodesArrayType;

using VectorType = BaseType::VectorType;

using MatrixType = BaseType::MatrixType;

using IndexType = BaseType::IndexType;

using SizeType = BaseType::SizeType;

using EquationIdVectorType = BaseType::EquationIdVectorType;

using DofsVectorType = BaseType::DofsVectorType;

using DofsArrayType = BaseType::DofsArrayType;

struct ElementDataContainer
{
// Gauss point kinematics
array_1d<double, VelocityNumNodes> N_v;
BoundedMatrix<double, VelocityNumNodes, TDim> DN_v;
GeometryType::ShapeFunctionsSecondDerivativesType DDN_v;

array_1d<double, PressureNumNodes> N_p;
BoundedMatrix<double, PressureNumNodes, TDim> DN_p;

// Nodal values
array_1d<double, PressureNumNodes> Pressure;
BoundedMatrix<double, VelocityNumNodes, TDim> Velocity;
BoundedMatrix<double, VelocityNumNodes, TDim> VelocityOld1;
BoundedMatrix<double, VelocityNumNodes, TDim> VelocityOld2;
BoundedMatrix<double, VelocityNumNodes, TDim> MeshVelocity;
BoundedMatrix<double, VelocityNumNodes, TDim> BodyForce;

// Material response variables
Vector StrainRate = ZeroVector(StrainSize);
Vector ShearStress = ZeroVector(StrainSize);
Matrix ConstitutiveMatrix = ZeroMatrix(StrainSize, StrainSize);

// Auxiliary values
double BDF0;
double BDF1;
double BDF2;
double Weight;
double DeltaTime;

// Stabilization values
double StabC1;
double StabC2;
double DynamicTau;
double ElementSize;

// Material parameters
double Density;
double EffectiveViscosity;
};

///@}
///@name Life Cycle
///@{

//Constructors.

/// Default constuctor.
/**
* @param NewId Index number of the new element (optional)
*/
IncompressibleNavierStokesP2P1Continuous(IndexType NewId = 0);

/// Constructor using an array of nodes.
/**
* @param NewId Index of the new element
* @param ThisNodes An array containing the nodes of the new element
*/
IncompressibleNavierStokesP2P1Continuous(
IndexType NewId,
const NodesArrayType& ThisNodes);

/// Constructor using a geometry object.
/**
* @param NewId Index of the new element
* @param pGeometry Pointer to a geometry object
*/
IncompressibleNavierStokesP2P1Continuous(
IndexType NewId,
GeometryType::Pointer pGeometry);

/// Constuctor using geometry and properties.
/**
* @param NewId Index of the new element
* @param pGeometry Pointer to a geometry object
* @param pProperties Pointer to the element's properties
*/
IncompressibleNavierStokesP2P1Continuous(
IndexType NewId,
GeometryType::Pointer pGeometry,
Properties::Pointer pProperties);

/// Destructor.
virtual ~IncompressibleNavierStokesP2P1Continuous();

/// Copy constructor.
IncompressibleNavierStokesP2P1Continuous(IncompressibleNavierStokesP2P1Continuous const &rOther) = delete;

///@}
///@name Operators
///@{

/// Assignment operator.
IncompressibleNavierStokesP2P1Continuous &operator=(IncompressibleNavierStokesP2P1Continuous const &rOther) = delete;

///@}
///@name Operations
///@{

Element::Pointer Create(
IndexType NewId,
NodesArrayType const& ThisNodes,
Properties::Pointer pProperties) const override;

Element::Pointer Create(
IndexType NewId,
GeometryType::Pointer pGeom,
Properties::Pointer pProperties) const override;

void Initialize(const ProcessInfo &rCurrentProcessInfo) override;

void EquationIdVector(
EquationIdVectorType &rResult,
const ProcessInfo &rCurrentProcessInfo) const override;

void GetDofList(
DofsVectorType &rElementalDofList,
const ProcessInfo &rCurrentProcessInfo) const override;

void CalculateLocalSystem(
MatrixType &rLeftHandSideMatrix,
VectorType &rRightHandSideVector,
const ProcessInfo &rCurrentProcessInfo) override;

///@}
///@name Inquiry
///@{

int Check(const ProcessInfo &rCurrentProcessInfo) const override;

///@}
///@name Input and output
///@{

const Parameters GetSpecifications() const override;

/// Turn back information as a string.
std::string Info() const override;

/// Print information about this object.
void PrintInfo(std::ostream& rOStream) const override;

///@}
private:
///@name Static Member Variables
///@{


///@}
///@name Member Variables
///@{

/// Pointer to the viscous constitutive model
ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr;

///@}
///@name Serialization
///@{

friend class Serializer;

void save(Serializer& rSerializer) const override;

void load(Serializer& rSerializer) override;

///@}
///@name Private Operators
///@{


///@}
///@name Private Operations
///@{

/**
* @brief Set the element data container
* This method accesses the database and fills the provided data container
* @param rProcessInfo Reference to the current ProcessInfo container
* @param rElementData Reference to the data container to be filled
*/
void SetElementData(
const ProcessInfo& rProcessInfo,
ElementDataContainer& rElementData);

/**
* @brief Calculate the kinematics
* This method calculates the current element kinematics
* @param rGaussWeights Integration points weights
* @param rVelocityN Velocity shape functions at the integration points
* @param rPressureN Pressure shape functions at the integrationo points
* @param rVelocityDNDX Velocity shape functions derivatives at the integration points
* @param rPressureDNDX Pressure shape functions derivatives at the integration points
* @param rVelocityDDNDDX Velocity shape functions second derivatives at the integration points
*/
void CalculateKinematics(
Vector& rGaussWeights,
Matrix& rVelocityN,
Matrix& rPressureN,
GeometryType::ShapeFunctionsGradientsType& rVelocityDNDX,
GeometryType::ShapeFunctionsGradientsType& rPressureDNDX,
DenseVector<GeometryType::ShapeFunctionsSecondDerivativesType>& rVelocityDDNDDX);

/**
* @brief Calculates the strain rate
* This method calculates the current element strain rate and stores it in the provided data container
* @param rData Reference to the data container
*/
void CalculateStrainRate(ElementDataContainer& rData);

/**
* @brief Adds the current Gauss point contribution to LHS
* This function adds the current Gauss point contribution to the provided Left Hand Side (LHS) matrix
* @param rData Reference to the data container from which the contribution is computed
* @param rLHS Reference to the LHS matrix
*/
void AddGaussPointLeftHandSideContribution(
const ElementDataContainer& rData,
MatrixType& rLHS);

/**
* @brief Adds the current Gauss point contribution to RHS
* This function adds the current Gauss point contribution to the provided Right Hand Side (RHS) vector
* @param rData Reference to the data container from which the contribution is computed
* @param rRHS Reference to the RHS vector
*/
void AddGaussPointRightHandSideContribution(
const ElementDataContainer& rData,
VectorType& rRHS);

///@}
///@name Private Access
///@{


///@}
///@name Private Inquiry
///@{


///@}
///@name Un accessible methods
///@{


///@}
}; // Class IncompressibleNavierStokesP2P1Continuous

///@}
///@name Type Definitions
///@{


///@}
///@name Input and output
///@{

/// input stream function
template< unsigned int TDim >
inline std::istream& operator >>(
std::istream& rIStream,
IncompressibleNavierStokesP2P1Continuous<TDim>& rThis)
{
return rIStream;
}

/// output stream function
template< unsigned int TDim >
inline std::ostream& operator <<(
std::ostream& rOStream,
const IncompressibleNavierStokesP2P1Continuous<TDim>& rThis)
{
rThis.PrintInfo(rOStream);
rOStream << std::endl;
rThis.PrintData(rOStream);

return rOStream;
}

///@}
///@} // Fluid Dynamics Application group

} // namespace Kratos.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ void AddCustomUtilitiesToPython(pybind11::module& m)
.def_static("MapVelocityFromSkinToVolumeRBF", &FluidAuxiliaryUtilities::MapVelocityFromSkinToVolumeRBF)
.def_static("FindMaximumEdgeLength", [](ModelPart& rModelPart){return FluidAuxiliaryUtilities::FindMaximumEdgeLength(rModelPart);})
.def_static("FindMaximumEdgeLength", [](ModelPart& rModelPart, const bool CalculateNodalNeighbours){return FluidAuxiliaryUtilities::FindMaximumEdgeLength(rModelPart, CalculateNodalNeighbours);})
.def_static("PostprocessP2P1ContinuousPressure", [](ModelPart& rModelPart){return FluidAuxiliaryUtilities::PostprocessP2P1ContinuousPressure(rModelPart);})
;

py::class_<FluidTestUtilities>(m, "FluidTestUtilities")
Expand Down
Loading
Loading