Skip to content

Commit

Permalink
Merge pull request #12960 from KratosMultiphysics/two_fluid_fractiona…
Browse files Browse the repository at this point in the history
…l_navier_stokes

[FluidDynamicsApplication] Two-fluid Navier-Stokes formulation with fractional splitting approach
  • Loading branch information
uxuech authored Jan 7, 2025
2 parents 885a57e + 2625567 commit 7e4c67e
Show file tree
Hide file tree
Showing 21 changed files with 8,439 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Uxue Chasco
//


#pragma once

#include "fluid_dynamics_application_variables.h"
#include "custom_elements/data_containers/fluid_element_data.h"
#include "utilities/element_size_calculator.h"
#include "custom_utilities/fluid_element_utilities.h"
namespace Kratos {

///@addtogroup FluidDynamicsApplication
///@{

///@name Kratos classes
///@{

template< size_t TDim, size_t TNumNodes >
class TwoFluidNavierStokesFractionalConvectionData : public FluidElementData<TDim,TNumNodes, true>
{
public:

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

using NodalScalarData = typename FluidElementData<TDim,TNumNodes, true>::NodalScalarData;
using NodalVectorData = typename FluidElementData<TDim,TNumNodes, true>::NodalVectorData;
using ShapeFunctionsType = typename FluidElementData<TDim, TNumNodes, true>::ShapeFunctionsType;
using ShapeDerivativesType = typename FluidElementData<TDim, TNumNodes, true>::ShapeDerivativesType;
using MatrixRowType = typename FluidElementData<TDim, TNumNodes, true>::MatrixRowType;

static constexpr std::size_t BlockSize = TDim + 1;
///@}
///@name Public Members
///@{


NodalVectorData FractionalVelocity;
NodalVectorData VelocityOldStep1;
NodalVectorData VelocityOldStep2;
NodalVectorData MeshVelocity;

double DeltaTime; // Time increment
double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients
double bdf0;
double bdf1;
double bdf2;
double ElementSize;

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

void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) override
{


const auto& r_geometry = rElement.GetGeometry();
this->FillFromHistoricalNodalData(VelocityOldStep1,VELOCITY,r_geometry,1);
this->FillFromHistoricalNodalData(VelocityOldStep2,VELOCITY,r_geometry,2);
this->FillFromHistoricalNodalData(FractionalVelocity, FRACTIONAL_VELOCITY, r_geometry, 0);
this->FillFromHistoricalNodalData(MeshVelocity,MESH_VELOCITY, r_geometry, 0);
this->FillFromProcessInfo(DeltaTime,DELTA_TIME,rProcessInfo);
this->FillFromProcessInfo(DynamicTau,DYNAMIC_TAU,rProcessInfo);
const Vector& BDFVector = rProcessInfo[BDF_COEFFICIENTS];
bdf0 = BDFVector[0];
bdf1 = BDFVector[1];
bdf2 = BDFVector[2];
}

void UpdateGeometryValues(
unsigned int IntegrationPointIndex,
double NewWeight,
const MatrixRowType& rN,
const BoundedMatrix<double, TNumNodes, TDim>& rDN_DX) override
{
FluidElementData<TDim,TNumNodes, true>::UpdateGeometryValues(IntegrationPointIndex, NewWeight,rN,rDN_DX);
ElementSize = ElementSizeCalculator<TDim,TNumNodes>::GradientsElementSize(rDN_DX);
}

static int Check(const Element& rElement, const ProcessInfo& rProcessInfo)
{
const auto& r_geometry = rElement.GetGeometry();
for (unsigned int i = 0; i < TNumNodes; i++)
{

KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(FRACTIONAL_VELOCITY, r_geometry[i]);

}

return 0;
}

///@}

};

///@}

///@}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Uxue Chasco
//


#pragma once

#include "fluid_dynamics_application_variables.h"
#include "custom_elements/data_containers/fluid_element_data.h"
#include "utilities/element_size_calculator.h"
#include "custom_utilities/fluid_element_utilities.h"
namespace Kratos {

///@addtogroup FluidDynamicsApplication
///@{

///@name Kratos classes
///@{

template< size_t TDim, size_t TNumNodes >
class TwoFluidNavierStokesFractionalConvectionData : public FluidElementData<TDim,TNumNodes, true>
{
public:

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

using NodalScalarData = typename FluidElementData<TDim,TNumNodes, true>::NodalScalarData;
using NodalVectorData = typename FluidElementData<TDim,TNumNodes, true>::NodalVectorData;
using ShapeFunctionsType = typename FluidElementData<TDim, TNumNodes, true>::ShapeFunctionsType;
using ShapeDerivativesType = typename FluidElementData<TDim, TNumNodes, true>::ShapeDerivativesType;
using MatrixRowType = typename FluidElementData<TDim, TNumNodes, true>::MatrixRowType;

static constexpr std::size_t BlockSize = TDim + 1;
///@}
///@name Public Members
///@{


NodalVectorData FractionalVelocity;
NodalVectorData VelocityOldStep1;
NodalVectorData VelocityOldStep2;
NodalVectorData MeshVelocity;

double DeltaTime; // Time increment
double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients
double bdf0;
double bdf1;
double bdf2;
double ElementSize;

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

void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) override
{


const auto& r_geometry = rElement.GetGeometry();
this->FillFromHistoricalNodalData(VelocityOldStep1,VELOCITY,r_geometry,1);
this->FillFromHistoricalNodalData(VelocityOldStep2,VELOCITY,r_geometry,2);
this->FillFromHistoricalNodalData(FractionalVelocity, FRACTIONAL_VELOCITY, r_geometry, 0);
this->FillFromHistoricalNodalData(MeshVelocity,MESH_VELOCITY, r_geometry, 0);
this->FillFromProcessInfo(DeltaTime,DELTA_TIME,rProcessInfo);
this->FillFromProcessInfo(DynamicTau,DYNAMIC_TAU,rProcessInfo);
const Vector& BDFVector = rProcessInfo[BDF_COEFFICIENTS];
bdf0 = BDFVector[0];
bdf1 = BDFVector[1];
bdf2 = BDFVector[2];
}

void UpdateGeometryValues(
unsigned int IntegrationPointIndex,
double NewWeight,
const MatrixRowType& rN,
const BoundedMatrix<double, TNumNodes, TDim>& rDN_DX) override
{
FluidElementData<TDim,TNumNodes, true>::UpdateGeometryValues(IntegrationPointIndex, NewWeight,rN,rDN_DX);
ElementSize = ElementSizeCalculator<TDim,TNumNodes>::GradientsElementSize(rDN_DX);
}

static int Check(const Element& rElement, const ProcessInfo& rProcessInfo)
{
const auto& r_geometry = rElement.GetGeometry();
for (unsigned int i = 0; i < TNumNodes; i++)
{

KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(FRACTIONAL_VELOCITY, r_geometry[i]);

}

return 0;
}

///@}

};

///@}

///@}

}
Loading

0 comments on commit 7e4c67e

Please sign in to comment.