From 6cc444159a11ec76830fc70633acadfc70ab3193 Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 19 Dec 2024 11:25:38 +0100 Subject: [PATCH 01/13] two fluid fractional navier stokes elements --- .../two_fluid_navier_stokes_fractional_data.h | 383 +++ ...orial_convection_fractional_element_data.h | 128 + .../custom_elements/fluid_element.cpp | 4 + .../two_fluid_navier_stokes_fractional.cpp | 2593 +++++++++++++++++ .../two_fluid_navier_stokes_fractional.h | 608 ++++ ...ectorial_convection_fractional_element.cpp | 730 +++++ .../vectorial_convection_fractional_element.h | 318 ++ .../fluid_dynamics_python_application.cpp | 3 + .../fluid_dynamics_application.cpp | 13 +- .../fluid_dynamics_application.h | 8 + .../fluid_dynamics_application_variables.cpp | 4 +- .../fluid_dynamics_application_variables.h | 3 + ...enerate_two_fluid_convection_fractional.py | 163 ++ ...rate_two_fluid_navier_stokes_fractional.py | 331 +++ ...luid_navier_stokes_fractional_template.cpp | 1289 ++++++++ ...convection_fractional_element_template.cpp | 363 +++ ...fluid_fractional_navier_stokes_element.cpp | 898 ++++++ ...ectorial_convection_fractional_element.cpp | 233 ++ 18 files changed, 8070 insertions(+), 2 deletions(-) create mode 100644 applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h create mode 100644 applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h create mode 100644 applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp create mode 100644 applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h create mode 100644 applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp create mode 100644 applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h create mode 100644 applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py create mode 100644 applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py create mode 100644 applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp create mode 100644 applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp create mode 100644 applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp create mode 100644 applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h new file mode 100644 index 000000000000..cbbc6ca5f14e --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -0,0 +1,383 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Uxue Chasco Goñi +// + + +#if !defined(KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL_DATA_H) +#define KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL_DATA_H + +#include "includes/constitutive_law.h" + +#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 TwoFluidNavierStokesFractionalData : public FluidElementData +{ +public: + +///@name Type Definitions +///@{ + +using NodalScalarData = typename FluidElementData::NodalScalarData; +using NodalVectorData = typename FluidElementData::NodalVectorData; +using ShapeFunctionsType = typename FluidElementData::ShapeFunctionsType; +using ShapeDerivativesType = typename FluidElementData::ShapeDerivativesType; +using MatrixRowType = typename FluidElementData::MatrixRowType; +typedef Geometry GeometryType; +typedef GeometryType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType; + +static constexpr std::size_t BlockSize = TDim + 1; +///@} +///@name Public Members +///@{ + +NodalVectorData Velocity; +NodalVectorData Velocity_OldStep1; +NodalVectorData Velocity_OldStep2; +NodalVectorData Velocity_OldStep3; +NodalVectorData MeshVelocity; +NodalVectorData BodyForce; +NodalVectorData Velocity_Fractional; +NodalScalarData Pressure; +NodalScalarData Distance; +NodalScalarData NodalDensity; +NodalScalarData NodalDynamicViscosity; + +double Density; +double DynamicViscosity; +double DeltaTime; // Time increment +double PreviousDeltaTime; +double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients +double SmagorinskyConstant; +double LinearDarcyCoefficient; +double NonLinearDarcyCoefficient; +double DarcyTerm; +double VolumeError; +double AirVolumeError; +double WaterVolumeError; +double bdf0; +double bdf1; +double bdf2; + +// Auxiliary containers for the symbolically-generated matrices +BoundedMatrix lhs; +array_1d rhs; +BoundedMatrix V; +BoundedMatrix H; +BoundedMatrix Kee; +array_1d rhs_ee; + +double ElementSize; + +Matrix N_pos_side; +Matrix N_neg_side; +ShapeFunctionsGradientsType DN_DX_pos_side; +ShapeFunctionsGradientsType DN_DX_neg_side; + +BoundedMatrix Enr_Pos_Interp; +BoundedMatrix Enr_Neg_Interp; + +Vector w_gauss_pos_side; +Vector w_gauss_neg_side; + +ShapeFunctionsType Nenr; +ShapeDerivativesType DN_DXenr; + +size_t NumPositiveNodes; +size_t NumNegativeNodes; +unsigned int NumberOfDivisions; + + +///@} +///@name Public Operations +///@{ + +void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) override +{ + // Base class Initialize manages constitutive law parameters + FluidElementData::Initialize(rElement,rProcessInfo); + + const Geometry< Node >& r_geometry = rElement.GetGeometry(); + const Properties& r_properties = rElement.GetProperties(); + this->FillFromHistoricalNodalData(Velocity,VELOCITY,r_geometry); + this->FillFromHistoricalNodalData(Velocity_OldStep1,VELOCITY,r_geometry,1); + this->FillFromHistoricalNodalData(Velocity_OldStep2,VELOCITY,r_geometry,2); + this->FillFromHistoricalNodalData(Velocity_OldStep3, VELOCITY, r_geometry, 3); + + this->FillFromHistoricalNodalData(Distance, DISTANCE, r_geometry); + this->FillFromHistoricalNodalData(MeshVelocity,MESH_VELOCITY,r_geometry); + this->FillFromHistoricalNodalData(BodyForce,BODY_FORCE,r_geometry); + this->FillFromHistoricalNodalData(Pressure,PRESSURE,r_geometry); + this->FillFromHistoricalNodalData(NodalDensity, DENSITY, r_geometry); + this->FillFromHistoricalNodalData(NodalDynamicViscosity, DYNAMIC_VISCOSITY, r_geometry); + // this->FillFromHistoricalNodalData(Acceleration, FRACTIONAL_ACCELERATION, r_geometry,1); + this->FillFromHistoricalNodalData(Velocity_Fractional, FRACTIONAL_VELOCITY, r_geometry, 0); + this->FillFromProperties(SmagorinskyConstant, C_SMAGORINSKY, r_properties); + this->FillFromProperties(LinearDarcyCoefficient, LIN_DARCY_COEF, r_properties); + this->FillFromProperties(NonLinearDarcyCoefficient, NONLIN_DARCY_COEF, r_properties); + this->FillFromProcessInfo(DeltaTime,DELTA_TIME,rProcessInfo); + this->FillFromProcessInfo(VolumeError, VOLUME_ERROR, rProcessInfo); + this->FillFromProcessInfo(DynamicTau, DYNAMIC_TAU, rProcessInfo); + this->FillFromProcessInfo(AirVolumeError, AIR_VOLUME_ERROR, rProcessInfo); + this->FillFromProcessInfo(WaterVolumeError, WATER_VOLUME_ERROR, rProcessInfo); + + const Vector& BDFVector = rProcessInfo[BDF_COEFFICIENTS]; + + bdf0 = BDFVector[0]; + bdf1 = BDFVector[1]; + bdf2 = BDFVector[2]; + + PreviousDeltaTime = rProcessInfo.GetPreviousTimeStepInfo()[DELTA_TIME]; + noalias(lhs) = ZeroMatrix(TNumNodes*(TDim+1),TNumNodes*(TDim+1)); + noalias(rhs) = ZeroVector(TNumNodes*(TDim+1)); + noalias(V) = ZeroMatrix(TNumNodes*(TDim + 1), TNumNodes); + noalias(H) = ZeroMatrix(TNumNodes, TNumNodes*(TDim + 1)); + noalias(Kee) = ZeroMatrix(TNumNodes, TNumNodes); + noalias(rhs_ee) = ZeroVector(TNumNodes); + + NumPositiveNodes = 0; + NumNegativeNodes = 0; + + for (unsigned int i = 0; i < TNumNodes; i++) + { + if (Distance[i] > 0) + NumPositiveNodes++; + else + NumNegativeNodes++; + } +} + +void UpdateGeometryValues( + unsigned int IntegrationPointIndex, + double NewWeight, + const MatrixRowType& rN, + const BoundedMatrix& rDN_DX) override +{ + FluidElementData::UpdateGeometryValues(IntegrationPointIndex, NewWeight,rN,rDN_DX); + ElementSize = ElementSizeCalculator::GradientsElementSize(rDN_DX); + CalculateDensityAtGaussPoint(); +} + +void UpdateGeometryValues( + unsigned int IntegrationPointIndex, + double NewWeight, + const MatrixRowType& rN, + const BoundedMatrix& rDN_DX, + const MatrixRowType& rNenr, + const BoundedMatrix& rDN_DXenr) +{ + FluidElementData::UpdateGeometryValues(IntegrationPointIndex, NewWeight, rN, rDN_DX); + ElementSize = ElementSizeCalculator::GradientsElementSize(rDN_DX); + noalias(this->Nenr) = rNenr; + noalias(this->DN_DXenr) = rDN_DXenr; + CalculateDensityAtGaussPoint(); +} + +static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) +{ + const Geometry< Node >& r_geometry = rElement.GetGeometry(); + + for (unsigned int i = 0; i < TNumNodes; i++) + { + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VELOCITY,r_geometry[i]); + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(DISTANCE, r_geometry[i]); + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(MESH_VELOCITY,r_geometry[i]); + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(BODY_FORCE,r_geometry[i]); + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(PRESSURE,r_geometry[i]); + } + + return 0; +} + +bool IsCut() { + return (NumPositiveNodes > 0) && (NumNegativeNodes > 0); +} + +bool IsAir() { + return (NumPositiveNodes == TNumNodes); +} + +bool IsWater() +{ + return (NumNegativeNodes == TNumNodes); +} + +void CalculateAirMaterialResponse() { + const unsigned int strain_size = 3 * (TDim - 1); + + if(this->C.size1() != strain_size) + this->C.resize(strain_size,strain_size,false); + if(this->ShearStress.size() != strain_size) + this->ShearStress.resize(strain_size,false); + + ComputeStrain(); + + CalculateEffectiveViscosityAtGaussPoint(); + + const double mu = this->EffectiveViscosity; + const double c1 = 2.0*mu; + const double c2 = mu; + this->C.clear(); + BoundedMatrix c_mat = this->C; + Vector& stress = this->ShearStress; + Vector& strain = this->StrainRate; + + FluidElementUtilities::GetNewtonianConstitutiveMatrix(mu, c_mat); + this->C = c_mat; + + if constexpr (TDim == 2) + { + const double trace = strain[0] + strain[1]; + const double volumetric_part = trace/2.0; // Note: this should be small for an incompressible fluid (it is basically the incompressibility error) + + stress[0] = c1 * (strain[0] - volumetric_part); + stress[1] = c1 * (strain[1] - volumetric_part); + stress[2] = c2 * strain[2]; + } + + else if constexpr (TDim == 3) + { + const double trace = strain[0] + strain[1] + strain[2]; + const double volumetric_part = trace/3.0; // Note: this should be small for an incompressible fluid (it is basically the incompressibility error) + + stress[0] = c1*(strain[0] - volumetric_part); + stress[1] = c1*(strain[1] - volumetric_part); + stress[2] = c1*(strain[2] - volumetric_part); + stress[3] = c2*strain[3]; + stress[4] = c2*strain[4]; + stress[5] = c2*strain[5]; + } +} + +void ComputeStrain() +{ + const BoundedMatrix& v = Velocity; + const BoundedMatrix& DN = this->DN_DX; + + // Compute strain (B*v) + // 3D strain computation + if constexpr (TDim == 3) + { + this->StrainRate[0] = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); + this->StrainRate[1] = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); + this->StrainRate[2] = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); + this->StrainRate[3] = DN(0,0)*v(0,1) + DN(0,1)*v(0,0) + DN(1,0)*v(1,1) + DN(1,1)*v(1,0) + DN(2,0)*v(2,1) + DN(2,1)*v(2,0) + DN(3,0)*v(3,1) + DN(3,1)*v(3,0); + this->StrainRate[4] = DN(0,1)*v(0,2) + DN(0,2)*v(0,1) + DN(1,1)*v(1,2) + DN(1,2)*v(1,1) + DN(2,1)*v(2,2) + DN(2,2)*v(2,1) + DN(3,1)*v(3,2) + DN(3,2)*v(3,1); + this->StrainRate[5] = DN(0,0)*v(0,2) + DN(0,2)*v(0,0) + DN(1,0)*v(1,2) + DN(1,2)*v(1,0) + DN(2,0)*v(2,2) + DN(2,2)*v(2,0) + DN(3,0)*v(3,2) + DN(3,2)*v(3,0); + } + // 2D strain computation + else if constexpr (TDim == 2) + { + this->StrainRate[0] = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); + this->StrainRate[1] = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); + this->StrainRate[2] = DN(0,1)*v(0,0) + DN(0,0)*v(0,1) + DN(1,1)*v(1,0) + DN(1,0)*v(1,1) + DN(2,1)*v(2,0) + DN(2,0)*v(2,1); + } +} + +double ComputeStrainNorm() +{ + double strain_rate_norm; + Vector& S = this->StrainRate; + if constexpr (TDim == 3) + { + strain_rate_norm = std::sqrt(2.*S[0] * S[0] + 2.*S[1] * S[1] + 2.*S[2] * S[2] + + S[3] * S[3] + S[4] * S[4] + S[5] * S[5]); + } + + else if constexpr (TDim == 2) + { + strain_rate_norm = std::sqrt(2.*S[0] * S[0] + 2.*S[1] * S[1] + S[2] * S[2]); + } + return strain_rate_norm; +} + +void CalculateDensityAtGaussPoint() +{ + double dist = 0.0; + for (unsigned int i = 0; i < TNumNodes; i++) + dist += this->N[i] * Distance[i]; + + int navg = 0; + double density = 0.0; + for (unsigned int i = 0; i < TNumNodes; i++) + { + if (dist * Distance[i] > 0.0) + { + navg += 1; + density += NodalDensity[i]; + } + } + + Density = density / navg; +} + +void CalculateEffectiveViscosityAtGaussPoint() +{ + double dist = 0.0; + for (unsigned int i = 0; i < TNumNodes; i++) + dist += this->N[i] * Distance[i]; + + int navg = 0; + double dynamic_viscosity = 0.0; + for (unsigned int i = 0; i < TNumNodes; i++) + { + if (dist * Distance[i] > 0.0) + { + navg += 1; + dynamic_viscosity += NodalDynamicViscosity[i]; + } + } + DynamicViscosity = dynamic_viscosity / navg; + + if (SmagorinskyConstant > 0.0) + { + const double strain_rate_norm = ComputeStrainNorm(); + + double length_scale = SmagorinskyConstant*ElementSize; + length_scale *= length_scale; // square + this->EffectiveViscosity = DynamicViscosity + 2.0*length_scale*strain_rate_norm; + } + else this->EffectiveViscosity = DynamicViscosity; +} + +void ComputeDarcyTerm() +{ + array_1d convective_velocity(3, 0.0); + for (size_t i = 0; i < TNumNodes; i++) { + for (size_t j = 0; j < TDim; j++) { + convective_velocity[j] += this->N[i] * (Velocity(i, j) - MeshVelocity(i, j)); + } + } + const double convective_velocity_norm = MathUtils::Norm(convective_velocity); + DarcyTerm = this->EffectiveViscosity * LinearDarcyCoefficient + Density * NonLinearDarcyCoefficient * convective_velocity_norm; +} +///@} + +}; + +///@} + +///@} + +} + +#endif \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h new file mode 100644 index 000000000000..5605e1a75bfb --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h @@ -0,0 +1,128 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Uxue Chasco +// + + +#if !defined(KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT_DATA_H) +#define KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT_DATA_H + +#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 VectorialConvectionFractionalElementData : public FluidElementData +{ +public: + +///@name Type Definitions +///@{ + +using NodalScalarData = typename FluidElementData::NodalScalarData; +using NodalVectorData = typename FluidElementData::NodalVectorData; +using ShapeFunctionsType = typename FluidElementData::ShapeFunctionsType; +using ShapeDerivativesType = typename FluidElementData::ShapeDerivativesType; +using MatrixRowType = typename FluidElementData::MatrixRowType; + +static constexpr std::size_t BlockSize = TDim + 1; +///@} +///@name Public Members +///@{ + + +NodalVectorData Velocity_Fractional; +NodalVectorData Velocity_OldStep1; +NodalVectorData Velocity_OldStep2; +NodalVectorData Velocity_OldStep3; // Old step acceleration approximation using BDF2 +NodalVectorData MeshVelocity; + +double DynamicViscosity; +double DeltaTime; // Time increment +double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients +double bdf0; +double bdf1; +double bdf2; + +// Auxiliary containers for the symbolically-generated matrices +BoundedMatrix lhs; +array_1d rhs; + +double ElementSize; + + + +///@} +///@name Public Operations +///@{ + +void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) override +{ + + + const Geometry< Node >& r_geometry = rElement.GetGeometry(); + const Properties& r_properties = rElement.GetProperties(); + this->FillFromHistoricalNodalData(Velocity_OldStep1,VELOCITY,r_geometry,1); + this->FillFromHistoricalNodalData(Velocity_OldStep2,VELOCITY,r_geometry,2); + // this->FillFromHistoricalNodalData(Velocity_OldStep3, VELOCITY, r_geometry, 3); // Old step acceleration approximation using BDF2 + this->FillFromHistoricalNodalData(Velocity_Fractional, FRACTIONAL_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]; + noalias(lhs) = ZeroMatrix(TNumNodes*(TDim),TNumNodes*(TDim)); + noalias(rhs) = ZeroVector(TNumNodes*(TDim)); +} + +void UpdateGeometryValues( + unsigned int IntegrationPointIndex, + double NewWeight, + const MatrixRowType& rN, + const BoundedMatrix& rDN_DX) override +{ + FluidElementData::UpdateGeometryValues(IntegrationPointIndex, NewWeight,rN,rDN_DX); + ElementSize = ElementSizeCalculator::GradientsElementSize(rDN_DX); +} + +static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) +{ + const Geometry< Node >& 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; +} + +///@} + +}; + +///@} + +///@} + +} + +#endif \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp index 66ec1334e046..4c31b2227bcb 100644 --- a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp @@ -24,6 +24,8 @@ #include "custom_elements/data_containers/two_fluid_navier_stokes/two_fluid_navier_stokes_data.h" #include "custom_elements/data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" #include "custom_elements/data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" #include "utilities/element_size_calculator.h" #include "custom_utilities/vorticity_utilities.h" @@ -948,6 +950,8 @@ template class FluidElement< TwoFluidNavierStokesData<3, 4> >; template class FluidElement>; template class FluidElement< TwoFluidNavierStokesAlphaMethodData<3, 4> >; +template class FluidElement>; +template class FluidElement>; /////////////////////////////////////////////////////////////////////////////////////////////////// } diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp new file mode 100644 index 000000000000..1f89dd0ebe04 --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp @@ -0,0 +1,2593 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Autor: Uxue Chasco Goñi +// + +#include "two_fluid_navier_stokes_fractional.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" +namespace Kratos +{ + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Life cycle + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional(IndexType NewId) + : FluidElement(NewId) {} + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional( + IndexType NewId, const NodesArrayType &ThisNodes) + : FluidElement(NewId, ThisNodes) {} + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional( + IndexType NewId, GeometryType::Pointer pGeometry) + : FluidElement(NewId, pGeometry) {} + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional( + IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties) + : FluidElement(NewId, pGeometry, pProperties) {} + +template +TwoFluidNavierStokesFractional::~TwoFluidNavierStokesFractional() {} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Public Operations + +template +Element::Pointer TwoFluidNavierStokesFractional::Create( + IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const +{ + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); +} + +template +Element::Pointer TwoFluidNavierStokesFractional::Create( + IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const +{ + return Kratos::make_intrusive(NewId, pGeom, pProperties); +} + +template +void TwoFluidNavierStokesFractional::CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) +{ + // Resize and intialize output + if (rLeftHandSideMatrix.size1() != LocalSize) + rLeftHandSideMatrix.resize(LocalSize, LocalSize, false); + + if (rRightHandSideVector.size() != LocalSize) + rRightHandSideVector.resize(LocalSize, false); + + noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize); + noalias(rRightHandSideVector) = ZeroVector(LocalSize); + + if constexpr (TElementData::ElementManagesTimeIntegration){ + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + if (data.IsCut()){ + GeometryType::Pointer p_geom = this->pGetGeometry(); + Matrix shape_functions_pos, shape_functions_neg; + Matrix shape_functions_enr_pos, shape_functions_enr_neg; + GeometryType::ShapeFunctionsGradientsType shape_derivatives_pos, shape_derivatives_neg; + GeometryType::ShapeFunctionsGradientsType shape_derivatives_enr_pos, shape_derivatives_enr_neg; + + ModifiedShapeFunctions::Pointer p_modified_sh_func = pGetModifiedShapeFunctionsUtility(p_geom, data.Distance); + + ComputeSplitting( + data, + shape_functions_pos, + shape_functions_neg, + shape_functions_enr_pos, + shape_functions_enr_neg, + shape_derivatives_pos, + shape_derivatives_neg, + shape_derivatives_enr_pos, + shape_derivatives_enr_neg, + p_modified_sh_func); + + if (data.NumberOfDivisions == 1){ + // Cases exist when the element is not subdivided due to the characteristics of the provided distance + // In this cases the element is treated as AIR or FLUID depending on the side + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + array_1d Ncenter; + for (unsigned int i = 0; i < NumNodes; ++i){ + Ncenter[i] = 1.0/NumNodes; + } + for (unsigned int g = 0; g < number_of_gauss_points; ++g){ + UpdateIntegrationPointData( + data, + g, + gauss_weights[g], + row(shape_functions, g), + shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } else { + MatrixType Vtot = ZeroMatrix(NumNodes * (Dim + 1), NumNodes); + MatrixType Htot = ZeroMatrix(NumNodes, NumNodes * (Dim + 1)); + MatrixType Kee_tot = ZeroMatrix(NumNodes, NumNodes); + VectorType rhs_ee_tot = ZeroVector(NumNodes); + + for (unsigned int g_pos = 0; g_pos < data.w_gauss_pos_side.size(); ++g_pos){ + UpdateIntegrationPointData( + data, + g_pos, + data.w_gauss_pos_side[g_pos], + row(shape_functions_pos, g_pos), + shape_derivatives_pos[g_pos], + row(shape_functions_enr_pos, g_pos), + shape_derivatives_enr_pos[g_pos]); + + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + this->ComputeGaussPointEnrichmentContributions(data, Vtot, Htot, Kee_tot, rhs_ee_tot); + } + + for (unsigned int g_neg = 0; g_neg < data.w_gauss_neg_side.size(); ++g_neg){ + UpdateIntegrationPointData( + data, + g_neg, + data.w_gauss_neg_side[g_neg], + row(shape_functions_neg, g_neg), + shape_derivatives_neg[g_neg], + row(shape_functions_enr_neg, g_neg), + shape_derivatives_enr_neg[g_neg]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + this->ComputeGaussPointEnrichmentContributions(data, Vtot, Htot, Kee_tot, rhs_ee_tot); + } + + Matrix int_shape_function, int_shape_function_enr_neg, int_shape_function_enr_pos; + GeometryType::ShapeFunctionsGradientsType int_shape_derivatives; + Vector int_gauss_pts_weights; + std::vector< array_1d > int_normals_neg; + + if (rCurrentProcessInfo[SURFACE_TENSION] || rCurrentProcessInfo[MOMENTUM_CORRECTION]){ + ComputeSplitInterface( + data, + int_shape_function, + int_shape_function_enr_pos, + int_shape_function_enr_neg, + int_shape_derivatives, + int_gauss_pts_weights, + int_normals_neg, + p_modified_sh_func); + } + + if (rCurrentProcessInfo[MOMENTUM_CORRECTION]){ + BoundedMatrix lhs_acc_correction = ZeroMatrix(LocalSize,LocalSize); + + double positive_density = 0.0; + double negative_density = 0.0; + + const auto& r_geom = this->GetGeometry(); + + for (unsigned int intgp = 0; intgp < int_gauss_pts_weights.size(); ++intgp){ + double u_dot_n = 0.0; + for (unsigned int i = 0; i < NumNodes; ++i){ + u_dot_n += int_shape_function(intgp,i)*r_geom[i].GetValue(DISTANCE_CORRECTION); + + if (data.Distance[i] > 0.0){ + positive_density = data.NodalDensity[i]; + } else { + negative_density = data.NodalDensity[i]; + } + } + + u_dot_n /= data.DeltaTime; + + for (unsigned int i = 0; i < NumNodes; ++i){ + for (unsigned int j = 0; j < NumNodes; ++j){ + for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ + lhs_acc_correction( i*(NumNodes) + dim, j*(NumNodes) + dim) += + int_shape_function(intgp,i)*int_shape_function(intgp,j)*u_dot_n*int_gauss_pts_weights(intgp); + } + } + } + } + + lhs_acc_correction = (negative_density - positive_density)*lhs_acc_correction; + noalias(rLeftHandSideMatrix) += lhs_acc_correction; + + Kratos::array_1d tempU; // Unknowns vector containing only velocity components + for (unsigned int i = 0; i < NumNodes; ++i){ + for (unsigned int dimi = 0; dimi < Dim; ++dimi){ + tempU[i*(Dim+1) + dimi] = data.Velocity(i,dimi); + } + } + noalias(rRightHandSideVector) -= prod(lhs_acc_correction,tempU); + } + + if (rCurrentProcessInfo[SURFACE_TENSION]){ + + AddSurfaceTensionContribution( + data, + int_shape_function, + int_shape_function_enr_pos, + int_shape_function_enr_neg, + int_shape_derivatives, + int_gauss_pts_weights, + int_normals_neg, + rLeftHandSideMatrix, + rRightHandSideVector, + Htot, + Vtot, + Kee_tot, + rhs_ee_tot + ); + + } else{ + // Without pressure gradient stabilization, volume ratio is checked during condensation + // Also, without surface tension, zero pressure difference is penalized + CondenseEnrichmentWithContinuity(data, rLeftHandSideMatrix, rRightHandSideVector, Htot, Vtot, Kee_tot, rhs_ee_tot); + } + + } + } else { + //Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + // Iterate over integration points to evaluate local contribution + for (unsigned int g = 0; g < number_of_gauss_points; ++g){ + UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } + } else{ + KRATOS_ERROR << "TwoFluidNavierStokesFractional is supposed to manage time integration." << std::endl; + } +} + +template +void TwoFluidNavierStokesFractional::CalculateRightHandSide( + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) +{ + MatrixType tmp; + CalculateLocalSystem(tmp, rRightHandSideVector, rCurrentProcessInfo); +} +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Public Inquiry + +template +int TwoFluidNavierStokesFractional::Check(const ProcessInfo &rCurrentProcessInfo) const +{ + KRATOS_TRY; + int out = FluidElement::Check(rCurrentProcessInfo); + KRATOS_ERROR_IF_NOT(out == 0) + << "Error in base class Check for Element " << this->Info() << std::endl + << "Error code is " << out << std::endl; + + return 0; + + KRATOS_CATCH(""); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Public I/O + +template +const Parameters TwoFluidNavierStokesFractional::GetSpecifications() const +{ + const Parameters specifications = Parameters(R"({ + "time_integration" : ["implicit"], + "framework" : "ale", + "symmetric_lhs" : false, + "positive_definite_lhs" : true, + "output" : { + "gauss_point" : [], + "nodal_historical" : ["VELOCITY","PRESSURE"], + "nodal_non_historical" : [], + "entity" : [] + }, + "required_variables" : ["DISTANCE","VELOCITY","PRESSURE","MESH_VELOCITY","DENSITY","DYNAMIC_VISCOSITY"], + "required_dofs" : [], + "flags_used" : [], + "compatible_geometries" : ["Triangle2D3","Tetrahedra3D4"], + "element_integrates_in_time" : true, + "compatible_constitutive_laws": { + "type" : ["NewtonianTwoFluid2DLaw","NewtonianTwoFluid3DLaw"], + "dimension" : ["2D","3D"], + "strain_size" : [3,6] + }, + "required_polynomial_degree_of_geometry" : 1, + "documentation" : + "This element implements Navier-Stokes biphasic fluid-air formulation with a levelset-based interface representation with Variational MultiScales (VMS) stabilization. Note that any viscous behavior can be used for the fluid phase through a constitutive law. The air phase is assumed to be Newtonian. Surface tension contribution can be accounted for by setting the SURFACE_TENSION variable to true in the ProcessInfo container. + })"); + + if (Dim == 2) { + std::vector dofs_2d({"VELOCITY_X","VELOCITY_Y","PRESSURE"}); + specifications["required_dofs"].SetStringArray(dofs_2d); + } else { + std::vector dofs_3d({"VELOCITY_X","VELOCITY_Y","VELOCITY_Z","PRESSURE"}); + specifications["required_dofs"].SetStringArray(dofs_3d); + } + + return specifications; +} + +template +std::string TwoFluidNavierStokesFractional::Info() const +{ + std::stringstream buffer; + buffer << "TwoFluidNavierStokesFractional" << Dim << "D" << NumNodes << "N #" << this->Id(); + return buffer.str(); +} + +template +void TwoFluidNavierStokesFractional::PrintInfo( + std::ostream &rOStream) const +{ + rOStream << this->Info() << std::endl; + + if (this->GetConstitutiveLaw() != nullptr){ + rOStream << "with constitutive law " << std::endl; + this->GetConstitutiveLaw()->PrintInfo(rOStream); + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Protected operations + +template +void TwoFluidNavierStokesFractional::AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) +{ + this->ComputeGaussPointLHSContribution(rData, rLHS); + this->ComputeGaussPointRHSContribution(rData, rRHS); +} + +template +void TwoFluidNavierStokesFractional::AddTimeIntegratedLHS( + TElementData &rData, + MatrixType &rLHS) +{ + this->ComputeGaussPointLHSContribution(rData, rLHS); +} + +template +void TwoFluidNavierStokesFractional::AddTimeIntegratedRHS( + TElementData &rData, + VectorType &rRHS) +{ + this->ComputeGaussPointRHSContribution(rData, rRHS); +} + +template +void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( + TElementData& rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType& rN, + const typename TElementData::ShapeDerivativesType& rDN_DX) const +{ + rData.UpdateGeometryValues(IntegrationPointIndex, Weight, rN, rDN_DX); + const double d_gauss = inner_prod(rData.Distance, rN); + if (d_gauss > 0.0) + rData.CalculateAirMaterialResponse(); + else + this->CalculateMaterialResponse(rData); + rData.ComputeDarcyTerm(); +} + +template +void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( + TElementData& rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType& rN, + const typename TElementData::ShapeDerivativesType& rDN_DX, + const typename TElementData::MatrixRowType& rNenr, + const typename TElementData::ShapeDerivativesType& rDN_DXenr) const +{ + rData.UpdateGeometryValues(IntegrationPointIndex,Weight,rN,rDN_DX,rNenr,rDN_DXenr); + const double d_gauss = inner_prod(rData.Distance, rN); + if (d_gauss > 0.0) + rData.CalculateAirMaterialResponse(); + else + this->CalculateMaterialResponse(rData); + rData.ComputeDarcyTerm(); +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalData<2, 3> &rData, + MatrixType &rLHS) +{ + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + const auto vn = rData.Velocity_OldStep1; + const auto vconv = rData.Velocity - rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + + // Get constitutive matrix + const Matrix &C = rData.C; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + + const double clhs0 = C(0,0)*DN(0,0) + C(0,2)*DN(0,1); +const double clhs1 = C(0,2)*DN(0,0); +const double clhs2 = C(2,2)*DN(0,1) + clhs1; +const double clhs3 = DN(0,0)*DN(0,0); +const double clhs4 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double clhs5 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double clhs6 = rho*stab_c2*sqrt(clhs4*clhs4 + clhs5*clhs5); +const double clhs7 = clhs6*h*1.0/stab_c1 + mu; +const double clhs8 = N[0]*N[0]; +const double clhs9 = rho*(DN(0,0)*clhs4 + DN(0,1)*clhs5); +const double clhs10 = bdf0*rho; +const double clhs11 = K_darcy*N[0]; +const double clhs12 = N[0]*clhs10; +const double clhs13 = clhs11 + clhs12 + clhs9; +const double clhs14 = 1.0/(K_darcy + clhs6*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); +const double clhs15 = 1.0*clhs9; +const double clhs16 = clhs14*clhs15; +const double clhs17 = 1.0*clhs11; +const double clhs18 = clhs14*clhs17; +const double clhs19 = 1.0*clhs14; +const double clhs20 = clhs13*clhs19; +const double clhs21 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double clhs22 = N[0]*clhs21; +const double clhs23 = K_darcy*clhs8 + N[0]*clhs9 + clhs10*clhs8 + clhs13*clhs16 - clhs13*clhs18 + clhs20*clhs22; +const double clhs24 = C(0,1)*DN(0,1) + clhs1; +const double clhs25 = C(1,2)*DN(0,1); +const double clhs26 = C(2,2)*DN(0,0) + clhs25; +const double clhs27 = DN(0,0)*clhs7; +const double clhs28 = DN(0,1)*clhs27; +const double clhs29 = clhs19*clhs21; +const double clhs30 = N[0]*clhs29 - N[0] + clhs16 - clhs18; +const double clhs31 = C(0,0)*DN(1,0) + C(0,2)*DN(1,1); +const double clhs32 = C(0,2)*DN(1,0); +const double clhs33 = C(2,2)*DN(1,1) + clhs32; +const double clhs34 = DN(0,0)*DN(1,0); +const double clhs35 = N[1]*clhs11 + N[1]*clhs12; +const double clhs36 = clhs34*clhs7 + clhs35; +const double clhs37 = rho*(DN(1,0)*clhs4 + DN(1,1)*clhs5); +const double clhs38 = K_darcy*N[1]; +const double clhs39 = N[1]*clhs10; +const double clhs40 = clhs37 + clhs38 + clhs39; +const double clhs41 = clhs19*clhs40; +const double clhs42 = N[0]*clhs37 + clhs16*clhs40 - clhs18*clhs40 + clhs22*clhs41; +const double clhs43 = C(0,1)*DN(1,1) + clhs32; +const double clhs44 = C(1,2)*DN(1,1); +const double clhs45 = C(2,2)*DN(1,0) + clhs44; +const double clhs46 = DN(1,1)*clhs27; +const double clhs47 = DN(0,0)*N[1]; +const double clhs48 = DN(1,0)*N[0]; +const double clhs49 = C(0,0)*DN(2,0) + C(0,2)*DN(2,1); +const double clhs50 = C(0,2)*DN(2,0); +const double clhs51 = C(2,2)*DN(2,1) + clhs50; +const double clhs52 = DN(0,0)*DN(2,0); +const double clhs53 = N[2]*clhs11 + N[2]*clhs12; +const double clhs54 = clhs52*clhs7 + clhs53; +const double clhs55 = rho*(DN(2,0)*clhs4 + DN(2,1)*clhs5); +const double clhs56 = K_darcy*N[2]; +const double clhs57 = N[2]*clhs10; +const double clhs58 = clhs55 + clhs56 + clhs57; +const double clhs59 = clhs19*clhs58; +const double clhs60 = N[0]*clhs55 + clhs16*clhs58 - clhs18*clhs58 + clhs22*clhs59; +const double clhs61 = C(0,1)*DN(2,1) + clhs50; +const double clhs62 = C(1,2)*DN(2,1); +const double clhs63 = C(2,2)*DN(2,0) + clhs62; +const double clhs64 = DN(2,1)*clhs27; +const double clhs65 = DN(0,0)*N[2]; +const double clhs66 = DN(2,0)*N[0]; +const double clhs67 = C(0,1)*DN(0,0) + clhs25; +const double clhs68 = C(1,1)*DN(0,1) + C(1,2)*DN(0,0); +const double clhs69 = DN(0,1)*DN(0,1); +const double clhs70 = C(0,1)*DN(1,0) + clhs44; +const double clhs71 = DN(0,1)*clhs7; +const double clhs72 = DN(1,0)*clhs71; +const double clhs73 = C(1,1)*DN(1,1) + C(1,2)*DN(1,0); +const double clhs74 = DN(0,1)*DN(1,1); +const double clhs75 = clhs35 + clhs7*clhs74; +const double clhs76 = DN(0,1)*N[1]; +const double clhs77 = DN(1,1)*N[0]; +const double clhs78 = C(0,1)*DN(2,0) + clhs62; +const double clhs79 = DN(2,0)*clhs71; +const double clhs80 = C(1,1)*DN(2,1) + C(1,2)*DN(2,0); +const double clhs81 = DN(0,1)*DN(2,1); +const double clhs82 = clhs53 + clhs7*clhs81; +const double clhs83 = DN(0,1)*N[2]; +const double clhs84 = DN(2,1)*N[0]; +const double clhs85 = N[0] + clhs14*(1.0*clhs12 + clhs15 + clhs17); +const double clhs86 = clhs19*(clhs34 + clhs74); +const double clhs87 = clhs19*(clhs52 + clhs81); +const double clhs88 = clhs19*clhs37; +const double clhs89 = clhs19*clhs38; +const double clhs90 = N[1]*clhs21; +const double clhs91 = N[1]*clhs9 + clhs13*clhs88 - clhs13*clhs89 + clhs20*clhs90; +const double clhs92 = DN(1,0)*DN(1,0); +const double clhs93 = N[1]*N[1]; +const double clhs94 = K_darcy*clhs93 + N[1]*clhs37 + clhs10*clhs93 + clhs37*clhs41 - clhs38*clhs41 + clhs41*clhs90; +const double clhs95 = DN(1,0)*clhs7; +const double clhs96 = DN(1,1)*clhs95; +const double clhs97 = N[1]*clhs29 - N[1] + clhs88 - clhs89; +const double clhs98 = DN(1,0)*DN(2,0); +const double clhs99 = N[2]*clhs38 + N[2]*clhs39; +const double clhs100 = clhs7*clhs98 + clhs99; +const double clhs101 = N[1]*clhs55 + clhs37*clhs59 - clhs38*clhs59 + clhs59*clhs90; +const double clhs102 = DN(2,1)*clhs95; +const double clhs103 = DN(1,0)*N[2]; +const double clhs104 = DN(2,0)*N[1]; +const double clhs105 = DN(1,1)*DN(1,1); +const double clhs106 = DN(2,0)*clhs7; +const double clhs107 = DN(1,1)*clhs106; +const double clhs108 = DN(1,1)*DN(2,1); +const double clhs109 = clhs108*clhs7 + clhs99; +const double clhs110 = DN(1,1)*N[2]; +const double clhs111 = DN(2,1)*N[1]; +const double clhs112 = N[1] + clhs14*(1.0*clhs37 + 1.0*clhs38 + 1.0*clhs39); +const double clhs113 = clhs19*(clhs108 + clhs98); +const double clhs114 = N[2]*clhs21; +const double clhs115 = N[2]*clhs9 + clhs114*clhs20 + clhs20*clhs55 - clhs20*clhs56; +const double clhs116 = clhs19*clhs56; +const double clhs117 = clhs19*clhs55; +const double clhs118 = N[2]*clhs37 + clhs114*clhs41 + clhs41*clhs55 - clhs41*clhs56; +const double clhs119 = DN(2,0)*DN(2,0); +const double clhs120 = N[2]*N[2]; +const double clhs121 = K_darcy*clhs120 + N[2]*clhs55 + clhs10*clhs120 + clhs114*clhs59 + clhs55*clhs59 - clhs56*clhs59; +const double clhs122 = DN(2,1)*clhs106; +const double clhs123 = N[2]*clhs29 - N[2] - clhs116 + clhs117; +const double clhs124 = DN(2,1)*DN(2,1); +const double clhs125 = N[2] + clhs14*(1.0*clhs55 + 1.0*clhs56 + 1.0*clhs57); +lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + clhs23 + clhs3*clhs7; +lhs(0,1)=DN(0,0)*clhs24 + DN(0,1)*clhs26 + clhs28; +lhs(0,2)=DN(0,0)*clhs30; +lhs(0,3)=DN(0,0)*clhs31 + DN(0,1)*clhs33 + clhs36 + clhs42; +lhs(0,4)=DN(0,0)*clhs43 + DN(0,1)*clhs45 + clhs46; +lhs(0,5)=DN(1,0)*clhs16 - DN(1,0)*clhs18 + clhs29*clhs48 - clhs47; +lhs(0,6)=DN(0,0)*clhs49 + DN(0,1)*clhs51 + clhs54 + clhs60; +lhs(0,7)=DN(0,0)*clhs61 + DN(0,1)*clhs63 + clhs64; +lhs(0,8)=DN(2,0)*clhs16 - DN(2,0)*clhs18 + clhs29*clhs66 - clhs65; +lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs67 + clhs28; +lhs(1,1)=DN(0,0)*clhs26 + DN(0,1)*clhs68 + clhs23 + clhs69*clhs7; +lhs(1,2)=DN(0,1)*clhs30; +lhs(1,3)=DN(0,0)*clhs33 + DN(0,1)*clhs70 + clhs72; +lhs(1,4)=DN(0,0)*clhs45 + DN(0,1)*clhs73 + clhs42 + clhs75; +lhs(1,5)=DN(1,1)*clhs16 - DN(1,1)*clhs18 + clhs29*clhs77 - clhs76; +lhs(1,6)=DN(0,0)*clhs51 + DN(0,1)*clhs78 + clhs79; +lhs(1,7)=DN(0,0)*clhs63 + DN(0,1)*clhs80 + clhs60 + clhs82; +lhs(1,8)=DN(2,1)*clhs16 - DN(2,1)*clhs18 + clhs29*clhs84 - clhs83; +lhs(2,0)=DN(0,0)*clhs85; +lhs(2,1)=DN(0,1)*clhs85; +lhs(2,2)=clhs19*(clhs3 + clhs69); +lhs(2,3)=DN(0,0)*clhs41 + clhs48; +lhs(2,4)=DN(0,1)*clhs41 + clhs77; +lhs(2,5)=clhs86; +lhs(2,6)=DN(0,0)*clhs59 + clhs66; +lhs(2,7)=DN(0,1)*clhs59 + clhs84; +lhs(2,8)=clhs87; +lhs(3,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + clhs36 + clhs91; +lhs(3,1)=DN(1,0)*clhs24 + DN(1,1)*clhs26 + clhs72; +lhs(3,2)=DN(0,0)*clhs88 - DN(0,0)*clhs89 + clhs29*clhs47 - clhs48; +lhs(3,3)=DN(1,0)*clhs31 + DN(1,1)*clhs33 + clhs7*clhs92 + clhs94; +lhs(3,4)=DN(1,0)*clhs43 + DN(1,1)*clhs45 + clhs96; +lhs(3,5)=DN(1,0)*clhs97; +lhs(3,6)=DN(1,0)*clhs49 + DN(1,1)*clhs51 + clhs100 + clhs101; +lhs(3,7)=DN(1,0)*clhs61 + DN(1,1)*clhs63 + clhs102; +lhs(3,8)=DN(2,0)*clhs88 - DN(2,0)*clhs89 - clhs103 + clhs104*clhs29; +lhs(4,0)=DN(1,0)*clhs2 + DN(1,1)*clhs67 + clhs46; +lhs(4,1)=DN(1,0)*clhs26 + DN(1,1)*clhs68 + clhs75 + clhs91; +lhs(4,2)=DN(0,1)*clhs88 - DN(0,1)*clhs89 + clhs29*clhs76 - clhs77; +lhs(4,3)=DN(1,0)*clhs33 + DN(1,1)*clhs70 + clhs96; +lhs(4,4)=DN(1,0)*clhs45 + DN(1,1)*clhs73 + clhs105*clhs7 + clhs94; +lhs(4,5)=DN(1,1)*clhs97; +lhs(4,6)=DN(1,0)*clhs51 + DN(1,1)*clhs78 + clhs107; +lhs(4,7)=DN(1,0)*clhs63 + DN(1,1)*clhs80 + clhs101 + clhs109; +lhs(4,8)=DN(2,1)*clhs88 - DN(2,1)*clhs89 - clhs110 + clhs111*clhs29; +lhs(5,0)=DN(1,0)*clhs20 + clhs47; +lhs(5,1)=DN(1,1)*clhs20 + clhs76; +lhs(5,2)=clhs86; +lhs(5,3)=DN(1,0)*clhs112; +lhs(5,4)=DN(1,1)*clhs112; +lhs(5,5)=clhs19*(clhs105 + clhs92); +lhs(5,6)=DN(1,0)*clhs59 + clhs104; +lhs(5,7)=DN(1,1)*clhs59 + clhs111; +lhs(5,8)=clhs113; +lhs(6,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + clhs115 + clhs54; +lhs(6,1)=DN(2,0)*clhs24 + DN(2,1)*clhs26 + clhs79; +lhs(6,2)=-DN(0,0)*clhs116 + DN(0,0)*clhs117 + clhs29*clhs65 - clhs66; +lhs(6,3)=DN(2,0)*clhs31 + DN(2,1)*clhs33 + clhs100 + clhs118; +lhs(6,4)=DN(2,0)*clhs43 + DN(2,1)*clhs45 + clhs107; +lhs(6,5)=-DN(1,0)*clhs116 + DN(1,0)*clhs117 + clhs103*clhs29 - clhs104; +lhs(6,6)=DN(2,0)*clhs49 + DN(2,1)*clhs51 + clhs119*clhs7 + clhs121; +lhs(6,7)=DN(2,0)*clhs61 + DN(2,1)*clhs63 + clhs122; +lhs(6,8)=DN(2,0)*clhs123; +lhs(7,0)=DN(2,0)*clhs2 + DN(2,1)*clhs67 + clhs64; +lhs(7,1)=DN(2,0)*clhs26 + DN(2,1)*clhs68 + clhs115 + clhs82; +lhs(7,2)=-DN(0,1)*clhs116 + DN(0,1)*clhs117 + clhs29*clhs83 - clhs84; +lhs(7,3)=DN(2,0)*clhs33 + DN(2,1)*clhs70 + clhs102; +lhs(7,4)=DN(2,0)*clhs45 + DN(2,1)*clhs73 + clhs109 + clhs118; +lhs(7,5)=-DN(1,1)*clhs116 + DN(1,1)*clhs117 + clhs110*clhs29 - clhs111; +lhs(7,6)=DN(2,0)*clhs51 + DN(2,1)*clhs78 + clhs122; +lhs(7,7)=DN(2,0)*clhs63 + DN(2,1)*clhs80 + clhs121 + clhs124*clhs7; +lhs(7,8)=DN(2,1)*clhs123; +lhs(8,0)=DN(2,0)*clhs20 + clhs65; +lhs(8,1)=DN(2,1)*clhs20 + clhs83; +lhs(8,2)=clhs87; +lhs(8,3)=DN(2,0)*clhs41 + clhs103; +lhs(8,4)=DN(2,1)*clhs41 + clhs110; +lhs(8,5)=clhs113; +lhs(8,6)=DN(2,0)*clhs125; +lhs(8,7)=DN(2,1)*clhs125; +lhs(8,8)=clhs19*(clhs119 + clhs124); + + + // Add intermediate results to local system + noalias(rLHS) += lhs * rData.Weight; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalData<3, 4> &rData, + MatrixType &rLHS) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + const double K_darcy = rData.DarcyTerm; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + + const auto vn=rData.Velocity_OldStep1; + const auto vconv = rData.Velocity - rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + + // Get constitutive matrix + const Matrix &C = rData.C; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + + const double clhs0 = C(0,0)*DN(0,0) + C(0,3)*DN(0,1) + C(0,5)*DN(0,2); +const double clhs1 = C(0,3)*DN(0,0); +const double clhs2 = C(3,3)*DN(0,1) + C(3,5)*DN(0,2) + clhs1; +const double clhs3 = C(0,5)*DN(0,0); +const double clhs4 = C(3,5)*DN(0,1) + C(5,5)*DN(0,2) + clhs3; +const double clhs5 = DN(0,0)*DN(0,0); +const double clhs6 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double clhs7 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double clhs8 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double clhs9 = rho*stab_c2*sqrt(clhs6*clhs6 + clhs7*clhs7 + clhs8*clhs8); +const double clhs10 = clhs9*h*1.0/stab_c1 + mu; +const double clhs11 = N[0]*N[0]; +const double clhs12 = rho*(DN(0,0)*clhs6 + DN(0,1)*clhs7 + DN(0,2)*clhs8); +const double clhs13 = bdf0*rho; +const double clhs14 = K_darcy*N[0]; +const double clhs15 = N[0]*clhs13; +const double clhs16 = clhs12 + clhs14 + clhs15; +const double clhs17 = 1.0/(K_darcy + clhs9*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); +const double clhs18 = 1.0*clhs12; +const double clhs19 = clhs17*clhs18; +const double clhs20 = 1.0*clhs14; +const double clhs21 = clhs17*clhs20; +const double clhs22 = 1.0*clhs17; +const double clhs23 = clhs16*clhs22; +const double clhs24 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double clhs25 = N[0]*clhs24; +const double clhs26 = K_darcy*clhs11 + N[0]*clhs12 + clhs11*clhs13 + clhs16*clhs19 - clhs16*clhs21 + clhs23*clhs25; +const double clhs27 = C(0,1)*DN(0,1) + C(0,4)*DN(0,2) + clhs1; +const double clhs28 = C(1,3)*DN(0,1); +const double clhs29 = C(3,3)*DN(0,0) + C(3,4)*DN(0,2) + clhs28; +const double clhs30 = C(3,5)*DN(0,0); +const double clhs31 = C(4,5)*DN(0,2); +const double clhs32 = C(1,5)*DN(0,1) + clhs30 + clhs31; +const double clhs33 = DN(0,0)*clhs10; +const double clhs34 = DN(0,1)*clhs33; +const double clhs35 = C(0,2)*DN(0,2) + C(0,4)*DN(0,1) + clhs3; +const double clhs36 = C(3,4)*DN(0,1); +const double clhs37 = C(2,3)*DN(0,2) + clhs30 + clhs36; +const double clhs38 = C(2,5)*DN(0,2); +const double clhs39 = C(4,5)*DN(0,1) + C(5,5)*DN(0,0) + clhs38; +const double clhs40 = DN(0,2)*clhs33; +const double clhs41 = clhs22*clhs24; +const double clhs42 = N[0]*clhs41 - N[0] + clhs19 - clhs21; +const double clhs43 = C(0,0)*DN(1,0) + C(0,3)*DN(1,1) + C(0,5)*DN(1,2); +const double clhs44 = C(0,3)*DN(1,0); +const double clhs45 = C(3,3)*DN(1,1) + C(3,5)*DN(1,2) + clhs44; +const double clhs46 = C(0,5)*DN(1,0); +const double clhs47 = C(3,5)*DN(1,1) + C(5,5)*DN(1,2) + clhs46; +const double clhs48 = DN(0,0)*DN(1,0); +const double clhs49 = N[1]*clhs14 + N[1]*clhs15; +const double clhs50 = clhs10*clhs48 + clhs49; +const double clhs51 = rho*(DN(1,0)*clhs6 + DN(1,1)*clhs7 + DN(1,2)*clhs8); +const double clhs52 = K_darcy*N[1]; +const double clhs53 = N[1]*clhs13; +const double clhs54 = clhs51 + clhs52 + clhs53; +const double clhs55 = clhs22*clhs54; +const double clhs56 = N[0]*clhs51 + clhs19*clhs54 - clhs21*clhs54 + clhs25*clhs55; +const double clhs57 = C(0,1)*DN(1,1) + C(0,4)*DN(1,2) + clhs44; +const double clhs58 = C(1,3)*DN(1,1); +const double clhs59 = C(3,3)*DN(1,0) + C(3,4)*DN(1,2) + clhs58; +const double clhs60 = C(3,5)*DN(1,0); +const double clhs61 = C(4,5)*DN(1,2); +const double clhs62 = C(1,5)*DN(1,1) + clhs60 + clhs61; +const double clhs63 = DN(1,1)*clhs33; +const double clhs64 = C(0,2)*DN(1,2) + C(0,4)*DN(1,1) + clhs46; +const double clhs65 = C(3,4)*DN(1,1); +const double clhs66 = C(2,3)*DN(1,2) + clhs60 + clhs65; +const double clhs67 = C(2,5)*DN(1,2); +const double clhs68 = C(4,5)*DN(1,1) + C(5,5)*DN(1,0) + clhs67; +const double clhs69 = DN(1,2)*clhs33; +const double clhs70 = DN(0,0)*N[1]; +const double clhs71 = DN(1,0)*N[0]; +const double clhs72 = C(0,0)*DN(2,0) + C(0,3)*DN(2,1) + C(0,5)*DN(2,2); +const double clhs73 = C(0,3)*DN(2,0); +const double clhs74 = C(3,3)*DN(2,1) + C(3,5)*DN(2,2) + clhs73; +const double clhs75 = C(0,5)*DN(2,0); +const double clhs76 = C(3,5)*DN(2,1) + C(5,5)*DN(2,2) + clhs75; +const double clhs77 = DN(0,0)*DN(2,0); +const double clhs78 = N[2]*clhs14 + N[2]*clhs15; +const double clhs79 = clhs10*clhs77 + clhs78; +const double clhs80 = rho*(DN(2,0)*clhs6 + DN(2,1)*clhs7 + DN(2,2)*clhs8); +const double clhs81 = K_darcy*N[2]; +const double clhs82 = N[2]*clhs13; +const double clhs83 = clhs80 + clhs81 + clhs82; +const double clhs84 = clhs22*clhs83; +const double clhs85 = N[0]*clhs80 + clhs19*clhs83 - clhs21*clhs83 + clhs25*clhs84; +const double clhs86 = C(0,1)*DN(2,1) + C(0,4)*DN(2,2) + clhs73; +const double clhs87 = C(1,3)*DN(2,1); +const double clhs88 = C(3,3)*DN(2,0) + C(3,4)*DN(2,2) + clhs87; +const double clhs89 = C(3,5)*DN(2,0); +const double clhs90 = C(4,5)*DN(2,2); +const double clhs91 = C(1,5)*DN(2,1) + clhs89 + clhs90; +const double clhs92 = DN(2,1)*clhs33; +const double clhs93 = C(0,2)*DN(2,2) + C(0,4)*DN(2,1) + clhs75; +const double clhs94 = C(3,4)*DN(2,1); +const double clhs95 = C(2,3)*DN(2,2) + clhs89 + clhs94; +const double clhs96 = C(2,5)*DN(2,2); +const double clhs97 = C(4,5)*DN(2,1) + C(5,5)*DN(2,0) + clhs96; +const double clhs98 = DN(2,2)*clhs33; +const double clhs99 = DN(0,0)*N[2]; +const double clhs100 = DN(2,0)*N[0]; +const double clhs101 = C(0,0)*DN(3,0) + C(0,3)*DN(3,1) + C(0,5)*DN(3,2); +const double clhs102 = C(0,3)*DN(3,0); +const double clhs103 = C(3,3)*DN(3,1) + C(3,5)*DN(3,2) + clhs102; +const double clhs104 = C(0,5)*DN(3,0); +const double clhs105 = C(3,5)*DN(3,1) + C(5,5)*DN(3,2) + clhs104; +const double clhs106 = DN(0,0)*DN(3,0); +const double clhs107 = N[3]*clhs14 + N[3]*clhs15; +const double clhs108 = clhs10*clhs106 + clhs107; +const double clhs109 = rho*(DN(3,0)*clhs6 + DN(3,1)*clhs7 + DN(3,2)*clhs8); +const double clhs110 = K_darcy*N[3]; +const double clhs111 = N[3]*clhs13; +const double clhs112 = clhs109 + clhs110 + clhs111; +const double clhs113 = clhs112*clhs22; +const double clhs114 = N[0]*clhs109 + clhs112*clhs19 - clhs112*clhs21 + clhs113*clhs25; +const double clhs115 = C(0,1)*DN(3,1) + C(0,4)*DN(3,2) + clhs102; +const double clhs116 = C(1,3)*DN(3,1); +const double clhs117 = C(3,3)*DN(3,0) + C(3,4)*DN(3,2) + clhs116; +const double clhs118 = C(3,5)*DN(3,0); +const double clhs119 = C(4,5)*DN(3,2); +const double clhs120 = C(1,5)*DN(3,1) + clhs118 + clhs119; +const double clhs121 = DN(3,1)*clhs33; +const double clhs122 = C(0,2)*DN(3,2) + C(0,4)*DN(3,1) + clhs104; +const double clhs123 = C(3,4)*DN(3,1); +const double clhs124 = C(2,3)*DN(3,2) + clhs118 + clhs123; +const double clhs125 = C(2,5)*DN(3,2); +const double clhs126 = C(4,5)*DN(3,1) + C(5,5)*DN(3,0) + clhs125; +const double clhs127 = DN(3,2)*clhs33; +const double clhs128 = DN(0,0)*N[3]; +const double clhs129 = DN(3,0)*N[0]; +const double clhs130 = C(0,1)*DN(0,0) + C(1,5)*DN(0,2) + clhs28; +const double clhs131 = C(0,4)*DN(0,0) + clhs31 + clhs36; +const double clhs132 = C(1,1)*DN(0,1) + C(1,3)*DN(0,0) + C(1,4)*DN(0,2); +const double clhs133 = C(1,4)*DN(0,1); +const double clhs134 = C(3,4)*DN(0,0) + C(4,4)*DN(0,2) + clhs133; +const double clhs135 = DN(0,1)*DN(0,1); +const double clhs136 = C(1,2)*DN(0,2) + C(1,5)*DN(0,0) + clhs133; +const double clhs137 = C(2,4)*DN(0,2); +const double clhs138 = C(4,4)*DN(0,1) + C(4,5)*DN(0,0) + clhs137; +const double clhs139 = DN(0,1)*clhs10; +const double clhs140 = DN(0,2)*clhs139; +const double clhs141 = C(0,1)*DN(1,0) + C(1,5)*DN(1,2) + clhs58; +const double clhs142 = C(0,4)*DN(1,0) + clhs61 + clhs65; +const double clhs143 = DN(1,0)*clhs139; +const double clhs144 = C(1,1)*DN(1,1) + C(1,3)*DN(1,0) + C(1,4)*DN(1,2); +const double clhs145 = C(1,4)*DN(1,1); +const double clhs146 = C(3,4)*DN(1,0) + C(4,4)*DN(1,2) + clhs145; +const double clhs147 = DN(0,1)*DN(1,1); +const double clhs148 = clhs10*clhs147; +const double clhs149 = clhs49 + clhs56; +const double clhs150 = C(1,2)*DN(1,2) + C(1,5)*DN(1,0) + clhs145; +const double clhs151 = C(2,4)*DN(1,2); +const double clhs152 = C(4,4)*DN(1,1) + C(4,5)*DN(1,0) + clhs151; +const double clhs153 = DN(1,2)*clhs139; +const double clhs154 = DN(0,1)*N[1]; +const double clhs155 = DN(1,1)*N[0]; +const double clhs156 = C(0,1)*DN(2,0) + C(1,5)*DN(2,2) + clhs87; +const double clhs157 = C(0,4)*DN(2,0) + clhs90 + clhs94; +const double clhs158 = DN(2,0)*clhs139; +const double clhs159 = C(1,1)*DN(2,1) + C(1,3)*DN(2,0) + C(1,4)*DN(2,2); +const double clhs160 = C(1,4)*DN(2,1); +const double clhs161 = C(3,4)*DN(2,0) + C(4,4)*DN(2,2) + clhs160; +const double clhs162 = DN(0,1)*DN(2,1); +const double clhs163 = clhs10*clhs162; +const double clhs164 = clhs78 + clhs85; +const double clhs165 = C(1,2)*DN(2,2) + C(1,5)*DN(2,0) + clhs160; +const double clhs166 = C(2,4)*DN(2,2); +const double clhs167 = C(4,4)*DN(2,1) + C(4,5)*DN(2,0) + clhs166; +const double clhs168 = DN(2,2)*clhs139; +const double clhs169 = DN(0,1)*N[2]; +const double clhs170 = DN(2,1)*N[0]; +const double clhs171 = C(0,1)*DN(3,0) + C(1,5)*DN(3,2) + clhs116; +const double clhs172 = C(0,4)*DN(3,0) + clhs119 + clhs123; +const double clhs173 = DN(3,0)*clhs139; +const double clhs174 = C(1,1)*DN(3,1) + C(1,3)*DN(3,0) + C(1,4)*DN(3,2); +const double clhs175 = C(1,4)*DN(3,1); +const double clhs176 = C(3,4)*DN(3,0) + C(4,4)*DN(3,2) + clhs175; +const double clhs177 = DN(0,1)*DN(3,1); +const double clhs178 = clhs10*clhs177; +const double clhs179 = clhs107 + clhs114; +const double clhs180 = C(1,2)*DN(3,2) + C(1,5)*DN(3,0) + clhs175; +const double clhs181 = C(2,4)*DN(3,2); +const double clhs182 = C(4,4)*DN(3,1) + C(4,5)*DN(3,0) + clhs181; +const double clhs183 = DN(3,2)*clhs139; +const double clhs184 = DN(0,1)*N[3]; +const double clhs185 = DN(3,1)*N[0]; +const double clhs186 = C(0,2)*DN(0,0) + C(2,3)*DN(0,1) + clhs38; +const double clhs187 = C(1,2)*DN(0,1) + C(2,3)*DN(0,0) + clhs137; +const double clhs188 = C(2,2)*DN(0,2) + C(2,4)*DN(0,1) + C(2,5)*DN(0,0); +const double clhs189 = DN(0,2)*DN(0,2); +const double clhs190 = C(0,2)*DN(1,0) + C(2,3)*DN(1,1) + clhs67; +const double clhs191 = DN(0,2)*clhs10; +const double clhs192 = DN(1,0)*clhs191; +const double clhs193 = C(1,2)*DN(1,1) + C(2,3)*DN(1,0) + clhs151; +const double clhs194 = DN(1,1)*clhs191; +const double clhs195 = C(2,2)*DN(1,2) + C(2,4)*DN(1,1) + C(2,5)*DN(1,0); +const double clhs196 = DN(0,2)*DN(1,2); +const double clhs197 = clhs10*clhs196; +const double clhs198 = DN(0,2)*N[1]; +const double clhs199 = DN(1,2)*N[0]; +const double clhs200 = C(0,2)*DN(2,0) + C(2,3)*DN(2,1) + clhs96; +const double clhs201 = DN(2,0)*clhs191; +const double clhs202 = C(1,2)*DN(2,1) + C(2,3)*DN(2,0) + clhs166; +const double clhs203 = DN(2,1)*clhs191; +const double clhs204 = C(2,2)*DN(2,2) + C(2,4)*DN(2,1) + C(2,5)*DN(2,0); +const double clhs205 = DN(0,2)*DN(2,2); +const double clhs206 = clhs10*clhs205; +const double clhs207 = DN(0,2)*N[2]; +const double clhs208 = DN(2,2)*N[0]; +const double clhs209 = C(0,2)*DN(3,0) + C(2,3)*DN(3,1) + clhs125; +const double clhs210 = DN(3,0)*clhs191; +const double clhs211 = C(1,2)*DN(3,1) + C(2,3)*DN(3,0) + clhs181; +const double clhs212 = DN(3,1)*clhs191; +const double clhs213 = C(2,2)*DN(3,2) + C(2,4)*DN(3,1) + C(2,5)*DN(3,0); +const double clhs214 = DN(0,2)*DN(3,2); +const double clhs215 = clhs10*clhs214; +const double clhs216 = DN(0,2)*N[3]; +const double clhs217 = DN(3,2)*N[0]; +const double clhs218 = N[0] + clhs17*(1.0*clhs15 + clhs18 + clhs20); +const double clhs219 = clhs22*(clhs147 + clhs196 + clhs48); +const double clhs220 = clhs22*(clhs162 + clhs205 + clhs77); +const double clhs221 = clhs22*(clhs106 + clhs177 + clhs214); +const double clhs222 = clhs22*clhs51; +const double clhs223 = clhs22*clhs52; +const double clhs224 = N[1]*clhs24; +const double clhs225 = N[1]*clhs12 + clhs16*clhs222 - clhs16*clhs223 + clhs224*clhs23; +const double clhs226 = DN(1,0)*DN(1,0); +const double clhs227 = N[1]*N[1]; +const double clhs228 = K_darcy*clhs227 + N[1]*clhs51 + clhs13*clhs227 + clhs224*clhs55 + clhs51*clhs55 - clhs52*clhs55; +const double clhs229 = DN(1,0)*clhs10; +const double clhs230 = DN(1,1)*clhs229; +const double clhs231 = DN(1,2)*clhs229; +const double clhs232 = N[1]*clhs41 - N[1] + clhs222 - clhs223; +const double clhs233 = DN(1,0)*DN(2,0); +const double clhs234 = N[2]*clhs52 + N[2]*clhs53; +const double clhs235 = clhs10*clhs233 + clhs234; +const double clhs236 = N[1]*clhs80 + clhs224*clhs84 + clhs51*clhs84 - clhs52*clhs84; +const double clhs237 = DN(2,1)*clhs229; +const double clhs238 = DN(2,2)*clhs229; +const double clhs239 = DN(1,0)*N[2]; +const double clhs240 = DN(2,0)*N[1]; +const double clhs241 = DN(1,0)*DN(3,0); +const double clhs242 = N[3]*clhs52 + N[3]*clhs53; +const double clhs243 = clhs10*clhs241 + clhs242; +const double clhs244 = N[1]*clhs109 + clhs113*clhs224 + clhs113*clhs51 - clhs113*clhs52; +const double clhs245 = DN(3,1)*clhs229; +const double clhs246 = DN(3,2)*clhs229; +const double clhs247 = DN(1,0)*N[3]; +const double clhs248 = DN(3,0)*N[1]; +const double clhs249 = clhs225 + clhs49; +const double clhs250 = DN(1,1)*DN(1,1); +const double clhs251 = DN(1,1)*clhs10; +const double clhs252 = DN(1,2)*clhs251; +const double clhs253 = DN(2,0)*clhs251; +const double clhs254 = DN(1,1)*DN(2,1); +const double clhs255 = clhs10*clhs254; +const double clhs256 = clhs234 + clhs236; +const double clhs257 = DN(2,2)*clhs251; +const double clhs258 = DN(1,1)*N[2]; +const double clhs259 = DN(2,1)*N[1]; +const double clhs260 = DN(3,0)*clhs251; +const double clhs261 = DN(1,1)*DN(3,1); +const double clhs262 = clhs10*clhs261; +const double clhs263 = clhs242 + clhs244; +const double clhs264 = DN(3,2)*clhs251; +const double clhs265 = DN(1,1)*N[3]; +const double clhs266 = DN(3,1)*N[1]; +const double clhs267 = DN(1,2)*DN(1,2); +const double clhs268 = DN(1,2)*clhs10; +const double clhs269 = DN(2,0)*clhs268; +const double clhs270 = DN(2,1)*clhs268; +const double clhs271 = DN(1,2)*DN(2,2); +const double clhs272 = clhs10*clhs271; +const double clhs273 = DN(1,2)*N[2]; +const double clhs274 = DN(2,2)*N[1]; +const double clhs275 = DN(3,0)*clhs268; +const double clhs276 = DN(3,1)*clhs268; +const double clhs277 = DN(1,2)*DN(3,2); +const double clhs278 = clhs10*clhs277; +const double clhs279 = DN(1,2)*N[3]; +const double clhs280 = DN(3,2)*N[1]; +const double clhs281 = N[1] + clhs17*(1.0*clhs51 + 1.0*clhs52 + 1.0*clhs53); +const double clhs282 = clhs22*(clhs233 + clhs254 + clhs271); +const double clhs283 = clhs22*(clhs241 + clhs261 + clhs277); +const double clhs284 = N[2]*clhs24; +const double clhs285 = N[2]*clhs12 + clhs23*clhs284 + clhs23*clhs80 - clhs23*clhs81; +const double clhs286 = clhs22*clhs81; +const double clhs287 = clhs22*clhs80; +const double clhs288 = N[2]*clhs51 + clhs284*clhs55 + clhs55*clhs80 - clhs55*clhs81; +const double clhs289 = DN(2,0)*DN(2,0); +const double clhs290 = N[2]*N[2]; +const double clhs291 = K_darcy*clhs290 + N[2]*clhs80 + clhs13*clhs290 + clhs284*clhs84 + clhs80*clhs84 - clhs81*clhs84; +const double clhs292 = DN(2,0)*clhs10; +const double clhs293 = DN(2,1)*clhs292; +const double clhs294 = DN(2,2)*clhs292; +const double clhs295 = N[2]*clhs41 - N[2] - clhs286 + clhs287; +const double clhs296 = DN(2,0)*DN(3,0); +const double clhs297 = N[3]*clhs81 + N[3]*clhs82; +const double clhs298 = clhs10*clhs296 + clhs297; +const double clhs299 = N[2]*clhs109 + clhs113*clhs284 + clhs113*clhs80 - clhs113*clhs81; +const double clhs300 = DN(3,1)*clhs292; +const double clhs301 = DN(3,2)*clhs292; +const double clhs302 = DN(2,0)*N[3]; +const double clhs303 = DN(3,0)*N[2]; +const double clhs304 = clhs285 + clhs78; +const double clhs305 = clhs234 + clhs288; +const double clhs306 = DN(2,1)*DN(2,1); +const double clhs307 = DN(2,1)*clhs10; +const double clhs308 = DN(2,2)*clhs307; +const double clhs309 = DN(3,0)*clhs307; +const double clhs310 = DN(2,1)*DN(3,1); +const double clhs311 = clhs10*clhs310; +const double clhs312 = clhs297 + clhs299; +const double clhs313 = DN(3,2)*clhs307; +const double clhs314 = DN(2,1)*N[3]; +const double clhs315 = DN(3,1)*N[2]; +const double clhs316 = DN(2,2)*DN(2,2); +const double clhs317 = DN(2,2)*clhs10; +const double clhs318 = DN(3,0)*clhs317; +const double clhs319 = DN(3,1)*clhs317; +const double clhs320 = DN(2,2)*DN(3,2); +const double clhs321 = clhs10*clhs320; +const double clhs322 = DN(2,2)*N[3]; +const double clhs323 = DN(3,2)*N[2]; +const double clhs324 = N[2] + clhs17*(1.0*clhs80 + 1.0*clhs81 + 1.0*clhs82); +const double clhs325 = clhs22*(clhs296 + clhs310 + clhs320); +const double clhs326 = N[3]*clhs24; +const double clhs327 = N[3]*clhs12 + clhs109*clhs23 - clhs110*clhs23 + clhs23*clhs326; +const double clhs328 = clhs110*clhs22; +const double clhs329 = clhs109*clhs22; +const double clhs330 = N[3]*clhs51 + clhs109*clhs55 - clhs110*clhs55 + clhs326*clhs55; +const double clhs331 = N[3]*clhs80 + clhs109*clhs84 - clhs110*clhs84 + clhs326*clhs84; +const double clhs332 = DN(3,0)*DN(3,0); +const double clhs333 = N[3]*N[3]; +const double clhs334 = K_darcy*clhs333 + N[3]*clhs109 + clhs109*clhs113 - clhs110*clhs113 + clhs113*clhs326 + clhs13*clhs333; +const double clhs335 = DN(3,0)*clhs10; +const double clhs336 = DN(3,1)*clhs335; +const double clhs337 = DN(3,2)*clhs335; +const double clhs338 = N[3]*clhs41 - N[3] - clhs328 + clhs329; +const double clhs339 = clhs107 + clhs327; +const double clhs340 = clhs242 + clhs330; +const double clhs341 = clhs297 + clhs331; +const double clhs342 = DN(3,1)*DN(3,1); +const double clhs343 = DN(3,1)*DN(3,2)*clhs10; +const double clhs344 = DN(3,2)*DN(3,2); +const double clhs345 = N[3] + clhs17*(1.0*clhs109 + 1.0*clhs110 + 1.0*clhs111); +lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + DN(0,2)*clhs4 + clhs10*clhs5 + clhs26; +lhs(0,1)=DN(0,0)*clhs27 + DN(0,1)*clhs29 + DN(0,2)*clhs32 + clhs34; +lhs(0,2)=DN(0,0)*clhs35 + DN(0,1)*clhs37 + DN(0,2)*clhs39 + clhs40; +lhs(0,3)=DN(0,0)*clhs42; +lhs(0,4)=DN(0,0)*clhs43 + DN(0,1)*clhs45 + DN(0,2)*clhs47 + clhs50 + clhs56; +lhs(0,5)=DN(0,0)*clhs57 + DN(0,1)*clhs59 + DN(0,2)*clhs62 + clhs63; +lhs(0,6)=DN(0,0)*clhs64 + DN(0,1)*clhs66 + DN(0,2)*clhs68 + clhs69; +lhs(0,7)=DN(1,0)*clhs19 - DN(1,0)*clhs21 + clhs41*clhs71 - clhs70; +lhs(0,8)=DN(0,0)*clhs72 + DN(0,1)*clhs74 + DN(0,2)*clhs76 + clhs79 + clhs85; +lhs(0,9)=DN(0,0)*clhs86 + DN(0,1)*clhs88 + DN(0,2)*clhs91 + clhs92; +lhs(0,10)=DN(0,0)*clhs93 + DN(0,1)*clhs95 + DN(0,2)*clhs97 + clhs98; +lhs(0,11)=DN(2,0)*clhs19 - DN(2,0)*clhs21 + clhs100*clhs41 - clhs99; +lhs(0,12)=DN(0,0)*clhs101 + DN(0,1)*clhs103 + DN(0,2)*clhs105 + clhs108 + clhs114; +lhs(0,13)=DN(0,0)*clhs115 + DN(0,1)*clhs117 + DN(0,2)*clhs120 + clhs121; +lhs(0,14)=DN(0,0)*clhs122 + DN(0,1)*clhs124 + DN(0,2)*clhs126 + clhs127; +lhs(0,15)=DN(3,0)*clhs19 - DN(3,0)*clhs21 - clhs128 + clhs129*clhs41; +lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs130 + DN(0,2)*clhs131 + clhs34; +lhs(1,1)=DN(0,0)*clhs29 + DN(0,1)*clhs132 + DN(0,2)*clhs134 + clhs10*clhs135 + clhs26; +lhs(1,2)=DN(0,0)*clhs37 + DN(0,1)*clhs136 + DN(0,2)*clhs138 + clhs140; +lhs(1,3)=DN(0,1)*clhs42; +lhs(1,4)=DN(0,0)*clhs45 + DN(0,1)*clhs141 + DN(0,2)*clhs142 + clhs143; +lhs(1,5)=DN(0,0)*clhs59 + DN(0,1)*clhs144 + DN(0,2)*clhs146 + clhs148 + clhs149; +lhs(1,6)=DN(0,0)*clhs66 + DN(0,1)*clhs150 + DN(0,2)*clhs152 + clhs153; +lhs(1,7)=DN(1,1)*clhs19 - DN(1,1)*clhs21 - clhs154 + clhs155*clhs41; +lhs(1,8)=DN(0,0)*clhs74 + DN(0,1)*clhs156 + DN(0,2)*clhs157 + clhs158; +lhs(1,9)=DN(0,0)*clhs88 + DN(0,1)*clhs159 + DN(0,2)*clhs161 + clhs163 + clhs164; +lhs(1,10)=DN(0,0)*clhs95 + DN(0,1)*clhs165 + DN(0,2)*clhs167 + clhs168; +lhs(1,11)=DN(2,1)*clhs19 - DN(2,1)*clhs21 - clhs169 + clhs170*clhs41; +lhs(1,12)=DN(0,0)*clhs103 + DN(0,1)*clhs171 + DN(0,2)*clhs172 + clhs173; +lhs(1,13)=DN(0,0)*clhs117 + DN(0,1)*clhs174 + DN(0,2)*clhs176 + clhs178 + clhs179; +lhs(1,14)=DN(0,0)*clhs124 + DN(0,1)*clhs180 + DN(0,2)*clhs182 + clhs183; +lhs(1,15)=DN(3,1)*clhs19 - DN(3,1)*clhs21 - clhs184 + clhs185*clhs41; +lhs(2,0)=DN(0,0)*clhs4 + DN(0,1)*clhs131 + DN(0,2)*clhs186 + clhs40; +lhs(2,1)=DN(0,0)*clhs32 + DN(0,1)*clhs134 + DN(0,2)*clhs187 + clhs140; +lhs(2,2)=DN(0,0)*clhs39 + DN(0,1)*clhs138 + DN(0,2)*clhs188 + clhs10*clhs189 + clhs26; +lhs(2,3)=DN(0,2)*clhs42; +lhs(2,4)=DN(0,0)*clhs47 + DN(0,1)*clhs142 + DN(0,2)*clhs190 + clhs192; +lhs(2,5)=DN(0,0)*clhs62 + DN(0,1)*clhs146 + DN(0,2)*clhs193 + clhs194; +lhs(2,6)=DN(0,0)*clhs68 + DN(0,1)*clhs152 + DN(0,2)*clhs195 + clhs149 + clhs197; +lhs(2,7)=DN(1,2)*clhs19 - DN(1,2)*clhs21 - clhs198 + clhs199*clhs41; +lhs(2,8)=DN(0,0)*clhs76 + DN(0,1)*clhs157 + DN(0,2)*clhs200 + clhs201; +lhs(2,9)=DN(0,0)*clhs91 + DN(0,1)*clhs161 + DN(0,2)*clhs202 + clhs203; +lhs(2,10)=DN(0,0)*clhs97 + DN(0,1)*clhs167 + DN(0,2)*clhs204 + clhs164 + clhs206; +lhs(2,11)=DN(2,2)*clhs19 - DN(2,2)*clhs21 - clhs207 + clhs208*clhs41; +lhs(2,12)=DN(0,0)*clhs105 + DN(0,1)*clhs172 + DN(0,2)*clhs209 + clhs210; +lhs(2,13)=DN(0,0)*clhs120 + DN(0,1)*clhs176 + DN(0,2)*clhs211 + clhs212; +lhs(2,14)=DN(0,0)*clhs126 + DN(0,1)*clhs182 + DN(0,2)*clhs213 + clhs179 + clhs215; +lhs(2,15)=DN(3,2)*clhs19 - DN(3,2)*clhs21 - clhs216 + clhs217*clhs41; +lhs(3,0)=DN(0,0)*clhs218; +lhs(3,1)=DN(0,1)*clhs218; +lhs(3,2)=DN(0,2)*clhs218; +lhs(3,3)=clhs22*(clhs135 + clhs189 + clhs5); +lhs(3,4)=DN(0,0)*clhs55 + clhs71; +lhs(3,5)=DN(0,1)*clhs55 + clhs155; +lhs(3,6)=DN(0,2)*clhs55 + clhs199; +lhs(3,7)=clhs219; +lhs(3,8)=DN(0,0)*clhs84 + clhs100; +lhs(3,9)=DN(0,1)*clhs84 + clhs170; +lhs(3,10)=DN(0,2)*clhs84 + clhs208; +lhs(3,11)=clhs220; +lhs(3,12)=DN(0,0)*clhs113 + clhs129; +lhs(3,13)=DN(0,1)*clhs113 + clhs185; +lhs(3,14)=DN(0,2)*clhs113 + clhs217; +lhs(3,15)=clhs221; +lhs(4,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + DN(1,2)*clhs4 + clhs225 + clhs50; +lhs(4,1)=DN(1,0)*clhs27 + DN(1,1)*clhs29 + DN(1,2)*clhs32 + clhs143; +lhs(4,2)=DN(1,0)*clhs35 + DN(1,1)*clhs37 + DN(1,2)*clhs39 + clhs192; +lhs(4,3)=DN(0,0)*clhs222 - DN(0,0)*clhs223 + clhs41*clhs70 - clhs71; +lhs(4,4)=DN(1,0)*clhs43 + DN(1,1)*clhs45 + DN(1,2)*clhs47 + clhs10*clhs226 + clhs228; +lhs(4,5)=DN(1,0)*clhs57 + DN(1,1)*clhs59 + DN(1,2)*clhs62 + clhs230; +lhs(4,6)=DN(1,0)*clhs64 + DN(1,1)*clhs66 + DN(1,2)*clhs68 + clhs231; +lhs(4,7)=DN(1,0)*clhs232; +lhs(4,8)=DN(1,0)*clhs72 + DN(1,1)*clhs74 + DN(1,2)*clhs76 + clhs235 + clhs236; +lhs(4,9)=DN(1,0)*clhs86 + DN(1,1)*clhs88 + DN(1,2)*clhs91 + clhs237; +lhs(4,10)=DN(1,0)*clhs93 + DN(1,1)*clhs95 + DN(1,2)*clhs97 + clhs238; +lhs(4,11)=DN(2,0)*clhs222 - DN(2,0)*clhs223 - clhs239 + clhs240*clhs41; +lhs(4,12)=DN(1,0)*clhs101 + DN(1,1)*clhs103 + DN(1,2)*clhs105 + clhs243 + clhs244; +lhs(4,13)=DN(1,0)*clhs115 + DN(1,1)*clhs117 + DN(1,2)*clhs120 + clhs245; +lhs(4,14)=DN(1,0)*clhs122 + DN(1,1)*clhs124 + DN(1,2)*clhs126 + clhs246; +lhs(4,15)=DN(3,0)*clhs222 - DN(3,0)*clhs223 - clhs247 + clhs248*clhs41; +lhs(5,0)=DN(1,0)*clhs2 + DN(1,1)*clhs130 + DN(1,2)*clhs131 + clhs63; +lhs(5,1)=DN(1,0)*clhs29 + DN(1,1)*clhs132 + DN(1,2)*clhs134 + clhs148 + clhs249; +lhs(5,2)=DN(1,0)*clhs37 + DN(1,1)*clhs136 + DN(1,2)*clhs138 + clhs194; +lhs(5,3)=DN(0,1)*clhs222 - DN(0,1)*clhs223 + clhs154*clhs41 - clhs155; +lhs(5,4)=DN(1,0)*clhs45 + DN(1,1)*clhs141 + DN(1,2)*clhs142 + clhs230; +lhs(5,5)=DN(1,0)*clhs59 + DN(1,1)*clhs144 + DN(1,2)*clhs146 + clhs10*clhs250 + clhs228; +lhs(5,6)=DN(1,0)*clhs66 + DN(1,1)*clhs150 + DN(1,2)*clhs152 + clhs252; +lhs(5,7)=DN(1,1)*clhs232; +lhs(5,8)=DN(1,0)*clhs74 + DN(1,1)*clhs156 + DN(1,2)*clhs157 + clhs253; +lhs(5,9)=DN(1,0)*clhs88 + DN(1,1)*clhs159 + DN(1,2)*clhs161 + clhs255 + clhs256; +lhs(5,10)=DN(1,0)*clhs95 + DN(1,1)*clhs165 + DN(1,2)*clhs167 + clhs257; +lhs(5,11)=DN(2,1)*clhs222 - DN(2,1)*clhs223 - clhs258 + clhs259*clhs41; +lhs(5,12)=DN(1,0)*clhs103 + DN(1,1)*clhs171 + DN(1,2)*clhs172 + clhs260; +lhs(5,13)=DN(1,0)*clhs117 + DN(1,1)*clhs174 + DN(1,2)*clhs176 + clhs262 + clhs263; +lhs(5,14)=DN(1,0)*clhs124 + DN(1,1)*clhs180 + DN(1,2)*clhs182 + clhs264; +lhs(5,15)=DN(3,1)*clhs222 - DN(3,1)*clhs223 - clhs265 + clhs266*clhs41; +lhs(6,0)=DN(1,0)*clhs4 + DN(1,1)*clhs131 + DN(1,2)*clhs186 + clhs69; +lhs(6,1)=DN(1,0)*clhs32 + DN(1,1)*clhs134 + DN(1,2)*clhs187 + clhs153; +lhs(6,2)=DN(1,0)*clhs39 + DN(1,1)*clhs138 + DN(1,2)*clhs188 + clhs197 + clhs249; +lhs(6,3)=DN(0,2)*clhs222 - DN(0,2)*clhs223 + clhs198*clhs41 - clhs199; +lhs(6,4)=DN(1,0)*clhs47 + DN(1,1)*clhs142 + DN(1,2)*clhs190 + clhs231; +lhs(6,5)=DN(1,0)*clhs62 + DN(1,1)*clhs146 + DN(1,2)*clhs193 + clhs252; +lhs(6,6)=DN(1,0)*clhs68 + DN(1,1)*clhs152 + DN(1,2)*clhs195 + clhs10*clhs267 + clhs228; +lhs(6,7)=DN(1,2)*clhs232; +lhs(6,8)=DN(1,0)*clhs76 + DN(1,1)*clhs157 + DN(1,2)*clhs200 + clhs269; +lhs(6,9)=DN(1,0)*clhs91 + DN(1,1)*clhs161 + DN(1,2)*clhs202 + clhs270; +lhs(6,10)=DN(1,0)*clhs97 + DN(1,1)*clhs167 + DN(1,2)*clhs204 + clhs256 + clhs272; +lhs(6,11)=DN(2,2)*clhs222 - DN(2,2)*clhs223 - clhs273 + clhs274*clhs41; +lhs(6,12)=DN(1,0)*clhs105 + DN(1,1)*clhs172 + DN(1,2)*clhs209 + clhs275; +lhs(6,13)=DN(1,0)*clhs120 + DN(1,1)*clhs176 + DN(1,2)*clhs211 + clhs276; +lhs(6,14)=DN(1,0)*clhs126 + DN(1,1)*clhs182 + DN(1,2)*clhs213 + clhs263 + clhs278; +lhs(6,15)=DN(3,2)*clhs222 - DN(3,2)*clhs223 - clhs279 + clhs280*clhs41; +lhs(7,0)=DN(1,0)*clhs23 + clhs70; +lhs(7,1)=DN(1,1)*clhs23 + clhs154; +lhs(7,2)=DN(1,2)*clhs23 + clhs198; +lhs(7,3)=clhs219; +lhs(7,4)=DN(1,0)*clhs281; +lhs(7,5)=DN(1,1)*clhs281; +lhs(7,6)=DN(1,2)*clhs281; +lhs(7,7)=clhs22*(clhs226 + clhs250 + clhs267); +lhs(7,8)=DN(1,0)*clhs84 + clhs240; +lhs(7,9)=DN(1,1)*clhs84 + clhs259; +lhs(7,10)=DN(1,2)*clhs84 + clhs274; +lhs(7,11)=clhs282; +lhs(7,12)=DN(1,0)*clhs113 + clhs248; +lhs(7,13)=DN(1,1)*clhs113 + clhs266; +lhs(7,14)=DN(1,2)*clhs113 + clhs280; +lhs(7,15)=clhs283; +lhs(8,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + DN(2,2)*clhs4 + clhs285 + clhs79; +lhs(8,1)=DN(2,0)*clhs27 + DN(2,1)*clhs29 + DN(2,2)*clhs32 + clhs158; +lhs(8,2)=DN(2,0)*clhs35 + DN(2,1)*clhs37 + DN(2,2)*clhs39 + clhs201; +lhs(8,3)=-DN(0,0)*clhs286 + DN(0,0)*clhs287 - clhs100 + clhs41*clhs99; +lhs(8,4)=DN(2,0)*clhs43 + DN(2,1)*clhs45 + DN(2,2)*clhs47 + clhs235 + clhs288; +lhs(8,5)=DN(2,0)*clhs57 + DN(2,1)*clhs59 + DN(2,2)*clhs62 + clhs253; +lhs(8,6)=DN(2,0)*clhs64 + DN(2,1)*clhs66 + DN(2,2)*clhs68 + clhs269; +lhs(8,7)=-DN(1,0)*clhs286 + DN(1,0)*clhs287 + clhs239*clhs41 - clhs240; +lhs(8,8)=DN(2,0)*clhs72 + DN(2,1)*clhs74 + DN(2,2)*clhs76 + clhs10*clhs289 + clhs291; +lhs(8,9)=DN(2,0)*clhs86 + DN(2,1)*clhs88 + DN(2,2)*clhs91 + clhs293; +lhs(8,10)=DN(2,0)*clhs93 + DN(2,1)*clhs95 + DN(2,2)*clhs97 + clhs294; +lhs(8,11)=DN(2,0)*clhs295; +lhs(8,12)=DN(2,0)*clhs101 + DN(2,1)*clhs103 + DN(2,2)*clhs105 + clhs298 + clhs299; +lhs(8,13)=DN(2,0)*clhs115 + DN(2,1)*clhs117 + DN(2,2)*clhs120 + clhs300; +lhs(8,14)=DN(2,0)*clhs122 + DN(2,1)*clhs124 + DN(2,2)*clhs126 + clhs301; +lhs(8,15)=-DN(3,0)*clhs286 + DN(3,0)*clhs287 - clhs302 + clhs303*clhs41; +lhs(9,0)=DN(2,0)*clhs2 + DN(2,1)*clhs130 + DN(2,2)*clhs131 + clhs92; +lhs(9,1)=DN(2,0)*clhs29 + DN(2,1)*clhs132 + DN(2,2)*clhs134 + clhs163 + clhs304; +lhs(9,2)=DN(2,0)*clhs37 + DN(2,1)*clhs136 + DN(2,2)*clhs138 + clhs203; +lhs(9,3)=-DN(0,1)*clhs286 + DN(0,1)*clhs287 + clhs169*clhs41 - clhs170; +lhs(9,4)=DN(2,0)*clhs45 + DN(2,1)*clhs141 + DN(2,2)*clhs142 + clhs237; +lhs(9,5)=DN(2,0)*clhs59 + DN(2,1)*clhs144 + DN(2,2)*clhs146 + clhs255 + clhs305; +lhs(9,6)=DN(2,0)*clhs66 + DN(2,1)*clhs150 + DN(2,2)*clhs152 + clhs270; +lhs(9,7)=-DN(1,1)*clhs286 + DN(1,1)*clhs287 + clhs258*clhs41 - clhs259; +lhs(9,8)=DN(2,0)*clhs74 + DN(2,1)*clhs156 + DN(2,2)*clhs157 + clhs293; +lhs(9,9)=DN(2,0)*clhs88 + DN(2,1)*clhs159 + DN(2,2)*clhs161 + clhs10*clhs306 + clhs291; +lhs(9,10)=DN(2,0)*clhs95 + DN(2,1)*clhs165 + DN(2,2)*clhs167 + clhs308; +lhs(9,11)=DN(2,1)*clhs295; +lhs(9,12)=DN(2,0)*clhs103 + DN(2,1)*clhs171 + DN(2,2)*clhs172 + clhs309; +lhs(9,13)=DN(2,0)*clhs117 + DN(2,1)*clhs174 + DN(2,2)*clhs176 + clhs311 + clhs312; +lhs(9,14)=DN(2,0)*clhs124 + DN(2,1)*clhs180 + DN(2,2)*clhs182 + clhs313; +lhs(9,15)=-DN(3,1)*clhs286 + DN(3,1)*clhs287 - clhs314 + clhs315*clhs41; +lhs(10,0)=DN(2,0)*clhs4 + DN(2,1)*clhs131 + DN(2,2)*clhs186 + clhs98; +lhs(10,1)=DN(2,0)*clhs32 + DN(2,1)*clhs134 + DN(2,2)*clhs187 + clhs168; +lhs(10,2)=DN(2,0)*clhs39 + DN(2,1)*clhs138 + DN(2,2)*clhs188 + clhs206 + clhs304; +lhs(10,3)=-DN(0,2)*clhs286 + DN(0,2)*clhs287 + clhs207*clhs41 - clhs208; +lhs(10,4)=DN(2,0)*clhs47 + DN(2,1)*clhs142 + DN(2,2)*clhs190 + clhs238; +lhs(10,5)=DN(2,0)*clhs62 + DN(2,1)*clhs146 + DN(2,2)*clhs193 + clhs257; +lhs(10,6)=DN(2,0)*clhs68 + DN(2,1)*clhs152 + DN(2,2)*clhs195 + clhs272 + clhs305; +lhs(10,7)=-DN(1,2)*clhs286 + DN(1,2)*clhs287 + clhs273*clhs41 - clhs274; +lhs(10,8)=DN(2,0)*clhs76 + DN(2,1)*clhs157 + DN(2,2)*clhs200 + clhs294; +lhs(10,9)=DN(2,0)*clhs91 + DN(2,1)*clhs161 + DN(2,2)*clhs202 + clhs308; +lhs(10,10)=DN(2,0)*clhs97 + DN(2,1)*clhs167 + DN(2,2)*clhs204 + clhs10*clhs316 + clhs291; +lhs(10,11)=DN(2,2)*clhs295; +lhs(10,12)=DN(2,0)*clhs105 + DN(2,1)*clhs172 + DN(2,2)*clhs209 + clhs318; +lhs(10,13)=DN(2,0)*clhs120 + DN(2,1)*clhs176 + DN(2,2)*clhs211 + clhs319; +lhs(10,14)=DN(2,0)*clhs126 + DN(2,1)*clhs182 + DN(2,2)*clhs213 + clhs312 + clhs321; +lhs(10,15)=-DN(3,2)*clhs286 + DN(3,2)*clhs287 - clhs322 + clhs323*clhs41; +lhs(11,0)=DN(2,0)*clhs23 + clhs99; +lhs(11,1)=DN(2,1)*clhs23 + clhs169; +lhs(11,2)=DN(2,2)*clhs23 + clhs207; +lhs(11,3)=clhs220; +lhs(11,4)=DN(2,0)*clhs55 + clhs239; +lhs(11,5)=DN(2,1)*clhs55 + clhs258; +lhs(11,6)=DN(2,2)*clhs55 + clhs273; +lhs(11,7)=clhs282; +lhs(11,8)=DN(2,0)*clhs324; +lhs(11,9)=DN(2,1)*clhs324; +lhs(11,10)=DN(2,2)*clhs324; +lhs(11,11)=clhs22*(clhs289 + clhs306 + clhs316); +lhs(11,12)=DN(2,0)*clhs113 + clhs303; +lhs(11,13)=DN(2,1)*clhs113 + clhs315; +lhs(11,14)=DN(2,2)*clhs113 + clhs323; +lhs(11,15)=clhs325; +lhs(12,0)=DN(3,0)*clhs0 + DN(3,1)*clhs2 + DN(3,2)*clhs4 + clhs108 + clhs327; +lhs(12,1)=DN(3,0)*clhs27 + DN(3,1)*clhs29 + DN(3,2)*clhs32 + clhs173; +lhs(12,2)=DN(3,0)*clhs35 + DN(3,1)*clhs37 + DN(3,2)*clhs39 + clhs210; +lhs(12,3)=-DN(0,0)*clhs328 + DN(0,0)*clhs329 + clhs128*clhs41 - clhs129; +lhs(12,4)=DN(3,0)*clhs43 + DN(3,1)*clhs45 + DN(3,2)*clhs47 + clhs243 + clhs330; +lhs(12,5)=DN(3,0)*clhs57 + DN(3,1)*clhs59 + DN(3,2)*clhs62 + clhs260; +lhs(12,6)=DN(3,0)*clhs64 + DN(3,1)*clhs66 + DN(3,2)*clhs68 + clhs275; +lhs(12,7)=-DN(1,0)*clhs328 + DN(1,0)*clhs329 + clhs247*clhs41 - clhs248; +lhs(12,8)=DN(3,0)*clhs72 + DN(3,1)*clhs74 + DN(3,2)*clhs76 + clhs298 + clhs331; +lhs(12,9)=DN(3,0)*clhs86 + DN(3,1)*clhs88 + DN(3,2)*clhs91 + clhs309; +lhs(12,10)=DN(3,0)*clhs93 + DN(3,1)*clhs95 + DN(3,2)*clhs97 + clhs318; +lhs(12,11)=-DN(2,0)*clhs328 + DN(2,0)*clhs329 + clhs302*clhs41 - clhs303; +lhs(12,12)=DN(3,0)*clhs101 + DN(3,1)*clhs103 + DN(3,2)*clhs105 + clhs10*clhs332 + clhs334; +lhs(12,13)=DN(3,0)*clhs115 + DN(3,1)*clhs117 + DN(3,2)*clhs120 + clhs336; +lhs(12,14)=DN(3,0)*clhs122 + DN(3,1)*clhs124 + DN(3,2)*clhs126 + clhs337; +lhs(12,15)=DN(3,0)*clhs338; +lhs(13,0)=DN(3,0)*clhs2 + DN(3,1)*clhs130 + DN(3,2)*clhs131 + clhs121; +lhs(13,1)=DN(3,0)*clhs29 + DN(3,1)*clhs132 + DN(3,2)*clhs134 + clhs178 + clhs339; +lhs(13,2)=DN(3,0)*clhs37 + DN(3,1)*clhs136 + DN(3,2)*clhs138 + clhs212; +lhs(13,3)=-DN(0,1)*clhs328 + DN(0,1)*clhs329 + clhs184*clhs41 - clhs185; +lhs(13,4)=DN(3,0)*clhs45 + DN(3,1)*clhs141 + DN(3,2)*clhs142 + clhs245; +lhs(13,5)=DN(3,0)*clhs59 + DN(3,1)*clhs144 + DN(3,2)*clhs146 + clhs262 + clhs340; +lhs(13,6)=DN(3,0)*clhs66 + DN(3,1)*clhs150 + DN(3,2)*clhs152 + clhs276; +lhs(13,7)=-DN(1,1)*clhs328 + DN(1,1)*clhs329 + clhs265*clhs41 - clhs266; +lhs(13,8)=DN(3,0)*clhs74 + DN(3,1)*clhs156 + DN(3,2)*clhs157 + clhs300; +lhs(13,9)=DN(3,0)*clhs88 + DN(3,1)*clhs159 + DN(3,2)*clhs161 + clhs311 + clhs341; +lhs(13,10)=DN(3,0)*clhs95 + DN(3,1)*clhs165 + DN(3,2)*clhs167 + clhs319; +lhs(13,11)=-DN(2,1)*clhs328 + DN(2,1)*clhs329 + clhs314*clhs41 - clhs315; +lhs(13,12)=DN(3,0)*clhs103 + DN(3,1)*clhs171 + DN(3,2)*clhs172 + clhs336; +lhs(13,13)=DN(3,0)*clhs117 + DN(3,1)*clhs174 + DN(3,2)*clhs176 + clhs10*clhs342 + clhs334; +lhs(13,14)=DN(3,0)*clhs124 + DN(3,1)*clhs180 + DN(3,2)*clhs182 + clhs343; +lhs(13,15)=DN(3,1)*clhs338; +lhs(14,0)=DN(3,0)*clhs4 + DN(3,1)*clhs131 + DN(3,2)*clhs186 + clhs127; +lhs(14,1)=DN(3,0)*clhs32 + DN(3,1)*clhs134 + DN(3,2)*clhs187 + clhs183; +lhs(14,2)=DN(3,0)*clhs39 + DN(3,1)*clhs138 + DN(3,2)*clhs188 + clhs215 + clhs339; +lhs(14,3)=-DN(0,2)*clhs328 + DN(0,2)*clhs329 + clhs216*clhs41 - clhs217; +lhs(14,4)=DN(3,0)*clhs47 + DN(3,1)*clhs142 + DN(3,2)*clhs190 + clhs246; +lhs(14,5)=DN(3,0)*clhs62 + DN(3,1)*clhs146 + DN(3,2)*clhs193 + clhs264; +lhs(14,6)=DN(3,0)*clhs68 + DN(3,1)*clhs152 + DN(3,2)*clhs195 + clhs278 + clhs340; +lhs(14,7)=-DN(1,2)*clhs328 + DN(1,2)*clhs329 + clhs279*clhs41 - clhs280; +lhs(14,8)=DN(3,0)*clhs76 + DN(3,1)*clhs157 + DN(3,2)*clhs200 + clhs301; +lhs(14,9)=DN(3,0)*clhs91 + DN(3,1)*clhs161 + DN(3,2)*clhs202 + clhs313; +lhs(14,10)=DN(3,0)*clhs97 + DN(3,1)*clhs167 + DN(3,2)*clhs204 + clhs321 + clhs341; +lhs(14,11)=-DN(2,2)*clhs328 + DN(2,2)*clhs329 + clhs322*clhs41 - clhs323; +lhs(14,12)=DN(3,0)*clhs105 + DN(3,1)*clhs172 + DN(3,2)*clhs209 + clhs337; +lhs(14,13)=DN(3,0)*clhs120 + DN(3,1)*clhs176 + DN(3,2)*clhs211 + clhs343; +lhs(14,14)=DN(3,0)*clhs126 + DN(3,1)*clhs182 + DN(3,2)*clhs213 + clhs10*clhs344 + clhs334; +lhs(14,15)=DN(3,2)*clhs338; +lhs(15,0)=DN(3,0)*clhs23 + clhs128; +lhs(15,1)=DN(3,1)*clhs23 + clhs184; +lhs(15,2)=DN(3,2)*clhs23 + clhs216; +lhs(15,3)=clhs221; +lhs(15,4)=DN(3,0)*clhs55 + clhs247; +lhs(15,5)=DN(3,1)*clhs55 + clhs265; +lhs(15,6)=DN(3,2)*clhs55 + clhs279; +lhs(15,7)=clhs283; +lhs(15,8)=DN(3,0)*clhs84 + clhs302; +lhs(15,9)=DN(3,1)*clhs84 + clhs314; +lhs(15,10)=DN(3,2)*clhs84 + clhs322; +lhs(15,11)=clhs325; +lhs(15,12)=DN(3,0)*clhs345; +lhs(15,13)=DN(3,1)*clhs345; +lhs(15,14)=DN(3,2)*clhs345; +lhs(15,15)=clhs22*(clhs332 + clhs342 + clhs344); + + + // Add intermediate results to local system + noalias(rLHS) += lhs * rData.Weight; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalData<2, 3> &rData, + VectorType &rRHS) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + + const auto vfrac = rData.Velocity_Fractional; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const auto &stress = rData.ShearStress; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const auto &phi = rData.Distance; + const double previous_dt = rData.PreviousDeltaTime; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &rhs = rData.rhs; + + const double crhs0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2]; +const double crhs1 = rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)); +const double crhs2 = K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0)); +const double crhs3 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)); +const double crhs4 = N[0]*rho; +const double crhs5 = bdf0*crhs4; +const double crhs6 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs7 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs8 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs9 = crhs6 + crhs7 + crhs8; +const double crhs10 = 1.0/dt; +const double crhs11 = crhs10*crhs4; +const double crhs12 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); +const double crhs13 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); +const double crhs14 = rho*(crhs12*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs13*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))); +const double crhs15 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); +const double crhs16 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crhs17 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crhs18 = rho*(crhs15*crhs16 + crhs17*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))); +const double crhs19 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crhs20 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crhs21 = crhs19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crhs22 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); +const double crhs23 = crhs15 + crhs22 - volume_error_ratio; +const double crhs24 = rho*stab_c2*sqrt(crhs16*crhs16 + crhs17*crhs17); +const double crhs25 = crhs23*(crhs24*h*1.0/stab_c1 + mu); +const double crhs26 = bdf0*rho; +const double crhs27 = crhs26*crhs3; +const double crhs28 = crhs10*rho; +const double crhs29 = 1.0*1.0/(K_darcy + crhs24*1.0/h + crhs28*dyn_tau + mu*stab_c1*1.0/(h*h)); +const double crhs30 = crhs29*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] - crhs1 - crhs14 + crhs18 + crhs2 + crhs27 + rho*(crhs10*crhs6 + crhs10*crhs7 + crhs10*crhs8 + crhs21)); +const double crhs31 = K_darcy*N[0]; +const double crhs32 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); +const double crhs33 = crhs32*crhs4; +const double crhs34 = rho*(DN(0,0)*crhs16 + DN(0,1)*crhs17); +const double crhs35 = rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)); +const double crhs36 = K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1)); +const double crhs37 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)); +const double crhs38 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs39 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs40 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs41 = crhs38 + crhs39 + crhs40; +const double crhs42 = rho*(crhs12*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs13*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))); +const double crhs43 = rho*(crhs16*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1)) + crhs17*crhs22); +const double crhs44 = crhs19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); +const double crhs45 = crhs26*crhs37; +const double crhs46 = crhs29*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] - crhs35 + crhs36 - crhs42 + crhs43 + crhs45 + rho*(crhs10*crhs38 + crhs10*crhs39 + crhs10*crhs40 + crhs44)); +const double crhs47 = N[1]*crhs28; +const double crhs48 = N[1]*rho; +const double crhs49 = K_darcy*N[1]; +const double crhs50 = crhs32*crhs48; +const double crhs51 = rho*(DN(1,0)*crhs16 + DN(1,1)*crhs17); +const double crhs52 = N[2]*crhs28; +const double crhs53 = N[2]*rho; +const double crhs54 = K_darcy*N[2]; +const double crhs55 = crhs32*crhs53; +const double crhs56 = rho*(DN(2,0)*crhs16 + DN(2,1)*crhs17); +rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs25 - DN(0,0)*stress[0] - DN(0,1)*stress[2] + N[0]*crhs1 + N[0]*crhs14 - N[0]*crhs18 - N[0]*crhs2 - crhs11*crhs9 - crhs21*crhs4 - crhs3*crhs5 + crhs30*crhs31 - crhs30*crhs33 - crhs30*crhs34; +rhs[1]=-DN(0,0)*stress[2] + DN(0,1)*crhs0 - DN(0,1)*crhs25 - DN(0,1)*stress[1] + N[0]*crhs35 - N[0]*crhs36 + N[0]*crhs42 - N[0]*crhs43 - crhs11*crhs41 + crhs31*crhs46 - crhs33*crhs46 - crhs34*crhs46 - crhs37*crhs5 - crhs4*crhs44; +rhs[2]=-DN(0,0)*crhs30 - DN(0,1)*crhs46 - N[0]*crhs23; +rhs[3]=DN(1,0)*crhs0 - DN(1,0)*crhs25 - DN(1,0)*stress[0] - DN(1,1)*stress[2] + N[1]*crhs1 + N[1]*crhs14 - N[1]*crhs18 - N[1]*crhs2 - N[1]*crhs27 - crhs21*crhs48 + crhs30*crhs49 - crhs30*crhs50 - crhs30*crhs51 - crhs47*crhs9; +rhs[4]=-DN(1,0)*stress[2] + DN(1,1)*crhs0 - DN(1,1)*crhs25 - DN(1,1)*stress[1] + N[1]*crhs35 - N[1]*crhs36 + N[1]*crhs42 - N[1]*crhs43 - N[1]*crhs45 - crhs41*crhs47 - crhs44*crhs48 + crhs46*crhs49 - crhs46*crhs50 - crhs46*crhs51; +rhs[5]=-DN(1,0)*crhs30 - DN(1,1)*crhs46 - N[1]*crhs23; +rhs[6]=DN(2,0)*crhs0 - DN(2,0)*crhs25 - DN(2,0)*stress[0] - DN(2,1)*stress[2] + N[2]*crhs1 + N[2]*crhs14 - N[2]*crhs18 - N[2]*crhs2 - N[2]*crhs27 - crhs21*crhs53 + crhs30*crhs54 - crhs30*crhs55 - crhs30*crhs56 - crhs52*crhs9; +rhs[7]=-DN(2,0)*stress[2] + DN(2,1)*crhs0 - DN(2,1)*crhs25 - DN(2,1)*stress[1] + N[2]*crhs35 - N[2]*crhs36 + N[2]*crhs42 - N[2]*crhs43 - N[2]*crhs45 - crhs41*crhs52 - crhs44*crhs53 + crhs46*crhs54 - crhs46*crhs55 - crhs46*crhs56; +rhs[8]=-DN(2,0)*crhs30 - DN(2,1)*crhs46 - N[2]*crhs23; + + + noalias(rRHS) += rData.Weight * rhs; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalData<3, 4> &rData, + VectorType &rRHS) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + const auto vfrac = rData.Velocity_Fractional; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const auto &stress = rData.ShearStress; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const auto &phi = rData.Distance; + const double previous_dt = rData.PreviousDeltaTime; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &rhs = rData.rhs; + + const double crhs0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2] + N[3]*p[3]; +const double crhs1 = rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)); +const double crhs2 = K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0) + N[3]*v(3,0)); +const double crhs3 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)) + N[3]*(v(3,0) - vfrac(3,0)); +const double crhs4 = N[0]*rho; +const double crhs5 = bdf0*crhs4; +const double crhs6 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs7 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs8 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs9 = N[3]*(vn(3,0) - vnn(3,0)); +const double crhs10 = crhs6 + crhs7 + crhs8 + crhs9; +const double crhs11 = 1.0/dt; +const double crhs12 = crhs11*crhs4; +const double crhs13 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); +const double crhs14 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); +const double crhs15 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); +const double crhs16 = rho*(crhs13*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs14*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs15*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))); +const double crhs17 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); +const double crhs18 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crhs19 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crhs20 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crhs21 = rho*(crhs17*crhs18 + crhs19*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs20*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0))); +const double crhs22 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crhs23 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crhs24 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crhs25 = crhs22*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs23*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs24*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crhs26 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); +const double crhs27 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); +const double crhs28 = crhs17 + crhs26 + crhs27 - volume_error_ratio; +const double crhs29 = rho*stab_c2*sqrt(crhs18*crhs18 + crhs19*crhs19 + crhs20*crhs20); +const double crhs30 = crhs28*(crhs29*h*1.0/stab_c1 + mu); +const double crhs31 = bdf0*rho; +const double crhs32 = crhs3*crhs31; +const double crhs33 = crhs11*rho; +const double crhs34 = 1.0*1.0/(K_darcy + crhs29*1.0/h + crhs33*dyn_tau + mu*stab_c1*1.0/(h*h)); +const double crhs35 = crhs34*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] - crhs1 - crhs16 + crhs2 + crhs21 + crhs32 + rho*(crhs11*crhs6 + crhs11*crhs7 + crhs11*crhs8 + crhs11*crhs9 + crhs25)); +const double crhs36 = K_darcy*N[0]; +const double crhs37 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); +const double crhs38 = crhs37*crhs4; +const double crhs39 = rho*(DN(0,0)*crhs18 + DN(0,1)*crhs19 + DN(0,2)*crhs20); +const double crhs40 = rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)); +const double crhs41 = K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1) + N[3]*v(3,1)); +const double crhs42 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)) + N[3]*(v(3,1) - vfrac(3,1)); +const double crhs43 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs44 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs45 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs46 = N[3]*(vn(3,1) - vnn(3,1)); +const double crhs47 = crhs43 + crhs44 + crhs45 + crhs46; +const double crhs48 = rho*(crhs13*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs14*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs15*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))); +const double crhs49 = rho*(crhs18*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs19*crhs26 + crhs20*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1))); +const double crhs50 = crhs22*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs23*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs24*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); +const double crhs51 = crhs31*crhs42; +const double crhs52 = crhs34*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] - crhs40 + crhs41 - crhs48 + crhs49 + crhs51 + rho*(crhs11*crhs43 + crhs11*crhs44 + crhs11*crhs45 + crhs11*crhs46 + crhs50)); +const double crhs53 = rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)); +const double crhs54 = K_darcy*(N[0]*v(0,2) + N[1]*v(1,2) + N[2]*v(2,2) + N[3]*v(3,2)); +const double crhs55 = N[0]*(v(0,2) - vfrac(0,2)) + N[1]*(v(1,2) - vfrac(1,2)) + N[2]*(v(2,2) - vfrac(2,2)) + N[3]*(v(3,2) - vfrac(3,2)); +const double crhs56 = N[0]*(vn(0,2) - vnn(0,2)); +const double crhs57 = N[1]*(vn(1,2) - vnn(1,2)); +const double crhs58 = N[2]*(vn(2,2) - vnn(2,2)); +const double crhs59 = N[3]*(vn(3,2) - vnn(3,2)); +const double crhs60 = crhs56 + crhs57 + crhs58 + crhs59; +const double crhs61 = rho*(crhs13*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs14*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs15*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))); +const double crhs62 = rho*(crhs18*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs19*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs20*crhs27); +const double crhs63 = crhs22*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs23*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs24*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crhs64 = crhs31*crhs55; +const double crhs65 = crhs34*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] - crhs53 + crhs54 - crhs61 + crhs62 + crhs64 + rho*(crhs11*crhs56 + crhs11*crhs57 + crhs11*crhs58 + crhs11*crhs59 + crhs63)); +const double crhs66 = N[1]*crhs33; +const double crhs67 = N[1]*rho; +const double crhs68 = K_darcy*N[1]; +const double crhs69 = crhs37*crhs67; +const double crhs70 = rho*(DN(1,0)*crhs18 + DN(1,1)*crhs19 + DN(1,2)*crhs20); +const double crhs71 = N[2]*crhs33; +const double crhs72 = N[2]*rho; +const double crhs73 = K_darcy*N[2]; +const double crhs74 = crhs37*crhs72; +const double crhs75 = rho*(DN(2,0)*crhs18 + DN(2,1)*crhs19 + DN(2,2)*crhs20); +const double crhs76 = N[3]*crhs33; +const double crhs77 = N[3]*rho; +const double crhs78 = K_darcy*N[3]; +const double crhs79 = crhs37*crhs77; +const double crhs80 = rho*(DN(3,0)*crhs18 + DN(3,1)*crhs19 + DN(3,2)*crhs20); +rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs30 - DN(0,0)*stress[0] - DN(0,1)*stress[3] - DN(0,2)*stress[5] + N[0]*crhs1 + N[0]*crhs16 - N[0]*crhs2 - N[0]*crhs21 - crhs10*crhs12 - crhs25*crhs4 - crhs3*crhs5 + crhs35*crhs36 - crhs35*crhs38 - crhs35*crhs39; +rhs[1]=-DN(0,0)*stress[3] + DN(0,1)*crhs0 - DN(0,1)*crhs30 - DN(0,1)*stress[1] - DN(0,2)*stress[4] + N[0]*crhs40 - N[0]*crhs41 + N[0]*crhs48 - N[0]*crhs49 - crhs12*crhs47 + crhs36*crhs52 - crhs38*crhs52 - crhs39*crhs52 - crhs4*crhs50 - crhs42*crhs5; +rhs[2]=-DN(0,0)*stress[5] - DN(0,1)*stress[4] + DN(0,2)*crhs0 - DN(0,2)*crhs30 - DN(0,2)*stress[2] + N[0]*crhs53 - N[0]*crhs54 + N[0]*crhs61 - N[0]*crhs62 - crhs12*crhs60 + crhs36*crhs65 - crhs38*crhs65 - crhs39*crhs65 - crhs4*crhs63 - crhs5*crhs55; +rhs[3]=-DN(0,0)*crhs35 - DN(0,1)*crhs52 - DN(0,2)*crhs65 - N[0]*crhs28; +rhs[4]=DN(1,0)*crhs0 - DN(1,0)*crhs30 - DN(1,0)*stress[0] - DN(1,1)*stress[3] - DN(1,2)*stress[5] + N[1]*crhs1 + N[1]*crhs16 - N[1]*crhs2 - N[1]*crhs21 - N[1]*crhs32 - crhs10*crhs66 - crhs25*crhs67 + crhs35*crhs68 - crhs35*crhs69 - crhs35*crhs70; +rhs[5]=-DN(1,0)*stress[3] + DN(1,1)*crhs0 - DN(1,1)*crhs30 - DN(1,1)*stress[1] - DN(1,2)*stress[4] + N[1]*crhs40 - N[1]*crhs41 + N[1]*crhs48 - N[1]*crhs49 - N[1]*crhs51 - crhs47*crhs66 - crhs50*crhs67 + crhs52*crhs68 - crhs52*crhs69 - crhs52*crhs70; +rhs[6]=-DN(1,0)*stress[5] - DN(1,1)*stress[4] + DN(1,2)*crhs0 - DN(1,2)*crhs30 - DN(1,2)*stress[2] + N[1]*crhs53 - N[1]*crhs54 + N[1]*crhs61 - N[1]*crhs62 - N[1]*crhs64 - crhs60*crhs66 - crhs63*crhs67 + crhs65*crhs68 - crhs65*crhs69 - crhs65*crhs70; +rhs[7]=-DN(1,0)*crhs35 - DN(1,1)*crhs52 - DN(1,2)*crhs65 - N[1]*crhs28; +rhs[8]=DN(2,0)*crhs0 - DN(2,0)*crhs30 - DN(2,0)*stress[0] - DN(2,1)*stress[3] - DN(2,2)*stress[5] + N[2]*crhs1 + N[2]*crhs16 - N[2]*crhs2 - N[2]*crhs21 - N[2]*crhs32 - crhs10*crhs71 - crhs25*crhs72 + crhs35*crhs73 - crhs35*crhs74 - crhs35*crhs75; +rhs[9]=-DN(2,0)*stress[3] + DN(2,1)*crhs0 - DN(2,1)*crhs30 - DN(2,1)*stress[1] - DN(2,2)*stress[4] + N[2]*crhs40 - N[2]*crhs41 + N[2]*crhs48 - N[2]*crhs49 - N[2]*crhs51 - crhs47*crhs71 - crhs50*crhs72 + crhs52*crhs73 - crhs52*crhs74 - crhs52*crhs75; +rhs[10]=-DN(2,0)*stress[5] - DN(2,1)*stress[4] + DN(2,2)*crhs0 - DN(2,2)*crhs30 - DN(2,2)*stress[2] + N[2]*crhs53 - N[2]*crhs54 + N[2]*crhs61 - N[2]*crhs62 - N[2]*crhs64 - crhs60*crhs71 - crhs63*crhs72 + crhs65*crhs73 - crhs65*crhs74 - crhs65*crhs75; +rhs[11]=-DN(2,0)*crhs35 - DN(2,1)*crhs52 - DN(2,2)*crhs65 - N[2]*crhs28; +rhs[12]=DN(3,0)*crhs0 - DN(3,0)*crhs30 - DN(3,0)*stress[0] - DN(3,1)*stress[3] - DN(3,2)*stress[5] + N[3]*crhs1 + N[3]*crhs16 - N[3]*crhs2 - N[3]*crhs21 - N[3]*crhs32 - crhs10*crhs76 - crhs25*crhs77 + crhs35*crhs78 - crhs35*crhs79 - crhs35*crhs80; +rhs[13]=-DN(3,0)*stress[3] + DN(3,1)*crhs0 - DN(3,1)*crhs30 - DN(3,1)*stress[1] - DN(3,2)*stress[4] + N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs48 - N[3]*crhs49 - N[3]*crhs51 - crhs47*crhs76 - crhs50*crhs77 + crhs52*crhs78 - crhs52*crhs79 - crhs52*crhs80; +rhs[14]=-DN(3,0)*stress[5] - DN(3,1)*stress[4] + DN(3,2)*crhs0 - DN(3,2)*crhs30 - DN(3,2)*stress[2] + N[3]*crhs53 - N[3]*crhs54 + N[3]*crhs61 - N[3]*crhs62 - N[3]*crhs64 - crhs60*crhs76 - crhs63*crhs77 + crhs65*crhs78 - crhs65*crhs79 - crhs65*crhs80; +rhs[15]=-DN(3,0)*crhs35 - DN(3,1)*crhs52 - DN(3,2)*crhs65 - N[3]*crhs28; + + + noalias(rRHS) += rData.Weight * rhs; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointEnrichmentContributions( + TwoFluidNavierStokesFractionalData<2, 3> &rData, + MatrixType &rV, + MatrixType &rH, + MatrixType &rKee, + VectorType &rRHS_ee) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + const auto vfrac = rData.Velocity_Fractional; + + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const auto &Nenr = rData.Nenr; + const auto &DNenr = rData.DN_DXenr; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const auto &phi = rData.Distance; + const double previous_dt = rData.PreviousDeltaTime; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &V = rData.V; + auto &H = rData.H; + auto &Kee = rData.Kee; + auto &rhs_ee = rData.rhs_ee; + + array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it + + const double cV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double cV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double cV2 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1)); +const double cV3 = DNenr(0,0)*cV2; +const double cV4 = K_darcy*N[0]; +const double cV5 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double cV6 = N[0]*cV5; +const double cV7 = rho*(DN(0,0)*cV0 + DN(0,1)*cV1); +const double cV8 = DNenr(1,0)*cV2; +const double cV9 = DNenr(2,0)*cV2; +const double cV10 = DNenr(0,1)*cV2; +const double cV11 = DNenr(1,1)*cV2; +const double cV12 = DNenr(2,1)*cV2; +const double cV13 = K_darcy*N[1]; +const double cV14 = N[1]*cV5; +const double cV15 = rho*(DN(1,0)*cV0 + DN(1,1)*cV1); +const double cV16 = K_darcy*N[2]; +const double cV17 = N[2]*cV5; +const double cV18 = rho*(DN(2,0)*cV0 + DN(2,1)*cV1); +V(0,0)=-DN(0,0)*Nenr[0] - cV3*cV4 + cV3*cV6 + cV3*cV7; +V(0,1)=-DN(0,0)*Nenr[1] - cV4*cV8 + cV6*cV8 + cV7*cV8; +V(0,2)=-DN(0,0)*Nenr[2] - cV4*cV9 + cV6*cV9 + cV7*cV9; +V(1,0)=-DN(0,1)*Nenr[0] - cV10*cV4 + cV10*cV6 + cV10*cV7; +V(1,1)=-DN(0,1)*Nenr[1] - cV11*cV4 + cV11*cV6 + cV11*cV7; +V(1,2)=-DN(0,1)*Nenr[2] - cV12*cV4 + cV12*cV6 + cV12*cV7; +V(2,0)=cV2*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); +V(2,1)=cV2*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); +V(2,2)=cV2*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); +V(3,0)=-DN(1,0)*Nenr[0] - cV13*cV3 + cV14*cV3 + cV15*cV3; +V(3,1)=-DN(1,0)*Nenr[1] - cV13*cV8 + cV14*cV8 + cV15*cV8; +V(3,2)=-DN(1,0)*Nenr[2] - cV13*cV9 + cV14*cV9 + cV15*cV9; +V(4,0)=-DN(1,1)*Nenr[0] - cV10*cV13 + cV10*cV14 + cV10*cV15; +V(4,1)=-DN(1,1)*Nenr[1] - cV11*cV13 + cV11*cV14 + cV11*cV15; +V(4,2)=-DN(1,1)*Nenr[2] - cV12*cV13 + cV12*cV14 + cV12*cV15; +V(5,0)=cV2*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); +V(5,1)=cV2*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); +V(5,2)=cV2*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); +V(6,0)=-DN(2,0)*Nenr[0] - cV16*cV3 + cV17*cV3 + cV18*cV3; +V(6,1)=-DN(2,0)*Nenr[1] - cV16*cV8 + cV17*cV8 + cV18*cV8; +V(6,2)=-DN(2,0)*Nenr[2] - cV16*cV9 + cV17*cV9 + cV18*cV9; +V(7,0)=-DN(2,1)*Nenr[0] - cV10*cV16 + cV10*cV17 + cV10*cV18; +V(7,1)=-DN(2,1)*Nenr[1] - cV11*cV16 + cV11*cV17 + cV11*cV18; +V(7,2)=-DN(2,1)*Nenr[2] - cV12*cV16 + cV12*cV17 + cV12*cV18; +V(8,0)=cV2*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); +V(8,1)=cV2*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); +V(8,2)=cV2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); + + + const double cH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double cH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double cH2 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1)); +const double cH3 = cH2*(K_darcy*N[0] + rho*(DN(0,0)*cH0 + DN(0,1)*cH1 + N[0]*bdf0)); +const double cH4 = cH2*(K_darcy*N[1] + rho*(DN(1,0)*cH0 + DN(1,1)*cH1 + N[1]*bdf0)); +const double cH5 = cH2*(K_darcy*N[2] + rho*(DN(2,0)*cH0 + DN(2,1)*cH1 + N[2]*bdf0)); +H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH3; +H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH3; +H(0,2)=cH2*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); +H(0,3)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH4; +H(0,4)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH4; +H(0,5)=cH2*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); +H(0,6)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH5; +H(0,7)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH5; +H(0,8)=cH2*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); +H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH3; +H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH3; +H(1,2)=cH2*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); +H(1,3)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH4; +H(1,4)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH4; +H(1,5)=cH2*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); +H(1,6)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH5; +H(1,7)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH5; +H(1,8)=cH2*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); +H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH3; +H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH3; +H(2,2)=cH2*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); +H(2,3)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH4; +H(2,4)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH4; +H(2,5)=cH2*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); +H(2,6)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH5; +H(2,7)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH5; +H(2,8)=cH2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); + + + const double cKee0 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1), 2))*1.0/h); +const double cKee1 = cKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1)); +const double cKee2 = cKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1)); +const double cKee3 = cKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1)); +Kee(0,0)=cKee0*(DNenr(0,0)*DNenr(0,0) + DNenr(0,1)*DNenr(0,1)); +Kee(0,1)=cKee1; +Kee(0,2)=cKee2; +Kee(1,0)=cKee1; +Kee(1,1)=cKee0*(DNenr(1,0)*DNenr(1,0) + DNenr(1,1)*DNenr(1,1)); +Kee(1,2)=cKee3; +Kee(2,0)=cKee2; +Kee(2,1)=cKee3; +Kee(2,2)=cKee0*(DNenr(2,0)*DNenr(2,0) + DNenr(2,1)*DNenr(2,1)); + + + const double crhs_ee0 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); +const double crhs_ee1 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); +const double crhs_ee2 = crhs_ee0 + crhs_ee1 - volume_error_ratio; +const double crhs_ee3 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); +const double crhs_ee4 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); +const double crhs_ee5 = N[0]*bdf0; +const double crhs_ee6 = N[1]*bdf0; +const double crhs_ee7 = N[2]*bdf0; +const double crhs_ee8 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crhs_ee9 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crhs_ee10 = 1.0/dt; +const double crhs_ee11 = N[0]*crhs_ee10; +const double crhs_ee12 = N[1]*crhs_ee10; +const double crhs_ee13 = N[2]*crhs_ee10; +const double crhs_ee14 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crhs_ee15 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crhs_ee16 = 1.0*1.0/(K_darcy + crhs_ee10*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee8*crhs_ee8 + crhs_ee9*crhs_ee9)); +const double crhs_ee17 = crhs_ee16*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0)) - rho*(crhs_ee3*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs_ee4*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)) + rho*(crhs_ee0*crhs_ee8 + crhs_ee5*(v(0,0) - vfrac(0,0)) + crhs_ee6*(v(1,0) - vfrac(1,0)) + crhs_ee7*(v(2,0) - vfrac(2,0)) + crhs_ee9*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))) + rho*(crhs_ee11*(vn(0,0) - vnn(0,0)) + crhs_ee12*(vn(1,0) - vnn(1,0)) + crhs_ee13*(vn(2,0) - vnn(2,0)) + crhs_ee14*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs_ee15*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)))); +const double crhs_ee18 = crhs_ee16*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1)) - rho*(crhs_ee3*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs_ee4*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)) + rho*(crhs_ee1*crhs_ee9 + crhs_ee5*(v(0,1) - vfrac(0,1)) + crhs_ee6*(v(1,1) - vfrac(1,1)) + crhs_ee7*(v(2,1) - vfrac(2,1)) + crhs_ee8*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1))) + rho*(crhs_ee11*(vn(0,1) - vnn(0,1)) + crhs_ee12*(vn(1,1) - vnn(1,1)) + crhs_ee13*(vn(2,1) - vnn(2,1)) + crhs_ee14*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs_ee15*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)))); +rhs_ee[0]=-DNenr(0,0)*crhs_ee17 - DNenr(0,1)*crhs_ee18 - Nenr[0]*crhs_ee2; +rhs_ee[1]=-DNenr(1,0)*crhs_ee17 - DNenr(1,1)*crhs_ee18 - Nenr[1]*crhs_ee2; +rhs_ee[2]=-DNenr(2,0)*crhs_ee17 - DNenr(2,1)*crhs_ee18 - Nenr[2]*crhs_ee2; + + + noalias(rV) += rData.Weight * V; + noalias(rH) += rData.Weight * H; + noalias(rKee) += rData.Weight * Kee; + noalias(rRHS_ee) += rData.Weight * rhs_ee; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointEnrichmentContributions( + TwoFluidNavierStokesFractionalData<3, 4> &rData, + MatrixType &rV, + MatrixType &rH, + MatrixType &rKee, + VectorType &rRHS_ee) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + const auto vfrac = rData.Velocity_Fractional; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const auto &Nenr = rData.Nenr; + const auto &DNenr = rData.DN_DXenr; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const double previous_dt = rData.PreviousDeltaTime; + const auto &phi = rData.Distance; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &V = rData.V; + auto &H = rData.H; + auto &Kee = rData.Kee; + auto &rhs_ee = rData.rhs_ee; + + array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it + + const double cV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double cV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double cV2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double cV3 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1 + cV2*cV2)); +const double cV4 = DNenr(0,0)*cV3; +const double cV5 = K_darcy*N[0]; +const double cV6 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double cV7 = N[0]*cV6; +const double cV8 = rho*(DN(0,0)*cV0 + DN(0,1)*cV1 + DN(0,2)*cV2); +const double cV9 = DNenr(1,0)*cV3; +const double cV10 = DNenr(2,0)*cV3; +const double cV11 = DNenr(3,0)*cV3; +const double cV12 = DNenr(0,1)*cV3; +const double cV13 = DNenr(1,1)*cV3; +const double cV14 = DNenr(2,1)*cV3; +const double cV15 = DNenr(3,1)*cV3; +const double cV16 = DNenr(0,2)*cV3; +const double cV17 = DNenr(1,2)*cV3; +const double cV18 = DNenr(2,2)*cV3; +const double cV19 = DNenr(3,2)*cV3; +const double cV20 = K_darcy*N[1]; +const double cV21 = N[1]*cV6; +const double cV22 = rho*(DN(1,0)*cV0 + DN(1,1)*cV1 + DN(1,2)*cV2); +const double cV23 = K_darcy*N[2]; +const double cV24 = N[2]*cV6; +const double cV25 = rho*(DN(2,0)*cV0 + DN(2,1)*cV1 + DN(2,2)*cV2); +const double cV26 = K_darcy*N[3]; +const double cV27 = N[3]*cV6; +const double cV28 = rho*(DN(3,0)*cV0 + DN(3,1)*cV1 + DN(3,2)*cV2); +V(0,0)=-DN(0,0)*Nenr[0] - cV4*cV5 + cV4*cV7 + cV4*cV8; +V(0,1)=-DN(0,0)*Nenr[1] - cV5*cV9 + cV7*cV9 + cV8*cV9; +V(0,2)=-DN(0,0)*Nenr[2] - cV10*cV5 + cV10*cV7 + cV10*cV8; +V(0,3)=-DN(0,0)*Nenr[3] - cV11*cV5 + cV11*cV7 + cV11*cV8; +V(1,0)=-DN(0,1)*Nenr[0] - cV12*cV5 + cV12*cV7 + cV12*cV8; +V(1,1)=-DN(0,1)*Nenr[1] - cV13*cV5 + cV13*cV7 + cV13*cV8; +V(1,2)=-DN(0,1)*Nenr[2] - cV14*cV5 + cV14*cV7 + cV14*cV8; +V(1,3)=-DN(0,1)*Nenr[3] - cV15*cV5 + cV15*cV7 + cV15*cV8; +V(2,0)=-DN(0,2)*Nenr[0] - cV16*cV5 + cV16*cV7 + cV16*cV8; +V(2,1)=-DN(0,2)*Nenr[1] - cV17*cV5 + cV17*cV7 + cV17*cV8; +V(2,2)=-DN(0,2)*Nenr[2] - cV18*cV5 + cV18*cV7 + cV18*cV8; +V(2,3)=-DN(0,2)*Nenr[3] - cV19*cV5 + cV19*cV7 + cV19*cV8; +V(3,0)=cV3*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); +V(3,1)=cV3*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); +V(3,2)=cV3*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); +V(3,3)=cV3*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); +V(4,0)=-DN(1,0)*Nenr[0] - cV20*cV4 + cV21*cV4 + cV22*cV4; +V(4,1)=-DN(1,0)*Nenr[1] - cV20*cV9 + cV21*cV9 + cV22*cV9; +V(4,2)=-DN(1,0)*Nenr[2] - cV10*cV20 + cV10*cV21 + cV10*cV22; +V(4,3)=-DN(1,0)*Nenr[3] - cV11*cV20 + cV11*cV21 + cV11*cV22; +V(5,0)=-DN(1,1)*Nenr[0] - cV12*cV20 + cV12*cV21 + cV12*cV22; +V(5,1)=-DN(1,1)*Nenr[1] - cV13*cV20 + cV13*cV21 + cV13*cV22; +V(5,2)=-DN(1,1)*Nenr[2] - cV14*cV20 + cV14*cV21 + cV14*cV22; +V(5,3)=-DN(1,1)*Nenr[3] - cV15*cV20 + cV15*cV21 + cV15*cV22; +V(6,0)=-DN(1,2)*Nenr[0] - cV16*cV20 + cV16*cV21 + cV16*cV22; +V(6,1)=-DN(1,2)*Nenr[1] - cV17*cV20 + cV17*cV21 + cV17*cV22; +V(6,2)=-DN(1,2)*Nenr[2] - cV18*cV20 + cV18*cV21 + cV18*cV22; +V(6,3)=-DN(1,2)*Nenr[3] - cV19*cV20 + cV19*cV21 + cV19*cV22; +V(7,0)=cV3*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); +V(7,1)=cV3*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); +V(7,2)=cV3*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); +V(7,3)=cV3*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); +V(8,0)=-DN(2,0)*Nenr[0] - cV23*cV4 + cV24*cV4 + cV25*cV4; +V(8,1)=-DN(2,0)*Nenr[1] - cV23*cV9 + cV24*cV9 + cV25*cV9; +V(8,2)=-DN(2,0)*Nenr[2] - cV10*cV23 + cV10*cV24 + cV10*cV25; +V(8,3)=-DN(2,0)*Nenr[3] - cV11*cV23 + cV11*cV24 + cV11*cV25; +V(9,0)=-DN(2,1)*Nenr[0] - cV12*cV23 + cV12*cV24 + cV12*cV25; +V(9,1)=-DN(2,1)*Nenr[1] - cV13*cV23 + cV13*cV24 + cV13*cV25; +V(9,2)=-DN(2,1)*Nenr[2] - cV14*cV23 + cV14*cV24 + cV14*cV25; +V(9,3)=-DN(2,1)*Nenr[3] - cV15*cV23 + cV15*cV24 + cV15*cV25; +V(10,0)=-DN(2,2)*Nenr[0] - cV16*cV23 + cV16*cV24 + cV16*cV25; +V(10,1)=-DN(2,2)*Nenr[1] - cV17*cV23 + cV17*cV24 + cV17*cV25; +V(10,2)=-DN(2,2)*Nenr[2] - cV18*cV23 + cV18*cV24 + cV18*cV25; +V(10,3)=-DN(2,2)*Nenr[3] - cV19*cV23 + cV19*cV24 + cV19*cV25; +V(11,0)=cV3*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); +V(11,1)=cV3*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); +V(11,2)=cV3*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); +V(11,3)=cV3*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); +V(12,0)=-DN(3,0)*Nenr[0] - cV26*cV4 + cV27*cV4 + cV28*cV4; +V(12,1)=-DN(3,0)*Nenr[1] - cV26*cV9 + cV27*cV9 + cV28*cV9; +V(12,2)=-DN(3,0)*Nenr[2] - cV10*cV26 + cV10*cV27 + cV10*cV28; +V(12,3)=-DN(3,0)*Nenr[3] - cV11*cV26 + cV11*cV27 + cV11*cV28; +V(13,0)=-DN(3,1)*Nenr[0] - cV12*cV26 + cV12*cV27 + cV12*cV28; +V(13,1)=-DN(3,1)*Nenr[1] - cV13*cV26 + cV13*cV27 + cV13*cV28; +V(13,2)=-DN(3,1)*Nenr[2] - cV14*cV26 + cV14*cV27 + cV14*cV28; +V(13,3)=-DN(3,1)*Nenr[3] - cV15*cV26 + cV15*cV27 + cV15*cV28; +V(14,0)=-DN(3,2)*Nenr[0] - cV16*cV26 + cV16*cV27 + cV16*cV28; +V(14,1)=-DN(3,2)*Nenr[1] - cV17*cV26 + cV17*cV27 + cV17*cV28; +V(14,2)=-DN(3,2)*Nenr[2] - cV18*cV26 + cV18*cV27 + cV18*cV28; +V(14,3)=-DN(3,2)*Nenr[3] - cV19*cV26 + cV19*cV27 + cV19*cV28; +V(15,0)=cV3*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); +V(15,1)=cV3*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); +V(15,2)=cV3*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); +V(15,3)=cV3*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); + + + const double cH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double cH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double cH2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double cH3 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1 + cH2*cH2)); +const double cH4 = cH3*(K_darcy*N[0] + rho*(DN(0,0)*cH0 + DN(0,1)*cH1 + DN(0,2)*cH2 + N[0]*bdf0)); +const double cH5 = cH3*(K_darcy*N[1] + rho*(DN(1,0)*cH0 + DN(1,1)*cH1 + DN(1,2)*cH2 + N[1]*bdf0)); +const double cH6 = cH3*(K_darcy*N[2] + rho*(DN(2,0)*cH0 + DN(2,1)*cH1 + DN(2,2)*cH2 + N[2]*bdf0)); +const double cH7 = cH3*(K_darcy*N[3] + rho*(DN(3,0)*cH0 + DN(3,1)*cH1 + DN(3,2)*cH2 + N[3]*bdf0)); +H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH4; +H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH4; +H(0,2)=DN(0,2)*Nenr[0] + DNenr(0,2)*cH4; +H(0,3)=cH3*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); +H(0,4)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH5; +H(0,5)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH5; +H(0,6)=DN(1,2)*Nenr[0] + DNenr(0,2)*cH5; +H(0,7)=cH3*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); +H(0,8)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH6; +H(0,9)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH6; +H(0,10)=DN(2,2)*Nenr[0] + DNenr(0,2)*cH6; +H(0,11)=cH3*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); +H(0,12)=DN(3,0)*Nenr[0] + DNenr(0,0)*cH7; +H(0,13)=DN(3,1)*Nenr[0] + DNenr(0,1)*cH7; +H(0,14)=DN(3,2)*Nenr[0] + DNenr(0,2)*cH7; +H(0,15)=cH3*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); +H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH4; +H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH4; +H(1,2)=DN(0,2)*Nenr[1] + DNenr(1,2)*cH4; +H(1,3)=cH3*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); +H(1,4)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH5; +H(1,5)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH5; +H(1,6)=DN(1,2)*Nenr[1] + DNenr(1,2)*cH5; +H(1,7)=cH3*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); +H(1,8)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH6; +H(1,9)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH6; +H(1,10)=DN(2,2)*Nenr[1] + DNenr(1,2)*cH6; +H(1,11)=cH3*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); +H(1,12)=DN(3,0)*Nenr[1] + DNenr(1,0)*cH7; +H(1,13)=DN(3,1)*Nenr[1] + DNenr(1,1)*cH7; +H(1,14)=DN(3,2)*Nenr[1] + DNenr(1,2)*cH7; +H(1,15)=cH3*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); +H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH4; +H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH4; +H(2,2)=DN(0,2)*Nenr[2] + DNenr(2,2)*cH4; +H(2,3)=cH3*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); +H(2,4)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH5; +H(2,5)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH5; +H(2,6)=DN(1,2)*Nenr[2] + DNenr(2,2)*cH5; +H(2,7)=cH3*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); +H(2,8)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH6; +H(2,9)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH6; +H(2,10)=DN(2,2)*Nenr[2] + DNenr(2,2)*cH6; +H(2,11)=cH3*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); +H(2,12)=DN(3,0)*Nenr[2] + DNenr(2,0)*cH7; +H(2,13)=DN(3,1)*Nenr[2] + DNenr(2,1)*cH7; +H(2,14)=DN(3,2)*Nenr[2] + DNenr(2,2)*cH7; +H(2,15)=cH3*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); +H(3,0)=DN(0,0)*Nenr[3] + DNenr(3,0)*cH4; +H(3,1)=DN(0,1)*Nenr[3] + DNenr(3,1)*cH4; +H(3,2)=DN(0,2)*Nenr[3] + DNenr(3,2)*cH4; +H(3,3)=cH3*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); +H(3,4)=DN(1,0)*Nenr[3] + DNenr(3,0)*cH5; +H(3,5)=DN(1,1)*Nenr[3] + DNenr(3,1)*cH5; +H(3,6)=DN(1,2)*Nenr[3] + DNenr(3,2)*cH5; +H(3,7)=cH3*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); +H(3,8)=DN(2,0)*Nenr[3] + DNenr(3,0)*cH6; +H(3,9)=DN(2,1)*Nenr[3] + DNenr(3,1)*cH6; +H(3,10)=DN(2,2)*Nenr[3] + DNenr(3,2)*cH6; +H(3,11)=cH3*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); +H(3,12)=DN(3,0)*Nenr[3] + DNenr(3,0)*cH7; +H(3,13)=DN(3,1)*Nenr[3] + DNenr(3,1)*cH7; +H(3,14)=DN(3,2)*Nenr[3] + DNenr(3,2)*cH7; +H(3,15)=cH3*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); + + + const double cKee0 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1), 2) + pow(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2), 2))*1.0/h); +const double cKee1 = cKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1) + DNenr(0,2)*DNenr(1,2)); +const double cKee2 = cKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1) + DNenr(0,2)*DNenr(2,2)); +const double cKee3 = cKee0*(DNenr(0,0)*DNenr(3,0) + DNenr(0,1)*DNenr(3,1) + DNenr(0,2)*DNenr(3,2)); +const double cKee4 = cKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1) + DNenr(1,2)*DNenr(2,2)); +const double cKee5 = cKee0*(DNenr(1,0)*DNenr(3,0) + DNenr(1,1)*DNenr(3,1) + DNenr(1,2)*DNenr(3,2)); +const double cKee6 = cKee0*(DNenr(2,0)*DNenr(3,0) + DNenr(2,1)*DNenr(3,1) + DNenr(2,2)*DNenr(3,2)); +Kee(0,0)=cKee0*(DNenr(0,0)*DNenr(0,0) + DNenr(0,1)*DNenr(0,1) + DNenr(0,2)*DNenr(0,2)); +Kee(0,1)=cKee1; +Kee(0,2)=cKee2; +Kee(0,3)=cKee3; +Kee(1,0)=cKee1; +Kee(1,1)=cKee0*(DNenr(1,0)*DNenr(1,0) + DNenr(1,1)*DNenr(1,1) + DNenr(1,2)*DNenr(1,2)); +Kee(1,2)=cKee4; +Kee(1,3)=cKee5; +Kee(2,0)=cKee2; +Kee(2,1)=cKee4; +Kee(2,2)=cKee0*(DNenr(2,0)*DNenr(2,0) + DNenr(2,1)*DNenr(2,1) + DNenr(2,2)*DNenr(2,2)); +Kee(2,3)=cKee6; +Kee(3,0)=cKee3; +Kee(3,1)=cKee5; +Kee(3,2)=cKee6; +Kee(3,3)=cKee0*(DNenr(3,0)*DNenr(3,0) + DNenr(3,1)*DNenr(3,1) + DNenr(3,2)*DNenr(3,2)); + + + const double crhs_ee0 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); +const double crhs_ee1 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); +const double crhs_ee2 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); +const double crhs_ee3 = crhs_ee0 + crhs_ee1 + crhs_ee2 - volume_error_ratio; +const double crhs_ee4 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); +const double crhs_ee5 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); +const double crhs_ee6 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); +const double crhs_ee7 = N[0]*bdf0; +const double crhs_ee8 = N[1]*bdf0; +const double crhs_ee9 = N[2]*bdf0; +const double crhs_ee10 = N[3]*bdf0; +const double crhs_ee11 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crhs_ee12 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crhs_ee13 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crhs_ee14 = 1.0/dt; +const double crhs_ee15 = N[0]*crhs_ee14; +const double crhs_ee16 = N[1]*crhs_ee14; +const double crhs_ee17 = N[2]*crhs_ee14; +const double crhs_ee18 = N[3]*crhs_ee14; +const double crhs_ee19 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crhs_ee20 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crhs_ee21 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crhs_ee22 = 1.0*1.0/(K_darcy + crhs_ee14*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee11*crhs_ee11 + crhs_ee12*crhs_ee12 + crhs_ee13*crhs_ee13)); +const double crhs_ee23 = crhs_ee22*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + DNenr(3,0)*penr[3] + K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0) + N[3]*v(3,0)) - rho*(crhs_ee4*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs_ee5*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs_ee6*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)) + rho*(crhs_ee0*crhs_ee11 + crhs_ee10*(v(3,0) - vfrac(3,0)) + crhs_ee12*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs_ee13*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0)) + crhs_ee7*(v(0,0) - vfrac(0,0)) + crhs_ee8*(v(1,0) - vfrac(1,0)) + crhs_ee9*(v(2,0) - vfrac(2,0))) + rho*(crhs_ee15*(vn(0,0) - vnn(0,0)) + crhs_ee16*(vn(1,0) - vnn(1,0)) + crhs_ee17*(vn(2,0) - vnn(2,0)) + crhs_ee18*(vn(3,0) - vnn(3,0)) + crhs_ee19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs_ee20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs_ee21*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)))); +const double crhs_ee24 = crhs_ee22*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + DNenr(3,1)*penr[3] + K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1) + N[3]*v(3,1)) - rho*(crhs_ee4*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs_ee5*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs_ee6*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)) + rho*(crhs_ee1*crhs_ee12 + crhs_ee10*(v(3,1) - vfrac(3,1)) + crhs_ee11*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs_ee13*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1)) + crhs_ee7*(v(0,1) - vfrac(0,1)) + crhs_ee8*(v(1,1) - vfrac(1,1)) + crhs_ee9*(v(2,1) - vfrac(2,1))) + rho*(crhs_ee15*(vn(0,1) - vnn(0,1)) + crhs_ee16*(vn(1,1) - vnn(1,1)) + crhs_ee17*(vn(2,1) - vnn(2,1)) + crhs_ee18*(vn(3,1) - vnn(3,1)) + crhs_ee19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs_ee20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs_ee21*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)))); +const double crhs_ee25 = crhs_ee22*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] + DNenr(0,2)*penr[0] + DNenr(1,2)*penr[1] + DNenr(2,2)*penr[2] + DNenr(3,2)*penr[3] + K_darcy*(N[0]*v(0,2) + N[1]*v(1,2) + N[2]*v(2,2) + N[3]*v(3,2)) - rho*(crhs_ee4*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs_ee5*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs_ee6*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))) - rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)) + rho*(crhs_ee10*(v(3,2) - vfrac(3,2)) + crhs_ee11*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs_ee12*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs_ee13*crhs_ee2 + crhs_ee7*(v(0,2) - vfrac(0,2)) + crhs_ee8*(v(1,2) - vfrac(1,2)) + crhs_ee9*(v(2,2) - vfrac(2,2))) + rho*(crhs_ee15*(vn(0,2) - vnn(0,2)) + crhs_ee16*(vn(1,2) - vnn(1,2)) + crhs_ee17*(vn(2,2) - vnn(2,2)) + crhs_ee18*(vn(3,2) - vnn(3,2)) + crhs_ee19*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs_ee20*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs_ee21*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)))); +rhs_ee[0]=-DNenr(0,0)*crhs_ee23 - DNenr(0,1)*crhs_ee24 - DNenr(0,2)*crhs_ee25 - Nenr[0]*crhs_ee3; +rhs_ee[1]=-DNenr(1,0)*crhs_ee23 - DNenr(1,1)*crhs_ee24 - DNenr(1,2)*crhs_ee25 - Nenr[1]*crhs_ee3; +rhs_ee[2]=-DNenr(2,0)*crhs_ee23 - DNenr(2,1)*crhs_ee24 - DNenr(2,2)*crhs_ee25 - Nenr[2]*crhs_ee3; +rhs_ee[3]=-DNenr(3,0)*crhs_ee23 - DNenr(3,1)*crhs_ee24 - DNenr(3,2)*crhs_ee25 - Nenr[3]*crhs_ee3; + + + noalias(rV) += rData.Weight * V; + noalias(rH) += rData.Weight * H; + noalias(rKee) += rData.Weight * Kee; + noalias(rRHS_ee) += rData.Weight * rhs_ee; +} + +template +void TwoFluidNavierStokesFractional::ComputeSplitting( + TElementData &rData, + MatrixType &rShapeFunctionsPos, + MatrixType &rShapeFunctionsNeg, + MatrixType &rEnrichedShapeFunctionsPos, + MatrixType &rEnrichedShapeFunctionsNeg, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesNeg, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions) +{ + // Set the positive and negative enrichment interpolation matrices + // Note that the enrichment is constructed using the standard shape functions such that: + // In the negative distance region, the enrichment functions correspondig to the negative + // distance nodes are null and the positive distance nodes are equal to the standard shape + // functions. On the contrary, for the positive distance region, the enrichment functions + // corresponding to the positive distance nodes are null meanwhile the negative distance + // nodes are equal to the standard. This yields a discontinuous enrichment space. + Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); + Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); + + for (unsigned int i = 0; i < NumNodes; ++i){ + if (rData.Distance[i] > 0.0){ + enr_neg_interp(i, i) = 1.0; + } else{ + enr_pos_interp(i, i) = 1.0; + } + } + + // Call the positive side modified shape functions calculator + pModifiedShapeFunctions->ComputePositiveSideShapeFunctionsAndGradientsValues( + rShapeFunctionsPos, + rShapeDerivativesPos, + rData.w_gauss_pos_side, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + // Call the negative side modified shape functions calculator + pModifiedShapeFunctions->ComputeNegativeSideShapeFunctionsAndGradientsValues( + rShapeFunctionsNeg, + rShapeDerivativesNeg, + rData.w_gauss_neg_side, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + // Compute the enrichment shape function values using the enrichment interpolation matrices + rEnrichedShapeFunctionsPos = prod(rShapeFunctionsPos, enr_pos_interp); + rEnrichedShapeFunctionsNeg = prod(rShapeFunctionsNeg, enr_neg_interp); + + // Compute the enrichment shape function gradient values using the enrichment interpolation matrices + rEnrichedShapeDerivativesPos = rShapeDerivativesPos; + rEnrichedShapeDerivativesNeg = rShapeDerivativesNeg; + + for (unsigned int i = 0; i < rShapeDerivativesPos.size(); ++i){ + rEnrichedShapeDerivativesPos[i] = prod(enr_pos_interp, rShapeDerivativesPos[i]); + } + + for (unsigned int i = 0; i < rShapeDerivativesNeg.size(); ++i){ + rEnrichedShapeDerivativesNeg[i] = prod(enr_neg_interp, rShapeDerivativesNeg[i]); + } + + rData.NumberOfDivisions = (pModifiedShapeFunctions->pGetSplittingUtil())->mDivisionsNumber; +} + +template +void TwoFluidNavierStokesFractional::ComputeSplitInterface( + const TElementData &rData, + MatrixType& rInterfaceShapeFunctionNeg, + MatrixType& rEnrInterfaceShapeFunctionPos, + MatrixType& rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivativesNeg, + Vector& rInterfaceWeightsNeg, + std::vector>& rInterfaceNormalsNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions) +{ + Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); + Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); + + for (unsigned int i = 0; i < NumNodes; ++i){ + if (rData.Distance[i] > 0.0){ + enr_neg_interp(i, i) = 1.0; + } else{ + enr_pos_interp(i, i) = 1.0; + } + } + + // Call the Interface negative side shape functions calculator + pModifiedShapeFunctions->ComputeInterfaceNegativeSideShapeFunctionsAndGradientsValues( + rInterfaceShapeFunctionNeg, + rInterfaceShapeDerivativesNeg, + rInterfaceWeightsNeg, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + // Call the Interface negative side normal functions calculator + pModifiedShapeFunctions->ComputeNegativeSideInterfaceAreaNormals( + rInterfaceNormalsNeg, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + for (unsigned int gp = 0; gp < rInterfaceNormalsNeg.size(); ++gp){ + const double normal_norm = norm_2(rInterfaceNormalsNeg[gp]); + rInterfaceNormalsNeg[gp] /= normal_norm; + } + + // Compute the enrichment shape function values at the interface gauss points using the enrichment interpolation matrices + rEnrInterfaceShapeFunctionPos = prod(rInterfaceShapeFunctionNeg, enr_pos_interp); + rEnrInterfaceShapeFunctionNeg = prod(rInterfaceShapeFunctionNeg, enr_neg_interp); +} + +template <> +ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNavierStokesFractionalData<2, 3> >::pGetModifiedShapeFunctionsUtility( + const GeometryType::Pointer pGeometry, + const Vector& rDistances) +{ + return Kratos::make_unique(pGeometry, rDistances); +} + +template <> +ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNavierStokesFractionalData<3, 4> >::pGetModifiedShapeFunctionsUtility( + const GeometryType::Pointer pGeometry, + const Vector& rDistances) +{ + return Kratos::make_unique(pGeometry, rDistances); +} + +template +void TwoFluidNavierStokesFractional::CalculateCurvatureOnInterfaceGaussPoints( + const Matrix& rInterfaceShapeFunctions, + Vector& rInterfaceCurvature) +{ + const auto& r_geom = this->GetGeometry(); + const unsigned int n_gpt = rInterfaceShapeFunctions.size1(); + + rInterfaceCurvature.resize(n_gpt, false); + + for (unsigned int gpt = 0; gpt < n_gpt; ++gpt){ + double curvature = 0.0; + for (unsigned int i = 0; i < NumNodes; ++i){ + curvature += rInterfaceShapeFunctions(gpt,i) * r_geom[i].GetValue(CURVATURE); + } + rInterfaceCurvature[gpt] = curvature; + } +} + +template +void TwoFluidNavierStokesFractional::SurfaceTension( + const double SurfaceTensionCoefficient, + const Vector& rCurvature, + const Vector& rInterfaceWeights, + const Matrix& rInterfaceShapeFunctions, + const std::vector>& rInterfaceNormalsNeg, + VectorType& rRHS) +{ + for (unsigned int intgp = 0; intgp < rInterfaceWeights.size(); ++intgp){ + const double intgp_curv = rCurvature(intgp); + const double intgp_w = rInterfaceWeights(intgp); + const auto& intgp_normal = rInterfaceNormalsNeg[intgp]; + for (unsigned int j = 0; j < NumNodes; ++j){ + for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ + rRHS[ j*(NumNodes) + dim ] -= SurfaceTensionCoefficient*intgp_normal[dim] + *intgp_curv*intgp_w*rInterfaceShapeFunctions(intgp,j); + } + } + } +} + +template +void TwoFluidNavierStokesFractional::PressureGradientStabilization( + const TElementData& rData, + const Vector& rInterfaceWeights, + const Matrix& rEnrInterfaceShapeFunctionPos, + const Matrix& rEnrInterfaceShapeFunctionNeg, + const GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, + MatrixType& rKeeTot, + VectorType& rRHSeeTot) +{ + MatrixType kee = ZeroMatrix(NumNodes, NumNodes); + VectorType rhs_enr = ZeroVector(NumNodes); + + Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); + Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); + + double positive_density = 0.0; + double negative_density = 0.0; + double positive_viscosity = 0.0; + double negative_viscosity = 0.0; + + for (unsigned int i = 0; i < NumNodes; ++i){ + if (rData.Distance[i] > 0.0){ + enr_neg_interp(i, i) = 1.0; + positive_density = rData.NodalDensity[i]; + positive_viscosity = rData.NodalDynamicViscosity[i]; + } else{ + enr_pos_interp(i, i) = 1.0; + negative_density = rData.NodalDensity[i]; + negative_viscosity = rData.NodalDynamicViscosity[i]; + } + } + + GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesPos = rInterfaceShapeDerivatives; + GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesNeg = rInterfaceShapeDerivatives; + + for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ + EnrichedInterfaceShapeDerivativesPos[i] = prod(enr_pos_interp, rInterfaceShapeDerivatives[i]); + } + + for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ + EnrichedInterfaceShapeDerivativesNeg[i] = prod(enr_neg_interp, rInterfaceShapeDerivatives[i]); + } + + double positive_volume = 0.0; + double negative_volume = 0.0; + for (unsigned int igauss_pos = 0; igauss_pos < rData.w_gauss_pos_side.size(); ++igauss_pos){ + positive_volume += rData.w_gauss_pos_side[igauss_pos]; + } + + for (unsigned int igauss_neg = 0; igauss_neg < rData.w_gauss_neg_side.size(); ++igauss_neg){ + negative_volume += rData.w_gauss_neg_side[igauss_neg]; + } + const double element_volume = positive_volume + negative_volume; + + const auto& r_geom = this->GetGeometry(); + const double h_elem = rData.ElementSize; + + double cut_area = 0.0; + for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ + cut_area += rInterfaceWeights[gp]; + } + + const double density = 1.0/(1.0/positive_density + 1.0/negative_density); + const double viscosity = 1.0/(1.0/positive_viscosity + 1.0/negative_viscosity); + + // Stabilization parameters + const double cut_stabilization_coefficient = 1.0; + const double stab_c1 = 4.0; + const double stab_c2 = 2.0; + const double dyn_tau = rData.DynamicTau; + + const double dt = rData.DeltaTime; + + // const auto v_convection = rData.Velocity - rData.Velocity_OldStep1; + const auto v_convection = rData.Velocity - rData.MeshVelocity; + + for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ + + Vector vconv = ZeroVector(Dim); + double positive_weight = 0.0; + double negative_weight = 0.0; + + for (unsigned int j = 0; j < NumNodes; ++j){ + for (unsigned int dim = 0; dim < Dim; ++dim){ + vconv[dim] += (rEnrInterfaceShapeFunctionNeg(gp, j) + rEnrInterfaceShapeFunctionPos(gp, j)) + *v_convection(j,dim); + } + positive_weight += rEnrInterfaceShapeFunctionNeg(gp, j); + negative_weight += rEnrInterfaceShapeFunctionPos(gp, j); + } + + const double v_conv_norm = norm_2(vconv); + + const double penalty_coefficient = cut_stabilization_coefficient * + density * 1.0 / (dyn_tau * density / dt + stab_c1 * viscosity / h_elem / h_elem + + stab_c2 * density * v_conv_norm / h_elem) * element_volume / cut_area; + + const auto& r_gp_enriched_interface_shape_derivatives_pos = EnrichedInterfaceShapeDerivativesPos[gp]; + const auto& r_gp_enriched_interface_shape_derivatives_neg = EnrichedInterfaceShapeDerivativesNeg[gp]; + + for (unsigned int i = 0; i < NumNodes; ++i){ + + for (unsigned int j = 0; j < NumNodes; ++j){ + + const auto& r_pressure_gradient_j = r_geom[j].GetValue(PRESSURE_GRADIENT); + + for (unsigned int dim = 0; dim < Dim; ++dim){ + kee(i, j) += penalty_coefficient * rInterfaceWeights[gp] * + ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* + ( r_gp_enriched_interface_shape_derivatives_pos(j,dim) - r_gp_enriched_interface_shape_derivatives_neg(j,dim) ); + + rhs_enr(i) += penalty_coefficient * rInterfaceWeights[gp] * + ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* + (rEnrInterfaceShapeFunctionNeg(gp, j)/positive_weight - rEnrInterfaceShapeFunctionPos(gp, j)/negative_weight)* + r_pressure_gradient_j(dim); + } + } + } + } + + noalias(rKeeTot) += kee; + noalias(rRHSeeTot) += rhs_enr; +} + +template +void TwoFluidNavierStokesFractional::CalculateStrainRate(TElementData& rData) const +{ + FluidElement::CalculateStrainRate(rData); +} + +template +void TwoFluidNavierStokesFractional::CondenseEnrichmentWithContinuity( + const TElementData &rData, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot) +{ + const double min_area_ratio = 1e-7; + + // Compute positive side, negative side and total volumes + double positive_volume = 0.0; + double negative_volume = 0.0; + for (unsigned int igauss_pos = 0; igauss_pos < rData.w_gauss_pos_side.size(); ++igauss_pos){ + positive_volume += rData.w_gauss_pos_side[igauss_pos]; + } + + for (unsigned int igauss_neg = 0; igauss_neg < rData.w_gauss_neg_side.size(); ++igauss_neg){ + negative_volume += rData.w_gauss_neg_side[igauss_neg]; + } + const double Vol = positive_volume + negative_volume; + + //We only enrich elements which are not almost empty/full + if (positive_volume / Vol > min_area_ratio && negative_volume / Vol > min_area_ratio) { + + // Compute the maximum diagonal value in the enrichment stiffness matrix + double max_diag = 0.0; + for (unsigned int k = 0; k < NumNodes; ++k){ + if (std::abs(rKeeTot(k, k)) > max_diag){ + max_diag = std::abs(rKeeTot(k, k)); + } + } + if (max_diag == 0.0){ + max_diag = 1.0; + } + // "weakly" impose continuity + for (unsigned int i = 0; i < Dim; ++i){ + const double di = std::abs(rData.Distance[i]); + for (unsigned int j = i + 1; j < NumNodes; ++j){ + const double dj = std::abs(rData.Distance[j]); + // Check if the edge is cut, if it is, set the penalty constraint + if (rData.Distance[i] * rData.Distance[j] < 0.0){ + double sum_d = di + dj; + double Ni = dj / sum_d; + double Nj = di / sum_d; + double penalty_coeff = max_diag * 0.001; // h/BDFVector[0]; + rKeeTot(i, i) += penalty_coeff * Ni * Ni; + rKeeTot(i, j) -= penalty_coeff * Ni * Nj; + rKeeTot(j, i) -= penalty_coeff * Nj * Ni; + rKeeTot(j, j) += penalty_coeff * Nj * Nj; + } + } + } + + // Enrichment condensation (add to LHS and RHS the enrichment contributions) + double det; + MatrixType inverse_diag(NumNodes, NumNodes); + MathUtils::InvertMatrix(rKeeTot, inverse_diag, det); + + const Matrix tmp = prod(inverse_diag, rHtot); + noalias(rLeftHandSideMatrix) -= prod(rVtot, tmp); + + const Vector tmp2 = prod(inverse_diag, rRHSeeTot); + noalias(rRightHandSideVector) -= prod(rVtot, tmp2); + } +} + +template +void TwoFluidNavierStokesFractional::CondenseEnrichment( + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot) +{ + // Enrichment condensation (add to LHS and RHS the enrichment contributions) + double det; + MatrixType inverse_diag(NumNodes, NumNodes); + MathUtils::InvertMatrix(rKeeTot, inverse_diag, det); + + const Matrix tmp = prod(inverse_diag, rHtot); + noalias(rLeftHandSideMatrix) -= prod(rVtot, tmp); + + const Vector tmp2 = prod(inverse_diag, rRHSeeTot); + noalias(rRightHandSideVector) -= prod(rVtot, tmp2); +} + +template +void TwoFluidNavierStokesFractional::AddSurfaceTensionContribution( + const TElementData& rData, + MatrixType& rInterfaceShapeFunction, + MatrixType& rEnrInterfaceShapeFunctionPos, + MatrixType& rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, + Vector& rInterfaceWeights, + std::vector< array_1d >& rInterfaceNormalsNeg, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + VectorType &rRHSeeTot) +{ + // Surface tension coefficient is set in material properties + const double surface_tension_coefficient = this->GetProperties().GetValue(SURFACE_TENSION_COEFFICIENT); + + Vector gauss_pts_curvature; // curvatures calculated on interface Gauss points + + CalculateCurvatureOnInterfaceGaussPoints( + rInterfaceShapeFunction, + gauss_pts_curvature); + + SurfaceTension( + surface_tension_coefficient, + gauss_pts_curvature, + rInterfaceWeights, + rInterfaceShapeFunction, + rInterfaceNormalsNeg, + rRightHandSideVector); + + this->PressureGradientStabilization( + rData, + rInterfaceWeights, + rEnrInterfaceShapeFunctionPos, + rEnrInterfaceShapeFunctionNeg, + rInterfaceShapeDerivatives, + rKeeTot, + rRHSeeTot); + + CondenseEnrichment(rLeftHandSideMatrix, rRightHandSideVector, rHtot, rVtot, rKeeTot, rRHSeeTot); +} + +template +void TwoFluidNavierStokesFractional::save(Serializer &rSerializer) const +{ + using BaseType = FluidElement; + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType); +} + +template +void TwoFluidNavierStokesFractional::load(Serializer &rSerializer) +{ + using BaseType = FluidElement; + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType); +} + + +template +void TwoFluidNavierStokesFractional::CalculateOnIntegrationPoints( + const Variable &rVariable, + std::vector &rValues, + const ProcessInfo &rCurrentProcessInfo ) +{ + if (rVariable == DIVERGENCE){ + + const auto& rGeom = this->GetGeometry(); + const GeometryType::IntegrationPointsArrayType& IntegrationPoints = rGeom.IntegrationPoints(GeometryData::IntegrationMethod::GI_GAUSS_2); + const unsigned int num_gauss = IntegrationPoints.size(); + + if (rValues.size() != num_gauss){ + rValues.resize(num_gauss); + } + + Vector gauss_pts_jacobian_determinant = ZeroVector(num_gauss); + GeometryData::ShapeFunctionsGradientsType DN_DX; + rGeom.ShapeFunctionsIntegrationPointsGradients(DN_DX, gauss_pts_jacobian_determinant, GeometryData::IntegrationMethod::GI_GAUSS_2); + + for (unsigned int i_gauss = 0; i_gauss < num_gauss; ++i_gauss){ + + const Matrix gp_DN_DX = DN_DX[i_gauss]; + double DVi_DXi = 0.0; + + for(unsigned int nnode = 0; nnode < NumNodes; ++nnode){ + + const array_1d vel = rGeom[nnode].GetSolutionStepValue(VELOCITY); + for(unsigned int ndim = 0; ndim < Dim; ++ndim){ + DVi_DXi += gp_DN_DX(nnode, ndim) * vel[ndim]; + } + } + rValues[i_gauss] = DVi_DXi; + } + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Class template instantiation + +template class TwoFluidNavierStokesFractional>; +template class TwoFluidNavierStokesFractional>; + +} // namespace Kratos \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h new file mode 100644 index 000000000000..8b0575c16a4e --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h @@ -0,0 +1,608 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main author: Uxue Chasco Goñi +// Co-authors: Ruben Zorrilla +// + +#if !defined(KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL) +#define KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL + +// System includes + +// Project includes +#include "includes/define.h" +#include "includes/element.h" +#include "includes/variables.h" +#include "includes/serializer.h" +#include "includes/cfd_variables.h" +#include "custom_elements/fluid_element.h" +#include "custom_utilities/fluid_element_utilities.h" +#include "utilities/geometry_utilities.h" +#include "modified_shape_functions/tetrahedra_3d_4_modified_shape_functions.h" +#include "modified_shape_functions/triangle_2d_3_modified_shape_functions.h" + +namespace Kratos +{ + +/*The "TwoFluidNavierStokesFractional" element is an element based on the Variational Multiscale Stabilization technique (VMS) + * which is designed for the solution of a two fluids (air and a non-air one) problems. + * + * A distinctive feature of the element is the use of 4 LOCAL enrichment functions, which allows to model + * a discontinuity in both the pressure field and in its gradient. + * The enrichment functions are obtained by duplicating all of the degrees of freedom of the element. + * Since the enrichment is performed elementwise, a purely local static condensation step is performed, + * meaning that no extra degrees of freedom are added.. + * + * Since a jump in the pressure can be considered, the element shall be able to habdle moderate changes of the viscosity + * between the two fluids to be considered + * The main difference between this element and the generic one "TwoFluidNavierStokes" is that the Navier-Stokes momentum conservation equation is solved in two problems using a fractional splitting approach. This element refers to the second problem. + */ + +///@name Kratos Globals +///@{ + +///@} +///@name Type Definitions +///@{ + +///@} +///@name Enum's +///@{ + +///@} +///@name Functions +///@{ + +///@} +///@name Kratos Classes +///@{ + + template + class TwoFluidNavierStokesFractional : public FluidElement + { + public: + /// Counted pointer of + KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractional); + + ///@name Type Definitions + ///@{ + + typedef Node NodeType; + typedef Geometry GeometryType; + typedef Geometry::PointsArrayType NodesArrayType; + typedef Vector VectorType; + typedef Matrix MatrixType; + typedef std::size_t IndexType; + typedef std::size_t SizeType; + typedef std::vector EquationIdVectorType; + typedef std::vector::Pointer> DofsVectorType; + typedef PointerVectorSet, IndexedObject> DofsArrayType; + typedef typename FluidElement::ShapeFunctionsType ShapeFunctionsType; + typedef typename FluidElement::ShapeFunctionDerivativesType ShapeFunctionDerivativesType; + typedef typename FluidElement::ShapeFunctionDerivativesArrayType ShapeFunctionDerivativesArrayType; + constexpr static unsigned int Dim = FluidElement::Dim; + constexpr static unsigned int NumNodes = FluidElement::NumNodes; + constexpr static unsigned int BlockSize = FluidElement::BlockSize; + constexpr static unsigned int LocalSize = FluidElement::LocalSize; + constexpr static unsigned int StrainSize = (Dim - 1) * 3; + + ///@} + ///@name Life Cycle + ///@{ + + /// Default constuctor. + /** + * @param NewId Index number of the new element (optional) + */ + TwoFluidNavierStokesFractional(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 + */ + TwoFluidNavierStokesFractional(IndexType NewId, const NodesArrayType &ThisNodes); + + /// Constructor using a geometry object. + /** + * @param NewId Index of the new element + * @param pGeometry Pointer to a geometry object + */ + TwoFluidNavierStokesFractional(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 + */ + TwoFluidNavierStokesFractional(IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties); + + /// Destructor. + virtual ~TwoFluidNavierStokesFractional(); + + ///@} + ///@name Operators + ///@{ + + ///@} + ///@name Operations + ///@{ + + /// Create a new element of this type + /** + * Returns a pointer to a new TwoFluidNavierStokesFractional element, created using given input. + * @param NewId the ID of the new element + * @param ThisNodes the nodes of the new element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create(IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const override; + + /// Create a new element of this type using given geometry + /** + * Returns a pointer to a new FluidElement element, created using given input. + * @param NewId the ID of the new element + * @param pGeom a pointer to the geomerty to be used to create the element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create(IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const override; + + /// Computes the elemental LHS and RHS elemental contributions + /** + * Given a distance function, computes the time integrated Left Hand Side (LHS) + * and Right Hand Side elemental contributions for the two-fluid element. + * @param rLeftHandSideMatrix elemental stiffness matrix + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) override; + + /// Computes the elemental RHS elemental contribution + /** + * Given a distance function, computes the time integrated Right Hand Side (RHS) + * elemental contribution for the two-fluid element. + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateRightHandSide( + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) override; + + /// Auxiliar element check function + /** + * This function calls the base element check method and adds the + * current element check implementations + * @param rCurrentProcessInfo reference to the current process info + */ + int Check(const ProcessInfo &rCurrentProcessInfo) const override; + + ///@} + ///@name Inquiry + ///@{ + + ///@} + ///@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; + + ///@} + ///@name Access + ///@{ + + ///@} + ///@name Inquiry + ///@{ + + ///@} + ///@name Input and output + ///@{ + + /// Function to visualize the divergence field + + /** + * @brief Get the Value On Integration Points object (used to visualize the divergence field) + * + * @param rVariable Variable to be retrieved (implementation supports DIVERGENCE) + * @param rValues Vector for the values at the Gauss integration points + * @param rCurrentProcessInfo ProcessInfo object + */ + void CalculateOnIntegrationPoints( + const Variable &rVariable, + std::vector &rValues, + const ProcessInfo &rCurrentProcessInfo) override; + + ///@} + ///@name Friends + ///@{ + + ///@} + protected: + ///@name Protected static Member Variables + ///@{ + + ///@} + ///@name Protected member Variables + ///@{ + + ///@} + ///@name Protected Operators + ///@{ + + ///@} + ///@name Protected Operations + ///@{ + + /** + * @brief Computes time integrated LHS and RHS arrays + * This method computes both the Left Hand Side and + * Right Hand Side time integrated contributions. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + void AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) override; + + /** + * @brief Computes the time integrated LHS matrix + * This method computes the Left Hand Side time integrated contribution + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + */ + void AddTimeIntegratedLHS( + TElementData &rData, + MatrixType &rLHS) override; + + /** + * @brief Computes the time integrated RHS vector + * This method computes the Right Hand Side time integrated contribution + * @param rData Reference to the element data container + * @param rRHS Reference to the Right Hand Side matrix to be filled + */ + void AddTimeIntegratedRHS( + TElementData &rData, + VectorType &rRHS) override; + + /** + * @brief Computes the LHS Gauss pt. contribution + * This method computes the contribution to the LHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + */ + virtual void ComputeGaussPointLHSContribution( + TElementData &rData, + MatrixType &rLHS); + + /** + * @brief Computes the RHS Gaus pt. contribution + * This method computes the contribution to the RHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + virtual void ComputeGaussPointRHSContribution( + TElementData &rData, + VectorType &rRHS); + + /** + * @brief Computes the pressure enrichment contributions + * This method computes the pressure enrichment contributions for + * a Gauss pt. in both the left hand side and righ hand side of the equations. + * @param rData Reference to the element data container + * @param rV Contribution related to the pressure enrichment DOFs in the N-S standard equations + * @param rH Contribution related to the standard velocity and pressure DOFs in the enrichment equations + * @param rKee Contribution related to the pressure enrichment DOFs in the enrichment equations + * @param rRHS_ee Right Hand Side of the enrichment equations + */ + virtual void ComputeGaussPointEnrichmentContributions( + TElementData &rData, + MatrixType &rV, + MatrixType &rH, + MatrixType &rKee, + VectorType &rRHS_ee); + + /// Set up the element's data and constitutive law for the current integration point. + /** @param[in/out] rData Container for the current element's data. + * @param[in] Weight Integration point weight. + * @param[in] rN Values of nodal shape functions at the integration point. + * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. + */ + void UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const override; + + /// Set up the element's data for a cut element and constitutive law for the current integration point. + /** @param[in/out] rData Container for the current element's data. + * @param[in] Weight Integration point weight. + * @param[in] rN Values of nodal shape functions at the integration point. + * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. + * @param[in] rNenr Values of nodal enriched shape functions at the integration point. + * @param[in] rDN_DXenr Values of nodal enriched shape functions gradients at the integration point. + */ + void UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX, + const typename TElementData::MatrixRowType &rNenr, + const typename TElementData::ShapeDerivativesType &rDN_DXenr) const; + + /** + * @brief Computes the enriched LHS/RHS terms associated with the pressure stabilizations at the interface + * @param rInterfaceWeightsNeg Negative side weights for the interface-gauss-points + * @param rEnrInterfaceShapeFunctionPos Enriched shape functions at the interface-gauss-points Positive side + * @param rEnrInterfaceShapeFunctionNeg Enriched shape functions at the interface-gauss-points Negative side + * @param rInterfaceShapeDerivativesNeg Shape functions derivatives at the interface-gauss-points + * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs + * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs + */ + virtual void PressureGradientStabilization( + const TElementData &rData, + const Vector &rInterfaceWeights, + const Matrix &rEnrInterfaceShapeFunctionPos, + const Matrix &rEnrInterfaceShapeFunctionNeg, + const GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivatives, + MatrixType &rKeeTot, + VectorType &rRHSeeTot); + + /** + * @brief Calculate the strain rate + * In this function we calculate the strain rate at the mid step + * @param rData Data container with the input velocity and gradients and output strain rate vector + */ + void CalculateStrainRate(TElementData &rData) const override; + + ///@} + ///@name Protected Access + ///@{ + + ///@} + ///@name Protected Inquiry + ///@{ + + ///@} + ///@name Protected LifeCycle + ///@{ + + ///@} + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Serialization + ///@{ + + friend class Serializer; + + void save(Serializer &rSerializer) const override; + + void load(Serializer &rSerializer) override; + + ///@} + private: + ///@name Private Operations + ///@{ + + /** + * @brief Split shape functions computation auxiliar method + * This method computes the standard and enrichment shape functions for a split element + * @param rData Element data container + * @param rShapeFunctionsPos Positive side shape functions values + * @param rShapeFunctionsNeg Negative side shape functions values + * @param rEnrichedShapeFunctionsPos Positive side enrichment shape functions values + * @param rEnrichedShapeFunctionsNeg Negative side enrichment shape functions values + * @param rShapeDerivativesPos Positive side shape functions derivatives values + * @param rShapeDerivativesNeg Negative side shape functions derivatives values + * @param rEnrichedShapeDerivativesPos Positive side enrichment shape functions derivatives values + * @param rEnrichedShapeDerivativesNeg Negative side enrichment shape functions derivatives values + * @param pModifiedShapeFunctions Pointer to the element splitting utility + */ + void ComputeSplitting( + TElementData &rData, + MatrixType &rShapeFunctionsPos, + MatrixType &rShapeFunctionsNeg, + MatrixType &rEnrichedShapeFunctionsPos, + MatrixType &rEnrichedShapeFunctionsNeg, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesNeg, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions); + + /** + * @brief This method computes the standard and enrichment shape functions for the interfaces + * @param rData Element data container + * @param rInterfaceShapeFunctionNeg Negative side shape functions at the interface-gauss-points + * @param rEnrInterfaceShapeFunctionPos Enriched shape functions at the interface-gauss-points Positive side + * @param rEnrInterfaceShapeFunctionNeg Enriched shape functions at the interface-gauss-points Negative side + * @param rInterfaceShapeDerivativesNeg Negative side shape functions derivatives at the interface-gauss-points + * @param rInterfaceWeightsNeg Negative side weights for the interface-gauss-points + * @param rInterfaceNormalsNeg Negative side normal vectors for the interface-gauss-points + * @param pModifiedShapeFunctions Pointer to the element splitting utility + */ + void ComputeSplitInterface( + const TElementData &rData, + MatrixType &rInterfaceShapeFunctionNeg, + MatrixType &rEnrInterfaceShapeFunctionPos, + MatrixType &rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivativesNeg, + Vector &rInterfaceWeightsNeg, + std::vector> &rInterfaceNormalsNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions); + + /** + * @brief This function returns the ModifiedShapeFunctions object according to TDim + * @param pGeometry Pointer to the element geometry + * @param rDistances Distance at the nodes + */ + ModifiedShapeFunctions::UniquePointer pGetModifiedShapeFunctionsUtility( + const GeometryType::Pointer pGeometry, + const Vector &rDistances); + + /** + * @brief Calculates curvature at the gauss points of the interface. + * @param rInterfaceCurvature Vector containing curvature values at the gauss points + * @param rInterfaceShapeFunctions Shape functions calculated at the interface gauss points + */ + void CalculateCurvatureOnInterfaceGaussPoints( + const Matrix &rInterfaceShapeFunctions, + Vector &rInterfaceCurvature); + + /** + * @brief Computes the surface tension on the interface and implement its effect on the RHS vector + * @param SurfaceTensionCoefficient surface tension coefficient + * @param rCurvature curvature calculated at the interface gauss points + * @param rInterfaceWeights Weights associated with interface gauss points + * @param rInterfaceShapeFunctions Shape functions calculated at the interface gauss points + * @param rInterfaceNormalsNeg Normal vectors (negative side) associated with interface gauss points + * @param rRHS The effect of pressure discontinuity is implemented as an interfacial integral on the RHS + */ + void SurfaceTension( + const double SurfaceTensionCoefficient, + const Vector &rCurvature, + const Vector &rInterfaceWeights, + const Matrix &rInterfaceShapeFunctions, + const std::vector> &rInterfaceNormalsNeg, + VectorType &rRHS); + + /** + * @brief Condense the enrichment + * This method performs the static condensation of the enrichment terms, by adding + * its local contributions to both the LHS and RHS elemental matrices. + * @param rData Element data container + * @param rLeftHandSideMatrix Reference to the element Left Hand Side matrix + * @param rRightHandSideVector Reference to the element Right Hand Side vector + * @param rVTot Common N-S equations term associated to pressure enrichment DOFs + * @param rHTot Pressure enrichment contribution related to velocity and pressure DOFs + * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs + * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs + */ + void CondenseEnrichmentWithContinuity( + const TElementData &rData, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rVTot, + const MatrixType &rHTot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot); + + /** + * @brief Condense the enrichment without penalty + * This method performs the static condensation of the enrichment terms, by adding + * its local contributions to both the LHS and RHS elemental matrices. + * Pressure continuity along cut edges is not penalized in this function + * Volume ratio is not checked in this function + * @param rLeftHandSideMatrix Reference to the element Left Hand Side matrix + * @param rRightHandSideVector Reference to the element Right Hand Side vector + * @param rVTot Common N-S equations term associated to pressure enrichment DOFs + * @param rHTot Pressure enrichment contribution related to velocity and pressure DOFs + * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs + * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs + */ + void CondenseEnrichment( + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rVTot, + const MatrixType &rHTot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot); + + void AddSurfaceTensionContribution( + const TElementData &rData, + MatrixType &rInterfaceShapeFunction, + MatrixType &rEnrInterfaceShapeFunctionPos, + MatrixType &rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivatives, + Vector &rInterfaceWeights, + std::vector> &rInterfaceNormalsNeg, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + VectorType &rRHSeeTot); + + ///@} + ///@name Private Access + ///@{ + + ///@} + ///@name Private Inquiry + ///@{ + + ///@} + ///@name Un accessible methods + ///@{ + + /// Assignment operator. + TwoFluidNavierStokesFractional &operator=(TwoFluidNavierStokesFractional const &rOther); + + /// Copy constructor. + TwoFluidNavierStokesFractional(TwoFluidNavierStokesFractional const &rOther); + + ///@} + +}; // Class TwoFluidNavierStokesFractional +///@name Type Definitions +///@{ + +///@} +///@name Input and output +///@{ + +/// input stream function +template< class TElementData > +inline std::istream& operator >> (std::istream& rIStream, + TwoFluidNavierStokesFractional& rThis) +{ + return rIStream; +} + +/// output stream function +template< class TElementData > +inline std::ostream& operator <<(std::ostream& rOStream, + const TwoFluidNavierStokesFractional& rThis) +{ + rThis.PrintInfo(rOStream); + rOStream << std::endl; + rThis.PrintData(rOStream); + + return rOStream; +} +///@} + +} // namespace Kratos. + +#endif // KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp new file mode 100644 index 000000000000..e05779ee97c6 --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp @@ -0,0 +1,730 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main author: Uxue Chasco Goñi +// + +#include "vectorial_convection_fractional_element.h" + +namespace Kratos +{ + + /***********************************************************************************/ + /***********************************************************************************/ + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId) : Element(NewId) + { + } + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + { + } + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + { + } + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + { + } + + template + VectorialConvectionFractionalElement::~VectorialConvectionFractionalElement() + { + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + Element::Pointer VectorialConvectionFractionalElement::Create( + IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const + { + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + } + + /***********************************************************************************/ + + template + Element::Pointer VectorialConvectionFractionalElement::Create( + IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const + { + return Kratos::make_intrusive(NewId, pGeom, pProperties); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + { + KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); + } + + template + void VectorialConvectionFractionalElement::CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) + { + + if (rLeftHandSideMatrix.size1() != LocalSize) + rLeftHandSideMatrix.resize(LocalSize, LocalSize, false); + + if (rRightHandSideVector.size() != LocalSize) + rRightHandSideVector.resize(LocalSize, false); + + noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize); + noalias(rRightHandSideVector) = ZeroVector(LocalSize); + + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Iterate over integration points to evaluate local contribution + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + // Iterate over integration points to evaluate local contribution + for (unsigned int g = 0; g < number_of_gauss_points; ++g) + { + UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const + { + rData.UpdateGeometryValues(IntegrationPointIndex, Weight, rN, rDN_DX); + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + void VectorialConvectionFractionalElement::AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) + { + this->ComputeGaussPointLHSContribution(rData, rLHS); + this->ComputeGaussPointRHSContribution(rData, rRHS); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::CalculateGeometryData(Vector &rGaussWeights, + Matrix &rNContainer, + ShapeFunctionDerivativesArrayType &rDN_DX) const + { + const GeometryData::IntegrationMethod integration_method = this->GetIntegrationMethod(); + const GeometryType &r_geometry = this->GetGeometry(); + const unsigned int number_of_gauss_points = r_geometry.IntegrationPointsNumber(integration_method); + + Vector DetJ; + r_geometry.ShapeFunctionsIntegrationPointsGradients(rDN_DX, DetJ, integration_method); + + if (rNContainer.size1() != number_of_gauss_points || rNContainer.size2() != NumNodes) + { + rNContainer.resize(number_of_gauss_points, NumNodes, false); + } + rNContainer = r_geometry.ShapeFunctionsValues(integration_method); + + const GeometryType::IntegrationPointsArrayType &IntegrationPoints = r_geometry.IntegrationPoints(integration_method); + + if (rGaussWeights.size() != number_of_gauss_points) + { + rGaussWeights.resize(number_of_gauss_points, false); + } + + for (unsigned int g = 0; g < number_of_gauss_points; g++) + rGaussWeights[g] = DetJ[g] * IntegrationPoints[g].Weight(); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + MatrixType &rLHS) + { + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double dyn_tau = rData.DynamicTau; + const auto vfrac = rData.Velocity_Fractional; + const auto vn = rData.Velocity_OldStep1; + const auto vmesh = rData.MeshVelocity; + const auto vconv = vfrac-vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + const double clhs0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double clhs1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double clhs2 = DN(0,0)*clhs0 + DN(0,1)*clhs1; +const double clhs3 = N[0]*bdf0; +const double clhs4 = clhs2 + clhs3; +const double clhs5 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(clhs0*clhs0 + clhs1*clhs1)); +const double clhs6 = clhs5*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double clhs7 = N[0]*clhs6; +const double clhs8 = clhs2*clhs5; +const double clhs9 = N[0]*clhs2 + bdf0*(N[0]*N[0]) + clhs4*clhs7 + clhs4*clhs8; +const double clhs10 = N[1]*clhs3; +const double clhs11 = DN(1,0)*clhs0 + DN(1,1)*clhs1; +const double clhs12 = N[1]*bdf0; +const double clhs13 = clhs11 + clhs12; +const double clhs14 = N[0]*clhs11 + clhs10 + clhs13*clhs7 + clhs13*clhs8; +const double clhs15 = N[2]*clhs3; +const double clhs16 = DN(2,0)*clhs0 + DN(2,1)*clhs1; +const double clhs17 = N[2]*bdf0 + clhs16; +const double clhs18 = N[0]*clhs16 + clhs15 + clhs17*clhs7 + clhs17*clhs8; +const double clhs19 = N[1]*clhs6; +const double clhs20 = clhs11*clhs5; +const double clhs21 = N[1]*clhs2 + clhs10 + clhs19*clhs4 + clhs20*clhs4; +const double clhs22 = N[1]*clhs11 + bdf0*(N[1]*N[1]) + clhs13*clhs19 + clhs13*clhs20; +const double clhs23 = N[2]*clhs12; +const double clhs24 = N[1]*clhs16 + clhs17*clhs19 + clhs17*clhs20 + clhs23; +const double clhs25 = N[2]*clhs6; +const double clhs26 = clhs16*clhs5; +const double clhs27 = N[2]*clhs2 + clhs15 + clhs25*clhs4 + clhs26*clhs4; +const double clhs28 = N[2]*clhs11 + clhs13*clhs25 + clhs13*clhs26 + clhs23; +const double clhs29 = N[2]*clhs16 + bdf0*(N[2]*N[2]) + clhs17*clhs25 + clhs17*clhs26; +lhs(0,0)=clhs9; +lhs(0,1)=0; +lhs(0,2)=clhs14; +lhs(0,3)=0; +lhs(0,4)=clhs18; +lhs(0,5)=0; +lhs(1,0)=0; +lhs(1,1)=clhs9; +lhs(1,2)=0; +lhs(1,3)=clhs14; +lhs(1,4)=0; +lhs(1,5)=clhs18; +lhs(2,0)=clhs21; +lhs(2,1)=0; +lhs(2,2)=clhs22; +lhs(2,3)=0; +lhs(2,4)=clhs24; +lhs(2,5)=0; +lhs(3,0)=0; +lhs(3,1)=clhs21; +lhs(3,2)=0; +lhs(3,3)=clhs22; +lhs(3,4)=0; +lhs(3,5)=clhs24; +lhs(4,0)=clhs27; +lhs(4,1)=0; +lhs(4,2)=clhs28; +lhs(4,3)=0; +lhs(4,4)=clhs29; +lhs(4,5)=0; +lhs(5,0)=0; +lhs(5,1)=clhs27; +lhs(5,2)=0; +lhs(5,3)=clhs28; +lhs(5,4)=0; +lhs(5,5)=clhs29; + + // Add intermediate results to local system. + noalias(rLHS) += lhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + MatrixType &rLHS) + { + + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const auto vn = rData.Velocity_OldStep1; + const auto vfrac = rData.Velocity_Fractional; + const auto vmesh = rData.MeshVelocity; + const auto vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + + const double clhs0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double clhs1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double clhs2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double clhs3 = DN(0,0)*clhs0 + DN(0,1)*clhs1 + DN(0,2)*clhs2; +const double clhs4 = N[0]*bdf0; +const double clhs5 = clhs3 + clhs4; +const double clhs6 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(clhs0*clhs0 + clhs1*clhs1 + clhs2*clhs2)); +const double clhs7 = clhs6*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double clhs8 = N[0]*clhs7; +const double clhs9 = clhs3*clhs6; +const double clhs10 = N[0]*clhs3 + bdf0*(N[0]*N[0]) + clhs5*clhs8 + clhs5*clhs9; +const double clhs11 = N[1]*clhs4; +const double clhs12 = DN(1,0)*clhs0 + DN(1,1)*clhs1 + DN(1,2)*clhs2; +const double clhs13 = N[1]*bdf0; +const double clhs14 = clhs12 + clhs13; +const double clhs15 = N[0]*clhs12 + clhs11 + clhs14*clhs8 + clhs14*clhs9; +const double clhs16 = N[2]*clhs4; +const double clhs17 = DN(2,0)*clhs0 + DN(2,1)*clhs1 + DN(2,2)*clhs2; +const double clhs18 = N[2]*bdf0; +const double clhs19 = clhs17 + clhs18; +const double clhs20 = N[0]*clhs17 + clhs16 + clhs19*clhs8 + clhs19*clhs9; +const double clhs21 = N[3]*clhs4; +const double clhs22 = DN(3,0)*clhs0 + DN(3,1)*clhs1 + DN(3,2)*clhs2; +const double clhs23 = N[3]*bdf0 + clhs22; +const double clhs24 = N[0]*clhs22 + clhs21 + clhs23*clhs8 + clhs23*clhs9; +const double clhs25 = N[1]*clhs7; +const double clhs26 = clhs12*clhs6; +const double clhs27 = N[1]*clhs3 + clhs11 + clhs25*clhs5 + clhs26*clhs5; +const double clhs28 = N[1]*clhs12 + bdf0*(N[1]*N[1]) + clhs14*clhs25 + clhs14*clhs26; +const double clhs29 = N[2]*clhs13; +const double clhs30 = N[1]*clhs17 + clhs19*clhs25 + clhs19*clhs26 + clhs29; +const double clhs31 = N[3]*clhs13; +const double clhs32 = N[1]*clhs22 + clhs23*clhs25 + clhs23*clhs26 + clhs31; +const double clhs33 = N[2]*clhs7; +const double clhs34 = clhs17*clhs6; +const double clhs35 = N[2]*clhs3 + clhs16 + clhs33*clhs5 + clhs34*clhs5; +const double clhs36 = N[2]*clhs12 + clhs14*clhs33 + clhs14*clhs34 + clhs29; +const double clhs37 = N[2]*clhs17 + bdf0*(N[2]*N[2]) + clhs19*clhs33 + clhs19*clhs34; +const double clhs38 = N[3]*clhs18; +const double clhs39 = N[2]*clhs22 + clhs23*clhs33 + clhs23*clhs34 + clhs38; +const double clhs40 = N[3]*clhs7; +const double clhs41 = clhs22*clhs6; +const double clhs42 = N[3]*clhs3 + clhs21 + clhs40*clhs5 + clhs41*clhs5; +const double clhs43 = N[3]*clhs12 + clhs14*clhs40 + clhs14*clhs41 + clhs31; +const double clhs44 = N[3]*clhs17 + clhs19*clhs40 + clhs19*clhs41 + clhs38; +const double clhs45 = N[3]*clhs22 + bdf0*(N[3]*N[3]) + clhs23*clhs40 + clhs23*clhs41; +lhs(0,0)=clhs10; +lhs(0,1)=0; +lhs(0,2)=0; +lhs(0,3)=clhs15; +lhs(0,4)=0; +lhs(0,5)=0; +lhs(0,6)=clhs20; +lhs(0,7)=0; +lhs(0,8)=0; +lhs(0,9)=clhs24; +lhs(0,10)=0; +lhs(0,11)=0; +lhs(1,0)=0; +lhs(1,1)=clhs10; +lhs(1,2)=0; +lhs(1,3)=0; +lhs(1,4)=clhs15; +lhs(1,5)=0; +lhs(1,6)=0; +lhs(1,7)=clhs20; +lhs(1,8)=0; +lhs(1,9)=0; +lhs(1,10)=clhs24; +lhs(1,11)=0; +lhs(2,0)=0; +lhs(2,1)=0; +lhs(2,2)=clhs10; +lhs(2,3)=0; +lhs(2,4)=0; +lhs(2,5)=clhs15; +lhs(2,6)=0; +lhs(2,7)=0; +lhs(2,8)=clhs20; +lhs(2,9)=0; +lhs(2,10)=0; +lhs(2,11)=clhs24; +lhs(3,0)=clhs27; +lhs(3,1)=0; +lhs(3,2)=0; +lhs(3,3)=clhs28; +lhs(3,4)=0; +lhs(3,5)=0; +lhs(3,6)=clhs30; +lhs(3,7)=0; +lhs(3,8)=0; +lhs(3,9)=clhs32; +lhs(3,10)=0; +lhs(3,11)=0; +lhs(4,0)=0; +lhs(4,1)=clhs27; +lhs(4,2)=0; +lhs(4,3)=0; +lhs(4,4)=clhs28; +lhs(4,5)=0; +lhs(4,6)=0; +lhs(4,7)=clhs30; +lhs(4,8)=0; +lhs(4,9)=0; +lhs(4,10)=clhs32; +lhs(4,11)=0; +lhs(5,0)=0; +lhs(5,1)=0; +lhs(5,2)=clhs27; +lhs(5,3)=0; +lhs(5,4)=0; +lhs(5,5)=clhs28; +lhs(5,6)=0; +lhs(5,7)=0; +lhs(5,8)=clhs30; +lhs(5,9)=0; +lhs(5,10)=0; +lhs(5,11)=clhs32; +lhs(6,0)=clhs35; +lhs(6,1)=0; +lhs(6,2)=0; +lhs(6,3)=clhs36; +lhs(6,4)=0; +lhs(6,5)=0; +lhs(6,6)=clhs37; +lhs(6,7)=0; +lhs(6,8)=0; +lhs(6,9)=clhs39; +lhs(6,10)=0; +lhs(6,11)=0; +lhs(7,0)=0; +lhs(7,1)=clhs35; +lhs(7,2)=0; +lhs(7,3)=0; +lhs(7,4)=clhs36; +lhs(7,5)=0; +lhs(7,6)=0; +lhs(7,7)=clhs37; +lhs(7,8)=0; +lhs(7,9)=0; +lhs(7,10)=clhs39; +lhs(7,11)=0; +lhs(8,0)=0; +lhs(8,1)=0; +lhs(8,2)=clhs35; +lhs(8,3)=0; +lhs(8,4)=0; +lhs(8,5)=clhs36; +lhs(8,6)=0; +lhs(8,7)=0; +lhs(8,8)=clhs37; +lhs(8,9)=0; +lhs(8,10)=0; +lhs(8,11)=clhs39; +lhs(9,0)=clhs42; +lhs(9,1)=0; +lhs(9,2)=0; +lhs(9,3)=clhs43; +lhs(9,4)=0; +lhs(9,5)=0; +lhs(9,6)=clhs44; +lhs(9,7)=0; +lhs(9,8)=0; +lhs(9,9)=clhs45; +lhs(9,10)=0; +lhs(9,11)=0; +lhs(10,0)=0; +lhs(10,1)=clhs42; +lhs(10,2)=0; +lhs(10,3)=0; +lhs(10,4)=clhs43; +lhs(10,5)=0; +lhs(10,6)=0; +lhs(10,7)=clhs44; +lhs(10,8)=0; +lhs(10,9)=0; +lhs(10,10)=clhs45; +lhs(10,11)=0; +lhs(11,0)=0; +lhs(11,1)=0; +lhs(11,2)=clhs42; +lhs(11,3)=0; +lhs(11,4)=0; +lhs(11,5)=clhs43; +lhs(11,6)=0; +lhs(11,7)=0; +lhs(11,8)=clhs44; +lhs(11,9)=0; +lhs(11,10)=0; +lhs(11,11)=clhs45; + + // Add intermediate results to local system. + noalias(rLHS) += lhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + VectorType &rRHS) + { + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double bdf1 = rData.bdf1; + const double bdf2 = rData.bdf2; + + const double dyn_tau = rData.DynamicTau; + + const auto &vn = rData.Velocity_OldStep1; + + const auto &vnnn = rData.Velocity_OldStep3; + const auto &vnn = rData.Velocity_OldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &rhs = rData.rhs; + + const double crhs0 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs1 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs2 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs3 = crhs0 + crhs1 + crhs2; +const double crhs4 = 1.0/dt; +const double crhs5 = N[0]*crhs4; +const double crhs6 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)); +const double crhs7 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crhs8 = crhs7*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)); +const double crhs9 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crhs10 = crhs9*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crhs11 = crhs10 + crhs8; +const double crhs12 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crhs13 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crhs14 = crhs12*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs13*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); +const double crhs15 = -crhs0*crhs4 - crhs1*crhs4 - crhs10 + crhs14 - crhs2*crhs4 + crhs6 - crhs8; +const double crhs16 = 1.0*1.0/(crhs4*dyn_tau + stab_c2*1.0/h*sqrt(crhs12*crhs12 + crhs13*crhs13)); +const double crhs17 = crhs16*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crhs18 = N[0]*crhs17; +const double crhs19 = crhs16*(DN(0,0)*crhs12 + DN(0,1)*crhs13); +const double crhs20 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs21 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs22 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs23 = crhs20 + crhs21 + crhs22; +const double crhs24 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)); +const double crhs25 = crhs7*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)); +const double crhs26 = crhs9*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); +const double crhs27 = crhs25 + crhs26; +const double crhs28 = crhs12*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs13*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); +const double crhs29 = -crhs20*crhs4 - crhs21*crhs4 - crhs22*crhs4 + crhs24 - crhs25 - crhs26 + crhs28; +const double crhs30 = N[1]*crhs4; +const double crhs31 = N[1]*crhs17; +const double crhs32 = crhs16*(DN(1,0)*crhs12 + DN(1,1)*crhs13); +const double crhs33 = N[2]*crhs4; +const double crhs34 = N[2]*crhs17; +const double crhs35 = crhs16*(DN(2,0)*crhs12 + DN(2,1)*crhs13); +rhs[0]=N[0]*crhs11 - N[0]*crhs14 - N[0]*crhs6 - crhs15*crhs18 - crhs15*crhs19 + crhs3*crhs5; +rhs[1]=-N[0]*crhs24 + N[0]*crhs27 - N[0]*crhs28 - crhs18*crhs29 - crhs19*crhs29 + crhs23*crhs5; +rhs[2]=N[1]*crhs11 - N[1]*crhs14 - N[1]*crhs6 - crhs15*crhs31 - crhs15*crhs32 + crhs3*crhs30; +rhs[3]=-N[1]*crhs24 + N[1]*crhs27 - N[1]*crhs28 + crhs23*crhs30 - crhs29*crhs31 - crhs29*crhs32; +rhs[4]=N[2]*crhs11 - N[2]*crhs14 - N[2]*crhs6 - crhs15*crhs34 - crhs15*crhs35 + crhs3*crhs33; +rhs[5]=-N[2]*crhs24 + N[2]*crhs27 - N[2]*crhs28 + crhs23*crhs33 - crhs29*crhs34 - crhs29*crhs35; + + //Add intermediate results to local system. + noalias(rRHS) += rhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + VectorType &rRHS) + { + + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double bdf1 = rData.bdf1; + const double bdf2 = rData.bdf2; + const double dyn_tau = rData.DynamicTau; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + const auto &vnnn = rData.Velocity_OldStep3; + const auto &vmesh = rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &rhs = rData.rhs; + + const double crhs0 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs1 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs2 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs3 = N[3]*(vn(3,0) - vnn(3,0)); +const double crhs4 = crhs0 + crhs1 + crhs2 + crhs3; +const double crhs5 = 1.0/dt; +const double crhs6 = N[0]*crhs5; +const double crhs7 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)) + N[3]*(bdf0*vfrac(3,0) + bdf1*vn(3,0) + bdf2*vnn(3,0)); +const double crhs8 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crhs9 = crhs8*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)); +const double crhs10 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crhs11 = crhs10*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)); +const double crhs12 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crhs13 = crhs12*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crhs14 = crhs11 + crhs13 + crhs9; +const double crhs15 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crhs16 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crhs17 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crhs18 = crhs15*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs16*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs17*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)); +const double crhs19 = -crhs0*crhs5 - crhs1*crhs5 - crhs11 - crhs13 + crhs18 - crhs2*crhs5 - crhs3*crhs5 + crhs7 - crhs9; +const double crhs20 = 1.0*1.0/(crhs5*dyn_tau + stab_c2*1.0/h*sqrt(crhs15*crhs15 + crhs16*crhs16 + crhs17*crhs17)); +const double crhs21 = crhs20*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crhs22 = N[0]*crhs21; +const double crhs23 = crhs20*(DN(0,0)*crhs15 + DN(0,1)*crhs16 + DN(0,2)*crhs17); +const double crhs24 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs25 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs26 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs27 = N[3]*(vn(3,1) - vnn(3,1)); +const double crhs28 = crhs24 + crhs25 + crhs26 + crhs27; +const double crhs29 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)) + N[3]*(bdf0*vfrac(3,1) + bdf1*vn(3,1) + bdf2*vnn(3,1)); +const double crhs30 = crhs8*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)); +const double crhs31 = crhs10*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)); +const double crhs32 = crhs12*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); +const double crhs33 = crhs30 + crhs31 + crhs32; +const double crhs34 = crhs15*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs16*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs17*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)); +const double crhs35 = -crhs24*crhs5 - crhs25*crhs5 - crhs26*crhs5 - crhs27*crhs5 + crhs29 - crhs30 - crhs31 - crhs32 + crhs34; +const double crhs36 = N[0]*(vn(0,2) - vnn(0,2)); +const double crhs37 = N[1]*(vn(1,2) - vnn(1,2)); +const double crhs38 = N[2]*(vn(2,2) - vnn(2,2)); +const double crhs39 = N[3]*(vn(3,2) - vnn(3,2)); +const double crhs40 = crhs36 + crhs37 + crhs38 + crhs39; +const double crhs41 = N[0]*(bdf0*vfrac(0,2) + bdf1*vn(0,2) + bdf2*vnn(0,2)) + N[1]*(bdf0*vfrac(1,2) + bdf1*vn(1,2) + bdf2*vnn(1,2)) + N[2]*(bdf0*vfrac(2,2) + bdf1*vn(2,2) + bdf2*vnn(2,2)) + N[3]*(bdf0*vfrac(3,2) + bdf1*vn(3,2) + bdf2*vnn(3,2)); +const double crhs42 = crhs8*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)); +const double crhs43 = crhs10*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)); +const double crhs44 = crhs12*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crhs45 = crhs42 + crhs43 + crhs44; +const double crhs46 = crhs15*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs16*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs17*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)); +const double crhs47 = -crhs36*crhs5 - crhs37*crhs5 - crhs38*crhs5 - crhs39*crhs5 + crhs41 - crhs42 - crhs43 - crhs44 + crhs46; +const double crhs48 = N[1]*crhs5; +const double crhs49 = N[1]*crhs21; +const double crhs50 = crhs20*(DN(1,0)*crhs15 + DN(1,1)*crhs16 + DN(1,2)*crhs17); +const double crhs51 = N[2]*crhs5; +const double crhs52 = N[2]*crhs21; +const double crhs53 = crhs20*(DN(2,0)*crhs15 + DN(2,1)*crhs16 + DN(2,2)*crhs17); +const double crhs54 = N[3]*crhs5; +const double crhs55 = N[3]*crhs21; +const double crhs56 = crhs20*(DN(3,0)*crhs15 + DN(3,1)*crhs16 + DN(3,2)*crhs17); +rhs[0]=N[0]*crhs14 - N[0]*crhs18 - N[0]*crhs7 - crhs19*crhs22 - crhs19*crhs23 + crhs4*crhs6; +rhs[1]=-N[0]*crhs29 + N[0]*crhs33 - N[0]*crhs34 - crhs22*crhs35 - crhs23*crhs35 + crhs28*crhs6; +rhs[2]=-N[0]*crhs41 + N[0]*crhs45 - N[0]*crhs46 - crhs22*crhs47 - crhs23*crhs47 + crhs40*crhs6; +rhs[3]=N[1]*crhs14 - N[1]*crhs18 - N[1]*crhs7 - crhs19*crhs49 - crhs19*crhs50 + crhs4*crhs48; +rhs[4]=-N[1]*crhs29 + N[1]*crhs33 - N[1]*crhs34 + crhs28*crhs48 - crhs35*crhs49 - crhs35*crhs50; +rhs[5]=-N[1]*crhs41 + N[1]*crhs45 - N[1]*crhs46 + crhs40*crhs48 - crhs47*crhs49 - crhs47*crhs50; +rhs[6]=N[2]*crhs14 - N[2]*crhs18 - N[2]*crhs7 - crhs19*crhs52 - crhs19*crhs53 + crhs4*crhs51; +rhs[7]=-N[2]*crhs29 + N[2]*crhs33 - N[2]*crhs34 + crhs28*crhs51 - crhs35*crhs52 - crhs35*crhs53; +rhs[8]=-N[2]*crhs41 + N[2]*crhs45 - N[2]*crhs46 + crhs40*crhs51 - crhs47*crhs52 - crhs47*crhs53; +rhs[9]=N[3]*crhs14 - N[3]*crhs18 - N[3]*crhs7 - crhs19*crhs55 - crhs19*crhs56 + crhs4*crhs54; +rhs[10]=-N[3]*crhs29 + N[3]*crhs33 - N[3]*crhs34 + crhs28*crhs54 - crhs35*crhs55 - crhs35*crhs56; +rhs[11]=-N[3]*crhs41 + N[3]*crhs45 - N[3]*crhs46 + crhs40*crhs54 - crhs47*crhs55 - crhs47*crhs56; + + + // Add intermediate results to local system. + noalias(rRHS) += rhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::EquationIdVector( + EquationIdVectorType &rResult, + const ProcessInfo &rCurrentProcessInfo) const + { + const GeometryType &r_geometry = this->GetGeometry(); + + unsigned int LocalIndex = 0; + + if (rResult.size() != LocalSize) + rResult.resize(LocalSize, false); + + const unsigned int xpos = this->GetGeometry()[0].GetDofPosition(FRACTIONAL_VELOCITY_X); + + for (unsigned int i = 0; i < NumNodes; ++i) + { + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_X, xpos).EquationId(); + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Y, xpos + 1).EquationId(); + if (Dim == 3) + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Z, xpos + 2).EquationId(); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + void VectorialConvectionFractionalElement::GetDofList( + DofsVectorType &rElementalDofList, + const ProcessInfo &rCurrentProcessInfo) const + { + const GeometryType &r_geometry = this->GetGeometry(); + + if (rElementalDofList.size() != LocalSize) + rElementalDofList.resize(LocalSize); + + const unsigned int xpos = this->GetGeometry()[0].GetDofPosition(FRACTIONAL_VELOCITY_X); + + unsigned int LocalIndex = 0; + for (unsigned int i = 0; i < NumNodes; ++i) + { + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_X, xpos); + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Y, xpos + 1); + if (Dim == 3) + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Z, xpos + 2); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + + /***********************************************************************************/ + /***********************************************************************************/ + template class VectorialConvectionFractionalElement>; + template class VectorialConvectionFractionalElement>; + + /***********************************************************************************/ + /***********************************************************************************/ +} \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h new file mode 100644 index 000000000000..494e2d572b93 --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h @@ -0,0 +1,318 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Uxue Chasco Goñi +// +// +// + + +#if !defined(KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT) +#define KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT + +// System includes + +// External includes + +// Project includes +#include "includes/define.h" +#include "includes/element.h" +#include "includes/ublas_interface.h" +#include "includes/variables.h" +#include "includes/serializer.h" +#include "includes/cfd_variables.h" +#include "includes/convection_diffusion_settings.h" +#include "utilities/geometry_utilities.h" +#include "custom_elements/data_containers/fluid_element_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" +#include "fluid_dynamics_application_variables.h" + +namespace Kratos +{ +/* + The "VectorialConvectionFractionalElement" solves the convection problem of a vector field, specifically the fractional velocity, and convects this field using its own velocity. + This element is part of the two-fluid Navier-Stokes fractional element TwoFluidNavierStokesFractional. + The Navier-Stokes momentum conservation equation is split into two problems: the first one convects the fractional velocity (using this element), and the second one resolves the remaining terms of the Navier-Stokes momentum conservation. + Combining both problems in the continuous framework results in the original Navier-Stokes momentum equation + */ + +///@name Kratos Globals +///@{ +///@} +///@name Type Definitions +///@{ +///@} +///@name Enum's +///@{ +///@} +///@name Functions +///@{ +///@} +///@name Kratos Classes +///@{ + namespace Internals + { + template + class FluidElementTimeIntegrationDetail; +} +template +class VectorialConvectionFractionalElement: public Element +{ +public: + ///@name Type Definitions + ///@{ + + /// Counted pointer of + KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(VectorialConvectionFractionalElement); + + using ElementData = TElementData; + typedef GeometryType::ShapeFunctionsGradientsType ShapeFunctionDerivativesArrayType; + static constexpr unsigned int Dim = TElementData::Dim; + + static constexpr unsigned int NumNodes = TElementData::NumNodes; + + static constexpr unsigned int BlockSize = Dim; + + static constexpr unsigned int LocalSize = NumNodes * BlockSize; + + ///@} + ///@name Life Cycle + ///@{ + + /// Default constuctor. + /** + * @param NewId Index number of the new element (optional) + */ + VectorialConvectionFractionalElement(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 + */ + VectorialConvectionFractionalElement(IndexType NewId, const NodesArrayType &ThisNodes); + + /// Constructor using a geometry object. + /** + * @param NewId Index of the new element + * @param pGeometry Pointer to a geometry object + */ + VectorialConvectionFractionalElement(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 + */ + VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties); + + /// Destructor. + virtual ~VectorialConvectionFractionalElement(); + + ///@} + ///@name Operators + ///@{ + + + ///@} + ///@name Operations + ///@{ + + Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override; + Element::Pointer Create(IndexType NewId,GeometryType::Pointer pGeom,PropertiesType::Pointer pProperties) const override; + + void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; + virtual void ComputeGaussPointLHSContribution(TElementData &rData,MatrixType &rLHS); + virtual void ComputeGaussPointRHSContribution(TElementData &rData,VectorType &rRHS); + + void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override; + void GetDofList( + DofsVectorType &rElementalDofList, + const ProcessInfo &rCurrentProcessInfo) const override; + void CalculateRightHandSide( + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) override; + virtual void AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS); + virtual void UpdateIntegrationPointData(TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const; + virtual void CalculateGeometryData(Vector &rGaussWeights, + Matrix &rNContainer, + ShapeFunctionDerivativesArrayType &rDN_DX) const; + ///@} + ///@name Access + ///@{ + + + ///@} + ///@name Inquiry + ///@{ + + + ///@} + ///@name Input and output + ///@{ + + /// Turn back information as a string. + + std::string Info() const override + { + return "VectorialConvectionFractionalElement #"; + } + + /// Print information about this object. + + void PrintInfo(std::ostream& rOStream) const override + { + rOStream << Info() << Id(); + } + + /// Print object's data. + // virtual void PrintData(std::ostream& rOStream) const; + + + ///@} + ///@name Friends + ///@{ + + + ///@} + +protected: + ///@name Protected static Member Variables + ///@{ + + + ///@} + ///@name Protected member Variables + ///@{ + + ///@} + ///@name Protected Operators + ///@{ + + ///@} + ///@name Protected Operations + ///@{ + + + ///@} + ///@name Protected Access + ///@{ + + + ///@} + ///@name Protected Inquiry + ///@{ + + + ///@} + ///@name Protected LifeCycle + ///@{ + + + ///@} + + + + +private: + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + bool mElementTauNodal; // Flag to indicate if the stabilization tau is evaluated at each Gauss point or interpolated + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + // ASGS2D() : Element() + // { + // } + + void save(Serializer& rSerializer) const override + { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, Element); + } + + void load(Serializer& rSerializer) override + { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, Element); + } + + ///@} + + ///@name Private Operations + ///@{ + + + ///@} + ///@name Private Access + ///@{ + + + ///@} + ///@name Private Inquiry + ///@{ + + + ///@} + ///@name Un accessible methods + ///@{ + + + + + + ///@} + +}; + +///@} + +///@name Type Definitions +///@{ + + +///@} +///@name Input and output +///@{ + + +/// input stream function +/* inline std::istream& operator >> (std::istream& rIStream, + Fluid2DASGS& rThis); + */ +/// output stream function +/* inline std::ostream& operator << (std::ostream& rOStream, + const Fluid2DASGS& rThis) + { + rThis.PrintInfo(rOStream); + rOStream << std::endl; + rThis.PrintData(rOStream); + + return rOStream; + }*/ +///@} + +} // namespace Kratos. + +#endif // KRATOS_LEVELSET_CONVECTION_ELEMENT_SIMPLEX_INCLUDED defined + + diff --git a/applications/FluidDynamicsApplication/custom_python/fluid_dynamics_python_application.cpp b/applications/FluidDynamicsApplication/custom_python/fluid_dynamics_python_application.cpp index 9d5c0632d7c5..2595ebaad173 100644 --- a/applications/FluidDynamicsApplication/custom_python/fluid_dynamics_python_application.cpp +++ b/applications/FluidDynamicsApplication/custom_python/fluid_dynamics_python_application.cpp @@ -87,6 +87,9 @@ PYBIND11_MODULE(KratosFluidDynamicsApplication,m) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, CONVECTION_VELOCITY); KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, CONVECTION_SCALAR_GRADIENT); KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, AUXILIAR_VECTOR_VELOCITY); + KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, FRACTIONAL_VELOCITY); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, WATER_VOLUME_ERROR); + KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, AIR_VOLUME_ERROR); // Adjoint variables KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m, ADJOINT_FLUID_VECTOR_1 ) diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp index f61a533f43e0..3eabef9f9785 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp @@ -163,6 +163,10 @@ KratosFluidDynamicsApplication::KratosFluidDynamicsApplication(): mTwoFluidNavierStokesAlphaMethod3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), mTwoFluidNavierStokesWallCondition2D(0, Element::GeometryType::Pointer(new Line2D2(Element::GeometryType::PointsArrayType(2)))), mTwoFluidNavierStokesWallCondition3D(0, Element::GeometryType::Pointer(new Triangle3D3(Element::GeometryType::PointsArrayType(3)))), + mVectorialConvectionFractionalElement2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), + mVectorialConvectionFractionalElement3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), + mTwoFluidNavierStokesFractional2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), + mTwoFluidNavierStokesFractional3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), // Incompressbile Navier-Stokes div-stable elements mIncompressibleNavierStokesP2P1Continuous2D6N(0, Element::GeometryType::Pointer(new Triangle2D6(Element::GeometryType::PointsArrayType(6)))), mIncompressibleNavierStokesP2P1Continuous3D10N(0, Element::GeometryType::Pointer(new Tetrahedra3D10(Element::GeometryType::PointsArrayType(10)))), @@ -195,8 +199,11 @@ void KratosFluidDynamicsApplication::Register() { KRATOS_REGISTER_VARIABLE(C_DES); KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(SUBSCALE_VELOCITY); KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(COARSE_VELOCITY); - + KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(FRACTIONAL_VELOCITY); KRATOS_REGISTER_VARIABLE(VOLUME_ERROR); + KRATOS_REGISTER_VARIABLE(AIR_VOLUME_ERROR); + KRATOS_REGISTER_VARIABLE(WATER_VOLUME_ERROR); + KRATOS_REGISTER_VARIABLE(CONVECTION_SCALAR); KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(CONVECTION_VELOCITY); KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(CONVECTION_SCALAR_GRADIENT); @@ -387,6 +394,10 @@ void KratosFluidDynamicsApplication::Register() { KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokes3D4N", mTwoFluidNavierStokes3D4N); KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesAlphaMethod2D3N", mTwoFluidNavierStokesAlphaMethod2D3N); KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesAlphaMethod3D4N", mTwoFluidNavierStokesAlphaMethod3D4N); + KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractional2D3N", mTwoFluidNavierStokesFractional2D3N); + KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractional3D4N", mTwoFluidNavierStokesFractional3D4N); + KRATOS_REGISTER_ELEMENT("VectorialConvectionFractionalElement2D3N", mVectorialConvectionFractionalElement2D3N); + KRATOS_REGISTER_ELEMENT("VectorialConvectionFractionalElement3D4N", mVectorialConvectionFractionalElement3D4N); // Compressible Navier-Stokes symbolic elements KRATOS_REGISTER_ELEMENT("CompressibleNavierStokesExplicit2D3N",mCompressibleNavierStokesExplicit2D3N); diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.h b/applications/FluidDynamicsApplication/fluid_dynamics_application.h index 4c6a696d9a7a..4dab2fd2fe34 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.h +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.h @@ -80,6 +80,8 @@ #include "custom_elements/compressible_navier_stokes_explicit.h" #include "custom_elements/two_fluid_navier_stokes.h" #include "custom_elements/two_fluid_navier_stokes_alpha_method.h" +#include "custom_elements/two_fluid_navier_stokes_fractional.h" +#include "custom_elements/vectorial_convection_fractional_element.h" #include "custom_elements/data_containers/axisymmetric_navier_stokes/axisymmetric_navier_stokes_data.h" #include "custom_elements/data_containers/qs_vms/qs_vms_data.h" @@ -91,6 +93,8 @@ #include "custom_elements/data_containers/two_fluid_navier_stokes/two_fluid_navier_stokes_data.h" #include "custom_elements/data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" #include "custom_elements/data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" #include "custom_constitutive/bingham_3d_law.h" #include "custom_constitutive/euler_2d_law.h" @@ -455,6 +459,10 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) KratosFluidDynamicsApplication : pu const TwoFluidNavierStokesAlphaMethod< TwoFluidNavierStokesAlphaMethodData<3, 4> > mTwoFluidNavierStokesAlphaMethod3D4N; const TwoFluidNavierStokesWallCondition<2,2> mTwoFluidNavierStokesWallCondition2D; const TwoFluidNavierStokesWallCondition<3,3> mTwoFluidNavierStokesWallCondition3D; + const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional2D3N; + const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional3D4N; + const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement3D4N; + const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement2D3N; /// Incompressible Navier-Stokes div-stable element const IncompressibleNavierStokesP2P1Continuous<2> mIncompressibleNavierStokesP2P1Continuous2D6N; diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp b/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp index 58ca441d9753..a8903071a474 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp @@ -37,7 +37,9 @@ KRATOS_CREATE_VARIABLE(double, CONVECTION_SCALAR) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(CONVECTION_VELOCITY) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(CONVECTION_SCALAR_GRADIENT) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(AUXILIAR_VECTOR_VELOCITY) - +KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(FRACTIONAL_VELOCITY) +KRATOS_CREATE_VARIABLE(double,WATER_VOLUME_ERROR) +KRATOS_CREATE_VARIABLE(double,AIR_VOLUME_ERROR) // Darcy's flow variables KRATOS_CREATE_VARIABLE(double, RESISTANCE) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(SOLID_FRACTION_VELOCITY) diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.h b/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.h index 5445bd47abc4..66e60231c65f 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.h +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.h @@ -47,6 +47,9 @@ KRATOS_DEFINE_APPLICATION_VARIABLE( FLUID_DYNAMICS_APPLICATION, Vector, FLUID_ST KRATOS_DEFINE_APPLICATION_VARIABLE( FLUID_DYNAMICS_APPLICATION, Vector, GAPS ) KRATOS_DEFINE_APPLICATION_VARIABLE( FLUID_DYNAMICS_APPLICATION, double, DIVERGENCE) KRATOS_DEFINE_APPLICATION_VARIABLE( FLUID_DYNAMICS_APPLICATION, double, FS_PRESSURE_GRADIENT_RELAXATION_FACTOR) +KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS(FLUID_DYNAMICS_APPLICATION, FRACTIONAL_VELOCITY) +KRATOS_DEFINE_APPLICATION_VARIABLE(FLUID_DYNAMICS_APPLICATION, double,AIR_VOLUME_ERROR) +KRATOS_DEFINE_APPLICATION_VARIABLE(FLUID_DYNAMICS_APPLICATION, double, WATER_VOLUME_ERROR) // Darcy's flow variables KRATOS_DEFINE_APPLICATION_VARIABLE(FLUID_DYNAMICS_APPLICATION, double, RESISTANCE) diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py new file mode 100644 index 000000000000..0d71775c5ead --- /dev/null +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py @@ -0,0 +1,163 @@ +import sympy +from KratosMultiphysics import * +from KratosMultiphysics.sympy_fe_utilities import * + +## Settings explanation +# DIMENSION TO COMPUTE: +# This symbolic generator is valid for both 2D and 3D cases. Since the element has been programed with a dimension template in Kratos, +# it is advised to set the dim_to_compute flag as "Both". In this case the generated .cpp file will contain both 2D and 3D implementations. +# LINEARISATION SETTINGS: +# FullNR considers the convective velocity as "v-vmesh", hence v is taken into account in the derivation of the LHS and RHS. +# Picard (a.k.a. QuasiNR) considers the convective velocity as "a", thus it is considered as a constant in the derivation of the LHS and RHS. + + +## Symbolic generation settings +do_simplifications = False +dim_to_compute = "Both" # Spatial dimensions to compute. Options: "2D","3D","Both" +linearisation = "Picard" # Iteration type. Options: "Picard", "FullNR" +ASGS_stabilization = True # Consider ASGS stabilization terms +mode = "c" # Output mode to a c++ file +adding_acceleration = True # Whether to add acceleration + + +output_filename = "vectorial_convection_fractional_element.cpp" +template_filename = "vectorial_convection_fractional_element_template.cpp" + +if (dim_to_compute == "2D"): + dim_vector = [2] +elif (dim_to_compute == "3D"): + dim_vector = [3] +elif (dim_to_compute == "Both"): + dim_vector = [2,3] + +## Read the template file +templatefile = open(template_filename) +outstring = templatefile.read() + +for dim in dim_vector: + if(dim == 2): + nnodes = 3 + strain_size = 3 + else: + nnodes = 4 + strain_size = 6 + impose_partion_of_unity = False + N,DN = DefineShapeFunctions(nnodes, dim, impose_partion_of_unity) + #define enrichment shape functions + DNenr = DefineMatrix('DNenr',nnodes,dim) + Nenr = DefineVector('Nenr',nnodes) + vfrac = DefineMatrix('vfrac', nnodes, dim) + vn = DefineMatrix('vn',nnodes,dim) # Previous step velocity + vnn = DefineMatrix('vnn',nnodes,dim) # 2 previous step velocity + vmeshn = DefineMatrix('vmeshn',nnodes,dim) # Previous step mesh velocity + # vnnn = DefineMatrix('vnnn', nnodes, dim) # 3 previous step velocity. In case of using an BDF2 old acceleration + vconv = DefineMatrix('vconv',nnodes,dim) # Convective velocity defined a symbol and in the element template is it substituted for vfrac from the previous iteration. + + ## Test functions definition. + w = DefineMatrix('w',nnodes,dim) # Velocity field test function + + # Scalar symbols. + dt = sympy.Symbol('dt', positive = True) + nu = sympy.Symbol('nu', positive = True) + mu = sympy.Symbol('mu', positive = True) + tau1 = sympy.Symbol('tau1', positive = True) + tau2 = sympy.Symbol('tau2', positive = True) + h = sympy.Symbol('h', positive = True) + dyn_tau = sympy.Symbol('dyn_tau', positive = True) + stab_c1 = sympy.Symbol('stab_c1', positive = True) + stab_c2 = sympy.Symbol('stab_c2', positive = True) + bdf0 = sympy.Symbol('bdf0') + bdf1 = sympy.Symbol('bdf1') + bdf2 = sympy.Symbol('bdf2') + acceleration = (bdf0*vfrac + bdf1*vn+bdf2*vnn) # This acceleration is calculated in a differnt way of a bdf2 since it is considered in the fractional splitting. + vconv_gauss = vconv.transpose()*N + vconv_gauss_norm = 0.0 + for i in range(0, dim): + vconv_gauss_norm += vconv_gauss[i]**2 + vconv_gauss_norm = sympy.sqrt(vconv_gauss_norm) + tau1 = 1.0/((dyn_tau/dt) + (stab_c2*vconv_gauss_norm)/h) + + # Interpolate to the gauss points. + accel_gauss = acceleration.transpose()*N + vfrac_gauss = vfrac.transpose()*N + vn_gauss = vn.transpose()*N + w_gauss = w.transpose()*N + + ## Gradients computation + grad_vfrac = DN.transpose()*vfrac + grad_v_old = DN.transpose()*vn + grad_w = DN.transpose()*w + + # Convective term definition + convective_term = (vconv_gauss.transpose()*grad_vfrac) + + # Accelerated convection definitoin + # "an = dv_n/dt +v_n*grad_v_old" + if adding_acceleration: + # dv_d/dt TODO:It is posible to use a BDF2 + accel_n = (vn-vnn)/dt + accel_gauss_n = accel_n.transpose()*N + # Convective past term definition vn*gradv_n + convective_n_term = (vn_gauss.transpose()*grad_v_old) + + ## Galerkin Functional + rv_galerkin =-w_gauss.transpose()*accel_gauss -w_gauss.transpose()*convective_term.transpose() + + # Adding acceleration + if adding_acceleration: + rv_galerkin+= w_gauss.transpose()*accel_gauss_n+ w_gauss.transpose()*convective_n_term.transpose() + + # Stabilization functional terms + # Momentum conservation residual + # Note that the viscous stress term is dropped since linear elements are used + vel_residual = -accel_gauss - convective_term.transpose() + if adding_acceleration: + vel_residual+= accel_gauss_n + convective_n_term.transpose() + vel_subscale = tau1*vel_residual + + # Compute the ASGS stabilization terms using the momentum and mass conservation residuals above + rv_stab =vconv_gauss.transpose()*grad_w*vel_subscale + div_vconv = div(DN,vconv) + rv_stab += div_vconv*w_gauss.transpose()*vel_subscale + + ## Add the stabilization terms to the original residual terms + if (ASGS_stabilization): + rv = rv_galerkin + rv_stab + else: + rv = rv_galerkin + + ## Define DOFs and test function vectors + dofs = sympy.zeros(nnodes*(dim), 1) + testfunc = sympy.zeros(nnodes*(dim), 1) + + for i in range(0,nnodes): + for k in range(0,dim): + dofs[i*(dim)+k] = vfrac[i,k] + testfunc[i*(dim)+k] = w[i,k] + + ## Compute LHS and RHS + # For the RHS computation one wants the residual of the previous iteration (residual based formulation). + rhs = Compute_RHS(rv.copy(), testfunc, do_simplifications) + rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) + + # Compute LHS (RHS(residual) differenctiation w.r.t. the DOFs) + lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications) + lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode) + + ##################################################################### + ##################################################################### + + if(dim == 2): + outstring = outstring.replace("//substitute_lhs_2D", lhs_out) + outstring = outstring.replace("//substitute_rhs_2D", rhs_out) + + + elif(dim == 3): + outstring = outstring.replace("//substitute_lhs_3D", lhs_out) + outstring = outstring.replace("//substitute_rhs_3D", rhs_out) + +#We write in the file +out = open(output_filename,'w') +out.write(outstring) +out.close() + diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py new file mode 100644 index 000000000000..0efd434ac286 --- /dev/null +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py @@ -0,0 +1,331 @@ +import sympy +from KratosMultiphysics import * +from KratosMultiphysics.sympy_fe_utilities import * + +## Settings explanation +# DIMENSION TO COMPUTE: +# This symbolic generator is valid for both 2D and 3D cases. Since the element has been programed with a dimension template in Kratos, +# it is advised to set the dim_to_compute flag as "Both". In this case the generated .cpp file will contain both 2D and 3D implementations. +# LINEARISATION SETTINGS: +# FullNR considers the convective velocity as "v-vmesh", hence v is taken into account in the derivation of the LHS and RHS. +# Picard (a.k.a. QuasiNR) considers the convective velocity as "a", thus it is considered as a constant in the derivation of the LHS and RHS. +# DIVIDE BY RHO: +# If set to true, divides the mass conservation equation by rho in order to have a better conditioned matrix. Otherwise the original form is kept. + + +## Symbolic generation settings +do_simplifications = False +dim_to_compute = "Both" # Spatial dimensions to compute. Options: "2D","3D","Both" +linearisation = "Picard" # Iteration type. Options: "Picard", "FullNR" +divide_by_rho = True # Divide by density in mass conservation equation +ASGS_stabilization = True # Consider ASGS stabilization terms +mode = "c" # Output mode to a c++ file +time_integration="bdf2" # TODO: Right now the formulation is validated only for BDF2 but there is a working version for generalized alpha. +adding_acceleration=True # Add acceleration + +if time_integration == "bdf2": + output_filename = "two_fluid_navier_stokes_fractional.cpp" + template_filename = "two_fluid_navier_stokes_fractional_template.cpp" +else: + # TODO: There is a version with the generalised alpha time integration scheme but validation is requiered. + err_msg = "Wrong time_integration. Given \'" + time_integration + "\'. Available options are \'bdf2\'." + raise Exception(err_msg) + +if (dim_to_compute == "2D"): + dim_vector = [2] +elif (dim_to_compute == "3D"): + dim_vector = [3] +elif (dim_to_compute == "Both"): + dim_vector = [2,3] + +## Read the template file +templatefile = open(template_filename) +outstring = templatefile.read() + +for dim in dim_vector: + + if(dim == 2): + nnodes = 3 + strain_size = 3 + else: + nnodes = 4 + strain_size = 6 + + impose_partion_of_unity = False + N,DN = DefineShapeFunctions(nnodes, dim, impose_partion_of_unity) + + #define enrichment shape functions + DNenr = DefineMatrix('DNenr',nnodes,dim) + Nenr = DefineVector('Nenr',nnodes) + + ## Unknown fields definition + v = DefineMatrix('v',nnodes,dim) # Current step velocity (v(i,j) refers to velocity of node i component j) + vn = DefineMatrix('vn',nnodes,dim) # Previous step velocity + vnn = DefineMatrix('vnn',nnodes,dim) # 2 previous step velocity + vnnn = DefineMatrix('vnnn', nnodes, dim) # 3 previous step velocity TODO: We use this in case that the an is going to be obtained doing a BDF2 approximation + p = DefineVector('p',nnodes) # Pressure + penr= DefineVector('penr',nnodes) # Enriched Pressure + + # Variables needed for the navier stokes fractional splitting + vfrac = DefineMatrix('vfrac', nnodes, dim) # Fractional velocity, + + ## Test functions definition + w = DefineMatrix('w',nnodes,dim) # Velocity field test function + q = DefineVector('q',nnodes) # Pressure field test function + qenr = DefineVector('qenr' ,nnodes) # Enriched Pressure field test function + + ## Other data definitions + f = DefineMatrix('f',nnodes,dim) # Forcing term + fn = DefineMatrix('fn',nnodes,dim) # Previous step forcing term + vmeshn = DefineMatrix('vmeshn',nnodes,dim) # Previous step mesh velocity + + ## Constitutive matrix definition + C = DefineSymmetricMatrix('C',strain_size,strain_size) + + ## Stress vector definition + stress = DefineVector('stress',strain_size) + + ## Other simbols definition + dt = sympy.Symbol('dt', positive = True) + rho = sympy.Symbol('rho', positive = True) + nu = sympy.Symbol('nu', positive = True) + mu = sympy.Symbol('mu', positive = True) + tau1 = sympy.Symbol('tau1', positive = True) + tau2 = sympy.Symbol('tau2', positive = True) + h = sympy.Symbol('h', positive = True) + dyn_tau = sympy.Symbol('dyn_tau', positive = True) + stab_c1 = sympy.Symbol('stab_c1', positive = True) + stab_c2 = sympy.Symbol('stab_c2', positive = True) + volume_error_ratio = sympy.Symbol('volume_error_ratio') + art_dyn_visc_coeff = sympy.Symbol('art_dyn_visc_coeff') + + ## Convective velocity definition + if (linearisation == "Picard"): + vconv = DefineMatrix('vconv',nnodes,dim) # Convective velocity defined a symbol + elif (linearisation == "FullNR"): + vmesh = DefineMatrix('vmesh',nnodes,dim) # Mesh velocity + vconv = v - vmesh # Convective velocity defined as a velocity dependent variable + + vconv_gauss = vconv.transpose()*N #Convective velocity on the current time step linearized + vconv_old_gauss = vn.transpose()*N #Convective velocity on the previous time step for the convective term of the fractional acceleration + vconv_fractional = vfrac.transpose()*N #Convective velocity corresponding to the convective fractional term. + + ## Compute the stabilization parameters + vconv_gauss_norm = 0.0 + for i in range(0, dim): + vconv_gauss_norm += vconv_gauss[i]**2 + vconv_gauss_norm = sympy.sqrt(vconv_gauss_norm) + + ## Data interpolation to the Gauss points + K_darcy = sympy.Symbol('K_darcy', positive = True) + ## Backward differences coefficients + bdf0 = sympy.Symbol('bdf0') + bdf1 = sympy.Symbol('bdf1') + bdf2 = sympy.Symbol('bdf2') + ## Part of the NS acceleration due to the fractional splitting + acceleration = (bdf0*v -bdf0*vfrac) + v_gauss = v.transpose()*N + f_gauss = f.transpose()*N + + tau1 = 1.0/((rho*dyn_tau)/dt + (stab_c2*rho*vconv_gauss_norm)/h + (stab_c1*mu)/(h*h) + K_darcy) # Stabilization parameter 1 + tau2 = mu + (stab_c2*rho*vconv_gauss_norm*h)/stab_c1 # Stabilization parameter 2 + + p_gauss = p.transpose()*N #NOTE: We evaluate p-related terms at n+1 as temporal component makes no sense in this case for both time integration schemes + penr_gauss = penr.transpose()*Nenr + w_gauss = w.transpose()*N + q_gauss = q.transpose()*N + qenr_gauss = qenr.transpose()*Nenr + accel_gauss = acceleration.transpose()*N + + ## Gradients computation + grad_v = DN.transpose()*v + grad_v_fractional = DN.transpose()*vfrac + grad_v_old = DN.transpose()*vn + grad_w = DN.transpose()*w + grad_q = DN.transpose()*q + grad_qenr = DNenr.transpose()*qenr + grad_p = DN.transpose()*p + grad_penr = DNenr.transpose()*penr + grad_sym_v_voigt = grad_sym_voigtform(DN, v) + # Symmetric gradient of w in Voigt notation + grad_sym_w_voigt = grad_sym_voigtform(DN, w) + # Recall that the grad(w):sigma contraction equals grad_sym(w)*sigma in Voigt notation since sigma is a symmetric tensor. + + ## Divergence computation + div_v = div(DN,v) + div_w = div(DN,w) + div_vconv = div(DN,vconv) + + # All the convective term definition + convective_term = (vconv_gauss.transpose()*grad_v) #Convective term on the current time step NS equation + convective_n_term = (vconv_old_gauss.transpose()*grad_v_old) #Convective term for the previous time step acceleration term (fractional splitting) + convective_frac_term = vconv_fractional.transpose()*grad_v_fractional #Fractional convective term + + # accel_n = bdf0*vn+bdf1*vnn+bdf2*vnnn #TODO: Approximating the acceleration with BDF2 + accel_n = (vn-vnn)/dt + accel_gauss_n = accel_n.transpose()*N + + ## Galerkin Functional + rv_galerkin = rho*w_gauss.transpose()*f_gauss - rho*w_gauss.transpose()*accel_gauss -rho*w_gauss.transpose()*convective_term.transpose() - grad_sym_w_voigt.transpose()*stress + div_w*p_gauss + rho*w_gauss.transpose()*convective_frac_term.transpose() + + rv_galerkin -= w_gauss.transpose()*K_darcy*v_gauss #Darcy Term + if adding_acceleration: + # Adding fractional acceleration convective part + rv_galerkin -= rho*w_gauss.transpose()*convective_n_term.transpose() + # Adding fractional acceleration partial part + rv_galerkin -= rho*w_gauss.transpose()*accel_gauss_n + + if (divide_by_rho): + rv_galerkin += q_gauss*(volume_error_ratio - div_v[0,0]) + else: + rv_galerkin += rho*q_gauss*(volume_error_ratio - div_v[0,0]) + + # Stabilization functional terms + # Momentum conservation residual + # Note that the viscous stress term is dropped since linear elements are used + + vel_residual = rho*f_gauss - rho*accel_gauss - rho*convective_term.transpose() -grad_p +rho*convective_frac_term.transpose() + if adding_acceleration: + vel_residual -=rho*(accel_gauss_n+convective_n_term.transpose()) + + vel_residual-= K_darcy*v_gauss + + # Mass conservation residual + if (divide_by_rho): + mas_residual = -div_v[0,0] + volume_error_ratio + else: + mas_residual = -rho*div_v[0,0] + rho*volume_error_ratio + + vel_subscale = tau1*vel_residual + mas_subscale = tau2*mas_residual + + # Compute the ASGS stabilization terms using the momentum and mass conservation residuals above + if (divide_by_rho): + rv_stab = grad_q.transpose()*vel_subscale + else: + rv_stab = rho*grad_q.transpose()*vel_subscale + + rv_stab += rho*vconv_gauss.transpose()*grad_w*vel_subscale + rv_stab += rho*div_vconv*w_gauss.transpose()*vel_subscale + rv_stab += div_w*mas_subscale + rv_stab -= w_gauss.transpose()*K_darcy*vel_subscale + + ## Add the stabilization terms to the original residual terms + if (ASGS_stabilization): + rv = rv_galerkin + rv_stab + else: + rv = rv_galerkin + + ## Define DOFs and test function vectors + dofs = sympy.zeros(nnodes*(dim+1), 1) + testfunc = sympy.zeros(nnodes*(dim+1), 1) + + for i in range(0,nnodes): + for k in range(0,dim): + dofs[i*(dim+1)+k] = v[i,k] + testfunc[i*(dim+1)+k] = w[i,k] + dofs[i*(dim+1)+dim] = p[i,0] + testfunc[i*(dim+1)+dim] = q[i,0] + + ## Compute LHS and RHS + # For the RHS computation one wants the residual of the previous iteration (residual based formulation). By this reason the stress is + # included as a symbolic variable, which is assumed to be passed as an argument from the previous iteration database. + rhs = Compute_RHS(rv.copy(), testfunc, do_simplifications) + rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) + + # Compute LHS (RHS(residual) differenctiation w.r.t. the DOFs) + # Note that the 'stress' (symbolic variable) is substituted by 'C*grad_sym_v_voigt' for the LHS differenctiation. Otherwise the velocity terms + # within the velocity symmetryc gradient would not be considered in the differenctiation, meaning that the stress would be considered as + # a velocity independent constant in the LHS. + SubstituteMatrixValue(rhs, stress, C*grad_sym_v_voigt) + lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications) # Compute the LHS (considering stress as C*(B*v) to derive w.r.t. v) + lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode) + + #Enrichment Functional + ## K V x = b + rhs_eV + ## H Kee penr = rhs_ee + + vel_residual_enr = rho*f_gauss - rho*(accel_gauss + convective_term.transpose()) - grad_p - grad_penr+rho*convective_frac_term.transpose() + + if adding_acceleration: + vel_residual_enr -= rho*(accel_gauss_n+convective_n_term.transpose()) + + vel_residual_enr-= K_darcy*v_gauss + vel_subscale_enr = vel_residual_enr * tau1 + rv_galerkin_enriched = div_w*penr_gauss + + if (divide_by_rho): + rv_galerkin_enriched += qenr_gauss*(volume_error_ratio - div_v[0,0]) + rv_stab_enriched = grad_qenr.transpose()*vel_subscale_enr + rv_stab_enriched -= grad_q.transpose()*tau1*grad_penr + else: + rv_galerkin_enriched += qenr_gauss*rho*(volume_error_ratio - div_v[0,0]) + rv_stab_enriched = rho*grad_qenr.transpose()*vel_subscale_enr + rv_stab_enriched -= rho*grad_q.transpose()*tau1*grad_penr + + rv_stab_enriched -= rho*vconv_gauss.transpose()*grad_w*tau1*grad_penr + rv_stab_enriched += w_gauss.transpose()*K_darcy*tau1*grad_penr + rv_stab_enriched -= rho*div_vconv*w_gauss.transpose()*tau1*grad_penr + rv_enriched = rv_galerkin_enriched + ## Add the stabilization terms to the original residual terms + if (ASGS_stabilization): + rv_enriched += rv_stab_enriched + + dofs_enr=sympy.zeros(nnodes,1) + testfunc_enr = sympy.zeros(nnodes,1) + + for i in range(0,nnodes): + dofs_enr[i]=penr[i,0] + testfunc_enr[i]=qenr[i,0] + + ## K V x = b + rhs_eV + ## H Kee penr = rhs_ee + rhs_eV, V = Compute_RHS_and_LHS(rv_enriched, testfunc, dofs_enr, do_simplifications) + rhs_ee, H = Compute_RHS_and_LHS(rv_enriched, testfunc_enr, dofs, do_simplifications) + rhs_ee, Kee = Compute_RHS_and_LHS(rv_enriched, testfunc_enr, dofs_enr, do_simplifications) + + V_out = OutputMatrix_CollectingFactors(V,"V",mode) + H_out = OutputMatrix_CollectingFactors(H,"H",mode) + Kee_out = OutputMatrix_CollectingFactors(Kee,"Kee",mode) + rhs_ee_out = OutputVector_CollectingFactors(rhs_ee,"rhs_ee",mode) + + # Calculate artificial dynamic viscosity in each Gauss point + vel_residual_norm = vel_residual.norm() + grad_v_norm = grad_v.norm() + artificial_mu = 0.5*h*art_dyn_visc_coeff*(vel_residual_norm/grad_v_norm) + + grad_v_norm_out = OutputScalar(grad_v_norm, "grad_v_norm", mode) + artificial_mu_out = OutputScalar(artificial_mu, "artificial_mu", mode) + + ##################################################################### + ##################################################################### + + if(dim == 2): + outstring = outstring.replace("//substitute_lhs_2D", lhs_out) + outstring = outstring.replace("//substitute_rhs_2D", rhs_out) + + outstring = outstring.replace("//substitute_enrichment_V_2D", V_out) + outstring = outstring.replace("//substitute_enrichment_H_2D", H_out) + outstring = outstring.replace("//substitute_enrichment_Kee_2D", Kee_out) + outstring = outstring.replace("//substitute_enrichment_rhs_ee_2D", rhs_ee_out) + + outstring = outstring.replace("//substitute_artificial_mu_2D_3N", artificial_mu_out) + outstring = outstring.replace("//substitute_artificial_mu_grad_v_norm_2D_3N", grad_v_norm_out) + + elif(dim == 3): + outstring = outstring.replace("//substitute_lhs_3D", lhs_out) + outstring = outstring.replace("//substitute_rhs_3D", rhs_out) + + outstring = outstring.replace("//substitute_enrichment_V_3D", V_out) + outstring = outstring.replace("//substitute_enrichment_H_3D", H_out) + outstring = outstring.replace("//substitute_enrichment_Kee_3D", Kee_out) + outstring = outstring.replace("//substitute_enrichment_rhs_ee_3D", rhs_ee_out) + + outstring = outstring.replace("//substitute_artificial_mu_3D_4N", artificial_mu_out) + outstring = outstring.replace("//substitute_artificial_mu_grad_v_norm_3D_4N", grad_v_norm_out) + +#We write in the file +out = open(output_filename,'w') +out.write(outstring) +out.close() + diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp new file mode 100644 index 000000000000..888fd2bc0d93 --- /dev/null +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp @@ -0,0 +1,1289 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Autor: Uxue Chasco Goñi +// + +#include "two_fluid_navier_stokes_fractional.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" +namespace Kratos +{ + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Life cycle + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional(IndexType NewId) + : FluidElement(NewId) {} + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional( + IndexType NewId, const NodesArrayType &ThisNodes) + : FluidElement(NewId, ThisNodes) {} + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional( + IndexType NewId, GeometryType::Pointer pGeometry) + : FluidElement(NewId, pGeometry) {} + +template +TwoFluidNavierStokesFractional::TwoFluidNavierStokesFractional( + IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties) + : FluidElement(NewId, pGeometry, pProperties) {} + +template +TwoFluidNavierStokesFractional::~TwoFluidNavierStokesFractional() {} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Public Operations + +template +Element::Pointer TwoFluidNavierStokesFractional::Create( + IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const +{ + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); +} + +template +Element::Pointer TwoFluidNavierStokesFractional::Create( + IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const +{ + return Kratos::make_intrusive(NewId, pGeom, pProperties); +} + +template +void TwoFluidNavierStokesFractional::CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) +{ + // Resize and intialize output + if (rLeftHandSideMatrix.size1() != LocalSize) + rLeftHandSideMatrix.resize(LocalSize, LocalSize, false); + + if (rRightHandSideVector.size() != LocalSize) + rRightHandSideVector.resize(LocalSize, false); + + noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize); + noalias(rRightHandSideVector) = ZeroVector(LocalSize); + + if constexpr (TElementData::ElementManagesTimeIntegration){ + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + if (data.IsCut()){ + GeometryType::Pointer p_geom = this->pGetGeometry(); + Matrix shape_functions_pos, shape_functions_neg; + Matrix shape_functions_enr_pos, shape_functions_enr_neg; + GeometryType::ShapeFunctionsGradientsType shape_derivatives_pos, shape_derivatives_neg; + GeometryType::ShapeFunctionsGradientsType shape_derivatives_enr_pos, shape_derivatives_enr_neg; + + ModifiedShapeFunctions::Pointer p_modified_sh_func = pGetModifiedShapeFunctionsUtility(p_geom, data.Distance); + + ComputeSplitting( + data, + shape_functions_pos, + shape_functions_neg, + shape_functions_enr_pos, + shape_functions_enr_neg, + shape_derivatives_pos, + shape_derivatives_neg, + shape_derivatives_enr_pos, + shape_derivatives_enr_neg, + p_modified_sh_func); + + if (data.NumberOfDivisions == 1){ + // Cases exist when the element is not subdivided due to the characteristics of the provided distance + // In this cases the element is treated as AIR or FLUID depending on the side + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + array_1d Ncenter; + for (unsigned int i = 0; i < NumNodes; ++i){ + Ncenter[i] = 1.0/NumNodes; + } + for (unsigned int g = 0; g < number_of_gauss_points; ++g){ + UpdateIntegrationPointData( + data, + g, + gauss_weights[g], + row(shape_functions, g), + shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } else { + MatrixType Vtot = ZeroMatrix(NumNodes * (Dim + 1), NumNodes); + MatrixType Htot = ZeroMatrix(NumNodes, NumNodes * (Dim + 1)); + MatrixType Kee_tot = ZeroMatrix(NumNodes, NumNodes); + VectorType rhs_ee_tot = ZeroVector(NumNodes); + + for (unsigned int g_pos = 0; g_pos < data.w_gauss_pos_side.size(); ++g_pos){ + UpdateIntegrationPointData( + data, + g_pos, + data.w_gauss_pos_side[g_pos], + row(shape_functions_pos, g_pos), + shape_derivatives_pos[g_pos], + row(shape_functions_enr_pos, g_pos), + shape_derivatives_enr_pos[g_pos]); + + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + this->ComputeGaussPointEnrichmentContributions(data, Vtot, Htot, Kee_tot, rhs_ee_tot); + } + + for (unsigned int g_neg = 0; g_neg < data.w_gauss_neg_side.size(); ++g_neg){ + UpdateIntegrationPointData( + data, + g_neg, + data.w_gauss_neg_side[g_neg], + row(shape_functions_neg, g_neg), + shape_derivatives_neg[g_neg], + row(shape_functions_enr_neg, g_neg), + shape_derivatives_enr_neg[g_neg]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + this->ComputeGaussPointEnrichmentContributions(data, Vtot, Htot, Kee_tot, rhs_ee_tot); + } + + Matrix int_shape_function, int_shape_function_enr_neg, int_shape_function_enr_pos; + GeometryType::ShapeFunctionsGradientsType int_shape_derivatives; + Vector int_gauss_pts_weights; + std::vector< array_1d > int_normals_neg; + + if (rCurrentProcessInfo[SURFACE_TENSION] || rCurrentProcessInfo[MOMENTUM_CORRECTION]){ + ComputeSplitInterface( + data, + int_shape_function, + int_shape_function_enr_pos, + int_shape_function_enr_neg, + int_shape_derivatives, + int_gauss_pts_weights, + int_normals_neg, + p_modified_sh_func); + } + + if (rCurrentProcessInfo[MOMENTUM_CORRECTION]){ + BoundedMatrix lhs_acc_correction = ZeroMatrix(LocalSize,LocalSize); + + double positive_density = 0.0; + double negative_density = 0.0; + + const auto& r_geom = this->GetGeometry(); + + for (unsigned int intgp = 0; intgp < int_gauss_pts_weights.size(); ++intgp){ + double u_dot_n = 0.0; + for (unsigned int i = 0; i < NumNodes; ++i){ + u_dot_n += int_shape_function(intgp,i)*r_geom[i].GetValue(DISTANCE_CORRECTION); + + if (data.Distance[i] > 0.0){ + positive_density = data.NodalDensity[i]; + } else { + negative_density = data.NodalDensity[i]; + } + } + + u_dot_n /= data.DeltaTime; + + for (unsigned int i = 0; i < NumNodes; ++i){ + for (unsigned int j = 0; j < NumNodes; ++j){ + for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ + lhs_acc_correction( i*(NumNodes) + dim, j*(NumNodes) + dim) += + int_shape_function(intgp,i)*int_shape_function(intgp,j)*u_dot_n*int_gauss_pts_weights(intgp); + } + } + } + } + + lhs_acc_correction = (negative_density - positive_density)*lhs_acc_correction; + noalias(rLeftHandSideMatrix) += lhs_acc_correction; + + Kratos::array_1d tempU; // Unknowns vector containing only velocity components + for (unsigned int i = 0; i < NumNodes; ++i){ + for (unsigned int dimi = 0; dimi < Dim; ++dimi){ + tempU[i*(Dim+1) + dimi] = data.Velocity(i,dimi); + } + } + noalias(rRightHandSideVector) -= prod(lhs_acc_correction,tempU); + } + + if (rCurrentProcessInfo[SURFACE_TENSION]){ + + AddSurfaceTensionContribution( + data, + int_shape_function, + int_shape_function_enr_pos, + int_shape_function_enr_neg, + int_shape_derivatives, + int_gauss_pts_weights, + int_normals_neg, + rLeftHandSideMatrix, + rRightHandSideVector, + Htot, + Vtot, + Kee_tot, + rhs_ee_tot + ); + + } else{ + // Without pressure gradient stabilization, volume ratio is checked during condensation + // Also, without surface tension, zero pressure difference is penalized + CondenseEnrichmentWithContinuity(data, rLeftHandSideMatrix, rRightHandSideVector, Htot, Vtot, Kee_tot, rhs_ee_tot); + } + + } + } else { + //Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + // Iterate over integration points to evaluate local contribution + for (unsigned int g = 0; g < number_of_gauss_points; ++g){ + UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } + } else{ + KRATOS_ERROR << "TwoFluidNavierStokesFractional is supposed to manage time integration." << std::endl; + } +} + +template +void TwoFluidNavierStokesFractional::CalculateRightHandSide( + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) +{ + MatrixType tmp; + CalculateLocalSystem(tmp, rRightHandSideVector, rCurrentProcessInfo); +} +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Public Inquiry + +template +int TwoFluidNavierStokesFractional::Check(const ProcessInfo &rCurrentProcessInfo) const +{ + KRATOS_TRY; + int out = FluidElement::Check(rCurrentProcessInfo); + KRATOS_ERROR_IF_NOT(out == 0) + << "Error in base class Check for Element " << this->Info() << std::endl + << "Error code is " << out << std::endl; + + return 0; + + KRATOS_CATCH(""); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Public I/O + +template +const Parameters TwoFluidNavierStokesFractional::GetSpecifications() const +{ + const Parameters specifications = Parameters(R"({ + "time_integration" : ["implicit"], + "framework" : "ale", + "symmetric_lhs" : false, + "positive_definite_lhs" : true, + "output" : { + "gauss_point" : [], + "nodal_historical" : ["VELOCITY","PRESSURE"], + "nodal_non_historical" : [], + "entity" : [] + }, + "required_variables" : ["DISTANCE","VELOCITY","PRESSURE","MESH_VELOCITY","DENSITY","DYNAMIC_VISCOSITY"], + "required_dofs" : [], + "flags_used" : [], + "compatible_geometries" : ["Triangle2D3","Tetrahedra3D4"], + "element_integrates_in_time" : true, + "compatible_constitutive_laws": { + "type" : ["NewtonianTwoFluid2DLaw","NewtonianTwoFluid3DLaw"], + "dimension" : ["2D","3D"], + "strain_size" : [3,6] + }, + "required_polynomial_degree_of_geometry" : 1, + "documentation" : + "This element implements Navier-Stokes biphasic fluid-air formulation with a levelset-based interface representation with Variational MultiScales (VMS) stabilization. Note that any viscous behavior can be used for the fluid phase through a constitutive law. The air phase is assumed to be Newtonian. Surface tension contribution can be accounted for by setting the SURFACE_TENSION variable to true in the ProcessInfo container. + })"); + + if (Dim == 2) { + std::vector dofs_2d({"VELOCITY_X","VELOCITY_Y","PRESSURE"}); + specifications["required_dofs"].SetStringArray(dofs_2d); + } else { + std::vector dofs_3d({"VELOCITY_X","VELOCITY_Y","VELOCITY_Z","PRESSURE"}); + specifications["required_dofs"].SetStringArray(dofs_3d); + } + + return specifications; +} + +template +std::string TwoFluidNavierStokesFractional::Info() const +{ + std::stringstream buffer; + buffer << "TwoFluidNavierStokesFractional" << Dim << "D" << NumNodes << "N #" << this->Id(); + return buffer.str(); +} + +template +void TwoFluidNavierStokesFractional::PrintInfo( + std::ostream &rOStream) const +{ + rOStream << this->Info() << std::endl; + + if (this->GetConstitutiveLaw() != nullptr){ + rOStream << "with constitutive law " << std::endl; + this->GetConstitutiveLaw()->PrintInfo(rOStream); + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Protected operations + +template +void TwoFluidNavierStokesFractional::AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) +{ + this->ComputeGaussPointLHSContribution(rData, rLHS); + this->ComputeGaussPointRHSContribution(rData, rRHS); +} + +template +void TwoFluidNavierStokesFractional::AddTimeIntegratedLHS( + TElementData &rData, + MatrixType &rLHS) +{ + this->ComputeGaussPointLHSContribution(rData, rLHS); +} + +template +void TwoFluidNavierStokesFractional::AddTimeIntegratedRHS( + TElementData &rData, + VectorType &rRHS) +{ + this->ComputeGaussPointRHSContribution(rData, rRHS); +} + +template +void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( + TElementData& rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType& rN, + const typename TElementData::ShapeDerivativesType& rDN_DX) const +{ + rData.UpdateGeometryValues(IntegrationPointIndex, Weight, rN, rDN_DX); + const double d_gauss = inner_prod(rData.Distance, rN); + if (d_gauss > 0.0) + rData.CalculateAirMaterialResponse(); + else + this->CalculateMaterialResponse(rData); + rData.ComputeDarcyTerm(); +} + +template +void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( + TElementData& rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType& rN, + const typename TElementData::ShapeDerivativesType& rDN_DX, + const typename TElementData::MatrixRowType& rNenr, + const typename TElementData::ShapeDerivativesType& rDN_DXenr) const +{ + rData.UpdateGeometryValues(IntegrationPointIndex,Weight,rN,rDN_DX,rNenr,rDN_DXenr); + const double d_gauss = inner_prod(rData.Distance, rN); + if (d_gauss > 0.0) + rData.CalculateAirMaterialResponse(); + else + this->CalculateMaterialResponse(rData); + rData.ComputeDarcyTerm(); +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalData<2, 3> &rData, + MatrixType &rLHS) +{ + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + const auto vn = rData.Velocity_OldStep1; + const auto vconv = rData.Velocity - rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + + // Get constitutive matrix + const Matrix &C = rData.C; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + + //substitute_lhs_2D + + // Add intermediate results to local system + noalias(rLHS) += lhs * rData.Weight; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalData<3, 4> &rData, + MatrixType &rLHS) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + const double K_darcy = rData.DarcyTerm; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + + const auto vn=rData.Velocity_OldStep1; + const auto vconv = rData.Velocity - rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + + // Get constitutive matrix + const Matrix &C = rData.C; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + + //substitute_lhs_3D + + // Add intermediate results to local system + noalias(rLHS) += lhs * rData.Weight; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalData<2, 3> &rData, + VectorType &rRHS) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + + const auto vfrac = rData.Velocity_Fractional; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const auto &stress = rData.ShearStress; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const auto &phi = rData.Distance; + const double previous_dt = rData.PreviousDeltaTime; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &rhs = rData.rhs; + + //substitute_rhs_2D + + noalias(rRHS) += rData.Weight * rhs; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalData<3, 4> &rData, + VectorType &rRHS) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + const auto vfrac = rData.Velocity_Fractional; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const auto &stress = rData.ShearStress; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const auto &phi = rData.Distance; + const double previous_dt = rData.PreviousDeltaTime; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &rhs = rData.rhs; + + //substitute_rhs_3D + + noalias(rRHS) += rData.Weight * rhs; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointEnrichmentContributions( + TwoFluidNavierStokesFractionalData<2, 3> &rData, + MatrixType &rV, + MatrixType &rH, + MatrixType &rKee, + VectorType &rRHS_ee) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + const auto vfrac = rData.Velocity_Fractional; + + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const auto &Nenr = rData.Nenr; + const auto &DNenr = rData.DN_DXenr; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const auto &phi = rData.Distance; + const double previous_dt = rData.PreviousDeltaTime; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &V = rData.V; + auto &H = rData.H; + auto &Kee = rData.Kee; + auto &rhs_ee = rData.rhs_ee; + + array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it + + //substitute_enrichment_V_2D + + //substitute_enrichment_H_2D + + //substitute_enrichment_Kee_2D + + //substitute_enrichment_rhs_ee_2D + + noalias(rV) += rData.Weight * V; + noalias(rH) += rData.Weight * H; + noalias(rKee) += rData.Weight * Kee; + noalias(rRHS_ee) += rData.Weight * rhs_ee; +} + +template <> +void TwoFluidNavierStokesFractional>::ComputeGaussPointEnrichmentContributions( + TwoFluidNavierStokesFractionalData<3, 4> &rData, + MatrixType &rV, + MatrixType &rH, + MatrixType &rKee, + VectorType &rRHS_ee) +{ + + const double rho = rData.Density; + const double mu = rData.EffectiveViscosity; + + const double h = rData.ElementSize; + + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const double K_darcy = rData.DarcyTerm; + + const auto &v = rData.Velocity; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = v - vmesh; + const auto vfrac = rData.Velocity_Fractional; + // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible + + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const auto &Nenr = rData.Nenr; + const auto &DNenr = rData.DN_DXenr; + + // Stabilization parameters + constexpr double stab_c1 = 4.0; + constexpr double stab_c2 = 2.0; + + // Mass correction term + double volume_error_ratio = 0.0; + + if (rData.IsCut()) + { + const double previous_dt = rData.PreviousDeltaTime; + const auto &phi = rData.Distance; + double volume_error = 0.0; + double distance_gauss = 0.0; + for (std::size_t i = 0; i < N.size(); ++i) + { + distance_gauss += N[i] * phi[i]; + } + if (distance_gauss < 0.0) + { + volume_error = -rData.WaterVolumeError; + } + else if (distance_gauss > 0.0) + { + volume_error = -rData.AirVolumeError; + } + volume_error_ratio = volume_error / previous_dt; + } + + auto &V = rData.V; + auto &H = rData.H; + auto &Kee = rData.Kee; + auto &rhs_ee = rData.rhs_ee; + + array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it + + //substitute_enrichment_V_3D + + //substitute_enrichment_H_3D + + //substitute_enrichment_Kee_3D + + //substitute_enrichment_rhs_ee_3D + + noalias(rV) += rData.Weight * V; + noalias(rH) += rData.Weight * H; + noalias(rKee) += rData.Weight * Kee; + noalias(rRHS_ee) += rData.Weight * rhs_ee; +} + +template +void TwoFluidNavierStokesFractional::ComputeSplitting( + TElementData &rData, + MatrixType &rShapeFunctionsPos, + MatrixType &rShapeFunctionsNeg, + MatrixType &rEnrichedShapeFunctionsPos, + MatrixType &rEnrichedShapeFunctionsNeg, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesNeg, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions) +{ + // Set the positive and negative enrichment interpolation matrices + // Note that the enrichment is constructed using the standard shape functions such that: + // In the negative distance region, the enrichment functions correspondig to the negative + // distance nodes are null and the positive distance nodes are equal to the standard shape + // functions. On the contrary, for the positive distance region, the enrichment functions + // corresponding to the positive distance nodes are null meanwhile the negative distance + // nodes are equal to the standard. This yields a discontinuous enrichment space. + Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); + Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); + + for (unsigned int i = 0; i < NumNodes; ++i){ + if (rData.Distance[i] > 0.0){ + enr_neg_interp(i, i) = 1.0; + } else{ + enr_pos_interp(i, i) = 1.0; + } + } + + // Call the positive side modified shape functions calculator + pModifiedShapeFunctions->ComputePositiveSideShapeFunctionsAndGradientsValues( + rShapeFunctionsPos, + rShapeDerivativesPos, + rData.w_gauss_pos_side, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + // Call the negative side modified shape functions calculator + pModifiedShapeFunctions->ComputeNegativeSideShapeFunctionsAndGradientsValues( + rShapeFunctionsNeg, + rShapeDerivativesNeg, + rData.w_gauss_neg_side, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + // Compute the enrichment shape function values using the enrichment interpolation matrices + rEnrichedShapeFunctionsPos = prod(rShapeFunctionsPos, enr_pos_interp); + rEnrichedShapeFunctionsNeg = prod(rShapeFunctionsNeg, enr_neg_interp); + + // Compute the enrichment shape function gradient values using the enrichment interpolation matrices + rEnrichedShapeDerivativesPos = rShapeDerivativesPos; + rEnrichedShapeDerivativesNeg = rShapeDerivativesNeg; + + for (unsigned int i = 0; i < rShapeDerivativesPos.size(); ++i){ + rEnrichedShapeDerivativesPos[i] = prod(enr_pos_interp, rShapeDerivativesPos[i]); + } + + for (unsigned int i = 0; i < rShapeDerivativesNeg.size(); ++i){ + rEnrichedShapeDerivativesNeg[i] = prod(enr_neg_interp, rShapeDerivativesNeg[i]); + } + + rData.NumberOfDivisions = (pModifiedShapeFunctions->pGetSplittingUtil())->mDivisionsNumber; +} + +template +void TwoFluidNavierStokesFractional::ComputeSplitInterface( + const TElementData &rData, + MatrixType& rInterfaceShapeFunctionNeg, + MatrixType& rEnrInterfaceShapeFunctionPos, + MatrixType& rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivativesNeg, + Vector& rInterfaceWeightsNeg, + std::vector>& rInterfaceNormalsNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions) +{ + Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); + Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); + + for (unsigned int i = 0; i < NumNodes; ++i){ + if (rData.Distance[i] > 0.0){ + enr_neg_interp(i, i) = 1.0; + } else{ + enr_pos_interp(i, i) = 1.0; + } + } + + // Call the Interface negative side shape functions calculator + pModifiedShapeFunctions->ComputeInterfaceNegativeSideShapeFunctionsAndGradientsValues( + rInterfaceShapeFunctionNeg, + rInterfaceShapeDerivativesNeg, + rInterfaceWeightsNeg, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + // Call the Interface negative side normal functions calculator + pModifiedShapeFunctions->ComputeNegativeSideInterfaceAreaNormals( + rInterfaceNormalsNeg, + GeometryData::IntegrationMethod::GI_GAUSS_2); + + for (unsigned int gp = 0; gp < rInterfaceNormalsNeg.size(); ++gp){ + const double normal_norm = norm_2(rInterfaceNormalsNeg[gp]); + rInterfaceNormalsNeg[gp] /= normal_norm; + } + + // Compute the enrichment shape function values at the interface gauss points using the enrichment interpolation matrices + rEnrInterfaceShapeFunctionPos = prod(rInterfaceShapeFunctionNeg, enr_pos_interp); + rEnrInterfaceShapeFunctionNeg = prod(rInterfaceShapeFunctionNeg, enr_neg_interp); +} + +template <> +ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNavierStokesFractionalData<2, 3> >::pGetModifiedShapeFunctionsUtility( + const GeometryType::Pointer pGeometry, + const Vector& rDistances) +{ + return Kratos::make_unique(pGeometry, rDistances); +} + +template <> +ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNavierStokesFractionalData<3, 4> >::pGetModifiedShapeFunctionsUtility( + const GeometryType::Pointer pGeometry, + const Vector& rDistances) +{ + return Kratos::make_unique(pGeometry, rDistances); +} + +template +void TwoFluidNavierStokesFractional::CalculateCurvatureOnInterfaceGaussPoints( + const Matrix& rInterfaceShapeFunctions, + Vector& rInterfaceCurvature) +{ + const auto& r_geom = this->GetGeometry(); + const unsigned int n_gpt = rInterfaceShapeFunctions.size1(); + + rInterfaceCurvature.resize(n_gpt, false); + + for (unsigned int gpt = 0; gpt < n_gpt; ++gpt){ + double curvature = 0.0; + for (unsigned int i = 0; i < NumNodes; ++i){ + curvature += rInterfaceShapeFunctions(gpt,i) * r_geom[i].GetValue(CURVATURE); + } + rInterfaceCurvature[gpt] = curvature; + } +} + +template +void TwoFluidNavierStokesFractional::SurfaceTension( + const double SurfaceTensionCoefficient, + const Vector& rCurvature, + const Vector& rInterfaceWeights, + const Matrix& rInterfaceShapeFunctions, + const std::vector>& rInterfaceNormalsNeg, + VectorType& rRHS) +{ + for (unsigned int intgp = 0; intgp < rInterfaceWeights.size(); ++intgp){ + const double intgp_curv = rCurvature(intgp); + const double intgp_w = rInterfaceWeights(intgp); + const auto& intgp_normal = rInterfaceNormalsNeg[intgp]; + for (unsigned int j = 0; j < NumNodes; ++j){ + for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ + rRHS[ j*(NumNodes) + dim ] -= SurfaceTensionCoefficient*intgp_normal[dim] + *intgp_curv*intgp_w*rInterfaceShapeFunctions(intgp,j); + } + } + } +} + +template +void TwoFluidNavierStokesFractional::PressureGradientStabilization( + const TElementData& rData, + const Vector& rInterfaceWeights, + const Matrix& rEnrInterfaceShapeFunctionPos, + const Matrix& rEnrInterfaceShapeFunctionNeg, + const GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, + MatrixType& rKeeTot, + VectorType& rRHSeeTot) +{ + MatrixType kee = ZeroMatrix(NumNodes, NumNodes); + VectorType rhs_enr = ZeroVector(NumNodes); + + Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); + Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); + + double positive_density = 0.0; + double negative_density = 0.0; + double positive_viscosity = 0.0; + double negative_viscosity = 0.0; + + for (unsigned int i = 0; i < NumNodes; ++i){ + if (rData.Distance[i] > 0.0){ + enr_neg_interp(i, i) = 1.0; + positive_density = rData.NodalDensity[i]; + positive_viscosity = rData.NodalDynamicViscosity[i]; + } else{ + enr_pos_interp(i, i) = 1.0; + negative_density = rData.NodalDensity[i]; + negative_viscosity = rData.NodalDynamicViscosity[i]; + } + } + + GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesPos = rInterfaceShapeDerivatives; + GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesNeg = rInterfaceShapeDerivatives; + + for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ + EnrichedInterfaceShapeDerivativesPos[i] = prod(enr_pos_interp, rInterfaceShapeDerivatives[i]); + } + + for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ + EnrichedInterfaceShapeDerivativesNeg[i] = prod(enr_neg_interp, rInterfaceShapeDerivatives[i]); + } + + double positive_volume = 0.0; + double negative_volume = 0.0; + for (unsigned int igauss_pos = 0; igauss_pos < rData.w_gauss_pos_side.size(); ++igauss_pos){ + positive_volume += rData.w_gauss_pos_side[igauss_pos]; + } + + for (unsigned int igauss_neg = 0; igauss_neg < rData.w_gauss_neg_side.size(); ++igauss_neg){ + negative_volume += rData.w_gauss_neg_side[igauss_neg]; + } + const double element_volume = positive_volume + negative_volume; + + const auto& r_geom = this->GetGeometry(); + const double h_elem = rData.ElementSize; + + double cut_area = 0.0; + for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ + cut_area += rInterfaceWeights[gp]; + } + + const double density = 1.0/(1.0/positive_density + 1.0/negative_density); + const double viscosity = 1.0/(1.0/positive_viscosity + 1.0/negative_viscosity); + + // Stabilization parameters + const double cut_stabilization_coefficient = 1.0; + const double stab_c1 = 4.0; + const double stab_c2 = 2.0; + const double dyn_tau = rData.DynamicTau; + + const double dt = rData.DeltaTime; + + // const auto v_convection = rData.Velocity - rData.Velocity_OldStep1; + const auto v_convection = rData.Velocity - rData.MeshVelocity; + + for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ + + Vector vconv = ZeroVector(Dim); + double positive_weight = 0.0; + double negative_weight = 0.0; + + for (unsigned int j = 0; j < NumNodes; ++j){ + for (unsigned int dim = 0; dim < Dim; ++dim){ + vconv[dim] += (rEnrInterfaceShapeFunctionNeg(gp, j) + rEnrInterfaceShapeFunctionPos(gp, j)) + *v_convection(j,dim); + } + positive_weight += rEnrInterfaceShapeFunctionNeg(gp, j); + negative_weight += rEnrInterfaceShapeFunctionPos(gp, j); + } + + const double v_conv_norm = norm_2(vconv); + + const double penalty_coefficient = cut_stabilization_coefficient * + density * 1.0 / (dyn_tau * density / dt + stab_c1 * viscosity / h_elem / h_elem + + stab_c2 * density * v_conv_norm / h_elem) * element_volume / cut_area; + + const auto& r_gp_enriched_interface_shape_derivatives_pos = EnrichedInterfaceShapeDerivativesPos[gp]; + const auto& r_gp_enriched_interface_shape_derivatives_neg = EnrichedInterfaceShapeDerivativesNeg[gp]; + + for (unsigned int i = 0; i < NumNodes; ++i){ + + for (unsigned int j = 0; j < NumNodes; ++j){ + + const auto& r_pressure_gradient_j = r_geom[j].GetValue(PRESSURE_GRADIENT); + + for (unsigned int dim = 0; dim < Dim; ++dim){ + kee(i, j) += penalty_coefficient * rInterfaceWeights[gp] * + ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* + ( r_gp_enriched_interface_shape_derivatives_pos(j,dim) - r_gp_enriched_interface_shape_derivatives_neg(j,dim) ); + + rhs_enr(i) += penalty_coefficient * rInterfaceWeights[gp] * + ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* + (rEnrInterfaceShapeFunctionNeg(gp, j)/positive_weight - rEnrInterfaceShapeFunctionPos(gp, j)/negative_weight)* + r_pressure_gradient_j(dim); + } + } + } + } + + noalias(rKeeTot) += kee; + noalias(rRHSeeTot) += rhs_enr; +} + +template +void TwoFluidNavierStokesFractional::CalculateStrainRate(TElementData& rData) const +{ + FluidElement::CalculateStrainRate(rData); +} + +template +void TwoFluidNavierStokesFractional::CondenseEnrichmentWithContinuity( + const TElementData &rData, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot) +{ + const double min_area_ratio = 1e-7; + + // Compute positive side, negative side and total volumes + double positive_volume = 0.0; + double negative_volume = 0.0; + for (unsigned int igauss_pos = 0; igauss_pos < rData.w_gauss_pos_side.size(); ++igauss_pos){ + positive_volume += rData.w_gauss_pos_side[igauss_pos]; + } + + for (unsigned int igauss_neg = 0; igauss_neg < rData.w_gauss_neg_side.size(); ++igauss_neg){ + negative_volume += rData.w_gauss_neg_side[igauss_neg]; + } + const double Vol = positive_volume + negative_volume; + + //We only enrich elements which are not almost empty/full + if (positive_volume / Vol > min_area_ratio && negative_volume / Vol > min_area_ratio) { + + // Compute the maximum diagonal value in the enrichment stiffness matrix + double max_diag = 0.0; + for (unsigned int k = 0; k < NumNodes; ++k){ + if (std::abs(rKeeTot(k, k)) > max_diag){ + max_diag = std::abs(rKeeTot(k, k)); + } + } + if (max_diag == 0.0){ + max_diag = 1.0; + } + // "weakly" impose continuity + for (unsigned int i = 0; i < Dim; ++i){ + const double di = std::abs(rData.Distance[i]); + for (unsigned int j = i + 1; j < NumNodes; ++j){ + const double dj = std::abs(rData.Distance[j]); + // Check if the edge is cut, if it is, set the penalty constraint + if (rData.Distance[i] * rData.Distance[j] < 0.0){ + double sum_d = di + dj; + double Ni = dj / sum_d; + double Nj = di / sum_d; + double penalty_coeff = max_diag * 0.001; // h/BDFVector[0]; + rKeeTot(i, i) += penalty_coeff * Ni * Ni; + rKeeTot(i, j) -= penalty_coeff * Ni * Nj; + rKeeTot(j, i) -= penalty_coeff * Nj * Ni; + rKeeTot(j, j) += penalty_coeff * Nj * Nj; + } + } + } + + // Enrichment condensation (add to LHS and RHS the enrichment contributions) + double det; + MatrixType inverse_diag(NumNodes, NumNodes); + MathUtils::InvertMatrix(rKeeTot, inverse_diag, det); + + const Matrix tmp = prod(inverse_diag, rHtot); + noalias(rLeftHandSideMatrix) -= prod(rVtot, tmp); + + const Vector tmp2 = prod(inverse_diag, rRHSeeTot); + noalias(rRightHandSideVector) -= prod(rVtot, tmp2); + } +} + +template +void TwoFluidNavierStokesFractional::CondenseEnrichment( + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot) +{ + // Enrichment condensation (add to LHS and RHS the enrichment contributions) + double det; + MatrixType inverse_diag(NumNodes, NumNodes); + MathUtils::InvertMatrix(rKeeTot, inverse_diag, det); + + const Matrix tmp = prod(inverse_diag, rHtot); + noalias(rLeftHandSideMatrix) -= prod(rVtot, tmp); + + const Vector tmp2 = prod(inverse_diag, rRHSeeTot); + noalias(rRightHandSideVector) -= prod(rVtot, tmp2); +} + +template +void TwoFluidNavierStokesFractional::AddSurfaceTensionContribution( + const TElementData& rData, + MatrixType& rInterfaceShapeFunction, + MatrixType& rEnrInterfaceShapeFunctionPos, + MatrixType& rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, + Vector& rInterfaceWeights, + std::vector< array_1d >& rInterfaceNormalsNeg, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rHtot, + const MatrixType &rVtot, + MatrixType &rKeeTot, + VectorType &rRHSeeTot) +{ + // Surface tension coefficient is set in material properties + const double surface_tension_coefficient = this->GetProperties().GetValue(SURFACE_TENSION_COEFFICIENT); + + Vector gauss_pts_curvature; // curvatures calculated on interface Gauss points + + CalculateCurvatureOnInterfaceGaussPoints( + rInterfaceShapeFunction, + gauss_pts_curvature); + + SurfaceTension( + surface_tension_coefficient, + gauss_pts_curvature, + rInterfaceWeights, + rInterfaceShapeFunction, + rInterfaceNormalsNeg, + rRightHandSideVector); + + this->PressureGradientStabilization( + rData, + rInterfaceWeights, + rEnrInterfaceShapeFunctionPos, + rEnrInterfaceShapeFunctionNeg, + rInterfaceShapeDerivatives, + rKeeTot, + rRHSeeTot); + + CondenseEnrichment(rLeftHandSideMatrix, rRightHandSideVector, rHtot, rVtot, rKeeTot, rRHSeeTot); +} + +template +void TwoFluidNavierStokesFractional::save(Serializer &rSerializer) const +{ + using BaseType = FluidElement; + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType); +} + +template +void TwoFluidNavierStokesFractional::load(Serializer &rSerializer) +{ + using BaseType = FluidElement; + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType); +} + + +template +void TwoFluidNavierStokesFractional::CalculateOnIntegrationPoints( + const Variable &rVariable, + std::vector &rValues, + const ProcessInfo &rCurrentProcessInfo ) +{ + if (rVariable == DIVERGENCE){ + + const auto& rGeom = this->GetGeometry(); + const GeometryType::IntegrationPointsArrayType& IntegrationPoints = rGeom.IntegrationPoints(GeometryData::IntegrationMethod::GI_GAUSS_2); + const unsigned int num_gauss = IntegrationPoints.size(); + + if (rValues.size() != num_gauss){ + rValues.resize(num_gauss); + } + + Vector gauss_pts_jacobian_determinant = ZeroVector(num_gauss); + GeometryData::ShapeFunctionsGradientsType DN_DX; + rGeom.ShapeFunctionsIntegrationPointsGradients(DN_DX, gauss_pts_jacobian_determinant, GeometryData::IntegrationMethod::GI_GAUSS_2); + + for (unsigned int i_gauss = 0; i_gauss < num_gauss; ++i_gauss){ + + const Matrix gp_DN_DX = DN_DX[i_gauss]; + double DVi_DXi = 0.0; + + for(unsigned int nnode = 0; nnode < NumNodes; ++nnode){ + + const array_1d vel = rGeom[nnode].GetSolutionStepValue(VELOCITY); + for(unsigned int ndim = 0; ndim < Dim; ++ndim){ + DVi_DXi += gp_DN_DX(nnode, ndim) * vel[ndim]; + } + } + rValues[i_gauss] = DVi_DXi; + } + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Class template instantiation + +template class TwoFluidNavierStokesFractional>; +template class TwoFluidNavierStokesFractional>; + +} // namespace Kratos \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp new file mode 100644 index 000000000000..c45d42ad8a49 --- /dev/null +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp @@ -0,0 +1,363 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main author: Uxue Chasco Goñi +// + +#include "vectorial_convection_fractional_element.h" + +namespace Kratos +{ + + /***********************************************************************************/ + /***********************************************************************************/ + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId) : Element(NewId) + { + } + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + { + } + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + { + } + + template + VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + { + } + + template + VectorialConvectionFractionalElement::~VectorialConvectionFractionalElement() + { + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + Element::Pointer VectorialConvectionFractionalElement::Create( + IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const + { + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + } + + /***********************************************************************************/ + + template + Element::Pointer VectorialConvectionFractionalElement::Create( + IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const + { + return Kratos::make_intrusive(NewId, pGeom, pProperties); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + { + KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); + } + + template + void VectorialConvectionFractionalElement::CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) + { + + if (rLeftHandSideMatrix.size1() != LocalSize) + rLeftHandSideMatrix.resize(LocalSize, LocalSize, false); + + if (rRightHandSideVector.size() != LocalSize) + rRightHandSideVector.resize(LocalSize, false); + + noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize); + noalias(rRightHandSideVector) = ZeroVector(LocalSize); + + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Iterate over integration points to evaluate local contribution + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + // Iterate over integration points to evaluate local contribution + for (unsigned int g = 0; g < number_of_gauss_points; ++g) + { + UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const + { + rData.UpdateGeometryValues(IntegrationPointIndex, Weight, rN, rDN_DX); + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + void VectorialConvectionFractionalElement::AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) + { + this->ComputeGaussPointLHSContribution(rData, rLHS); + this->ComputeGaussPointRHSContribution(rData, rRHS); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::CalculateGeometryData(Vector &rGaussWeights, + Matrix &rNContainer, + ShapeFunctionDerivativesArrayType &rDN_DX) const + { + const GeometryData::IntegrationMethod integration_method = this->GetIntegrationMethod(); + const GeometryType &r_geometry = this->GetGeometry(); + const unsigned int number_of_gauss_points = r_geometry.IntegrationPointsNumber(integration_method); + + Vector DetJ; + r_geometry.ShapeFunctionsIntegrationPointsGradients(rDN_DX, DetJ, integration_method); + + if (rNContainer.size1() != number_of_gauss_points || rNContainer.size2() != NumNodes) + { + rNContainer.resize(number_of_gauss_points, NumNodes, false); + } + rNContainer = r_geometry.ShapeFunctionsValues(integration_method); + + const GeometryType::IntegrationPointsArrayType &IntegrationPoints = r_geometry.IntegrationPoints(integration_method); + + if (rGaussWeights.size() != number_of_gauss_points) + { + rGaussWeights.resize(number_of_gauss_points, false); + } + + for (unsigned int g = 0; g < number_of_gauss_points; g++) + rGaussWeights[g] = DetJ[g] * IntegrationPoints[g].Weight(); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + MatrixType &rLHS) + { + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double dyn_tau = rData.DynamicTau; + const auto vfrac = rData.Velocity_Fractional; + const auto vn = rData.Velocity_OldStep1; + const auto vmesh = rData.MeshVelocity; + const auto vconv = vfrac-vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + //substitute_lhs_2D + // Add intermediate results to local system. + noalias(rLHS) += lhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + MatrixType &rLHS) + { + + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const auto vn = rData.Velocity_OldStep1; + const auto vfrac = rData.Velocity_Fractional; + const auto vmesh = rData.MeshVelocity; + const auto vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &lhs = rData.lhs; + + //substitute_lhs_3D + // Add intermediate results to local system. + noalias(rLHS) += lhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + VectorType &rRHS) + { + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double bdf1 = rData.bdf1; + const double bdf2 = rData.bdf2; + + const double dyn_tau = rData.DynamicTau; + + const auto &vn = rData.Velocity_OldStep1; + + const auto &vnnn = rData.Velocity_OldStep3; + const auto &vnn = rData.Velocity_OldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &rhs = rData.rhs; + + //substitute_rhs_2D + //Add intermediate results to local system. + noalias(rRHS) += rhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + VectorType &rRHS) + { + + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double bdf1 = rData.bdf1; + const double bdf2 = rData.bdf2; + const double dyn_tau = rData.DynamicTau; + const auto &vn = rData.Velocity_OldStep1; + const auto &vnn = rData.Velocity_OldStep2; + const auto &vnnn = rData.Velocity_OldStep3; + const auto &vmesh = rData.MeshVelocity; + const auto vfrac = rData.Velocity_Fractional; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Stabilization parameters + constexpr double stab_c2 = 2.0; + + auto &rhs = rData.rhs; + + //substitute_rhs_3D + + // Add intermediate results to local system. + noalias(rRHS) += rhs * rData.Weight; + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void VectorialConvectionFractionalElement::EquationIdVector( + EquationIdVectorType &rResult, + const ProcessInfo &rCurrentProcessInfo) const + { + const GeometryType &r_geometry = this->GetGeometry(); + + unsigned int LocalIndex = 0; + + if (rResult.size() != LocalSize) + rResult.resize(LocalSize, false); + + const unsigned int xpos = this->GetGeometry()[0].GetDofPosition(FRACTIONAL_VELOCITY_X); + + for (unsigned int i = 0; i < NumNodes; ++i) + { + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_X, xpos).EquationId(); + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Y, xpos + 1).EquationId(); + if (Dim == 3) + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Z, xpos + 2).EquationId(); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + void VectorialConvectionFractionalElement::GetDofList( + DofsVectorType &rElementalDofList, + const ProcessInfo &rCurrentProcessInfo) const + { + const GeometryType &r_geometry = this->GetGeometry(); + + if (rElementalDofList.size() != LocalSize) + rElementalDofList.resize(LocalSize); + + const unsigned int xpos = this->GetGeometry()[0].GetDofPosition(FRACTIONAL_VELOCITY_X); + + unsigned int LocalIndex = 0; + for (unsigned int i = 0; i < NumNodes; ++i) + { + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_X, xpos); + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Y, xpos + 1); + if (Dim == 3) + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Z, xpos + 2); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + + /***********************************************************************************/ + /***********************************************************************************/ + template class VectorialConvectionFractionalElement>; + template class VectorialConvectionFractionalElement>; + + /***********************************************************************************/ + /***********************************************************************************/ +} \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp new file mode 100644 index 000000000000..fd5d5947178e --- /dev/null +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -0,0 +1,898 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Uxue Chasco Goñi +// +// + +// System includes +#include + +// External includes + +// Project includes +#include "containers/model.h" +#include "spaces/ublas_space.h" +#include "includes/properties.h" +#include "includes/model_part.h" +#include "includes/global_pointer_variables.h" +#include "utilities/math_utils.h" +#include "utilities/normal_calculation_utils.h" + +// Application includes +#include "custom_elements/two_fluid_navier_stokes_fractional.h" +#include "custom_constitutive/newtonian_2d_law.h" +#include "custom_constitutive/newtonian_3d_law.h" +#include "custom_constitutive/newtonian_two_fluid_3d_law.h" +#include "processes/find_nodal_neighbours_process.h" +#include "tests/cpp_tests/fluid_dynamics_fast_suite.h" + +namespace Kratos { + namespace Testing { + + typedef ModelPart::IndexType IndexType; + typedef ModelPart::NodeIterator NodeIteratorType; + + /** Checks the TwoFluidNavierStokesFractional2D3N element. + * Checks the LHS and RHS computation + */ + + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynamicsApplicationFastSuite) + { + + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,0.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for(unsigned int i=0; i<3; i++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9,9); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0), 285.327812743, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),-75.7286708218, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), 0.678487936315, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),-758.586246712, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -529.046820664, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), -0.808596445975, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -549.320499823, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), -931.191955616, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -0.0198914903401, 1e-7); + } + + // /** Checks the TwoFluidNavierStokesFractional3D4N element + // * Checks the LHS and RHS for a cut element + // */ + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDynamicsApplicationFastSuite) + { + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4,3); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; + vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for(unsigned int i=0; i<4; i++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for(unsigned int k=0; k<3; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16,16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + std::cout << std::setprecision(12) << RHS << std::endl; + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + KRATOS_EXPECT_NEAR(RHS(0), -182.780712656, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), -5.97373013, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), -366.425812874, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 0.136180451508, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -65.5996318562, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),-195.157657105, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -732.8993499, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), 0.228653068676, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -30.1350973711, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), -309.557107994, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), -744.055344314, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), -0.182507276303, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12), 4.70728308942, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13), -259.815870553, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14), -872.015239241, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15), -0.282326243881, 1e-7); + } + + + // /** Checks the TwoFluidNavierStokesFractional3D4N element + // * Checks the LHS and RHS for a negative element (distance <= 0.0) + // */ + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, FluidDynamicsApplicationFastSuite) + { + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes{ 1, 2, 3, 4 }; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = -1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),64.3649724019, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2),130.747961753, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),1.82139199133, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4),-173.148878249, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),-263.100173027, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6),-1019.86139378, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7),-0.231551322358, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8),-198.517992416, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9),-320.806050475, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10),-1153.91463291, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11),-0.36014021379, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12),-233.824784725, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13),-357.542877174, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14),-1300.79220817, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15),-1.32970045518 , 1e-7); + } + + // /** Checks the TwoFluidNavierStokesFractional3D4N element + // * Checks the LHS and RHS for a positive element (distance > 0.0) + // */ + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, FluidDynamicsApplicationFastSuite) + { + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes{ 1, 2, 3, 4 }; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + // std::cout<< std::setprecision(12) << RHS << std::endl; + KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), 64.3649724019, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), 130.747961753, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 1.82139199133, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -173.148878249, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), -263.100173027, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -1019.86139378, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), -0.231551322358, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -198.517992416, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), -320.806050475, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), -1153.91463291, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), -0.36014021379, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12), -233.824784725, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13), -357.542877174, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14), -1300.79220817, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15), -1.32970045518, 1e-7); + } + + /** Checks the TwoFluidNavierStokesFractional2D3N element in a hydrostatic case. + * Checks the computation of the RHS + */ + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, FluidDynamicsApplicationFastSuite) + { + + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-03); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 2.0, 0.0, 0.0); // 0 = node 1 + modelPart.CreateNewNode(2, 2.0, 2.0, 0.0); // 1 = node 2 + modelPart.CreateNewNode(3, 0.0, 2.0, 0.0); // 2 = node 3 + + std::vector elemNodes1 {1, 2, 3}; + + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes1, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values as 0 for hydrostatic case + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.0; + vel_original(1,0) = 0.0; vel_original(1,1) = 0.0; + vel_original(2,0) = 0.0; vel_original(2,1) = 0.0; + + // Setting equal nodal values for DENSITY, DYNAMIC_VISCOSITY, BODY_FORCE + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_X) = 0.0; + it_node->FastGetSolutionStepValue(BODY_FORCE_Y) = -10.0; + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = 0.0; + } + + // Setting the density (different for nodes since element cut by surface) + pElement->GetGeometry()[0].FastGetSolutionStepValue(DENSITY) = 2.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DENSITY) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DENSITY) = 1.0; + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + + pElement->GetGeometry()[0].Fix(VELOCITY_X); + pElement->GetGeometry()[0].Fix(VELOCITY_Y); + + // Setting the density (different for nodes to define the position of the surface) + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Simon : Setting the pressure + pElement->GetGeometry()[0].FastGetSolutionStepValue(PRESSURE) = 30.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(PRESSURE) = 0.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(PRESSURE) = 0.0; + + pElement->GetGeometry()[0].Fix(PRESSURE); + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9,9); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + double det; + MathUtils::InvertMatrix(LHS, LHS, det); + + const Vector solVec = prod(LHS, RHS); + + // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. + // If the "standard" pressure shape functions are used, the results do not hold. + // std::cout<< std::setprecision(12) << RHS << std::endl; + KRATOS_EXPECT_NEAR(RHS(0), 0.0, 1e-7); // U_x at node 1 + KRATOS_EXPECT_NEAR(RHS(1), -17.5, 1e-7); // U_y at node 1 + KRATOS_EXPECT_NEAR(RHS(2), 0.0, 1e-7); // P at node 1 + + KRATOS_EXPECT_NEAR(RHS(3), 7.5, 1e-7); // U_x at node 2 + KRATOS_EXPECT_NEAR(RHS(4), 0.0, 1e-7); // U_y at node 2 + KRATOS_EXPECT_NEAR(RHS(5), 0.0, 1e-7); // P at node 2 + + KRATOS_EXPECT_NEAR(RHS(6), -7.5, 1e-7); // U_x at node 3 + KRATOS_EXPECT_NEAR(RHS(7), -7.5, 1e-7); // U_y at node 3 + KRATOS_EXPECT_NEAR(RHS(8), 0.0, 1e-7); // P at node 3 + } + + + // Giving a value different to zero to source term in order to test it. + + // /** Checks the TwoFluidNavierStokeFractional2D3N element with a source term in mass conservation equation + // * Checks the LHS and RHS for a cut element + // */ + + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NError, FluidDynamicsApplicationFastSuite) + { + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,10.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3, 2); + vel_original(0, 0) = 0.0; + vel_original(0, 1) = 0.1; + vel_original(1, 0) = 0.1; + vel_original(1, 1) = 0.2; + vel_original(2, 0) = 0.2; + vel_original(2, 1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) + { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 3; i++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 2; k++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9, 9); + + const auto &r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + Vector reference_RHS = ZeroVector(9); + reference_RHS[0] = 6075.49; + reference_RHS[1] = 4684.29; + reference_RHS[2] = -27.713; + reference_RHS[3] = -6671.02; + reference_RHS[4] = 1521.5; + reference_RHS[5] = -16.8578; + reference_RHS[6] = -241.804; + reference_RHS[7] = -4409.55; + reference_RHS[8] = -5.5792; + + KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); + } + + // /** Checks the TwoFluidNavierStokesFractional3D4N element with a source term in mass conservation equation + // * Checks the LHS and RHS for a cut element + // */ + + KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, FluidDynamicsApplicationFastSuite) + { + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 10.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; + vel_original(0, 1) = 0.1; + vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; + vel_original(1, 1) = 0.2; + vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; + vel_original(2, 1) = 0.3; + vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; + vel_original(3, 1) = 0.4; + vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) + { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto &r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + Vector reference_RHS = ZeroVector(16); + reference_RHS[0] = 3885.7277179; + reference_RHS[1] = 2853.21656651; + reference_RHS[2] = 3702.08261768; + reference_RHS[3] = -5.3352875285; + reference_RHS[4] = -4028.70584416; + reference_RHS[5] = 302.05648046; + reference_RHS[6] = -945.708093278; + reference_RHS[7] = -3.93555167259; + reference_RHS[8] = 47.4447861701; + reference_RHS[9] = -3601.6349217; + reference_RHS[10] = -666.475460772; + reference_RHS[11] = -3.04929648043; + reference_RHS[12] = -176.79766346; + reference_RHS[13] = 455.783986472; + reference_RHS[14] = -4803.81765472; + reference_RHS[15] = -4.44653098515; + + KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); + } + } // namespace Testing +} // namespace Kratos. diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp new file mode 100644 index 000000000000..0aced7a5e75e --- /dev/null +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp @@ -0,0 +1,233 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Uxue Chasco Goñi +// +// + +// System includes +#include + +// External includes + +// Project includes +#include "containers/model.h" +#include "spaces/ublas_space.h" +#include "includes/properties.h" +#include "includes/model_part.h" +#include "includes/global_pointer_variables.h" +#include "utilities/math_utils.h" +#include "utilities/normal_calculation_utils.h" + +// Application includes +#include "custom_elements/vectorial_convection_fractional_element.h" +#include "processes/find_nodal_neighbours_process.h" +#include "tests/cpp_tests/fluid_dynamics_fast_suite.h" + +namespace Kratos { + namespace Testing { + + typedef ModelPart::IndexType IndexType; + typedef ModelPart::NodeIterator NodeIteratorType; + + /** Checks the VectorialConvectionFractional2D3N element. + * Checks the LHS and RHS computation + */ + + KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional2D3N, FluidDynamicsApplicationFastSuite) + { + + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + // Variables addition + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + + // Process info creation + const int buffer_size = 3; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("VectorialConvectionFractionalElement2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY);; + } + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + + // Compute RHS and LHS + Vector RHS = ZeroVector(6); + Matrix LHS = ZeroMatrix(6,6); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + // std::cout << std::setprecision(12) << RHS << std::endl; + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0),0.0897168467616, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),0.176984086786, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2),0.398616486572, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),0.786349246548, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4),0.475841396524, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),0.938690536488, 1e-7); + } + + // /** Checks the VectorialConvectionFractional3D4N element + // * Checks the LHS and RHS for a cut element + // */ + KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional3D4N, FluidDynamicsApplicationFastSuite) + { + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 3; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + + // Variables addition + + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("VectorialConvectionFractionalElement3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4,3); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; + vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + + } + + for(unsigned int i=0; i<4; i++){ + for(unsigned int k=0; k<3; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + + // Compute RHS and LHS + Vector RHS = ZeroVector(12); + Matrix LHS = ZeroMatrix(12,12); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0), -0.0137395522001, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), -0.0223513234274, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), -0.0309630946547, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 0.1489635261, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), 0.242331911714, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), 0.335700297327, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), 0.167041645911, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), 0.271741160063, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), 0.376440674214, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), 0.185119765722, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), 0.301150408412, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), 0.417181051101, 1e-7); + + } + + + + } // namespace Testing +} // namespace Kratos. From 9b0b81785be88bb203d0cfefe85788d43147fb89 Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 19 Dec 2024 14:57:55 +0100 Subject: [PATCH 02/13] fixing unused variables and droplets methods --- .../two_fluid_navier_stokes_fractional_data.h | 2 +- ...orial_convection_fractional_element_data.h | 1 - .../two_fluid_navier_stokes_fractional.cpp | 297 +----------------- .../two_fluid_navier_stokes_fractional.h | 62 +--- ...ectorial_convection_fractional_element.cpp | 6 +- .../vectorial_convection_fractional_element.h | 2 +- ...luid_navier_stokes_fractional_template.cpp | 297 +----------------- ...convection_fractional_element_template.cpp | 6 +- ...fluid_fractional_navier_stokes_element.cpp | 2 +- ...ectorial_convection_fractional_element.cpp | 2 +- 10 files changed, 21 insertions(+), 656 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h index cbbc6ca5f14e..180107077256 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main authors: Uxue Chasco Goñi +// Main authors: Uxue Chasco // diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h index 5605e1a75bfb..0f897b76ed24 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h @@ -76,7 +76,6 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri const Geometry< Node >& r_geometry = rElement.GetGeometry(); - const Properties& r_properties = rElement.GetProperties(); this->FillFromHistoricalNodalData(Velocity_OldStep1,VELOCITY,r_geometry,1); this->FillFromHistoricalNodalData(Velocity_OldStep2,VELOCITY,r_geometry,2); // this->FillFromHistoricalNodalData(Velocity_OldStep3, VELOCITY, r_geometry, 3); // Old step acceleration approximation using BDF2 diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp index 1f89dd0ebe04..3cbd5a12234b 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Autor: Uxue Chasco Goñi +// Autor: Uxue Chasco // #include "two_fluid_navier_stokes_fractional.h" @@ -156,90 +156,14 @@ void TwoFluidNavierStokesFractional::CalculateLocalSystem( this->ComputeGaussPointEnrichmentContributions(data, Vtot, Htot, Kee_tot, rhs_ee_tot); } - Matrix int_shape_function, int_shape_function_enr_neg, int_shape_function_enr_pos; + GeometryType::ShapeFunctionsGradientsType int_shape_derivatives; Vector int_gauss_pts_weights; std::vector< array_1d > int_normals_neg; - if (rCurrentProcessInfo[SURFACE_TENSION] || rCurrentProcessInfo[MOMENTUM_CORRECTION]){ - ComputeSplitInterface( - data, - int_shape_function, - int_shape_function_enr_pos, - int_shape_function_enr_neg, - int_shape_derivatives, - int_gauss_pts_weights, - int_normals_neg, - p_modified_sh_func); - } + // Without pressure gradient stabilization, volume ratio is checked during condensation + CondenseEnrichmentWithContinuity(data, rLeftHandSideMatrix, rRightHandSideVector, Htot, Vtot, Kee_tot, rhs_ee_tot); - if (rCurrentProcessInfo[MOMENTUM_CORRECTION]){ - BoundedMatrix lhs_acc_correction = ZeroMatrix(LocalSize,LocalSize); - - double positive_density = 0.0; - double negative_density = 0.0; - - const auto& r_geom = this->GetGeometry(); - - for (unsigned int intgp = 0; intgp < int_gauss_pts_weights.size(); ++intgp){ - double u_dot_n = 0.0; - for (unsigned int i = 0; i < NumNodes; ++i){ - u_dot_n += int_shape_function(intgp,i)*r_geom[i].GetValue(DISTANCE_CORRECTION); - - if (data.Distance[i] > 0.0){ - positive_density = data.NodalDensity[i]; - } else { - negative_density = data.NodalDensity[i]; - } - } - - u_dot_n /= data.DeltaTime; - - for (unsigned int i = 0; i < NumNodes; ++i){ - for (unsigned int j = 0; j < NumNodes; ++j){ - for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ - lhs_acc_correction( i*(NumNodes) + dim, j*(NumNodes) + dim) += - int_shape_function(intgp,i)*int_shape_function(intgp,j)*u_dot_n*int_gauss_pts_weights(intgp); - } - } - } - } - - lhs_acc_correction = (negative_density - positive_density)*lhs_acc_correction; - noalias(rLeftHandSideMatrix) += lhs_acc_correction; - - Kratos::array_1d tempU; // Unknowns vector containing only velocity components - for (unsigned int i = 0; i < NumNodes; ++i){ - for (unsigned int dimi = 0; dimi < Dim; ++dimi){ - tempU[i*(Dim+1) + dimi] = data.Velocity(i,dimi); - } - } - noalias(rRightHandSideVector) -= prod(lhs_acc_correction,tempU); - } - - if (rCurrentProcessInfo[SURFACE_TENSION]){ - - AddSurfaceTensionContribution( - data, - int_shape_function, - int_shape_function_enr_pos, - int_shape_function_enr_neg, - int_shape_derivatives, - int_gauss_pts_weights, - int_normals_neg, - rLeftHandSideMatrix, - rRightHandSideVector, - Htot, - Vtot, - Kee_tot, - rhs_ee_tot - ); - - } else{ - // Without pressure gradient stabilization, volume ratio is checked during condensation - // Also, without surface tension, zero pressure difference is penalized - CondenseEnrichmentWithContinuity(data, rLeftHandSideMatrix, rRightHandSideVector, Htot, Vtot, Kee_tot, rhs_ee_tot); - } } } else { @@ -314,7 +238,7 @@ const Parameters TwoFluidNavierStokesFractional::GetSpecifications }, "required_polynomial_degree_of_geometry" : 1, "documentation" : - "This element implements Navier-Stokes biphasic fluid-air formulation with a levelset-based interface representation with Variational MultiScales (VMS) stabilization. Note that any viscous behavior can be used for the fluid phase through a constitutive law. The air phase is assumed to be Newtonian. Surface tension contribution can be accounted for by setting the SURFACE_TENSION variable to true in the ProcessInfo container. + "This element implements Navier-Stokes biphasic fluid-air formulation with a levelset-based interface representation with Variational MultiScales (VMS) stabilization. Note that any viscous behavior can be used for the fluid phase through a constitutive law. The air phase is assumed to be Newtonian. })"); if (Dim == 2) { @@ -2225,172 +2149,6 @@ ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNa return Kratos::make_unique(pGeometry, rDistances); } -template -void TwoFluidNavierStokesFractional::CalculateCurvatureOnInterfaceGaussPoints( - const Matrix& rInterfaceShapeFunctions, - Vector& rInterfaceCurvature) -{ - const auto& r_geom = this->GetGeometry(); - const unsigned int n_gpt = rInterfaceShapeFunctions.size1(); - - rInterfaceCurvature.resize(n_gpt, false); - - for (unsigned int gpt = 0; gpt < n_gpt; ++gpt){ - double curvature = 0.0; - for (unsigned int i = 0; i < NumNodes; ++i){ - curvature += rInterfaceShapeFunctions(gpt,i) * r_geom[i].GetValue(CURVATURE); - } - rInterfaceCurvature[gpt] = curvature; - } -} - -template -void TwoFluidNavierStokesFractional::SurfaceTension( - const double SurfaceTensionCoefficient, - const Vector& rCurvature, - const Vector& rInterfaceWeights, - const Matrix& rInterfaceShapeFunctions, - const std::vector>& rInterfaceNormalsNeg, - VectorType& rRHS) -{ - for (unsigned int intgp = 0; intgp < rInterfaceWeights.size(); ++intgp){ - const double intgp_curv = rCurvature(intgp); - const double intgp_w = rInterfaceWeights(intgp); - const auto& intgp_normal = rInterfaceNormalsNeg[intgp]; - for (unsigned int j = 0; j < NumNodes; ++j){ - for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ - rRHS[ j*(NumNodes) + dim ] -= SurfaceTensionCoefficient*intgp_normal[dim] - *intgp_curv*intgp_w*rInterfaceShapeFunctions(intgp,j); - } - } - } -} - -template -void TwoFluidNavierStokesFractional::PressureGradientStabilization( - const TElementData& rData, - const Vector& rInterfaceWeights, - const Matrix& rEnrInterfaceShapeFunctionPos, - const Matrix& rEnrInterfaceShapeFunctionNeg, - const GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, - MatrixType& rKeeTot, - VectorType& rRHSeeTot) -{ - MatrixType kee = ZeroMatrix(NumNodes, NumNodes); - VectorType rhs_enr = ZeroVector(NumNodes); - - Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); - Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); - - double positive_density = 0.0; - double negative_density = 0.0; - double positive_viscosity = 0.0; - double negative_viscosity = 0.0; - - for (unsigned int i = 0; i < NumNodes; ++i){ - if (rData.Distance[i] > 0.0){ - enr_neg_interp(i, i) = 1.0; - positive_density = rData.NodalDensity[i]; - positive_viscosity = rData.NodalDynamicViscosity[i]; - } else{ - enr_pos_interp(i, i) = 1.0; - negative_density = rData.NodalDensity[i]; - negative_viscosity = rData.NodalDynamicViscosity[i]; - } - } - - GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesPos = rInterfaceShapeDerivatives; - GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesNeg = rInterfaceShapeDerivatives; - - for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ - EnrichedInterfaceShapeDerivativesPos[i] = prod(enr_pos_interp, rInterfaceShapeDerivatives[i]); - } - - for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ - EnrichedInterfaceShapeDerivativesNeg[i] = prod(enr_neg_interp, rInterfaceShapeDerivatives[i]); - } - - double positive_volume = 0.0; - double negative_volume = 0.0; - for (unsigned int igauss_pos = 0; igauss_pos < rData.w_gauss_pos_side.size(); ++igauss_pos){ - positive_volume += rData.w_gauss_pos_side[igauss_pos]; - } - - for (unsigned int igauss_neg = 0; igauss_neg < rData.w_gauss_neg_side.size(); ++igauss_neg){ - negative_volume += rData.w_gauss_neg_side[igauss_neg]; - } - const double element_volume = positive_volume + negative_volume; - - const auto& r_geom = this->GetGeometry(); - const double h_elem = rData.ElementSize; - - double cut_area = 0.0; - for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ - cut_area += rInterfaceWeights[gp]; - } - - const double density = 1.0/(1.0/positive_density + 1.0/negative_density); - const double viscosity = 1.0/(1.0/positive_viscosity + 1.0/negative_viscosity); - - // Stabilization parameters - const double cut_stabilization_coefficient = 1.0; - const double stab_c1 = 4.0; - const double stab_c2 = 2.0; - const double dyn_tau = rData.DynamicTau; - - const double dt = rData.DeltaTime; - - // const auto v_convection = rData.Velocity - rData.Velocity_OldStep1; - const auto v_convection = rData.Velocity - rData.MeshVelocity; - - for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ - - Vector vconv = ZeroVector(Dim); - double positive_weight = 0.0; - double negative_weight = 0.0; - - for (unsigned int j = 0; j < NumNodes; ++j){ - for (unsigned int dim = 0; dim < Dim; ++dim){ - vconv[dim] += (rEnrInterfaceShapeFunctionNeg(gp, j) + rEnrInterfaceShapeFunctionPos(gp, j)) - *v_convection(j,dim); - } - positive_weight += rEnrInterfaceShapeFunctionNeg(gp, j); - negative_weight += rEnrInterfaceShapeFunctionPos(gp, j); - } - - const double v_conv_norm = norm_2(vconv); - - const double penalty_coefficient = cut_stabilization_coefficient * - density * 1.0 / (dyn_tau * density / dt + stab_c1 * viscosity / h_elem / h_elem + - stab_c2 * density * v_conv_norm / h_elem) * element_volume / cut_area; - - const auto& r_gp_enriched_interface_shape_derivatives_pos = EnrichedInterfaceShapeDerivativesPos[gp]; - const auto& r_gp_enriched_interface_shape_derivatives_neg = EnrichedInterfaceShapeDerivativesNeg[gp]; - - for (unsigned int i = 0; i < NumNodes; ++i){ - - for (unsigned int j = 0; j < NumNodes; ++j){ - - const auto& r_pressure_gradient_j = r_geom[j].GetValue(PRESSURE_GRADIENT); - - for (unsigned int dim = 0; dim < Dim; ++dim){ - kee(i, j) += penalty_coefficient * rInterfaceWeights[gp] * - ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* - ( r_gp_enriched_interface_shape_derivatives_pos(j,dim) - r_gp_enriched_interface_shape_derivatives_neg(j,dim) ); - - rhs_enr(i) += penalty_coefficient * rInterfaceWeights[gp] * - ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* - (rEnrInterfaceShapeFunctionNeg(gp, j)/positive_weight - rEnrInterfaceShapeFunctionPos(gp, j)/negative_weight)* - r_pressure_gradient_j(dim); - } - } - } - } - - noalias(rKeeTot) += kee; - noalias(rRHSeeTot) += rhs_enr; -} - template void TwoFluidNavierStokesFractional::CalculateStrainRate(TElementData& rData) const { @@ -2487,51 +2245,6 @@ void TwoFluidNavierStokesFractional::CondenseEnrichment( noalias(rRightHandSideVector) -= prod(rVtot, tmp2); } -template -void TwoFluidNavierStokesFractional::AddSurfaceTensionContribution( - const TElementData& rData, - MatrixType& rInterfaceShapeFunction, - MatrixType& rEnrInterfaceShapeFunctionPos, - MatrixType& rEnrInterfaceShapeFunctionNeg, - GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, - Vector& rInterfaceWeights, - std::vector< array_1d >& rInterfaceNormalsNeg, - Matrix &rLeftHandSideMatrix, - VectorType &rRightHandSideVector, - const MatrixType &rHtot, - const MatrixType &rVtot, - MatrixType &rKeeTot, - VectorType &rRHSeeTot) -{ - // Surface tension coefficient is set in material properties - const double surface_tension_coefficient = this->GetProperties().GetValue(SURFACE_TENSION_COEFFICIENT); - - Vector gauss_pts_curvature; // curvatures calculated on interface Gauss points - - CalculateCurvatureOnInterfaceGaussPoints( - rInterfaceShapeFunction, - gauss_pts_curvature); - - SurfaceTension( - surface_tension_coefficient, - gauss_pts_curvature, - rInterfaceWeights, - rInterfaceShapeFunction, - rInterfaceNormalsNeg, - rRightHandSideVector); - - this->PressureGradientStabilization( - rData, - rInterfaceWeights, - rEnrInterfaceShapeFunctionPos, - rEnrInterfaceShapeFunctionNeg, - rInterfaceShapeDerivatives, - rKeeTot, - rRHSeeTot); - - CondenseEnrichment(rLeftHandSideMatrix, rRightHandSideVector, rHtot, rVtot, rKeeTot, rRHSeeTot); -} - template void TwoFluidNavierStokesFractional::save(Serializer &rSerializer) const { diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h index 8b0575c16a4e..aaf76b83cbb0 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main author: Uxue Chasco Goñi +// Main author: Uxue Chasco // Co-authors: Ruben Zorrilla // @@ -355,24 +355,6 @@ namespace Kratos const typename TElementData::MatrixRowType &rNenr, const typename TElementData::ShapeDerivativesType &rDN_DXenr) const; - /** - * @brief Computes the enriched LHS/RHS terms associated with the pressure stabilizations at the interface - * @param rInterfaceWeightsNeg Negative side weights for the interface-gauss-points - * @param rEnrInterfaceShapeFunctionPos Enriched shape functions at the interface-gauss-points Positive side - * @param rEnrInterfaceShapeFunctionNeg Enriched shape functions at the interface-gauss-points Negative side - * @param rInterfaceShapeDerivativesNeg Shape functions derivatives at the interface-gauss-points - * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs - * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs - */ - virtual void PressureGradientStabilization( - const TElementData &rData, - const Vector &rInterfaceWeights, - const Matrix &rEnrInterfaceShapeFunctionPos, - const Matrix &rEnrInterfaceShapeFunctionNeg, - const GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivatives, - MatrixType &rKeeTot, - VectorType &rRHSeeTot); - /** * @brief Calculate the strain rate * In this function we calculate the strain rate at the mid step @@ -470,33 +452,6 @@ namespace Kratos ModifiedShapeFunctions::UniquePointer pGetModifiedShapeFunctionsUtility( const GeometryType::Pointer pGeometry, const Vector &rDistances); - - /** - * @brief Calculates curvature at the gauss points of the interface. - * @param rInterfaceCurvature Vector containing curvature values at the gauss points - * @param rInterfaceShapeFunctions Shape functions calculated at the interface gauss points - */ - void CalculateCurvatureOnInterfaceGaussPoints( - const Matrix &rInterfaceShapeFunctions, - Vector &rInterfaceCurvature); - - /** - * @brief Computes the surface tension on the interface and implement its effect on the RHS vector - * @param SurfaceTensionCoefficient surface tension coefficient - * @param rCurvature curvature calculated at the interface gauss points - * @param rInterfaceWeights Weights associated with interface gauss points - * @param rInterfaceShapeFunctions Shape functions calculated at the interface gauss points - * @param rInterfaceNormalsNeg Normal vectors (negative side) associated with interface gauss points - * @param rRHS The effect of pressure discontinuity is implemented as an interfacial integral on the RHS - */ - void SurfaceTension( - const double SurfaceTensionCoefficient, - const Vector &rCurvature, - const Vector &rInterfaceWeights, - const Matrix &rInterfaceShapeFunctions, - const std::vector> &rInterfaceNormalsNeg, - VectorType &rRHS); - /** * @brief Condense the enrichment * This method performs the static condensation of the enrichment terms, by adding @@ -539,21 +494,6 @@ namespace Kratos MatrixType &rKeeTot, const VectorType &rRHSeeTot); - void AddSurfaceTensionContribution( - const TElementData &rData, - MatrixType &rInterfaceShapeFunction, - MatrixType &rEnrInterfaceShapeFunctionPos, - MatrixType &rEnrInterfaceShapeFunctionNeg, - GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivatives, - Vector &rInterfaceWeights, - std::vector> &rInterfaceNormalsNeg, - Matrix &rLeftHandSideMatrix, - VectorType &rRightHandSideVector, - const MatrixType &rHtot, - const MatrixType &rVtot, - MatrixType &rKeeTot, - VectorType &rRHSeeTot); - ///@} ///@name Private Access ///@{ diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp index e05779ee97c6..406abfa9d8a1 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main author: Uxue Chasco Goñi +// Main author: Uxue Chasco // #include "vectorial_convection_fractional_element.h" @@ -500,7 +500,7 @@ lhs(11,11)=clhs45; const auto &vn = rData.Velocity_OldStep1; - const auto &vnnn = rData.Velocity_OldStep3; + // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vnn = rData.Velocity_OldStep2; const auto &vmesh = rData.MeshVelocity; const auto vfrac = rData.Velocity_Fractional; @@ -578,7 +578,7 @@ rhs[5]=-N[2]*crhs24 + N[2]*crhs27 - N[2]*crhs28 + crhs23*crhs33 - crhs29*crhs34 const double dyn_tau = rData.DynamicTau; const auto &vn = rData.Velocity_OldStep1; const auto &vnn = rData.Velocity_OldStep2; - const auto &vnnn = rData.Velocity_OldStep3; + // const auto &vnnn = rData.Velocity_OldStep3; #an_bdf2 const auto &vmesh = rData.MeshVelocity; const auto vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h index 494e2d572b93..a9130705162f 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main authors: Uxue Chasco Goñi +// Main authors: Uxue Chasco // // // diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp index 888fd2bc0d93..038280c5cfe9 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Autor: Uxue Chasco Goñi +// Autor: Uxue Chasco // #include "two_fluid_navier_stokes_fractional.h" @@ -156,90 +156,14 @@ void TwoFluidNavierStokesFractional::CalculateLocalSystem( this->ComputeGaussPointEnrichmentContributions(data, Vtot, Htot, Kee_tot, rhs_ee_tot); } - Matrix int_shape_function, int_shape_function_enr_neg, int_shape_function_enr_pos; + GeometryType::ShapeFunctionsGradientsType int_shape_derivatives; Vector int_gauss_pts_weights; std::vector< array_1d > int_normals_neg; - if (rCurrentProcessInfo[SURFACE_TENSION] || rCurrentProcessInfo[MOMENTUM_CORRECTION]){ - ComputeSplitInterface( - data, - int_shape_function, - int_shape_function_enr_pos, - int_shape_function_enr_neg, - int_shape_derivatives, - int_gauss_pts_weights, - int_normals_neg, - p_modified_sh_func); - } + // Without pressure gradient stabilization, volume ratio is checked during condensation + CondenseEnrichmentWithContinuity(data, rLeftHandSideMatrix, rRightHandSideVector, Htot, Vtot, Kee_tot, rhs_ee_tot); - if (rCurrentProcessInfo[MOMENTUM_CORRECTION]){ - BoundedMatrix lhs_acc_correction = ZeroMatrix(LocalSize,LocalSize); - - double positive_density = 0.0; - double negative_density = 0.0; - - const auto& r_geom = this->GetGeometry(); - - for (unsigned int intgp = 0; intgp < int_gauss_pts_weights.size(); ++intgp){ - double u_dot_n = 0.0; - for (unsigned int i = 0; i < NumNodes; ++i){ - u_dot_n += int_shape_function(intgp,i)*r_geom[i].GetValue(DISTANCE_CORRECTION); - - if (data.Distance[i] > 0.0){ - positive_density = data.NodalDensity[i]; - } else { - negative_density = data.NodalDensity[i]; - } - } - - u_dot_n /= data.DeltaTime; - - for (unsigned int i = 0; i < NumNodes; ++i){ - for (unsigned int j = 0; j < NumNodes; ++j){ - for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ - lhs_acc_correction( i*(NumNodes) + dim, j*(NumNodes) + dim) += - int_shape_function(intgp,i)*int_shape_function(intgp,j)*u_dot_n*int_gauss_pts_weights(intgp); - } - } - } - } - - lhs_acc_correction = (negative_density - positive_density)*lhs_acc_correction; - noalias(rLeftHandSideMatrix) += lhs_acc_correction; - - Kratos::array_1d tempU; // Unknowns vector containing only velocity components - for (unsigned int i = 0; i < NumNodes; ++i){ - for (unsigned int dimi = 0; dimi < Dim; ++dimi){ - tempU[i*(Dim+1) + dimi] = data.Velocity(i,dimi); - } - } - noalias(rRightHandSideVector) -= prod(lhs_acc_correction,tempU); - } - - if (rCurrentProcessInfo[SURFACE_TENSION]){ - - AddSurfaceTensionContribution( - data, - int_shape_function, - int_shape_function_enr_pos, - int_shape_function_enr_neg, - int_shape_derivatives, - int_gauss_pts_weights, - int_normals_neg, - rLeftHandSideMatrix, - rRightHandSideVector, - Htot, - Vtot, - Kee_tot, - rhs_ee_tot - ); - - } else{ - // Without pressure gradient stabilization, volume ratio is checked during condensation - // Also, without surface tension, zero pressure difference is penalized - CondenseEnrichmentWithContinuity(data, rLeftHandSideMatrix, rRightHandSideVector, Htot, Vtot, Kee_tot, rhs_ee_tot); - } } } else { @@ -314,7 +238,7 @@ const Parameters TwoFluidNavierStokesFractional::GetSpecifications }, "required_polynomial_degree_of_geometry" : 1, "documentation" : - "This element implements Navier-Stokes biphasic fluid-air formulation with a levelset-based interface representation with Variational MultiScales (VMS) stabilization. Note that any viscous behavior can be used for the fluid phase through a constitutive law. The air phase is assumed to be Newtonian. Surface tension contribution can be accounted for by setting the SURFACE_TENSION variable to true in the ProcessInfo container. + "This element implements Navier-Stokes biphasic fluid-air formulation with a levelset-based interface representation with Variational MultiScales (VMS) stabilization. Note that any viscous behavior can be used for the fluid phase through a constitutive law. The air phase is assumed to be Newtonian. })"); if (Dim == 2) { @@ -921,172 +845,6 @@ ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNa return Kratos::make_unique(pGeometry, rDistances); } -template -void TwoFluidNavierStokesFractional::CalculateCurvatureOnInterfaceGaussPoints( - const Matrix& rInterfaceShapeFunctions, - Vector& rInterfaceCurvature) -{ - const auto& r_geom = this->GetGeometry(); - const unsigned int n_gpt = rInterfaceShapeFunctions.size1(); - - rInterfaceCurvature.resize(n_gpt, false); - - for (unsigned int gpt = 0; gpt < n_gpt; ++gpt){ - double curvature = 0.0; - for (unsigned int i = 0; i < NumNodes; ++i){ - curvature += rInterfaceShapeFunctions(gpt,i) * r_geom[i].GetValue(CURVATURE); - } - rInterfaceCurvature[gpt] = curvature; - } -} - -template -void TwoFluidNavierStokesFractional::SurfaceTension( - const double SurfaceTensionCoefficient, - const Vector& rCurvature, - const Vector& rInterfaceWeights, - const Matrix& rInterfaceShapeFunctions, - const std::vector>& rInterfaceNormalsNeg, - VectorType& rRHS) -{ - for (unsigned int intgp = 0; intgp < rInterfaceWeights.size(); ++intgp){ - const double intgp_curv = rCurvature(intgp); - const double intgp_w = rInterfaceWeights(intgp); - const auto& intgp_normal = rInterfaceNormalsNeg[intgp]; - for (unsigned int j = 0; j < NumNodes; ++j){ - for (unsigned int dim = 0; dim < NumNodes-1; ++dim){ - rRHS[ j*(NumNodes) + dim ] -= SurfaceTensionCoefficient*intgp_normal[dim] - *intgp_curv*intgp_w*rInterfaceShapeFunctions(intgp,j); - } - } - } -} - -template -void TwoFluidNavierStokesFractional::PressureGradientStabilization( - const TElementData& rData, - const Vector& rInterfaceWeights, - const Matrix& rEnrInterfaceShapeFunctionPos, - const Matrix& rEnrInterfaceShapeFunctionNeg, - const GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, - MatrixType& rKeeTot, - VectorType& rRHSeeTot) -{ - MatrixType kee = ZeroMatrix(NumNodes, NumNodes); - VectorType rhs_enr = ZeroVector(NumNodes); - - Matrix enr_neg_interp = ZeroMatrix(NumNodes, NumNodes); - Matrix enr_pos_interp = ZeroMatrix(NumNodes, NumNodes); - - double positive_density = 0.0; - double negative_density = 0.0; - double positive_viscosity = 0.0; - double negative_viscosity = 0.0; - - for (unsigned int i = 0; i < NumNodes; ++i){ - if (rData.Distance[i] > 0.0){ - enr_neg_interp(i, i) = 1.0; - positive_density = rData.NodalDensity[i]; - positive_viscosity = rData.NodalDynamicViscosity[i]; - } else{ - enr_pos_interp(i, i) = 1.0; - negative_density = rData.NodalDensity[i]; - negative_viscosity = rData.NodalDynamicViscosity[i]; - } - } - - GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesPos = rInterfaceShapeDerivatives; - GeometryType::ShapeFunctionsGradientsType EnrichedInterfaceShapeDerivativesNeg = rInterfaceShapeDerivatives; - - for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ - EnrichedInterfaceShapeDerivativesPos[i] = prod(enr_pos_interp, rInterfaceShapeDerivatives[i]); - } - - for (unsigned int i = 0; i < rInterfaceShapeDerivatives.size(); ++i){ - EnrichedInterfaceShapeDerivativesNeg[i] = prod(enr_neg_interp, rInterfaceShapeDerivatives[i]); - } - - double positive_volume = 0.0; - double negative_volume = 0.0; - for (unsigned int igauss_pos = 0; igauss_pos < rData.w_gauss_pos_side.size(); ++igauss_pos){ - positive_volume += rData.w_gauss_pos_side[igauss_pos]; - } - - for (unsigned int igauss_neg = 0; igauss_neg < rData.w_gauss_neg_side.size(); ++igauss_neg){ - negative_volume += rData.w_gauss_neg_side[igauss_neg]; - } - const double element_volume = positive_volume + negative_volume; - - const auto& r_geom = this->GetGeometry(); - const double h_elem = rData.ElementSize; - - double cut_area = 0.0; - for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ - cut_area += rInterfaceWeights[gp]; - } - - const double density = 1.0/(1.0/positive_density + 1.0/negative_density); - const double viscosity = 1.0/(1.0/positive_viscosity + 1.0/negative_viscosity); - - // Stabilization parameters - const double cut_stabilization_coefficient = 1.0; - const double stab_c1 = 4.0; - const double stab_c2 = 2.0; - const double dyn_tau = rData.DynamicTau; - - const double dt = rData.DeltaTime; - - // const auto v_convection = rData.Velocity - rData.Velocity_OldStep1; - const auto v_convection = rData.Velocity - rData.MeshVelocity; - - for (unsigned int gp = 0; gp < rInterfaceWeights.size(); ++gp){ - - Vector vconv = ZeroVector(Dim); - double positive_weight = 0.0; - double negative_weight = 0.0; - - for (unsigned int j = 0; j < NumNodes; ++j){ - for (unsigned int dim = 0; dim < Dim; ++dim){ - vconv[dim] += (rEnrInterfaceShapeFunctionNeg(gp, j) + rEnrInterfaceShapeFunctionPos(gp, j)) - *v_convection(j,dim); - } - positive_weight += rEnrInterfaceShapeFunctionNeg(gp, j); - negative_weight += rEnrInterfaceShapeFunctionPos(gp, j); - } - - const double v_conv_norm = norm_2(vconv); - - const double penalty_coefficient = cut_stabilization_coefficient * - density * 1.0 / (dyn_tau * density / dt + stab_c1 * viscosity / h_elem / h_elem + - stab_c2 * density * v_conv_norm / h_elem) * element_volume / cut_area; - - const auto& r_gp_enriched_interface_shape_derivatives_pos = EnrichedInterfaceShapeDerivativesPos[gp]; - const auto& r_gp_enriched_interface_shape_derivatives_neg = EnrichedInterfaceShapeDerivativesNeg[gp]; - - for (unsigned int i = 0; i < NumNodes; ++i){ - - for (unsigned int j = 0; j < NumNodes; ++j){ - - const auto& r_pressure_gradient_j = r_geom[j].GetValue(PRESSURE_GRADIENT); - - for (unsigned int dim = 0; dim < Dim; ++dim){ - kee(i, j) += penalty_coefficient * rInterfaceWeights[gp] * - ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* - ( r_gp_enriched_interface_shape_derivatives_pos(j,dim) - r_gp_enriched_interface_shape_derivatives_neg(j,dim) ); - - rhs_enr(i) += penalty_coefficient * rInterfaceWeights[gp] * - ( r_gp_enriched_interface_shape_derivatives_pos(i,dim) - r_gp_enriched_interface_shape_derivatives_neg(i,dim) )* - (rEnrInterfaceShapeFunctionNeg(gp, j)/positive_weight - rEnrInterfaceShapeFunctionPos(gp, j)/negative_weight)* - r_pressure_gradient_j(dim); - } - } - } - } - - noalias(rKeeTot) += kee; - noalias(rRHSeeTot) += rhs_enr; -} - template void TwoFluidNavierStokesFractional::CalculateStrainRate(TElementData& rData) const { @@ -1183,51 +941,6 @@ void TwoFluidNavierStokesFractional::CondenseEnrichment( noalias(rRightHandSideVector) -= prod(rVtot, tmp2); } -template -void TwoFluidNavierStokesFractional::AddSurfaceTensionContribution( - const TElementData& rData, - MatrixType& rInterfaceShapeFunction, - MatrixType& rEnrInterfaceShapeFunctionPos, - MatrixType& rEnrInterfaceShapeFunctionNeg, - GeometryType::ShapeFunctionsGradientsType& rInterfaceShapeDerivatives, - Vector& rInterfaceWeights, - std::vector< array_1d >& rInterfaceNormalsNeg, - Matrix &rLeftHandSideMatrix, - VectorType &rRightHandSideVector, - const MatrixType &rHtot, - const MatrixType &rVtot, - MatrixType &rKeeTot, - VectorType &rRHSeeTot) -{ - // Surface tension coefficient is set in material properties - const double surface_tension_coefficient = this->GetProperties().GetValue(SURFACE_TENSION_COEFFICIENT); - - Vector gauss_pts_curvature; // curvatures calculated on interface Gauss points - - CalculateCurvatureOnInterfaceGaussPoints( - rInterfaceShapeFunction, - gauss_pts_curvature); - - SurfaceTension( - surface_tension_coefficient, - gauss_pts_curvature, - rInterfaceWeights, - rInterfaceShapeFunction, - rInterfaceNormalsNeg, - rRightHandSideVector); - - this->PressureGradientStabilization( - rData, - rInterfaceWeights, - rEnrInterfaceShapeFunctionPos, - rEnrInterfaceShapeFunctionNeg, - rInterfaceShapeDerivatives, - rKeeTot, - rRHSeeTot); - - CondenseEnrichment(rLeftHandSideMatrix, rRightHandSideVector, rHtot, rVtot, rKeeTot, rRHSeeTot); -} - template void TwoFluidNavierStokesFractional::save(Serializer &rSerializer) const { diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp index c45d42ad8a49..c75ba7dbe451 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main author: Uxue Chasco Goñi +// Main author: Uxue Chasco // #include "vectorial_convection_fractional_element.h" @@ -244,7 +244,7 @@ namespace Kratos const auto &vn = rData.Velocity_OldStep1; - const auto &vnnn = rData.Velocity_OldStep3; + // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vnn = rData.Velocity_OldStep2; const auto &vmesh = rData.MeshVelocity; const auto vfrac = rData.Velocity_Fractional; @@ -280,7 +280,7 @@ namespace Kratos const double dyn_tau = rData.DynamicTau; const auto &vn = rData.Velocity_OldStep1; const auto &vnn = rData.Velocity_OldStep2; - const auto &vnnn = rData.Velocity_OldStep3; + // const auto &vnnn = rData.Velocity_OldStep3; #an_bdf2 const auto &vmesh = rData.MeshVelocity; const auto vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index fd5d5947178e..d36281c740fb 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main authors: Uxue Chasco Goñi +// Main authors: Uxue Chasco // // diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp index 0aced7a5e75e..1129474eff5b 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp @@ -7,7 +7,7 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main authors: Uxue Chasco Goñi +// Main authors: Uxue Chasco // // From 0f1454dcd3b7a24cff5f38024c0e5c6b88c461ba Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 19 Dec 2024 15:25:59 +0100 Subject: [PATCH 03/13] fixing CI warning compilation error and adding pragma once --- .../two_fluid_navier_stokes_fractional_data.h | 6 ++---- .../custom_elements/two_fluid_navier_stokes_fractional.h | 6 ++---- .../vectorial_convection_fractional_element.h | 7 +------ .../fluid_dynamics_application.cpp | 4 ++-- .../FluidDynamicsApplication/fluid_dynamics_application.h | 2 +- .../test_two_fluid_fractional_navier_stokes_element.cpp | 6 +++--- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h index 180107077256..289ee7e54dac 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -10,8 +10,8 @@ // Main authors: Uxue Chasco // +#pragma once -#if !defined(KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL_DATA_H) #define KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL_DATA_H #include "includes/constitutive_law.h" @@ -378,6 +378,4 @@ void ComputeDarcyTerm() ///@} -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h index aaf76b83cbb0..010c71d0447f 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h @@ -11,7 +11,7 @@ // Co-authors: Ruben Zorrilla // -#if !defined(KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL) +#pragma once #define KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL // System includes @@ -543,6 +543,4 @@ inline std::ostream& operator <<(std::ostream& rOStream, } ///@} -} // namespace Kratos. - -#endif // KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL \ No newline at end of file +} // namespace Kratos. \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h index a9130705162f..ceb9fef3bb45 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h @@ -12,8 +12,7 @@ // // - -#if !defined(KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT) +#pragma once #define KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT // System includes @@ -312,7 +311,3 @@ class VectorialConvectionFractionalElement: public Element ///@} } // namespace Kratos. - -#endif // KRATOS_LEVELSET_CONVECTION_ELEMENT_SIMPLEX_INCLUDED defined - - diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp index 1d68cdeddec0..9920d28eb730 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp @@ -163,10 +163,10 @@ KratosFluidDynamicsApplication::KratosFluidDynamicsApplication(): mTwoFluidNavierStokesAlphaMethod3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), mTwoFluidNavierStokesWallCondition2D(0, Element::GeometryType::Pointer(new Line2D2(Element::GeometryType::PointsArrayType(2)))), mTwoFluidNavierStokesWallCondition3D(0, Element::GeometryType::Pointer(new Triangle3D3(Element::GeometryType::PointsArrayType(3)))), - mVectorialConvectionFractionalElement2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), - mVectorialConvectionFractionalElement3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), mTwoFluidNavierStokesFractional2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), mTwoFluidNavierStokesFractional3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), + mVectorialConvectionFractionalElement2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), + mVectorialConvectionFractionalElement3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), // Incompressbile Navier-Stokes div-stable elements mIncompressibleNavierStokesP2P1Continuous2D6N(0, Element::GeometryType::Pointer(new Triangle2D6(Element::GeometryType::PointsArrayType(6)))), mIncompressibleNavierStokesP2P1Continuous3D10N(0, Element::GeometryType::Pointer(new Tetrahedra3D10(Element::GeometryType::PointsArrayType(10)))), diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.h b/applications/FluidDynamicsApplication/fluid_dynamics_application.h index 4dab2fd2fe34..37a405543c97 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.h +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.h @@ -461,8 +461,8 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) KratosFluidDynamicsApplication : pu const TwoFluidNavierStokesWallCondition<3,3> mTwoFluidNavierStokesWallCondition3D; const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional2D3N; const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional3D4N; - const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement3D4N; const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement2D3N; + const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement3D4N; /// Incompressible Navier-Stokes div-stable element const IncompressibleNavierStokesP2P1Continuous<2> mIncompressibleNavierStokesP2P1Continuous2D6N; diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index d36281c740fb..1361a4348716 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -4,10 +4,10 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // -// Main authors: Uxue Chasco +// Main authors: Uxue Chasco // // From 49390fbe621fed62196477b4d622d28a776f029d Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 19 Dec 2024 19:20:31 +0100 Subject: [PATCH 04/13] adding Kratos testing --- .../vectorial_convection_fractional_element.h | 3 - ...convection_fractional_element_template.cpp | 5 +- ...fluid_fractional_navier_stokes_element.cpp | 1726 ++++++++--------- ...ectorial_convection_fractional_element.cpp | 6 +- 4 files changed, 867 insertions(+), 873 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h index ceb9fef3bb45..81e578e3af8d 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h @@ -20,11 +20,8 @@ // External includes // Project includes -#include "includes/define.h" -#include "includes/element.h" #include "includes/ublas_interface.h" #include "includes/variables.h" -#include "includes/serializer.h" #include "includes/cfd_variables.h" #include "includes/convection_diffusion_settings.h" #include "utilities/geometry_utilities.h" diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp index c75ba7dbe451..a67873810a29 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp @@ -239,13 +239,10 @@ namespace Kratos const double bdf0 = rData.bdf0; const double bdf1 = rData.bdf1; const double bdf2 = rData.bdf2; - const double dyn_tau = rData.DynamicTau; - const auto &vn = rData.Velocity_OldStep1; - - // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vmesh = rData.MeshVelocity; const auto vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index 1361a4348716..cb645626bcc4 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -33,866 +33,866 @@ #include "processes/find_nodal_neighbours_process.h" #include "tests/cpp_tests/fluid_dynamics_fast_suite.h" -namespace Kratos { - namespace Testing { - - typedef ModelPart::IndexType IndexType; - typedef ModelPart::NodeIterator NodeIteratorType; - - /** Checks the TwoFluidNavierStokesFractional2D3N element. - * Checks the LHS and RHS computation - */ - - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynamicsApplicationFastSuite) - { - - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,0.0); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(3,2); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; - vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; - vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; - - // Set the nodal DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for(unsigned int i=0; i<3; i++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for(unsigned int k=0; k<2; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; - - // Compute RHS and LHS - Vector RHS = ZeroVector(9); - Matrix LHS = ZeroMatrix(9,9); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0), 285.327812743, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),-75.7286708218, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), 0.678487936315, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),-758.586246712, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -529.046820664, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), -0.808596445975, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -549.320499823, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), -931.191955616, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -0.0198914903401, 1e-7); - } - - // /** Checks the TwoFluidNavierStokesFractional3D4N element - // * Checks the LHS and RHS for a cut element - // */ - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDynamicsApplicationFastSuite) - { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4,3); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; - vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; - vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; - vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for(unsigned int i=0; i<4; i++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for(unsigned int k=0; k<3; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16,16); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - std::cout << std::setprecision(12) << RHS << std::endl; - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - KRATOS_EXPECT_NEAR(RHS(0), -182.780712656, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), -5.97373013, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), -366.425812874, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 0.136180451508, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -65.5996318562, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),-195.157657105, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -732.8993499, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), 0.228653068676, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -30.1350973711, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), -309.557107994, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), -744.055344314, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), -0.182507276303, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12), 4.70728308942, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13), -259.815870553, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14), -872.015239241, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15), -0.282326243881, 1e-7); - } - - - // /** Checks the TwoFluidNavierStokesFractional3D4N element - // * Checks the LHS and RHS for a negative element (distance <= 0.0) - // */ - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, FluidDynamicsApplicationFastSuite) - { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes{ 1, 2, 3, 4 }; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4, 3); - vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; - vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; - vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; - vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 4; i++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 3; k++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = -1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16, 16); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),64.3649724019, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2),130.747961753, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),1.82139199133, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4),-173.148878249, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),-263.100173027, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6),-1019.86139378, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7),-0.231551322358, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8),-198.517992416, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9),-320.806050475, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10),-1153.91463291, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11),-0.36014021379, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12),-233.824784725, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13),-357.542877174, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14),-1300.79220817, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15),-1.32970045518 , 1e-7); - } - - // /** Checks the TwoFluidNavierStokesFractional3D4N element - // * Checks the LHS and RHS for a positive element (distance > 0.0) - // */ - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, FluidDynamicsApplicationFastSuite) - { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes{ 1, 2, 3, 4 }; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4, 3); - vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; - vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; - vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; - vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 4; i++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 3; k++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16, 16); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - // std::cout<< std::setprecision(12) << RHS << std::endl; - KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), 64.3649724019, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), 130.747961753, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 1.82139199133, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -173.148878249, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), -263.100173027, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -1019.86139378, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), -0.231551322358, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -198.517992416, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), -320.806050475, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), -1153.91463291, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), -0.36014021379, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12), -233.824784725, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13), -357.542877174, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14), -1300.79220817, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15), -1.32970045518, 1e-7); - } - - /** Checks the TwoFluidNavierStokesFractional2D3N element in a hydrostatic case. - * Checks the computation of the RHS - */ - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, FluidDynamicsApplicationFastSuite) - { - - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-03); - Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 2.0, 0.0, 0.0); // 0 = node 1 - modelPart.CreateNewNode(2, 2.0, 2.0, 0.0); // 1 = node 2 - modelPart.CreateNewNode(3, 0.0, 2.0, 0.0); // 2 = node 3 - - std::vector elemNodes1 {1, 2, 3}; - - modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes1, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values as 0 for hydrostatic case - Matrix vel_original(3,2); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.0; - vel_original(1,0) = 0.0; vel_original(1,1) = 0.0; - vel_original(2,0) = 0.0; vel_original(2,1) = 0.0; - - // Setting equal nodal values for DENSITY, DYNAMIC_VISCOSITY, BODY_FORCE - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_X) = 0.0; - it_node->FastGetSolutionStepValue(BODY_FORCE_Y) = -10.0; - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = 0.0; - } - - // Setting the density (different for nodes since element cut by surface) - pElement->GetGeometry()[0].FastGetSolutionStepValue(DENSITY) = 2.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DENSITY) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DENSITY) = 1.0; - - for(unsigned int i=0; i<3; i++){ - for(unsigned int k=0; k<2; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - - pElement->GetGeometry()[0].Fix(VELOCITY_X); - pElement->GetGeometry()[0].Fix(VELOCITY_Y); - - // Setting the density (different for nodes to define the position of the surface) - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Simon : Setting the pressure - pElement->GetGeometry()[0].FastGetSolutionStepValue(PRESSURE) = 30.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(PRESSURE) = 0.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(PRESSURE) = 0.0; - - pElement->GetGeometry()[0].Fix(PRESSURE); - - // Compute RHS and LHS - Vector RHS = ZeroVector(9); - Matrix LHS = ZeroMatrix(9,9); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - double det; - MathUtils::InvertMatrix(LHS, LHS, det); - - const Vector solVec = prod(LHS, RHS); - - // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. - // If the "standard" pressure shape functions are used, the results do not hold. - // std::cout<< std::setprecision(12) << RHS << std::endl; - KRATOS_EXPECT_NEAR(RHS(0), 0.0, 1e-7); // U_x at node 1 - KRATOS_EXPECT_NEAR(RHS(1), -17.5, 1e-7); // U_y at node 1 - KRATOS_EXPECT_NEAR(RHS(2), 0.0, 1e-7); // P at node 1 - - KRATOS_EXPECT_NEAR(RHS(3), 7.5, 1e-7); // U_x at node 2 - KRATOS_EXPECT_NEAR(RHS(4), 0.0, 1e-7); // U_y at node 2 - KRATOS_EXPECT_NEAR(RHS(5), 0.0, 1e-7); // P at node 2 - - KRATOS_EXPECT_NEAR(RHS(6), -7.5, 1e-7); // U_x at node 3 - KRATOS_EXPECT_NEAR(RHS(7), -7.5, 1e-7); // U_y at node 3 - KRATOS_EXPECT_NEAR(RHS(8), 0.0, 1e-7); // P at node 3 - } - - - // Giving a value different to zero to source term in order to test it. - - // /** Checks the TwoFluidNavierStokeFractional2D3N element with a source term in mass conservation equation - // * Checks the LHS and RHS for a cut element - // */ - - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NError, FluidDynamicsApplicationFastSuite) - { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,10.0); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(3, 2); - vel_original(0, 0) = 0.0; - vel_original(0, 1) = 0.1; - vel_original(1, 0) = 0.1; - vel_original(1, 1) = 0.2; - vel_original(2, 0) = 0.2; - vel_original(2, 1) = 0.3; - - // Set the nodal DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) - { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 3; i++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 2; k++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; - - // Compute RHS and LHS - Vector RHS = ZeroVector(9); - Matrix LHS = ZeroMatrix(9, 9); - - const auto &r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - Vector reference_RHS = ZeroVector(9); - reference_RHS[0] = 6075.49; - reference_RHS[1] = 4684.29; - reference_RHS[2] = -27.713; - reference_RHS[3] = -6671.02; - reference_RHS[4] = 1521.5; - reference_RHS[5] = -16.8578; - reference_RHS[6] = -241.804; - reference_RHS[7] = -4409.55; - reference_RHS[8] = -5.5792; - - KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); - } - - // /** Checks the TwoFluidNavierStokesFractional3D4N element with a source term in mass conservation equation - // * Checks the LHS and RHS for a cut element - // */ - - KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, FluidDynamicsApplicationFastSuite) - { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Process info creation - - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 10.0); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - // Define the nodal values - Matrix vel_original(4, 3); - vel_original(0, 0) = 0.0; - vel_original(0, 1) = 0.1; - vel_original(0, 2) = 0.2; - vel_original(1, 0) = 0.1; - vel_original(1, 1) = 0.2; - vel_original(1, 2) = 0.3; - vel_original(2, 0) = 0.2; - vel_original(2, 1) = 0.3; - vel_original(2, 2) = 0.4; - vel_original(3, 0) = 0.3; - vel_original(3, 1) = 0.4; - vel_original(3, 2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) - { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 4; i++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 3; k++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16, 16); - - const auto &r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - Vector reference_RHS = ZeroVector(16); - reference_RHS[0] = 3885.7277179; - reference_RHS[1] = 2853.21656651; - reference_RHS[2] = 3702.08261768; - reference_RHS[3] = -5.3352875285; - reference_RHS[4] = -4028.70584416; - reference_RHS[5] = 302.05648046; - reference_RHS[6] = -945.708093278; - reference_RHS[7] = -3.93555167259; - reference_RHS[8] = 47.4447861701; - reference_RHS[9] = -3601.6349217; - reference_RHS[10] = -666.475460772; - reference_RHS[11] = -3.04929648043; - reference_RHS[12] = -176.79766346; - reference_RHS[13] = 455.783986472; - reference_RHS[14] = -4803.81765472; - reference_RHS[15] = -4.44653098515; - - KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); - } - } // namespace Testing -} // namespace Kratos. +namespace Kratos::Testing +{ + +typedef ModelPart::IndexType IndexType; +typedef ModelPart::NodeIterator NodeIteratorType; + +/** Checks the TwoFluidNavierStokesFractional2D3N element. + * Checks the LHS and RHS computation + */ + +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynamicsApplicationFastSuite) +{ + + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,0.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for(unsigned int i=0; i<3; i++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9,9); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0), 285.327812743, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),-75.7286708218, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), 0.678487936315, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),-758.586246712, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -529.046820664, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), -0.808596445975, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -549.320499823, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), -931.191955616, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -0.0198914903401, 1e-7); +} + +// /** Checks the TwoFluidNavierStokesFractional3D4N element +// * Checks the LHS and RHS for a cut element +// */ +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDynamicsApplicationFastSuite) +{ + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4,3); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; + vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for(unsigned int i=0; i<4; i++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for(unsigned int k=0; k<3; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16,16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + std::cout << std::setprecision(12) << RHS << std::endl; + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + KRATOS_EXPECT_NEAR(RHS(0), -182.780712656, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), -5.97373013, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), -366.425812874, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 0.136180451508, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -65.5996318562, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),-195.157657105, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -732.8993499, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), 0.228653068676, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -30.1350973711, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), -309.557107994, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), -744.055344314, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), -0.182507276303, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12), 4.70728308942, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13), -259.815870553, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14), -872.015239241, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15), -0.282326243881, 1e-7); +} + + +// /** Checks the TwoFluidNavierStokesFractional3D4N element +// * Checks the LHS and RHS for a negative element (distance <= 0.0) +// */ +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, FluidDynamicsApplicationFastSuite) +{ + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes{ 1, 2, 3, 4 }; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = -1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),64.3649724019, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2),130.747961753, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),1.82139199133, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4),-173.148878249, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),-263.100173027, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6),-1019.86139378, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7),-0.231551322358, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8),-198.517992416, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9),-320.806050475, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10),-1153.91463291, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11),-0.36014021379, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12),-233.824784725, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13),-357.542877174, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14),-1300.79220817, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15),-1.32970045518 , 1e-7); +} + +// /** Checks the TwoFluidNavierStokesFractional3D4N element +// * Checks the LHS and RHS for a positive element (distance > 0.0) +// */ +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, FluidDynamicsApplicationFastSuite) +{ + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes{ 1, 2, 3, 4 }; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + // std::cout<< std::setprecision(12) << RHS << std::endl; + KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), 64.3649724019, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), 130.747961753, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 1.82139199133, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -173.148878249, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), -263.100173027, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -1019.86139378, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), -0.231551322358, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -198.517992416, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), -320.806050475, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), -1153.91463291, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), -0.36014021379, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12), -233.824784725, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13), -357.542877174, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14), -1300.79220817, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15), -1.32970045518, 1e-7); +} + +/** Checks the TwoFluidNavierStokesFractional2D3N element in a hydrostatic case. + * Checks the computation of the RHS + */ +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, FluidDynamicsApplicationFastSuite) +{ + + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-03); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 2.0, 0.0, 0.0); // 0 = node 1 + modelPart.CreateNewNode(2, 2.0, 2.0, 0.0); // 1 = node 2 + modelPart.CreateNewNode(3, 0.0, 2.0, 0.0); // 2 = node 3 + + std::vector elemNodes1 {1, 2, 3}; + + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes1, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values as 0 for hydrostatic case + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.0; + vel_original(1,0) = 0.0; vel_original(1,1) = 0.0; + vel_original(2,0) = 0.0; vel_original(2,1) = 0.0; + + // Setting equal nodal values for DENSITY, DYNAMIC_VISCOSITY, BODY_FORCE + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_X) = 0.0; + it_node->FastGetSolutionStepValue(BODY_FORCE_Y) = -10.0; + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = 0.0; + } + + // Setting the density (different for nodes since element cut by surface) + pElement->GetGeometry()[0].FastGetSolutionStepValue(DENSITY) = 2.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DENSITY) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DENSITY) = 1.0; + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + + pElement->GetGeometry()[0].Fix(VELOCITY_X); + pElement->GetGeometry()[0].Fix(VELOCITY_Y); + + // Setting the density (different for nodes to define the position of the surface) + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Simon : Setting the pressure + pElement->GetGeometry()[0].FastGetSolutionStepValue(PRESSURE) = 30.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(PRESSURE) = 0.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(PRESSURE) = 0.0; + + pElement->GetGeometry()[0].Fix(PRESSURE); + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9,9); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + double det; + MathUtils::InvertMatrix(LHS, LHS, det); + + const Vector solVec = prod(LHS, RHS); + + // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. + // If the "standard" pressure shape functions are used, the results do not hold. + // std::cout<< std::setprecision(12) << RHS << std::endl; + KRATOS_EXPECT_NEAR(RHS(0), 0.0, 1e-7); // U_x at node 1 + KRATOS_EXPECT_NEAR(RHS(1), -17.5, 1e-7); // U_y at node 1 + KRATOS_EXPECT_NEAR(RHS(2), 0.0, 1e-7); // P at node 1 + + KRATOS_EXPECT_NEAR(RHS(3), 7.5, 1e-7); // U_x at node 2 + KRATOS_EXPECT_NEAR(RHS(4), 0.0, 1e-7); // U_y at node 2 + KRATOS_EXPECT_NEAR(RHS(5), 0.0, 1e-7); // P at node 2 + + KRATOS_EXPECT_NEAR(RHS(6), -7.5, 1e-7); // U_x at node 3 + KRATOS_EXPECT_NEAR(RHS(7), -7.5, 1e-7); // U_y at node 3 + KRATOS_EXPECT_NEAR(RHS(8), 0.0, 1e-7); // P at node 3 +} + + +// Giving a value different to zero to source term in order to test it. + +// /** Checks the TwoFluidNavierStokeFractional2D3N element with a source term in mass conservation equation +// * Checks the LHS and RHS for a cut element +// */ + +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NError, FluidDynamicsApplicationFastSuite) +{ + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,10.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3, 2); + vel_original(0, 0) = 0.0; + vel_original(0, 1) = 0.1; + vel_original(1, 0) = 0.1; + vel_original(1, 1) = 0.2; + vel_original(2, 0) = 0.2; + vel_original(2, 1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) + { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 3; i++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 2; k++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9, 9); + + const auto &r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + Vector reference_RHS = ZeroVector(9); + reference_RHS[0] = 6075.49; + reference_RHS[1] = 4684.29; + reference_RHS[2] = -27.713; + reference_RHS[3] = -6671.02; + reference_RHS[4] = 1521.5; + reference_RHS[5] = -16.8578; + reference_RHS[6] = -241.804; + reference_RHS[7] = -4409.55; + reference_RHS[8] = -5.5792; + + KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); +} + +// /** Checks the TwoFluidNavierStokesFractional3D4N element with a source term in mass conservation equation +// * Checks the LHS and RHS for a cut element +// */ + +KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, FluidDynamicsApplicationFastSuite) +{ + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 10.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-02); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; + vel_original(0, 1) = 0.1; + vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; + vel_original(1, 1) = 0.2; + vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; + vel_original(2, 1) = 0.3; + vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; + vel_original(3, 1) = 0.4; + vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) + { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto &r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + Vector reference_RHS = ZeroVector(16); + reference_RHS[0] = 3885.7277179; + reference_RHS[1] = 2853.21656651; + reference_RHS[2] = 3702.08261768; + reference_RHS[3] = -5.3352875285; + reference_RHS[4] = -4028.70584416; + reference_RHS[5] = 302.05648046; + reference_RHS[6] = -945.708093278; + reference_RHS[7] = -3.93555167259; + reference_RHS[8] = 47.4447861701; + reference_RHS[9] = -3601.6349217; + reference_RHS[10] = -666.475460772; + reference_RHS[11] = -3.04929648043; + reference_RHS[12] = -176.79766346; + reference_RHS[13] = 455.783986472; + reference_RHS[14] = -4803.81765472; + reference_RHS[15] = -4.44653098515; + + KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-10); +} + +} // namespace Kratos::Testing. diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp index 1129474eff5b..c0a2bcd15831 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp @@ -33,8 +33,8 @@ namespace Kratos { namespace Testing { - typedef ModelPart::IndexType IndexType; - typedef ModelPart::NodeIterator NodeIteratorType; + typedef ModelPart::IndexType IndexType; + typedef ModelPart::NodeIterator NodeIteratorType; /** Checks the VectorialConvectionFractional2D3N element. * Checks the LHS and RHS computation @@ -114,7 +114,7 @@ namespace Kratos { const auto& r_process_info = modelPart.GetProcessInfo(); pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - // std::cout << std::setprecision(12) << RHS << std::endl; + std::cout << std::setprecision(12) << RHS << std::endl; // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) From ddf863739edf99fcf642469816b6e777a8f39bea Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 19 Dec 2024 20:07:36 +0100 Subject: [PATCH 05/13] different tolerance --- ...fluid_fractional_navier_stokes_element.cpp | 1599 ++++++++--------- 1 file changed, 799 insertions(+), 800 deletions(-) diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index cb645626bcc4..6e3a7632df8f 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -46,105 +46,105 @@ typedef ModelPart::NodeIterator NodeIteratorType; KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,0.0); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(3,2); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; - vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; - vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; - - // Set the nodal DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for(unsigned int i=0; i<3; i++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for(unsigned int k=0; k<2; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; - - // Compute RHS and LHS - Vector RHS = ZeroVector(9); - Matrix LHS = ZeroMatrix(9,9); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0), 285.327812743, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),-75.7286708218, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), 0.678487936315, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),-758.586246712, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -529.046820664, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), -0.808596445975, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -549.320499823, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), -931.191955616, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -0.0198914903401, 1e-7); + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,0.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for(unsigned int i=0; i<3; i++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9,9); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0), 285.327812743, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),-75.7286708218, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), 0.678487936315, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),-758.586246712, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -529.046820664, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), -0.808596445975, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -549.320499823, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), -931.191955616, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -0.0198914903401, 1e-7); } // /** Checks the TwoFluidNavierStokesFractional3D4N element @@ -152,116 +152,116 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynami // */ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4,3); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; - vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; - vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; - vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for(unsigned int i=0; i<4; i++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for(unsigned int k=0; k<3; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16,16); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - std::cout << std::setprecision(12) << RHS << std::endl; - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - KRATOS_EXPECT_NEAR(RHS(0), -182.780712656, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), -5.97373013, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), -366.425812874, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 0.136180451508, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -65.5996318562, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),-195.157657105, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -732.8993499, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), 0.228653068676, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -30.1350973711, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), -309.557107994, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), -744.055344314, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), -0.182507276303, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12), 4.70728308942, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13), -259.815870553, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14), -872.015239241, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15), -0.282326243881, 1e-7); + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4,3); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; + vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for(unsigned int i=0; i<4; i++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for(unsigned int k=0; k<3; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16,16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + std::cout << std::setprecision(12) << RHS << std::endl; + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + KRATOS_EXPECT_NEAR(RHS(0), -182.780712656, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), -5.97373013, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), -366.425812874, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 0.136180451508, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -65.5996318562, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),-195.157657105, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -732.8993499, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), 0.228653068676, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -30.1350973711, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), -309.557107994, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), -744.055344314, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), -0.182507276303, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12), 4.70728308942, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13), -259.815870553, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14), -872.015239241, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15), -0.282326243881, 1e-7); } @@ -270,117 +270,117 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDyn // */ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes{ 1, 2, 3, 4 }; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4, 3); - vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; - vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; - vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; - vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 4; i++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 3; k++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = -1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16, 16); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),64.3649724019, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2),130.747961753, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),1.82139199133, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4),-173.148878249, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),-263.100173027, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6),-1019.86139378, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7),-0.231551322358, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8),-198.517992416, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9),-320.806050475, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10),-1153.91463291, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11),-0.36014021379, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12),-233.824784725, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13),-357.542877174, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14),-1300.79220817, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15),-1.32970045518 , 1e-7); + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes{ 1, 2, 3, 4 }; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = -1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + + KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1),64.3649724019, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2),130.747961753, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3),1.82139199133, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4),-173.148878249, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5),-263.100173027, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6),-1019.86139378, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7),-0.231551322358, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8),-198.517992416, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9),-320.806050475, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10),-1153.91463291, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11),-0.36014021379, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12),-233.824784725, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13),-357.542877174, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14),-1300.79220817, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15),-1.32970045518 , 1e-7); } // /** Checks the TwoFluidNavierStokesFractional3D4N element @@ -388,255 +388,255 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, // */ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes{ 1, 2, 3, 4 }; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4, 3); - vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; - vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; - vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; - vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 4; i++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 3; k++) { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16, 16); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - // std::cout<< std::setprecision(12) << RHS << std::endl; - KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), 64.3649724019, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), 130.747961753, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 1.82139199133, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -173.148878249, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), -263.100173027, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -1019.86139378, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), -0.231551322358, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -198.517992416, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), -320.806050475, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), -1153.91463291, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), -0.36014021379, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12), -233.824784725, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13), -357.542877174, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14), -1300.79220817, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15), -1.32970045518, 1e-7); + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes{ 1, 2, 3, 4 }; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; vel_original(0, 1) = 0.1; vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; vel_original(1, 1) = 0.2; vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; vel_original(2, 1) = 0.3; vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; vel_original(3, 1) = 0.4; vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + // std::cout<< std::setprecision(12) << RHS << std::endl; + KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); + KRATOS_EXPECT_NEAR(RHS(1), 64.3649724019, 1e-7); + KRATOS_EXPECT_NEAR(RHS(2), 130.747961753, 1e-7); + KRATOS_EXPECT_NEAR(RHS(3), 1.82139199133, 1e-7); + KRATOS_EXPECT_NEAR(RHS(4), -173.148878249, 1e-7); + KRATOS_EXPECT_NEAR(RHS(5), -263.100173027, 1e-7); + KRATOS_EXPECT_NEAR(RHS(6), -1019.86139378, 1e-7); + KRATOS_EXPECT_NEAR(RHS(7), -0.231551322358, 1e-7); + KRATOS_EXPECT_NEAR(RHS(8), -198.517992416, 1e-7); + KRATOS_EXPECT_NEAR(RHS(9), -320.806050475, 1e-7); + KRATOS_EXPECT_NEAR(RHS(10), -1153.91463291, 1e-7); + KRATOS_EXPECT_NEAR(RHS(11), -0.36014021379, 1e-7); + KRATOS_EXPECT_NEAR(RHS(12), -233.824784725, 1e-7); + KRATOS_EXPECT_NEAR(RHS(13), -357.542877174, 1e-7); + KRATOS_EXPECT_NEAR(RHS(14), -1300.79220817, 1e-7); + KRATOS_EXPECT_NEAR(RHS(15), -1.32970045518, 1e-7); } /** Checks the TwoFluidNavierStokesFractional2D3N element in a hydrostatic case. - * Checks the computation of the RHS - */ + * Checks the computation of the RHS + */ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-03); - Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 2.0, 0.0, 0.0); // 0 = node 1 - modelPart.CreateNewNode(2, 2.0, 2.0, 0.0); // 1 = node 2 - modelPart.CreateNewNode(3, 0.0, 2.0, 0.0); // 2 = node 3 - - std::vector elemNodes1 {1, 2, 3}; - - modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes1, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values as 0 for hydrostatic case - Matrix vel_original(3,2); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.0; - vel_original(1,0) = 0.0; vel_original(1,1) = 0.0; - vel_original(2,0) = 0.0; vel_original(2,1) = 0.0; - - // Setting equal nodal values for DENSITY, DYNAMIC_VISCOSITY, BODY_FORCE - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_X) = 0.0; - it_node->FastGetSolutionStepValue(BODY_FORCE_Y) = -10.0; - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = 0.0; - } - - // Setting the density (different for nodes since element cut by surface) - pElement->GetGeometry()[0].FastGetSolutionStepValue(DENSITY) = 2.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DENSITY) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DENSITY) = 1.0; - - for(unsigned int i=0; i<3; i++){ - for(unsigned int k=0; k<2; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - - pElement->GetGeometry()[0].Fix(VELOCITY_X); - pElement->GetGeometry()[0].Fix(VELOCITY_Y); - - // Setting the density (different for nodes to define the position of the surface) - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Simon : Setting the pressure - pElement->GetGeometry()[0].FastGetSolutionStepValue(PRESSURE) = 30.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(PRESSURE) = 0.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(PRESSURE) = 0.0; - - pElement->GetGeometry()[0].Fix(PRESSURE); - - // Compute RHS and LHS - Vector RHS = ZeroVector(9); - Matrix LHS = ZeroMatrix(9,9); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - double det; - MathUtils::InvertMatrix(LHS, LHS, det); - - const Vector solVec = prod(LHS, RHS); - - // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. - // If the "standard" pressure shape functions are used, the results do not hold. - // std::cout<< std::setprecision(12) << RHS << std::endl; - KRATOS_EXPECT_NEAR(RHS(0), 0.0, 1e-7); // U_x at node 1 - KRATOS_EXPECT_NEAR(RHS(1), -17.5, 1e-7); // U_y at node 1 - KRATOS_EXPECT_NEAR(RHS(2), 0.0, 1e-7); // P at node 1 - - KRATOS_EXPECT_NEAR(RHS(3), 7.5, 1e-7); // U_x at node 2 - KRATOS_EXPECT_NEAR(RHS(4), 0.0, 1e-7); // U_y at node 2 - KRATOS_EXPECT_NEAR(RHS(5), 0.0, 1e-7); // P at node 2 - - KRATOS_EXPECT_NEAR(RHS(6), -7.5, 1e-7); // U_x at node 3 - KRATOS_EXPECT_NEAR(RHS(7), -7.5, 1e-7); // U_y at node 3 - KRATOS_EXPECT_NEAR(RHS(8), 0.0, 1e-7); // P at node 3 + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 0.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 0.0); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-03); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 2.0, 0.0, 0.0); // 0 = node 1 + modelPart.CreateNewNode(2, 2.0, 2.0, 0.0); // 1 = node 2 + modelPart.CreateNewNode(3, 0.0, 2.0, 0.0); // 2 = node 3 + + std::vector elemNodes1 {1, 2, 3}; + + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes1, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values as 0 for hydrostatic case + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.0; + vel_original(1,0) = 0.0; vel_original(1,1) = 0.0; + vel_original(2,0) = 0.0; vel_original(2,1) = 0.0; + + // Setting equal nodal values for DENSITY, DYNAMIC_VISCOSITY, BODY_FORCE + for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_X) = 0.0; + it_node->FastGetSolutionStepValue(BODY_FORCE_Y) = -10.0; + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = 0.0; + } + + // Setting the density (different for nodes since element cut by surface) + pElement->GetGeometry()[0].FastGetSolutionStepValue(DENSITY) = 2.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DENSITY) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DENSITY) = 1.0; + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + + pElement->GetGeometry()[0].Fix(VELOCITY_X); + pElement->GetGeometry()[0].Fix(VELOCITY_Y); + + // Setting the density (different for nodes to define the position of the surface) + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Simon : Setting the pressure + pElement->GetGeometry()[0].FastGetSolutionStepValue(PRESSURE) = 30.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(PRESSURE) = 0.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(PRESSURE) = 0.0; + + pElement->GetGeometry()[0].Fix(PRESSURE); + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9,9); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + double det; + MathUtils::InvertMatrix(LHS, LHS, det); + + const Vector solVec = prod(LHS, RHS); + + // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. + // If the "standard" pressure shape functions are used, the results do not hold. + // std::cout<< std::setprecision(12) << RHS << std::endl; + KRATOS_EXPECT_NEAR(RHS(0), 0.0, 1e-7); // U_x at node 1 + KRATOS_EXPECT_NEAR(RHS(1), -17.5, 1e-7); // U_y at node 1 + KRATOS_EXPECT_NEAR(RHS(2), 0.0, 1e-7); // P at node 1 + + KRATOS_EXPECT_NEAR(RHS(3), 7.5, 1e-7); // U_x at node 2 + KRATOS_EXPECT_NEAR(RHS(4), 0.0, 1e-7); // U_y at node 2 + KRATOS_EXPECT_NEAR(RHS(5), 0.0, 1e-7); // P at node 2 + + KRATOS_EXPECT_NEAR(RHS(6), -7.5, 1e-7); // U_x at node 3 + KRATOS_EXPECT_NEAR(RHS(7), -7.5, 1e-7); // U_y at node 3 + KRATOS_EXPECT_NEAR(RHS(8), 0.0, 1e-7); // P at node 3 } @@ -648,117 +648,117 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NError, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,10.0); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1000.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(3, 2); - vel_original(0, 0) = 0.0; - vel_original(0, 1) = 0.1; - vel_original(1, 0) = 0.1; - vel_original(1, 1) = 0.2; - vel_original(2, 0) = 0.2; - vel_original(2, 1) = 0.3; - - // Set the nodal DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) - { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 3; i++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 2; k++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; - - // Compute RHS and LHS - Vector RHS = ZeroVector(9); - Matrix LHS = ZeroMatrix(9, 9); - - const auto &r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - Vector reference_RHS = ZeroVector(9); - reference_RHS[0] = 6075.49; - reference_RHS[1] = 4684.29; - reference_RHS[2] = -27.713; - reference_RHS[3] = -6671.02; - reference_RHS[4] = 1521.5; - reference_RHS[5] = -16.8578; - reference_RHS[6] = -241.804; - reference_RHS[7] = -4409.55; - reference_RHS[8] = -5.5792; - - KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(SOUND_VELOCITY, 1.0e+3); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR,10.0); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); + Newtonian2DLaw::Pointer pConsLaw(new Newtonian2DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3, 2); + vel_original(0, 0) = 0.0; + vel_original(0, 1) = 0.1; + vel_original(1, 0) = 0.1; + vel_original(1, 1) = 0.2; + vel_original(2, 0) = 0.2; + vel_original(2, 1) = 0.3; + + // Set the nodal DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) + { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 3; i++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 2; k++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = 0.5; + + // Compute RHS and LHS + Vector RHS = ZeroVector(9); + Matrix LHS = ZeroMatrix(9, 9); + + const auto &r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + Vector reference_RHS = ZeroVector(9); + reference_RHS[0] = 6075.49; + reference_RHS[1] = 4684.29; + reference_RHS[2] = -27.713; + reference_RHS[3] = -6671.02; + reference_RHS[4] = 1521.5; + reference_RHS[5] = -16.8578; + reference_RHS[6] = -241.804; + reference_RHS[7] = -4409.55; + reference_RHS[8] = -5.5792; + + KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); } // /** Checks the TwoFluidNavierStokesFractional3D4N element with a source term in mass conservation equation @@ -767,132 +767,131 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NError, FluidD KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, FluidDynamicsApplicationFastSuite) { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 4; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - // Variables addition - modelPart.AddNodalSolutionStepVariable(BODY_FORCE); - modelPart.AddNodalSolutionStepVariable(DENSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(PRESSURE); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - modelPart.AddNodalSolutionStepVariable(DISTANCE); - - // Process info creation - - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); - modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 10.0); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DENSITY, 1.0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-02); - NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); - pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - // Define the nodal values - Matrix vel_original(4, 3); - vel_original(0, 0) = 0.0; - vel_original(0, 1) = 0.1; - vel_original(0, 2) = 0.2; - vel_original(1, 0) = 0.1; - vel_original(1, 1) = 0.2; - vel_original(1, 2) = 0.3; - vel_original(2, 0) = 0.2; - vel_original(2, 1) = 0.3; - vel_original(2, 2) = 0.4; - vel_original(3, 0) = 0.3; - vel_original(3, 1) = 0.4; - vel_original(3, 2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) - { - it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); - it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; - } - - for (unsigned int i = 0; i < 4; i++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; - for (unsigned int k = 0; k < 3; k++) - { - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; - pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; - pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; - - // Compute RHS and LHS - Vector RHS = ZeroVector(16); - Matrix LHS = ZeroMatrix(16, 16); - - const auto &r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - Vector reference_RHS = ZeroVector(16); - reference_RHS[0] = 3885.7277179; - reference_RHS[1] = 2853.21656651; - reference_RHS[2] = 3702.08261768; - reference_RHS[3] = -5.3352875285; - reference_RHS[4] = -4028.70584416; - reference_RHS[5] = 302.05648046; - reference_RHS[6] = -945.708093278; - reference_RHS[7] = -3.93555167259; - reference_RHS[8] = 47.4447861701; - reference_RHS[9] = -3601.6349217; - reference_RHS[10] = -666.475460772; - reference_RHS[11] = -3.04929648043; - reference_RHS[12] = -176.79766346; - reference_RHS[13] = 455.783986472; - reference_RHS[14] = -4803.81765472; - reference_RHS[15] = -4.44653098515; - - KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-10); + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 4; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + // Variables addition + modelPart.AddNodalSolutionStepVariable(BODY_FORCE); + modelPart.AddNodalSolutionStepVariable(DENSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(PRESSURE); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + modelPart.AddNodalSolutionStepVariable(DISTANCE); + + // Process info creation + + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + modelPart.GetProcessInfo().SetValue(AIR_VOLUME_ERROR, 10.0); + modelPart.GetProcessInfo().SetValue(WATER_VOLUME_ERROR, 10.0); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + pElemProp->SetValue(DENSITY, 1000.0); + pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-03); + NewtonianTwoFluid3DLaw::Pointer pConsLaw(new NewtonianTwoFluid3DLaw()); + pElemProp->SetValue(CONSTITUTIVE_LAW, pConsLaw); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("TwoFluidNavierStokesFractional3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + // Define the nodal values + Matrix vel_original(4, 3); + vel_original(0, 0) = 0.0; + vel_original(0, 1) = 0.1; + vel_original(0, 2) = 0.2; + vel_original(1, 0) = 0.1; + vel_original(1, 1) = 0.2; + vel_original(1, 2) = 0.3; + vel_original(2, 0) = 0.2; + vel_original(2, 1) = 0.3; + vel_original(2, 2) = 0.4; + vel_original(3, 0) = 0.3; + vel_original(3, 1) = 0.4; + vel_original(3, 2) = 0.5; + + // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values + for (NodeIteratorType it_node = modelPart.NodesBegin(); it_node < modelPart.NodesEnd(); ++it_node) + { + it_node->FastGetSolutionStepValue(DENSITY) = pElemProp->GetValue(DENSITY); + it_node->FastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); + it_node->FastGetSolutionStepValue(BODY_FORCE_Z) = -9.81; + } + + for (unsigned int i = 0; i < 4; i++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0.0; + for (unsigned int k = 0; k < 3; k++) + { + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; + } + } + pElement->GetGeometry()[0].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[1].FastGetSolutionStepValue(DISTANCE) = 1.0; + pElement->GetGeometry()[2].FastGetSolutionStepValue(DISTANCE) = -1.0; + pElement->GetGeometry()[3].FastGetSolutionStepValue(DISTANCE) = 1.0; + + // Compute RHS and LHS + Vector RHS = ZeroVector(16); + Matrix LHS = ZeroMatrix(16, 16); + + const auto &r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + std::cout<< std::setprecision(12) << RHS << std::endl; + Vector reference_RHS = ZeroVector(16); + reference_RHS[0] = 3885.76546946; + reference_RHS[1] = 2853.252194541; + reference_RHS[2] = 3702.11733421; + reference_RHS[3] = -5.33528927901; + reference_RHS[4] = 4028.74316648; + reference_RHS[5] = 302.056712497; + reference_RHS[6] = -945.707036998; + reference_RHS[7] = -3.93555403796; + reference_RHS[8] = 47.4442472421; + reference_RHS[9] = -3601.67069179; + reference_RHS[10] = -666.474404348; + reference_RHS[11] = -3.04929475341; + reference_RHS[12] = -176.798973004; + reference_RHS[13] = 455.784932702; + reference_RHS[14] = -4803.85305063; + reference_RHS[15] = -4.44652859628; + + KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-7); } } // namespace Kratos::Testing. From 310a985783daaf83d658d719595b8c7c3ef7bed9 Mon Sep 17 00:00:00 2001 From: uxuech Date: Fri, 20 Dec 2024 10:53:55 +0100 Subject: [PATCH 06/13] adding references --- ...ectorial_convection_fractional_element.cpp | 23 ++++++++----------- ...convection_fractional_element_template.cpp | 18 +++++++-------- ...fluid_fractional_navier_stokes_element.cpp | 3 +-- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp index 406abfa9d8a1..6decdb52b354 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp @@ -176,10 +176,9 @@ namespace Kratos const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto vfrac = rData.Velocity_Fractional; - const auto vn = rData.Velocity_OldStep1; - const auto vmesh = rData.MeshVelocity; - const auto vconv = vfrac-vmesh; + const auto &vfrac = rData.Velocity_Fractional; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = vfrac-vmesh; // Get shape function values const auto &N = rData.N; @@ -273,10 +272,9 @@ lhs(5,5)=clhs29; const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto vn = rData.Velocity_OldStep1; - const auto vfrac = rData.Velocity_Fractional; - const auto vmesh = rData.MeshVelocity; - const auto vconv = vfrac - vmesh; + const auto &vfrac = rData.Velocity_Fractional; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = vfrac - vmesh; // Get shape function values const auto &N = rData.N; @@ -495,15 +493,12 @@ lhs(11,11)=clhs45; const double bdf0 = rData.bdf0; const double bdf1 = rData.bdf1; const double bdf2 = rData.bdf2; - const double dyn_tau = rData.DynamicTau; - const auto &vn = rData.Velocity_OldStep1; - - // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vnn = rData.Velocity_OldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vmesh = rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; // Get shape function values @@ -580,7 +575,7 @@ rhs[5]=-N[2]*crhs24 + N[2]*crhs27 - N[2]*crhs28 + crhs23*crhs33 - crhs29*crhs34 const auto &vnn = rData.Velocity_OldStep2; // const auto &vnnn = rData.Velocity_OldStep3; #an_bdf2 const auto &vmesh = rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; // Get shape function values diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp index a67873810a29..0122bc5e52cd 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp @@ -176,10 +176,9 @@ namespace Kratos const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto vfrac = rData.Velocity_Fractional; - const auto vn = rData.Velocity_OldStep1; - const auto vmesh = rData.MeshVelocity; - const auto vconv = vfrac-vmesh; + const auto &vfrac = rData.Velocity_Fractional; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = vfrac-vmesh; // Get shape function values const auto &N = rData.N; @@ -207,10 +206,9 @@ namespace Kratos const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto vn = rData.Velocity_OldStep1; - const auto vfrac = rData.Velocity_Fractional; - const auto vmesh = rData.MeshVelocity; - const auto vconv = vfrac - vmesh; + const auto &vfrac = rData.Velocity_Fractional; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = vfrac - vmesh; // Get shape function values const auto &N = rData.N; @@ -244,7 +242,7 @@ namespace Kratos const auto &vnn = rData.Velocity_OldStep2; // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vmesh = rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; // Get shape function values @@ -279,7 +277,7 @@ namespace Kratos const auto &vnn = rData.Velocity_OldStep2; // const auto &vnnn = rData.Velocity_OldStep3; #an_bdf2 const auto &vmesh = rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.Velocity_Fractional; const auto &vconv = vfrac - vmesh; // Get shape function values diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index 6e3a7632df8f..92a846217b97 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -872,13 +872,12 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, Flu pElement->CalculateLocalSystem(LHS, RHS, r_process_info); // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - std::cout<< std::setprecision(12) << RHS << std::endl; Vector reference_RHS = ZeroVector(16); reference_RHS[0] = 3885.76546946; reference_RHS[1] = 2853.252194541; reference_RHS[2] = 3702.11733421; reference_RHS[3] = -5.33528927901; - reference_RHS[4] = 4028.74316648; + reference_RHS[4] = -4028.74316648; reference_RHS[5] = 302.056712497; reference_RHS[6] = -945.707036998; reference_RHS[7] = -3.93555403796; From 3db88ddd9577055c80e83172aa07b39b030dbc21 Mon Sep 17 00:00:00 2001 From: uxuech Date: Fri, 20 Dec 2024 12:08:35 +0100 Subject: [PATCH 07/13] minor changes --- .../custom_elements/fluid_element.cpp | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp index 4c31b2227bcb..2c9d8d7a13be 100644 --- a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp @@ -15,17 +15,18 @@ #include "includes/checks.h" #include "data_containers/axisymmetric_navier_stokes/axisymmetric_navier_stokes_data.h" -#include "custom_elements/data_containers/qs_vms/qs_vms_data.h" -#include "custom_elements/data_containers/time_integrated_qs_vms/time_integrated_qs_vms_data.h" -#include "custom_elements/data_containers/qs_vms_dem_coupled/qs_vms_dem_coupled_data.h" -#include "custom_elements/data_containers/fic/fic_data.h" -#include "custom_elements/data_containers/time_integrated_fic/time_integrated_fic_data.h" -#include "custom_elements/data_containers/stokes/stokes_data.h" -#include "custom_elements/data_containers/two_fluid_navier_stokes/two_fluid_navier_stokes_data.h" -#include "custom_elements/data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" -#include "custom_elements/data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" -#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" -#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" +#include "data_containers/low_mach_navier_stokes/low_mach_navier_stokes_data.h" +#include "data_containers/qs_vms/qs_vms_data.h" +#include "data_containers/time_integrated_qs_vms/time_integrated_qs_vms_data.h" +#include "data_containers/qs_vms_dem_coupled/qs_vms_dem_coupled_data.h" +#include "data_containers/fic/fic_data.h" +#include "data_containers/time_integrated_fic/time_integrated_fic_data.h" +#include "data_containers/stokes/stokes_data.h" +#include "data_containers/two_fluid_navier_stokes/two_fluid_navier_stokes_data.h" +#include "data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" +#include "data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" +#include "data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" +#include "data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" #include "utilities/element_size_calculator.h" #include "custom_utilities/vorticity_utilities.h" @@ -952,6 +953,11 @@ template class FluidElement>; template class FluidElement< TwoFluidNavierStokesAlphaMethodData<3, 4> >; template class FluidElement>; template class FluidElement>; + +template class FluidElement< LowMachNavierStokesData<2,3> >; +template class FluidElement< LowMachNavierStokesData<2,4> >; +template class FluidElement< LowMachNavierStokesData<3,4> >; +template class FluidElement< LowMachNavierStokesData<3,8> >; /////////////////////////////////////////////////////////////////////////////////////////////////// } From 321716f0870dcc113ec76e11cf1e7310bcf31c08 Mon Sep 17 00:00:00 2001 From: uxuech Date: Mon, 23 Dec 2024 20:33:23 +0100 Subject: [PATCH 08/13] Modifying suggested changes but still need to rename the element --- .../two_fluid_navier_stokes_fractional_data.h | 44 +- ...orial_convection_fractional_element_data.h | 28 +- .../two_fluid_navier_stokes_fractional.cpp | 2338 ++++++++--------- .../two_fluid_navier_stokes_fractional.h | 915 +++---- ...ectorial_convection_fractional_element.cpp | 232 +- .../vectorial_convection_fractional_element.h | 202 +- ...rate_two_fluid_navier_stokes_fractional.py | 9 +- ...luid_navier_stokes_fractional_template.cpp | 94 +- ...convection_fractional_element_template.cpp | 23 +- ...fluid_fractional_navier_stokes_element.cpp | 125 +- ...ectorial_convection_fractional_element.cpp | 357 ++- 11 files changed, 2038 insertions(+), 2329 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h index 289ee7e54dac..59de9dade392 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -12,10 +12,7 @@ #pragma once -#define KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL_DATA_H - #include "includes/constitutive_law.h" - #include "fluid_dynamics_application_variables.h" #include "custom_elements/data_containers/fluid_element_data.h" #include "utilities/element_size_calculator.h" @@ -51,16 +48,15 @@ static constexpr std::size_t BlockSize = TDim + 1; ///@{ NodalVectorData Velocity; -NodalVectorData Velocity_OldStep1; -NodalVectorData Velocity_OldStep2; -NodalVectorData Velocity_OldStep3; +NodalVectorData VelocityOldStep1; +NodalVectorData VelocityOldStep2; NodalVectorData MeshVelocity; NodalVectorData BodyForce; -NodalVectorData Velocity_Fractional; NodalScalarData Pressure; NodalScalarData Distance; -NodalScalarData NodalDensity; +NodalVectorData FractionalVelocity; NodalScalarData NodalDynamicViscosity; +NodalScalarData NodalDensity; double Density; double DynamicViscosity; @@ -68,9 +64,6 @@ double DeltaTime; // Time increment double PreviousDeltaTime; double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients double SmagorinskyConstant; -double LinearDarcyCoefficient; -double NonLinearDarcyCoefficient; -double DarcyTerm; double VolumeError; double AirVolumeError; double WaterVolumeError; @@ -116,24 +109,18 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri // Base class Initialize manages constitutive law parameters FluidElementData::Initialize(rElement,rProcessInfo); - const Geometry< Node >& r_geometry = rElement.GetGeometry(); + const auto& r_geometry = rElement.GetGeometry(); const Properties& r_properties = rElement.GetProperties(); this->FillFromHistoricalNodalData(Velocity,VELOCITY,r_geometry); - this->FillFromHistoricalNodalData(Velocity_OldStep1,VELOCITY,r_geometry,1); - this->FillFromHistoricalNodalData(Velocity_OldStep2,VELOCITY,r_geometry,2); - this->FillFromHistoricalNodalData(Velocity_OldStep3, VELOCITY, r_geometry, 3); - + this->FillFromHistoricalNodalData(VelocityOldStep1,VELOCITY,r_geometry,1); + this->FillFromHistoricalNodalData(VelocityOldStep2,VELOCITY,r_geometry,2); this->FillFromHistoricalNodalData(Distance, DISTANCE, r_geometry); - this->FillFromHistoricalNodalData(MeshVelocity,MESH_VELOCITY,r_geometry); - this->FillFromHistoricalNodalData(BodyForce,BODY_FORCE,r_geometry); + this->FillFromHistoricalNodalData(MeshVelocity,MESH_VELOCITY,r_geometry,0); this->FillFromHistoricalNodalData(Pressure,PRESSURE,r_geometry); this->FillFromHistoricalNodalData(NodalDensity, DENSITY, r_geometry); this->FillFromHistoricalNodalData(NodalDynamicViscosity, DYNAMIC_VISCOSITY, r_geometry); - // this->FillFromHistoricalNodalData(Acceleration, FRACTIONAL_ACCELERATION, r_geometry,1); - this->FillFromHistoricalNodalData(Velocity_Fractional, FRACTIONAL_VELOCITY, r_geometry, 0); + this->FillFromHistoricalNodalData(FractionalVelocity, FRACTIONAL_VELOCITY, r_geometry, 0); this->FillFromProperties(SmagorinskyConstant, C_SMAGORINSKY, r_properties); - this->FillFromProperties(LinearDarcyCoefficient, LIN_DARCY_COEF, r_properties); - this->FillFromProperties(NonLinearDarcyCoefficient, NONLIN_DARCY_COEF, r_properties); this->FillFromProcessInfo(DeltaTime,DELTA_TIME,rProcessInfo); this->FillFromProcessInfo(VolumeError, VOLUME_ERROR, rProcessInfo); this->FillFromProcessInfo(DynamicTau, DYNAMIC_TAU, rProcessInfo); @@ -198,6 +185,7 @@ static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) for (unsigned int i = 0; i < TNumNodes; i++) { + KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(FRACTIONAL_VELOCITY,r_geometry[i]); KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(VELOCITY,r_geometry[i]); KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(DISTANCE, r_geometry[i]); KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(MESH_VELOCITY,r_geometry[i]); @@ -358,18 +346,6 @@ void CalculateEffectiveViscosityAtGaussPoint() } else this->EffectiveViscosity = DynamicViscosity; } - -void ComputeDarcyTerm() -{ - array_1d convective_velocity(3, 0.0); - for (size_t i = 0; i < TNumNodes; i++) { - for (size_t j = 0; j < TDim; j++) { - convective_velocity[j] += this->N[i] * (Velocity(i, j) - MeshVelocity(i, j)); - } - } - const double convective_velocity_norm = MathUtils::Norm(convective_velocity); - DarcyTerm = this->EffectiveViscosity * LinearDarcyCoefficient + Density * NonLinearDarcyCoefficient * convective_velocity_norm; -} ///@} }; diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h index 0f897b76ed24..00b51faa7dc1 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h @@ -11,8 +11,7 @@ // -#if !defined(KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT_DATA_H) -#define KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT_DATA_H +#pragma once #include "fluid_dynamics_application_variables.h" #include "custom_elements/data_containers/fluid_element_data.h" @@ -46,13 +45,11 @@ static constexpr std::size_t BlockSize = TDim + 1; ///@{ -NodalVectorData Velocity_Fractional; -NodalVectorData Velocity_OldStep1; -NodalVectorData Velocity_OldStep2; -NodalVectorData Velocity_OldStep3; // Old step acceleration approximation using BDF2 +NodalVectorData FractionalVelocity; +NodalVectorData VelocityOldStep1; +NodalVectorData VelocityOldStep2; NodalVectorData MeshVelocity; -double DynamicViscosity; double DeltaTime; // Time increment double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients double bdf0; @@ -75,11 +72,11 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri { - const Geometry< Node >& r_geometry = rElement.GetGeometry(); - this->FillFromHistoricalNodalData(Velocity_OldStep1,VELOCITY,r_geometry,1); - this->FillFromHistoricalNodalData(Velocity_OldStep2,VELOCITY,r_geometry,2); - // this->FillFromHistoricalNodalData(Velocity_OldStep3, VELOCITY, r_geometry, 3); // Old step acceleration approximation using BDF2 - this->FillFromHistoricalNodalData(Velocity_Fractional, FRACTIONAL_VELOCITY, r_geometry, 0); + 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]; @@ -102,8 +99,7 @@ void UpdateGeometryValues( static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) { - const Geometry< Node >& r_geometry = rElement.GetGeometry(); - + const auto& r_geometry = rElement.GetGeometry(); for (unsigned int i = 0; i < TNumNodes; i++) { @@ -122,6 +118,4 @@ static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) ///@} -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp index 3cbd5a12234b..ea756e5ffc26 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp @@ -226,7 +226,7 @@ const Parameters TwoFluidNavierStokesFractional::GetSpecifications "nodal_non_historical" : [], "entity" : [] }, - "required_variables" : ["DISTANCE","VELOCITY","PRESSURE","MESH_VELOCITY","DENSITY","DYNAMIC_VISCOSITY"], + "required_variables" : ["DISTANCE","VELOCITY","PRESSURE","MESH_VELOCITY","DENSITY","DYNAMIC_VISCOSITY","FRACTIONAL_VELOCITY"], "required_dofs" : [], "flags_used" : [], "compatible_geometries" : ["Triangle2D3","Tetrahedra3D4"], @@ -315,7 +315,6 @@ void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( rData.CalculateAirMaterialResponse(); else this->CalculateMaterialResponse(rData); - rData.ComputeDarcyTerm(); } template @@ -334,7 +333,6 @@ void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( rData.CalculateAirMaterialResponse(); else this->CalculateMaterialResponse(rData); - rData.ComputeDarcyTerm(); } template <> @@ -344,17 +342,13 @@ void TwoFluidNavierStokesFractional>::C { const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto vn = rData.Velocity_OldStep1; + const auto vn = rData.VelocityOldStep1; const auto vconv = rData.Velocity - rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; // Get constitutive matrix const Matrix &C = rData.C; @@ -363,10 +357,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; const double clhs0 = C(0,0)*DN(0,0) + C(0,2)*DN(0,1); @@ -377,205 +367,202 @@ const double clhs4 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); const double clhs5 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); const double clhs6 = rho*stab_c2*sqrt(clhs4*clhs4 + clhs5*clhs5); const double clhs7 = clhs6*h*1.0/stab_c1 + mu; -const double clhs8 = N[0]*N[0]; -const double clhs9 = rho*(DN(0,0)*clhs4 + DN(0,1)*clhs5); +const double clhs8 = DN(0,0)*clhs4 + DN(0,1)*clhs5; +const double clhs9 = N[0]*rho; const double clhs10 = bdf0*rho; -const double clhs11 = K_darcy*N[0]; -const double clhs12 = N[0]*clhs10; -const double clhs13 = clhs11 + clhs12 + clhs9; -const double clhs14 = 1.0/(K_darcy + clhs6*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); -const double clhs15 = 1.0*clhs9; -const double clhs16 = clhs14*clhs15; -const double clhs17 = 1.0*clhs11; -const double clhs18 = clhs14*clhs17; -const double clhs19 = 1.0*clhs14; -const double clhs20 = clhs13*clhs19; -const double clhs21 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); -const double clhs22 = N[0]*clhs21; -const double clhs23 = K_darcy*clhs8 + N[0]*clhs9 + clhs10*clhs8 + clhs13*clhs16 - clhs13*clhs18 + clhs20*clhs22; -const double clhs24 = C(0,1)*DN(0,1) + clhs1; -const double clhs25 = C(1,2)*DN(0,1); -const double clhs26 = C(2,2)*DN(0,0) + clhs25; -const double clhs27 = DN(0,0)*clhs7; -const double clhs28 = DN(0,1)*clhs27; -const double clhs29 = clhs19*clhs21; -const double clhs30 = N[0]*clhs29 - N[0] + clhs16 - clhs18; -const double clhs31 = C(0,0)*DN(1,0) + C(0,2)*DN(1,1); -const double clhs32 = C(0,2)*DN(1,0); -const double clhs33 = C(2,2)*DN(1,1) + clhs32; -const double clhs34 = DN(0,0)*DN(1,0); -const double clhs35 = N[1]*clhs11 + N[1]*clhs12; -const double clhs36 = clhs34*clhs7 + clhs35; -const double clhs37 = rho*(DN(1,0)*clhs4 + DN(1,1)*clhs5); -const double clhs38 = K_darcy*N[1]; -const double clhs39 = N[1]*clhs10; -const double clhs40 = clhs37 + clhs38 + clhs39; -const double clhs41 = clhs19*clhs40; -const double clhs42 = N[0]*clhs37 + clhs16*clhs40 - clhs18*clhs40 + clhs22*clhs41; -const double clhs43 = C(0,1)*DN(1,1) + clhs32; -const double clhs44 = C(1,2)*DN(1,1); -const double clhs45 = C(2,2)*DN(1,0) + clhs44; -const double clhs46 = DN(1,1)*clhs27; -const double clhs47 = DN(0,0)*N[1]; -const double clhs48 = DN(1,0)*N[0]; -const double clhs49 = C(0,0)*DN(2,0) + C(0,2)*DN(2,1); -const double clhs50 = C(0,2)*DN(2,0); -const double clhs51 = C(2,2)*DN(2,1) + clhs50; -const double clhs52 = DN(0,0)*DN(2,0); -const double clhs53 = N[2]*clhs11 + N[2]*clhs12; -const double clhs54 = clhs52*clhs7 + clhs53; -const double clhs55 = rho*(DN(2,0)*clhs4 + DN(2,1)*clhs5); -const double clhs56 = K_darcy*N[2]; -const double clhs57 = N[2]*clhs10; -const double clhs58 = clhs55 + clhs56 + clhs57; -const double clhs59 = clhs19*clhs58; -const double clhs60 = N[0]*clhs55 + clhs16*clhs58 - clhs18*clhs58 + clhs22*clhs59; -const double clhs61 = C(0,1)*DN(2,1) + clhs50; -const double clhs62 = C(1,2)*DN(2,1); -const double clhs63 = C(2,2)*DN(2,0) + clhs62; -const double clhs64 = DN(2,1)*clhs27; -const double clhs65 = DN(0,0)*N[2]; -const double clhs66 = DN(2,0)*N[0]; -const double clhs67 = C(0,1)*DN(0,0) + clhs25; -const double clhs68 = C(1,1)*DN(0,1) + C(1,2)*DN(0,0); -const double clhs69 = DN(0,1)*DN(0,1); -const double clhs70 = C(0,1)*DN(1,0) + clhs44; -const double clhs71 = DN(0,1)*clhs7; -const double clhs72 = DN(1,0)*clhs71; -const double clhs73 = C(1,1)*DN(1,1) + C(1,2)*DN(1,0); -const double clhs74 = DN(0,1)*DN(1,1); -const double clhs75 = clhs35 + clhs7*clhs74; -const double clhs76 = DN(0,1)*N[1]; -const double clhs77 = DN(1,1)*N[0]; -const double clhs78 = C(0,1)*DN(2,0) + clhs62; -const double clhs79 = DN(2,0)*clhs71; -const double clhs80 = C(1,1)*DN(2,1) + C(1,2)*DN(2,0); -const double clhs81 = DN(0,1)*DN(2,1); -const double clhs82 = clhs53 + clhs7*clhs81; -const double clhs83 = DN(0,1)*N[2]; -const double clhs84 = DN(2,1)*N[0]; -const double clhs85 = N[0] + clhs14*(1.0*clhs12 + clhs15 + clhs17); -const double clhs86 = clhs19*(clhs34 + clhs74); -const double clhs87 = clhs19*(clhs52 + clhs81); -const double clhs88 = clhs19*clhs37; -const double clhs89 = clhs19*clhs38; -const double clhs90 = N[1]*clhs21; -const double clhs91 = N[1]*clhs9 + clhs13*clhs88 - clhs13*clhs89 + clhs20*clhs90; -const double clhs92 = DN(1,0)*DN(1,0); -const double clhs93 = N[1]*N[1]; -const double clhs94 = K_darcy*clhs93 + N[1]*clhs37 + clhs10*clhs93 + clhs37*clhs41 - clhs38*clhs41 + clhs41*clhs90; -const double clhs95 = DN(1,0)*clhs7; -const double clhs96 = DN(1,1)*clhs95; -const double clhs97 = N[1]*clhs29 - N[1] + clhs88 - clhs89; -const double clhs98 = DN(1,0)*DN(2,0); -const double clhs99 = N[2]*clhs38 + N[2]*clhs39; -const double clhs100 = clhs7*clhs98 + clhs99; -const double clhs101 = N[1]*clhs55 + clhs37*clhs59 - clhs38*clhs59 + clhs59*clhs90; -const double clhs102 = DN(2,1)*clhs95; -const double clhs103 = DN(1,0)*N[2]; -const double clhs104 = DN(2,0)*N[1]; -const double clhs105 = DN(1,1)*DN(1,1); -const double clhs106 = DN(2,0)*clhs7; -const double clhs107 = DN(1,1)*clhs106; -const double clhs108 = DN(1,1)*DN(2,1); -const double clhs109 = clhs108*clhs7 + clhs99; -const double clhs110 = DN(1,1)*N[2]; -const double clhs111 = DN(2,1)*N[1]; -const double clhs112 = N[1] + clhs14*(1.0*clhs37 + 1.0*clhs38 + 1.0*clhs39); -const double clhs113 = clhs19*(clhs108 + clhs98); -const double clhs114 = N[2]*clhs21; -const double clhs115 = N[2]*clhs9 + clhs114*clhs20 + clhs20*clhs55 - clhs20*clhs56; -const double clhs116 = clhs19*clhs56; -const double clhs117 = clhs19*clhs55; -const double clhs118 = N[2]*clhs37 + clhs114*clhs41 + clhs41*clhs55 - clhs41*clhs56; -const double clhs119 = DN(2,0)*DN(2,0); -const double clhs120 = N[2]*N[2]; -const double clhs121 = K_darcy*clhs120 + N[2]*clhs55 + clhs10*clhs120 + clhs114*clhs59 + clhs55*clhs59 - clhs56*clhs59; -const double clhs122 = DN(2,1)*clhs106; -const double clhs123 = N[2]*clhs29 - N[2] - clhs116 + clhs117; -const double clhs124 = DN(2,1)*DN(2,1); -const double clhs125 = N[2] + clhs14*(1.0*clhs55 + 1.0*clhs56 + 1.0*clhs57); -lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + clhs23 + clhs3*clhs7; -lhs(0,1)=DN(0,0)*clhs24 + DN(0,1)*clhs26 + clhs28; -lhs(0,2)=DN(0,0)*clhs30; -lhs(0,3)=DN(0,0)*clhs31 + DN(0,1)*clhs33 + clhs36 + clhs42; -lhs(0,4)=DN(0,0)*clhs43 + DN(0,1)*clhs45 + clhs46; -lhs(0,5)=DN(1,0)*clhs16 - DN(1,0)*clhs18 + clhs29*clhs48 - clhs47; -lhs(0,6)=DN(0,0)*clhs49 + DN(0,1)*clhs51 + clhs54 + clhs60; -lhs(0,7)=DN(0,0)*clhs61 + DN(0,1)*clhs63 + clhs64; -lhs(0,8)=DN(2,0)*clhs16 - DN(2,0)*clhs18 + clhs29*clhs66 - clhs65; -lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs67 + clhs28; -lhs(1,1)=DN(0,0)*clhs26 + DN(0,1)*clhs68 + clhs23 + clhs69*clhs7; -lhs(1,2)=DN(0,1)*clhs30; -lhs(1,3)=DN(0,0)*clhs33 + DN(0,1)*clhs70 + clhs72; -lhs(1,4)=DN(0,0)*clhs45 + DN(0,1)*clhs73 + clhs42 + clhs75; -lhs(1,5)=DN(1,1)*clhs16 - DN(1,1)*clhs18 + clhs29*clhs77 - clhs76; -lhs(1,6)=DN(0,0)*clhs51 + DN(0,1)*clhs78 + clhs79; -lhs(1,7)=DN(0,0)*clhs63 + DN(0,1)*clhs80 + clhs60 + clhs82; -lhs(1,8)=DN(2,1)*clhs16 - DN(2,1)*clhs18 + clhs29*clhs84 - clhs83; -lhs(2,0)=DN(0,0)*clhs85; -lhs(2,1)=DN(0,1)*clhs85; -lhs(2,2)=clhs19*(clhs3 + clhs69); -lhs(2,3)=DN(0,0)*clhs41 + clhs48; -lhs(2,4)=DN(0,1)*clhs41 + clhs77; -lhs(2,5)=clhs86; -lhs(2,6)=DN(0,0)*clhs59 + clhs66; -lhs(2,7)=DN(0,1)*clhs59 + clhs84; -lhs(2,8)=clhs87; -lhs(3,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + clhs36 + clhs91; -lhs(3,1)=DN(1,0)*clhs24 + DN(1,1)*clhs26 + clhs72; -lhs(3,2)=DN(0,0)*clhs88 - DN(0,0)*clhs89 + clhs29*clhs47 - clhs48; -lhs(3,3)=DN(1,0)*clhs31 + DN(1,1)*clhs33 + clhs7*clhs92 + clhs94; -lhs(3,4)=DN(1,0)*clhs43 + DN(1,1)*clhs45 + clhs96; -lhs(3,5)=DN(1,0)*clhs97; -lhs(3,6)=DN(1,0)*clhs49 + DN(1,1)*clhs51 + clhs100 + clhs101; -lhs(3,7)=DN(1,0)*clhs61 + DN(1,1)*clhs63 + clhs102; -lhs(3,8)=DN(2,0)*clhs88 - DN(2,0)*clhs89 - clhs103 + clhs104*clhs29; -lhs(4,0)=DN(1,0)*clhs2 + DN(1,1)*clhs67 + clhs46; -lhs(4,1)=DN(1,0)*clhs26 + DN(1,1)*clhs68 + clhs75 + clhs91; -lhs(4,2)=DN(0,1)*clhs88 - DN(0,1)*clhs89 + clhs29*clhs76 - clhs77; -lhs(4,3)=DN(1,0)*clhs33 + DN(1,1)*clhs70 + clhs96; -lhs(4,4)=DN(1,0)*clhs45 + DN(1,1)*clhs73 + clhs105*clhs7 + clhs94; -lhs(4,5)=DN(1,1)*clhs97; -lhs(4,6)=DN(1,0)*clhs51 + DN(1,1)*clhs78 + clhs107; -lhs(4,7)=DN(1,0)*clhs63 + DN(1,1)*clhs80 + clhs101 + clhs109; -lhs(4,8)=DN(2,1)*clhs88 - DN(2,1)*clhs89 - clhs110 + clhs111*clhs29; -lhs(5,0)=DN(1,0)*clhs20 + clhs47; -lhs(5,1)=DN(1,1)*clhs20 + clhs76; -lhs(5,2)=clhs86; -lhs(5,3)=DN(1,0)*clhs112; -lhs(5,4)=DN(1,1)*clhs112; -lhs(5,5)=clhs19*(clhs105 + clhs92); -lhs(5,6)=DN(1,0)*clhs59 + clhs104; -lhs(5,7)=DN(1,1)*clhs59 + clhs111; -lhs(5,8)=clhs113; -lhs(6,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + clhs115 + clhs54; -lhs(6,1)=DN(2,0)*clhs24 + DN(2,1)*clhs26 + clhs79; -lhs(6,2)=-DN(0,0)*clhs116 + DN(0,0)*clhs117 + clhs29*clhs65 - clhs66; -lhs(6,3)=DN(2,0)*clhs31 + DN(2,1)*clhs33 + clhs100 + clhs118; -lhs(6,4)=DN(2,0)*clhs43 + DN(2,1)*clhs45 + clhs107; -lhs(6,5)=-DN(1,0)*clhs116 + DN(1,0)*clhs117 + clhs103*clhs29 - clhs104; -lhs(6,6)=DN(2,0)*clhs49 + DN(2,1)*clhs51 + clhs119*clhs7 + clhs121; -lhs(6,7)=DN(2,0)*clhs61 + DN(2,1)*clhs63 + clhs122; -lhs(6,8)=DN(2,0)*clhs123; -lhs(7,0)=DN(2,0)*clhs2 + DN(2,1)*clhs67 + clhs64; -lhs(7,1)=DN(2,0)*clhs26 + DN(2,1)*clhs68 + clhs115 + clhs82; -lhs(7,2)=-DN(0,1)*clhs116 + DN(0,1)*clhs117 + clhs29*clhs83 - clhs84; -lhs(7,3)=DN(2,0)*clhs33 + DN(2,1)*clhs70 + clhs102; -lhs(7,4)=DN(2,0)*clhs45 + DN(2,1)*clhs73 + clhs109 + clhs118; -lhs(7,5)=-DN(1,1)*clhs116 + DN(1,1)*clhs117 + clhs110*clhs29 - clhs111; -lhs(7,6)=DN(2,0)*clhs51 + DN(2,1)*clhs78 + clhs122; -lhs(7,7)=DN(2,0)*clhs63 + DN(2,1)*clhs80 + clhs121 + clhs124*clhs7; -lhs(7,8)=DN(2,1)*clhs123; -lhs(8,0)=DN(2,0)*clhs20 + clhs65; -lhs(8,1)=DN(2,1)*clhs20 + clhs83; -lhs(8,2)=clhs87; -lhs(8,3)=DN(2,0)*clhs41 + clhs103; -lhs(8,4)=DN(2,1)*clhs41 + clhs110; -lhs(8,5)=clhs113; -lhs(8,6)=DN(2,0)*clhs125; -lhs(8,7)=DN(2,1)*clhs125; -lhs(8,8)=clhs19*(clhs119 + clhs124); +const double clhs11 = N[0]*bdf0; +const double clhs12 = clhs11 + clhs8; +const double clhs13 = 1.0*1.0/(clhs6*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); +const double clhs14 = clhs13*(rho*rho); +const double clhs15 = clhs14*clhs8; +const double clhs16 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); +const double clhs17 = clhs14*clhs16; +const double clhs18 = N[0]*clhs17; +const double clhs19 = clhs10*(N[0]*N[0]) + clhs12*clhs15 + clhs12*clhs18 + clhs8*clhs9; +const double clhs20 = C(0,1)*DN(0,1) + clhs1; +const double clhs21 = C(1,2)*DN(0,1); +const double clhs22 = C(2,2)*DN(0,0) + clhs21; +const double clhs23 = DN(0,0)*clhs7; +const double clhs24 = DN(0,1)*clhs23; +const double clhs25 = clhs13*clhs16; +const double clhs26 = clhs13*rho; +const double clhs27 = clhs26*clhs8; +const double clhs28 = -N[0] + clhs25*clhs9 + clhs27; +const double clhs29 = C(0,0)*DN(1,0) + C(0,2)*DN(1,1); +const double clhs30 = C(0,2)*DN(1,0); +const double clhs31 = C(2,2)*DN(1,1) + clhs30; +const double clhs32 = DN(0,0)*DN(1,0); +const double clhs33 = N[1]*rho; +const double clhs34 = clhs11*clhs33; +const double clhs35 = clhs32*clhs7 + clhs34; +const double clhs36 = DN(1,0)*clhs4 + DN(1,1)*clhs5; +const double clhs37 = N[1]*bdf0; +const double clhs38 = clhs36 + clhs37; +const double clhs39 = clhs15*clhs38 + clhs18*clhs38 + clhs36*clhs9; +const double clhs40 = C(0,1)*DN(1,1) + clhs30; +const double clhs41 = C(1,2)*DN(1,1); +const double clhs42 = C(2,2)*DN(1,0) + clhs41; +const double clhs43 = DN(1,1)*clhs23; +const double clhs44 = DN(0,0)*N[1]; +const double clhs45 = DN(1,0)*N[0]; +const double clhs46 = clhs16*clhs26; +const double clhs47 = C(0,0)*DN(2,0) + C(0,2)*DN(2,1); +const double clhs48 = C(0,2)*DN(2,0); +const double clhs49 = C(2,2)*DN(2,1) + clhs48; +const double clhs50 = DN(0,0)*DN(2,0); +const double clhs51 = N[2]*rho; +const double clhs52 = clhs11*clhs51; +const double clhs53 = clhs50*clhs7 + clhs52; +const double clhs54 = DN(2,0)*clhs4 + DN(2,1)*clhs5; +const double clhs55 = N[2]*bdf0 + clhs54; +const double clhs56 = clhs15*clhs55 + clhs18*clhs55 + clhs54*clhs9; +const double clhs57 = C(0,1)*DN(2,1) + clhs48; +const double clhs58 = C(1,2)*DN(2,1); +const double clhs59 = C(2,2)*DN(2,0) + clhs58; +const double clhs60 = DN(2,1)*clhs23; +const double clhs61 = DN(0,0)*N[2]; +const double clhs62 = DN(2,0)*N[0]; +const double clhs63 = C(0,1)*DN(0,0) + clhs21; +const double clhs64 = C(1,1)*DN(0,1) + C(1,2)*DN(0,0); +const double clhs65 = DN(0,1)*DN(0,1); +const double clhs66 = C(0,1)*DN(1,0) + clhs41; +const double clhs67 = DN(0,1)*clhs7; +const double clhs68 = DN(1,0)*clhs67; +const double clhs69 = C(1,1)*DN(1,1) + C(1,2)*DN(1,0); +const double clhs70 = DN(0,1)*DN(1,1); +const double clhs71 = clhs34 + clhs7*clhs70; +const double clhs72 = DN(0,1)*N[1]; +const double clhs73 = DN(1,1)*N[0]; +const double clhs74 = C(0,1)*DN(2,0) + clhs58; +const double clhs75 = DN(2,0)*clhs67; +const double clhs76 = C(1,1)*DN(2,1) + C(1,2)*DN(2,0); +const double clhs77 = DN(0,1)*DN(2,1); +const double clhs78 = clhs52 + clhs7*clhs77; +const double clhs79 = DN(0,1)*N[2]; +const double clhs80 = DN(2,1)*N[0]; +const double clhs81 = clhs12*clhs26; +const double clhs82 = N[0] + clhs81; +const double clhs83 = clhs26*clhs38; +const double clhs84 = clhs13*(clhs32 + clhs70); +const double clhs85 = clhs26*clhs55; +const double clhs86 = clhs13*(clhs50 + clhs77); +const double clhs87 = clhs14*clhs36; +const double clhs88 = N[1]*clhs17; +const double clhs89 = clhs12*clhs87 + clhs12*clhs88 + clhs33*clhs8; +const double clhs90 = clhs26*clhs36; +const double clhs91 = DN(1,0)*DN(1,0); +const double clhs92 = clhs10*(N[1]*N[1]) + clhs33*clhs36 + clhs38*clhs87 + clhs38*clhs88; +const double clhs93 = DN(1,0)*clhs7; +const double clhs94 = DN(1,1)*clhs93; +const double clhs95 = -N[1] + clhs25*clhs33 + clhs90; +const double clhs96 = DN(1,0)*DN(2,0); +const double clhs97 = clhs37*clhs51; +const double clhs98 = clhs7*clhs96 + clhs97; +const double clhs99 = clhs33*clhs54 + clhs55*clhs87 + clhs55*clhs88; +const double clhs100 = DN(2,1)*clhs93; +const double clhs101 = DN(1,0)*N[2]; +const double clhs102 = DN(2,0)*N[1]; +const double clhs103 = DN(1,1)*DN(1,1); +const double clhs104 = DN(2,0)*clhs7; +const double clhs105 = DN(1,1)*clhs104; +const double clhs106 = DN(1,1)*DN(2,1); +const double clhs107 = clhs106*clhs7 + clhs97; +const double clhs108 = DN(1,1)*N[2]; +const double clhs109 = DN(2,1)*N[1]; +const double clhs110 = N[1] + clhs83; +const double clhs111 = clhs13*(clhs106 + clhs96); +const double clhs112 = clhs14*clhs54; +const double clhs113 = N[2]*clhs17; +const double clhs114 = clhs112*clhs12 + clhs113*clhs12 + clhs51*clhs8; +const double clhs115 = clhs26*clhs54; +const double clhs116 = clhs112*clhs38 + clhs113*clhs38 + clhs36*clhs51; +const double clhs117 = DN(2,0)*DN(2,0); +const double clhs118 = clhs10*(N[2]*N[2]) + clhs112*clhs55 + clhs113*clhs55 + clhs51*clhs54; +const double clhs119 = DN(2,1)*clhs104; +const double clhs120 = -N[2] + clhs115 + clhs25*clhs51; +const double clhs121 = DN(2,1)*DN(2,1); +const double clhs122 = N[2] + clhs85; +lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + clhs19 + clhs3*clhs7; +lhs(0,1)=DN(0,0)*clhs20 + DN(0,1)*clhs22 + clhs24; +lhs(0,2)=DN(0,0)*clhs28; +lhs(0,3)=DN(0,0)*clhs29 + DN(0,1)*clhs31 + clhs35 + clhs39; +lhs(0,4)=DN(0,0)*clhs40 + DN(0,1)*clhs42 + clhs43; +lhs(0,5)=DN(1,0)*clhs27 - clhs44 + clhs45*clhs46; +lhs(0,6)=DN(0,0)*clhs47 + DN(0,1)*clhs49 + clhs53 + clhs56; +lhs(0,7)=DN(0,0)*clhs57 + DN(0,1)*clhs59 + clhs60; +lhs(0,8)=DN(2,0)*clhs27 + clhs46*clhs62 - clhs61; +lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs63 + clhs24; +lhs(1,1)=DN(0,0)*clhs22 + DN(0,1)*clhs64 + clhs19 + clhs65*clhs7; +lhs(1,2)=DN(0,1)*clhs28; +lhs(1,3)=DN(0,0)*clhs31 + DN(0,1)*clhs66 + clhs68; +lhs(1,4)=DN(0,0)*clhs42 + DN(0,1)*clhs69 + clhs39 + clhs71; +lhs(1,5)=DN(1,1)*clhs27 + clhs46*clhs73 - clhs72; +lhs(1,6)=DN(0,0)*clhs49 + DN(0,1)*clhs74 + clhs75; +lhs(1,7)=DN(0,0)*clhs59 + DN(0,1)*clhs76 + clhs56 + clhs78; +lhs(1,8)=DN(2,1)*clhs27 + clhs46*clhs80 - clhs79; +lhs(2,0)=DN(0,0)*clhs82; +lhs(2,1)=DN(0,1)*clhs82; +lhs(2,2)=clhs13*(clhs3 + clhs65); +lhs(2,3)=DN(0,0)*clhs83 + clhs45; +lhs(2,4)=DN(0,1)*clhs83 + clhs73; +lhs(2,5)=clhs84; +lhs(2,6)=DN(0,0)*clhs85 + clhs62; +lhs(2,7)=DN(0,1)*clhs85 + clhs80; +lhs(2,8)=clhs86; +lhs(3,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + clhs35 + clhs89; +lhs(3,1)=DN(1,0)*clhs20 + DN(1,1)*clhs22 + clhs68; +lhs(3,2)=DN(0,0)*clhs90 + clhs44*clhs46 - clhs45; +lhs(3,3)=DN(1,0)*clhs29 + DN(1,1)*clhs31 + clhs7*clhs91 + clhs92; +lhs(3,4)=DN(1,0)*clhs40 + DN(1,1)*clhs42 + clhs94; +lhs(3,5)=DN(1,0)*clhs95; +lhs(3,6)=DN(1,0)*clhs47 + DN(1,1)*clhs49 + clhs98 + clhs99; +lhs(3,7)=DN(1,0)*clhs57 + DN(1,1)*clhs59 + clhs100; +lhs(3,8)=DN(2,0)*clhs90 - clhs101 + clhs102*clhs46; +lhs(4,0)=DN(1,0)*clhs2 + DN(1,1)*clhs63 + clhs43; +lhs(4,1)=DN(1,0)*clhs22 + DN(1,1)*clhs64 + clhs71 + clhs89; +lhs(4,2)=DN(0,1)*clhs90 + clhs46*clhs72 - clhs73; +lhs(4,3)=DN(1,0)*clhs31 + DN(1,1)*clhs66 + clhs94; +lhs(4,4)=DN(1,0)*clhs42 + DN(1,1)*clhs69 + clhs103*clhs7 + clhs92; +lhs(4,5)=DN(1,1)*clhs95; +lhs(4,6)=DN(1,0)*clhs49 + DN(1,1)*clhs74 + clhs105; +lhs(4,7)=DN(1,0)*clhs59 + DN(1,1)*clhs76 + clhs107 + clhs99; +lhs(4,8)=DN(2,1)*clhs90 - clhs108 + clhs109*clhs46; +lhs(5,0)=DN(1,0)*clhs81 + clhs44; +lhs(5,1)=DN(1,1)*clhs81 + clhs72; +lhs(5,2)=clhs84; +lhs(5,3)=DN(1,0)*clhs110; +lhs(5,4)=DN(1,1)*clhs110; +lhs(5,5)=clhs13*(clhs103 + clhs91); +lhs(5,6)=DN(1,0)*clhs85 + clhs102; +lhs(5,7)=DN(1,1)*clhs85 + clhs109; +lhs(5,8)=clhs111; +lhs(6,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + clhs114 + clhs53; +lhs(6,1)=DN(2,0)*clhs20 + DN(2,1)*clhs22 + clhs75; +lhs(6,2)=DN(0,0)*clhs115 + clhs46*clhs61 - clhs62; +lhs(6,3)=DN(2,0)*clhs29 + DN(2,1)*clhs31 + clhs116 + clhs98; +lhs(6,4)=DN(2,0)*clhs40 + DN(2,1)*clhs42 + clhs105; +lhs(6,5)=DN(1,0)*clhs115 + clhs101*clhs46 - clhs102; +lhs(6,6)=DN(2,0)*clhs47 + DN(2,1)*clhs49 + clhs117*clhs7 + clhs118; +lhs(6,7)=DN(2,0)*clhs57 + DN(2,1)*clhs59 + clhs119; +lhs(6,8)=DN(2,0)*clhs120; +lhs(7,0)=DN(2,0)*clhs2 + DN(2,1)*clhs63 + clhs60; +lhs(7,1)=DN(2,0)*clhs22 + DN(2,1)*clhs64 + clhs114 + clhs78; +lhs(7,2)=DN(0,1)*clhs115 + clhs46*clhs79 - clhs80; +lhs(7,3)=DN(2,0)*clhs31 + DN(2,1)*clhs66 + clhs100; +lhs(7,4)=DN(2,0)*clhs42 + DN(2,1)*clhs69 + clhs107 + clhs116; +lhs(7,5)=DN(1,1)*clhs115 + clhs108*clhs46 - clhs109; +lhs(7,6)=DN(2,0)*clhs49 + DN(2,1)*clhs74 + clhs119; +lhs(7,7)=DN(2,0)*clhs59 + DN(2,1)*clhs76 + clhs118 + clhs121*clhs7; +lhs(7,8)=DN(2,1)*clhs120; +lhs(8,0)=DN(2,0)*clhs81 + clhs61; +lhs(8,1)=DN(2,1)*clhs81 + clhs79; +lhs(8,2)=clhs86; +lhs(8,3)=DN(2,0)*clhs83 + clhs101; +lhs(8,4)=DN(2,1)*clhs83 + clhs108; +lhs(8,5)=clhs111; +lhs(8,6)=DN(2,0)*clhs122; +lhs(8,7)=DN(2,1)*clhs122; +lhs(8,8)=clhs13*(clhs117 + clhs121); // Add intermediate results to local system @@ -590,18 +577,13 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double K_darcy = rData.DarcyTerm; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - - const auto vn=rData.Velocity_OldStep1; + const auto vn=rData.VelocityOldStep1; const auto vconv = rData.Velocity - rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; // Get constitutive matrix const Matrix &C = rData.C; @@ -610,10 +592,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; const double clhs0 = C(0,0)*DN(0,0) + C(0,3)*DN(0,1) + C(0,5)*DN(0,2); @@ -627,597 +605,593 @@ const double clhs7 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]* const double clhs8 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); const double clhs9 = rho*stab_c2*sqrt(clhs6*clhs6 + clhs7*clhs7 + clhs8*clhs8); const double clhs10 = clhs9*h*1.0/stab_c1 + mu; -const double clhs11 = N[0]*N[0]; -const double clhs12 = rho*(DN(0,0)*clhs6 + DN(0,1)*clhs7 + DN(0,2)*clhs8); +const double clhs11 = DN(0,0)*clhs6 + DN(0,1)*clhs7 + DN(0,2)*clhs8; +const double clhs12 = N[0]*rho; const double clhs13 = bdf0*rho; -const double clhs14 = K_darcy*N[0]; -const double clhs15 = N[0]*clhs13; -const double clhs16 = clhs12 + clhs14 + clhs15; -const double clhs17 = 1.0/(K_darcy + clhs9*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); -const double clhs18 = 1.0*clhs12; -const double clhs19 = clhs17*clhs18; -const double clhs20 = 1.0*clhs14; -const double clhs21 = clhs17*clhs20; -const double clhs22 = 1.0*clhs17; -const double clhs23 = clhs16*clhs22; -const double clhs24 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); -const double clhs25 = N[0]*clhs24; -const double clhs26 = K_darcy*clhs11 + N[0]*clhs12 + clhs11*clhs13 + clhs16*clhs19 - clhs16*clhs21 + clhs23*clhs25; -const double clhs27 = C(0,1)*DN(0,1) + C(0,4)*DN(0,2) + clhs1; -const double clhs28 = C(1,3)*DN(0,1); -const double clhs29 = C(3,3)*DN(0,0) + C(3,4)*DN(0,2) + clhs28; -const double clhs30 = C(3,5)*DN(0,0); -const double clhs31 = C(4,5)*DN(0,2); -const double clhs32 = C(1,5)*DN(0,1) + clhs30 + clhs31; -const double clhs33 = DN(0,0)*clhs10; -const double clhs34 = DN(0,1)*clhs33; -const double clhs35 = C(0,2)*DN(0,2) + C(0,4)*DN(0,1) + clhs3; -const double clhs36 = C(3,4)*DN(0,1); -const double clhs37 = C(2,3)*DN(0,2) + clhs30 + clhs36; -const double clhs38 = C(2,5)*DN(0,2); -const double clhs39 = C(4,5)*DN(0,1) + C(5,5)*DN(0,0) + clhs38; -const double clhs40 = DN(0,2)*clhs33; -const double clhs41 = clhs22*clhs24; -const double clhs42 = N[0]*clhs41 - N[0] + clhs19 - clhs21; -const double clhs43 = C(0,0)*DN(1,0) + C(0,3)*DN(1,1) + C(0,5)*DN(1,2); -const double clhs44 = C(0,3)*DN(1,0); -const double clhs45 = C(3,3)*DN(1,1) + C(3,5)*DN(1,2) + clhs44; -const double clhs46 = C(0,5)*DN(1,0); -const double clhs47 = C(3,5)*DN(1,1) + C(5,5)*DN(1,2) + clhs46; -const double clhs48 = DN(0,0)*DN(1,0); -const double clhs49 = N[1]*clhs14 + N[1]*clhs15; -const double clhs50 = clhs10*clhs48 + clhs49; -const double clhs51 = rho*(DN(1,0)*clhs6 + DN(1,1)*clhs7 + DN(1,2)*clhs8); -const double clhs52 = K_darcy*N[1]; -const double clhs53 = N[1]*clhs13; -const double clhs54 = clhs51 + clhs52 + clhs53; -const double clhs55 = clhs22*clhs54; -const double clhs56 = N[0]*clhs51 + clhs19*clhs54 - clhs21*clhs54 + clhs25*clhs55; -const double clhs57 = C(0,1)*DN(1,1) + C(0,4)*DN(1,2) + clhs44; -const double clhs58 = C(1,3)*DN(1,1); -const double clhs59 = C(3,3)*DN(1,0) + C(3,4)*DN(1,2) + clhs58; -const double clhs60 = C(3,5)*DN(1,0); -const double clhs61 = C(4,5)*DN(1,2); -const double clhs62 = C(1,5)*DN(1,1) + clhs60 + clhs61; -const double clhs63 = DN(1,1)*clhs33; -const double clhs64 = C(0,2)*DN(1,2) + C(0,4)*DN(1,1) + clhs46; -const double clhs65 = C(3,4)*DN(1,1); -const double clhs66 = C(2,3)*DN(1,2) + clhs60 + clhs65; -const double clhs67 = C(2,5)*DN(1,2); -const double clhs68 = C(4,5)*DN(1,1) + C(5,5)*DN(1,0) + clhs67; -const double clhs69 = DN(1,2)*clhs33; -const double clhs70 = DN(0,0)*N[1]; -const double clhs71 = DN(1,0)*N[0]; -const double clhs72 = C(0,0)*DN(2,0) + C(0,3)*DN(2,1) + C(0,5)*DN(2,2); -const double clhs73 = C(0,3)*DN(2,0); -const double clhs74 = C(3,3)*DN(2,1) + C(3,5)*DN(2,2) + clhs73; -const double clhs75 = C(0,5)*DN(2,0); -const double clhs76 = C(3,5)*DN(2,1) + C(5,5)*DN(2,2) + clhs75; -const double clhs77 = DN(0,0)*DN(2,0); -const double clhs78 = N[2]*clhs14 + N[2]*clhs15; -const double clhs79 = clhs10*clhs77 + clhs78; -const double clhs80 = rho*(DN(2,0)*clhs6 + DN(2,1)*clhs7 + DN(2,2)*clhs8); -const double clhs81 = K_darcy*N[2]; -const double clhs82 = N[2]*clhs13; -const double clhs83 = clhs80 + clhs81 + clhs82; -const double clhs84 = clhs22*clhs83; -const double clhs85 = N[0]*clhs80 + clhs19*clhs83 - clhs21*clhs83 + clhs25*clhs84; -const double clhs86 = C(0,1)*DN(2,1) + C(0,4)*DN(2,2) + clhs73; -const double clhs87 = C(1,3)*DN(2,1); -const double clhs88 = C(3,3)*DN(2,0) + C(3,4)*DN(2,2) + clhs87; -const double clhs89 = C(3,5)*DN(2,0); -const double clhs90 = C(4,5)*DN(2,2); -const double clhs91 = C(1,5)*DN(2,1) + clhs89 + clhs90; -const double clhs92 = DN(2,1)*clhs33; -const double clhs93 = C(0,2)*DN(2,2) + C(0,4)*DN(2,1) + clhs75; -const double clhs94 = C(3,4)*DN(2,1); -const double clhs95 = C(2,3)*DN(2,2) + clhs89 + clhs94; -const double clhs96 = C(2,5)*DN(2,2); -const double clhs97 = C(4,5)*DN(2,1) + C(5,5)*DN(2,0) + clhs96; -const double clhs98 = DN(2,2)*clhs33; -const double clhs99 = DN(0,0)*N[2]; -const double clhs100 = DN(2,0)*N[0]; -const double clhs101 = C(0,0)*DN(3,0) + C(0,3)*DN(3,1) + C(0,5)*DN(3,2); -const double clhs102 = C(0,3)*DN(3,0); -const double clhs103 = C(3,3)*DN(3,1) + C(3,5)*DN(3,2) + clhs102; -const double clhs104 = C(0,5)*DN(3,0); -const double clhs105 = C(3,5)*DN(3,1) + C(5,5)*DN(3,2) + clhs104; -const double clhs106 = DN(0,0)*DN(3,0); -const double clhs107 = N[3]*clhs14 + N[3]*clhs15; -const double clhs108 = clhs10*clhs106 + clhs107; -const double clhs109 = rho*(DN(3,0)*clhs6 + DN(3,1)*clhs7 + DN(3,2)*clhs8); -const double clhs110 = K_darcy*N[3]; -const double clhs111 = N[3]*clhs13; -const double clhs112 = clhs109 + clhs110 + clhs111; -const double clhs113 = clhs112*clhs22; -const double clhs114 = N[0]*clhs109 + clhs112*clhs19 - clhs112*clhs21 + clhs113*clhs25; -const double clhs115 = C(0,1)*DN(3,1) + C(0,4)*DN(3,2) + clhs102; -const double clhs116 = C(1,3)*DN(3,1); -const double clhs117 = C(3,3)*DN(3,0) + C(3,4)*DN(3,2) + clhs116; -const double clhs118 = C(3,5)*DN(3,0); -const double clhs119 = C(4,5)*DN(3,2); -const double clhs120 = C(1,5)*DN(3,1) + clhs118 + clhs119; -const double clhs121 = DN(3,1)*clhs33; -const double clhs122 = C(0,2)*DN(3,2) + C(0,4)*DN(3,1) + clhs104; -const double clhs123 = C(3,4)*DN(3,1); -const double clhs124 = C(2,3)*DN(3,2) + clhs118 + clhs123; -const double clhs125 = C(2,5)*DN(3,2); -const double clhs126 = C(4,5)*DN(3,1) + C(5,5)*DN(3,0) + clhs125; -const double clhs127 = DN(3,2)*clhs33; -const double clhs128 = DN(0,0)*N[3]; -const double clhs129 = DN(3,0)*N[0]; -const double clhs130 = C(0,1)*DN(0,0) + C(1,5)*DN(0,2) + clhs28; -const double clhs131 = C(0,4)*DN(0,0) + clhs31 + clhs36; -const double clhs132 = C(1,1)*DN(0,1) + C(1,3)*DN(0,0) + C(1,4)*DN(0,2); -const double clhs133 = C(1,4)*DN(0,1); -const double clhs134 = C(3,4)*DN(0,0) + C(4,4)*DN(0,2) + clhs133; -const double clhs135 = DN(0,1)*DN(0,1); -const double clhs136 = C(1,2)*DN(0,2) + C(1,5)*DN(0,0) + clhs133; -const double clhs137 = C(2,4)*DN(0,2); -const double clhs138 = C(4,4)*DN(0,1) + C(4,5)*DN(0,0) + clhs137; -const double clhs139 = DN(0,1)*clhs10; -const double clhs140 = DN(0,2)*clhs139; -const double clhs141 = C(0,1)*DN(1,0) + C(1,5)*DN(1,2) + clhs58; -const double clhs142 = C(0,4)*DN(1,0) + clhs61 + clhs65; -const double clhs143 = DN(1,0)*clhs139; -const double clhs144 = C(1,1)*DN(1,1) + C(1,3)*DN(1,0) + C(1,4)*DN(1,2); -const double clhs145 = C(1,4)*DN(1,1); -const double clhs146 = C(3,4)*DN(1,0) + C(4,4)*DN(1,2) + clhs145; -const double clhs147 = DN(0,1)*DN(1,1); -const double clhs148 = clhs10*clhs147; -const double clhs149 = clhs49 + clhs56; -const double clhs150 = C(1,2)*DN(1,2) + C(1,5)*DN(1,0) + clhs145; -const double clhs151 = C(2,4)*DN(1,2); -const double clhs152 = C(4,4)*DN(1,1) + C(4,5)*DN(1,0) + clhs151; -const double clhs153 = DN(1,2)*clhs139; -const double clhs154 = DN(0,1)*N[1]; -const double clhs155 = DN(1,1)*N[0]; -const double clhs156 = C(0,1)*DN(2,0) + C(1,5)*DN(2,2) + clhs87; -const double clhs157 = C(0,4)*DN(2,0) + clhs90 + clhs94; -const double clhs158 = DN(2,0)*clhs139; -const double clhs159 = C(1,1)*DN(2,1) + C(1,3)*DN(2,0) + C(1,4)*DN(2,2); -const double clhs160 = C(1,4)*DN(2,1); -const double clhs161 = C(3,4)*DN(2,0) + C(4,4)*DN(2,2) + clhs160; -const double clhs162 = DN(0,1)*DN(2,1); -const double clhs163 = clhs10*clhs162; -const double clhs164 = clhs78 + clhs85; -const double clhs165 = C(1,2)*DN(2,2) + C(1,5)*DN(2,0) + clhs160; -const double clhs166 = C(2,4)*DN(2,2); -const double clhs167 = C(4,4)*DN(2,1) + C(4,5)*DN(2,0) + clhs166; -const double clhs168 = DN(2,2)*clhs139; -const double clhs169 = DN(0,1)*N[2]; -const double clhs170 = DN(2,1)*N[0]; -const double clhs171 = C(0,1)*DN(3,0) + C(1,5)*DN(3,2) + clhs116; -const double clhs172 = C(0,4)*DN(3,0) + clhs119 + clhs123; -const double clhs173 = DN(3,0)*clhs139; -const double clhs174 = C(1,1)*DN(3,1) + C(1,3)*DN(3,0) + C(1,4)*DN(3,2); -const double clhs175 = C(1,4)*DN(3,1); -const double clhs176 = C(3,4)*DN(3,0) + C(4,4)*DN(3,2) + clhs175; -const double clhs177 = DN(0,1)*DN(3,1); -const double clhs178 = clhs10*clhs177; -const double clhs179 = clhs107 + clhs114; -const double clhs180 = C(1,2)*DN(3,2) + C(1,5)*DN(3,0) + clhs175; -const double clhs181 = C(2,4)*DN(3,2); -const double clhs182 = C(4,4)*DN(3,1) + C(4,5)*DN(3,0) + clhs181; -const double clhs183 = DN(3,2)*clhs139; -const double clhs184 = DN(0,1)*N[3]; -const double clhs185 = DN(3,1)*N[0]; -const double clhs186 = C(0,2)*DN(0,0) + C(2,3)*DN(0,1) + clhs38; -const double clhs187 = C(1,2)*DN(0,1) + C(2,3)*DN(0,0) + clhs137; -const double clhs188 = C(2,2)*DN(0,2) + C(2,4)*DN(0,1) + C(2,5)*DN(0,0); -const double clhs189 = DN(0,2)*DN(0,2); -const double clhs190 = C(0,2)*DN(1,0) + C(2,3)*DN(1,1) + clhs67; -const double clhs191 = DN(0,2)*clhs10; -const double clhs192 = DN(1,0)*clhs191; -const double clhs193 = C(1,2)*DN(1,1) + C(2,3)*DN(1,0) + clhs151; -const double clhs194 = DN(1,1)*clhs191; -const double clhs195 = C(2,2)*DN(1,2) + C(2,4)*DN(1,1) + C(2,5)*DN(1,0); -const double clhs196 = DN(0,2)*DN(1,2); -const double clhs197 = clhs10*clhs196; -const double clhs198 = DN(0,2)*N[1]; -const double clhs199 = DN(1,2)*N[0]; -const double clhs200 = C(0,2)*DN(2,0) + C(2,3)*DN(2,1) + clhs96; -const double clhs201 = DN(2,0)*clhs191; -const double clhs202 = C(1,2)*DN(2,1) + C(2,3)*DN(2,0) + clhs166; -const double clhs203 = DN(2,1)*clhs191; -const double clhs204 = C(2,2)*DN(2,2) + C(2,4)*DN(2,1) + C(2,5)*DN(2,0); -const double clhs205 = DN(0,2)*DN(2,2); -const double clhs206 = clhs10*clhs205; -const double clhs207 = DN(0,2)*N[2]; -const double clhs208 = DN(2,2)*N[0]; -const double clhs209 = C(0,2)*DN(3,0) + C(2,3)*DN(3,1) + clhs125; -const double clhs210 = DN(3,0)*clhs191; -const double clhs211 = C(1,2)*DN(3,1) + C(2,3)*DN(3,0) + clhs181; -const double clhs212 = DN(3,1)*clhs191; -const double clhs213 = C(2,2)*DN(3,2) + C(2,4)*DN(3,1) + C(2,5)*DN(3,0); -const double clhs214 = DN(0,2)*DN(3,2); -const double clhs215 = clhs10*clhs214; -const double clhs216 = DN(0,2)*N[3]; -const double clhs217 = DN(3,2)*N[0]; -const double clhs218 = N[0] + clhs17*(1.0*clhs15 + clhs18 + clhs20); -const double clhs219 = clhs22*(clhs147 + clhs196 + clhs48); -const double clhs220 = clhs22*(clhs162 + clhs205 + clhs77); -const double clhs221 = clhs22*(clhs106 + clhs177 + clhs214); -const double clhs222 = clhs22*clhs51; -const double clhs223 = clhs22*clhs52; -const double clhs224 = N[1]*clhs24; -const double clhs225 = N[1]*clhs12 + clhs16*clhs222 - clhs16*clhs223 + clhs224*clhs23; -const double clhs226 = DN(1,0)*DN(1,0); -const double clhs227 = N[1]*N[1]; -const double clhs228 = K_darcy*clhs227 + N[1]*clhs51 + clhs13*clhs227 + clhs224*clhs55 + clhs51*clhs55 - clhs52*clhs55; -const double clhs229 = DN(1,0)*clhs10; -const double clhs230 = DN(1,1)*clhs229; -const double clhs231 = DN(1,2)*clhs229; -const double clhs232 = N[1]*clhs41 - N[1] + clhs222 - clhs223; -const double clhs233 = DN(1,0)*DN(2,0); -const double clhs234 = N[2]*clhs52 + N[2]*clhs53; -const double clhs235 = clhs10*clhs233 + clhs234; -const double clhs236 = N[1]*clhs80 + clhs224*clhs84 + clhs51*clhs84 - clhs52*clhs84; -const double clhs237 = DN(2,1)*clhs229; -const double clhs238 = DN(2,2)*clhs229; -const double clhs239 = DN(1,0)*N[2]; -const double clhs240 = DN(2,0)*N[1]; -const double clhs241 = DN(1,0)*DN(3,0); -const double clhs242 = N[3]*clhs52 + N[3]*clhs53; -const double clhs243 = clhs10*clhs241 + clhs242; -const double clhs244 = N[1]*clhs109 + clhs113*clhs224 + clhs113*clhs51 - clhs113*clhs52; -const double clhs245 = DN(3,1)*clhs229; -const double clhs246 = DN(3,2)*clhs229; -const double clhs247 = DN(1,0)*N[3]; -const double clhs248 = DN(3,0)*N[1]; -const double clhs249 = clhs225 + clhs49; -const double clhs250 = DN(1,1)*DN(1,1); -const double clhs251 = DN(1,1)*clhs10; -const double clhs252 = DN(1,2)*clhs251; -const double clhs253 = DN(2,0)*clhs251; -const double clhs254 = DN(1,1)*DN(2,1); -const double clhs255 = clhs10*clhs254; -const double clhs256 = clhs234 + clhs236; -const double clhs257 = DN(2,2)*clhs251; -const double clhs258 = DN(1,1)*N[2]; -const double clhs259 = DN(2,1)*N[1]; -const double clhs260 = DN(3,0)*clhs251; -const double clhs261 = DN(1,1)*DN(3,1); -const double clhs262 = clhs10*clhs261; -const double clhs263 = clhs242 + clhs244; -const double clhs264 = DN(3,2)*clhs251; -const double clhs265 = DN(1,1)*N[3]; -const double clhs266 = DN(3,1)*N[1]; -const double clhs267 = DN(1,2)*DN(1,2); -const double clhs268 = DN(1,2)*clhs10; -const double clhs269 = DN(2,0)*clhs268; -const double clhs270 = DN(2,1)*clhs268; -const double clhs271 = DN(1,2)*DN(2,2); -const double clhs272 = clhs10*clhs271; -const double clhs273 = DN(1,2)*N[2]; -const double clhs274 = DN(2,2)*N[1]; -const double clhs275 = DN(3,0)*clhs268; -const double clhs276 = DN(3,1)*clhs268; -const double clhs277 = DN(1,2)*DN(3,2); -const double clhs278 = clhs10*clhs277; -const double clhs279 = DN(1,2)*N[3]; -const double clhs280 = DN(3,2)*N[1]; -const double clhs281 = N[1] + clhs17*(1.0*clhs51 + 1.0*clhs52 + 1.0*clhs53); -const double clhs282 = clhs22*(clhs233 + clhs254 + clhs271); -const double clhs283 = clhs22*(clhs241 + clhs261 + clhs277); -const double clhs284 = N[2]*clhs24; -const double clhs285 = N[2]*clhs12 + clhs23*clhs284 + clhs23*clhs80 - clhs23*clhs81; -const double clhs286 = clhs22*clhs81; -const double clhs287 = clhs22*clhs80; -const double clhs288 = N[2]*clhs51 + clhs284*clhs55 + clhs55*clhs80 - clhs55*clhs81; -const double clhs289 = DN(2,0)*DN(2,0); -const double clhs290 = N[2]*N[2]; -const double clhs291 = K_darcy*clhs290 + N[2]*clhs80 + clhs13*clhs290 + clhs284*clhs84 + clhs80*clhs84 - clhs81*clhs84; -const double clhs292 = DN(2,0)*clhs10; -const double clhs293 = DN(2,1)*clhs292; -const double clhs294 = DN(2,2)*clhs292; -const double clhs295 = N[2]*clhs41 - N[2] - clhs286 + clhs287; -const double clhs296 = DN(2,0)*DN(3,0); -const double clhs297 = N[3]*clhs81 + N[3]*clhs82; -const double clhs298 = clhs10*clhs296 + clhs297; -const double clhs299 = N[2]*clhs109 + clhs113*clhs284 + clhs113*clhs80 - clhs113*clhs81; -const double clhs300 = DN(3,1)*clhs292; -const double clhs301 = DN(3,2)*clhs292; -const double clhs302 = DN(2,0)*N[3]; -const double clhs303 = DN(3,0)*N[2]; -const double clhs304 = clhs285 + clhs78; -const double clhs305 = clhs234 + clhs288; -const double clhs306 = DN(2,1)*DN(2,1); -const double clhs307 = DN(2,1)*clhs10; -const double clhs308 = DN(2,2)*clhs307; -const double clhs309 = DN(3,0)*clhs307; -const double clhs310 = DN(2,1)*DN(3,1); -const double clhs311 = clhs10*clhs310; -const double clhs312 = clhs297 + clhs299; -const double clhs313 = DN(3,2)*clhs307; -const double clhs314 = DN(2,1)*N[3]; -const double clhs315 = DN(3,1)*N[2]; -const double clhs316 = DN(2,2)*DN(2,2); -const double clhs317 = DN(2,2)*clhs10; -const double clhs318 = DN(3,0)*clhs317; -const double clhs319 = DN(3,1)*clhs317; -const double clhs320 = DN(2,2)*DN(3,2); -const double clhs321 = clhs10*clhs320; -const double clhs322 = DN(2,2)*N[3]; -const double clhs323 = DN(3,2)*N[2]; -const double clhs324 = N[2] + clhs17*(1.0*clhs80 + 1.0*clhs81 + 1.0*clhs82); -const double clhs325 = clhs22*(clhs296 + clhs310 + clhs320); -const double clhs326 = N[3]*clhs24; -const double clhs327 = N[3]*clhs12 + clhs109*clhs23 - clhs110*clhs23 + clhs23*clhs326; -const double clhs328 = clhs110*clhs22; -const double clhs329 = clhs109*clhs22; -const double clhs330 = N[3]*clhs51 + clhs109*clhs55 - clhs110*clhs55 + clhs326*clhs55; -const double clhs331 = N[3]*clhs80 + clhs109*clhs84 - clhs110*clhs84 + clhs326*clhs84; -const double clhs332 = DN(3,0)*DN(3,0); -const double clhs333 = N[3]*N[3]; -const double clhs334 = K_darcy*clhs333 + N[3]*clhs109 + clhs109*clhs113 - clhs110*clhs113 + clhs113*clhs326 + clhs13*clhs333; -const double clhs335 = DN(3,0)*clhs10; -const double clhs336 = DN(3,1)*clhs335; -const double clhs337 = DN(3,2)*clhs335; -const double clhs338 = N[3]*clhs41 - N[3] - clhs328 + clhs329; -const double clhs339 = clhs107 + clhs327; -const double clhs340 = clhs242 + clhs330; -const double clhs341 = clhs297 + clhs331; -const double clhs342 = DN(3,1)*DN(3,1); -const double clhs343 = DN(3,1)*DN(3,2)*clhs10; -const double clhs344 = DN(3,2)*DN(3,2); -const double clhs345 = N[3] + clhs17*(1.0*clhs109 + 1.0*clhs110 + 1.0*clhs111); -lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + DN(0,2)*clhs4 + clhs10*clhs5 + clhs26; -lhs(0,1)=DN(0,0)*clhs27 + DN(0,1)*clhs29 + DN(0,2)*clhs32 + clhs34; -lhs(0,2)=DN(0,0)*clhs35 + DN(0,1)*clhs37 + DN(0,2)*clhs39 + clhs40; -lhs(0,3)=DN(0,0)*clhs42; -lhs(0,4)=DN(0,0)*clhs43 + DN(0,1)*clhs45 + DN(0,2)*clhs47 + clhs50 + clhs56; -lhs(0,5)=DN(0,0)*clhs57 + DN(0,1)*clhs59 + DN(0,2)*clhs62 + clhs63; -lhs(0,6)=DN(0,0)*clhs64 + DN(0,1)*clhs66 + DN(0,2)*clhs68 + clhs69; -lhs(0,7)=DN(1,0)*clhs19 - DN(1,0)*clhs21 + clhs41*clhs71 - clhs70; -lhs(0,8)=DN(0,0)*clhs72 + DN(0,1)*clhs74 + DN(0,2)*clhs76 + clhs79 + clhs85; -lhs(0,9)=DN(0,0)*clhs86 + DN(0,1)*clhs88 + DN(0,2)*clhs91 + clhs92; -lhs(0,10)=DN(0,0)*clhs93 + DN(0,1)*clhs95 + DN(0,2)*clhs97 + clhs98; -lhs(0,11)=DN(2,0)*clhs19 - DN(2,0)*clhs21 + clhs100*clhs41 - clhs99; -lhs(0,12)=DN(0,0)*clhs101 + DN(0,1)*clhs103 + DN(0,2)*clhs105 + clhs108 + clhs114; -lhs(0,13)=DN(0,0)*clhs115 + DN(0,1)*clhs117 + DN(0,2)*clhs120 + clhs121; -lhs(0,14)=DN(0,0)*clhs122 + DN(0,1)*clhs124 + DN(0,2)*clhs126 + clhs127; -lhs(0,15)=DN(3,0)*clhs19 - DN(3,0)*clhs21 - clhs128 + clhs129*clhs41; -lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs130 + DN(0,2)*clhs131 + clhs34; -lhs(1,1)=DN(0,0)*clhs29 + DN(0,1)*clhs132 + DN(0,2)*clhs134 + clhs10*clhs135 + clhs26; -lhs(1,2)=DN(0,0)*clhs37 + DN(0,1)*clhs136 + DN(0,2)*clhs138 + clhs140; -lhs(1,3)=DN(0,1)*clhs42; -lhs(1,4)=DN(0,0)*clhs45 + DN(0,1)*clhs141 + DN(0,2)*clhs142 + clhs143; -lhs(1,5)=DN(0,0)*clhs59 + DN(0,1)*clhs144 + DN(0,2)*clhs146 + clhs148 + clhs149; -lhs(1,6)=DN(0,0)*clhs66 + DN(0,1)*clhs150 + DN(0,2)*clhs152 + clhs153; -lhs(1,7)=DN(1,1)*clhs19 - DN(1,1)*clhs21 - clhs154 + clhs155*clhs41; -lhs(1,8)=DN(0,0)*clhs74 + DN(0,1)*clhs156 + DN(0,2)*clhs157 + clhs158; -lhs(1,9)=DN(0,0)*clhs88 + DN(0,1)*clhs159 + DN(0,2)*clhs161 + clhs163 + clhs164; -lhs(1,10)=DN(0,0)*clhs95 + DN(0,1)*clhs165 + DN(0,2)*clhs167 + clhs168; -lhs(1,11)=DN(2,1)*clhs19 - DN(2,1)*clhs21 - clhs169 + clhs170*clhs41; -lhs(1,12)=DN(0,0)*clhs103 + DN(0,1)*clhs171 + DN(0,2)*clhs172 + clhs173; -lhs(1,13)=DN(0,0)*clhs117 + DN(0,1)*clhs174 + DN(0,2)*clhs176 + clhs178 + clhs179; -lhs(1,14)=DN(0,0)*clhs124 + DN(0,1)*clhs180 + DN(0,2)*clhs182 + clhs183; -lhs(1,15)=DN(3,1)*clhs19 - DN(3,1)*clhs21 - clhs184 + clhs185*clhs41; -lhs(2,0)=DN(0,0)*clhs4 + DN(0,1)*clhs131 + DN(0,2)*clhs186 + clhs40; -lhs(2,1)=DN(0,0)*clhs32 + DN(0,1)*clhs134 + DN(0,2)*clhs187 + clhs140; -lhs(2,2)=DN(0,0)*clhs39 + DN(0,1)*clhs138 + DN(0,2)*clhs188 + clhs10*clhs189 + clhs26; -lhs(2,3)=DN(0,2)*clhs42; -lhs(2,4)=DN(0,0)*clhs47 + DN(0,1)*clhs142 + DN(0,2)*clhs190 + clhs192; -lhs(2,5)=DN(0,0)*clhs62 + DN(0,1)*clhs146 + DN(0,2)*clhs193 + clhs194; -lhs(2,6)=DN(0,0)*clhs68 + DN(0,1)*clhs152 + DN(0,2)*clhs195 + clhs149 + clhs197; -lhs(2,7)=DN(1,2)*clhs19 - DN(1,2)*clhs21 - clhs198 + clhs199*clhs41; -lhs(2,8)=DN(0,0)*clhs76 + DN(0,1)*clhs157 + DN(0,2)*clhs200 + clhs201; -lhs(2,9)=DN(0,0)*clhs91 + DN(0,1)*clhs161 + DN(0,2)*clhs202 + clhs203; -lhs(2,10)=DN(0,0)*clhs97 + DN(0,1)*clhs167 + DN(0,2)*clhs204 + clhs164 + clhs206; -lhs(2,11)=DN(2,2)*clhs19 - DN(2,2)*clhs21 - clhs207 + clhs208*clhs41; -lhs(2,12)=DN(0,0)*clhs105 + DN(0,1)*clhs172 + DN(0,2)*clhs209 + clhs210; -lhs(2,13)=DN(0,0)*clhs120 + DN(0,1)*clhs176 + DN(0,2)*clhs211 + clhs212; -lhs(2,14)=DN(0,0)*clhs126 + DN(0,1)*clhs182 + DN(0,2)*clhs213 + clhs179 + clhs215; -lhs(2,15)=DN(3,2)*clhs19 - DN(3,2)*clhs21 - clhs216 + clhs217*clhs41; -lhs(3,0)=DN(0,0)*clhs218; -lhs(3,1)=DN(0,1)*clhs218; -lhs(3,2)=DN(0,2)*clhs218; -lhs(3,3)=clhs22*(clhs135 + clhs189 + clhs5); -lhs(3,4)=DN(0,0)*clhs55 + clhs71; -lhs(3,5)=DN(0,1)*clhs55 + clhs155; -lhs(3,6)=DN(0,2)*clhs55 + clhs199; -lhs(3,7)=clhs219; -lhs(3,8)=DN(0,0)*clhs84 + clhs100; -lhs(3,9)=DN(0,1)*clhs84 + clhs170; -lhs(3,10)=DN(0,2)*clhs84 + clhs208; -lhs(3,11)=clhs220; -lhs(3,12)=DN(0,0)*clhs113 + clhs129; -lhs(3,13)=DN(0,1)*clhs113 + clhs185; -lhs(3,14)=DN(0,2)*clhs113 + clhs217; -lhs(3,15)=clhs221; -lhs(4,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + DN(1,2)*clhs4 + clhs225 + clhs50; -lhs(4,1)=DN(1,0)*clhs27 + DN(1,1)*clhs29 + DN(1,2)*clhs32 + clhs143; -lhs(4,2)=DN(1,0)*clhs35 + DN(1,1)*clhs37 + DN(1,2)*clhs39 + clhs192; -lhs(4,3)=DN(0,0)*clhs222 - DN(0,0)*clhs223 + clhs41*clhs70 - clhs71; -lhs(4,4)=DN(1,0)*clhs43 + DN(1,1)*clhs45 + DN(1,2)*clhs47 + clhs10*clhs226 + clhs228; -lhs(4,5)=DN(1,0)*clhs57 + DN(1,1)*clhs59 + DN(1,2)*clhs62 + clhs230; -lhs(4,6)=DN(1,0)*clhs64 + DN(1,1)*clhs66 + DN(1,2)*clhs68 + clhs231; -lhs(4,7)=DN(1,0)*clhs232; -lhs(4,8)=DN(1,0)*clhs72 + DN(1,1)*clhs74 + DN(1,2)*clhs76 + clhs235 + clhs236; -lhs(4,9)=DN(1,0)*clhs86 + DN(1,1)*clhs88 + DN(1,2)*clhs91 + clhs237; -lhs(4,10)=DN(1,0)*clhs93 + DN(1,1)*clhs95 + DN(1,2)*clhs97 + clhs238; -lhs(4,11)=DN(2,0)*clhs222 - DN(2,0)*clhs223 - clhs239 + clhs240*clhs41; -lhs(4,12)=DN(1,0)*clhs101 + DN(1,1)*clhs103 + DN(1,2)*clhs105 + clhs243 + clhs244; -lhs(4,13)=DN(1,0)*clhs115 + DN(1,1)*clhs117 + DN(1,2)*clhs120 + clhs245; -lhs(4,14)=DN(1,0)*clhs122 + DN(1,1)*clhs124 + DN(1,2)*clhs126 + clhs246; -lhs(4,15)=DN(3,0)*clhs222 - DN(3,0)*clhs223 - clhs247 + clhs248*clhs41; -lhs(5,0)=DN(1,0)*clhs2 + DN(1,1)*clhs130 + DN(1,2)*clhs131 + clhs63; -lhs(5,1)=DN(1,0)*clhs29 + DN(1,1)*clhs132 + DN(1,2)*clhs134 + clhs148 + clhs249; -lhs(5,2)=DN(1,0)*clhs37 + DN(1,1)*clhs136 + DN(1,2)*clhs138 + clhs194; -lhs(5,3)=DN(0,1)*clhs222 - DN(0,1)*clhs223 + clhs154*clhs41 - clhs155; -lhs(5,4)=DN(1,0)*clhs45 + DN(1,1)*clhs141 + DN(1,2)*clhs142 + clhs230; -lhs(5,5)=DN(1,0)*clhs59 + DN(1,1)*clhs144 + DN(1,2)*clhs146 + clhs10*clhs250 + clhs228; -lhs(5,6)=DN(1,0)*clhs66 + DN(1,1)*clhs150 + DN(1,2)*clhs152 + clhs252; -lhs(5,7)=DN(1,1)*clhs232; -lhs(5,8)=DN(1,0)*clhs74 + DN(1,1)*clhs156 + DN(1,2)*clhs157 + clhs253; -lhs(5,9)=DN(1,0)*clhs88 + DN(1,1)*clhs159 + DN(1,2)*clhs161 + clhs255 + clhs256; -lhs(5,10)=DN(1,0)*clhs95 + DN(1,1)*clhs165 + DN(1,2)*clhs167 + clhs257; -lhs(5,11)=DN(2,1)*clhs222 - DN(2,1)*clhs223 - clhs258 + clhs259*clhs41; -lhs(5,12)=DN(1,0)*clhs103 + DN(1,1)*clhs171 + DN(1,2)*clhs172 + clhs260; -lhs(5,13)=DN(1,0)*clhs117 + DN(1,1)*clhs174 + DN(1,2)*clhs176 + clhs262 + clhs263; -lhs(5,14)=DN(1,0)*clhs124 + DN(1,1)*clhs180 + DN(1,2)*clhs182 + clhs264; -lhs(5,15)=DN(3,1)*clhs222 - DN(3,1)*clhs223 - clhs265 + clhs266*clhs41; -lhs(6,0)=DN(1,0)*clhs4 + DN(1,1)*clhs131 + DN(1,2)*clhs186 + clhs69; -lhs(6,1)=DN(1,0)*clhs32 + DN(1,1)*clhs134 + DN(1,2)*clhs187 + clhs153; -lhs(6,2)=DN(1,0)*clhs39 + DN(1,1)*clhs138 + DN(1,2)*clhs188 + clhs197 + clhs249; -lhs(6,3)=DN(0,2)*clhs222 - DN(0,2)*clhs223 + clhs198*clhs41 - clhs199; -lhs(6,4)=DN(1,0)*clhs47 + DN(1,1)*clhs142 + DN(1,2)*clhs190 + clhs231; -lhs(6,5)=DN(1,0)*clhs62 + DN(1,1)*clhs146 + DN(1,2)*clhs193 + clhs252; -lhs(6,6)=DN(1,0)*clhs68 + DN(1,1)*clhs152 + DN(1,2)*clhs195 + clhs10*clhs267 + clhs228; -lhs(6,7)=DN(1,2)*clhs232; -lhs(6,8)=DN(1,0)*clhs76 + DN(1,1)*clhs157 + DN(1,2)*clhs200 + clhs269; -lhs(6,9)=DN(1,0)*clhs91 + DN(1,1)*clhs161 + DN(1,2)*clhs202 + clhs270; -lhs(6,10)=DN(1,0)*clhs97 + DN(1,1)*clhs167 + DN(1,2)*clhs204 + clhs256 + clhs272; -lhs(6,11)=DN(2,2)*clhs222 - DN(2,2)*clhs223 - clhs273 + clhs274*clhs41; -lhs(6,12)=DN(1,0)*clhs105 + DN(1,1)*clhs172 + DN(1,2)*clhs209 + clhs275; -lhs(6,13)=DN(1,0)*clhs120 + DN(1,1)*clhs176 + DN(1,2)*clhs211 + clhs276; -lhs(6,14)=DN(1,0)*clhs126 + DN(1,1)*clhs182 + DN(1,2)*clhs213 + clhs263 + clhs278; -lhs(6,15)=DN(3,2)*clhs222 - DN(3,2)*clhs223 - clhs279 + clhs280*clhs41; -lhs(7,0)=DN(1,0)*clhs23 + clhs70; -lhs(7,1)=DN(1,1)*clhs23 + clhs154; -lhs(7,2)=DN(1,2)*clhs23 + clhs198; -lhs(7,3)=clhs219; -lhs(7,4)=DN(1,0)*clhs281; -lhs(7,5)=DN(1,1)*clhs281; -lhs(7,6)=DN(1,2)*clhs281; -lhs(7,7)=clhs22*(clhs226 + clhs250 + clhs267); -lhs(7,8)=DN(1,0)*clhs84 + clhs240; -lhs(7,9)=DN(1,1)*clhs84 + clhs259; -lhs(7,10)=DN(1,2)*clhs84 + clhs274; -lhs(7,11)=clhs282; -lhs(7,12)=DN(1,0)*clhs113 + clhs248; -lhs(7,13)=DN(1,1)*clhs113 + clhs266; -lhs(7,14)=DN(1,2)*clhs113 + clhs280; -lhs(7,15)=clhs283; -lhs(8,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + DN(2,2)*clhs4 + clhs285 + clhs79; -lhs(8,1)=DN(2,0)*clhs27 + DN(2,1)*clhs29 + DN(2,2)*clhs32 + clhs158; -lhs(8,2)=DN(2,0)*clhs35 + DN(2,1)*clhs37 + DN(2,2)*clhs39 + clhs201; -lhs(8,3)=-DN(0,0)*clhs286 + DN(0,0)*clhs287 - clhs100 + clhs41*clhs99; -lhs(8,4)=DN(2,0)*clhs43 + DN(2,1)*clhs45 + DN(2,2)*clhs47 + clhs235 + clhs288; -lhs(8,5)=DN(2,0)*clhs57 + DN(2,1)*clhs59 + DN(2,2)*clhs62 + clhs253; -lhs(8,6)=DN(2,0)*clhs64 + DN(2,1)*clhs66 + DN(2,2)*clhs68 + clhs269; -lhs(8,7)=-DN(1,0)*clhs286 + DN(1,0)*clhs287 + clhs239*clhs41 - clhs240; -lhs(8,8)=DN(2,0)*clhs72 + DN(2,1)*clhs74 + DN(2,2)*clhs76 + clhs10*clhs289 + clhs291; -lhs(8,9)=DN(2,0)*clhs86 + DN(2,1)*clhs88 + DN(2,2)*clhs91 + clhs293; -lhs(8,10)=DN(2,0)*clhs93 + DN(2,1)*clhs95 + DN(2,2)*clhs97 + clhs294; -lhs(8,11)=DN(2,0)*clhs295; -lhs(8,12)=DN(2,0)*clhs101 + DN(2,1)*clhs103 + DN(2,2)*clhs105 + clhs298 + clhs299; -lhs(8,13)=DN(2,0)*clhs115 + DN(2,1)*clhs117 + DN(2,2)*clhs120 + clhs300; -lhs(8,14)=DN(2,0)*clhs122 + DN(2,1)*clhs124 + DN(2,2)*clhs126 + clhs301; -lhs(8,15)=-DN(3,0)*clhs286 + DN(3,0)*clhs287 - clhs302 + clhs303*clhs41; -lhs(9,0)=DN(2,0)*clhs2 + DN(2,1)*clhs130 + DN(2,2)*clhs131 + clhs92; -lhs(9,1)=DN(2,0)*clhs29 + DN(2,1)*clhs132 + DN(2,2)*clhs134 + clhs163 + clhs304; -lhs(9,2)=DN(2,0)*clhs37 + DN(2,1)*clhs136 + DN(2,2)*clhs138 + clhs203; -lhs(9,3)=-DN(0,1)*clhs286 + DN(0,1)*clhs287 + clhs169*clhs41 - clhs170; -lhs(9,4)=DN(2,0)*clhs45 + DN(2,1)*clhs141 + DN(2,2)*clhs142 + clhs237; -lhs(9,5)=DN(2,0)*clhs59 + DN(2,1)*clhs144 + DN(2,2)*clhs146 + clhs255 + clhs305; -lhs(9,6)=DN(2,0)*clhs66 + DN(2,1)*clhs150 + DN(2,2)*clhs152 + clhs270; -lhs(9,7)=-DN(1,1)*clhs286 + DN(1,1)*clhs287 + clhs258*clhs41 - clhs259; -lhs(9,8)=DN(2,0)*clhs74 + DN(2,1)*clhs156 + DN(2,2)*clhs157 + clhs293; -lhs(9,9)=DN(2,0)*clhs88 + DN(2,1)*clhs159 + DN(2,2)*clhs161 + clhs10*clhs306 + clhs291; -lhs(9,10)=DN(2,0)*clhs95 + DN(2,1)*clhs165 + DN(2,2)*clhs167 + clhs308; -lhs(9,11)=DN(2,1)*clhs295; -lhs(9,12)=DN(2,0)*clhs103 + DN(2,1)*clhs171 + DN(2,2)*clhs172 + clhs309; -lhs(9,13)=DN(2,0)*clhs117 + DN(2,1)*clhs174 + DN(2,2)*clhs176 + clhs311 + clhs312; -lhs(9,14)=DN(2,0)*clhs124 + DN(2,1)*clhs180 + DN(2,2)*clhs182 + clhs313; -lhs(9,15)=-DN(3,1)*clhs286 + DN(3,1)*clhs287 - clhs314 + clhs315*clhs41; -lhs(10,0)=DN(2,0)*clhs4 + DN(2,1)*clhs131 + DN(2,2)*clhs186 + clhs98; -lhs(10,1)=DN(2,0)*clhs32 + DN(2,1)*clhs134 + DN(2,2)*clhs187 + clhs168; -lhs(10,2)=DN(2,0)*clhs39 + DN(2,1)*clhs138 + DN(2,2)*clhs188 + clhs206 + clhs304; -lhs(10,3)=-DN(0,2)*clhs286 + DN(0,2)*clhs287 + clhs207*clhs41 - clhs208; -lhs(10,4)=DN(2,0)*clhs47 + DN(2,1)*clhs142 + DN(2,2)*clhs190 + clhs238; -lhs(10,5)=DN(2,0)*clhs62 + DN(2,1)*clhs146 + DN(2,2)*clhs193 + clhs257; -lhs(10,6)=DN(2,0)*clhs68 + DN(2,1)*clhs152 + DN(2,2)*clhs195 + clhs272 + clhs305; -lhs(10,7)=-DN(1,2)*clhs286 + DN(1,2)*clhs287 + clhs273*clhs41 - clhs274; -lhs(10,8)=DN(2,0)*clhs76 + DN(2,1)*clhs157 + DN(2,2)*clhs200 + clhs294; -lhs(10,9)=DN(2,0)*clhs91 + DN(2,1)*clhs161 + DN(2,2)*clhs202 + clhs308; -lhs(10,10)=DN(2,0)*clhs97 + DN(2,1)*clhs167 + DN(2,2)*clhs204 + clhs10*clhs316 + clhs291; -lhs(10,11)=DN(2,2)*clhs295; -lhs(10,12)=DN(2,0)*clhs105 + DN(2,1)*clhs172 + DN(2,2)*clhs209 + clhs318; -lhs(10,13)=DN(2,0)*clhs120 + DN(2,1)*clhs176 + DN(2,2)*clhs211 + clhs319; -lhs(10,14)=DN(2,0)*clhs126 + DN(2,1)*clhs182 + DN(2,2)*clhs213 + clhs312 + clhs321; -lhs(10,15)=-DN(3,2)*clhs286 + DN(3,2)*clhs287 - clhs322 + clhs323*clhs41; -lhs(11,0)=DN(2,0)*clhs23 + clhs99; -lhs(11,1)=DN(2,1)*clhs23 + clhs169; -lhs(11,2)=DN(2,2)*clhs23 + clhs207; -lhs(11,3)=clhs220; -lhs(11,4)=DN(2,0)*clhs55 + clhs239; -lhs(11,5)=DN(2,1)*clhs55 + clhs258; -lhs(11,6)=DN(2,2)*clhs55 + clhs273; -lhs(11,7)=clhs282; -lhs(11,8)=DN(2,0)*clhs324; -lhs(11,9)=DN(2,1)*clhs324; -lhs(11,10)=DN(2,2)*clhs324; -lhs(11,11)=clhs22*(clhs289 + clhs306 + clhs316); -lhs(11,12)=DN(2,0)*clhs113 + clhs303; -lhs(11,13)=DN(2,1)*clhs113 + clhs315; -lhs(11,14)=DN(2,2)*clhs113 + clhs323; -lhs(11,15)=clhs325; -lhs(12,0)=DN(3,0)*clhs0 + DN(3,1)*clhs2 + DN(3,2)*clhs4 + clhs108 + clhs327; -lhs(12,1)=DN(3,0)*clhs27 + DN(3,1)*clhs29 + DN(3,2)*clhs32 + clhs173; -lhs(12,2)=DN(3,0)*clhs35 + DN(3,1)*clhs37 + DN(3,2)*clhs39 + clhs210; -lhs(12,3)=-DN(0,0)*clhs328 + DN(0,0)*clhs329 + clhs128*clhs41 - clhs129; -lhs(12,4)=DN(3,0)*clhs43 + DN(3,1)*clhs45 + DN(3,2)*clhs47 + clhs243 + clhs330; -lhs(12,5)=DN(3,0)*clhs57 + DN(3,1)*clhs59 + DN(3,2)*clhs62 + clhs260; -lhs(12,6)=DN(3,0)*clhs64 + DN(3,1)*clhs66 + DN(3,2)*clhs68 + clhs275; -lhs(12,7)=-DN(1,0)*clhs328 + DN(1,0)*clhs329 + clhs247*clhs41 - clhs248; -lhs(12,8)=DN(3,0)*clhs72 + DN(3,1)*clhs74 + DN(3,2)*clhs76 + clhs298 + clhs331; -lhs(12,9)=DN(3,0)*clhs86 + DN(3,1)*clhs88 + DN(3,2)*clhs91 + clhs309; -lhs(12,10)=DN(3,0)*clhs93 + DN(3,1)*clhs95 + DN(3,2)*clhs97 + clhs318; -lhs(12,11)=-DN(2,0)*clhs328 + DN(2,0)*clhs329 + clhs302*clhs41 - clhs303; -lhs(12,12)=DN(3,0)*clhs101 + DN(3,1)*clhs103 + DN(3,2)*clhs105 + clhs10*clhs332 + clhs334; -lhs(12,13)=DN(3,0)*clhs115 + DN(3,1)*clhs117 + DN(3,2)*clhs120 + clhs336; -lhs(12,14)=DN(3,0)*clhs122 + DN(3,1)*clhs124 + DN(3,2)*clhs126 + clhs337; -lhs(12,15)=DN(3,0)*clhs338; -lhs(13,0)=DN(3,0)*clhs2 + DN(3,1)*clhs130 + DN(3,2)*clhs131 + clhs121; -lhs(13,1)=DN(3,0)*clhs29 + DN(3,1)*clhs132 + DN(3,2)*clhs134 + clhs178 + clhs339; -lhs(13,2)=DN(3,0)*clhs37 + DN(3,1)*clhs136 + DN(3,2)*clhs138 + clhs212; -lhs(13,3)=-DN(0,1)*clhs328 + DN(0,1)*clhs329 + clhs184*clhs41 - clhs185; -lhs(13,4)=DN(3,0)*clhs45 + DN(3,1)*clhs141 + DN(3,2)*clhs142 + clhs245; -lhs(13,5)=DN(3,0)*clhs59 + DN(3,1)*clhs144 + DN(3,2)*clhs146 + clhs262 + clhs340; -lhs(13,6)=DN(3,0)*clhs66 + DN(3,1)*clhs150 + DN(3,2)*clhs152 + clhs276; -lhs(13,7)=-DN(1,1)*clhs328 + DN(1,1)*clhs329 + clhs265*clhs41 - clhs266; -lhs(13,8)=DN(3,0)*clhs74 + DN(3,1)*clhs156 + DN(3,2)*clhs157 + clhs300; -lhs(13,9)=DN(3,0)*clhs88 + DN(3,1)*clhs159 + DN(3,2)*clhs161 + clhs311 + clhs341; -lhs(13,10)=DN(3,0)*clhs95 + DN(3,1)*clhs165 + DN(3,2)*clhs167 + clhs319; -lhs(13,11)=-DN(2,1)*clhs328 + DN(2,1)*clhs329 + clhs314*clhs41 - clhs315; -lhs(13,12)=DN(3,0)*clhs103 + DN(3,1)*clhs171 + DN(3,2)*clhs172 + clhs336; -lhs(13,13)=DN(3,0)*clhs117 + DN(3,1)*clhs174 + DN(3,2)*clhs176 + clhs10*clhs342 + clhs334; -lhs(13,14)=DN(3,0)*clhs124 + DN(3,1)*clhs180 + DN(3,2)*clhs182 + clhs343; -lhs(13,15)=DN(3,1)*clhs338; -lhs(14,0)=DN(3,0)*clhs4 + DN(3,1)*clhs131 + DN(3,2)*clhs186 + clhs127; -lhs(14,1)=DN(3,0)*clhs32 + DN(3,1)*clhs134 + DN(3,2)*clhs187 + clhs183; -lhs(14,2)=DN(3,0)*clhs39 + DN(3,1)*clhs138 + DN(3,2)*clhs188 + clhs215 + clhs339; -lhs(14,3)=-DN(0,2)*clhs328 + DN(0,2)*clhs329 + clhs216*clhs41 - clhs217; -lhs(14,4)=DN(3,0)*clhs47 + DN(3,1)*clhs142 + DN(3,2)*clhs190 + clhs246; -lhs(14,5)=DN(3,0)*clhs62 + DN(3,1)*clhs146 + DN(3,2)*clhs193 + clhs264; -lhs(14,6)=DN(3,0)*clhs68 + DN(3,1)*clhs152 + DN(3,2)*clhs195 + clhs278 + clhs340; -lhs(14,7)=-DN(1,2)*clhs328 + DN(1,2)*clhs329 + clhs279*clhs41 - clhs280; -lhs(14,8)=DN(3,0)*clhs76 + DN(3,1)*clhs157 + DN(3,2)*clhs200 + clhs301; -lhs(14,9)=DN(3,0)*clhs91 + DN(3,1)*clhs161 + DN(3,2)*clhs202 + clhs313; -lhs(14,10)=DN(3,0)*clhs97 + DN(3,1)*clhs167 + DN(3,2)*clhs204 + clhs321 + clhs341; -lhs(14,11)=-DN(2,2)*clhs328 + DN(2,2)*clhs329 + clhs322*clhs41 - clhs323; -lhs(14,12)=DN(3,0)*clhs105 + DN(3,1)*clhs172 + DN(3,2)*clhs209 + clhs337; -lhs(14,13)=DN(3,0)*clhs120 + DN(3,1)*clhs176 + DN(3,2)*clhs211 + clhs343; -lhs(14,14)=DN(3,0)*clhs126 + DN(3,1)*clhs182 + DN(3,2)*clhs213 + clhs10*clhs344 + clhs334; -lhs(14,15)=DN(3,2)*clhs338; -lhs(15,0)=DN(3,0)*clhs23 + clhs128; -lhs(15,1)=DN(3,1)*clhs23 + clhs184; -lhs(15,2)=DN(3,2)*clhs23 + clhs216; -lhs(15,3)=clhs221; -lhs(15,4)=DN(3,0)*clhs55 + clhs247; -lhs(15,5)=DN(3,1)*clhs55 + clhs265; -lhs(15,6)=DN(3,2)*clhs55 + clhs279; -lhs(15,7)=clhs283; -lhs(15,8)=DN(3,0)*clhs84 + clhs302; -lhs(15,9)=DN(3,1)*clhs84 + clhs314; -lhs(15,10)=DN(3,2)*clhs84 + clhs322; -lhs(15,11)=clhs325; -lhs(15,12)=DN(3,0)*clhs345; -lhs(15,13)=DN(3,1)*clhs345; -lhs(15,14)=DN(3,2)*clhs345; -lhs(15,15)=clhs22*(clhs332 + clhs342 + clhs344); +const double clhs14 = N[0]*bdf0; +const double clhs15 = clhs11 + clhs14; +const double clhs16 = 1.0*1.0/(clhs9*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); +const double clhs17 = clhs16*(rho*rho); +const double clhs18 = clhs11*clhs17; +const double clhs19 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); +const double clhs20 = clhs17*clhs19; +const double clhs21 = N[0]*clhs20; +const double clhs22 = clhs11*clhs12 + clhs13*(N[0]*N[0]) + clhs15*clhs18 + clhs15*clhs21; +const double clhs23 = C(0,1)*DN(0,1) + C(0,4)*DN(0,2) + clhs1; +const double clhs24 = C(1,3)*DN(0,1); +const double clhs25 = C(3,3)*DN(0,0) + C(3,4)*DN(0,2) + clhs24; +const double clhs26 = C(3,5)*DN(0,0); +const double clhs27 = C(4,5)*DN(0,2); +const double clhs28 = C(1,5)*DN(0,1) + clhs26 + clhs27; +const double clhs29 = DN(0,0)*clhs10; +const double clhs30 = DN(0,1)*clhs29; +const double clhs31 = C(0,2)*DN(0,2) + C(0,4)*DN(0,1) + clhs3; +const double clhs32 = C(3,4)*DN(0,1); +const double clhs33 = C(2,3)*DN(0,2) + clhs26 + clhs32; +const double clhs34 = C(2,5)*DN(0,2); +const double clhs35 = C(4,5)*DN(0,1) + C(5,5)*DN(0,0) + clhs34; +const double clhs36 = DN(0,2)*clhs29; +const double clhs37 = clhs16*clhs19; +const double clhs38 = clhs16*rho; +const double clhs39 = clhs11*clhs38; +const double clhs40 = -N[0] + clhs12*clhs37 + clhs39; +const double clhs41 = C(0,0)*DN(1,0) + C(0,3)*DN(1,1) + C(0,5)*DN(1,2); +const double clhs42 = C(0,3)*DN(1,0); +const double clhs43 = C(3,3)*DN(1,1) + C(3,5)*DN(1,2) + clhs42; +const double clhs44 = C(0,5)*DN(1,0); +const double clhs45 = C(3,5)*DN(1,1) + C(5,5)*DN(1,2) + clhs44; +const double clhs46 = DN(0,0)*DN(1,0); +const double clhs47 = N[1]*rho; +const double clhs48 = clhs14*clhs47; +const double clhs49 = clhs10*clhs46 + clhs48; +const double clhs50 = DN(1,0)*clhs6 + DN(1,1)*clhs7 + DN(1,2)*clhs8; +const double clhs51 = N[1]*bdf0; +const double clhs52 = clhs50 + clhs51; +const double clhs53 = clhs12*clhs50 + clhs18*clhs52 + clhs21*clhs52; +const double clhs54 = C(0,1)*DN(1,1) + C(0,4)*DN(1,2) + clhs42; +const double clhs55 = C(1,3)*DN(1,1); +const double clhs56 = C(3,3)*DN(1,0) + C(3,4)*DN(1,2) + clhs55; +const double clhs57 = C(3,5)*DN(1,0); +const double clhs58 = C(4,5)*DN(1,2); +const double clhs59 = C(1,5)*DN(1,1) + clhs57 + clhs58; +const double clhs60 = DN(1,1)*clhs29; +const double clhs61 = C(0,2)*DN(1,2) + C(0,4)*DN(1,1) + clhs44; +const double clhs62 = C(3,4)*DN(1,1); +const double clhs63 = C(2,3)*DN(1,2) + clhs57 + clhs62; +const double clhs64 = C(2,5)*DN(1,2); +const double clhs65 = C(4,5)*DN(1,1) + C(5,5)*DN(1,0) + clhs64; +const double clhs66 = DN(1,2)*clhs29; +const double clhs67 = DN(0,0)*N[1]; +const double clhs68 = DN(1,0)*N[0]; +const double clhs69 = clhs19*clhs38; +const double clhs70 = C(0,0)*DN(2,0) + C(0,3)*DN(2,1) + C(0,5)*DN(2,2); +const double clhs71 = C(0,3)*DN(2,0); +const double clhs72 = C(3,3)*DN(2,1) + C(3,5)*DN(2,2) + clhs71; +const double clhs73 = C(0,5)*DN(2,0); +const double clhs74 = C(3,5)*DN(2,1) + C(5,5)*DN(2,2) + clhs73; +const double clhs75 = DN(0,0)*DN(2,0); +const double clhs76 = N[2]*rho; +const double clhs77 = clhs14*clhs76; +const double clhs78 = clhs10*clhs75 + clhs77; +const double clhs79 = DN(2,0)*clhs6 + DN(2,1)*clhs7 + DN(2,2)*clhs8; +const double clhs80 = N[2]*bdf0; +const double clhs81 = clhs79 + clhs80; +const double clhs82 = clhs12*clhs79 + clhs18*clhs81 + clhs21*clhs81; +const double clhs83 = C(0,1)*DN(2,1) + C(0,4)*DN(2,2) + clhs71; +const double clhs84 = C(1,3)*DN(2,1); +const double clhs85 = C(3,3)*DN(2,0) + C(3,4)*DN(2,2) + clhs84; +const double clhs86 = C(3,5)*DN(2,0); +const double clhs87 = C(4,5)*DN(2,2); +const double clhs88 = C(1,5)*DN(2,1) + clhs86 + clhs87; +const double clhs89 = DN(2,1)*clhs29; +const double clhs90 = C(0,2)*DN(2,2) + C(0,4)*DN(2,1) + clhs73; +const double clhs91 = C(3,4)*DN(2,1); +const double clhs92 = C(2,3)*DN(2,2) + clhs86 + clhs91; +const double clhs93 = C(2,5)*DN(2,2); +const double clhs94 = C(4,5)*DN(2,1) + C(5,5)*DN(2,0) + clhs93; +const double clhs95 = DN(2,2)*clhs29; +const double clhs96 = DN(0,0)*N[2]; +const double clhs97 = DN(2,0)*N[0]; +const double clhs98 = C(0,0)*DN(3,0) + C(0,3)*DN(3,1) + C(0,5)*DN(3,2); +const double clhs99 = C(0,3)*DN(3,0); +const double clhs100 = C(3,3)*DN(3,1) + C(3,5)*DN(3,2) + clhs99; +const double clhs101 = C(0,5)*DN(3,0); +const double clhs102 = C(3,5)*DN(3,1) + C(5,5)*DN(3,2) + clhs101; +const double clhs103 = DN(0,0)*DN(3,0); +const double clhs104 = N[3]*rho; +const double clhs105 = clhs104*clhs14; +const double clhs106 = clhs10*clhs103 + clhs105; +const double clhs107 = DN(3,0)*clhs6 + DN(3,1)*clhs7 + DN(3,2)*clhs8; +const double clhs108 = N[3]*bdf0 + clhs107; +const double clhs109 = clhs107*clhs12 + clhs108*clhs18 + clhs108*clhs21; +const double clhs110 = C(0,1)*DN(3,1) + C(0,4)*DN(3,2) + clhs99; +const double clhs111 = C(1,3)*DN(3,1); +const double clhs112 = C(3,3)*DN(3,0) + C(3,4)*DN(3,2) + clhs111; +const double clhs113 = C(3,5)*DN(3,0); +const double clhs114 = C(4,5)*DN(3,2); +const double clhs115 = C(1,5)*DN(3,1) + clhs113 + clhs114; +const double clhs116 = DN(3,1)*clhs29; +const double clhs117 = C(0,2)*DN(3,2) + C(0,4)*DN(3,1) + clhs101; +const double clhs118 = C(3,4)*DN(3,1); +const double clhs119 = C(2,3)*DN(3,2) + clhs113 + clhs118; +const double clhs120 = C(2,5)*DN(3,2); +const double clhs121 = C(4,5)*DN(3,1) + C(5,5)*DN(3,0) + clhs120; +const double clhs122 = DN(3,2)*clhs29; +const double clhs123 = DN(0,0)*N[3]; +const double clhs124 = DN(3,0)*N[0]; +const double clhs125 = C(0,1)*DN(0,0) + C(1,5)*DN(0,2) + clhs24; +const double clhs126 = C(0,4)*DN(0,0) + clhs27 + clhs32; +const double clhs127 = C(1,1)*DN(0,1) + C(1,3)*DN(0,0) + C(1,4)*DN(0,2); +const double clhs128 = C(1,4)*DN(0,1); +const double clhs129 = C(3,4)*DN(0,0) + C(4,4)*DN(0,2) + clhs128; +const double clhs130 = DN(0,1)*DN(0,1); +const double clhs131 = C(1,2)*DN(0,2) + C(1,5)*DN(0,0) + clhs128; +const double clhs132 = C(2,4)*DN(0,2); +const double clhs133 = C(4,4)*DN(0,1) + C(4,5)*DN(0,0) + clhs132; +const double clhs134 = DN(0,1)*clhs10; +const double clhs135 = DN(0,2)*clhs134; +const double clhs136 = C(0,1)*DN(1,0) + C(1,5)*DN(1,2) + clhs55; +const double clhs137 = C(0,4)*DN(1,0) + clhs58 + clhs62; +const double clhs138 = DN(1,0)*clhs134; +const double clhs139 = C(1,1)*DN(1,1) + C(1,3)*DN(1,0) + C(1,4)*DN(1,2); +const double clhs140 = C(1,4)*DN(1,1); +const double clhs141 = C(3,4)*DN(1,0) + C(4,4)*DN(1,2) + clhs140; +const double clhs142 = DN(0,1)*DN(1,1); +const double clhs143 = clhs10*clhs142; +const double clhs144 = clhs48 + clhs53; +const double clhs145 = C(1,2)*DN(1,2) + C(1,5)*DN(1,0) + clhs140; +const double clhs146 = C(2,4)*DN(1,2); +const double clhs147 = C(4,4)*DN(1,1) + C(4,5)*DN(1,0) + clhs146; +const double clhs148 = DN(1,2)*clhs134; +const double clhs149 = DN(0,1)*N[1]; +const double clhs150 = DN(1,1)*N[0]; +const double clhs151 = C(0,1)*DN(2,0) + C(1,5)*DN(2,2) + clhs84; +const double clhs152 = C(0,4)*DN(2,0) + clhs87 + clhs91; +const double clhs153 = DN(2,0)*clhs134; +const double clhs154 = C(1,1)*DN(2,1) + C(1,3)*DN(2,0) + C(1,4)*DN(2,2); +const double clhs155 = C(1,4)*DN(2,1); +const double clhs156 = C(3,4)*DN(2,0) + C(4,4)*DN(2,2) + clhs155; +const double clhs157 = DN(0,1)*DN(2,1); +const double clhs158 = clhs10*clhs157; +const double clhs159 = clhs77 + clhs82; +const double clhs160 = C(1,2)*DN(2,2) + C(1,5)*DN(2,0) + clhs155; +const double clhs161 = C(2,4)*DN(2,2); +const double clhs162 = C(4,4)*DN(2,1) + C(4,5)*DN(2,0) + clhs161; +const double clhs163 = DN(2,2)*clhs134; +const double clhs164 = DN(0,1)*N[2]; +const double clhs165 = DN(2,1)*N[0]; +const double clhs166 = C(0,1)*DN(3,0) + C(1,5)*DN(3,2) + clhs111; +const double clhs167 = C(0,4)*DN(3,0) + clhs114 + clhs118; +const double clhs168 = DN(3,0)*clhs134; +const double clhs169 = C(1,1)*DN(3,1) + C(1,3)*DN(3,0) + C(1,4)*DN(3,2); +const double clhs170 = C(1,4)*DN(3,1); +const double clhs171 = C(3,4)*DN(3,0) + C(4,4)*DN(3,2) + clhs170; +const double clhs172 = DN(0,1)*DN(3,1); +const double clhs173 = clhs10*clhs172; +const double clhs174 = clhs105 + clhs109; +const double clhs175 = C(1,2)*DN(3,2) + C(1,5)*DN(3,0) + clhs170; +const double clhs176 = C(2,4)*DN(3,2); +const double clhs177 = C(4,4)*DN(3,1) + C(4,5)*DN(3,0) + clhs176; +const double clhs178 = DN(3,2)*clhs134; +const double clhs179 = DN(0,1)*N[3]; +const double clhs180 = DN(3,1)*N[0]; +const double clhs181 = C(0,2)*DN(0,0) + C(2,3)*DN(0,1) + clhs34; +const double clhs182 = C(1,2)*DN(0,1) + C(2,3)*DN(0,0) + clhs132; +const double clhs183 = C(2,2)*DN(0,2) + C(2,4)*DN(0,1) + C(2,5)*DN(0,0); +const double clhs184 = DN(0,2)*DN(0,2); +const double clhs185 = C(0,2)*DN(1,0) + C(2,3)*DN(1,1) + clhs64; +const double clhs186 = DN(0,2)*clhs10; +const double clhs187 = DN(1,0)*clhs186; +const double clhs188 = C(1,2)*DN(1,1) + C(2,3)*DN(1,0) + clhs146; +const double clhs189 = DN(1,1)*clhs186; +const double clhs190 = C(2,2)*DN(1,2) + C(2,4)*DN(1,1) + C(2,5)*DN(1,0); +const double clhs191 = DN(0,2)*DN(1,2); +const double clhs192 = clhs10*clhs191; +const double clhs193 = DN(0,2)*N[1]; +const double clhs194 = DN(1,2)*N[0]; +const double clhs195 = C(0,2)*DN(2,0) + C(2,3)*DN(2,1) + clhs93; +const double clhs196 = DN(2,0)*clhs186; +const double clhs197 = C(1,2)*DN(2,1) + C(2,3)*DN(2,0) + clhs161; +const double clhs198 = DN(2,1)*clhs186; +const double clhs199 = C(2,2)*DN(2,2) + C(2,4)*DN(2,1) + C(2,5)*DN(2,0); +const double clhs200 = DN(0,2)*DN(2,2); +const double clhs201 = clhs10*clhs200; +const double clhs202 = DN(0,2)*N[2]; +const double clhs203 = DN(2,2)*N[0]; +const double clhs204 = C(0,2)*DN(3,0) + C(2,3)*DN(3,1) + clhs120; +const double clhs205 = DN(3,0)*clhs186; +const double clhs206 = C(1,2)*DN(3,1) + C(2,3)*DN(3,0) + clhs176; +const double clhs207 = DN(3,1)*clhs186; +const double clhs208 = C(2,2)*DN(3,2) + C(2,4)*DN(3,1) + C(2,5)*DN(3,0); +const double clhs209 = DN(0,2)*DN(3,2); +const double clhs210 = clhs10*clhs209; +const double clhs211 = DN(0,2)*N[3]; +const double clhs212 = DN(3,2)*N[0]; +const double clhs213 = clhs15*clhs38; +const double clhs214 = N[0] + clhs213; +const double clhs215 = clhs38*clhs52; +const double clhs216 = clhs16*(clhs142 + clhs191 + clhs46); +const double clhs217 = clhs38*clhs81; +const double clhs218 = clhs16*(clhs157 + clhs200 + clhs75); +const double clhs219 = clhs108*clhs38; +const double clhs220 = clhs16*(clhs103 + clhs172 + clhs209); +const double clhs221 = clhs17*clhs50; +const double clhs222 = N[1]*clhs20; +const double clhs223 = clhs11*clhs47 + clhs15*clhs221 + clhs15*clhs222; +const double clhs224 = clhs38*clhs50; +const double clhs225 = DN(1,0)*DN(1,0); +const double clhs226 = clhs13*(N[1]*N[1]) + clhs221*clhs52 + clhs222*clhs52 + clhs47*clhs50; +const double clhs227 = DN(1,0)*clhs10; +const double clhs228 = DN(1,1)*clhs227; +const double clhs229 = DN(1,2)*clhs227; +const double clhs230 = -N[1] + clhs224 + clhs37*clhs47; +const double clhs231 = DN(1,0)*DN(2,0); +const double clhs232 = clhs51*clhs76; +const double clhs233 = clhs10*clhs231 + clhs232; +const double clhs234 = clhs221*clhs81 + clhs222*clhs81 + clhs47*clhs79; +const double clhs235 = DN(2,1)*clhs227; +const double clhs236 = DN(2,2)*clhs227; +const double clhs237 = DN(1,0)*N[2]; +const double clhs238 = DN(2,0)*N[1]; +const double clhs239 = DN(1,0)*DN(3,0); +const double clhs240 = clhs104*clhs51; +const double clhs241 = clhs10*clhs239 + clhs240; +const double clhs242 = clhs107*clhs47 + clhs108*clhs221 + clhs108*clhs222; +const double clhs243 = DN(3,1)*clhs227; +const double clhs244 = DN(3,2)*clhs227; +const double clhs245 = DN(1,0)*N[3]; +const double clhs246 = DN(3,0)*N[1]; +const double clhs247 = clhs223 + clhs48; +const double clhs248 = DN(1,1)*DN(1,1); +const double clhs249 = DN(1,1)*clhs10; +const double clhs250 = DN(1,2)*clhs249; +const double clhs251 = DN(2,0)*clhs249; +const double clhs252 = DN(1,1)*DN(2,1); +const double clhs253 = clhs10*clhs252; +const double clhs254 = clhs232 + clhs234; +const double clhs255 = DN(2,2)*clhs249; +const double clhs256 = DN(1,1)*N[2]; +const double clhs257 = DN(2,1)*N[1]; +const double clhs258 = DN(3,0)*clhs249; +const double clhs259 = DN(1,1)*DN(3,1); +const double clhs260 = clhs10*clhs259; +const double clhs261 = clhs240 + clhs242; +const double clhs262 = DN(3,2)*clhs249; +const double clhs263 = DN(1,1)*N[3]; +const double clhs264 = DN(3,1)*N[1]; +const double clhs265 = DN(1,2)*DN(1,2); +const double clhs266 = DN(1,2)*clhs10; +const double clhs267 = DN(2,0)*clhs266; +const double clhs268 = DN(2,1)*clhs266; +const double clhs269 = DN(1,2)*DN(2,2); +const double clhs270 = clhs10*clhs269; +const double clhs271 = DN(1,2)*N[2]; +const double clhs272 = DN(2,2)*N[1]; +const double clhs273 = DN(3,0)*clhs266; +const double clhs274 = DN(3,1)*clhs266; +const double clhs275 = DN(1,2)*DN(3,2); +const double clhs276 = clhs10*clhs275; +const double clhs277 = DN(1,2)*N[3]; +const double clhs278 = DN(3,2)*N[1]; +const double clhs279 = N[1] + clhs215; +const double clhs280 = clhs16*(clhs231 + clhs252 + clhs269); +const double clhs281 = clhs16*(clhs239 + clhs259 + clhs275); +const double clhs282 = clhs17*clhs79; +const double clhs283 = N[2]*clhs20; +const double clhs284 = clhs11*clhs76 + clhs15*clhs282 + clhs15*clhs283; +const double clhs285 = clhs38*clhs79; +const double clhs286 = clhs282*clhs52 + clhs283*clhs52 + clhs50*clhs76; +const double clhs287 = DN(2,0)*DN(2,0); +const double clhs288 = clhs13*(N[2]*N[2]) + clhs282*clhs81 + clhs283*clhs81 + clhs76*clhs79; +const double clhs289 = DN(2,0)*clhs10; +const double clhs290 = DN(2,1)*clhs289; +const double clhs291 = DN(2,2)*clhs289; +const double clhs292 = -N[2] + clhs285 + clhs37*clhs76; +const double clhs293 = DN(2,0)*DN(3,0); +const double clhs294 = clhs104*clhs80; +const double clhs295 = clhs10*clhs293 + clhs294; +const double clhs296 = clhs107*clhs76 + clhs108*clhs282 + clhs108*clhs283; +const double clhs297 = DN(3,1)*clhs289; +const double clhs298 = DN(3,2)*clhs289; +const double clhs299 = DN(2,0)*N[3]; +const double clhs300 = DN(3,0)*N[2]; +const double clhs301 = clhs284 + clhs77; +const double clhs302 = clhs232 + clhs286; +const double clhs303 = DN(2,1)*DN(2,1); +const double clhs304 = DN(2,1)*clhs10; +const double clhs305 = DN(2,2)*clhs304; +const double clhs306 = DN(3,0)*clhs304; +const double clhs307 = DN(2,1)*DN(3,1); +const double clhs308 = clhs10*clhs307; +const double clhs309 = clhs294 + clhs296; +const double clhs310 = DN(3,2)*clhs304; +const double clhs311 = DN(2,1)*N[3]; +const double clhs312 = DN(3,1)*N[2]; +const double clhs313 = DN(2,2)*DN(2,2); +const double clhs314 = DN(2,2)*clhs10; +const double clhs315 = DN(3,0)*clhs314; +const double clhs316 = DN(3,1)*clhs314; +const double clhs317 = DN(2,2)*DN(3,2); +const double clhs318 = clhs10*clhs317; +const double clhs319 = DN(2,2)*N[3]; +const double clhs320 = DN(3,2)*N[2]; +const double clhs321 = N[2] + clhs217; +const double clhs322 = clhs16*(clhs293 + clhs307 + clhs317); +const double clhs323 = clhs107*clhs17; +const double clhs324 = N[3]*clhs20; +const double clhs325 = clhs104*clhs11 + clhs15*clhs323 + clhs15*clhs324; +const double clhs326 = clhs107*clhs38; +const double clhs327 = clhs104*clhs50 + clhs323*clhs52 + clhs324*clhs52; +const double clhs328 = clhs104*clhs79 + clhs323*clhs81 + clhs324*clhs81; +const double clhs329 = DN(3,0)*DN(3,0); +const double clhs330 = clhs104*clhs107 + clhs108*clhs323 + clhs108*clhs324 + clhs13*(N[3]*N[3]); +const double clhs331 = DN(3,0)*clhs10; +const double clhs332 = DN(3,1)*clhs331; +const double clhs333 = DN(3,2)*clhs331; +const double clhs334 = -N[3] + clhs104*clhs37 + clhs326; +const double clhs335 = clhs105 + clhs325; +const double clhs336 = clhs240 + clhs327; +const double clhs337 = clhs294 + clhs328; +const double clhs338 = DN(3,1)*DN(3,1); +const double clhs339 = DN(3,1)*DN(3,2)*clhs10; +const double clhs340 = DN(3,2)*DN(3,2); +const double clhs341 = N[3] + clhs219; +lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + DN(0,2)*clhs4 + clhs10*clhs5 + clhs22; +lhs(0,1)=DN(0,0)*clhs23 + DN(0,1)*clhs25 + DN(0,2)*clhs28 + clhs30; +lhs(0,2)=DN(0,0)*clhs31 + DN(0,1)*clhs33 + DN(0,2)*clhs35 + clhs36; +lhs(0,3)=DN(0,0)*clhs40; +lhs(0,4)=DN(0,0)*clhs41 + DN(0,1)*clhs43 + DN(0,2)*clhs45 + clhs49 + clhs53; +lhs(0,5)=DN(0,0)*clhs54 + DN(0,1)*clhs56 + DN(0,2)*clhs59 + clhs60; +lhs(0,6)=DN(0,0)*clhs61 + DN(0,1)*clhs63 + DN(0,2)*clhs65 + clhs66; +lhs(0,7)=DN(1,0)*clhs39 - clhs67 + clhs68*clhs69; +lhs(0,8)=DN(0,0)*clhs70 + DN(0,1)*clhs72 + DN(0,2)*clhs74 + clhs78 + clhs82; +lhs(0,9)=DN(0,0)*clhs83 + DN(0,1)*clhs85 + DN(0,2)*clhs88 + clhs89; +lhs(0,10)=DN(0,0)*clhs90 + DN(0,1)*clhs92 + DN(0,2)*clhs94 + clhs95; +lhs(0,11)=DN(2,0)*clhs39 + clhs69*clhs97 - clhs96; +lhs(0,12)=DN(0,0)*clhs98 + DN(0,1)*clhs100 + DN(0,2)*clhs102 + clhs106 + clhs109; +lhs(0,13)=DN(0,0)*clhs110 + DN(0,1)*clhs112 + DN(0,2)*clhs115 + clhs116; +lhs(0,14)=DN(0,0)*clhs117 + DN(0,1)*clhs119 + DN(0,2)*clhs121 + clhs122; +lhs(0,15)=DN(3,0)*clhs39 - clhs123 + clhs124*clhs69; +lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs125 + DN(0,2)*clhs126 + clhs30; +lhs(1,1)=DN(0,0)*clhs25 + DN(0,1)*clhs127 + DN(0,2)*clhs129 + clhs10*clhs130 + clhs22; +lhs(1,2)=DN(0,0)*clhs33 + DN(0,1)*clhs131 + DN(0,2)*clhs133 + clhs135; +lhs(1,3)=DN(0,1)*clhs40; +lhs(1,4)=DN(0,0)*clhs43 + DN(0,1)*clhs136 + DN(0,2)*clhs137 + clhs138; +lhs(1,5)=DN(0,0)*clhs56 + DN(0,1)*clhs139 + DN(0,2)*clhs141 + clhs143 + clhs144; +lhs(1,6)=DN(0,0)*clhs63 + DN(0,1)*clhs145 + DN(0,2)*clhs147 + clhs148; +lhs(1,7)=DN(1,1)*clhs39 - clhs149 + clhs150*clhs69; +lhs(1,8)=DN(0,0)*clhs72 + DN(0,1)*clhs151 + DN(0,2)*clhs152 + clhs153; +lhs(1,9)=DN(0,0)*clhs85 + DN(0,1)*clhs154 + DN(0,2)*clhs156 + clhs158 + clhs159; +lhs(1,10)=DN(0,0)*clhs92 + DN(0,1)*clhs160 + DN(0,2)*clhs162 + clhs163; +lhs(1,11)=DN(2,1)*clhs39 - clhs164 + clhs165*clhs69; +lhs(1,12)=DN(0,0)*clhs100 + DN(0,1)*clhs166 + DN(0,2)*clhs167 + clhs168; +lhs(1,13)=DN(0,0)*clhs112 + DN(0,1)*clhs169 + DN(0,2)*clhs171 + clhs173 + clhs174; +lhs(1,14)=DN(0,0)*clhs119 + DN(0,1)*clhs175 + DN(0,2)*clhs177 + clhs178; +lhs(1,15)=DN(3,1)*clhs39 - clhs179 + clhs180*clhs69; +lhs(2,0)=DN(0,0)*clhs4 + DN(0,1)*clhs126 + DN(0,2)*clhs181 + clhs36; +lhs(2,1)=DN(0,0)*clhs28 + DN(0,1)*clhs129 + DN(0,2)*clhs182 + clhs135; +lhs(2,2)=DN(0,0)*clhs35 + DN(0,1)*clhs133 + DN(0,2)*clhs183 + clhs10*clhs184 + clhs22; +lhs(2,3)=DN(0,2)*clhs40; +lhs(2,4)=DN(0,0)*clhs45 + DN(0,1)*clhs137 + DN(0,2)*clhs185 + clhs187; +lhs(2,5)=DN(0,0)*clhs59 + DN(0,1)*clhs141 + DN(0,2)*clhs188 + clhs189; +lhs(2,6)=DN(0,0)*clhs65 + DN(0,1)*clhs147 + DN(0,2)*clhs190 + clhs144 + clhs192; +lhs(2,7)=DN(1,2)*clhs39 - clhs193 + clhs194*clhs69; +lhs(2,8)=DN(0,0)*clhs74 + DN(0,1)*clhs152 + DN(0,2)*clhs195 + clhs196; +lhs(2,9)=DN(0,0)*clhs88 + DN(0,1)*clhs156 + DN(0,2)*clhs197 + clhs198; +lhs(2,10)=DN(0,0)*clhs94 + DN(0,1)*clhs162 + DN(0,2)*clhs199 + clhs159 + clhs201; +lhs(2,11)=DN(2,2)*clhs39 - clhs202 + clhs203*clhs69; +lhs(2,12)=DN(0,0)*clhs102 + DN(0,1)*clhs167 + DN(0,2)*clhs204 + clhs205; +lhs(2,13)=DN(0,0)*clhs115 + DN(0,1)*clhs171 + DN(0,2)*clhs206 + clhs207; +lhs(2,14)=DN(0,0)*clhs121 + DN(0,1)*clhs177 + DN(0,2)*clhs208 + clhs174 + clhs210; +lhs(2,15)=DN(3,2)*clhs39 - clhs211 + clhs212*clhs69; +lhs(3,0)=DN(0,0)*clhs214; +lhs(3,1)=DN(0,1)*clhs214; +lhs(3,2)=DN(0,2)*clhs214; +lhs(3,3)=clhs16*(clhs130 + clhs184 + clhs5); +lhs(3,4)=DN(0,0)*clhs215 + clhs68; +lhs(3,5)=DN(0,1)*clhs215 + clhs150; +lhs(3,6)=DN(0,2)*clhs215 + clhs194; +lhs(3,7)=clhs216; +lhs(3,8)=DN(0,0)*clhs217 + clhs97; +lhs(3,9)=DN(0,1)*clhs217 + clhs165; +lhs(3,10)=DN(0,2)*clhs217 + clhs203; +lhs(3,11)=clhs218; +lhs(3,12)=DN(0,0)*clhs219 + clhs124; +lhs(3,13)=DN(0,1)*clhs219 + clhs180; +lhs(3,14)=DN(0,2)*clhs219 + clhs212; +lhs(3,15)=clhs220; +lhs(4,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + DN(1,2)*clhs4 + clhs223 + clhs49; +lhs(4,1)=DN(1,0)*clhs23 + DN(1,1)*clhs25 + DN(1,2)*clhs28 + clhs138; +lhs(4,2)=DN(1,0)*clhs31 + DN(1,1)*clhs33 + DN(1,2)*clhs35 + clhs187; +lhs(4,3)=DN(0,0)*clhs224 + clhs67*clhs69 - clhs68; +lhs(4,4)=DN(1,0)*clhs41 + DN(1,1)*clhs43 + DN(1,2)*clhs45 + clhs10*clhs225 + clhs226; +lhs(4,5)=DN(1,0)*clhs54 + DN(1,1)*clhs56 + DN(1,2)*clhs59 + clhs228; +lhs(4,6)=DN(1,0)*clhs61 + DN(1,1)*clhs63 + DN(1,2)*clhs65 + clhs229; +lhs(4,7)=DN(1,0)*clhs230; +lhs(4,8)=DN(1,0)*clhs70 + DN(1,1)*clhs72 + DN(1,2)*clhs74 + clhs233 + clhs234; +lhs(4,9)=DN(1,0)*clhs83 + DN(1,1)*clhs85 + DN(1,2)*clhs88 + clhs235; +lhs(4,10)=DN(1,0)*clhs90 + DN(1,1)*clhs92 + DN(1,2)*clhs94 + clhs236; +lhs(4,11)=DN(2,0)*clhs224 - clhs237 + clhs238*clhs69; +lhs(4,12)=DN(1,0)*clhs98 + DN(1,1)*clhs100 + DN(1,2)*clhs102 + clhs241 + clhs242; +lhs(4,13)=DN(1,0)*clhs110 + DN(1,1)*clhs112 + DN(1,2)*clhs115 + clhs243; +lhs(4,14)=DN(1,0)*clhs117 + DN(1,1)*clhs119 + DN(1,2)*clhs121 + clhs244; +lhs(4,15)=DN(3,0)*clhs224 - clhs245 + clhs246*clhs69; +lhs(5,0)=DN(1,0)*clhs2 + DN(1,1)*clhs125 + DN(1,2)*clhs126 + clhs60; +lhs(5,1)=DN(1,0)*clhs25 + DN(1,1)*clhs127 + DN(1,2)*clhs129 + clhs143 + clhs247; +lhs(5,2)=DN(1,0)*clhs33 + DN(1,1)*clhs131 + DN(1,2)*clhs133 + clhs189; +lhs(5,3)=DN(0,1)*clhs224 + clhs149*clhs69 - clhs150; +lhs(5,4)=DN(1,0)*clhs43 + DN(1,1)*clhs136 + DN(1,2)*clhs137 + clhs228; +lhs(5,5)=DN(1,0)*clhs56 + DN(1,1)*clhs139 + DN(1,2)*clhs141 + clhs10*clhs248 + clhs226; +lhs(5,6)=DN(1,0)*clhs63 + DN(1,1)*clhs145 + DN(1,2)*clhs147 + clhs250; +lhs(5,7)=DN(1,1)*clhs230; +lhs(5,8)=DN(1,0)*clhs72 + DN(1,1)*clhs151 + DN(1,2)*clhs152 + clhs251; +lhs(5,9)=DN(1,0)*clhs85 + DN(1,1)*clhs154 + DN(1,2)*clhs156 + clhs253 + clhs254; +lhs(5,10)=DN(1,0)*clhs92 + DN(1,1)*clhs160 + DN(1,2)*clhs162 + clhs255; +lhs(5,11)=DN(2,1)*clhs224 - clhs256 + clhs257*clhs69; +lhs(5,12)=DN(1,0)*clhs100 + DN(1,1)*clhs166 + DN(1,2)*clhs167 + clhs258; +lhs(5,13)=DN(1,0)*clhs112 + DN(1,1)*clhs169 + DN(1,2)*clhs171 + clhs260 + clhs261; +lhs(5,14)=DN(1,0)*clhs119 + DN(1,1)*clhs175 + DN(1,2)*clhs177 + clhs262; +lhs(5,15)=DN(3,1)*clhs224 - clhs263 + clhs264*clhs69; +lhs(6,0)=DN(1,0)*clhs4 + DN(1,1)*clhs126 + DN(1,2)*clhs181 + clhs66; +lhs(6,1)=DN(1,0)*clhs28 + DN(1,1)*clhs129 + DN(1,2)*clhs182 + clhs148; +lhs(6,2)=DN(1,0)*clhs35 + DN(1,1)*clhs133 + DN(1,2)*clhs183 + clhs192 + clhs247; +lhs(6,3)=DN(0,2)*clhs224 + clhs193*clhs69 - clhs194; +lhs(6,4)=DN(1,0)*clhs45 + DN(1,1)*clhs137 + DN(1,2)*clhs185 + clhs229; +lhs(6,5)=DN(1,0)*clhs59 + DN(1,1)*clhs141 + DN(1,2)*clhs188 + clhs250; +lhs(6,6)=DN(1,0)*clhs65 + DN(1,1)*clhs147 + DN(1,2)*clhs190 + clhs10*clhs265 + clhs226; +lhs(6,7)=DN(1,2)*clhs230; +lhs(6,8)=DN(1,0)*clhs74 + DN(1,1)*clhs152 + DN(1,2)*clhs195 + clhs267; +lhs(6,9)=DN(1,0)*clhs88 + DN(1,1)*clhs156 + DN(1,2)*clhs197 + clhs268; +lhs(6,10)=DN(1,0)*clhs94 + DN(1,1)*clhs162 + DN(1,2)*clhs199 + clhs254 + clhs270; +lhs(6,11)=DN(2,2)*clhs224 - clhs271 + clhs272*clhs69; +lhs(6,12)=DN(1,0)*clhs102 + DN(1,1)*clhs167 + DN(1,2)*clhs204 + clhs273; +lhs(6,13)=DN(1,0)*clhs115 + DN(1,1)*clhs171 + DN(1,2)*clhs206 + clhs274; +lhs(6,14)=DN(1,0)*clhs121 + DN(1,1)*clhs177 + DN(1,2)*clhs208 + clhs261 + clhs276; +lhs(6,15)=DN(3,2)*clhs224 - clhs277 + clhs278*clhs69; +lhs(7,0)=DN(1,0)*clhs213 + clhs67; +lhs(7,1)=DN(1,1)*clhs213 + clhs149; +lhs(7,2)=DN(1,2)*clhs213 + clhs193; +lhs(7,3)=clhs216; +lhs(7,4)=DN(1,0)*clhs279; +lhs(7,5)=DN(1,1)*clhs279; +lhs(7,6)=DN(1,2)*clhs279; +lhs(7,7)=clhs16*(clhs225 + clhs248 + clhs265); +lhs(7,8)=DN(1,0)*clhs217 + clhs238; +lhs(7,9)=DN(1,1)*clhs217 + clhs257; +lhs(7,10)=DN(1,2)*clhs217 + clhs272; +lhs(7,11)=clhs280; +lhs(7,12)=DN(1,0)*clhs219 + clhs246; +lhs(7,13)=DN(1,1)*clhs219 + clhs264; +lhs(7,14)=DN(1,2)*clhs219 + clhs278; +lhs(7,15)=clhs281; +lhs(8,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + DN(2,2)*clhs4 + clhs284 + clhs78; +lhs(8,1)=DN(2,0)*clhs23 + DN(2,1)*clhs25 + DN(2,2)*clhs28 + clhs153; +lhs(8,2)=DN(2,0)*clhs31 + DN(2,1)*clhs33 + DN(2,2)*clhs35 + clhs196; +lhs(8,3)=DN(0,0)*clhs285 + clhs69*clhs96 - clhs97; +lhs(8,4)=DN(2,0)*clhs41 + DN(2,1)*clhs43 + DN(2,2)*clhs45 + clhs233 + clhs286; +lhs(8,5)=DN(2,0)*clhs54 + DN(2,1)*clhs56 + DN(2,2)*clhs59 + clhs251; +lhs(8,6)=DN(2,0)*clhs61 + DN(2,1)*clhs63 + DN(2,2)*clhs65 + clhs267; +lhs(8,7)=DN(1,0)*clhs285 + clhs237*clhs69 - clhs238; +lhs(8,8)=DN(2,0)*clhs70 + DN(2,1)*clhs72 + DN(2,2)*clhs74 + clhs10*clhs287 + clhs288; +lhs(8,9)=DN(2,0)*clhs83 + DN(2,1)*clhs85 + DN(2,2)*clhs88 + clhs290; +lhs(8,10)=DN(2,0)*clhs90 + DN(2,1)*clhs92 + DN(2,2)*clhs94 + clhs291; +lhs(8,11)=DN(2,0)*clhs292; +lhs(8,12)=DN(2,0)*clhs98 + DN(2,1)*clhs100 + DN(2,2)*clhs102 + clhs295 + clhs296; +lhs(8,13)=DN(2,0)*clhs110 + DN(2,1)*clhs112 + DN(2,2)*clhs115 + clhs297; +lhs(8,14)=DN(2,0)*clhs117 + DN(2,1)*clhs119 + DN(2,2)*clhs121 + clhs298; +lhs(8,15)=DN(3,0)*clhs285 - clhs299 + clhs300*clhs69; +lhs(9,0)=DN(2,0)*clhs2 + DN(2,1)*clhs125 + DN(2,2)*clhs126 + clhs89; +lhs(9,1)=DN(2,0)*clhs25 + DN(2,1)*clhs127 + DN(2,2)*clhs129 + clhs158 + clhs301; +lhs(9,2)=DN(2,0)*clhs33 + DN(2,1)*clhs131 + DN(2,2)*clhs133 + clhs198; +lhs(9,3)=DN(0,1)*clhs285 + clhs164*clhs69 - clhs165; +lhs(9,4)=DN(2,0)*clhs43 + DN(2,1)*clhs136 + DN(2,2)*clhs137 + clhs235; +lhs(9,5)=DN(2,0)*clhs56 + DN(2,1)*clhs139 + DN(2,2)*clhs141 + clhs253 + clhs302; +lhs(9,6)=DN(2,0)*clhs63 + DN(2,1)*clhs145 + DN(2,2)*clhs147 + clhs268; +lhs(9,7)=DN(1,1)*clhs285 + clhs256*clhs69 - clhs257; +lhs(9,8)=DN(2,0)*clhs72 + DN(2,1)*clhs151 + DN(2,2)*clhs152 + clhs290; +lhs(9,9)=DN(2,0)*clhs85 + DN(2,1)*clhs154 + DN(2,2)*clhs156 + clhs10*clhs303 + clhs288; +lhs(9,10)=DN(2,0)*clhs92 + DN(2,1)*clhs160 + DN(2,2)*clhs162 + clhs305; +lhs(9,11)=DN(2,1)*clhs292; +lhs(9,12)=DN(2,0)*clhs100 + DN(2,1)*clhs166 + DN(2,2)*clhs167 + clhs306; +lhs(9,13)=DN(2,0)*clhs112 + DN(2,1)*clhs169 + DN(2,2)*clhs171 + clhs308 + clhs309; +lhs(9,14)=DN(2,0)*clhs119 + DN(2,1)*clhs175 + DN(2,2)*clhs177 + clhs310; +lhs(9,15)=DN(3,1)*clhs285 - clhs311 + clhs312*clhs69; +lhs(10,0)=DN(2,0)*clhs4 + DN(2,1)*clhs126 + DN(2,2)*clhs181 + clhs95; +lhs(10,1)=DN(2,0)*clhs28 + DN(2,1)*clhs129 + DN(2,2)*clhs182 + clhs163; +lhs(10,2)=DN(2,0)*clhs35 + DN(2,1)*clhs133 + DN(2,2)*clhs183 + clhs201 + clhs301; +lhs(10,3)=DN(0,2)*clhs285 + clhs202*clhs69 - clhs203; +lhs(10,4)=DN(2,0)*clhs45 + DN(2,1)*clhs137 + DN(2,2)*clhs185 + clhs236; +lhs(10,5)=DN(2,0)*clhs59 + DN(2,1)*clhs141 + DN(2,2)*clhs188 + clhs255; +lhs(10,6)=DN(2,0)*clhs65 + DN(2,1)*clhs147 + DN(2,2)*clhs190 + clhs270 + clhs302; +lhs(10,7)=DN(1,2)*clhs285 + clhs271*clhs69 - clhs272; +lhs(10,8)=DN(2,0)*clhs74 + DN(2,1)*clhs152 + DN(2,2)*clhs195 + clhs291; +lhs(10,9)=DN(2,0)*clhs88 + DN(2,1)*clhs156 + DN(2,2)*clhs197 + clhs305; +lhs(10,10)=DN(2,0)*clhs94 + DN(2,1)*clhs162 + DN(2,2)*clhs199 + clhs10*clhs313 + clhs288; +lhs(10,11)=DN(2,2)*clhs292; +lhs(10,12)=DN(2,0)*clhs102 + DN(2,1)*clhs167 + DN(2,2)*clhs204 + clhs315; +lhs(10,13)=DN(2,0)*clhs115 + DN(2,1)*clhs171 + DN(2,2)*clhs206 + clhs316; +lhs(10,14)=DN(2,0)*clhs121 + DN(2,1)*clhs177 + DN(2,2)*clhs208 + clhs309 + clhs318; +lhs(10,15)=DN(3,2)*clhs285 - clhs319 + clhs320*clhs69; +lhs(11,0)=DN(2,0)*clhs213 + clhs96; +lhs(11,1)=DN(2,1)*clhs213 + clhs164; +lhs(11,2)=DN(2,2)*clhs213 + clhs202; +lhs(11,3)=clhs218; +lhs(11,4)=DN(2,0)*clhs215 + clhs237; +lhs(11,5)=DN(2,1)*clhs215 + clhs256; +lhs(11,6)=DN(2,2)*clhs215 + clhs271; +lhs(11,7)=clhs280; +lhs(11,8)=DN(2,0)*clhs321; +lhs(11,9)=DN(2,1)*clhs321; +lhs(11,10)=DN(2,2)*clhs321; +lhs(11,11)=clhs16*(clhs287 + clhs303 + clhs313); +lhs(11,12)=DN(2,0)*clhs219 + clhs300; +lhs(11,13)=DN(2,1)*clhs219 + clhs312; +lhs(11,14)=DN(2,2)*clhs219 + clhs320; +lhs(11,15)=clhs322; +lhs(12,0)=DN(3,0)*clhs0 + DN(3,1)*clhs2 + DN(3,2)*clhs4 + clhs106 + clhs325; +lhs(12,1)=DN(3,0)*clhs23 + DN(3,1)*clhs25 + DN(3,2)*clhs28 + clhs168; +lhs(12,2)=DN(3,0)*clhs31 + DN(3,1)*clhs33 + DN(3,2)*clhs35 + clhs205; +lhs(12,3)=DN(0,0)*clhs326 + clhs123*clhs69 - clhs124; +lhs(12,4)=DN(3,0)*clhs41 + DN(3,1)*clhs43 + DN(3,2)*clhs45 + clhs241 + clhs327; +lhs(12,5)=DN(3,0)*clhs54 + DN(3,1)*clhs56 + DN(3,2)*clhs59 + clhs258; +lhs(12,6)=DN(3,0)*clhs61 + DN(3,1)*clhs63 + DN(3,2)*clhs65 + clhs273; +lhs(12,7)=DN(1,0)*clhs326 + clhs245*clhs69 - clhs246; +lhs(12,8)=DN(3,0)*clhs70 + DN(3,1)*clhs72 + DN(3,2)*clhs74 + clhs295 + clhs328; +lhs(12,9)=DN(3,0)*clhs83 + DN(3,1)*clhs85 + DN(3,2)*clhs88 + clhs306; +lhs(12,10)=DN(3,0)*clhs90 + DN(3,1)*clhs92 + DN(3,2)*clhs94 + clhs315; +lhs(12,11)=DN(2,0)*clhs326 + clhs299*clhs69 - clhs300; +lhs(12,12)=DN(3,0)*clhs98 + DN(3,1)*clhs100 + DN(3,2)*clhs102 + clhs10*clhs329 + clhs330; +lhs(12,13)=DN(3,0)*clhs110 + DN(3,1)*clhs112 + DN(3,2)*clhs115 + clhs332; +lhs(12,14)=DN(3,0)*clhs117 + DN(3,1)*clhs119 + DN(3,2)*clhs121 + clhs333; +lhs(12,15)=DN(3,0)*clhs334; +lhs(13,0)=DN(3,0)*clhs2 + DN(3,1)*clhs125 + DN(3,2)*clhs126 + clhs116; +lhs(13,1)=DN(3,0)*clhs25 + DN(3,1)*clhs127 + DN(3,2)*clhs129 + clhs173 + clhs335; +lhs(13,2)=DN(3,0)*clhs33 + DN(3,1)*clhs131 + DN(3,2)*clhs133 + clhs207; +lhs(13,3)=DN(0,1)*clhs326 + clhs179*clhs69 - clhs180; +lhs(13,4)=DN(3,0)*clhs43 + DN(3,1)*clhs136 + DN(3,2)*clhs137 + clhs243; +lhs(13,5)=DN(3,0)*clhs56 + DN(3,1)*clhs139 + DN(3,2)*clhs141 + clhs260 + clhs336; +lhs(13,6)=DN(3,0)*clhs63 + DN(3,1)*clhs145 + DN(3,2)*clhs147 + clhs274; +lhs(13,7)=DN(1,1)*clhs326 + clhs263*clhs69 - clhs264; +lhs(13,8)=DN(3,0)*clhs72 + DN(3,1)*clhs151 + DN(3,2)*clhs152 + clhs297; +lhs(13,9)=DN(3,0)*clhs85 + DN(3,1)*clhs154 + DN(3,2)*clhs156 + clhs308 + clhs337; +lhs(13,10)=DN(3,0)*clhs92 + DN(3,1)*clhs160 + DN(3,2)*clhs162 + clhs316; +lhs(13,11)=DN(2,1)*clhs326 + clhs311*clhs69 - clhs312; +lhs(13,12)=DN(3,0)*clhs100 + DN(3,1)*clhs166 + DN(3,2)*clhs167 + clhs332; +lhs(13,13)=DN(3,0)*clhs112 + DN(3,1)*clhs169 + DN(3,2)*clhs171 + clhs10*clhs338 + clhs330; +lhs(13,14)=DN(3,0)*clhs119 + DN(3,1)*clhs175 + DN(3,2)*clhs177 + clhs339; +lhs(13,15)=DN(3,1)*clhs334; +lhs(14,0)=DN(3,0)*clhs4 + DN(3,1)*clhs126 + DN(3,2)*clhs181 + clhs122; +lhs(14,1)=DN(3,0)*clhs28 + DN(3,1)*clhs129 + DN(3,2)*clhs182 + clhs178; +lhs(14,2)=DN(3,0)*clhs35 + DN(3,1)*clhs133 + DN(3,2)*clhs183 + clhs210 + clhs335; +lhs(14,3)=DN(0,2)*clhs326 + clhs211*clhs69 - clhs212; +lhs(14,4)=DN(3,0)*clhs45 + DN(3,1)*clhs137 + DN(3,2)*clhs185 + clhs244; +lhs(14,5)=DN(3,0)*clhs59 + DN(3,1)*clhs141 + DN(3,2)*clhs188 + clhs262; +lhs(14,6)=DN(3,0)*clhs65 + DN(3,1)*clhs147 + DN(3,2)*clhs190 + clhs276 + clhs336; +lhs(14,7)=DN(1,2)*clhs326 + clhs277*clhs69 - clhs278; +lhs(14,8)=DN(3,0)*clhs74 + DN(3,1)*clhs152 + DN(3,2)*clhs195 + clhs298; +lhs(14,9)=DN(3,0)*clhs88 + DN(3,1)*clhs156 + DN(3,2)*clhs197 + clhs310; +lhs(14,10)=DN(3,0)*clhs94 + DN(3,1)*clhs162 + DN(3,2)*clhs199 + clhs318 + clhs337; +lhs(14,11)=DN(2,2)*clhs326 + clhs319*clhs69 - clhs320; +lhs(14,12)=DN(3,0)*clhs102 + DN(3,1)*clhs167 + DN(3,2)*clhs204 + clhs333; +lhs(14,13)=DN(3,0)*clhs115 + DN(3,1)*clhs171 + DN(3,2)*clhs206 + clhs339; +lhs(14,14)=DN(3,0)*clhs121 + DN(3,1)*clhs177 + DN(3,2)*clhs208 + clhs10*clhs340 + clhs330; +lhs(14,15)=DN(3,2)*clhs334; +lhs(15,0)=DN(3,0)*clhs213 + clhs123; +lhs(15,1)=DN(3,1)*clhs213 + clhs179; +lhs(15,2)=DN(3,2)*clhs213 + clhs211; +lhs(15,3)=clhs220; +lhs(15,4)=DN(3,0)*clhs215 + clhs245; +lhs(15,5)=DN(3,1)*clhs215 + clhs263; +lhs(15,6)=DN(3,2)*clhs215 + clhs277; +lhs(15,7)=clhs281; +lhs(15,8)=DN(3,0)*clhs217 + clhs299; +lhs(15,9)=DN(3,1)*clhs217 + clhs311; +lhs(15,10)=DN(3,2)*clhs217 + clhs319; +lhs(15,11)=clhs322; +lhs(15,12)=DN(3,0)*clhs341; +lhs(15,13)=DN(3,1)*clhs341; +lhs(15,14)=DN(3,2)*clhs341; +lhs(15,15)=clhs16*(clhs329 + clhs338 + clhs340); // Add intermediate results to local system @@ -1232,24 +1206,16 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; - // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible - + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; const auto &stress = rData.ShearStress; @@ -1258,10 +1224,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -1289,71 +1251,66 @@ void TwoFluidNavierStokesFractional>::C auto &rhs = rData.rhs; const double crhs0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2]; -const double crhs1 = rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)); -const double crhs2 = K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0)); -const double crhs3 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)); -const double crhs4 = N[0]*rho; -const double crhs5 = bdf0*crhs4; -const double crhs6 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs7 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs8 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs9 = crhs6 + crhs7 + crhs8; -const double crhs10 = 1.0/dt; -const double crhs11 = crhs10*crhs4; -const double crhs12 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); -const double crhs13 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); -const double crhs14 = rho*(crhs12*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs13*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))); -const double crhs15 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); -const double crhs16 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double crhs17 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double crhs18 = rho*(crhs15*crhs16 + crhs17*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))); -const double crhs19 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); -const double crhs20 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); -const double crhs21 = crhs19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); -const double crhs22 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); -const double crhs23 = crhs15 + crhs22 - volume_error_ratio; -const double crhs24 = rho*stab_c2*sqrt(crhs16*crhs16 + crhs17*crhs17); -const double crhs25 = crhs23*(crhs24*h*1.0/stab_c1 + mu); -const double crhs26 = bdf0*rho; -const double crhs27 = crhs26*crhs3; -const double crhs28 = crhs10*rho; -const double crhs29 = 1.0*1.0/(K_darcy + crhs24*1.0/h + crhs28*dyn_tau + mu*stab_c1*1.0/(h*h)); -const double crhs30 = crhs29*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] - crhs1 - crhs14 + crhs18 + crhs2 + crhs27 + rho*(crhs10*crhs6 + crhs10*crhs7 + crhs10*crhs8 + crhs21)); -const double crhs31 = K_darcy*N[0]; -const double crhs32 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); -const double crhs33 = crhs32*crhs4; -const double crhs34 = rho*(DN(0,0)*crhs16 + DN(0,1)*crhs17); -const double crhs35 = rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)); -const double crhs36 = K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1)); -const double crhs37 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)); -const double crhs38 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs39 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs40 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs41 = crhs38 + crhs39 + crhs40; -const double crhs42 = rho*(crhs12*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs13*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))); -const double crhs43 = rho*(crhs16*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1)) + crhs17*crhs22); -const double crhs44 = crhs19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); -const double crhs45 = crhs26*crhs37; -const double crhs46 = crhs29*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] - crhs35 + crhs36 - crhs42 + crhs43 + crhs45 + rho*(crhs10*crhs38 + crhs10*crhs39 + crhs10*crhs40 + crhs44)); -const double crhs47 = N[1]*crhs28; -const double crhs48 = N[1]*rho; -const double crhs49 = K_darcy*N[1]; -const double crhs50 = crhs32*crhs48; -const double crhs51 = rho*(DN(1,0)*crhs16 + DN(1,1)*crhs17); -const double crhs52 = N[2]*crhs28; -const double crhs53 = N[2]*rho; -const double crhs54 = K_darcy*N[2]; -const double crhs55 = crhs32*crhs53; -const double crhs56 = rho*(DN(2,0)*crhs16 + DN(2,1)*crhs17); -rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs25 - DN(0,0)*stress[0] - DN(0,1)*stress[2] + N[0]*crhs1 + N[0]*crhs14 - N[0]*crhs18 - N[0]*crhs2 - crhs11*crhs9 - crhs21*crhs4 - crhs3*crhs5 + crhs30*crhs31 - crhs30*crhs33 - crhs30*crhs34; -rhs[1]=-DN(0,0)*stress[2] + DN(0,1)*crhs0 - DN(0,1)*crhs25 - DN(0,1)*stress[1] + N[0]*crhs35 - N[0]*crhs36 + N[0]*crhs42 - N[0]*crhs43 - crhs11*crhs41 + crhs31*crhs46 - crhs33*crhs46 - crhs34*crhs46 - crhs37*crhs5 - crhs4*crhs44; -rhs[2]=-DN(0,0)*crhs30 - DN(0,1)*crhs46 - N[0]*crhs23; -rhs[3]=DN(1,0)*crhs0 - DN(1,0)*crhs25 - DN(1,0)*stress[0] - DN(1,1)*stress[2] + N[1]*crhs1 + N[1]*crhs14 - N[1]*crhs18 - N[1]*crhs2 - N[1]*crhs27 - crhs21*crhs48 + crhs30*crhs49 - crhs30*crhs50 - crhs30*crhs51 - crhs47*crhs9; -rhs[4]=-DN(1,0)*stress[2] + DN(1,1)*crhs0 - DN(1,1)*crhs25 - DN(1,1)*stress[1] + N[1]*crhs35 - N[1]*crhs36 + N[1]*crhs42 - N[1]*crhs43 - N[1]*crhs45 - crhs41*crhs47 - crhs44*crhs48 + crhs46*crhs49 - crhs46*crhs50 - crhs46*crhs51; -rhs[5]=-DN(1,0)*crhs30 - DN(1,1)*crhs46 - N[1]*crhs23; -rhs[6]=DN(2,0)*crhs0 - DN(2,0)*crhs25 - DN(2,0)*stress[0] - DN(2,1)*stress[2] + N[2]*crhs1 + N[2]*crhs14 - N[2]*crhs18 - N[2]*crhs2 - N[2]*crhs27 - crhs21*crhs53 + crhs30*crhs54 - crhs30*crhs55 - crhs30*crhs56 - crhs52*crhs9; -rhs[7]=-DN(2,0)*stress[2] + DN(2,1)*crhs0 - DN(2,1)*crhs25 - DN(2,1)*stress[1] + N[2]*crhs35 - N[2]*crhs36 + N[2]*crhs42 - N[2]*crhs43 - N[2]*crhs45 - crhs41*crhs52 - crhs44*crhs53 + crhs46*crhs54 - crhs46*crhs55 - crhs46*crhs56; -rhs[8]=-DN(2,0)*crhs30 - DN(2,1)*crhs46 - N[2]*crhs23; +const double crhs1 = N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0); +const double crhs2 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)); +const double crhs3 = N[0]*rho; +const double crhs4 = bdf0*crhs3; +const double crhs5 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs6 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs7 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs8 = crhs5 + crhs6 + crhs7; +const double crhs9 = 1.0/dt; +const double crhs10 = crhs3*crhs9; +const double crhs11 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); +const double crhs12 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crhs13 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crhs14 = rho*(crhs11*crhs12 + crhs13*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))); +const double crhs15 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crhs16 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crhs17 = crhs15*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs16*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crhs18 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); +const double crhs19 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); +const double crhs20 = crhs18*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs19*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); +const double crhs21 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); +const double crhs22 = crhs11 + crhs21 - volume_error_ratio; +const double crhs23 = rho*stab_c2*sqrt(crhs12*crhs12 + crhs13*crhs13); +const double crhs24 = crhs22*(crhs23*h*1.0/stab_c1 + mu); +const double crhs25 = bdf0*rho; +const double crhs26 = crhs2*crhs25; +const double crhs27 = crhs9*rho; +const double crhs28 = 1.0*1.0/(crhs23*1.0/h + crhs27*dyn_tau + mu*stab_c1*1.0/(h*h)); +const double crhs29 = crhs28*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] - crhs1*rho + crhs14 - crhs20*rho + crhs26 + rho*(crhs17 + crhs5*crhs9 + crhs6*crhs9 + crhs7*crhs9)); +const double crhs30 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); +const double crhs31 = crhs3*crhs30; +const double crhs32 = rho*(DN(0,0)*crhs12 + DN(0,1)*crhs13); +const double crhs33 = N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1); +const double crhs34 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)); +const double crhs35 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs36 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs37 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs38 = crhs35 + crhs36 + crhs37; +const double crhs39 = rho*(crhs12*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1)) + crhs13*crhs21); +const double crhs40 = crhs15*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs16*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); +const double crhs41 = crhs18*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs19*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); +const double crhs42 = crhs25*crhs34; +const double crhs43 = crhs28*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] - crhs33*rho + crhs39 - crhs41*rho + crhs42 + rho*(crhs35*crhs9 + crhs36*crhs9 + crhs37*crhs9 + crhs40)); +const double crhs44 = N[1]*crhs27; +const double crhs45 = N[1]*rho; +const double crhs46 = crhs30*crhs45; +const double crhs47 = rho*(DN(1,0)*crhs12 + DN(1,1)*crhs13); +const double crhs48 = N[2]*crhs27; +const double crhs49 = N[2]*rho; +const double crhs50 = crhs30*crhs49; +const double crhs51 = rho*(DN(2,0)*crhs12 + DN(2,1)*crhs13); +rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs24 - DN(0,0)*stress[0] - DN(0,1)*stress[2] + N[0]*crhs1*rho - N[0]*crhs14 + N[0]*crhs20*rho - crhs10*crhs8 - crhs17*crhs3 - crhs2*crhs4 - crhs29*crhs31 - crhs29*crhs32; +rhs[1]=-DN(0,0)*stress[2] + DN(0,1)*crhs0 - DN(0,1)*crhs24 - DN(0,1)*stress[1] + N[0]*crhs33*rho - N[0]*crhs39 + N[0]*crhs41*rho - crhs10*crhs38 - crhs3*crhs40 - crhs31*crhs43 - crhs32*crhs43 - crhs34*crhs4; +rhs[2]=-DN(0,0)*crhs29 - DN(0,1)*crhs43 - N[0]*crhs22; +rhs[3]=DN(1,0)*crhs0 - DN(1,0)*crhs24 - DN(1,0)*stress[0] - DN(1,1)*stress[2] + N[1]*crhs1*rho - N[1]*crhs14 + N[1]*crhs20*rho - N[1]*crhs26 - crhs17*crhs45 - crhs29*crhs46 - crhs29*crhs47 - crhs44*crhs8; +rhs[4]=-DN(1,0)*stress[2] + DN(1,1)*crhs0 - DN(1,1)*crhs24 - DN(1,1)*stress[1] + N[1]*crhs33*rho - N[1]*crhs39 + N[1]*crhs41*rho - N[1]*crhs42 - crhs38*crhs44 - crhs40*crhs45 - crhs43*crhs46 - crhs43*crhs47; +rhs[5]=-DN(1,0)*crhs29 - DN(1,1)*crhs43 - N[1]*crhs22; +rhs[6]=DN(2,0)*crhs0 - DN(2,0)*crhs24 - DN(2,0)*stress[0] - DN(2,1)*stress[2] + N[2]*crhs1*rho - N[2]*crhs14 + N[2]*crhs20*rho - N[2]*crhs26 - crhs17*crhs49 - crhs29*crhs50 - crhs29*crhs51 - crhs48*crhs8; +rhs[7]=-DN(2,0)*stress[2] + DN(2,1)*crhs0 - DN(2,1)*crhs24 - DN(2,1)*stress[1] + N[2]*crhs33*rho - N[2]*crhs39 + N[2]*crhs41*rho - N[2]*crhs42 - crhs38*crhs48 - crhs40*crhs49 - crhs43*crhs50 - crhs43*crhs51; +rhs[8]=-DN(2,0)*crhs29 - DN(2,1)*crhs43 - N[2]*crhs22; noalias(rRHS) += rData.Weight * rhs; @@ -1370,18 +1327,13 @@ void TwoFluidNavierStokesFractional>::C const double h = rData.ElementSize; const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; - // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible - + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; const auto &stress = rData.ShearStress; @@ -1390,10 +1342,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -1421,102 +1369,95 @@ void TwoFluidNavierStokesFractional>::C auto &rhs = rData.rhs; const double crhs0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2] + N[3]*p[3]; -const double crhs1 = rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)); -const double crhs2 = K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0) + N[3]*v(3,0)); -const double crhs3 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)) + N[3]*(v(3,0) - vfrac(3,0)); -const double crhs4 = N[0]*rho; -const double crhs5 = bdf0*crhs4; -const double crhs6 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs7 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs8 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs9 = N[3]*(vn(3,0) - vnn(3,0)); -const double crhs10 = crhs6 + crhs7 + crhs8 + crhs9; -const double crhs11 = 1.0/dt; -const double crhs12 = crhs11*crhs4; -const double crhs13 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); -const double crhs14 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); -const double crhs15 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); -const double crhs16 = rho*(crhs13*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs14*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs15*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))); -const double crhs17 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); -const double crhs18 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double crhs19 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double crhs20 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double crhs21 = rho*(crhs17*crhs18 + crhs19*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs20*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0))); -const double crhs22 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); -const double crhs23 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); -const double crhs24 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); -const double crhs25 = crhs22*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs23*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs24*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); -const double crhs26 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); -const double crhs27 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); -const double crhs28 = crhs17 + crhs26 + crhs27 - volume_error_ratio; -const double crhs29 = rho*stab_c2*sqrt(crhs18*crhs18 + crhs19*crhs19 + crhs20*crhs20); -const double crhs30 = crhs28*(crhs29*h*1.0/stab_c1 + mu); -const double crhs31 = bdf0*rho; -const double crhs32 = crhs3*crhs31; -const double crhs33 = crhs11*rho; -const double crhs34 = 1.0*1.0/(K_darcy + crhs29*1.0/h + crhs33*dyn_tau + mu*stab_c1*1.0/(h*h)); -const double crhs35 = crhs34*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] - crhs1 - crhs16 + crhs2 + crhs21 + crhs32 + rho*(crhs11*crhs6 + crhs11*crhs7 + crhs11*crhs8 + crhs11*crhs9 + crhs25)); -const double crhs36 = K_darcy*N[0]; -const double crhs37 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); -const double crhs38 = crhs37*crhs4; -const double crhs39 = rho*(DN(0,0)*crhs18 + DN(0,1)*crhs19 + DN(0,2)*crhs20); -const double crhs40 = rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)); -const double crhs41 = K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1) + N[3]*v(3,1)); -const double crhs42 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)) + N[3]*(v(3,1) - vfrac(3,1)); -const double crhs43 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs44 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs45 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs46 = N[3]*(vn(3,1) - vnn(3,1)); -const double crhs47 = crhs43 + crhs44 + crhs45 + crhs46; -const double crhs48 = rho*(crhs13*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs14*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs15*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))); -const double crhs49 = rho*(crhs18*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs19*crhs26 + crhs20*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1))); -const double crhs50 = crhs22*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs23*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs24*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); -const double crhs51 = crhs31*crhs42; -const double crhs52 = crhs34*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] - crhs40 + crhs41 - crhs48 + crhs49 + crhs51 + rho*(crhs11*crhs43 + crhs11*crhs44 + crhs11*crhs45 + crhs11*crhs46 + crhs50)); -const double crhs53 = rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)); -const double crhs54 = K_darcy*(N[0]*v(0,2) + N[1]*v(1,2) + N[2]*v(2,2) + N[3]*v(3,2)); -const double crhs55 = N[0]*(v(0,2) - vfrac(0,2)) + N[1]*(v(1,2) - vfrac(1,2)) + N[2]*(v(2,2) - vfrac(2,2)) + N[3]*(v(3,2) - vfrac(3,2)); -const double crhs56 = N[0]*(vn(0,2) - vnn(0,2)); -const double crhs57 = N[1]*(vn(1,2) - vnn(1,2)); -const double crhs58 = N[2]*(vn(2,2) - vnn(2,2)); -const double crhs59 = N[3]*(vn(3,2) - vnn(3,2)); -const double crhs60 = crhs56 + crhs57 + crhs58 + crhs59; -const double crhs61 = rho*(crhs13*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs14*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs15*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))); -const double crhs62 = rho*(crhs18*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs19*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs20*crhs27); -const double crhs63 = crhs22*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs23*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs24*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); -const double crhs64 = crhs31*crhs55; -const double crhs65 = crhs34*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] - crhs53 + crhs54 - crhs61 + crhs62 + crhs64 + rho*(crhs11*crhs56 + crhs11*crhs57 + crhs11*crhs58 + crhs11*crhs59 + crhs63)); -const double crhs66 = N[1]*crhs33; -const double crhs67 = N[1]*rho; -const double crhs68 = K_darcy*N[1]; -const double crhs69 = crhs37*crhs67; -const double crhs70 = rho*(DN(1,0)*crhs18 + DN(1,1)*crhs19 + DN(1,2)*crhs20); -const double crhs71 = N[2]*crhs33; -const double crhs72 = N[2]*rho; -const double crhs73 = K_darcy*N[2]; -const double crhs74 = crhs37*crhs72; -const double crhs75 = rho*(DN(2,0)*crhs18 + DN(2,1)*crhs19 + DN(2,2)*crhs20); -const double crhs76 = N[3]*crhs33; -const double crhs77 = N[3]*rho; -const double crhs78 = K_darcy*N[3]; -const double crhs79 = crhs37*crhs77; -const double crhs80 = rho*(DN(3,0)*crhs18 + DN(3,1)*crhs19 + DN(3,2)*crhs20); -rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs30 - DN(0,0)*stress[0] - DN(0,1)*stress[3] - DN(0,2)*stress[5] + N[0]*crhs1 + N[0]*crhs16 - N[0]*crhs2 - N[0]*crhs21 - crhs10*crhs12 - crhs25*crhs4 - crhs3*crhs5 + crhs35*crhs36 - crhs35*crhs38 - crhs35*crhs39; -rhs[1]=-DN(0,0)*stress[3] + DN(0,1)*crhs0 - DN(0,1)*crhs30 - DN(0,1)*stress[1] - DN(0,2)*stress[4] + N[0]*crhs40 - N[0]*crhs41 + N[0]*crhs48 - N[0]*crhs49 - crhs12*crhs47 + crhs36*crhs52 - crhs38*crhs52 - crhs39*crhs52 - crhs4*crhs50 - crhs42*crhs5; -rhs[2]=-DN(0,0)*stress[5] - DN(0,1)*stress[4] + DN(0,2)*crhs0 - DN(0,2)*crhs30 - DN(0,2)*stress[2] + N[0]*crhs53 - N[0]*crhs54 + N[0]*crhs61 - N[0]*crhs62 - crhs12*crhs60 + crhs36*crhs65 - crhs38*crhs65 - crhs39*crhs65 - crhs4*crhs63 - crhs5*crhs55; -rhs[3]=-DN(0,0)*crhs35 - DN(0,1)*crhs52 - DN(0,2)*crhs65 - N[0]*crhs28; -rhs[4]=DN(1,0)*crhs0 - DN(1,0)*crhs30 - DN(1,0)*stress[0] - DN(1,1)*stress[3] - DN(1,2)*stress[5] + N[1]*crhs1 + N[1]*crhs16 - N[1]*crhs2 - N[1]*crhs21 - N[1]*crhs32 - crhs10*crhs66 - crhs25*crhs67 + crhs35*crhs68 - crhs35*crhs69 - crhs35*crhs70; -rhs[5]=-DN(1,0)*stress[3] + DN(1,1)*crhs0 - DN(1,1)*crhs30 - DN(1,1)*stress[1] - DN(1,2)*stress[4] + N[1]*crhs40 - N[1]*crhs41 + N[1]*crhs48 - N[1]*crhs49 - N[1]*crhs51 - crhs47*crhs66 - crhs50*crhs67 + crhs52*crhs68 - crhs52*crhs69 - crhs52*crhs70; -rhs[6]=-DN(1,0)*stress[5] - DN(1,1)*stress[4] + DN(1,2)*crhs0 - DN(1,2)*crhs30 - DN(1,2)*stress[2] + N[1]*crhs53 - N[1]*crhs54 + N[1]*crhs61 - N[1]*crhs62 - N[1]*crhs64 - crhs60*crhs66 - crhs63*crhs67 + crhs65*crhs68 - crhs65*crhs69 - crhs65*crhs70; -rhs[7]=-DN(1,0)*crhs35 - DN(1,1)*crhs52 - DN(1,2)*crhs65 - N[1]*crhs28; -rhs[8]=DN(2,0)*crhs0 - DN(2,0)*crhs30 - DN(2,0)*stress[0] - DN(2,1)*stress[3] - DN(2,2)*stress[5] + N[2]*crhs1 + N[2]*crhs16 - N[2]*crhs2 - N[2]*crhs21 - N[2]*crhs32 - crhs10*crhs71 - crhs25*crhs72 + crhs35*crhs73 - crhs35*crhs74 - crhs35*crhs75; -rhs[9]=-DN(2,0)*stress[3] + DN(2,1)*crhs0 - DN(2,1)*crhs30 - DN(2,1)*stress[1] - DN(2,2)*stress[4] + N[2]*crhs40 - N[2]*crhs41 + N[2]*crhs48 - N[2]*crhs49 - N[2]*crhs51 - crhs47*crhs71 - crhs50*crhs72 + crhs52*crhs73 - crhs52*crhs74 - crhs52*crhs75; -rhs[10]=-DN(2,0)*stress[5] - DN(2,1)*stress[4] + DN(2,2)*crhs0 - DN(2,2)*crhs30 - DN(2,2)*stress[2] + N[2]*crhs53 - N[2]*crhs54 + N[2]*crhs61 - N[2]*crhs62 - N[2]*crhs64 - crhs60*crhs71 - crhs63*crhs72 + crhs65*crhs73 - crhs65*crhs74 - crhs65*crhs75; -rhs[11]=-DN(2,0)*crhs35 - DN(2,1)*crhs52 - DN(2,2)*crhs65 - N[2]*crhs28; -rhs[12]=DN(3,0)*crhs0 - DN(3,0)*crhs30 - DN(3,0)*stress[0] - DN(3,1)*stress[3] - DN(3,2)*stress[5] + N[3]*crhs1 + N[3]*crhs16 - N[3]*crhs2 - N[3]*crhs21 - N[3]*crhs32 - crhs10*crhs76 - crhs25*crhs77 + crhs35*crhs78 - crhs35*crhs79 - crhs35*crhs80; -rhs[13]=-DN(3,0)*stress[3] + DN(3,1)*crhs0 - DN(3,1)*crhs30 - DN(3,1)*stress[1] - DN(3,2)*stress[4] + N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs48 - N[3]*crhs49 - N[3]*crhs51 - crhs47*crhs76 - crhs50*crhs77 + crhs52*crhs78 - crhs52*crhs79 - crhs52*crhs80; -rhs[14]=-DN(3,0)*stress[5] - DN(3,1)*stress[4] + DN(3,2)*crhs0 - DN(3,2)*crhs30 - DN(3,2)*stress[2] + N[3]*crhs53 - N[3]*crhs54 + N[3]*crhs61 - N[3]*crhs62 - N[3]*crhs64 - crhs60*crhs76 - crhs63*crhs77 + crhs65*crhs78 - crhs65*crhs79 - crhs65*crhs80; -rhs[15]=-DN(3,0)*crhs35 - DN(3,1)*crhs52 - DN(3,2)*crhs65 - N[3]*crhs28; +const double crhs1 = N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0); +const double crhs2 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)) + N[3]*(v(3,0) - vfrac(3,0)); +const double crhs3 = N[0]*rho; +const double crhs4 = bdf0*crhs3; +const double crhs5 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs6 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs7 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs8 = N[3]*(vn(3,0) - vnn(3,0)); +const double crhs9 = crhs5 + crhs6 + crhs7 + crhs8; +const double crhs10 = 1.0/dt; +const double crhs11 = crhs10*crhs3; +const double crhs12 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); +const double crhs13 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crhs14 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crhs15 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crhs16 = rho*(crhs12*crhs13 + crhs14*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs15*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0))); +const double crhs17 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crhs18 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crhs19 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crhs20 = crhs17*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs18*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs19*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crhs21 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); +const double crhs22 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); +const double crhs23 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); +const double crhs24 = crhs21*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs22*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs23*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)); +const double crhs25 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); +const double crhs26 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); +const double crhs27 = crhs12 + crhs25 + crhs26 - volume_error_ratio; +const double crhs28 = rho*stab_c2*sqrt(crhs13*crhs13 + crhs14*crhs14 + crhs15*crhs15); +const double crhs29 = crhs27*(crhs28*h*1.0/stab_c1 + mu); +const double crhs30 = bdf0*rho; +const double crhs31 = crhs2*crhs30; +const double crhs32 = crhs10*rho; +const double crhs33 = 1.0*1.0/(crhs28*1.0/h + crhs32*dyn_tau + mu*stab_c1*1.0/(h*h)); +const double crhs34 = crhs33*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] - crhs1*rho + crhs16 - crhs24*rho + crhs31 + rho*(crhs10*crhs5 + crhs10*crhs6 + crhs10*crhs7 + crhs10*crhs8 + crhs20)); +const double crhs35 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); +const double crhs36 = crhs3*crhs35; +const double crhs37 = rho*(DN(0,0)*crhs13 + DN(0,1)*crhs14 + DN(0,2)*crhs15); +const double crhs38 = N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1); +const double crhs39 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)) + N[3]*(v(3,1) - vfrac(3,1)); +const double crhs40 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs41 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs42 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs43 = N[3]*(vn(3,1) - vnn(3,1)); +const double crhs44 = crhs40 + crhs41 + crhs42 + crhs43; +const double crhs45 = rho*(crhs13*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs14*crhs25 + crhs15*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1))); +const double crhs46 = crhs17*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs18*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs19*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); +const double crhs47 = crhs21*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs22*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs23*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)); +const double crhs48 = crhs30*crhs39; +const double crhs49 = crhs33*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] - crhs38*rho + crhs45 - crhs47*rho + crhs48 + rho*(crhs10*crhs40 + crhs10*crhs41 + crhs10*crhs42 + crhs10*crhs43 + crhs46)); +const double crhs50 = N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2); +const double crhs51 = N[0]*(v(0,2) - vfrac(0,2)) + N[1]*(v(1,2) - vfrac(1,2)) + N[2]*(v(2,2) - vfrac(2,2)) + N[3]*(v(3,2) - vfrac(3,2)); +const double crhs52 = N[0]*(vn(0,2) - vnn(0,2)); +const double crhs53 = N[1]*(vn(1,2) - vnn(1,2)); +const double crhs54 = N[2]*(vn(2,2) - vnn(2,2)); +const double crhs55 = N[3]*(vn(3,2) - vnn(3,2)); +const double crhs56 = crhs52 + crhs53 + crhs54 + crhs55; +const double crhs57 = rho*(crhs13*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs14*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs15*crhs26); +const double crhs58 = crhs17*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs18*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs19*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crhs59 = crhs21*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs22*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs23*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)); +const double crhs60 = crhs30*crhs51; +const double crhs61 = crhs33*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] - crhs50*rho + crhs57 - crhs59*rho + crhs60 + rho*(crhs10*crhs52 + crhs10*crhs53 + crhs10*crhs54 + crhs10*crhs55 + crhs58)); +const double crhs62 = N[1]*crhs32; +const double crhs63 = N[1]*rho; +const double crhs64 = crhs35*crhs63; +const double crhs65 = rho*(DN(1,0)*crhs13 + DN(1,1)*crhs14 + DN(1,2)*crhs15); +const double crhs66 = N[2]*crhs32; +const double crhs67 = N[2]*rho; +const double crhs68 = crhs35*crhs67; +const double crhs69 = rho*(DN(2,0)*crhs13 + DN(2,1)*crhs14 + DN(2,2)*crhs15); +const double crhs70 = N[3]*crhs32; +const double crhs71 = N[3]*rho; +const double crhs72 = crhs35*crhs71; +const double crhs73 = rho*(DN(3,0)*crhs13 + DN(3,1)*crhs14 + DN(3,2)*crhs15); +rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs29 - DN(0,0)*stress[0] - DN(0,1)*stress[3] - DN(0,2)*stress[5] + N[0]*crhs1*rho - N[0]*crhs16 + N[0]*crhs24*rho - crhs11*crhs9 - crhs2*crhs4 - crhs20*crhs3 - crhs34*crhs36 - crhs34*crhs37; +rhs[1]=-DN(0,0)*stress[3] + DN(0,1)*crhs0 - DN(0,1)*crhs29 - DN(0,1)*stress[1] - DN(0,2)*stress[4] + N[0]*crhs38*rho - N[0]*crhs45 + N[0]*crhs47*rho - crhs11*crhs44 - crhs3*crhs46 - crhs36*crhs49 - crhs37*crhs49 - crhs39*crhs4; +rhs[2]=-DN(0,0)*stress[5] - DN(0,1)*stress[4] + DN(0,2)*crhs0 - DN(0,2)*crhs29 - DN(0,2)*stress[2] + N[0]*crhs50*rho - N[0]*crhs57 + N[0]*crhs59*rho - crhs11*crhs56 - crhs3*crhs58 - crhs36*crhs61 - crhs37*crhs61 - crhs4*crhs51; +rhs[3]=-DN(0,0)*crhs34 - DN(0,1)*crhs49 - DN(0,2)*crhs61 - N[0]*crhs27; +rhs[4]=DN(1,0)*crhs0 - DN(1,0)*crhs29 - DN(1,0)*stress[0] - DN(1,1)*stress[3] - DN(1,2)*stress[5] + N[1]*crhs1*rho - N[1]*crhs16 + N[1]*crhs24*rho - N[1]*crhs31 - crhs20*crhs63 - crhs34*crhs64 - crhs34*crhs65 - crhs62*crhs9; +rhs[5]=-DN(1,0)*stress[3] + DN(1,1)*crhs0 - DN(1,1)*crhs29 - DN(1,1)*stress[1] - DN(1,2)*stress[4] + N[1]*crhs38*rho - N[1]*crhs45 + N[1]*crhs47*rho - N[1]*crhs48 - crhs44*crhs62 - crhs46*crhs63 - crhs49*crhs64 - crhs49*crhs65; +rhs[6]=-DN(1,0)*stress[5] - DN(1,1)*stress[4] + DN(1,2)*crhs0 - DN(1,2)*crhs29 - DN(1,2)*stress[2] + N[1]*crhs50*rho - N[1]*crhs57 + N[1]*crhs59*rho - N[1]*crhs60 - crhs56*crhs62 - crhs58*crhs63 - crhs61*crhs64 - crhs61*crhs65; +rhs[7]=-DN(1,0)*crhs34 - DN(1,1)*crhs49 - DN(1,2)*crhs61 - N[1]*crhs27; +rhs[8]=DN(2,0)*crhs0 - DN(2,0)*crhs29 - DN(2,0)*stress[0] - DN(2,1)*stress[3] - DN(2,2)*stress[5] + N[2]*crhs1*rho - N[2]*crhs16 + N[2]*crhs24*rho - N[2]*crhs31 - crhs20*crhs67 - crhs34*crhs68 - crhs34*crhs69 - crhs66*crhs9; +rhs[9]=-DN(2,0)*stress[3] + DN(2,1)*crhs0 - DN(2,1)*crhs29 - DN(2,1)*stress[1] - DN(2,2)*stress[4] + N[2]*crhs38*rho - N[2]*crhs45 + N[2]*crhs47*rho - N[2]*crhs48 - crhs44*crhs66 - crhs46*crhs67 - crhs49*crhs68 - crhs49*crhs69; +rhs[10]=-DN(2,0)*stress[5] - DN(2,1)*stress[4] + DN(2,2)*crhs0 - DN(2,2)*crhs29 - DN(2,2)*stress[2] + N[2]*crhs50*rho - N[2]*crhs57 + N[2]*crhs59*rho - N[2]*crhs60 - crhs56*crhs66 - crhs58*crhs67 - crhs61*crhs68 - crhs61*crhs69; +rhs[11]=-DN(2,0)*crhs34 - DN(2,1)*crhs49 - DN(2,2)*crhs61 - N[2]*crhs27; +rhs[12]=DN(3,0)*crhs0 - DN(3,0)*crhs29 - DN(3,0)*stress[0] - DN(3,1)*stress[3] - DN(3,2)*stress[5] + N[3]*crhs1*rho - N[3]*crhs16 + N[3]*crhs24*rho - N[3]*crhs31 - crhs20*crhs71 - crhs34*crhs72 - crhs34*crhs73 - crhs70*crhs9; +rhs[13]=-DN(3,0)*stress[3] + DN(3,1)*crhs0 - DN(3,1)*crhs29 - DN(3,1)*stress[1] - DN(3,2)*stress[4] + N[3]*crhs38*rho - N[3]*crhs45 + N[3]*crhs47*rho - N[3]*crhs48 - crhs44*crhs70 - crhs46*crhs71 - crhs49*crhs72 - crhs49*crhs73; +rhs[14]=-DN(3,0)*stress[5] - DN(3,1)*stress[4] + DN(3,2)*crhs0 - DN(3,2)*crhs29 - DN(3,2)*stress[2] + N[3]*crhs50*rho - N[3]*crhs57 + N[3]*crhs59*rho - N[3]*crhs60 - crhs56*crhs70 - crhs58*crhs71 - crhs61*crhs72 - crhs61*crhs73; +rhs[15]=-DN(3,0)*crhs34 - DN(3,1)*crhs49 - DN(3,2)*crhs61 - N[3]*crhs27; noalias(rRHS) += rData.Weight * rhs; @@ -1534,21 +1475,16 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - const auto vfrac = rData.Velocity_Fractional; - + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; @@ -1558,10 +1494,6 @@ void TwoFluidNavierStokesFractional>::C const auto &Nenr = rData.Nenr; const auto &DNenr = rData.DN_DXenr; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -1595,47 +1527,39 @@ void TwoFluidNavierStokesFractional>::C const double cV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); const double cV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double cV2 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1)); -const double cV3 = DNenr(0,0)*cV2; -const double cV4 = K_darcy*N[0]; -const double cV5 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); -const double cV6 = N[0]*cV5; -const double cV7 = rho*(DN(0,0)*cV0 + DN(0,1)*cV1); -const double cV8 = DNenr(1,0)*cV2; -const double cV9 = DNenr(2,0)*cV2; -const double cV10 = DNenr(0,1)*cV2; -const double cV11 = DNenr(1,1)*cV2; -const double cV12 = DNenr(2,1)*cV2; -const double cV13 = K_darcy*N[1]; -const double cV14 = N[1]*cV5; -const double cV15 = rho*(DN(1,0)*cV0 + DN(1,1)*cV1); -const double cV16 = K_darcy*N[2]; -const double cV17 = N[2]*cV5; -const double cV18 = rho*(DN(2,0)*cV0 + DN(2,1)*cV1); -V(0,0)=-DN(0,0)*Nenr[0] - cV3*cV4 + cV3*cV6 + cV3*cV7; -V(0,1)=-DN(0,0)*Nenr[1] - cV4*cV8 + cV6*cV8 + cV7*cV8; -V(0,2)=-DN(0,0)*Nenr[2] - cV4*cV9 + cV6*cV9 + cV7*cV9; -V(1,0)=-DN(0,1)*Nenr[0] - cV10*cV4 + cV10*cV6 + cV10*cV7; -V(1,1)=-DN(0,1)*Nenr[1] - cV11*cV4 + cV11*cV6 + cV11*cV7; -V(1,2)=-DN(0,1)*Nenr[2] - cV12*cV4 + cV12*cV6 + cV12*cV7; +const double cV2 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1)); +const double cV3 = cV2*rho; +const double cV4 = cV3*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double cV5 = N[0]*cV4; +const double cV6 = cV3*(DN(0,0)*cV0 + DN(0,1)*cV1); +const double cV7 = N[1]*cV4; +const double cV8 = cV3*(DN(1,0)*cV0 + DN(1,1)*cV1); +const double cV9 = N[2]*cV4; +const double cV10 = cV3*(DN(2,0)*cV0 + DN(2,1)*cV1); +V(0,0)=-DN(0,0)*Nenr[0] + DNenr(0,0)*cV5 + DNenr(0,0)*cV6; +V(0,1)=-DN(0,0)*Nenr[1] + DNenr(1,0)*cV5 + DNenr(1,0)*cV6; +V(0,2)=-DN(0,0)*Nenr[2] + DNenr(2,0)*cV5 + DNenr(2,0)*cV6; +V(1,0)=-DN(0,1)*Nenr[0] + DNenr(0,1)*cV5 + DNenr(0,1)*cV6; +V(1,1)=-DN(0,1)*Nenr[1] + DNenr(1,1)*cV5 + DNenr(1,1)*cV6; +V(1,2)=-DN(0,1)*Nenr[2] + DNenr(2,1)*cV5 + DNenr(2,1)*cV6; V(2,0)=cV2*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); V(2,1)=cV2*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); V(2,2)=cV2*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); -V(3,0)=-DN(1,0)*Nenr[0] - cV13*cV3 + cV14*cV3 + cV15*cV3; -V(3,1)=-DN(1,0)*Nenr[1] - cV13*cV8 + cV14*cV8 + cV15*cV8; -V(3,2)=-DN(1,0)*Nenr[2] - cV13*cV9 + cV14*cV9 + cV15*cV9; -V(4,0)=-DN(1,1)*Nenr[0] - cV10*cV13 + cV10*cV14 + cV10*cV15; -V(4,1)=-DN(1,1)*Nenr[1] - cV11*cV13 + cV11*cV14 + cV11*cV15; -V(4,2)=-DN(1,1)*Nenr[2] - cV12*cV13 + cV12*cV14 + cV12*cV15; +V(3,0)=-DN(1,0)*Nenr[0] + DNenr(0,0)*cV7 + DNenr(0,0)*cV8; +V(3,1)=-DN(1,0)*Nenr[1] + DNenr(1,0)*cV7 + DNenr(1,0)*cV8; +V(3,2)=-DN(1,0)*Nenr[2] + DNenr(2,0)*cV7 + DNenr(2,0)*cV8; +V(4,0)=-DN(1,1)*Nenr[0] + DNenr(0,1)*cV7 + DNenr(0,1)*cV8; +V(4,1)=-DN(1,1)*Nenr[1] + DNenr(1,1)*cV7 + DNenr(1,1)*cV8; +V(4,2)=-DN(1,1)*Nenr[2] + DNenr(2,1)*cV7 + DNenr(2,1)*cV8; V(5,0)=cV2*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); V(5,1)=cV2*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); V(5,2)=cV2*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); -V(6,0)=-DN(2,0)*Nenr[0] - cV16*cV3 + cV17*cV3 + cV18*cV3; -V(6,1)=-DN(2,0)*Nenr[1] - cV16*cV8 + cV17*cV8 + cV18*cV8; -V(6,2)=-DN(2,0)*Nenr[2] - cV16*cV9 + cV17*cV9 + cV18*cV9; -V(7,0)=-DN(2,1)*Nenr[0] - cV10*cV16 + cV10*cV17 + cV10*cV18; -V(7,1)=-DN(2,1)*Nenr[1] - cV11*cV16 + cV11*cV17 + cV11*cV18; -V(7,2)=-DN(2,1)*Nenr[2] - cV12*cV16 + cV12*cV17 + cV12*cV18; +V(6,0)=-DN(2,0)*Nenr[0] + DNenr(0,0)*cV10 + DNenr(0,0)*cV9; +V(6,1)=-DN(2,0)*Nenr[1] + DNenr(1,0)*cV10 + DNenr(1,0)*cV9; +V(6,2)=-DN(2,0)*Nenr[2] + DNenr(2,0)*cV10 + DNenr(2,0)*cV9; +V(7,0)=-DN(2,1)*Nenr[0] + DNenr(0,1)*cV10 + DNenr(0,1)*cV9; +V(7,1)=-DN(2,1)*Nenr[1] + DNenr(1,1)*cV10 + DNenr(1,1)*cV9; +V(7,2)=-DN(2,1)*Nenr[2] + DNenr(2,1)*cV10 + DNenr(2,1)*cV9; V(8,0)=cV2*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); V(8,1)=cV2*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); V(8,2)=cV2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); @@ -1643,40 +1567,41 @@ V(8,2)=cV2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); const double cH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); const double cH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double cH2 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1)); -const double cH3 = cH2*(K_darcy*N[0] + rho*(DN(0,0)*cH0 + DN(0,1)*cH1 + N[0]*bdf0)); -const double cH4 = cH2*(K_darcy*N[1] + rho*(DN(1,0)*cH0 + DN(1,1)*cH1 + N[1]*bdf0)); -const double cH5 = cH2*(K_darcy*N[2] + rho*(DN(2,0)*cH0 + DN(2,1)*cH1 + N[2]*bdf0)); -H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH3; -H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH3; +const double cH2 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1)); +const double cH3 = cH2*rho; +const double cH4 = cH3*(DN(0,0)*cH0 + DN(0,1)*cH1 + N[0]*bdf0); +const double cH5 = cH3*(DN(1,0)*cH0 + DN(1,1)*cH1 + N[1]*bdf0); +const double cH6 = cH3*(DN(2,0)*cH0 + DN(2,1)*cH1 + N[2]*bdf0); +H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH4; +H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH4; H(0,2)=cH2*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); -H(0,3)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH4; -H(0,4)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH4; +H(0,3)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH5; +H(0,4)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH5; H(0,5)=cH2*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); -H(0,6)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH5; -H(0,7)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH5; +H(0,6)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH6; +H(0,7)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH6; H(0,8)=cH2*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); -H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH3; -H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH3; +H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH4; +H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH4; H(1,2)=cH2*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); -H(1,3)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH4; -H(1,4)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH4; +H(1,3)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH5; +H(1,4)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH5; H(1,5)=cH2*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); -H(1,6)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH5; -H(1,7)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH5; +H(1,6)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH6; +H(1,7)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH6; H(1,8)=cH2*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); -H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH3; -H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH3; +H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH4; +H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH4; H(2,2)=cH2*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); -H(2,3)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH4; -H(2,4)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH4; +H(2,3)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH5; +H(2,4)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH5; H(2,5)=cH2*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); -H(2,6)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH5; -H(2,7)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH5; +H(2,6)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH6; +H(2,7)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH6; H(2,8)=cH2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); - const double cKee0 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1), 2))*1.0/h); + const double cKee0 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1), 2))*1.0/h); const double cKee1 = cKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1)); const double cKee2 = cKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1)); const double cKee3 = cKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1)); @@ -1707,9 +1632,9 @@ const double crhs_ee12 = N[1]*crhs_ee10; const double crhs_ee13 = N[2]*crhs_ee10; const double crhs_ee14 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); const double crhs_ee15 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); -const double crhs_ee16 = 1.0*1.0/(K_darcy + crhs_ee10*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee8*crhs_ee8 + crhs_ee9*crhs_ee9)); -const double crhs_ee17 = crhs_ee16*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0)) - rho*(crhs_ee3*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs_ee4*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)) + rho*(crhs_ee0*crhs_ee8 + crhs_ee5*(v(0,0) - vfrac(0,0)) + crhs_ee6*(v(1,0) - vfrac(1,0)) + crhs_ee7*(v(2,0) - vfrac(2,0)) + crhs_ee9*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))) + rho*(crhs_ee11*(vn(0,0) - vnn(0,0)) + crhs_ee12*(vn(1,0) - vnn(1,0)) + crhs_ee13*(vn(2,0) - vnn(2,0)) + crhs_ee14*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs_ee15*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)))); -const double crhs_ee18 = crhs_ee16*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1)) - rho*(crhs_ee3*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs_ee4*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)) + rho*(crhs_ee1*crhs_ee9 + crhs_ee5*(v(0,1) - vfrac(0,1)) + crhs_ee6*(v(1,1) - vfrac(1,1)) + crhs_ee7*(v(2,1) - vfrac(2,1)) + crhs_ee8*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1))) + rho*(crhs_ee11*(vn(0,1) - vnn(0,1)) + crhs_ee12*(vn(1,1) - vnn(1,1)) + crhs_ee13*(vn(2,1) - vnn(2,1)) + crhs_ee14*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs_ee15*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)))); +const double crhs_ee16 = 1.0*1.0/(crhs_ee10*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee8*crhs_ee8 + crhs_ee9*crhs_ee9)); +const double crhs_ee17 = crhs_ee16*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] - rho*(crhs_ee3*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs_ee4*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)) + rho*(crhs_ee0*crhs_ee8 + crhs_ee5*(v(0,0) - vfrac(0,0)) + crhs_ee6*(v(1,0) - vfrac(1,0)) + crhs_ee7*(v(2,0) - vfrac(2,0)) + crhs_ee9*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))) + rho*(crhs_ee11*(vn(0,0) - vnn(0,0)) + crhs_ee12*(vn(1,0) - vnn(1,0)) + crhs_ee13*(vn(2,0) - vnn(2,0)) + crhs_ee14*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs_ee15*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)))); +const double crhs_ee18 = crhs_ee16*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] - rho*(crhs_ee3*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs_ee4*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)) + rho*(crhs_ee1*crhs_ee9 + crhs_ee5*(v(0,1) - vfrac(0,1)) + crhs_ee6*(v(1,1) - vfrac(1,1)) + crhs_ee7*(v(2,1) - vfrac(2,1)) + crhs_ee8*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1))) + rho*(crhs_ee11*(vn(0,1) - vnn(0,1)) + crhs_ee12*(vn(1,1) - vnn(1,1)) + crhs_ee13*(vn(2,1) - vnn(2,1)) + crhs_ee14*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs_ee15*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)))); rhs_ee[0]=-DNenr(0,0)*crhs_ee17 - DNenr(0,1)*crhs_ee18 - Nenr[0]*crhs_ee2; rhs_ee[1]=-DNenr(1,0)*crhs_ee17 - DNenr(1,1)*crhs_ee18 - Nenr[1]*crhs_ee2; rhs_ee[2]=-DNenr(2,0)*crhs_ee17 - DNenr(2,1)*crhs_ee18 - Nenr[2]*crhs_ee2; @@ -1732,23 +1657,16 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - const auto vfrac = rData.Velocity_Fractional; - // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible - + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; @@ -1758,10 +1676,6 @@ void TwoFluidNavierStokesFractional>::C const auto &Nenr = rData.Nenr; const auto &DNenr = rData.DN_DXenr; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -1796,92 +1710,77 @@ void TwoFluidNavierStokesFractional>::C const double cV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); const double cV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); const double cV2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double cV3 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1 + cV2*cV2)); -const double cV4 = DNenr(0,0)*cV3; -const double cV5 = K_darcy*N[0]; -const double cV6 = rho*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); -const double cV7 = N[0]*cV6; -const double cV8 = rho*(DN(0,0)*cV0 + DN(0,1)*cV1 + DN(0,2)*cV2); -const double cV9 = DNenr(1,0)*cV3; -const double cV10 = DNenr(2,0)*cV3; -const double cV11 = DNenr(3,0)*cV3; -const double cV12 = DNenr(0,1)*cV3; -const double cV13 = DNenr(1,1)*cV3; -const double cV14 = DNenr(2,1)*cV3; -const double cV15 = DNenr(3,1)*cV3; -const double cV16 = DNenr(0,2)*cV3; -const double cV17 = DNenr(1,2)*cV3; -const double cV18 = DNenr(2,2)*cV3; -const double cV19 = DNenr(3,2)*cV3; -const double cV20 = K_darcy*N[1]; -const double cV21 = N[1]*cV6; -const double cV22 = rho*(DN(1,0)*cV0 + DN(1,1)*cV1 + DN(1,2)*cV2); -const double cV23 = K_darcy*N[2]; -const double cV24 = N[2]*cV6; -const double cV25 = rho*(DN(2,0)*cV0 + DN(2,1)*cV1 + DN(2,2)*cV2); -const double cV26 = K_darcy*N[3]; -const double cV27 = N[3]*cV6; -const double cV28 = rho*(DN(3,0)*cV0 + DN(3,1)*cV1 + DN(3,2)*cV2); -V(0,0)=-DN(0,0)*Nenr[0] - cV4*cV5 + cV4*cV7 + cV4*cV8; -V(0,1)=-DN(0,0)*Nenr[1] - cV5*cV9 + cV7*cV9 + cV8*cV9; -V(0,2)=-DN(0,0)*Nenr[2] - cV10*cV5 + cV10*cV7 + cV10*cV8; -V(0,3)=-DN(0,0)*Nenr[3] - cV11*cV5 + cV11*cV7 + cV11*cV8; -V(1,0)=-DN(0,1)*Nenr[0] - cV12*cV5 + cV12*cV7 + cV12*cV8; -V(1,1)=-DN(0,1)*Nenr[1] - cV13*cV5 + cV13*cV7 + cV13*cV8; -V(1,2)=-DN(0,1)*Nenr[2] - cV14*cV5 + cV14*cV7 + cV14*cV8; -V(1,3)=-DN(0,1)*Nenr[3] - cV15*cV5 + cV15*cV7 + cV15*cV8; -V(2,0)=-DN(0,2)*Nenr[0] - cV16*cV5 + cV16*cV7 + cV16*cV8; -V(2,1)=-DN(0,2)*Nenr[1] - cV17*cV5 + cV17*cV7 + cV17*cV8; -V(2,2)=-DN(0,2)*Nenr[2] - cV18*cV5 + cV18*cV7 + cV18*cV8; -V(2,3)=-DN(0,2)*Nenr[3] - cV19*cV5 + cV19*cV7 + cV19*cV8; +const double cV3 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1 + cV2*cV2)); +const double cV4 = cV3*rho; +const double cV5 = cV4*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double cV6 = N[0]*cV5; +const double cV7 = cV4*(DN(0,0)*cV0 + DN(0,1)*cV1 + DN(0,2)*cV2); +const double cV8 = N[1]*cV5; +const double cV9 = cV4*(DN(1,0)*cV0 + DN(1,1)*cV1 + DN(1,2)*cV2); +const double cV10 = N[2]*cV5; +const double cV11 = cV4*(DN(2,0)*cV0 + DN(2,1)*cV1 + DN(2,2)*cV2); +const double cV12 = N[3]*cV5; +const double cV13 = cV4*(DN(3,0)*cV0 + DN(3,1)*cV1 + DN(3,2)*cV2); +V(0,0)=-DN(0,0)*Nenr[0] + DNenr(0,0)*cV6 + DNenr(0,0)*cV7; +V(0,1)=-DN(0,0)*Nenr[1] + DNenr(1,0)*cV6 + DNenr(1,0)*cV7; +V(0,2)=-DN(0,0)*Nenr[2] + DNenr(2,0)*cV6 + DNenr(2,0)*cV7; +V(0,3)=-DN(0,0)*Nenr[3] + DNenr(3,0)*cV6 + DNenr(3,0)*cV7; +V(1,0)=-DN(0,1)*Nenr[0] + DNenr(0,1)*cV6 + DNenr(0,1)*cV7; +V(1,1)=-DN(0,1)*Nenr[1] + DNenr(1,1)*cV6 + DNenr(1,1)*cV7; +V(1,2)=-DN(0,1)*Nenr[2] + DNenr(2,1)*cV6 + DNenr(2,1)*cV7; +V(1,3)=-DN(0,1)*Nenr[3] + DNenr(3,1)*cV6 + DNenr(3,1)*cV7; +V(2,0)=-DN(0,2)*Nenr[0] + DNenr(0,2)*cV6 + DNenr(0,2)*cV7; +V(2,1)=-DN(0,2)*Nenr[1] + DNenr(1,2)*cV6 + DNenr(1,2)*cV7; +V(2,2)=-DN(0,2)*Nenr[2] + DNenr(2,2)*cV6 + DNenr(2,2)*cV7; +V(2,3)=-DN(0,2)*Nenr[3] + DNenr(3,2)*cV6 + DNenr(3,2)*cV7; V(3,0)=cV3*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); V(3,1)=cV3*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); V(3,2)=cV3*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); V(3,3)=cV3*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); -V(4,0)=-DN(1,0)*Nenr[0] - cV20*cV4 + cV21*cV4 + cV22*cV4; -V(4,1)=-DN(1,0)*Nenr[1] - cV20*cV9 + cV21*cV9 + cV22*cV9; -V(4,2)=-DN(1,0)*Nenr[2] - cV10*cV20 + cV10*cV21 + cV10*cV22; -V(4,3)=-DN(1,0)*Nenr[3] - cV11*cV20 + cV11*cV21 + cV11*cV22; -V(5,0)=-DN(1,1)*Nenr[0] - cV12*cV20 + cV12*cV21 + cV12*cV22; -V(5,1)=-DN(1,1)*Nenr[1] - cV13*cV20 + cV13*cV21 + cV13*cV22; -V(5,2)=-DN(1,1)*Nenr[2] - cV14*cV20 + cV14*cV21 + cV14*cV22; -V(5,3)=-DN(1,1)*Nenr[3] - cV15*cV20 + cV15*cV21 + cV15*cV22; -V(6,0)=-DN(1,2)*Nenr[0] - cV16*cV20 + cV16*cV21 + cV16*cV22; -V(6,1)=-DN(1,2)*Nenr[1] - cV17*cV20 + cV17*cV21 + cV17*cV22; -V(6,2)=-DN(1,2)*Nenr[2] - cV18*cV20 + cV18*cV21 + cV18*cV22; -V(6,3)=-DN(1,2)*Nenr[3] - cV19*cV20 + cV19*cV21 + cV19*cV22; +V(4,0)=-DN(1,0)*Nenr[0] + DNenr(0,0)*cV8 + DNenr(0,0)*cV9; +V(4,1)=-DN(1,0)*Nenr[1] + DNenr(1,0)*cV8 + DNenr(1,0)*cV9; +V(4,2)=-DN(1,0)*Nenr[2] + DNenr(2,0)*cV8 + DNenr(2,0)*cV9; +V(4,3)=-DN(1,0)*Nenr[3] + DNenr(3,0)*cV8 + DNenr(3,0)*cV9; +V(5,0)=-DN(1,1)*Nenr[0] + DNenr(0,1)*cV8 + DNenr(0,1)*cV9; +V(5,1)=-DN(1,1)*Nenr[1] + DNenr(1,1)*cV8 + DNenr(1,1)*cV9; +V(5,2)=-DN(1,1)*Nenr[2] + DNenr(2,1)*cV8 + DNenr(2,1)*cV9; +V(5,3)=-DN(1,1)*Nenr[3] + DNenr(3,1)*cV8 + DNenr(3,1)*cV9; +V(6,0)=-DN(1,2)*Nenr[0] + DNenr(0,2)*cV8 + DNenr(0,2)*cV9; +V(6,1)=-DN(1,2)*Nenr[1] + DNenr(1,2)*cV8 + DNenr(1,2)*cV9; +V(6,2)=-DN(1,2)*Nenr[2] + DNenr(2,2)*cV8 + DNenr(2,2)*cV9; +V(6,3)=-DN(1,2)*Nenr[3] + DNenr(3,2)*cV8 + DNenr(3,2)*cV9; V(7,0)=cV3*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); V(7,1)=cV3*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); V(7,2)=cV3*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); V(7,3)=cV3*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); -V(8,0)=-DN(2,0)*Nenr[0] - cV23*cV4 + cV24*cV4 + cV25*cV4; -V(8,1)=-DN(2,0)*Nenr[1] - cV23*cV9 + cV24*cV9 + cV25*cV9; -V(8,2)=-DN(2,0)*Nenr[2] - cV10*cV23 + cV10*cV24 + cV10*cV25; -V(8,3)=-DN(2,0)*Nenr[3] - cV11*cV23 + cV11*cV24 + cV11*cV25; -V(9,0)=-DN(2,1)*Nenr[0] - cV12*cV23 + cV12*cV24 + cV12*cV25; -V(9,1)=-DN(2,1)*Nenr[1] - cV13*cV23 + cV13*cV24 + cV13*cV25; -V(9,2)=-DN(2,1)*Nenr[2] - cV14*cV23 + cV14*cV24 + cV14*cV25; -V(9,3)=-DN(2,1)*Nenr[3] - cV15*cV23 + cV15*cV24 + cV15*cV25; -V(10,0)=-DN(2,2)*Nenr[0] - cV16*cV23 + cV16*cV24 + cV16*cV25; -V(10,1)=-DN(2,2)*Nenr[1] - cV17*cV23 + cV17*cV24 + cV17*cV25; -V(10,2)=-DN(2,2)*Nenr[2] - cV18*cV23 + cV18*cV24 + cV18*cV25; -V(10,3)=-DN(2,2)*Nenr[3] - cV19*cV23 + cV19*cV24 + cV19*cV25; +V(8,0)=-DN(2,0)*Nenr[0] + DNenr(0,0)*cV10 + DNenr(0,0)*cV11; +V(8,1)=-DN(2,0)*Nenr[1] + DNenr(1,0)*cV10 + DNenr(1,0)*cV11; +V(8,2)=-DN(2,0)*Nenr[2] + DNenr(2,0)*cV10 + DNenr(2,0)*cV11; +V(8,3)=-DN(2,0)*Nenr[3] + DNenr(3,0)*cV10 + DNenr(3,0)*cV11; +V(9,0)=-DN(2,1)*Nenr[0] + DNenr(0,1)*cV10 + DNenr(0,1)*cV11; +V(9,1)=-DN(2,1)*Nenr[1] + DNenr(1,1)*cV10 + DNenr(1,1)*cV11; +V(9,2)=-DN(2,1)*Nenr[2] + DNenr(2,1)*cV10 + DNenr(2,1)*cV11; +V(9,3)=-DN(2,1)*Nenr[3] + DNenr(3,1)*cV10 + DNenr(3,1)*cV11; +V(10,0)=-DN(2,2)*Nenr[0] + DNenr(0,2)*cV10 + DNenr(0,2)*cV11; +V(10,1)=-DN(2,2)*Nenr[1] + DNenr(1,2)*cV10 + DNenr(1,2)*cV11; +V(10,2)=-DN(2,2)*Nenr[2] + DNenr(2,2)*cV10 + DNenr(2,2)*cV11; +V(10,3)=-DN(2,2)*Nenr[3] + DNenr(3,2)*cV10 + DNenr(3,2)*cV11; V(11,0)=cV3*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); V(11,1)=cV3*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); V(11,2)=cV3*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); V(11,3)=cV3*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); -V(12,0)=-DN(3,0)*Nenr[0] - cV26*cV4 + cV27*cV4 + cV28*cV4; -V(12,1)=-DN(3,0)*Nenr[1] - cV26*cV9 + cV27*cV9 + cV28*cV9; -V(12,2)=-DN(3,0)*Nenr[2] - cV10*cV26 + cV10*cV27 + cV10*cV28; -V(12,3)=-DN(3,0)*Nenr[3] - cV11*cV26 + cV11*cV27 + cV11*cV28; -V(13,0)=-DN(3,1)*Nenr[0] - cV12*cV26 + cV12*cV27 + cV12*cV28; -V(13,1)=-DN(3,1)*Nenr[1] - cV13*cV26 + cV13*cV27 + cV13*cV28; -V(13,2)=-DN(3,1)*Nenr[2] - cV14*cV26 + cV14*cV27 + cV14*cV28; -V(13,3)=-DN(3,1)*Nenr[3] - cV15*cV26 + cV15*cV27 + cV15*cV28; -V(14,0)=-DN(3,2)*Nenr[0] - cV16*cV26 + cV16*cV27 + cV16*cV28; -V(14,1)=-DN(3,2)*Nenr[1] - cV17*cV26 + cV17*cV27 + cV17*cV28; -V(14,2)=-DN(3,2)*Nenr[2] - cV18*cV26 + cV18*cV27 + cV18*cV28; -V(14,3)=-DN(3,2)*Nenr[3] - cV19*cV26 + cV19*cV27 + cV19*cV28; +V(12,0)=-DN(3,0)*Nenr[0] + DNenr(0,0)*cV12 + DNenr(0,0)*cV13; +V(12,1)=-DN(3,0)*Nenr[1] + DNenr(1,0)*cV12 + DNenr(1,0)*cV13; +V(12,2)=-DN(3,0)*Nenr[2] + DNenr(2,0)*cV12 + DNenr(2,0)*cV13; +V(12,3)=-DN(3,0)*Nenr[3] + DNenr(3,0)*cV12 + DNenr(3,0)*cV13; +V(13,0)=-DN(3,1)*Nenr[0] + DNenr(0,1)*cV12 + DNenr(0,1)*cV13; +V(13,1)=-DN(3,1)*Nenr[1] + DNenr(1,1)*cV12 + DNenr(1,1)*cV13; +V(13,2)=-DN(3,1)*Nenr[2] + DNenr(2,1)*cV12 + DNenr(2,1)*cV13; +V(13,3)=-DN(3,1)*Nenr[3] + DNenr(3,1)*cV12 + DNenr(3,1)*cV13; +V(14,0)=-DN(3,2)*Nenr[0] + DNenr(0,2)*cV12 + DNenr(0,2)*cV13; +V(14,1)=-DN(3,2)*Nenr[1] + DNenr(1,2)*cV12 + DNenr(1,2)*cV13; +V(14,2)=-DN(3,2)*Nenr[2] + DNenr(2,2)*cV12 + DNenr(2,2)*cV13; +V(14,3)=-DN(3,2)*Nenr[3] + DNenr(3,2)*cV12 + DNenr(3,2)*cV13; V(15,0)=cV3*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); V(15,1)=cV3*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); V(15,2)=cV3*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); @@ -1891,78 +1790,79 @@ V(15,3)=cV3*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); const double cH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); const double cH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); const double cH2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double cH3 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1 + cH2*cH2)); -const double cH4 = cH3*(K_darcy*N[0] + rho*(DN(0,0)*cH0 + DN(0,1)*cH1 + DN(0,2)*cH2 + N[0]*bdf0)); -const double cH5 = cH3*(K_darcy*N[1] + rho*(DN(1,0)*cH0 + DN(1,1)*cH1 + DN(1,2)*cH2 + N[1]*bdf0)); -const double cH6 = cH3*(K_darcy*N[2] + rho*(DN(2,0)*cH0 + DN(2,1)*cH1 + DN(2,2)*cH2 + N[2]*bdf0)); -const double cH7 = cH3*(K_darcy*N[3] + rho*(DN(3,0)*cH0 + DN(3,1)*cH1 + DN(3,2)*cH2 + N[3]*bdf0)); -H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH4; -H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH4; -H(0,2)=DN(0,2)*Nenr[0] + DNenr(0,2)*cH4; +const double cH3 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1 + cH2*cH2)); +const double cH4 = cH3*rho; +const double cH5 = cH4*(DN(0,0)*cH0 + DN(0,1)*cH1 + DN(0,2)*cH2 + N[0]*bdf0); +const double cH6 = cH4*(DN(1,0)*cH0 + DN(1,1)*cH1 + DN(1,2)*cH2 + N[1]*bdf0); +const double cH7 = cH4*(DN(2,0)*cH0 + DN(2,1)*cH1 + DN(2,2)*cH2 + N[2]*bdf0); +const double cH8 = cH4*(DN(3,0)*cH0 + DN(3,1)*cH1 + DN(3,2)*cH2 + N[3]*bdf0); +H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH5; +H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH5; +H(0,2)=DN(0,2)*Nenr[0] + DNenr(0,2)*cH5; H(0,3)=cH3*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); -H(0,4)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH5; -H(0,5)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH5; -H(0,6)=DN(1,2)*Nenr[0] + DNenr(0,2)*cH5; +H(0,4)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH6; +H(0,5)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH6; +H(0,6)=DN(1,2)*Nenr[0] + DNenr(0,2)*cH6; H(0,7)=cH3*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); -H(0,8)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH6; -H(0,9)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH6; -H(0,10)=DN(2,2)*Nenr[0] + DNenr(0,2)*cH6; +H(0,8)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH7; +H(0,9)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH7; +H(0,10)=DN(2,2)*Nenr[0] + DNenr(0,2)*cH7; H(0,11)=cH3*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); -H(0,12)=DN(3,0)*Nenr[0] + DNenr(0,0)*cH7; -H(0,13)=DN(3,1)*Nenr[0] + DNenr(0,1)*cH7; -H(0,14)=DN(3,2)*Nenr[0] + DNenr(0,2)*cH7; +H(0,12)=DN(3,0)*Nenr[0] + DNenr(0,0)*cH8; +H(0,13)=DN(3,1)*Nenr[0] + DNenr(0,1)*cH8; +H(0,14)=DN(3,2)*Nenr[0] + DNenr(0,2)*cH8; H(0,15)=cH3*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); -H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH4; -H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH4; -H(1,2)=DN(0,2)*Nenr[1] + DNenr(1,2)*cH4; +H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH5; +H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH5; +H(1,2)=DN(0,2)*Nenr[1] + DNenr(1,2)*cH5; H(1,3)=cH3*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); -H(1,4)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH5; -H(1,5)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH5; -H(1,6)=DN(1,2)*Nenr[1] + DNenr(1,2)*cH5; +H(1,4)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH6; +H(1,5)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH6; +H(1,6)=DN(1,2)*Nenr[1] + DNenr(1,2)*cH6; H(1,7)=cH3*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); -H(1,8)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH6; -H(1,9)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH6; -H(1,10)=DN(2,2)*Nenr[1] + DNenr(1,2)*cH6; +H(1,8)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH7; +H(1,9)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH7; +H(1,10)=DN(2,2)*Nenr[1] + DNenr(1,2)*cH7; H(1,11)=cH3*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); -H(1,12)=DN(3,0)*Nenr[1] + DNenr(1,0)*cH7; -H(1,13)=DN(3,1)*Nenr[1] + DNenr(1,1)*cH7; -H(1,14)=DN(3,2)*Nenr[1] + DNenr(1,2)*cH7; +H(1,12)=DN(3,0)*Nenr[1] + DNenr(1,0)*cH8; +H(1,13)=DN(3,1)*Nenr[1] + DNenr(1,1)*cH8; +H(1,14)=DN(3,2)*Nenr[1] + DNenr(1,2)*cH8; H(1,15)=cH3*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); -H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH4; -H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH4; -H(2,2)=DN(0,2)*Nenr[2] + DNenr(2,2)*cH4; +H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH5; +H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH5; +H(2,2)=DN(0,2)*Nenr[2] + DNenr(2,2)*cH5; H(2,3)=cH3*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); -H(2,4)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH5; -H(2,5)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH5; -H(2,6)=DN(1,2)*Nenr[2] + DNenr(2,2)*cH5; +H(2,4)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH6; +H(2,5)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH6; +H(2,6)=DN(1,2)*Nenr[2] + DNenr(2,2)*cH6; H(2,7)=cH3*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); -H(2,8)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH6; -H(2,9)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH6; -H(2,10)=DN(2,2)*Nenr[2] + DNenr(2,2)*cH6; +H(2,8)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH7; +H(2,9)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH7; +H(2,10)=DN(2,2)*Nenr[2] + DNenr(2,2)*cH7; H(2,11)=cH3*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); -H(2,12)=DN(3,0)*Nenr[2] + DNenr(2,0)*cH7; -H(2,13)=DN(3,1)*Nenr[2] + DNenr(2,1)*cH7; -H(2,14)=DN(3,2)*Nenr[2] + DNenr(2,2)*cH7; +H(2,12)=DN(3,0)*Nenr[2] + DNenr(2,0)*cH8; +H(2,13)=DN(3,1)*Nenr[2] + DNenr(2,1)*cH8; +H(2,14)=DN(3,2)*Nenr[2] + DNenr(2,2)*cH8; H(2,15)=cH3*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); -H(3,0)=DN(0,0)*Nenr[3] + DNenr(3,0)*cH4; -H(3,1)=DN(0,1)*Nenr[3] + DNenr(3,1)*cH4; -H(3,2)=DN(0,2)*Nenr[3] + DNenr(3,2)*cH4; +H(3,0)=DN(0,0)*Nenr[3] + DNenr(3,0)*cH5; +H(3,1)=DN(0,1)*Nenr[3] + DNenr(3,1)*cH5; +H(3,2)=DN(0,2)*Nenr[3] + DNenr(3,2)*cH5; H(3,3)=cH3*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); -H(3,4)=DN(1,0)*Nenr[3] + DNenr(3,0)*cH5; -H(3,5)=DN(1,1)*Nenr[3] + DNenr(3,1)*cH5; -H(3,6)=DN(1,2)*Nenr[3] + DNenr(3,2)*cH5; +H(3,4)=DN(1,0)*Nenr[3] + DNenr(3,0)*cH6; +H(3,5)=DN(1,1)*Nenr[3] + DNenr(3,1)*cH6; +H(3,6)=DN(1,2)*Nenr[3] + DNenr(3,2)*cH6; H(3,7)=cH3*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); -H(3,8)=DN(2,0)*Nenr[3] + DNenr(3,0)*cH6; -H(3,9)=DN(2,1)*Nenr[3] + DNenr(3,1)*cH6; -H(3,10)=DN(2,2)*Nenr[3] + DNenr(3,2)*cH6; +H(3,8)=DN(2,0)*Nenr[3] + DNenr(3,0)*cH7; +H(3,9)=DN(2,1)*Nenr[3] + DNenr(3,1)*cH7; +H(3,10)=DN(2,2)*Nenr[3] + DNenr(3,2)*cH7; H(3,11)=cH3*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); -H(3,12)=DN(3,0)*Nenr[3] + DNenr(3,0)*cH7; -H(3,13)=DN(3,1)*Nenr[3] + DNenr(3,1)*cH7; -H(3,14)=DN(3,2)*Nenr[3] + DNenr(3,2)*cH7; +H(3,12)=DN(3,0)*Nenr[3] + DNenr(3,0)*cH8; +H(3,13)=DN(3,1)*Nenr[3] + DNenr(3,1)*cH8; +H(3,14)=DN(3,2)*Nenr[3] + DNenr(3,2)*cH8; H(3,15)=cH3*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); - const double cKee0 = 1.0*1.0/(K_darcy + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1), 2) + pow(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2), 2))*1.0/h); + const double cKee0 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1), 2) + pow(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2), 2))*1.0/h); const double cKee1 = cKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1) + DNenr(0,2)*DNenr(1,2)); const double cKee2 = cKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1) + DNenr(0,2)*DNenr(2,2)); const double cKee3 = cKee0*(DNenr(0,0)*DNenr(3,0) + DNenr(0,1)*DNenr(3,1) + DNenr(0,2)*DNenr(3,2)); @@ -2009,10 +1909,10 @@ const double crhs_ee18 = N[3]*crhs_ee14; const double crhs_ee19 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); const double crhs_ee20 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); const double crhs_ee21 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); -const double crhs_ee22 = 1.0*1.0/(K_darcy + crhs_ee14*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee11*crhs_ee11 + crhs_ee12*crhs_ee12 + crhs_ee13*crhs_ee13)); -const double crhs_ee23 = crhs_ee22*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + DNenr(3,0)*penr[3] + K_darcy*(N[0]*v(0,0) + N[1]*v(1,0) + N[2]*v(2,0) + N[3]*v(3,0)) - rho*(crhs_ee4*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs_ee5*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs_ee6*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)) + rho*(crhs_ee0*crhs_ee11 + crhs_ee10*(v(3,0) - vfrac(3,0)) + crhs_ee12*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs_ee13*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0)) + crhs_ee7*(v(0,0) - vfrac(0,0)) + crhs_ee8*(v(1,0) - vfrac(1,0)) + crhs_ee9*(v(2,0) - vfrac(2,0))) + rho*(crhs_ee15*(vn(0,0) - vnn(0,0)) + crhs_ee16*(vn(1,0) - vnn(1,0)) + crhs_ee17*(vn(2,0) - vnn(2,0)) + crhs_ee18*(vn(3,0) - vnn(3,0)) + crhs_ee19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs_ee20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs_ee21*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)))); -const double crhs_ee24 = crhs_ee22*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + DNenr(3,1)*penr[3] + K_darcy*(N[0]*v(0,1) + N[1]*v(1,1) + N[2]*v(2,1) + N[3]*v(3,1)) - rho*(crhs_ee4*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs_ee5*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs_ee6*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)) + rho*(crhs_ee1*crhs_ee12 + crhs_ee10*(v(3,1) - vfrac(3,1)) + crhs_ee11*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs_ee13*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1)) + crhs_ee7*(v(0,1) - vfrac(0,1)) + crhs_ee8*(v(1,1) - vfrac(1,1)) + crhs_ee9*(v(2,1) - vfrac(2,1))) + rho*(crhs_ee15*(vn(0,1) - vnn(0,1)) + crhs_ee16*(vn(1,1) - vnn(1,1)) + crhs_ee17*(vn(2,1) - vnn(2,1)) + crhs_ee18*(vn(3,1) - vnn(3,1)) + crhs_ee19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs_ee20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs_ee21*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)))); -const double crhs_ee25 = crhs_ee22*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] + DNenr(0,2)*penr[0] + DNenr(1,2)*penr[1] + DNenr(2,2)*penr[2] + DNenr(3,2)*penr[3] + K_darcy*(N[0]*v(0,2) + N[1]*v(1,2) + N[2]*v(2,2) + N[3]*v(3,2)) - rho*(crhs_ee4*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs_ee5*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs_ee6*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))) - rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)) + rho*(crhs_ee10*(v(3,2) - vfrac(3,2)) + crhs_ee11*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs_ee12*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs_ee13*crhs_ee2 + crhs_ee7*(v(0,2) - vfrac(0,2)) + crhs_ee8*(v(1,2) - vfrac(1,2)) + crhs_ee9*(v(2,2) - vfrac(2,2))) + rho*(crhs_ee15*(vn(0,2) - vnn(0,2)) + crhs_ee16*(vn(1,2) - vnn(1,2)) + crhs_ee17*(vn(2,2) - vnn(2,2)) + crhs_ee18*(vn(3,2) - vnn(3,2)) + crhs_ee19*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs_ee20*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs_ee21*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)))); +const double crhs_ee22 = 1.0*1.0/(crhs_ee14*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee11*crhs_ee11 + crhs_ee12*crhs_ee12 + crhs_ee13*crhs_ee13)); +const double crhs_ee23 = crhs_ee22*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + DNenr(3,0)*penr[3] - rho*(crhs_ee4*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs_ee5*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs_ee6*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)) + rho*(crhs_ee0*crhs_ee11 + crhs_ee10*(v(3,0) - vfrac(3,0)) + crhs_ee12*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs_ee13*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0)) + crhs_ee7*(v(0,0) - vfrac(0,0)) + crhs_ee8*(v(1,0) - vfrac(1,0)) + crhs_ee9*(v(2,0) - vfrac(2,0))) + rho*(crhs_ee15*(vn(0,0) - vnn(0,0)) + crhs_ee16*(vn(1,0) - vnn(1,0)) + crhs_ee17*(vn(2,0) - vnn(2,0)) + crhs_ee18*(vn(3,0) - vnn(3,0)) + crhs_ee19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs_ee20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs_ee21*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)))); +const double crhs_ee24 = crhs_ee22*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + DNenr(3,1)*penr[3] - rho*(crhs_ee4*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs_ee5*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs_ee6*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)) + rho*(crhs_ee1*crhs_ee12 + crhs_ee10*(v(3,1) - vfrac(3,1)) + crhs_ee11*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs_ee13*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1)) + crhs_ee7*(v(0,1) - vfrac(0,1)) + crhs_ee8*(v(1,1) - vfrac(1,1)) + crhs_ee9*(v(2,1) - vfrac(2,1))) + rho*(crhs_ee15*(vn(0,1) - vnn(0,1)) + crhs_ee16*(vn(1,1) - vnn(1,1)) + crhs_ee17*(vn(2,1) - vnn(2,1)) + crhs_ee18*(vn(3,1) - vnn(3,1)) + crhs_ee19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs_ee20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs_ee21*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)))); +const double crhs_ee25 = crhs_ee22*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] + DNenr(0,2)*penr[0] + DNenr(1,2)*penr[1] + DNenr(2,2)*penr[2] + DNenr(3,2)*penr[3] - rho*(crhs_ee4*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs_ee5*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs_ee6*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))) - rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)) + rho*(crhs_ee10*(v(3,2) - vfrac(3,2)) + crhs_ee11*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs_ee12*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs_ee13*crhs_ee2 + crhs_ee7*(v(0,2) - vfrac(0,2)) + crhs_ee8*(v(1,2) - vfrac(1,2)) + crhs_ee9*(v(2,2) - vfrac(2,2))) + rho*(crhs_ee15*(vn(0,2) - vnn(0,2)) + crhs_ee16*(vn(1,2) - vnn(1,2)) + crhs_ee17*(vn(2,2) - vnn(2,2)) + crhs_ee18*(vn(3,2) - vnn(3,2)) + crhs_ee19*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs_ee20*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs_ee21*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)))); rhs_ee[0]=-DNenr(0,0)*crhs_ee23 - DNenr(0,1)*crhs_ee24 - DNenr(0,2)*crhs_ee25 - Nenr[0]*crhs_ee3; rhs_ee[1]=-DNenr(1,0)*crhs_ee23 - DNenr(1,1)*crhs_ee24 - DNenr(1,2)*crhs_ee25 - Nenr[1]*crhs_ee3; rhs_ee[2]=-DNenr(2,0)*crhs_ee23 - DNenr(2,1)*crhs_ee24 - DNenr(2,2)*crhs_ee25 - Nenr[2]*crhs_ee3; diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h index 010c71d0447f..159eef5f1a70 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h @@ -8,19 +8,15 @@ // Kratos default license: kratos/license.txt // // Main author: Uxue Chasco -// Co-authors: Ruben Zorrilla + // #pragma once -#define KRATOS_TWO_FLUID_NAVIER_STOKES_FRACTIONAL // System includes // Project includes -#include "includes/define.h" -#include "includes/element.h" #include "includes/variables.h" -#include "includes/serializer.h" #include "includes/cfd_variables.h" #include "custom_elements/fluid_element.h" #include "custom_utilities/fluid_element_utilities.h" @@ -64,455 +60,466 @@ namespace Kratos ///@name Kratos Classes ///@{ - template - class TwoFluidNavierStokesFractional : public FluidElement - { - public: - /// Counted pointer of - KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractional); - - ///@name Type Definitions - ///@{ - - typedef Node NodeType; - typedef Geometry GeometryType; - typedef Geometry::PointsArrayType NodesArrayType; - typedef Vector VectorType; - typedef Matrix MatrixType; - typedef std::size_t IndexType; - typedef std::size_t SizeType; - typedef std::vector EquationIdVectorType; - typedef std::vector::Pointer> DofsVectorType; - typedef PointerVectorSet, IndexedObject> DofsArrayType; - typedef typename FluidElement::ShapeFunctionsType ShapeFunctionsType; - typedef typename FluidElement::ShapeFunctionDerivativesType ShapeFunctionDerivativesType; - typedef typename FluidElement::ShapeFunctionDerivativesArrayType ShapeFunctionDerivativesArrayType; - constexpr static unsigned int Dim = FluidElement::Dim; - constexpr static unsigned int NumNodes = FluidElement::NumNodes; - constexpr static unsigned int BlockSize = FluidElement::BlockSize; - constexpr static unsigned int LocalSize = FluidElement::LocalSize; - constexpr static unsigned int StrainSize = (Dim - 1) * 3; - - ///@} - ///@name Life Cycle - ///@{ - - /// Default constuctor. - /** - * @param NewId Index number of the new element (optional) - */ - TwoFluidNavierStokesFractional(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 - */ - TwoFluidNavierStokesFractional(IndexType NewId, const NodesArrayType &ThisNodes); - - /// Constructor using a geometry object. - /** - * @param NewId Index of the new element - * @param pGeometry Pointer to a geometry object - */ - TwoFluidNavierStokesFractional(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 - */ - TwoFluidNavierStokesFractional(IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties); - - /// Destructor. - virtual ~TwoFluidNavierStokesFractional(); - - ///@} - ///@name Operators - ///@{ - - ///@} - ///@name Operations - ///@{ - - /// Create a new element of this type - /** - * Returns a pointer to a new TwoFluidNavierStokesFractional element, created using given input. - * @param NewId the ID of the new element - * @param ThisNodes the nodes of the new element - * @param pProperties the properties assigned to the new element - * @return a Pointer to the new element - */ - Element::Pointer Create(IndexType NewId, - NodesArrayType const &ThisNodes, - Properties::Pointer pProperties) const override; - - /// Create a new element of this type using given geometry - /** - * Returns a pointer to a new FluidElement element, created using given input. - * @param NewId the ID of the new element - * @param pGeom a pointer to the geomerty to be used to create the element - * @param pProperties the properties assigned to the new element - * @return a Pointer to the new element - */ - Element::Pointer Create(IndexType NewId, - GeometryType::Pointer pGeom, - Properties::Pointer pProperties) const override; - - /// Computes the elemental LHS and RHS elemental contributions - /** - * Given a distance function, computes the time integrated Left Hand Side (LHS) - * and Right Hand Side elemental contributions for the two-fluid element. - * @param rLeftHandSideMatrix elemental stiffness matrix - * @param rRightHandSideVector elemental residual vector - * @param rCurrentProcessInfo reference to the current process info - */ - void CalculateLocalSystem( - MatrixType &rLeftHandSideMatrix, - VectorType &rRightHandSideVector, - const ProcessInfo &rCurrentProcessInfo) override; - - /// Computes the elemental RHS elemental contribution - /** - * Given a distance function, computes the time integrated Right Hand Side (RHS) - * elemental contribution for the two-fluid element. - * @param rRightHandSideVector elemental residual vector - * @param rCurrentProcessInfo reference to the current process info - */ - void CalculateRightHandSide( - VectorType &rRightHandSideVector, - const ProcessInfo &rCurrentProcessInfo) override; - - /// Auxiliar element check function - /** - * This function calls the base element check method and adds the - * current element check implementations - * @param rCurrentProcessInfo reference to the current process info - */ - int Check(const ProcessInfo &rCurrentProcessInfo) const override; - - ///@} - ///@name Inquiry - ///@{ - - ///@} - ///@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; - - ///@} - ///@name Access - ///@{ - - ///@} - ///@name Inquiry - ///@{ - - ///@} - ///@name Input and output - ///@{ - - /// Function to visualize the divergence field - - /** - * @brief Get the Value On Integration Points object (used to visualize the divergence field) - * - * @param rVariable Variable to be retrieved (implementation supports DIVERGENCE) - * @param rValues Vector for the values at the Gauss integration points - * @param rCurrentProcessInfo ProcessInfo object - */ - void CalculateOnIntegrationPoints( - const Variable &rVariable, - std::vector &rValues, - const ProcessInfo &rCurrentProcessInfo) override; - - ///@} - ///@name Friends - ///@{ - - ///@} - protected: - ///@name Protected static Member Variables - ///@{ - - ///@} - ///@name Protected member Variables - ///@{ - - ///@} - ///@name Protected Operators - ///@{ - - ///@} - ///@name Protected Operations - ///@{ - - /** - * @brief Computes time integrated LHS and RHS arrays - * This method computes both the Left Hand Side and - * Right Hand Side time integrated contributions. - * @param rData Reference to the element data container - * @param rLHS Reference to the Left Hand Side matrix to be filled - * @param rRHS Reference to the Right Hand Side vector to be filled - */ - void AddTimeIntegratedSystem( - TElementData &rData, - MatrixType &rLHS, - VectorType &rRHS) override; - - /** - * @brief Computes the time integrated LHS matrix - * This method computes the Left Hand Side time integrated contribution - * @param rData Reference to the element data container - * @param rLHS Reference to the Left Hand Side matrix to be filled - */ - void AddTimeIntegratedLHS( - TElementData &rData, - MatrixType &rLHS) override; - - /** - * @brief Computes the time integrated RHS vector - * This method computes the Right Hand Side time integrated contribution - * @param rData Reference to the element data container - * @param rRHS Reference to the Right Hand Side matrix to be filled - */ - void AddTimeIntegratedRHS( - TElementData &rData, - VectorType &rRHS) override; - - /** - * @brief Computes the LHS Gauss pt. contribution - * This method computes the contribution to the LHS of a Gauss pt. - * @param rData Reference to the element data container - * @param rLHS Reference to the Left Hand Side matrix to be filled - */ - virtual void ComputeGaussPointLHSContribution( - TElementData &rData, - MatrixType &rLHS); - - /** - * @brief Computes the RHS Gaus pt. contribution - * This method computes the contribution to the RHS of a Gauss pt. - * @param rData Reference to the element data container - * @param rRHS Reference to the Right Hand Side vector to be filled - */ - virtual void ComputeGaussPointRHSContribution( - TElementData &rData, - VectorType &rRHS); - - /** - * @brief Computes the pressure enrichment contributions - * This method computes the pressure enrichment contributions for - * a Gauss pt. in both the left hand side and righ hand side of the equations. - * @param rData Reference to the element data container - * @param rV Contribution related to the pressure enrichment DOFs in the N-S standard equations - * @param rH Contribution related to the standard velocity and pressure DOFs in the enrichment equations - * @param rKee Contribution related to the pressure enrichment DOFs in the enrichment equations - * @param rRHS_ee Right Hand Side of the enrichment equations - */ - virtual void ComputeGaussPointEnrichmentContributions( - TElementData &rData, - MatrixType &rV, - MatrixType &rH, - MatrixType &rKee, - VectorType &rRHS_ee); - - /// Set up the element's data and constitutive law for the current integration point. - /** @param[in/out] rData Container for the current element's data. - * @param[in] Weight Integration point weight. - * @param[in] rN Values of nodal shape functions at the integration point. - * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. - */ - void UpdateIntegrationPointData( - TElementData &rData, - unsigned int IntegrationPointIndex, - double Weight, - const typename TElementData::MatrixRowType &rN, - const typename TElementData::ShapeDerivativesType &rDN_DX) const override; - - /// Set up the element's data for a cut element and constitutive law for the current integration point. - /** @param[in/out] rData Container for the current element's data. - * @param[in] Weight Integration point weight. - * @param[in] rN Values of nodal shape functions at the integration point. - * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. - * @param[in] rNenr Values of nodal enriched shape functions at the integration point. - * @param[in] rDN_DXenr Values of nodal enriched shape functions gradients at the integration point. - */ - void UpdateIntegrationPointData( - TElementData &rData, - unsigned int IntegrationPointIndex, - double Weight, - const typename TElementData::MatrixRowType &rN, - const typename TElementData::ShapeDerivativesType &rDN_DX, - const typename TElementData::MatrixRowType &rNenr, - const typename TElementData::ShapeDerivativesType &rDN_DXenr) const; - - /** - * @brief Calculate the strain rate - * In this function we calculate the strain rate at the mid step - * @param rData Data container with the input velocity and gradients and output strain rate vector - */ - void CalculateStrainRate(TElementData &rData) const override; - - ///@} - ///@name Protected Access - ///@{ - - ///@} - ///@name Protected Inquiry - ///@{ - - ///@} - ///@name Protected LifeCycle - ///@{ - - ///@} - ///@name Static Member Variables - ///@{ - - ///@} - ///@name Member Variables - ///@{ - - ///@} - ///@name Serialization - ///@{ - - friend class Serializer; - - void save(Serializer &rSerializer) const override; - - void load(Serializer &rSerializer) override; - - ///@} - private: - ///@name Private Operations - ///@{ - - /** - * @brief Split shape functions computation auxiliar method - * This method computes the standard and enrichment shape functions for a split element - * @param rData Element data container - * @param rShapeFunctionsPos Positive side shape functions values - * @param rShapeFunctionsNeg Negative side shape functions values - * @param rEnrichedShapeFunctionsPos Positive side enrichment shape functions values - * @param rEnrichedShapeFunctionsNeg Negative side enrichment shape functions values - * @param rShapeDerivativesPos Positive side shape functions derivatives values - * @param rShapeDerivativesNeg Negative side shape functions derivatives values - * @param rEnrichedShapeDerivativesPos Positive side enrichment shape functions derivatives values - * @param rEnrichedShapeDerivativesNeg Negative side enrichment shape functions derivatives values - * @param pModifiedShapeFunctions Pointer to the element splitting utility - */ - void ComputeSplitting( - TElementData &rData, - MatrixType &rShapeFunctionsPos, - MatrixType &rShapeFunctionsNeg, - MatrixType &rEnrichedShapeFunctionsPos, - MatrixType &rEnrichedShapeFunctionsNeg, - GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesPos, - GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesNeg, - GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesPos, - GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesNeg, - ModifiedShapeFunctions::Pointer pModifiedShapeFunctions); - - /** - * @brief This method computes the standard and enrichment shape functions for the interfaces - * @param rData Element data container - * @param rInterfaceShapeFunctionNeg Negative side shape functions at the interface-gauss-points - * @param rEnrInterfaceShapeFunctionPos Enriched shape functions at the interface-gauss-points Positive side - * @param rEnrInterfaceShapeFunctionNeg Enriched shape functions at the interface-gauss-points Negative side - * @param rInterfaceShapeDerivativesNeg Negative side shape functions derivatives at the interface-gauss-points - * @param rInterfaceWeightsNeg Negative side weights for the interface-gauss-points - * @param rInterfaceNormalsNeg Negative side normal vectors for the interface-gauss-points - * @param pModifiedShapeFunctions Pointer to the element splitting utility - */ - void ComputeSplitInterface( - const TElementData &rData, - MatrixType &rInterfaceShapeFunctionNeg, - MatrixType &rEnrInterfaceShapeFunctionPos, - MatrixType &rEnrInterfaceShapeFunctionNeg, - GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivativesNeg, - Vector &rInterfaceWeightsNeg, - std::vector> &rInterfaceNormalsNeg, - ModifiedShapeFunctions::Pointer pModifiedShapeFunctions); - - /** - * @brief This function returns the ModifiedShapeFunctions object according to TDim - * @param pGeometry Pointer to the element geometry - * @param rDistances Distance at the nodes - */ - ModifiedShapeFunctions::UniquePointer pGetModifiedShapeFunctionsUtility( - const GeometryType::Pointer pGeometry, - const Vector &rDistances); - /** - * @brief Condense the enrichment - * This method performs the static condensation of the enrichment terms, by adding - * its local contributions to both the LHS and RHS elemental matrices. - * @param rData Element data container - * @param rLeftHandSideMatrix Reference to the element Left Hand Side matrix - * @param rRightHandSideVector Reference to the element Right Hand Side vector - * @param rVTot Common N-S equations term associated to pressure enrichment DOFs - * @param rHTot Pressure enrichment contribution related to velocity and pressure DOFs - * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs - * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs - */ - void CondenseEnrichmentWithContinuity( - const TElementData &rData, - Matrix &rLeftHandSideMatrix, - VectorType &rRightHandSideVector, - const MatrixType &rVTot, - const MatrixType &rHTot, - MatrixType &rKeeTot, - const VectorType &rRHSeeTot); - - /** - * @brief Condense the enrichment without penalty - * This method performs the static condensation of the enrichment terms, by adding - * its local contributions to both the LHS and RHS elemental matrices. - * Pressure continuity along cut edges is not penalized in this function - * Volume ratio is not checked in this function - * @param rLeftHandSideMatrix Reference to the element Left Hand Side matrix - * @param rRightHandSideVector Reference to the element Right Hand Side vector - * @param rVTot Common N-S equations term associated to pressure enrichment DOFs - * @param rHTot Pressure enrichment contribution related to velocity and pressure DOFs - * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs - * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs - */ - void CondenseEnrichment( - Matrix &rLeftHandSideMatrix, - VectorType &rRightHandSideVector, - const MatrixType &rVTot, - const MatrixType &rHTot, - MatrixType &rKeeTot, - const VectorType &rRHSeeTot); - - ///@} - ///@name Private Access - ///@{ - - ///@} - ///@name Private Inquiry - ///@{ - - ///@} - ///@name Un accessible methods - ///@{ - - /// Assignment operator. - TwoFluidNavierStokesFractional &operator=(TwoFluidNavierStokesFractional const &rOther); - - /// Copy constructor. - TwoFluidNavierStokesFractional(TwoFluidNavierStokesFractional const &rOther); - - ///@} +template +class TwoFluidNavierStokesFractional : public FluidElement +{ +public: + /// Counted pointer of + KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractional); + + ///@name Type Definitions + ///@{ + + typedef Node NodeType; + typedef Geometry GeometryType; + typedef Geometry::PointsArrayType NodesArrayType; + typedef Vector VectorType; + typedef Matrix MatrixType; + typedef std::size_t IndexType; + typedef std::size_t SizeType; + typedef std::vector EquationIdVectorType; + typedef std::vector::Pointer> DofsVectorType; + typedef PointerVectorSet, IndexedObject> DofsArrayType; + typedef typename FluidElement::ShapeFunctionsType ShapeFunctionsType; + typedef typename FluidElement::ShapeFunctionDerivativesType ShapeFunctionDerivativesType; + typedef typename FluidElement::ShapeFunctionDerivativesArrayType ShapeFunctionDerivativesArrayType; + constexpr static unsigned int Dim = FluidElement::Dim; + constexpr static unsigned int NumNodes = FluidElement::NumNodes; + constexpr static unsigned int BlockSize = FluidElement::BlockSize; + constexpr static unsigned int LocalSize = FluidElement::LocalSize; + constexpr static unsigned int StrainSize = (Dim - 1) * 3; + + ///@} + ///@name Life Cycle + ///@{ + + /// Default constuctor. + /** + * @param NewId Index number of the new element (optional) + */ + TwoFluidNavierStokesFractional(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 + */ + TwoFluidNavierStokesFractional( + IndexType NewId, + const NodesArrayType &ThisNodes); + + /// Constructor using a geometry object. + /** + * @param NewId Index of the new element + * @param pGeometry Pointer to a geometry object + */ + TwoFluidNavierStokesFractional( + 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 + */ + TwoFluidNavierStokesFractional( + IndexType NewId, + GeometryType::Pointer pGeometry, + Properties::Pointer pProperties); + + /// Destructor. + virtual ~TwoFluidNavierStokesFractional(); + + ///@} + ///@name Operators + ///@{ + + ///@} + ///@name Operations + ///@{ + + /// Create a new element of this type + /** + * Returns a pointer to a new TwoFluidNavierStokesFractional element, created using given input. + * @param NewId the ID of the new element + * @param ThisNodes the nodes of the new element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create(IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const override; + + /// Create a new element of this type using given geometry + /** + * Returns a pointer to a new FluidElement element, created using given input. + * @param NewId the ID of the new element + * @param pGeom a pointer to the geomerty to be used to create the element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create(IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const override; + + /// Computes the elemental LHS and RHS elemental contributions + /** + * Given a distance function, computes the time integrated Left Hand Side (LHS) + * and Right Hand Side elemental contributions for the two-fluid element. + * @param rLeftHandSideMatrix elemental stiffness matrix + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) override; + + /// Computes the elemental RHS elemental contribution + /** + * Given a distance function, computes the time integrated Right Hand Side (RHS) + * elemental contribution for the two-fluid element. + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateRightHandSide( + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) override; + + /// Auxiliar element check function + /** + * This function calls the base element check method and adds the + * current element check implementations + * @param rCurrentProcessInfo reference to the current process info + */ + int Check(const ProcessInfo &rCurrentProcessInfo) const override; + + ///@} + ///@name Inquiry + ///@{ + + ///@} + ///@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; + + ///@} + ///@name Access + ///@{ + + ///@} + ///@name Inquiry + ///@{ + + ///@} + ///@name Input and output + ///@{ + + /// Function to visualize the divergence field + + /** + * @brief Get the Value On Integration Points object (used to visualize the divergence field) + * + * @param rVariable Variable to be retrieved (implementation supports DIVERGENCE) + * @param rValues Vector for the values at the Gauss integration points + * @param rCurrentProcessInfo ProcessInfo object + */ + void CalculateOnIntegrationPoints( + const Variable &rVariable, + std::vector &rValues, + const ProcessInfo &rCurrentProcessInfo) override; + + ///@} + ///@name Friends + ///@{ + + ///@} +protected: + ///@name Protected static Member Variables + ///@{ + + ///@} + ///@name Protected member Variables + ///@{ + + ///@} + ///@name Protected Operators + ///@{ + + ///@} + ///@name Protected Operations + ///@{ + + /** + * @brief Computes time integrated LHS and RHS arrays + * This method computes both the Left Hand Side and + * Right Hand Side time integrated contributions. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + void AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) override; + + /** + * @brief Computes the time integrated LHS matrix + * This method computes the Left Hand Side time integrated contribution + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + */ + void AddTimeIntegratedLHS( + TElementData &rData, + MatrixType &rLHS) override; + + /** + * @brief Computes the time integrated RHS vector + * This method computes the Right Hand Side time integrated contribution + * @param rData Reference to the element data container + * @param rRHS Reference to the Right Hand Side matrix to be filled + */ + void AddTimeIntegratedRHS( + TElementData &rData, + VectorType &rRHS) override; + + /** + * @brief Computes the LHS Gauss pt. contribution + * This method computes the contribution to the LHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + */ + virtual void ComputeGaussPointLHSContribution( + TElementData &rData, + MatrixType &rLHS); + + /** + * @brief Computes the RHS Gaus pt. contribution + * This method computes the contribution to the RHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + virtual void ComputeGaussPointRHSContribution( + TElementData &rData, + VectorType &rRHS); + + /** + * @brief Computes the pressure enrichment contributions + * This method computes the pressure enrichment contributions for + * a Gauss pt. in both the left hand side and righ hand side of the equations. + * @param rData Reference to the element data container + * @param rV Contribution related to the pressure enrichment DOFs in the N-S standard equations + * @param rH Contribution related to the standard velocity and pressure DOFs in the enrichment equations + * @param rKee Contribution related to the pressure enrichment DOFs in the enrichment equations + * @param rRHS_ee Right Hand Side of the enrichment equations + */ + virtual void ComputeGaussPointEnrichmentContributions( + TElementData &rData, + MatrixType &rV, + MatrixType &rH, + MatrixType &rKee, + VectorType &rRHS_ee); + + /// Set up the element's data and constitutive law for the current integration point. + /** @param[in/out] rData Container for the current element's data. + * @param[in] Weight Integration point weight. + * @param[in] rN Values of nodal shape functions at the integration point. + * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. + */ + void UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const override; + + /// Set up the element's data for a cut element and constitutive law for the current integration point. + /** @param[in/out] rData Container for the current element's data. + * @param[in] Weight Integration point weight. + * @param[in] rN Values of nodal shape functions at the integration point. + * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. + * @param[in] rNenr Values of nodal enriched shape functions at the integration point. + * @param[in] rDN_DXenr Values of nodal enriched shape functions gradients at the integration point. + */ + void UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX, + const typename TElementData::MatrixRowType &rNenr, + const typename TElementData::ShapeDerivativesType &rDN_DXenr) const; + + /** + * @brief Calculate the strain rate + * In this function we calculate the strain rate at the mid step + * @param rData Data container with the input velocity and gradients and output strain rate vector + */ + void CalculateStrainRate(TElementData &rData) const override; + + ///@} + ///@name Protected Access + ///@{ + + ///@} + ///@name Protected Inquiry + ///@{ + + ///@} + ///@name Protected LifeCycle + ///@{ + + ///@} + ///@name Static Member Variables + ///@{ + + ///@} + ///@name Member Variables + ///@{ + + ///@} + ///@name Serialization + ///@{ + + friend class Serializer; + + void save(Serializer &rSerializer) const override; + + void load(Serializer &rSerializer) override; + + ///@} +private: + ///@name Static Member Variables + ///@{ + static constexpr double stab_c2 = 2.0; + static constexpr double stab_c1= 4.0; + ///@name Private Operations + ///@{ + + /** + * @brief Split shape functions computation auxiliar method + * This method computes the standard and enrichment shape functions for a split element + * @param rData Element data container + * @param rShapeFunctionsPos Positive side shape functions values + * @param rShapeFunctionsNeg Negative side shape functions values + * @param rEnrichedShapeFunctionsPos Positive side enrichment shape functions values + * @param rEnrichedShapeFunctionsNeg Negative side enrichment shape functions values + * @param rShapeDerivativesPos Positive side shape functions derivatives values + * @param rShapeDerivativesNeg Negative side shape functions derivatives values + * @param rEnrichedShapeDerivativesPos Positive side enrichment shape functions derivatives values + * @param rEnrichedShapeDerivativesNeg Negative side enrichment shape functions derivatives values + * @param pModifiedShapeFunctions Pointer to the element splitting utility + */ + void ComputeSplitting( + TElementData &rData, + MatrixType &rShapeFunctionsPos, + MatrixType &rShapeFunctionsNeg, + MatrixType &rEnrichedShapeFunctionsPos, + MatrixType &rEnrichedShapeFunctionsNeg, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rShapeDerivativesNeg, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesPos, + GeometryType::ShapeFunctionsGradientsType &rEnrichedShapeDerivativesNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions); + + /** + * @brief This method computes the standard and enrichment shape functions for the interfaces + * @param rData Element data container + * @param rInterfaceShapeFunctionNeg Negative side shape functions at the interface-gauss-points + * @param rEnrInterfaceShapeFunctionPos Enriched shape functions at the interface-gauss-points Positive side + * @param rEnrInterfaceShapeFunctionNeg Enriched shape functions at the interface-gauss-points Negative side + * @param rInterfaceShapeDerivativesNeg Negative side shape functions derivatives at the interface-gauss-points + * @param rInterfaceWeightsNeg Negative side weights for the interface-gauss-points + * @param rInterfaceNormalsNeg Negative side normal vectors for the interface-gauss-points + * @param pModifiedShapeFunctions Pointer to the element splitting utility + */ + void ComputeSplitInterface( + const TElementData &rData, + MatrixType &rInterfaceShapeFunctionNeg, + MatrixType &rEnrInterfaceShapeFunctionPos, + MatrixType &rEnrInterfaceShapeFunctionNeg, + GeometryType::ShapeFunctionsGradientsType &rInterfaceShapeDerivativesNeg, + Vector &rInterfaceWeightsNeg, + std::vector> &rInterfaceNormalsNeg, + ModifiedShapeFunctions::Pointer pModifiedShapeFunctions); + + /** + * @brief This function returns the ModifiedShapeFunctions object according to TDim + * @param pGeometry Pointer to the element geometry + * @param rDistances Distance at the nodes + */ + ModifiedShapeFunctions::UniquePointer pGetModifiedShapeFunctionsUtility( + const GeometryType::Pointer pGeometry, + const Vector &rDistances); + /** + * @brief Condense the enrichment + * This method performs the static condensation of the enrichment terms, by adding + * its local contributions to both the LHS and RHS elemental matrices. + * @param rData Element data container + * @param rLeftHandSideMatrix Reference to the element Left Hand Side matrix + * @param rRightHandSideVector Reference to the element Right Hand Side vector + * @param rVTot Common N-S equations term associated to pressure enrichment DOFs + * @param rHTot Pressure enrichment contribution related to velocity and pressure DOFs + * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs + * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs + */ + void CondenseEnrichmentWithContinuity( + const TElementData &rData, + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rVTot, + const MatrixType &rHTot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot); + + /** + * @brief Condense the enrichment without penalty + * This method performs the static condensation of the enrichment terms, by adding + * its local contributions to both the LHS and RHS elemental matrices. + * Pressure continuity along cut edges is not penalized in this function + * Volume ratio is not checked in this function + * @param rLeftHandSideMatrix Reference to the element Left Hand Side matrix + * @param rRightHandSideVector Reference to the element Right Hand Side vector + * @param rVTot Common N-S equations term associated to pressure enrichment DOFs + * @param rHTot Pressure enrichment contribution related to velocity and pressure DOFs + * @param rKeeTot Pressure enrichment contribution related to pressure enrichment DOFs + * @param rRHSeeTot Right Hand Side vector associated to the pressure enrichment DOFs + */ + void CondenseEnrichment( + Matrix &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const MatrixType &rVTot, + const MatrixType &rHTot, + MatrixType &rKeeTot, + const VectorType &rRHSeeTot); + + ///@} + ///@name Private Access + ///@{ + + ///@} + ///@name Private Inquiry + ///@{ + + ///@} + ///@name Un accessible methods + ///@{ + + /// Assignment operator. + TwoFluidNavierStokesFractional &operator=(TwoFluidNavierStokesFractional const &rOther); + + /// Copy constructor. + TwoFluidNavierStokesFractional(TwoFluidNavierStokesFractional const &rOther); + + ///@} }; // Class TwoFluidNavierStokesFractional ///@name Type Definitions diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp index 6decdb52b354..7827a6263c59 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp @@ -176,7 +176,7 @@ namespace Kratos const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vmesh = rData.MeshVelocity; const auto &vconv = vfrac-vmesh; @@ -272,7 +272,7 @@ lhs(5,5)=clhs29; const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vmesh = rData.MeshVelocity; const auto &vconv = vfrac - vmesh; @@ -494,64 +494,58 @@ lhs(11,11)=clhs45; const double bdf1 = rData.bdf1; const double bdf2 = rData.bdf2; const double dyn_tau = rData.DynamicTau; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vmesh = rData.MeshVelocity; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vconv = vfrac - vmesh; // Get shape function values const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - auto &rhs = rData.rhs; - const double crhs0 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs1 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs2 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs3 = crhs0 + crhs1 + crhs2; -const double crhs4 = 1.0/dt; -const double crhs5 = N[0]*crhs4; -const double crhs6 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)); -const double crhs7 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); -const double crhs8 = crhs7*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)); -const double crhs9 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); -const double crhs10 = crhs9*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); -const double crhs11 = crhs10 + crhs8; -const double crhs12 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double crhs13 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double crhs14 = crhs12*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs13*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); -const double crhs15 = -crhs0*crhs4 - crhs1*crhs4 - crhs10 + crhs14 - crhs2*crhs4 + crhs6 - crhs8; -const double crhs16 = 1.0*1.0/(crhs4*dyn_tau + stab_c2*1.0/h*sqrt(crhs12*crhs12 + crhs13*crhs13)); -const double crhs17 = crhs16*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); -const double crhs18 = N[0]*crhs17; -const double crhs19 = crhs16*(DN(0,0)*crhs12 + DN(0,1)*crhs13); -const double crhs20 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs21 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs22 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs23 = crhs20 + crhs21 + crhs22; -const double crhs24 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)); -const double crhs25 = crhs7*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)); -const double crhs26 = crhs9*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); + const double crhs0 = 1.0/dt; +const double crhs1 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs2 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs3 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs4 = crhs1 + crhs2 + crhs3; +const double crhs5 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)); +const double crhs6 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crhs7 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crhs8 = crhs6*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs7*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); +const double crhs9 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crhs10 = crhs9*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)); +const double crhs11 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crhs12 = crhs11*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crhs13 = crhs10 + crhs12; +const double crhs14 = -crhs0*crhs1 - crhs0*crhs2 - crhs0*crhs3 - crhs10 - crhs12 + crhs5 + crhs8; +const double crhs15 = 1.0*1.0/(crhs0*dyn_tau + stab_c2*1.0/h*sqrt(crhs6*crhs6 + crhs7*crhs7)); +const double crhs16 = crhs15*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crhs17 = N[0]*crhs16; +const double crhs18 = crhs15*(DN(0,0)*crhs6 + DN(0,1)*crhs7); +const double crhs19 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs20 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs21 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs22 = crhs19 + crhs20 + crhs21; +const double crhs23 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)); +const double crhs24 = crhs6*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs7*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); +const double crhs25 = crhs9*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)); +const double crhs26 = crhs11*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); const double crhs27 = crhs25 + crhs26; -const double crhs28 = crhs12*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs13*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); -const double crhs29 = -crhs20*crhs4 - crhs21*crhs4 - crhs22*crhs4 + crhs24 - crhs25 - crhs26 + crhs28; -const double crhs30 = N[1]*crhs4; -const double crhs31 = N[1]*crhs17; -const double crhs32 = crhs16*(DN(1,0)*crhs12 + DN(1,1)*crhs13); -const double crhs33 = N[2]*crhs4; -const double crhs34 = N[2]*crhs17; -const double crhs35 = crhs16*(DN(2,0)*crhs12 + DN(2,1)*crhs13); -rhs[0]=N[0]*crhs11 - N[0]*crhs14 - N[0]*crhs6 - crhs15*crhs18 - crhs15*crhs19 + crhs3*crhs5; -rhs[1]=-N[0]*crhs24 + N[0]*crhs27 - N[0]*crhs28 - crhs18*crhs29 - crhs19*crhs29 + crhs23*crhs5; -rhs[2]=N[1]*crhs11 - N[1]*crhs14 - N[1]*crhs6 - crhs15*crhs31 - crhs15*crhs32 + crhs3*crhs30; -rhs[3]=-N[1]*crhs24 + N[1]*crhs27 - N[1]*crhs28 + crhs23*crhs30 - crhs29*crhs31 - crhs29*crhs32; -rhs[4]=N[2]*crhs11 - N[2]*crhs14 - N[2]*crhs6 - crhs15*crhs34 - crhs15*crhs35 + crhs3*crhs33; -rhs[5]=-N[2]*crhs24 + N[2]*crhs27 - N[2]*crhs28 + crhs23*crhs33 - crhs29*crhs34 - crhs29*crhs35; +const double crhs28 = -crhs0*crhs19 - crhs0*crhs20 - crhs0*crhs21 + crhs23 + crhs24 - crhs25 - crhs26; +const double crhs29 = N[1]*crhs16; +const double crhs30 = crhs15*(DN(1,0)*crhs6 + DN(1,1)*crhs7); +const double crhs31 = N[2]*crhs16; +const double crhs32 = crhs15*(DN(2,0)*crhs6 + DN(2,1)*crhs7); +rhs[0]=N[0]*crhs0*crhs4 + N[0]*crhs13 - N[0]*crhs5 - N[0]*crhs8 - crhs14*crhs17 - crhs14*crhs18; +rhs[1]=N[0]*crhs0*crhs22 - N[0]*crhs23 - N[0]*crhs24 + N[0]*crhs27 - crhs17*crhs28 - crhs18*crhs28; +rhs[2]=N[1]*crhs0*crhs4 + N[1]*crhs13 - N[1]*crhs5 - N[1]*crhs8 - crhs14*crhs29 - crhs14*crhs30; +rhs[3]=N[1]*crhs0*crhs22 - N[1]*crhs23 - N[1]*crhs24 + N[1]*crhs27 - crhs28*crhs29 - crhs28*crhs30; +rhs[4]=N[2]*crhs0*crhs4 + N[2]*crhs13 - N[2]*crhs5 - N[2]*crhs8 - crhs14*crhs31 - crhs14*crhs32; +rhs[5]=N[2]*crhs0*crhs22 - N[2]*crhs23 - N[2]*crhs24 + N[2]*crhs27 - crhs28*crhs31 - crhs28*crhs32; //Add intermediate results to local system. noalias(rRHS) += rhs * rData.Weight; @@ -571,91 +565,83 @@ rhs[5]=-N[2]*crhs24 + N[2]*crhs27 - N[2]*crhs28 + crhs23*crhs33 - crhs29*crhs34 const double bdf1 = rData.bdf1; const double bdf2 = rData.bdf2; const double dyn_tau = rData.DynamicTau; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; - // const auto &vnnn = rData.Velocity_OldStep3; #an_bdf2 + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vconv = vfrac - vmesh; // Get shape function values const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - auto &rhs = rData.rhs; - const double crhs0 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs1 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs2 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs3 = N[3]*(vn(3,0) - vnn(3,0)); -const double crhs4 = crhs0 + crhs1 + crhs2 + crhs3; -const double crhs5 = 1.0/dt; -const double crhs6 = N[0]*crhs5; -const double crhs7 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)) + N[3]*(bdf0*vfrac(3,0) + bdf1*vn(3,0) + bdf2*vnn(3,0)); -const double crhs8 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); -const double crhs9 = crhs8*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)); -const double crhs10 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); -const double crhs11 = crhs10*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)); -const double crhs12 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); -const double crhs13 = crhs12*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); -const double crhs14 = crhs11 + crhs13 + crhs9; -const double crhs15 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double crhs16 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double crhs17 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double crhs18 = crhs15*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs16*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs17*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)); -const double crhs19 = -crhs0*crhs5 - crhs1*crhs5 - crhs11 - crhs13 + crhs18 - crhs2*crhs5 - crhs3*crhs5 + crhs7 - crhs9; -const double crhs20 = 1.0*1.0/(crhs5*dyn_tau + stab_c2*1.0/h*sqrt(crhs15*crhs15 + crhs16*crhs16 + crhs17*crhs17)); -const double crhs21 = crhs20*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); -const double crhs22 = N[0]*crhs21; -const double crhs23 = crhs20*(DN(0,0)*crhs15 + DN(0,1)*crhs16 + DN(0,2)*crhs17); -const double crhs24 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs25 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs26 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs27 = N[3]*(vn(3,1) - vnn(3,1)); -const double crhs28 = crhs24 + crhs25 + crhs26 + crhs27; -const double crhs29 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)) + N[3]*(bdf0*vfrac(3,1) + bdf1*vn(3,1) + bdf2*vnn(3,1)); -const double crhs30 = crhs8*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)); -const double crhs31 = crhs10*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)); -const double crhs32 = crhs12*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); + const double crhs0 = 1.0/dt; +const double crhs1 = N[0]*(vn(0,0) - vnn(0,0)); +const double crhs2 = N[1]*(vn(1,0) - vnn(1,0)); +const double crhs3 = N[2]*(vn(2,0) - vnn(2,0)); +const double crhs4 = N[3]*(vn(3,0) - vnn(3,0)); +const double crhs5 = crhs1 + crhs2 + crhs3 + crhs4; +const double crhs6 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)) + N[3]*(bdf0*vfrac(3,0) + bdf1*vn(3,0) + bdf2*vnn(3,0)); +const double crhs7 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crhs8 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crhs9 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crhs10 = crhs7*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs8*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs9*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)); +const double crhs11 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crhs12 = crhs11*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)); +const double crhs13 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crhs14 = crhs13*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)); +const double crhs15 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crhs16 = crhs15*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crhs17 = crhs12 + crhs14 + crhs16; +const double crhs18 = -crhs0*crhs1 - crhs0*crhs2 - crhs0*crhs3 - crhs0*crhs4 + crhs10 - crhs12 - crhs14 - crhs16 + crhs6; +const double crhs19 = 1.0*1.0/(crhs0*dyn_tau + stab_c2*1.0/h*sqrt(crhs7*crhs7 + crhs8*crhs8 + crhs9*crhs9)); +const double crhs20 = crhs19*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crhs21 = N[0]*crhs20; +const double crhs22 = crhs19*(DN(0,0)*crhs7 + DN(0,1)*crhs8 + DN(0,2)*crhs9); +const double crhs23 = N[0]*(vn(0,1) - vnn(0,1)); +const double crhs24 = N[1]*(vn(1,1) - vnn(1,1)); +const double crhs25 = N[2]*(vn(2,1) - vnn(2,1)); +const double crhs26 = N[3]*(vn(3,1) - vnn(3,1)); +const double crhs27 = crhs23 + crhs24 + crhs25 + crhs26; +const double crhs28 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)) + N[3]*(bdf0*vfrac(3,1) + bdf1*vn(3,1) + bdf2*vnn(3,1)); +const double crhs29 = crhs7*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs8*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs9*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)); +const double crhs30 = crhs11*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)); +const double crhs31 = crhs13*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)); +const double crhs32 = crhs15*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); const double crhs33 = crhs30 + crhs31 + crhs32; -const double crhs34 = crhs15*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs16*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs17*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)); -const double crhs35 = -crhs24*crhs5 - crhs25*crhs5 - crhs26*crhs5 - crhs27*crhs5 + crhs29 - crhs30 - crhs31 - crhs32 + crhs34; -const double crhs36 = N[0]*(vn(0,2) - vnn(0,2)); -const double crhs37 = N[1]*(vn(1,2) - vnn(1,2)); -const double crhs38 = N[2]*(vn(2,2) - vnn(2,2)); -const double crhs39 = N[3]*(vn(3,2) - vnn(3,2)); -const double crhs40 = crhs36 + crhs37 + crhs38 + crhs39; -const double crhs41 = N[0]*(bdf0*vfrac(0,2) + bdf1*vn(0,2) + bdf2*vnn(0,2)) + N[1]*(bdf0*vfrac(1,2) + bdf1*vn(1,2) + bdf2*vnn(1,2)) + N[2]*(bdf0*vfrac(2,2) + bdf1*vn(2,2) + bdf2*vnn(2,2)) + N[3]*(bdf0*vfrac(3,2) + bdf1*vn(3,2) + bdf2*vnn(3,2)); -const double crhs42 = crhs8*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)); -const double crhs43 = crhs10*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)); -const double crhs44 = crhs12*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crhs34 = -crhs0*crhs23 - crhs0*crhs24 - crhs0*crhs25 - crhs0*crhs26 + crhs28 + crhs29 - crhs30 - crhs31 - crhs32; +const double crhs35 = N[0]*(vn(0,2) - vnn(0,2)); +const double crhs36 = N[1]*(vn(1,2) - vnn(1,2)); +const double crhs37 = N[2]*(vn(2,2) - vnn(2,2)); +const double crhs38 = N[3]*(vn(3,2) - vnn(3,2)); +const double crhs39 = crhs35 + crhs36 + crhs37 + crhs38; +const double crhs40 = N[0]*(bdf0*vfrac(0,2) + bdf1*vn(0,2) + bdf2*vnn(0,2)) + N[1]*(bdf0*vfrac(1,2) + bdf1*vn(1,2) + bdf2*vnn(1,2)) + N[2]*(bdf0*vfrac(2,2) + bdf1*vn(2,2) + bdf2*vnn(2,2)) + N[3]*(bdf0*vfrac(3,2) + bdf1*vn(3,2) + bdf2*vnn(3,2)); +const double crhs41 = crhs7*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs8*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs9*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)); +const double crhs42 = crhs11*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)); +const double crhs43 = crhs13*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)); +const double crhs44 = crhs15*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); const double crhs45 = crhs42 + crhs43 + crhs44; -const double crhs46 = crhs15*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs16*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs17*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)); -const double crhs47 = -crhs36*crhs5 - crhs37*crhs5 - crhs38*crhs5 - crhs39*crhs5 + crhs41 - crhs42 - crhs43 - crhs44 + crhs46; -const double crhs48 = N[1]*crhs5; -const double crhs49 = N[1]*crhs21; -const double crhs50 = crhs20*(DN(1,0)*crhs15 + DN(1,1)*crhs16 + DN(1,2)*crhs17); -const double crhs51 = N[2]*crhs5; -const double crhs52 = N[2]*crhs21; -const double crhs53 = crhs20*(DN(2,0)*crhs15 + DN(2,1)*crhs16 + DN(2,2)*crhs17); -const double crhs54 = N[3]*crhs5; -const double crhs55 = N[3]*crhs21; -const double crhs56 = crhs20*(DN(3,0)*crhs15 + DN(3,1)*crhs16 + DN(3,2)*crhs17); -rhs[0]=N[0]*crhs14 - N[0]*crhs18 - N[0]*crhs7 - crhs19*crhs22 - crhs19*crhs23 + crhs4*crhs6; -rhs[1]=-N[0]*crhs29 + N[0]*crhs33 - N[0]*crhs34 - crhs22*crhs35 - crhs23*crhs35 + crhs28*crhs6; -rhs[2]=-N[0]*crhs41 + N[0]*crhs45 - N[0]*crhs46 - crhs22*crhs47 - crhs23*crhs47 + crhs40*crhs6; -rhs[3]=N[1]*crhs14 - N[1]*crhs18 - N[1]*crhs7 - crhs19*crhs49 - crhs19*crhs50 + crhs4*crhs48; -rhs[4]=-N[1]*crhs29 + N[1]*crhs33 - N[1]*crhs34 + crhs28*crhs48 - crhs35*crhs49 - crhs35*crhs50; -rhs[5]=-N[1]*crhs41 + N[1]*crhs45 - N[1]*crhs46 + crhs40*crhs48 - crhs47*crhs49 - crhs47*crhs50; -rhs[6]=N[2]*crhs14 - N[2]*crhs18 - N[2]*crhs7 - crhs19*crhs52 - crhs19*crhs53 + crhs4*crhs51; -rhs[7]=-N[2]*crhs29 + N[2]*crhs33 - N[2]*crhs34 + crhs28*crhs51 - crhs35*crhs52 - crhs35*crhs53; -rhs[8]=-N[2]*crhs41 + N[2]*crhs45 - N[2]*crhs46 + crhs40*crhs51 - crhs47*crhs52 - crhs47*crhs53; -rhs[9]=N[3]*crhs14 - N[3]*crhs18 - N[3]*crhs7 - crhs19*crhs55 - crhs19*crhs56 + crhs4*crhs54; -rhs[10]=-N[3]*crhs29 + N[3]*crhs33 - N[3]*crhs34 + crhs28*crhs54 - crhs35*crhs55 - crhs35*crhs56; -rhs[11]=-N[3]*crhs41 + N[3]*crhs45 - N[3]*crhs46 + crhs40*crhs54 - crhs47*crhs55 - crhs47*crhs56; +const double crhs46 = -crhs0*crhs35 - crhs0*crhs36 - crhs0*crhs37 - crhs0*crhs38 + crhs40 + crhs41 - crhs42 - crhs43 - crhs44; +const double crhs47 = N[1]*crhs20; +const double crhs48 = crhs19*(DN(1,0)*crhs7 + DN(1,1)*crhs8 + DN(1,2)*crhs9); +const double crhs49 = N[2]*crhs20; +const double crhs50 = crhs19*(DN(2,0)*crhs7 + DN(2,1)*crhs8 + DN(2,2)*crhs9); +const double crhs51 = N[3]*crhs20; +const double crhs52 = crhs19*(DN(3,0)*crhs7 + DN(3,1)*crhs8 + DN(3,2)*crhs9); +rhs[0]=N[0]*crhs0*crhs5 - N[0]*crhs10 + N[0]*crhs17 - N[0]*crhs6 - crhs18*crhs21 - crhs18*crhs22; +rhs[1]=N[0]*crhs0*crhs27 - N[0]*crhs28 - N[0]*crhs29 + N[0]*crhs33 - crhs21*crhs34 - crhs22*crhs34; +rhs[2]=N[0]*crhs0*crhs39 - N[0]*crhs40 - N[0]*crhs41 + N[0]*crhs45 - crhs21*crhs46 - crhs22*crhs46; +rhs[3]=N[1]*crhs0*crhs5 - N[1]*crhs10 + N[1]*crhs17 - N[1]*crhs6 - crhs18*crhs47 - crhs18*crhs48; +rhs[4]=N[1]*crhs0*crhs27 - N[1]*crhs28 - N[1]*crhs29 + N[1]*crhs33 - crhs34*crhs47 - crhs34*crhs48; +rhs[5]=N[1]*crhs0*crhs39 - N[1]*crhs40 - N[1]*crhs41 + N[1]*crhs45 - crhs46*crhs47 - crhs46*crhs48; +rhs[6]=N[2]*crhs0*crhs5 - N[2]*crhs10 + N[2]*crhs17 - N[2]*crhs6 - crhs18*crhs49 - crhs18*crhs50; +rhs[7]=N[2]*crhs0*crhs27 - N[2]*crhs28 - N[2]*crhs29 + N[2]*crhs33 - crhs34*crhs49 - crhs34*crhs50; +rhs[8]=N[2]*crhs0*crhs39 - N[2]*crhs40 - N[2]*crhs41 + N[2]*crhs45 - crhs46*crhs49 - crhs46*crhs50; +rhs[9]=N[3]*crhs0*crhs5 - N[3]*crhs10 + N[3]*crhs17 - N[3]*crhs6 - crhs18*crhs51 - crhs18*crhs52; +rhs[10]=N[3]*crhs0*crhs27 - N[3]*crhs28 - N[3]*crhs29 + N[3]*crhs33 - crhs34*crhs51 - crhs34*crhs52; +rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crhs51 - crhs46*crhs52; // Add intermediate results to local system. diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h index 81e578e3af8d..ecf5367ad86c 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h +++ b/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h @@ -13,7 +13,6 @@ // #pragma once -#define KRATOS_VECTORIAL_CONVECTION_FRACTIONAL_ELEMENT // System includes @@ -52,11 +51,6 @@ namespace Kratos ///@} ///@name Kratos Classes ///@{ - namespace Internals - { - template - class FluidElementTimeIntegrationDetail; -} template class VectorialConvectionFractionalElement: public Element { @@ -86,28 +80,35 @@ class VectorialConvectionFractionalElement: public Element * @param NewId Index number of the new element (optional) */ VectorialConvectionFractionalElement(IndexType NewId = 0); - - /// Constructor using an array of nodes. + /** + * @brief Constructor using an array of nodes. * @param NewId Index of the new element * @param ThisNodes An array containing the nodes of the new element */ - VectorialConvectionFractionalElement(IndexType NewId, const NodesArrayType &ThisNodes); + VectorialConvectionFractionalElement( + IndexType NewId, + const NodesArrayType &ThisNodes); - /// Constructor using a geometry object. /** + * @brief Constructor using a geometry object. * @param NewId Index of the new element * @param pGeometry Pointer to a geometry object */ - VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry); + VectorialConvectionFractionalElement( + IndexType NewId, + GeometryType::Pointer pGeometry); - /// Constuctor using geometry and properties. /** + * @brief 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 */ - VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties); + VectorialConvectionFractionalElement( + IndexType NewId, + GeometryType::Pointer pGeometry, + Properties::Pointer pProperties); /// Destructor. virtual ~VectorialConvectionFractionalElement(); @@ -120,33 +121,125 @@ class VectorialConvectionFractionalElement: public Element ///@} ///@name Operations ///@{ + /** + @brief Returns a pointer to a new VectorialConvectionFractionalElement element, created using given input. + * @param NewId the ID of the new element + * @param ThisNodes the nodes of the new element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create( + IndexType NewId, + NodesArrayType const& ThisNodes, + PropertiesType::Pointer pProperties) const override; + + + /** + * @brief Returns a pointer to a new FluidElement element, created using given input. + * @param NewId the ID of the new element + * @param pGeom a pointer to the geomerty to be used to create the element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create( + IndexType NewId, + GeometryType::Pointer pGeom, + PropertiesType::Pointer pProperties) const override; + + /** + * @brief Given a distance function, computes the time integrated Left Hand Side (LHS) + * and Right Hand Side elemental contributions for the two-fluid element. + * @param rLeftHandSideMatrix elemental stiffness matrix + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateLocalSystem( + MatrixType& rLeftHandSideMatrix, + VectorType& rRightHandSideVector, + const ProcessInfo& rCurrentProcessInfo) override; - Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override; - Element::Pointer Create(IndexType NewId,GeometryType::Pointer pGeom,PropertiesType::Pointer pProperties) const override; + /** + * @brief Computes the LHS Gauss pt. contribution + * This method computes the contribution to the LHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + */ + virtual void ComputeGaussPointLHSContribution( + TElementData &rData, + MatrixType &rLHS); + + /** + * @brief Computes the RHS Gaus pt. contribution + * This method computes the contribution to the RHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + virtual void ComputeGaussPointRHSContribution( + TElementData &rData, + VectorType &rRHS); - void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override; - virtual void ComputeGaussPointLHSContribution(TElementData &rData,MatrixType &rLHS); - virtual void ComputeGaussPointRHSContribution(TElementData &rData,VectorType &rRHS); + /** + * @brief Sets on rResult the ID's of the element degrees of freedom + * @param rResult The result vector with the ID's of the DOF + * @param rCurrentProcessInfo the current process info instance + */ + void EquationIdVector( + EquationIdVectorType& rResult, + const ProcessInfo& rCurrentProcessInfo) const override; - void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override; void GetDofList( DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override; + + /** + * @brief Given a distance function, computes the time integrated Right Hand Side (RHS) + * elemental contribution for the two-fluid element. + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ void CalculateRightHandSide( VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override; - virtual void AddTimeIntegratedSystem( + + /** + * @brief Computes time integrated LHS and RHS arrays + * This method computes both the Left Hand Side and + * Right Hand Side time integrated contributions. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + void AddTimeIntegratedSystem( TElementData &rData, MatrixType &rLHS, VectorType &rRHS); - virtual void UpdateIntegrationPointData(TElementData &rData, + + /** + * @brief Set up the element's data and for the current integration point. + * @param[in/out] rData Container for the current element's data. + * @param[in] Weight Integration point weight. + * @param[in] rN Values of nodal shape functions at the integration point. + * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. + */ + void UpdateIntegrationPointData( + TElementData &rData, unsigned int IntegrationPointIndex, double Weight, const typename TElementData::MatrixRowType &rN, const typename TElementData::ShapeDerivativesType &rDN_DX) const; - virtual void CalculateGeometryData(Vector &rGaussWeights, - Matrix &rNContainer, - ShapeFunctionDerivativesArrayType &rDN_DX) const; + + /** + * @brief Computes shape function data for all the gauss points + * + * @param rGaussWeights Gauss point weights + * @param rNContainer Gauss point shape functions (each row corresponds to a specific gauss point) + * @param rDN_DX Gauss point shape function gradients (vector of matrices) + */ + virtual void CalculateGeometryData( + Vector &rGaussWeights, + Matrix &rNContainer, + ShapeFunctionDerivativesArrayType &rDN_DX) const; + ///@} ///@name Access ///@{ @@ -185,48 +278,13 @@ class VectorialConvectionFractionalElement: public Element ///@} - -protected: - ///@name Protected static Member Variables - ///@{ - - - ///@} - ///@name Protected member Variables - ///@{ - - ///@} - ///@name Protected Operators - ///@{ - - ///@} - ///@name Protected Operations - ///@{ - - - ///@} - ///@name Protected Access - ///@{ - - - ///@} - ///@name Protected Inquiry - ///@{ - - - ///@} - ///@name Protected LifeCycle - ///@{ - - - ///@} - - - - + private: ///@name Static Member Variables ///@{ + static constexpr double stab_c2 = 2.0; + static constexpr double stab_c1= 4.0; + ///@} ///@name Member Variables @@ -287,24 +345,6 @@ class VectorialConvectionFractionalElement: public Element ///@} -///@name Input and output -///@{ - -/// input stream function -/* inline std::istream& operator >> (std::istream& rIStream, - Fluid2DASGS& rThis); - */ -/// output stream function -/* inline std::ostream& operator << (std::ostream& rOStream, - const Fluid2DASGS& rThis) - { - rThis.PrintInfo(rOStream); - rOStream << std::endl; - rThis.PrintData(rOStream); - - return rOStream; - }*/ -///@} } // namespace Kratos. diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py index 0efd434ac286..0b066b914ca5 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py @@ -117,7 +117,6 @@ vconv_gauss_norm = sympy.sqrt(vconv_gauss_norm) ## Data interpolation to the Gauss points - K_darcy = sympy.Symbol('K_darcy', positive = True) ## Backward differences coefficients bdf0 = sympy.Symbol('bdf0') bdf1 = sympy.Symbol('bdf1') @@ -127,7 +126,7 @@ v_gauss = v.transpose()*N f_gauss = f.transpose()*N - tau1 = 1.0/((rho*dyn_tau)/dt + (stab_c2*rho*vconv_gauss_norm)/h + (stab_c1*mu)/(h*h) + K_darcy) # Stabilization parameter 1 + tau1 = 1.0/((rho*dyn_tau)/dt + (stab_c2*rho*vconv_gauss_norm)/h + (stab_c1*mu)/(h*h)) # Stabilization parameter 1 tau2 = mu + (stab_c2*rho*vconv_gauss_norm*h)/stab_c1 # Stabilization parameter 2 p_gauss = p.transpose()*N #NOTE: We evaluate p-related terms at n+1 as temporal component makes no sense in this case for both time integration schemes @@ -168,7 +167,6 @@ ## Galerkin Functional rv_galerkin = rho*w_gauss.transpose()*f_gauss - rho*w_gauss.transpose()*accel_gauss -rho*w_gauss.transpose()*convective_term.transpose() - grad_sym_w_voigt.transpose()*stress + div_w*p_gauss + rho*w_gauss.transpose()*convective_frac_term.transpose() - rv_galerkin -= w_gauss.transpose()*K_darcy*v_gauss #Darcy Term if adding_acceleration: # Adding fractional acceleration convective part rv_galerkin -= rho*w_gauss.transpose()*convective_n_term.transpose() @@ -188,8 +186,6 @@ if adding_acceleration: vel_residual -=rho*(accel_gauss_n+convective_n_term.transpose()) - vel_residual-= K_darcy*v_gauss - # Mass conservation residual if (divide_by_rho): mas_residual = -div_v[0,0] + volume_error_ratio @@ -208,7 +204,6 @@ rv_stab += rho*vconv_gauss.transpose()*grad_w*vel_subscale rv_stab += rho*div_vconv*w_gauss.transpose()*vel_subscale rv_stab += div_w*mas_subscale - rv_stab -= w_gauss.transpose()*K_darcy*vel_subscale ## Add the stabilization terms to the original residual terms if (ASGS_stabilization): @@ -250,7 +245,6 @@ if adding_acceleration: vel_residual_enr -= rho*(accel_gauss_n+convective_n_term.transpose()) - vel_residual_enr-= K_darcy*v_gauss vel_subscale_enr = vel_residual_enr * tau1 rv_galerkin_enriched = div_w*penr_gauss @@ -264,7 +258,6 @@ rv_stab_enriched -= rho*grad_q.transpose()*tau1*grad_penr rv_stab_enriched -= rho*vconv_gauss.transpose()*grad_w*tau1*grad_penr - rv_stab_enriched += w_gauss.transpose()*K_darcy*tau1*grad_penr rv_stab_enriched -= rho*div_vconv*w_gauss.transpose()*tau1*grad_penr rv_enriched = rv_galerkin_enriched ## Add the stabilization terms to the original residual terms diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp index 038280c5cfe9..5391d1e1251e 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp @@ -226,7 +226,7 @@ const Parameters TwoFluidNavierStokesFractional::GetSpecifications "nodal_non_historical" : [], "entity" : [] }, - "required_variables" : ["DISTANCE","VELOCITY","PRESSURE","MESH_VELOCITY","DENSITY","DYNAMIC_VISCOSITY"], + "required_variables" : ["DISTANCE","VELOCITY","PRESSURE","MESH_VELOCITY","DENSITY","DYNAMIC_VISCOSITY","FRACTIONAL_VELOCITY"], "required_dofs" : [], "flags_used" : [], "compatible_geometries" : ["Triangle2D3","Tetrahedra3D4"], @@ -315,7 +315,6 @@ void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( rData.CalculateAirMaterialResponse(); else this->CalculateMaterialResponse(rData); - rData.ComputeDarcyTerm(); } template @@ -334,7 +333,6 @@ void TwoFluidNavierStokesFractional::UpdateIntegrationPointData( rData.CalculateAirMaterialResponse(); else this->CalculateMaterialResponse(rData); - rData.ComputeDarcyTerm(); } template <> @@ -344,17 +342,13 @@ void TwoFluidNavierStokesFractional>::C { const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto vn = rData.Velocity_OldStep1; + const auto vn = rData.VelocityOldStep1; const auto vconv = rData.Velocity - rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; // Get constitutive matrix const Matrix &C = rData.C; @@ -363,10 +357,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; //substitute_lhs_2D @@ -383,18 +373,13 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double K_darcy = rData.DarcyTerm; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - - const auto vn=rData.Velocity_OldStep1; + const auto vn=rData.VelocityOldStep1; const auto vconv = rData.Velocity - rData.MeshVelocity; - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; // Get constitutive matrix const Matrix &C = rData.C; @@ -403,10 +388,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; //substitute_lhs_3D @@ -423,24 +404,16 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; - // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible - + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; const auto &stress = rData.ShearStress; @@ -449,10 +422,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -495,18 +464,13 @@ void TwoFluidNavierStokesFractional>::C const double h = rData.ElementSize; const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; - // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible - + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - const auto vfrac = rData.Velocity_Fractional; + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; const auto &stress = rData.ShearStress; @@ -515,10 +479,6 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -562,21 +522,16 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - const auto vfrac = rData.Velocity_Fractional; - + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; @@ -586,10 +541,6 @@ void TwoFluidNavierStokesFractional>::C const auto &Nenr = rData.Nenr; const auto &DNenr = rData.DN_DXenr; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; @@ -646,23 +597,16 @@ void TwoFluidNavierStokesFractional>::C const double rho = rData.Density; const double mu = rData.EffectiveViscosity; - const double h = rData.ElementSize; - const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; - const double dyn_tau = rData.DynamicTau; - const double K_darcy = rData.DarcyTerm; - const auto &v = rData.Velocity; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; const auto &vconv = v - vmesh; - const auto vfrac = rData.Velocity_Fractional; - // const auto &vnnn = rData.Velocity_OldStep3; # an bdf2 possible - + const auto vfrac = rData.FractionalVelocity; const auto &f = rData.BodyForce; const auto &p = rData.Pressure; @@ -672,10 +616,6 @@ void TwoFluidNavierStokesFractional>::C const auto &Nenr = rData.Nenr; const auto &DNenr = rData.DN_DXenr; - // Stabilization parameters - constexpr double stab_c1 = 4.0; - constexpr double stab_c2 = 2.0; - // Mass correction term double volume_error_ratio = 0.0; diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp index 0122bc5e52cd..7851a41e2266 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp @@ -176,7 +176,7 @@ namespace Kratos const double dt = rData.DeltaTime; const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vmesh = rData.MeshVelocity; const auto &vconv = vfrac-vmesh; @@ -206,7 +206,7 @@ namespace Kratos const double bdf0 = rData.bdf0; const double dyn_tau = rData.DynamicTau; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vmesh = rData.MeshVelocity; const auto &vconv = vfrac - vmesh; @@ -238,20 +238,17 @@ namespace Kratos const double bdf1 = rData.bdf1; const double bdf2 = rData.bdf2; const double dyn_tau = rData.DynamicTau; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 const auto &vmesh = rData.MeshVelocity; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vconv = vfrac - vmesh; // Get shape function values const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - auto &rhs = rData.rhs; //substitute_rhs_2D @@ -273,20 +270,16 @@ namespace Kratos const double bdf1 = rData.bdf1; const double bdf2 = rData.bdf2; const double dyn_tau = rData.DynamicTau; - const auto &vn = rData.Velocity_OldStep1; - const auto &vnn = rData.Velocity_OldStep2; - // const auto &vnnn = rData.Velocity_OldStep3; #an_bdf2 + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; const auto &vmesh = rData.MeshVelocity; - const auto &vfrac = rData.Velocity_Fractional; + const auto &vfrac = rData.FractionalVelocity; const auto &vconv = vfrac - vmesh; // Get shape function values const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - auto &rhs = rData.rhs; //substitute_rhs_3D diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index 92a846217b97..6b4e55fe316b 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -60,7 +60,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynami modelPart.AddNodalSolutionStepVariable(DISTANCE); // Process info creation - const int buffer_size = 4; + const int buffer_size = 3; const double delta_time = 0.1; modelPart.SetBufferSize(buffer_size); modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); @@ -135,16 +135,9 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3N, FluidDynami // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + const std::vector rhs_ref = {285.327812743,-75.7286708218,0.678487936315,-758.586246712,-529.046820664,-0.808596445975,-549.320499823,-931.191955616,-0.0198914903401}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); - KRATOS_EXPECT_NEAR(RHS(0), 285.327812743, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),-75.7286708218, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), 0.678487936315, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),-758.586246712, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -529.046820664, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), -0.808596445975, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -549.320499823, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), -931.191955616, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -0.0198914903401, 1e-7); } // /** Checks the TwoFluidNavierStokesFractional3D4N element @@ -156,7 +149,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDyn ModelPart& modelPart = current_model.CreateModelPart("Main"); // Process info creation - const int buffer_size = 4; + const int buffer_size = 3; const double delta_time = 0.1; modelPart.SetBufferSize(buffer_size); modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); @@ -243,25 +236,10 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDyn const auto& r_process_info = modelPart.GetProcessInfo(); pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - std::cout << std::setprecision(12) << RHS << std::endl; // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - KRATOS_EXPECT_NEAR(RHS(0), -182.780712656, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), -5.97373013, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), -366.425812874, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 0.136180451508, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -65.5996318562, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),-195.157657105, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -732.8993499, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), 0.228653068676, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -30.1350973711, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), -309.557107994, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), -744.055344314, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), -0.182507276303, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12), 4.70728308942, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13), -259.815870553, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14), -872.015239241, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15), -0.282326243881, 1e-7); + const std::vector rhs_ref = {-49.6230448446,-5.81518310901,-92.6312642702,0.134427963708,-139.799199585,-195.380881022,-249.006265616,0.0341650889644,-98.6768840265,-309.521310486,-265.871321505,-0.183090855324,-102.401818165,-260.137138577,-354.792467018,-0.0855021973489}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } @@ -274,7 +252,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, ModelPart& modelPart = current_model.CreateModelPart("Main"); // Process info creation - const int buffer_size = 4; + const int buffer_size = 3; const double delta_time = 0.1; modelPart.SetBufferSize(buffer_size); modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); @@ -364,23 +342,8 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),64.3649724019, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2),130.747961753, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),1.82139199133, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4),-173.148878249, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),-263.100173027, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6),-1019.86139378, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7),-0.231551322358, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8),-198.517992416, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9),-320.806050475, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10),-1153.91463291, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11),-0.36014021379, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12),-233.824784725, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13),-357.542877174, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14),-1300.79220817, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15),-1.32970045518 , 1e-7); + const std::vector rhs_ref={55.5608619747,64.3649724019,73.1690828291,0.98042064137,-173.148878249,-263.100173027,-363.46638282,-0.231551322358,-198.517992416,-320.806050475,-422.264278502,-0.36014021379,-233.824784725,-357.542877174,-491.67588464,-0.488729105221}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } // /** Checks the TwoFluidNavierStokesFractional3D4N element @@ -392,7 +355,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, ModelPart& modelPart = current_model.CreateModelPart("Main"); // Process info creation - const int buffer_size = 4; + const int buffer_size = 3; const double delta_time = 0.1; modelPart.SetBufferSize(buffer_size); modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); @@ -483,22 +446,8 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) // std::cout<< std::setprecision(12) << RHS << std::endl; - KRATOS_EXPECT_NEAR(RHS(0),55.5608619747, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), 64.3649724019, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), 130.747961753, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 1.82139199133, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), -173.148878249, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), -263.100173027, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), -1019.86139378, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), -0.231551322358, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), -198.517992416, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), -320.806050475, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), -1153.91463291, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), -0.36014021379, 1e-7); - KRATOS_EXPECT_NEAR(RHS(12), -233.824784725, 1e-7); - KRATOS_EXPECT_NEAR(RHS(13), -357.542877174, 1e-7); - KRATOS_EXPECT_NEAR(RHS(14), -1300.79220817, 1e-7); - KRATOS_EXPECT_NEAR(RHS(15), -1.32970045518, 1e-7); + const std::vector rhs_ref={55.5608619747,64.3649724019,73.1690828291,0.98042064137,-173.148878249,-263.100173027,-363.46638282,-0.231551322358,-198.517992416,-320.806050475,-422.264278502,-0.36014021379,-233.824784725,-357.542877174,-491.67588464,-0.488729105221}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } /** Checks the TwoFluidNavierStokesFractional2D3N element in a hydrostatic case. @@ -511,7 +460,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, ModelPart& modelPart = current_model.CreateModelPart("Main"); // Process info creation - const int buffer_size = 4; + const int buffer_size = 3; const double delta_time = 0.1; modelPart.SetBufferSize(buffer_size); modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); @@ -626,17 +575,9 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. // If the "standard" pressure shape functions are used, the results do not hold. // std::cout<< std::setprecision(12) << RHS << std::endl; - KRATOS_EXPECT_NEAR(RHS(0), 0.0, 1e-7); // U_x at node 1 - KRATOS_EXPECT_NEAR(RHS(1), -17.5, 1e-7); // U_y at node 1 - KRATOS_EXPECT_NEAR(RHS(2), 0.0, 1e-7); // P at node 1 - KRATOS_EXPECT_NEAR(RHS(3), 7.5, 1e-7); // U_x at node 2 - KRATOS_EXPECT_NEAR(RHS(4), 0.0, 1e-7); // U_y at node 2 - KRATOS_EXPECT_NEAR(RHS(5), 0.0, 1e-7); // P at node 2 - - KRATOS_EXPECT_NEAR(RHS(6), -7.5, 1e-7); // U_x at node 3 - KRATOS_EXPECT_NEAR(RHS(7), -7.5, 1e-7); // U_y at node 3 - KRATOS_EXPECT_NEAR(RHS(8), 0.0, 1e-7); // P at node 3 + const std::vector rhs_ref={0.0,-7.48877586059,-1.64822555671,7.48877586059,7.48877586059,1.2364371328,-7.48877586059,0,0.411788423917}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } @@ -748,17 +689,8 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NError, FluidD // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) Vector reference_RHS = ZeroVector(9); - reference_RHS[0] = 6075.49; - reference_RHS[1] = 4684.29; - reference_RHS[2] = -27.713; - reference_RHS[3] = -6671.02; - reference_RHS[4] = 1521.5; - reference_RHS[5] = -16.8578; - reference_RHS[6] = -241.804; - reference_RHS[7] = -4409.55; - reference_RHS[8] = -5.5792; - - KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-2); + const std::vector rhs_ref = {6075.49466849675,4684.29040473282,-27.7130224974724,-6671.02384528602,1521.49790451337,-16.8577767803168,-241.803857305756,-4409.54852590944,-5.57920072221086}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-10); } // /** Checks the TwoFluidNavierStokesFractional3D4N element with a source term in mass conservation equation @@ -871,26 +803,9 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, Flu pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law pElement->CalculateLocalSystem(LHS, RHS, r_process_info); // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - Vector reference_RHS = ZeroVector(16); - reference_RHS[0] = 3885.76546946; - reference_RHS[1] = 2853.252194541; - reference_RHS[2] = 3702.11733421; - reference_RHS[3] = -5.33528927901; - reference_RHS[4] = -4028.74316648; - reference_RHS[5] = 302.056712497; - reference_RHS[6] = -945.707036998; - reference_RHS[7] = -3.93555403796; - reference_RHS[8] = 47.4442472421; - reference_RHS[9] = -3601.67069179; - reference_RHS[10] = -666.474404348; - reference_RHS[11] = -3.04929475341; - reference_RHS[12] = -176.798973004; - reference_RHS[13] = 455.784932702; - reference_RHS[14] = -4803.85305063; - reference_RHS[15] = -4.44652859628; - - KRATOS_EXPECT_VECTOR_NEAR(reference_RHS, RHS, 1e-7); + // hence, it is assumd that if the RHS is correct, the LHS is correct as well) + const std::vector rhs_ref = {4018.9219434206,2853.4107384946,3975.91308902814,-5.33704175050362,-4102.94202942482,301.83349069426,-461.814664523128,-4.13004020812797,-21.0969198419593,-3601.634892931,-188.291008973188,-3.049878326998,-283.907119030602,455.463667543343,-4286.63124415407,-4.24970638103708}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-10); } } // namespace Kratos::Testing. diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp index c0a2bcd15831..c73e2ce42646 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp @@ -30,204 +30,169 @@ #include "processes/find_nodal_neighbours_process.h" #include "tests/cpp_tests/fluid_dynamics_fast_suite.h" -namespace Kratos { - namespace Testing { - - typedef ModelPart::IndexType IndexType; - typedef ModelPart::NodeIterator NodeIteratorType; - - /** Checks the VectorialConvectionFractional2D3N element. - * Checks the LHS and RHS computation - */ - - KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional2D3N, FluidDynamicsApplicationFastSuite) - { - - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - // Variables addition - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - - // Process info creation - const int buffer_size = 3; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("VectorialConvectionFractionalElement2D3N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(3,2); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; - vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; - vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; - - // Set the nodal DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY);; - } - - for(unsigned int i=0; i<3; i++){ - for(unsigned int k=0; k<2; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - - // Compute RHS and LHS - Vector RHS = ZeroVector(6); - Matrix LHS = ZeroMatrix(6,6); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - std::cout << std::setprecision(12) << RHS << std::endl; - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0),0.0897168467616, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1),0.176984086786, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2),0.398616486572, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3),0.786349246548, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4),0.475841396524, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5),0.938690536488, 1e-7); +namespace Kratos::Testing { + +typedef ModelPart::IndexType IndexType; +typedef ModelPart::NodeIterator NodeIteratorType; + +/** Checks the VectorialConvectionFractional2D3N element. + * Checks the LHS and RHS computation + */ + +KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional2D3N, FluidDynamicsApplicationFastSuite) +{ + + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + // Variables addition + modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + + // Process info creation + const int buffer_size = 3; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 2); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + std::vector elemNodes {1, 2, 3}; + modelPart.CreateNewElement("VectorialConvectionFractionalElement2D3N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(3,2); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; + + for(unsigned int i=0; i<3; i++){ + for(unsigned int k=0; k<2; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; } - - // /** Checks the VectorialConvectionFractional3D4N element - // * Checks the LHS and RHS for a cut element - // */ - KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional3D4N, FluidDynamicsApplicationFastSuite) - { - Model current_model; - ModelPart& modelPart = current_model.CreateModelPart("Main"); - - // Process info creation - const int buffer_size = 3; - const double delta_time = 0.1; - modelPart.SetBufferSize(buffer_size); - modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); - modelPart.GetProcessInfo().SetValue(TIME, 0.6); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); - modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); - modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); - modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); - Vector bdf_coefs(3); - bdf_coefs[0] = 3.0/(2.0*delta_time); - bdf_coefs[1] = -2.0/delta_time; - bdf_coefs[2] = 0.5/delta_time; - modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); - - // Variables addition - - modelPart.AddNodalSolutionStepVariable(DYNAMIC_VISCOSITY); - modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); - modelPart.AddNodalSolutionStepVariable(VELOCITY); - modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); - modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); - - // Set the element properties - Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); - pElemProp->SetValue(DYNAMIC_VISCOSITY, 1.0e-05); - - // Geometry creation - modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); - modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); - modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); - modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); - std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("VectorialConvectionFractionalElement3D4N", 1, elemNodes, pElemProp); - - Element::Pointer pElement = modelPart.pGetElement(1); - - // Define the nodal values - Matrix vel_original(4,3); - vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; - vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; - vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; - vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; - - // Set the nodal BODY_FORCE, DENSITY and DYNAMIC_VISCOSITY values - for (NodeIteratorType it_node=modelPart.NodesBegin(); it_nodeFastGetSolutionStepValue(DYNAMIC_VISCOSITY) = pElemProp->GetValue(DYNAMIC_VISCOSITY); - - } - - for(unsigned int i=0; i<4; i++){ - for(unsigned int k=0; k<3; k++){ - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; - pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; - } - } - - // Compute RHS and LHS - Vector RHS = ZeroVector(12); - Matrix LHS = ZeroMatrix(12,12); - - const auto& r_process_info = modelPart.GetProcessInfo(); - pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law - pElement->CalculateLocalSystem(LHS, RHS, r_process_info); - - // Check the RHS values (the RHS is computed as the LHS x previous_solution, - // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - - KRATOS_EXPECT_NEAR(RHS(0), -0.0137395522001, 1e-7); - KRATOS_EXPECT_NEAR(RHS(1), -0.0223513234274, 1e-7); - KRATOS_EXPECT_NEAR(RHS(2), -0.0309630946547, 1e-7); - KRATOS_EXPECT_NEAR(RHS(3), 0.1489635261, 1e-7); - KRATOS_EXPECT_NEAR(RHS(4), 0.242331911714, 1e-7); - KRATOS_EXPECT_NEAR(RHS(5), 0.335700297327, 1e-7); - KRATOS_EXPECT_NEAR(RHS(6), 0.167041645911, 1e-7); - KRATOS_EXPECT_NEAR(RHS(7), 0.271741160063, 1e-7); - KRATOS_EXPECT_NEAR(RHS(8), 0.376440674214, 1e-7); - KRATOS_EXPECT_NEAR(RHS(9), 0.185119765722, 1e-7); - KRATOS_EXPECT_NEAR(RHS(10), 0.301150408412, 1e-7); - KRATOS_EXPECT_NEAR(RHS(11), 0.417181051101, 1e-7); - + } + + // Compute RHS and LHS + Vector RHS = ZeroVector(6); + Matrix LHS = ZeroMatrix(6,6); + + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + const std::vector rhs_ref={0.0897168467616033,0.176984086785688,0.39861648657173,0.786349246547645,0.475841396524262,0.938690536488135}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-10) +} + +// /** Checks the VectorialConvectionFractional3D4N element +// * Checks the LHS and RHS for a cut element +// */ +KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional3D4N, FluidDynamicsApplicationFastSuite) +{ + Model current_model; + ModelPart& modelPart = current_model.CreateModelPart("Main"); + + // Process info creation + const int buffer_size = 3; + const double delta_time = 0.1; + modelPart.SetBufferSize(buffer_size); + modelPart.GetProcessInfo().SetValue(DOMAIN_SIZE, 3); + modelPart.GetProcessInfo().SetValue(TIME, 0.6); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + modelPart.CloneTimeStep(modelPart.GetProcessInfo().GetValue(TIME) + delta_time); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(TIME, 0.0); + modelPart.GetProcessInfo().GetPreviousTimeStepInfo(1).SetValue(DELTA_TIME, delta_time); + modelPart.GetProcessInfo().SetValue(DYNAMIC_TAU, 0.001); + modelPart.GetProcessInfo().SetValue(DELTA_TIME, delta_time); + Vector bdf_coefs(3); + bdf_coefs[0] = 3.0/(2.0*delta_time); + bdf_coefs[1] = -2.0/delta_time; + bdf_coefs[2] = 0.5/delta_time; + modelPart.GetProcessInfo().SetValue(BDF_COEFFICIENTS, bdf_coefs); + + // Variables addition + + modelPart.AddNodalSolutionStepVariable(DYNAMIC_TAU); + modelPart.AddNodalSolutionStepVariable(VELOCITY); + modelPart.AddNodalSolutionStepVariable(FRACTIONAL_VELOCITY); + modelPart.AddNodalSolutionStepVariable(MESH_VELOCITY); + + // Set the element properties + Properties::Pointer pElemProp = modelPart.CreateNewProperties(0); + + // Geometry creation + modelPart.CreateNewNode(1, 0.0, 0.0, 0.0); + modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); + modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); + modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); + std::vector elemNodes {1, 2, 3, 4}; + modelPart.CreateNewElement("VectorialConvectionFractionalElement3D4N", 1, elemNodes, pElemProp); + + Element::Pointer pElement = modelPart.pGetElement(1); + + // Define the nodal values + Matrix vel_original(4,3); + vel_original(0,0) = 0.0; vel_original(0,1) = 0.1; vel_original(0,2) = 0.2; + vel_original(1,0) = 0.1; vel_original(1,1) = 0.2; vel_original(1,2) = 0.3; + vel_original(2,0) = 0.2; vel_original(2,1) = 0.3; vel_original(2,2) = 0.4; + vel_original(3,0) = 0.3; vel_original(3,1) = 0.4; vel_original(3,2) = 0.5; + + for(unsigned int i=0; i<4; i++){ + for(unsigned int k=0; k<3; k++){ + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY)[k] = vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 1)[k] = 0.9*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(VELOCITY, 2)[k] = 0.75*vel_original(i,k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY)[k] = 0.1 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 1)[k] = 0.2 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(FRACTIONAL_VELOCITY, 2)[k] = 0.3 * vel_original(i, k); + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY,0)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 1)[k] = 0.0; + pElement->GetGeometry()[i].FastGetSolutionStepValue(MESH_VELOCITY, 2)[k] = 0.0; } + } + + // Compute RHS and LHS + Vector RHS = ZeroVector(12); + Matrix LHS = ZeroMatrix(12,12); + const auto& r_process_info = modelPart.GetProcessInfo(); + pElement->Initialize(r_process_info); // Initialize the element to initialize the constitutive law + pElement->CalculateLocalSystem(LHS, RHS, r_process_info); + // Check the RHS values (the RHS is computed as the LHS x previous_solution, + // hence, it is assumed that if the RHS is correct, the LHS is correct as well) + const std::vector rhs_ref={-0.0137395522001275,-0.0223513234273902,-0.0309630946546529,0.148963526100064,0.242331911713695,0.335700297327326,0.167041645911196,0.271741160062705,0.376440674214213,0.185119765722328,0.301150408411714,0.4171810511011}; + KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-10) + +} - } // namespace Testing -} // namespace Kratos. +} // namespace Kratos::Testing \ No newline at end of file From c210d1eb7e8c533722b3915931b17c5f085bd4cb Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 26 Dec 2024 13:33:52 +0100 Subject: [PATCH 09/13] test value are modified since body force was not correct in data container --- .../two_fluid_navier_stokes_fractional_data.h | 10 +++++----- .../generate_two_fluid_navier_stokes_fractional.py | 2 -- ...t_two_fluid_fractional_navier_stokes_element.cpp | 13 +++++-------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h index 59de9dade392..726549fa2505 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -64,7 +64,6 @@ double DeltaTime; // Time increment double PreviousDeltaTime; double DynamicTau; // Dynamic tau considered in ASGS stabilization coefficients double SmagorinskyConstant; -double VolumeError; double AirVolumeError; double WaterVolumeError; double bdf0; @@ -121,18 +120,19 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri this->FillFromHistoricalNodalData(NodalDynamicViscosity, DYNAMIC_VISCOSITY, r_geometry); this->FillFromHistoricalNodalData(FractionalVelocity, FRACTIONAL_VELOCITY, r_geometry, 0); this->FillFromProperties(SmagorinskyConstant, C_SMAGORINSKY, r_properties); + this->FillFromHistoricalNodalData(BodyForce,BODY_FORCE,r_geometry); this->FillFromProcessInfo(DeltaTime,DELTA_TIME,rProcessInfo); - this->FillFromProcessInfo(VolumeError, VOLUME_ERROR, rProcessInfo); this->FillFromProcessInfo(DynamicTau, DYNAMIC_TAU, rProcessInfo); this->FillFromProcessInfo(AirVolumeError, AIR_VOLUME_ERROR, rProcessInfo); this->FillFromProcessInfo(WaterVolumeError, WATER_VOLUME_ERROR, rProcessInfo); + const Vector& BDFVector = rProcessInfo[BDF_COEFFICIENTS]; bdf0 = BDFVector[0]; - bdf1 = BDFVector[1]; - bdf2 = BDFVector[2]; - + // bdf1 = BDFVector[1]; + // bdf2 = BDFVector[2]; + PreviousDeltaTime = rProcessInfo.GetPreviousTimeStepInfo()[DELTA_TIME]; noalias(lhs) = ZeroMatrix(TNumNodes*(TDim+1),TNumNodes*(TDim+1)); noalias(rhs) = ZeroVector(TNumNodes*(TDim+1)); diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py index 0b066b914ca5..360248f61600 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py @@ -119,8 +119,6 @@ ## Data interpolation to the Gauss points ## Backward differences coefficients bdf0 = sympy.Symbol('bdf0') - bdf1 = sympy.Symbol('bdf1') - bdf2 = sympy.Symbol('bdf2') ## Part of the NS acceleration due to the fractional splitting acceleration = (bdf0*v -bdf0*vfrac) v_gauss = v.transpose()*N diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp index 6b4e55fe316b..0c37e8d9c642 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_two_fluid_fractional_navier_stokes_element.cpp @@ -238,7 +238,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4N, FluidDyn pElement->CalculateLocalSystem(LHS, RHS, r_process_info); // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - const std::vector rhs_ref = {-49.6230448446,-5.81518310901,-92.6312642702,0.134427963708,-139.799199585,-195.380881022,-249.006265616,0.0341650889644,-98.6768840265,-309.521310486,-265.871321505,-0.183090855324,-102.401818165,-260.137138577,-354.792467018,-0.0855021973489}; + const std::vector rhs_ref = {-182.780712656374,-5.97373013000447,-366.425812873773,0.13618045150788,-65.5996318561992,-195.157657104678,-732.899349900163,0.228653068676312,-30.1350973710576,-309.557107994407,-744.055344313566,-0.182507276303036,4.70728308941767,-259.815870552732,-872.015239241193,-0.282326243881156}; KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } @@ -342,7 +342,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalNegativeSide3D4N, // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - const std::vector rhs_ref={55.5608619747,64.3649724019,73.1690828291,0.98042064137,-173.148878249,-263.100173027,-363.46638282,-0.231551322358,-198.517992416,-320.806050475,-422.264278502,-0.36014021379,-233.824784725,-357.542877174,-491.67588464,-0.488729105221}; + const std::vector rhs_ref={55.5608619747481,64.3649724019167,130.747961752768,1.82139199133129,-173.148878249225,-263.100173026906,-1019.86139377883,-0.231551322358482,-198.517992416071,-320.806050474686,-1153.91463291277,-0.360140213789913,-233.824784724542,-357.542877174272,-1300.79220817092,-1.3297004551829}; KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } @@ -445,8 +445,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalPositiveSide3D4N, // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumed that if the RHS is correct, the LHS is correct as well) - // std::cout<< std::setprecision(12) << RHS << std::endl; - const std::vector rhs_ref={55.5608619747,64.3649724019,73.1690828291,0.98042064137,-173.148878249,-263.100173027,-363.46638282,-0.231551322358,-198.517992416,-320.806050475,-422.264278502,-0.36014021379,-233.824784725,-357.542877174,-491.67588464,-0.488729105221}; + const std::vector rhs_ref={55.5608619747481,64.3649724019167,130.747961752768,1.82139199133129,-173.148878249225,-263.100173026906,-1019.86139377883,-0.231551322358482,-198.517992416071,-320.806050474686,-1153.91463291277,-0.360140213789913,-233.824784724542,-357.542877174272,-1300.79220817092,-1.3297004551829}; KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } @@ -574,9 +573,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractional2D3NHydrostatic, // The remaining residuals in the velocities have the size of the boundary integrals over the enriched pressure. // If the "standard" pressure shape functions are used, the results do not hold. - // std::cout<< std::setprecision(12) << RHS << std::endl; - - const std::vector rhs_ref={0.0,-7.48877586059,-1.64822555671,7.48877586059,7.48877586059,1.2364371328,-7.48877586059,0,0.411788423917}; + const std::vector rhs_ref={0,-17.5,-5.6843418860808e-14,7.5,4.44089209850063e-16,2.8421709430404e-14,-7.5,-7.5,7.105427357601e-15}; KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-7); } @@ -804,7 +801,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementTwoFluidNavierStokesFractionalCut3D4NError, Flu pElement->CalculateLocalSystem(LHS, RHS, r_process_info); // Check the RHS values (the RHS is computed as the LHS x previous_solution, // hence, it is assumd that if the RHS is correct, the LHS is correct as well) - const std::vector rhs_ref = {4018.9219434206,2853.4107384946,3975.91308902814,-5.33704175050362,-4102.94202942482,301.83349069426,-461.814664523128,-4.13004020812797,-21.0969198419593,-3601.634892931,-188.291008973188,-3.049878326998,-283.907119030602,455.463667543343,-4286.63124415407,-4.24970638103708}; + const std::vector rhs_ref = {3885.76546946416,2853.25219454485,3702.11733420833,-5.33528927901302,-4028.74316647894,302.056712496537,-945.70703699794,-3.93555403796184,47.44424724214,-3601.67069178779,-666.474404348206,-3.04929475340806,-176.798973004457,455.784932701568,-4803.85305063243,-4.44652859628375}; KRATOS_EXPECT_VECTOR_NEAR(RHS, rhs_ref, 1.0e-10); } From 9c6ad0d211e2311d6df8ee46c68d28afbf5d7218 Mon Sep 17 00:00:00 2001 From: uxuech Date: Thu, 26 Dec 2024 21:40:41 +0100 Subject: [PATCH 10/13] renaming fractional element name, following Ruben`s suggestion --- ...okes_fractional_convection_element_data.h} | 2 +- .../two_fluid_navier_stokes_fractional_data.h | 6 +-- .../custom_elements/fluid_element.cpp | 2 +- ..._stokes_fractional_convection_element.cpp} | 50 +++++++++---------- ...er_stokes_fractional_convection_element.h} | 22 ++++---- .../fluid_dynamics_application.cpp | 8 +-- .../fluid_dynamics_application.h | 8 +-- .../fluid_dynamics_application_variables.cpp | 1 + ...enerate_two_fluid_convection_fractional.py | 4 +- ...stokes_fractional_convection_template.cpp} | 50 +++++++++---------- ...ectorial_convection_fractional_element.cpp | 6 +-- 11 files changed, 79 insertions(+), 80 deletions(-) rename applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/{vectorial_convection_fractional_element_data.h => two_fluid_navier_stokes_fractional_convection_element_data.h} (96%) rename applications/FluidDynamicsApplication/custom_elements/{vectorial_convection_fractional_element.cpp => two_fluid_navier_stokes_fractional_convection_element.cpp} (89%) rename applications/FluidDynamicsApplication/custom_elements/{vectorial_convection_fractional_element.h => two_fluid_navier_stokes_fractional_convection_element.h} (91%) rename applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/{vectorial_convection_fractional_element_template.cpp => two_fluid_navier_stokes_fractional_convection_template.cpp} (78%) diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h similarity index 96% rename from applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h rename to applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h index 00b51faa7dc1..c28915995dac 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h @@ -26,7 +26,7 @@ namespace Kratos { ///@{ template< size_t TDim, size_t TNumNodes > -class VectorialConvectionFractionalElementData : public FluidElementData +class TwoFluidNavierStokesFractionalConvectionElementData : public FluidElementData { public: diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h index 726549fa2505..5cc4072b269c 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -120,7 +120,7 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri this->FillFromHistoricalNodalData(NodalDynamicViscosity, DYNAMIC_VISCOSITY, r_geometry); this->FillFromHistoricalNodalData(FractionalVelocity, FRACTIONAL_VELOCITY, r_geometry, 0); this->FillFromProperties(SmagorinskyConstant, C_SMAGORINSKY, r_properties); - this->FillFromHistoricalNodalData(BodyForce,BODY_FORCE,r_geometry); + this->FillFromHistoricalNodalData(BodyForce,BODY_FORCE,r_geometry); this->FillFromProcessInfo(DeltaTime,DELTA_TIME,rProcessInfo); this->FillFromProcessInfo(DynamicTau, DYNAMIC_TAU, rProcessInfo); this->FillFromProcessInfo(AirVolumeError, AIR_VOLUME_ERROR, rProcessInfo); @@ -130,8 +130,6 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri const Vector& BDFVector = rProcessInfo[BDF_COEFFICIENTS]; bdf0 = BDFVector[0]; - // bdf1 = BDFVector[1]; - // bdf2 = BDFVector[2]; PreviousDeltaTime = rProcessInfo.GetPreviousTimeStepInfo()[DELTA_TIME]; noalias(lhs) = ZeroMatrix(TNumNodes*(TDim+1),TNumNodes*(TDim+1)); @@ -181,7 +179,7 @@ void UpdateGeometryValues( static int Check(const Element& rElement, const ProcessInfo& rProcessInfo) { - const Geometry< Node >& r_geometry = rElement.GetGeometry(); + const auto& r_geometry = rElement.GetGeometry(); for (unsigned int i = 0; i < TNumNodes; i++) { diff --git a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp index 2c9d8d7a13be..5a8267588f95 100644 --- a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp @@ -26,7 +26,7 @@ #include "data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" #include "data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" #include "data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" -#include "data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" +#include "data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h" #include "utilities/element_size_calculator.h" #include "custom_utilities/vorticity_utilities.h" diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp similarity index 89% rename from applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp rename to applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp index 7827a6263c59..6b78671480fd 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp @@ -10,7 +10,7 @@ // Main author: Uxue Chasco // -#include "vectorial_convection_fractional_element.h" +#include "two_fluid_navier_stokes_fractional_convection_element.h" namespace Kratos { @@ -19,27 +19,27 @@ namespace Kratos /***********************************************************************************/ template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId) : Element(NewId) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId) : Element(NewId) { } template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) { } template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) { } template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) { } template - VectorialConvectionFractionalElement::~VectorialConvectionFractionalElement() + TwoFluidNavierStokesFractionalConvectionElement::~TwoFluidNavierStokesFractionalConvectionElement() { } @@ -47,35 +47,35 @@ namespace Kratos /***********************************************************************************/ template - Element::Pointer VectorialConvectionFractionalElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( IndexType NewId, NodesArrayType const &ThisNodes, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); } /***********************************************************************************/ template - Element::Pointer VectorialConvectionFractionalElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( IndexType NewId, GeometryType::Pointer pGeom, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, pGeom, pProperties); + return Kratos::make_intrusive(NewId, pGeom, pProperties); } /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + void TwoFluidNavierStokesFractionalConvectionElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) { KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); } template - void VectorialConvectionFractionalElement::CalculateLocalSystem( + void TwoFluidNavierStokesFractionalConvectionElement::CalculateLocalSystem( MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) @@ -111,7 +111,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::UpdateIntegrationPointData( + void TwoFluidNavierStokesFractionalConvectionElement::UpdateIntegrationPointData( TElementData &rData, unsigned int IntegrationPointIndex, double Weight, @@ -125,7 +125,7 @@ namespace Kratos /***********************************************************************************/ template - void VectorialConvectionFractionalElement::AddTimeIntegratedSystem( + void TwoFluidNavierStokesFractionalConvectionElement::AddTimeIntegratedSystem( TElementData &rData, MatrixType &rLHS, VectorType &rRHS) @@ -137,7 +137,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::CalculateGeometryData(Vector &rGaussWeights, + void TwoFluidNavierStokesFractionalConvectionElement::CalculateGeometryData(Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionDerivativesArrayType &rDN_DX) const { @@ -168,7 +168,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, MatrixType &rLHS) { @@ -262,7 +262,7 @@ lhs(5,5)=clhs29; /***********************************************************************************/ /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, MatrixType &rLHS) { @@ -484,7 +484,7 @@ lhs(11,11)=clhs45; /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, VectorType &rRHS) { @@ -554,7 +554,7 @@ rhs[5]=N[2]*crhs0*crhs22 - N[2]*crhs23 - N[2]*crhs24 + N[2]*crhs27 - crhs28*crhs /***********************************************************************************/ /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, VectorType &rRHS) { @@ -651,7 +651,7 @@ rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crh /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::EquationIdVector( + void TwoFluidNavierStokesFractionalConvectionElement::EquationIdVector( EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const { @@ -668,7 +668,7 @@ rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crh { rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_X, xpos).EquationId(); rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Y, xpos + 1).EquationId(); - if (Dim == 3) + if constexpr (Dim == 3) rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Z, xpos + 2).EquationId(); } } @@ -677,7 +677,7 @@ rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crh /***********************************************************************************/ template - void VectorialConvectionFractionalElement::GetDofList( + void TwoFluidNavierStokesFractionalConvectionElement::GetDofList( DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const { @@ -693,7 +693,7 @@ rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crh { rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_X, xpos); rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Y, xpos + 1); - if (Dim == 3) + if constexpr (Dim == 3) rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Z, xpos + 2); } } @@ -703,8 +703,8 @@ rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crh /***********************************************************************************/ /***********************************************************************************/ - template class VectorialConvectionFractionalElement>; - template class VectorialConvectionFractionalElement>; + template class TwoFluidNavierStokesFractionalConvectionElement>; + template class TwoFluidNavierStokesFractionalConvectionElement>; /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h similarity index 91% rename from applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h rename to applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h index ecf5367ad86c..789bde7da7df 100644 --- a/applications/FluidDynamicsApplication/custom_elements/vectorial_convection_fractional_element.h +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h @@ -25,13 +25,13 @@ #include "includes/convection_diffusion_settings.h" #include "utilities/geometry_utilities.h" #include "custom_elements/data_containers/fluid_element_data.h" -#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h" #include "fluid_dynamics_application_variables.h" namespace Kratos { /* - The "VectorialConvectionFractionalElement" solves the convection problem of a vector field, specifically the fractional velocity, and convects this field using its own velocity. + The "TwoFluidNavierStokesFractionalConvectionElement" solves the convection problem of a vector field, specifically the fractional velocity, and convects this field using its own velocity. This element is part of the two-fluid Navier-Stokes fractional element TwoFluidNavierStokesFractional. The Navier-Stokes momentum conservation equation is split into two problems: the first one convects the fractional velocity (using this element), and the second one resolves the remaining terms of the Navier-Stokes momentum conservation. Combining both problems in the continuous framework results in the original Navier-Stokes momentum equation @@ -52,14 +52,14 @@ namespace Kratos ///@name Kratos Classes ///@{ template -class VectorialConvectionFractionalElement: public Element +class TwoFluidNavierStokesFractionalConvectionElement: public Element { public: ///@name Type Definitions ///@{ /// Counted pointer of - KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(VectorialConvectionFractionalElement); + KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractionalConvectionElement); using ElementData = TElementData; typedef GeometryType::ShapeFunctionsGradientsType ShapeFunctionDerivativesArrayType; @@ -79,14 +79,14 @@ class VectorialConvectionFractionalElement: public Element /** * @param NewId Index number of the new element (optional) */ - VectorialConvectionFractionalElement(IndexType NewId = 0); + TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId = 0); /** * @brief Constructor using an array of nodes. * @param NewId Index of the new element * @param ThisNodes An array containing the nodes of the new element */ - VectorialConvectionFractionalElement( + TwoFluidNavierStokesFractionalConvectionElement( IndexType NewId, const NodesArrayType &ThisNodes); @@ -95,7 +95,7 @@ class VectorialConvectionFractionalElement: public Element * @param NewId Index of the new element * @param pGeometry Pointer to a geometry object */ - VectorialConvectionFractionalElement( + TwoFluidNavierStokesFractionalConvectionElement( IndexType NewId, GeometryType::Pointer pGeometry); @@ -105,13 +105,13 @@ class VectorialConvectionFractionalElement: public Element * @param pGeometry Pointer to a geometry object * @param pProperties Pointer to the element's properties */ - VectorialConvectionFractionalElement( + TwoFluidNavierStokesFractionalConvectionElement( IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties); /// Destructor. - virtual ~VectorialConvectionFractionalElement(); + virtual ~TwoFluidNavierStokesFractionalConvectionElement(); ///@} ///@name Operators @@ -122,7 +122,7 @@ class VectorialConvectionFractionalElement: public Element ///@name Operations ///@{ /** - @brief Returns a pointer to a new VectorialConvectionFractionalElement element, created using given input. + @brief Returns a pointer to a new TwoFluidNavierStokesFractionalConvectionElement element, created using given input. * @param NewId the ID of the new element * @param ThisNodes the nodes of the new element * @param pProperties the properties assigned to the new element @@ -258,7 +258,7 @@ class VectorialConvectionFractionalElement: public Element std::string Info() const override { - return "VectorialConvectionFractionalElement #"; + return "TwoFluidNavierStokesFractionalConvectionElement #"; } /// Print information about this object. diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp index db072ab691b5..c950eef1295b 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp @@ -170,8 +170,8 @@ KratosFluidDynamicsApplication::KratosFluidDynamicsApplication(): mTwoFluidNavierStokesWallCondition3D(0, Element::GeometryType::Pointer(new Triangle3D3(Element::GeometryType::PointsArrayType(3)))), mTwoFluidNavierStokesFractional2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), mTwoFluidNavierStokesFractional3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), - mVectorialConvectionFractionalElement2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), - mVectorialConvectionFractionalElement3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), + mTwoFluidNavierStokesFractionalConvectionElement2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), + mTwoFluidNavierStokesFractionalConvectionElement3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), // Incompressbile Navier-Stokes div-stable elements mIncompressibleNavierStokesP2P1Continuous2D6N(0, Element::GeometryType::Pointer(new Triangle2D6(Element::GeometryType::PointsArrayType(6)))), mIncompressibleNavierStokesP2P1Continuous3D10N(0, Element::GeometryType::Pointer(new Tetrahedra3D10(Element::GeometryType::PointsArrayType(10)))), @@ -409,8 +409,8 @@ void KratosFluidDynamicsApplication::Register() { KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesAlphaMethod3D4N", mTwoFluidNavierStokesAlphaMethod3D4N); KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractional2D3N", mTwoFluidNavierStokesFractional2D3N); KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractional3D4N", mTwoFluidNavierStokesFractional3D4N); - KRATOS_REGISTER_ELEMENT("VectorialConvectionFractionalElement2D3N", mVectorialConvectionFractionalElement2D3N); - KRATOS_REGISTER_ELEMENT("VectorialConvectionFractionalElement3D4N", mVectorialConvectionFractionalElement3D4N); + KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractionalConvectionElement2D3N", mTwoFluidNavierStokesFractionalConvectionElement2D3N); + KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractionalConvectionElement3D4N", mTwoFluidNavierStokesFractionalConvectionElement3D4N); // Low Mach Navier-Stokes elements KRATOS_REGISTER_ELEMENT("LowMachNavierStokes2D3N",mLowMachNavierStokes2D3N); diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.h b/applications/FluidDynamicsApplication/fluid_dynamics_application.h index 20dbd3305ac1..a0d3cf85e72a 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.h +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.h @@ -83,7 +83,7 @@ #include "custom_elements/two_fluid_navier_stokes.h" #include "custom_elements/two_fluid_navier_stokes_alpha_method.h" #include "custom_elements/two_fluid_navier_stokes_fractional.h" -#include "custom_elements/vectorial_convection_fractional_element.h" +#include "custom_elements/two_fluid_navier_stokes_fractional_convection_element.h" #include "custom_elements/data_containers/axisymmetric_navier_stokes/axisymmetric_navier_stokes_data.h" #include "custom_elements/data_containers/low_mach_navier_stokes/low_mach_navier_stokes_data.h" @@ -97,7 +97,7 @@ #include "custom_elements/data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" #include "custom_elements/data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" #include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" -#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/vectorial_convection_fractional_element_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h" #include "custom_constitutive/bingham_3d_law.h" #include "custom_constitutive/euler_2d_law.h" @@ -471,8 +471,8 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) KratosFluidDynamicsApplication : pu const TwoFluidNavierStokesWallCondition<3,3> mTwoFluidNavierStokesWallCondition3D; const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional2D3N; const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional3D4N; - const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement2D3N; - const VectorialConvectionFractionalElement> mVectorialConvectionFractionalElement3D4N; + const TwoFluidNavierStokesFractionalConvectionElement> mTwoFluidNavierStokesFractionalConvectionElement2D3N; + const TwoFluidNavierStokesFractionalConvectionElement> mTwoFluidNavierStokesFractionalConvectionElement3D4N; /// Incompressible Navier-Stokes div-stable element const IncompressibleNavierStokesP2P1Continuous<2> mIncompressibleNavierStokesP2P1Continuous2D6N; diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp b/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp index 7f89d4828918..d91f92fa0625 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application_variables.cpp @@ -40,6 +40,7 @@ KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(AUXILIAR_VECTOR_VELOCITY) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(FRACTIONAL_VELOCITY) KRATOS_CREATE_VARIABLE(double,WATER_VOLUME_ERROR) KRATOS_CREATE_VARIABLE(double,AIR_VOLUME_ERROR) + // Darcy's flow variables KRATOS_CREATE_VARIABLE(double, RESISTANCE) KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(SOLID_FRACTION_VELOCITY) diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py index 0d71775c5ead..247c8554f027 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py @@ -20,8 +20,8 @@ adding_acceleration = True # Whether to add acceleration -output_filename = "vectorial_convection_fractional_element.cpp" -template_filename = "vectorial_convection_fractional_element_template.cpp" +output_filename = "two_fluid_navier_stokes_fractional_convection_element.cpp" +template_filename = "two_fluid_navier_stokes_fractional_convection_template.cpp" if (dim_to_compute == "2D"): dim_vector = [2] diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp similarity index 78% rename from applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp rename to applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp index 7851a41e2266..0e2e63efe775 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/vectorial_convection_fractional_element_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp @@ -10,7 +10,7 @@ // Main author: Uxue Chasco // -#include "vectorial_convection_fractional_element.h" +#include "two_fluid_navier_stokes_fractional_convection_element.h" namespace Kratos { @@ -19,27 +19,27 @@ namespace Kratos /***********************************************************************************/ template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId) : Element(NewId) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId) : Element(NewId) { } template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) { } template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) { } template - VectorialConvectionFractionalElement::VectorialConvectionFractionalElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) { } template - VectorialConvectionFractionalElement::~VectorialConvectionFractionalElement() + TwoFluidNavierStokesFractionalConvectionElement::~TwoFluidNavierStokesFractionalConvectionElement() { } @@ -47,35 +47,35 @@ namespace Kratos /***********************************************************************************/ template - Element::Pointer VectorialConvectionFractionalElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( IndexType NewId, NodesArrayType const &ThisNodes, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); } /***********************************************************************************/ template - Element::Pointer VectorialConvectionFractionalElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( IndexType NewId, GeometryType::Pointer pGeom, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, pGeom, pProperties); + return Kratos::make_intrusive(NewId, pGeom, pProperties); } /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + void TwoFluidNavierStokesFractionalConvectionElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) { KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); } template - void VectorialConvectionFractionalElement::CalculateLocalSystem( + void TwoFluidNavierStokesFractionalConvectionElement::CalculateLocalSystem( MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) @@ -111,7 +111,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::UpdateIntegrationPointData( + void TwoFluidNavierStokesFractionalConvectionElement::UpdateIntegrationPointData( TElementData &rData, unsigned int IntegrationPointIndex, double Weight, @@ -125,7 +125,7 @@ namespace Kratos /***********************************************************************************/ template - void VectorialConvectionFractionalElement::AddTimeIntegratedSystem( + void TwoFluidNavierStokesFractionalConvectionElement::AddTimeIntegratedSystem( TElementData &rData, MatrixType &rLHS, VectorType &rRHS) @@ -137,7 +137,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::CalculateGeometryData(Vector &rGaussWeights, + void TwoFluidNavierStokesFractionalConvectionElement::CalculateGeometryData(Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionDerivativesArrayType &rDN_DX) const { @@ -168,7 +168,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, MatrixType &rLHS) { @@ -196,7 +196,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointLHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, MatrixType &rLHS) { @@ -228,7 +228,7 @@ namespace Kratos /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, VectorType &rRHS) { @@ -259,7 +259,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void VectorialConvectionFractionalElement>::ComputeGaussPointRHSContribution(VectorialConvectionFractionalElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, VectorType &rRHS) { @@ -291,7 +291,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void VectorialConvectionFractionalElement::EquationIdVector( + void TwoFluidNavierStokesFractionalConvectionElement::EquationIdVector( EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const { @@ -308,7 +308,7 @@ namespace Kratos { rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_X, xpos).EquationId(); rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Y, xpos + 1).EquationId(); - if (Dim == 3) + if constexpr (Dim == 3) rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Z, xpos + 2).EquationId(); } } @@ -317,7 +317,7 @@ namespace Kratos /***********************************************************************************/ template - void VectorialConvectionFractionalElement::GetDofList( + void TwoFluidNavierStokesFractionalConvectionElement::GetDofList( DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const { @@ -333,7 +333,7 @@ namespace Kratos { rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_X, xpos); rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Y, xpos + 1); - if (Dim == 3) + if constexpr (Dim == 3) rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Z, xpos + 2); } } @@ -343,8 +343,8 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ - template class VectorialConvectionFractionalElement>; - template class VectorialConvectionFractionalElement>; + template class TwoFluidNavierStokesFractionalConvectionElement>; + template class TwoFluidNavierStokesFractionalConvectionElement>; /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp index c73e2ce42646..616cb425c332 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp @@ -26,7 +26,7 @@ #include "utilities/normal_calculation_utils.h" // Application includes -#include "custom_elements/vectorial_convection_fractional_element.h" +#include "custom_elements/two_fluid_navier_stokes_fractional_convection_element.h" #include "processes/find_nodal_neighbours_process.h" #include "tests/cpp_tests/fluid_dynamics_fast_suite.h" @@ -76,7 +76,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional2D3N, FluidDynamic modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("VectorialConvectionFractionalElement2D3N", 1, elemNodes, pElemProp); + modelPart.CreateNewElement("TwoFluidNavierStokesFractionalConvectionElement2D3N", 1, elemNodes, pElemProp); Element::Pointer pElement = modelPart.pGetElement(1); @@ -155,7 +155,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional3D4N, FluidDynamic modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("VectorialConvectionFractionalElement3D4N", 1, elemNodes, pElemProp); + modelPart.CreateNewElement("TwoFluidNavierStokesFractionalConvectionElement3D4N", 1, elemNodes, pElemProp); Element::Pointer pElement = modelPart.pGetElement(1); From b3f44a05ff6d6ce38eaed84ff69a757a7c5286ea Mon Sep 17 00:00:00 2001 From: uxuech Date: Fri, 27 Dec 2024 18:42:50 +0100 Subject: [PATCH 11/13] adding Ruben`s suggestion in order to reduce memory footprint and adding also artificial viscosity to this element --- ...tokes_fractional_convection_element_data.h | 9 - .../two_fluid_navier_stokes_fractional_data.h | 17 - .../two_fluid_navier_stokes_fractional.cpp | 2774 +++++++++-------- .../two_fluid_navier_stokes_fractional.h | 21 +- ...r_stokes_fractional_convection_element.cpp | 787 ++--- ...enerate_two_fluid_convection_fractional.py | 5 +- ...rate_two_fluid_navier_stokes_fractional.py | 14 +- ..._stokes_fractional_convection_template.cpp | 46 +- ...luid_navier_stokes_fractional_template.cpp | 194 +- 9 files changed, 2014 insertions(+), 1853 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h index c28915995dac..7a1938094ca4 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h @@ -55,15 +55,8 @@ double DynamicTau; // Dynamic tau considered in ASGS stabilization coeff double bdf0; double bdf1; double bdf2; - -// Auxiliary containers for the symbolically-generated matrices -BoundedMatrix lhs; -array_1d rhs; - double ElementSize; - - ///@} ///@name Public Operations ///@{ @@ -83,8 +76,6 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri bdf0 = BDFVector[0]; bdf1 = BDFVector[1]; bdf2 = BDFVector[2]; - noalias(lhs) = ZeroMatrix(TNumNodes*(TDim),TNumNodes*(TDim)); - noalias(rhs) = ZeroVector(TNumNodes*(TDim)); } void UpdateGeometryValues( diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h index 5cc4072b269c..d5fa0369d26a 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h @@ -67,17 +67,6 @@ double SmagorinskyConstant; double AirVolumeError; double WaterVolumeError; double bdf0; -double bdf1; -double bdf2; - -// Auxiliary containers for the symbolically-generated matrices -BoundedMatrix lhs; -array_1d rhs; -BoundedMatrix V; -BoundedMatrix H; -BoundedMatrix Kee; -array_1d rhs_ee; - double ElementSize; Matrix N_pos_side; @@ -132,12 +121,6 @@ void Initialize(const Element& rElement, const ProcessInfo& rProcessInfo) overri bdf0 = BDFVector[0]; PreviousDeltaTime = rProcessInfo.GetPreviousTimeStepInfo()[DELTA_TIME]; - noalias(lhs) = ZeroMatrix(TNumNodes*(TDim+1),TNumNodes*(TDim+1)); - noalias(rhs) = ZeroVector(TNumNodes*(TDim+1)); - noalias(V) = ZeroMatrix(TNumNodes*(TDim + 1), TNumNodes); - noalias(H) = ZeroMatrix(TNumNodes, TNumNodes*(TDim + 1)); - noalias(Kee) = ZeroMatrix(TNumNodes, TNumNodes); - noalias(rhs_ee) = ZeroVector(TNumNodes); NumPositiveNodes = 0; NumNegativeNodes = 0; diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp index ea756e5ffc26..5d0610206a7c 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.cpp @@ -357,216 +357,215 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - auto &lhs = rData.lhs; - - const double clhs0 = C(0,0)*DN(0,0) + C(0,2)*DN(0,1); -const double clhs1 = C(0,2)*DN(0,0); -const double clhs2 = C(2,2)*DN(0,1) + clhs1; -const double clhs3 = DN(0,0)*DN(0,0); -const double clhs4 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double clhs5 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double clhs6 = rho*stab_c2*sqrt(clhs4*clhs4 + clhs5*clhs5); -const double clhs7 = clhs6*h*1.0/stab_c1 + mu; -const double clhs8 = DN(0,0)*clhs4 + DN(0,1)*clhs5; -const double clhs9 = N[0]*rho; -const double clhs10 = bdf0*rho; -const double clhs11 = N[0]*bdf0; -const double clhs12 = clhs11 + clhs8; -const double clhs13 = 1.0*1.0/(clhs6*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); -const double clhs14 = clhs13*(rho*rho); -const double clhs15 = clhs14*clhs8; -const double clhs16 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); -const double clhs17 = clhs14*clhs16; -const double clhs18 = N[0]*clhs17; -const double clhs19 = clhs10*(N[0]*N[0]) + clhs12*clhs15 + clhs12*clhs18 + clhs8*clhs9; -const double clhs20 = C(0,1)*DN(0,1) + clhs1; -const double clhs21 = C(1,2)*DN(0,1); -const double clhs22 = C(2,2)*DN(0,0) + clhs21; -const double clhs23 = DN(0,0)*clhs7; -const double clhs24 = DN(0,1)*clhs23; -const double clhs25 = clhs13*clhs16; -const double clhs26 = clhs13*rho; -const double clhs27 = clhs26*clhs8; -const double clhs28 = -N[0] + clhs25*clhs9 + clhs27; -const double clhs29 = C(0,0)*DN(1,0) + C(0,2)*DN(1,1); -const double clhs30 = C(0,2)*DN(1,0); -const double clhs31 = C(2,2)*DN(1,1) + clhs30; -const double clhs32 = DN(0,0)*DN(1,0); -const double clhs33 = N[1]*rho; -const double clhs34 = clhs11*clhs33; -const double clhs35 = clhs32*clhs7 + clhs34; -const double clhs36 = DN(1,0)*clhs4 + DN(1,1)*clhs5; -const double clhs37 = N[1]*bdf0; -const double clhs38 = clhs36 + clhs37; -const double clhs39 = clhs15*clhs38 + clhs18*clhs38 + clhs36*clhs9; -const double clhs40 = C(0,1)*DN(1,1) + clhs30; -const double clhs41 = C(1,2)*DN(1,1); -const double clhs42 = C(2,2)*DN(1,0) + clhs41; -const double clhs43 = DN(1,1)*clhs23; -const double clhs44 = DN(0,0)*N[1]; -const double clhs45 = DN(1,0)*N[0]; -const double clhs46 = clhs16*clhs26; -const double clhs47 = C(0,0)*DN(2,0) + C(0,2)*DN(2,1); -const double clhs48 = C(0,2)*DN(2,0); -const double clhs49 = C(2,2)*DN(2,1) + clhs48; -const double clhs50 = DN(0,0)*DN(2,0); -const double clhs51 = N[2]*rho; -const double clhs52 = clhs11*clhs51; -const double clhs53 = clhs50*clhs7 + clhs52; -const double clhs54 = DN(2,0)*clhs4 + DN(2,1)*clhs5; -const double clhs55 = N[2]*bdf0 + clhs54; -const double clhs56 = clhs15*clhs55 + clhs18*clhs55 + clhs54*clhs9; -const double clhs57 = C(0,1)*DN(2,1) + clhs48; -const double clhs58 = C(1,2)*DN(2,1); -const double clhs59 = C(2,2)*DN(2,0) + clhs58; -const double clhs60 = DN(2,1)*clhs23; -const double clhs61 = DN(0,0)*N[2]; -const double clhs62 = DN(2,0)*N[0]; -const double clhs63 = C(0,1)*DN(0,0) + clhs21; -const double clhs64 = C(1,1)*DN(0,1) + C(1,2)*DN(0,0); -const double clhs65 = DN(0,1)*DN(0,1); -const double clhs66 = C(0,1)*DN(1,0) + clhs41; -const double clhs67 = DN(0,1)*clhs7; -const double clhs68 = DN(1,0)*clhs67; -const double clhs69 = C(1,1)*DN(1,1) + C(1,2)*DN(1,0); -const double clhs70 = DN(0,1)*DN(1,1); -const double clhs71 = clhs34 + clhs7*clhs70; -const double clhs72 = DN(0,1)*N[1]; -const double clhs73 = DN(1,1)*N[0]; -const double clhs74 = C(0,1)*DN(2,0) + clhs58; -const double clhs75 = DN(2,0)*clhs67; -const double clhs76 = C(1,1)*DN(2,1) + C(1,2)*DN(2,0); -const double clhs77 = DN(0,1)*DN(2,1); -const double clhs78 = clhs52 + clhs7*clhs77; -const double clhs79 = DN(0,1)*N[2]; -const double clhs80 = DN(2,1)*N[0]; -const double clhs81 = clhs12*clhs26; -const double clhs82 = N[0] + clhs81; -const double clhs83 = clhs26*clhs38; -const double clhs84 = clhs13*(clhs32 + clhs70); -const double clhs85 = clhs26*clhs55; -const double clhs86 = clhs13*(clhs50 + clhs77); -const double clhs87 = clhs14*clhs36; -const double clhs88 = N[1]*clhs17; -const double clhs89 = clhs12*clhs87 + clhs12*clhs88 + clhs33*clhs8; -const double clhs90 = clhs26*clhs36; -const double clhs91 = DN(1,0)*DN(1,0); -const double clhs92 = clhs10*(N[1]*N[1]) + clhs33*clhs36 + clhs38*clhs87 + clhs38*clhs88; -const double clhs93 = DN(1,0)*clhs7; -const double clhs94 = DN(1,1)*clhs93; -const double clhs95 = -N[1] + clhs25*clhs33 + clhs90; -const double clhs96 = DN(1,0)*DN(2,0); -const double clhs97 = clhs37*clhs51; -const double clhs98 = clhs7*clhs96 + clhs97; -const double clhs99 = clhs33*clhs54 + clhs55*clhs87 + clhs55*clhs88; -const double clhs100 = DN(2,1)*clhs93; -const double clhs101 = DN(1,0)*N[2]; -const double clhs102 = DN(2,0)*N[1]; -const double clhs103 = DN(1,1)*DN(1,1); -const double clhs104 = DN(2,0)*clhs7; -const double clhs105 = DN(1,1)*clhs104; -const double clhs106 = DN(1,1)*DN(2,1); -const double clhs107 = clhs106*clhs7 + clhs97; -const double clhs108 = DN(1,1)*N[2]; -const double clhs109 = DN(2,1)*N[1]; -const double clhs110 = N[1] + clhs83; -const double clhs111 = clhs13*(clhs106 + clhs96); -const double clhs112 = clhs14*clhs54; -const double clhs113 = N[2]*clhs17; -const double clhs114 = clhs112*clhs12 + clhs113*clhs12 + clhs51*clhs8; -const double clhs115 = clhs26*clhs54; -const double clhs116 = clhs112*clhs38 + clhs113*clhs38 + clhs36*clhs51; -const double clhs117 = DN(2,0)*DN(2,0); -const double clhs118 = clhs10*(N[2]*N[2]) + clhs112*clhs55 + clhs113*clhs55 + clhs51*clhs54; -const double clhs119 = DN(2,1)*clhs104; -const double clhs120 = -N[2] + clhs115 + clhs25*clhs51; -const double clhs121 = DN(2,1)*DN(2,1); -const double clhs122 = N[2] + clhs85; -lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + clhs19 + clhs3*clhs7; -lhs(0,1)=DN(0,0)*clhs20 + DN(0,1)*clhs22 + clhs24; -lhs(0,2)=DN(0,0)*clhs28; -lhs(0,3)=DN(0,0)*clhs29 + DN(0,1)*clhs31 + clhs35 + clhs39; -lhs(0,4)=DN(0,0)*clhs40 + DN(0,1)*clhs42 + clhs43; -lhs(0,5)=DN(1,0)*clhs27 - clhs44 + clhs45*clhs46; -lhs(0,6)=DN(0,0)*clhs47 + DN(0,1)*clhs49 + clhs53 + clhs56; -lhs(0,7)=DN(0,0)*clhs57 + DN(0,1)*clhs59 + clhs60; -lhs(0,8)=DN(2,0)*clhs27 + clhs46*clhs62 - clhs61; -lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs63 + clhs24; -lhs(1,1)=DN(0,0)*clhs22 + DN(0,1)*clhs64 + clhs19 + clhs65*clhs7; -lhs(1,2)=DN(0,1)*clhs28; -lhs(1,3)=DN(0,0)*clhs31 + DN(0,1)*clhs66 + clhs68; -lhs(1,4)=DN(0,0)*clhs42 + DN(0,1)*clhs69 + clhs39 + clhs71; -lhs(1,5)=DN(1,1)*clhs27 + clhs46*clhs73 - clhs72; -lhs(1,6)=DN(0,0)*clhs49 + DN(0,1)*clhs74 + clhs75; -lhs(1,7)=DN(0,0)*clhs59 + DN(0,1)*clhs76 + clhs56 + clhs78; -lhs(1,8)=DN(2,1)*clhs27 + clhs46*clhs80 - clhs79; -lhs(2,0)=DN(0,0)*clhs82; -lhs(2,1)=DN(0,1)*clhs82; -lhs(2,2)=clhs13*(clhs3 + clhs65); -lhs(2,3)=DN(0,0)*clhs83 + clhs45; -lhs(2,4)=DN(0,1)*clhs83 + clhs73; -lhs(2,5)=clhs84; -lhs(2,6)=DN(0,0)*clhs85 + clhs62; -lhs(2,7)=DN(0,1)*clhs85 + clhs80; -lhs(2,8)=clhs86; -lhs(3,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + clhs35 + clhs89; -lhs(3,1)=DN(1,0)*clhs20 + DN(1,1)*clhs22 + clhs68; -lhs(3,2)=DN(0,0)*clhs90 + clhs44*clhs46 - clhs45; -lhs(3,3)=DN(1,0)*clhs29 + DN(1,1)*clhs31 + clhs7*clhs91 + clhs92; -lhs(3,4)=DN(1,0)*clhs40 + DN(1,1)*clhs42 + clhs94; -lhs(3,5)=DN(1,0)*clhs95; -lhs(3,6)=DN(1,0)*clhs47 + DN(1,1)*clhs49 + clhs98 + clhs99; -lhs(3,7)=DN(1,0)*clhs57 + DN(1,1)*clhs59 + clhs100; -lhs(3,8)=DN(2,0)*clhs90 - clhs101 + clhs102*clhs46; -lhs(4,0)=DN(1,0)*clhs2 + DN(1,1)*clhs63 + clhs43; -lhs(4,1)=DN(1,0)*clhs22 + DN(1,1)*clhs64 + clhs71 + clhs89; -lhs(4,2)=DN(0,1)*clhs90 + clhs46*clhs72 - clhs73; -lhs(4,3)=DN(1,0)*clhs31 + DN(1,1)*clhs66 + clhs94; -lhs(4,4)=DN(1,0)*clhs42 + DN(1,1)*clhs69 + clhs103*clhs7 + clhs92; -lhs(4,5)=DN(1,1)*clhs95; -lhs(4,6)=DN(1,0)*clhs49 + DN(1,1)*clhs74 + clhs105; -lhs(4,7)=DN(1,0)*clhs59 + DN(1,1)*clhs76 + clhs107 + clhs99; -lhs(4,8)=DN(2,1)*clhs90 - clhs108 + clhs109*clhs46; -lhs(5,0)=DN(1,0)*clhs81 + clhs44; -lhs(5,1)=DN(1,1)*clhs81 + clhs72; -lhs(5,2)=clhs84; -lhs(5,3)=DN(1,0)*clhs110; -lhs(5,4)=DN(1,1)*clhs110; -lhs(5,5)=clhs13*(clhs103 + clhs91); -lhs(5,6)=DN(1,0)*clhs85 + clhs102; -lhs(5,7)=DN(1,1)*clhs85 + clhs109; -lhs(5,8)=clhs111; -lhs(6,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + clhs114 + clhs53; -lhs(6,1)=DN(2,0)*clhs20 + DN(2,1)*clhs22 + clhs75; -lhs(6,2)=DN(0,0)*clhs115 + clhs46*clhs61 - clhs62; -lhs(6,3)=DN(2,0)*clhs29 + DN(2,1)*clhs31 + clhs116 + clhs98; -lhs(6,4)=DN(2,0)*clhs40 + DN(2,1)*clhs42 + clhs105; -lhs(6,5)=DN(1,0)*clhs115 + clhs101*clhs46 - clhs102; -lhs(6,6)=DN(2,0)*clhs47 + DN(2,1)*clhs49 + clhs117*clhs7 + clhs118; -lhs(6,7)=DN(2,0)*clhs57 + DN(2,1)*clhs59 + clhs119; -lhs(6,8)=DN(2,0)*clhs120; -lhs(7,0)=DN(2,0)*clhs2 + DN(2,1)*clhs63 + clhs60; -lhs(7,1)=DN(2,0)*clhs22 + DN(2,1)*clhs64 + clhs114 + clhs78; -lhs(7,2)=DN(0,1)*clhs115 + clhs46*clhs79 - clhs80; -lhs(7,3)=DN(2,0)*clhs31 + DN(2,1)*clhs66 + clhs100; -lhs(7,4)=DN(2,0)*clhs42 + DN(2,1)*clhs69 + clhs107 + clhs116; -lhs(7,5)=DN(1,1)*clhs115 + clhs108*clhs46 - clhs109; -lhs(7,6)=DN(2,0)*clhs49 + DN(2,1)*clhs74 + clhs119; -lhs(7,7)=DN(2,0)*clhs59 + DN(2,1)*clhs76 + clhs118 + clhs121*clhs7; -lhs(7,8)=DN(2,1)*clhs120; -lhs(8,0)=DN(2,0)*clhs81 + clhs61; -lhs(8,1)=DN(2,1)*clhs81 + clhs79; -lhs(8,2)=clhs86; -lhs(8,3)=DN(2,0)*clhs83 + clhs101; -lhs(8,4)=DN(2,1)*clhs83 + clhs108; -lhs(8,5)=clhs111; -lhs(8,6)=DN(2,0)*clhs122; -lhs(8,7)=DN(2,1)*clhs122; -lhs(8,8)=clhs13*(clhs117 + clhs121); - - - // Add intermediate results to local system - noalias(rLHS) += lhs * rData.Weight; + // Add LHS Gauss point contribution + const double w_gauss = rData.Weight; + + const double crLHS0 = C(0,0)*DN(0,0) + C(0,2)*DN(0,1); +const double crLHS1 = C(0,2)*DN(0,0); +const double crLHS2 = C(2,2)*DN(0,1) + crLHS1; +const double crLHS3 = DN(0,0)*DN(0,0); +const double crLHS4 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crLHS5 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crLHS6 = rho*stab_c2*sqrt(crLHS4*crLHS4 + crLHS5*crLHS5); +const double crLHS7 = crLHS6*h*1.0/stab_c1 + mu; +const double crLHS8 = DN(0,0)*crLHS4 + DN(0,1)*crLHS5; +const double crLHS9 = N[0]*rho; +const double crLHS10 = bdf0*rho; +const double crLHS11 = N[0]*bdf0; +const double crLHS12 = crLHS11 + crLHS8; +const double crLHS13 = 1.0*1.0/(crLHS6*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); +const double crLHS14 = crLHS13*(rho*rho); +const double crLHS15 = crLHS14*crLHS8; +const double crLHS16 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); +const double crLHS17 = crLHS14*crLHS16; +const double crLHS18 = N[0]*crLHS17; +const double crLHS19 = crLHS10*(N[0]*N[0]) + crLHS12*crLHS15 + crLHS12*crLHS18 + crLHS8*crLHS9; +const double crLHS20 = C(0,1)*DN(0,1) + crLHS1; +const double crLHS21 = C(1,2)*DN(0,1); +const double crLHS22 = C(2,2)*DN(0,0) + crLHS21; +const double crLHS23 = DN(0,0)*crLHS7; +const double crLHS24 = DN(0,1)*crLHS23; +const double crLHS25 = crLHS13*crLHS16; +const double crLHS26 = crLHS13*rho; +const double crLHS27 = crLHS26*crLHS8; +const double crLHS28 = w_gauss*(-N[0] + crLHS25*crLHS9 + crLHS27); +const double crLHS29 = C(0,0)*DN(1,0) + C(0,2)*DN(1,1); +const double crLHS30 = C(0,2)*DN(1,0); +const double crLHS31 = C(2,2)*DN(1,1) + crLHS30; +const double crLHS32 = DN(0,0)*DN(1,0); +const double crLHS33 = N[1]*rho; +const double crLHS34 = crLHS11*crLHS33; +const double crLHS35 = crLHS32*crLHS7 + crLHS34; +const double crLHS36 = DN(1,0)*crLHS4 + DN(1,1)*crLHS5; +const double crLHS37 = N[1]*bdf0; +const double crLHS38 = crLHS36 + crLHS37; +const double crLHS39 = crLHS15*crLHS38 + crLHS18*crLHS38 + crLHS36*crLHS9; +const double crLHS40 = C(0,1)*DN(1,1) + crLHS30; +const double crLHS41 = C(1,2)*DN(1,1); +const double crLHS42 = C(2,2)*DN(1,0) + crLHS41; +const double crLHS43 = DN(1,1)*crLHS23; +const double crLHS44 = DN(0,0)*N[1]; +const double crLHS45 = DN(1,0)*N[0]; +const double crLHS46 = crLHS16*crLHS26; +const double crLHS47 = C(0,0)*DN(2,0) + C(0,2)*DN(2,1); +const double crLHS48 = C(0,2)*DN(2,0); +const double crLHS49 = C(2,2)*DN(2,1) + crLHS48; +const double crLHS50 = DN(0,0)*DN(2,0); +const double crLHS51 = N[2]*rho; +const double crLHS52 = crLHS11*crLHS51; +const double crLHS53 = crLHS50*crLHS7 + crLHS52; +const double crLHS54 = DN(2,0)*crLHS4 + DN(2,1)*crLHS5; +const double crLHS55 = N[2]*bdf0 + crLHS54; +const double crLHS56 = crLHS15*crLHS55 + crLHS18*crLHS55 + crLHS54*crLHS9; +const double crLHS57 = C(0,1)*DN(2,1) + crLHS48; +const double crLHS58 = C(1,2)*DN(2,1); +const double crLHS59 = C(2,2)*DN(2,0) + crLHS58; +const double crLHS60 = DN(2,1)*crLHS23; +const double crLHS61 = DN(0,0)*N[2]; +const double crLHS62 = DN(2,0)*N[0]; +const double crLHS63 = C(0,1)*DN(0,0) + crLHS21; +const double crLHS64 = C(1,1)*DN(0,1) + C(1,2)*DN(0,0); +const double crLHS65 = DN(0,1)*DN(0,1); +const double crLHS66 = C(0,1)*DN(1,0) + crLHS41; +const double crLHS67 = DN(0,1)*crLHS7; +const double crLHS68 = DN(1,0)*crLHS67; +const double crLHS69 = C(1,1)*DN(1,1) + C(1,2)*DN(1,0); +const double crLHS70 = DN(0,1)*DN(1,1); +const double crLHS71 = crLHS34 + crLHS7*crLHS70; +const double crLHS72 = DN(0,1)*N[1]; +const double crLHS73 = DN(1,1)*N[0]; +const double crLHS74 = C(0,1)*DN(2,0) + crLHS58; +const double crLHS75 = DN(2,0)*crLHS67; +const double crLHS76 = C(1,1)*DN(2,1) + C(1,2)*DN(2,0); +const double crLHS77 = DN(0,1)*DN(2,1); +const double crLHS78 = crLHS52 + crLHS7*crLHS77; +const double crLHS79 = DN(0,1)*N[2]; +const double crLHS80 = DN(2,1)*N[0]; +const double crLHS81 = crLHS12*crLHS26; +const double crLHS82 = w_gauss*(N[0] + crLHS81); +const double crLHS83 = crLHS13*w_gauss; +const double crLHS84 = crLHS26*crLHS38; +const double crLHS85 = crLHS83*(crLHS32 + crLHS70); +const double crLHS86 = crLHS26*crLHS55; +const double crLHS87 = crLHS83*(crLHS50 + crLHS77); +const double crLHS88 = crLHS14*crLHS36; +const double crLHS89 = N[1]*crLHS17; +const double crLHS90 = crLHS12*crLHS88 + crLHS12*crLHS89 + crLHS33*crLHS8; +const double crLHS91 = crLHS26*crLHS36; +const double crLHS92 = DN(1,0)*DN(1,0); +const double crLHS93 = crLHS10*(N[1]*N[1]) + crLHS33*crLHS36 + crLHS38*crLHS88 + crLHS38*crLHS89; +const double crLHS94 = DN(1,0)*crLHS7; +const double crLHS95 = DN(1,1)*crLHS94; +const double crLHS96 = w_gauss*(-N[1] + crLHS25*crLHS33 + crLHS91); +const double crLHS97 = DN(1,0)*DN(2,0); +const double crLHS98 = crLHS37*crLHS51; +const double crLHS99 = crLHS7*crLHS97 + crLHS98; +const double crLHS100 = crLHS33*crLHS54 + crLHS55*crLHS88 + crLHS55*crLHS89; +const double crLHS101 = DN(2,1)*crLHS94; +const double crLHS102 = DN(1,0)*N[2]; +const double crLHS103 = DN(2,0)*N[1]; +const double crLHS104 = DN(1,1)*DN(1,1); +const double crLHS105 = DN(2,0)*crLHS7; +const double crLHS106 = DN(1,1)*crLHS105; +const double crLHS107 = DN(1,1)*DN(2,1); +const double crLHS108 = crLHS107*crLHS7 + crLHS98; +const double crLHS109 = DN(1,1)*N[2]; +const double crLHS110 = DN(2,1)*N[1]; +const double crLHS111 = w_gauss*(N[1] + crLHS84); +const double crLHS112 = crLHS83*(crLHS107 + crLHS97); +const double crLHS113 = crLHS14*crLHS54; +const double crLHS114 = N[2]*crLHS17; +const double crLHS115 = crLHS113*crLHS12 + crLHS114*crLHS12 + crLHS51*crLHS8; +const double crLHS116 = crLHS26*crLHS54; +const double crLHS117 = crLHS113*crLHS38 + crLHS114*crLHS38 + crLHS36*crLHS51; +const double crLHS118 = DN(2,0)*DN(2,0); +const double crLHS119 = crLHS10*(N[2]*N[2]) + crLHS113*crLHS55 + crLHS114*crLHS55 + crLHS51*crLHS54; +const double crLHS120 = DN(2,1)*crLHS105; +const double crLHS121 = w_gauss*(-N[2] + crLHS116 + crLHS25*crLHS51); +const double crLHS122 = DN(2,1)*DN(2,1); +const double crLHS123 = w_gauss*(N[2] + crLHS86); +rLHS(0,0)+=w_gauss*(DN(0,0)*crLHS0 + DN(0,1)*crLHS2 + crLHS19 + crLHS3*crLHS7); +rLHS(0,1)+=w_gauss*(DN(0,0)*crLHS20 + DN(0,1)*crLHS22 + crLHS24); +rLHS(0,2)+=DN(0,0)*crLHS28; +rLHS(0,3)+=w_gauss*(DN(0,0)*crLHS29 + DN(0,1)*crLHS31 + crLHS35 + crLHS39); +rLHS(0,4)+=w_gauss*(DN(0,0)*crLHS40 + DN(0,1)*crLHS42 + crLHS43); +rLHS(0,5)+=w_gauss*(DN(1,0)*crLHS27 - crLHS44 + crLHS45*crLHS46); +rLHS(0,6)+=w_gauss*(DN(0,0)*crLHS47 + DN(0,1)*crLHS49 + crLHS53 + crLHS56); +rLHS(0,7)+=w_gauss*(DN(0,0)*crLHS57 + DN(0,1)*crLHS59 + crLHS60); +rLHS(0,8)+=w_gauss*(DN(2,0)*crLHS27 + crLHS46*crLHS62 - crLHS61); +rLHS(1,0)+=w_gauss*(DN(0,0)*crLHS2 + DN(0,1)*crLHS63 + crLHS24); +rLHS(1,1)+=w_gauss*(DN(0,0)*crLHS22 + DN(0,1)*crLHS64 + crLHS19 + crLHS65*crLHS7); +rLHS(1,2)+=DN(0,1)*crLHS28; +rLHS(1,3)+=w_gauss*(DN(0,0)*crLHS31 + DN(0,1)*crLHS66 + crLHS68); +rLHS(1,4)+=w_gauss*(DN(0,0)*crLHS42 + DN(0,1)*crLHS69 + crLHS39 + crLHS71); +rLHS(1,5)+=w_gauss*(DN(1,1)*crLHS27 + crLHS46*crLHS73 - crLHS72); +rLHS(1,6)+=w_gauss*(DN(0,0)*crLHS49 + DN(0,1)*crLHS74 + crLHS75); +rLHS(1,7)+=w_gauss*(DN(0,0)*crLHS59 + DN(0,1)*crLHS76 + crLHS56 + crLHS78); +rLHS(1,8)+=w_gauss*(DN(2,1)*crLHS27 + crLHS46*crLHS80 - crLHS79); +rLHS(2,0)+=DN(0,0)*crLHS82; +rLHS(2,1)+=DN(0,1)*crLHS82; +rLHS(2,2)+=crLHS83*(crLHS3 + crLHS65); +rLHS(2,3)+=w_gauss*(DN(0,0)*crLHS84 + crLHS45); +rLHS(2,4)+=w_gauss*(DN(0,1)*crLHS84 + crLHS73); +rLHS(2,5)+=crLHS85; +rLHS(2,6)+=w_gauss*(DN(0,0)*crLHS86 + crLHS62); +rLHS(2,7)+=w_gauss*(DN(0,1)*crLHS86 + crLHS80); +rLHS(2,8)+=crLHS87; +rLHS(3,0)+=w_gauss*(DN(1,0)*crLHS0 + DN(1,1)*crLHS2 + crLHS35 + crLHS90); +rLHS(3,1)+=w_gauss*(DN(1,0)*crLHS20 + DN(1,1)*crLHS22 + crLHS68); +rLHS(3,2)+=w_gauss*(DN(0,0)*crLHS91 + crLHS44*crLHS46 - crLHS45); +rLHS(3,3)+=w_gauss*(DN(1,0)*crLHS29 + DN(1,1)*crLHS31 + crLHS7*crLHS92 + crLHS93); +rLHS(3,4)+=w_gauss*(DN(1,0)*crLHS40 + DN(1,1)*crLHS42 + crLHS95); +rLHS(3,5)+=DN(1,0)*crLHS96; +rLHS(3,6)+=w_gauss*(DN(1,0)*crLHS47 + DN(1,1)*crLHS49 + crLHS100 + crLHS99); +rLHS(3,7)+=w_gauss*(DN(1,0)*crLHS57 + DN(1,1)*crLHS59 + crLHS101); +rLHS(3,8)+=w_gauss*(DN(2,0)*crLHS91 - crLHS102 + crLHS103*crLHS46); +rLHS(4,0)+=w_gauss*(DN(1,0)*crLHS2 + DN(1,1)*crLHS63 + crLHS43); +rLHS(4,1)+=w_gauss*(DN(1,0)*crLHS22 + DN(1,1)*crLHS64 + crLHS71 + crLHS90); +rLHS(4,2)+=w_gauss*(DN(0,1)*crLHS91 + crLHS46*crLHS72 - crLHS73); +rLHS(4,3)+=w_gauss*(DN(1,0)*crLHS31 + DN(1,1)*crLHS66 + crLHS95); +rLHS(4,4)+=w_gauss*(DN(1,0)*crLHS42 + DN(1,1)*crLHS69 + crLHS104*crLHS7 + crLHS93); +rLHS(4,5)+=DN(1,1)*crLHS96; +rLHS(4,6)+=w_gauss*(DN(1,0)*crLHS49 + DN(1,1)*crLHS74 + crLHS106); +rLHS(4,7)+=w_gauss*(DN(1,0)*crLHS59 + DN(1,1)*crLHS76 + crLHS100 + crLHS108); +rLHS(4,8)+=w_gauss*(DN(2,1)*crLHS91 - crLHS109 + crLHS110*crLHS46); +rLHS(5,0)+=w_gauss*(DN(1,0)*crLHS81 + crLHS44); +rLHS(5,1)+=w_gauss*(DN(1,1)*crLHS81 + crLHS72); +rLHS(5,2)+=crLHS85; +rLHS(5,3)+=DN(1,0)*crLHS111; +rLHS(5,4)+=DN(1,1)*crLHS111; +rLHS(5,5)+=crLHS83*(crLHS104 + crLHS92); +rLHS(5,6)+=w_gauss*(DN(1,0)*crLHS86 + crLHS103); +rLHS(5,7)+=w_gauss*(DN(1,1)*crLHS86 + crLHS110); +rLHS(5,8)+=crLHS112; +rLHS(6,0)+=w_gauss*(DN(2,0)*crLHS0 + DN(2,1)*crLHS2 + crLHS115 + crLHS53); +rLHS(6,1)+=w_gauss*(DN(2,0)*crLHS20 + DN(2,1)*crLHS22 + crLHS75); +rLHS(6,2)+=w_gauss*(DN(0,0)*crLHS116 + crLHS46*crLHS61 - crLHS62); +rLHS(6,3)+=w_gauss*(DN(2,0)*crLHS29 + DN(2,1)*crLHS31 + crLHS117 + crLHS99); +rLHS(6,4)+=w_gauss*(DN(2,0)*crLHS40 + DN(2,1)*crLHS42 + crLHS106); +rLHS(6,5)+=w_gauss*(DN(1,0)*crLHS116 + crLHS102*crLHS46 - crLHS103); +rLHS(6,6)+=w_gauss*(DN(2,0)*crLHS47 + DN(2,1)*crLHS49 + crLHS118*crLHS7 + crLHS119); +rLHS(6,7)+=w_gauss*(DN(2,0)*crLHS57 + DN(2,1)*crLHS59 + crLHS120); +rLHS(6,8)+=DN(2,0)*crLHS121; +rLHS(7,0)+=w_gauss*(DN(2,0)*crLHS2 + DN(2,1)*crLHS63 + crLHS60); +rLHS(7,1)+=w_gauss*(DN(2,0)*crLHS22 + DN(2,1)*crLHS64 + crLHS115 + crLHS78); +rLHS(7,2)+=w_gauss*(DN(0,1)*crLHS116 + crLHS46*crLHS79 - crLHS80); +rLHS(7,3)+=w_gauss*(DN(2,0)*crLHS31 + DN(2,1)*crLHS66 + crLHS101); +rLHS(7,4)+=w_gauss*(DN(2,0)*crLHS42 + DN(2,1)*crLHS69 + crLHS108 + crLHS117); +rLHS(7,5)+=w_gauss*(DN(1,1)*crLHS116 + crLHS109*crLHS46 - crLHS110); +rLHS(7,6)+=w_gauss*(DN(2,0)*crLHS49 + DN(2,1)*crLHS74 + crLHS120); +rLHS(7,7)+=w_gauss*(DN(2,0)*crLHS59 + DN(2,1)*crLHS76 + crLHS119 + crLHS122*crLHS7); +rLHS(7,8)+=DN(2,1)*crLHS121; +rLHS(8,0)+=w_gauss*(DN(2,0)*crLHS81 + crLHS61); +rLHS(8,1)+=w_gauss*(DN(2,1)*crLHS81 + crLHS79); +rLHS(8,2)+=crLHS87; +rLHS(8,3)+=w_gauss*(DN(2,0)*crLHS84 + crLHS102); +rLHS(8,4)+=w_gauss*(DN(2,1)*crLHS84 + crLHS109); +rLHS(8,5)+=crLHS112; +rLHS(8,6)+=DN(2,0)*crLHS123; +rLHS(8,7)+=DN(2,1)*crLHS123; +rLHS(8,8)+=crLHS83*(crLHS118 + crLHS122); + } template <> @@ -591,611 +590,610 @@ void TwoFluidNavierStokesFractional>::C // Get shape function values const auto &N = rData.N; const auto &DN = rData.DN_DX; + + // Add LHS Gauss point contribution + const double w_gauss = rData.Weight; + + const double crLHS0 = C(0,0)*DN(0,0) + C(0,3)*DN(0,1) + C(0,5)*DN(0,2); +const double crLHS1 = C(0,3)*DN(0,0); +const double crLHS2 = C(3,3)*DN(0,1) + C(3,5)*DN(0,2) + crLHS1; +const double crLHS3 = C(0,5)*DN(0,0); +const double crLHS4 = C(3,5)*DN(0,1) + C(5,5)*DN(0,2) + crLHS3; +const double crLHS5 = DN(0,0)*DN(0,0); +const double crLHS6 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crLHS7 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crLHS8 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crLHS9 = rho*stab_c2*sqrt(crLHS6*crLHS6 + crLHS7*crLHS7 + crLHS8*crLHS8); +const double crLHS10 = crLHS9*h*1.0/stab_c1 + mu; +const double crLHS11 = DN(0,0)*crLHS6 + DN(0,1)*crLHS7 + DN(0,2)*crLHS8; +const double crLHS12 = N[0]*rho; +const double crLHS13 = bdf0*rho; +const double crLHS14 = N[0]*bdf0; +const double crLHS15 = crLHS11 + crLHS14; +const double crLHS16 = 1.0*1.0/(crLHS9*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); +const double crLHS17 = crLHS16*(rho*rho); +const double crLHS18 = crLHS11*crLHS17; +const double crLHS19 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); +const double crLHS20 = crLHS17*crLHS19; +const double crLHS21 = N[0]*crLHS20; +const double crLHS22 = crLHS11*crLHS12 + crLHS13*(N[0]*N[0]) + crLHS15*crLHS18 + crLHS15*crLHS21; +const double crLHS23 = C(0,1)*DN(0,1) + C(0,4)*DN(0,2) + crLHS1; +const double crLHS24 = C(1,3)*DN(0,1); +const double crLHS25 = C(3,3)*DN(0,0) + C(3,4)*DN(0,2) + crLHS24; +const double crLHS26 = C(3,5)*DN(0,0); +const double crLHS27 = C(4,5)*DN(0,2); +const double crLHS28 = C(1,5)*DN(0,1) + crLHS26 + crLHS27; +const double crLHS29 = DN(0,0)*crLHS10; +const double crLHS30 = DN(0,1)*crLHS29; +const double crLHS31 = C(0,2)*DN(0,2) + C(0,4)*DN(0,1) + crLHS3; +const double crLHS32 = C(3,4)*DN(0,1); +const double crLHS33 = C(2,3)*DN(0,2) + crLHS26 + crLHS32; +const double crLHS34 = C(2,5)*DN(0,2); +const double crLHS35 = C(4,5)*DN(0,1) + C(5,5)*DN(0,0) + crLHS34; +const double crLHS36 = DN(0,2)*crLHS29; +const double crLHS37 = crLHS16*crLHS19; +const double crLHS38 = crLHS16*rho; +const double crLHS39 = crLHS11*crLHS38; +const double crLHS40 = w_gauss*(-N[0] + crLHS12*crLHS37 + crLHS39); +const double crLHS41 = C(0,0)*DN(1,0) + C(0,3)*DN(1,1) + C(0,5)*DN(1,2); +const double crLHS42 = C(0,3)*DN(1,0); +const double crLHS43 = C(3,3)*DN(1,1) + C(3,5)*DN(1,2) + crLHS42; +const double crLHS44 = C(0,5)*DN(1,0); +const double crLHS45 = C(3,5)*DN(1,1) + C(5,5)*DN(1,2) + crLHS44; +const double crLHS46 = DN(0,0)*DN(1,0); +const double crLHS47 = N[1]*rho; +const double crLHS48 = crLHS14*crLHS47; +const double crLHS49 = crLHS10*crLHS46 + crLHS48; +const double crLHS50 = DN(1,0)*crLHS6 + DN(1,1)*crLHS7 + DN(1,2)*crLHS8; +const double crLHS51 = N[1]*bdf0; +const double crLHS52 = crLHS50 + crLHS51; +const double crLHS53 = crLHS12*crLHS50 + crLHS18*crLHS52 + crLHS21*crLHS52; +const double crLHS54 = C(0,1)*DN(1,1) + C(0,4)*DN(1,2) + crLHS42; +const double crLHS55 = C(1,3)*DN(1,1); +const double crLHS56 = C(3,3)*DN(1,0) + C(3,4)*DN(1,2) + crLHS55; +const double crLHS57 = C(3,5)*DN(1,0); +const double crLHS58 = C(4,5)*DN(1,2); +const double crLHS59 = C(1,5)*DN(1,1) + crLHS57 + crLHS58; +const double crLHS60 = DN(1,1)*crLHS29; +const double crLHS61 = C(0,2)*DN(1,2) + C(0,4)*DN(1,1) + crLHS44; +const double crLHS62 = C(3,4)*DN(1,1); +const double crLHS63 = C(2,3)*DN(1,2) + crLHS57 + crLHS62; +const double crLHS64 = C(2,5)*DN(1,2); +const double crLHS65 = C(4,5)*DN(1,1) + C(5,5)*DN(1,0) + crLHS64; +const double crLHS66 = DN(1,2)*crLHS29; +const double crLHS67 = DN(0,0)*N[1]; +const double crLHS68 = DN(1,0)*N[0]; +const double crLHS69 = crLHS19*crLHS38; +const double crLHS70 = C(0,0)*DN(2,0) + C(0,3)*DN(2,1) + C(0,5)*DN(2,2); +const double crLHS71 = C(0,3)*DN(2,0); +const double crLHS72 = C(3,3)*DN(2,1) + C(3,5)*DN(2,2) + crLHS71; +const double crLHS73 = C(0,5)*DN(2,0); +const double crLHS74 = C(3,5)*DN(2,1) + C(5,5)*DN(2,2) + crLHS73; +const double crLHS75 = DN(0,0)*DN(2,0); +const double crLHS76 = N[2]*rho; +const double crLHS77 = crLHS14*crLHS76; +const double crLHS78 = crLHS10*crLHS75 + crLHS77; +const double crLHS79 = DN(2,0)*crLHS6 + DN(2,1)*crLHS7 + DN(2,2)*crLHS8; +const double crLHS80 = N[2]*bdf0; +const double crLHS81 = crLHS79 + crLHS80; +const double crLHS82 = crLHS12*crLHS79 + crLHS18*crLHS81 + crLHS21*crLHS81; +const double crLHS83 = C(0,1)*DN(2,1) + C(0,4)*DN(2,2) + crLHS71; +const double crLHS84 = C(1,3)*DN(2,1); +const double crLHS85 = C(3,3)*DN(2,0) + C(3,4)*DN(2,2) + crLHS84; +const double crLHS86 = C(3,5)*DN(2,0); +const double crLHS87 = C(4,5)*DN(2,2); +const double crLHS88 = C(1,5)*DN(2,1) + crLHS86 + crLHS87; +const double crLHS89 = DN(2,1)*crLHS29; +const double crLHS90 = C(0,2)*DN(2,2) + C(0,4)*DN(2,1) + crLHS73; +const double crLHS91 = C(3,4)*DN(2,1); +const double crLHS92 = C(2,3)*DN(2,2) + crLHS86 + crLHS91; +const double crLHS93 = C(2,5)*DN(2,2); +const double crLHS94 = C(4,5)*DN(2,1) + C(5,5)*DN(2,0) + crLHS93; +const double crLHS95 = DN(2,2)*crLHS29; +const double crLHS96 = DN(0,0)*N[2]; +const double crLHS97 = DN(2,0)*N[0]; +const double crLHS98 = C(0,0)*DN(3,0) + C(0,3)*DN(3,1) + C(0,5)*DN(3,2); +const double crLHS99 = C(0,3)*DN(3,0); +const double crLHS100 = C(3,3)*DN(3,1) + C(3,5)*DN(3,2) + crLHS99; +const double crLHS101 = C(0,5)*DN(3,0); +const double crLHS102 = C(3,5)*DN(3,1) + C(5,5)*DN(3,2) + crLHS101; +const double crLHS103 = DN(0,0)*DN(3,0); +const double crLHS104 = N[3]*rho; +const double crLHS105 = crLHS104*crLHS14; +const double crLHS106 = crLHS10*crLHS103 + crLHS105; +const double crLHS107 = DN(3,0)*crLHS6 + DN(3,1)*crLHS7 + DN(3,2)*crLHS8; +const double crLHS108 = N[3]*bdf0 + crLHS107; +const double crLHS109 = crLHS107*crLHS12 + crLHS108*crLHS18 + crLHS108*crLHS21; +const double crLHS110 = C(0,1)*DN(3,1) + C(0,4)*DN(3,2) + crLHS99; +const double crLHS111 = C(1,3)*DN(3,1); +const double crLHS112 = C(3,3)*DN(3,0) + C(3,4)*DN(3,2) + crLHS111; +const double crLHS113 = C(3,5)*DN(3,0); +const double crLHS114 = C(4,5)*DN(3,2); +const double crLHS115 = C(1,5)*DN(3,1) + crLHS113 + crLHS114; +const double crLHS116 = DN(3,1)*crLHS29; +const double crLHS117 = C(0,2)*DN(3,2) + C(0,4)*DN(3,1) + crLHS101; +const double crLHS118 = C(3,4)*DN(3,1); +const double crLHS119 = C(2,3)*DN(3,2) + crLHS113 + crLHS118; +const double crLHS120 = C(2,5)*DN(3,2); +const double crLHS121 = C(4,5)*DN(3,1) + C(5,5)*DN(3,0) + crLHS120; +const double crLHS122 = DN(3,2)*crLHS29; +const double crLHS123 = DN(0,0)*N[3]; +const double crLHS124 = DN(3,0)*N[0]; +const double crLHS125 = C(0,1)*DN(0,0) + C(1,5)*DN(0,2) + crLHS24; +const double crLHS126 = C(0,4)*DN(0,0) + crLHS27 + crLHS32; +const double crLHS127 = C(1,1)*DN(0,1) + C(1,3)*DN(0,0) + C(1,4)*DN(0,2); +const double crLHS128 = C(1,4)*DN(0,1); +const double crLHS129 = C(3,4)*DN(0,0) + C(4,4)*DN(0,2) + crLHS128; +const double crLHS130 = DN(0,1)*DN(0,1); +const double crLHS131 = C(1,2)*DN(0,2) + C(1,5)*DN(0,0) + crLHS128; +const double crLHS132 = C(2,4)*DN(0,2); +const double crLHS133 = C(4,4)*DN(0,1) + C(4,5)*DN(0,0) + crLHS132; +const double crLHS134 = DN(0,1)*crLHS10; +const double crLHS135 = DN(0,2)*crLHS134; +const double crLHS136 = C(0,1)*DN(1,0) + C(1,5)*DN(1,2) + crLHS55; +const double crLHS137 = C(0,4)*DN(1,0) + crLHS58 + crLHS62; +const double crLHS138 = DN(1,0)*crLHS134; +const double crLHS139 = C(1,1)*DN(1,1) + C(1,3)*DN(1,0) + C(1,4)*DN(1,2); +const double crLHS140 = C(1,4)*DN(1,1); +const double crLHS141 = C(3,4)*DN(1,0) + C(4,4)*DN(1,2) + crLHS140; +const double crLHS142 = DN(0,1)*DN(1,1); +const double crLHS143 = crLHS10*crLHS142; +const double crLHS144 = crLHS48 + crLHS53; +const double crLHS145 = C(1,2)*DN(1,2) + C(1,5)*DN(1,0) + crLHS140; +const double crLHS146 = C(2,4)*DN(1,2); +const double crLHS147 = C(4,4)*DN(1,1) + C(4,5)*DN(1,0) + crLHS146; +const double crLHS148 = DN(1,2)*crLHS134; +const double crLHS149 = DN(0,1)*N[1]; +const double crLHS150 = DN(1,1)*N[0]; +const double crLHS151 = C(0,1)*DN(2,0) + C(1,5)*DN(2,2) + crLHS84; +const double crLHS152 = C(0,4)*DN(2,0) + crLHS87 + crLHS91; +const double crLHS153 = DN(2,0)*crLHS134; +const double crLHS154 = C(1,1)*DN(2,1) + C(1,3)*DN(2,0) + C(1,4)*DN(2,2); +const double crLHS155 = C(1,4)*DN(2,1); +const double crLHS156 = C(3,4)*DN(2,0) + C(4,4)*DN(2,2) + crLHS155; +const double crLHS157 = DN(0,1)*DN(2,1); +const double crLHS158 = crLHS10*crLHS157; +const double crLHS159 = crLHS77 + crLHS82; +const double crLHS160 = C(1,2)*DN(2,2) + C(1,5)*DN(2,0) + crLHS155; +const double crLHS161 = C(2,4)*DN(2,2); +const double crLHS162 = C(4,4)*DN(2,1) + C(4,5)*DN(2,0) + crLHS161; +const double crLHS163 = DN(2,2)*crLHS134; +const double crLHS164 = DN(0,1)*N[2]; +const double crLHS165 = DN(2,1)*N[0]; +const double crLHS166 = C(0,1)*DN(3,0) + C(1,5)*DN(3,2) + crLHS111; +const double crLHS167 = C(0,4)*DN(3,0) + crLHS114 + crLHS118; +const double crLHS168 = DN(3,0)*crLHS134; +const double crLHS169 = C(1,1)*DN(3,1) + C(1,3)*DN(3,0) + C(1,4)*DN(3,2); +const double crLHS170 = C(1,4)*DN(3,1); +const double crLHS171 = C(3,4)*DN(3,0) + C(4,4)*DN(3,2) + crLHS170; +const double crLHS172 = DN(0,1)*DN(3,1); +const double crLHS173 = crLHS10*crLHS172; +const double crLHS174 = crLHS105 + crLHS109; +const double crLHS175 = C(1,2)*DN(3,2) + C(1,5)*DN(3,0) + crLHS170; +const double crLHS176 = C(2,4)*DN(3,2); +const double crLHS177 = C(4,4)*DN(3,1) + C(4,5)*DN(3,0) + crLHS176; +const double crLHS178 = DN(3,2)*crLHS134; +const double crLHS179 = DN(0,1)*N[3]; +const double crLHS180 = DN(3,1)*N[0]; +const double crLHS181 = C(0,2)*DN(0,0) + C(2,3)*DN(0,1) + crLHS34; +const double crLHS182 = C(1,2)*DN(0,1) + C(2,3)*DN(0,0) + crLHS132; +const double crLHS183 = C(2,2)*DN(0,2) + C(2,4)*DN(0,1) + C(2,5)*DN(0,0); +const double crLHS184 = DN(0,2)*DN(0,2); +const double crLHS185 = C(0,2)*DN(1,0) + C(2,3)*DN(1,1) + crLHS64; +const double crLHS186 = DN(0,2)*crLHS10; +const double crLHS187 = DN(1,0)*crLHS186; +const double crLHS188 = C(1,2)*DN(1,1) + C(2,3)*DN(1,0) + crLHS146; +const double crLHS189 = DN(1,1)*crLHS186; +const double crLHS190 = C(2,2)*DN(1,2) + C(2,4)*DN(1,1) + C(2,5)*DN(1,0); +const double crLHS191 = DN(0,2)*DN(1,2); +const double crLHS192 = crLHS10*crLHS191; +const double crLHS193 = DN(0,2)*N[1]; +const double crLHS194 = DN(1,2)*N[0]; +const double crLHS195 = C(0,2)*DN(2,0) + C(2,3)*DN(2,1) + crLHS93; +const double crLHS196 = DN(2,0)*crLHS186; +const double crLHS197 = C(1,2)*DN(2,1) + C(2,3)*DN(2,0) + crLHS161; +const double crLHS198 = DN(2,1)*crLHS186; +const double crLHS199 = C(2,2)*DN(2,2) + C(2,4)*DN(2,1) + C(2,5)*DN(2,0); +const double crLHS200 = DN(0,2)*DN(2,2); +const double crLHS201 = crLHS10*crLHS200; +const double crLHS202 = DN(0,2)*N[2]; +const double crLHS203 = DN(2,2)*N[0]; +const double crLHS204 = C(0,2)*DN(3,0) + C(2,3)*DN(3,1) + crLHS120; +const double crLHS205 = DN(3,0)*crLHS186; +const double crLHS206 = C(1,2)*DN(3,1) + C(2,3)*DN(3,0) + crLHS176; +const double crLHS207 = DN(3,1)*crLHS186; +const double crLHS208 = C(2,2)*DN(3,2) + C(2,4)*DN(3,1) + C(2,5)*DN(3,0); +const double crLHS209 = DN(0,2)*DN(3,2); +const double crLHS210 = crLHS10*crLHS209; +const double crLHS211 = DN(0,2)*N[3]; +const double crLHS212 = DN(3,2)*N[0]; +const double crLHS213 = crLHS15*crLHS38; +const double crLHS214 = w_gauss*(N[0] + crLHS213); +const double crLHS215 = crLHS16*w_gauss; +const double crLHS216 = crLHS38*crLHS52; +const double crLHS217 = crLHS215*(crLHS142 + crLHS191 + crLHS46); +const double crLHS218 = crLHS38*crLHS81; +const double crLHS219 = crLHS215*(crLHS157 + crLHS200 + crLHS75); +const double crLHS220 = crLHS108*crLHS38; +const double crLHS221 = crLHS215*(crLHS103 + crLHS172 + crLHS209); +const double crLHS222 = crLHS17*crLHS50; +const double crLHS223 = N[1]*crLHS20; +const double crLHS224 = crLHS11*crLHS47 + crLHS15*crLHS222 + crLHS15*crLHS223; +const double crLHS225 = crLHS38*crLHS50; +const double crLHS226 = DN(1,0)*DN(1,0); +const double crLHS227 = crLHS13*(N[1]*N[1]) + crLHS222*crLHS52 + crLHS223*crLHS52 + crLHS47*crLHS50; +const double crLHS228 = DN(1,0)*crLHS10; +const double crLHS229 = DN(1,1)*crLHS228; +const double crLHS230 = DN(1,2)*crLHS228; +const double crLHS231 = w_gauss*(-N[1] + crLHS225 + crLHS37*crLHS47); +const double crLHS232 = DN(1,0)*DN(2,0); +const double crLHS233 = crLHS51*crLHS76; +const double crLHS234 = crLHS10*crLHS232 + crLHS233; +const double crLHS235 = crLHS222*crLHS81 + crLHS223*crLHS81 + crLHS47*crLHS79; +const double crLHS236 = DN(2,1)*crLHS228; +const double crLHS237 = DN(2,2)*crLHS228; +const double crLHS238 = DN(1,0)*N[2]; +const double crLHS239 = DN(2,0)*N[1]; +const double crLHS240 = DN(1,0)*DN(3,0); +const double crLHS241 = crLHS104*crLHS51; +const double crLHS242 = crLHS10*crLHS240 + crLHS241; +const double crLHS243 = crLHS107*crLHS47 + crLHS108*crLHS222 + crLHS108*crLHS223; +const double crLHS244 = DN(3,1)*crLHS228; +const double crLHS245 = DN(3,2)*crLHS228; +const double crLHS246 = DN(1,0)*N[3]; +const double crLHS247 = DN(3,0)*N[1]; +const double crLHS248 = crLHS224 + crLHS48; +const double crLHS249 = DN(1,1)*DN(1,1); +const double crLHS250 = DN(1,1)*crLHS10; +const double crLHS251 = DN(1,2)*crLHS250; +const double crLHS252 = DN(2,0)*crLHS250; +const double crLHS253 = DN(1,1)*DN(2,1); +const double crLHS254 = crLHS10*crLHS253; +const double crLHS255 = crLHS233 + crLHS235; +const double crLHS256 = DN(2,2)*crLHS250; +const double crLHS257 = DN(1,1)*N[2]; +const double crLHS258 = DN(2,1)*N[1]; +const double crLHS259 = DN(3,0)*crLHS250; +const double crLHS260 = DN(1,1)*DN(3,1); +const double crLHS261 = crLHS10*crLHS260; +const double crLHS262 = crLHS241 + crLHS243; +const double crLHS263 = DN(3,2)*crLHS250; +const double crLHS264 = DN(1,1)*N[3]; +const double crLHS265 = DN(3,1)*N[1]; +const double crLHS266 = DN(1,2)*DN(1,2); +const double crLHS267 = DN(1,2)*crLHS10; +const double crLHS268 = DN(2,0)*crLHS267; +const double crLHS269 = DN(2,1)*crLHS267; +const double crLHS270 = DN(1,2)*DN(2,2); +const double crLHS271 = crLHS10*crLHS270; +const double crLHS272 = DN(1,2)*N[2]; +const double crLHS273 = DN(2,2)*N[1]; +const double crLHS274 = DN(3,0)*crLHS267; +const double crLHS275 = DN(3,1)*crLHS267; +const double crLHS276 = DN(1,2)*DN(3,2); +const double crLHS277 = crLHS10*crLHS276; +const double crLHS278 = DN(1,2)*N[3]; +const double crLHS279 = DN(3,2)*N[1]; +const double crLHS280 = w_gauss*(N[1] + crLHS216); +const double crLHS281 = crLHS215*(crLHS232 + crLHS253 + crLHS270); +const double crLHS282 = crLHS215*(crLHS240 + crLHS260 + crLHS276); +const double crLHS283 = crLHS17*crLHS79; +const double crLHS284 = N[2]*crLHS20; +const double crLHS285 = crLHS11*crLHS76 + crLHS15*crLHS283 + crLHS15*crLHS284; +const double crLHS286 = crLHS38*crLHS79; +const double crLHS287 = crLHS283*crLHS52 + crLHS284*crLHS52 + crLHS50*crLHS76; +const double crLHS288 = DN(2,0)*DN(2,0); +const double crLHS289 = crLHS13*(N[2]*N[2]) + crLHS283*crLHS81 + crLHS284*crLHS81 + crLHS76*crLHS79; +const double crLHS290 = DN(2,0)*crLHS10; +const double crLHS291 = DN(2,1)*crLHS290; +const double crLHS292 = DN(2,2)*crLHS290; +const double crLHS293 = w_gauss*(-N[2] + crLHS286 + crLHS37*crLHS76); +const double crLHS294 = DN(2,0)*DN(3,0); +const double crLHS295 = crLHS104*crLHS80; +const double crLHS296 = crLHS10*crLHS294 + crLHS295; +const double crLHS297 = crLHS107*crLHS76 + crLHS108*crLHS283 + crLHS108*crLHS284; +const double crLHS298 = DN(3,1)*crLHS290; +const double crLHS299 = DN(3,2)*crLHS290; +const double crLHS300 = DN(2,0)*N[3]; +const double crLHS301 = DN(3,0)*N[2]; +const double crLHS302 = crLHS285 + crLHS77; +const double crLHS303 = crLHS233 + crLHS287; +const double crLHS304 = DN(2,1)*DN(2,1); +const double crLHS305 = DN(2,1)*crLHS10; +const double crLHS306 = DN(2,2)*crLHS305; +const double crLHS307 = DN(3,0)*crLHS305; +const double crLHS308 = DN(2,1)*DN(3,1); +const double crLHS309 = crLHS10*crLHS308; +const double crLHS310 = crLHS295 + crLHS297; +const double crLHS311 = DN(3,2)*crLHS305; +const double crLHS312 = DN(2,1)*N[3]; +const double crLHS313 = DN(3,1)*N[2]; +const double crLHS314 = DN(2,2)*DN(2,2); +const double crLHS315 = DN(2,2)*crLHS10; +const double crLHS316 = DN(3,0)*crLHS315; +const double crLHS317 = DN(3,1)*crLHS315; +const double crLHS318 = DN(2,2)*DN(3,2); +const double crLHS319 = crLHS10*crLHS318; +const double crLHS320 = DN(2,2)*N[3]; +const double crLHS321 = DN(3,2)*N[2]; +const double crLHS322 = w_gauss*(N[2] + crLHS218); +const double crLHS323 = crLHS215*(crLHS294 + crLHS308 + crLHS318); +const double crLHS324 = crLHS107*crLHS17; +const double crLHS325 = N[3]*crLHS20; +const double crLHS326 = crLHS104*crLHS11 + crLHS15*crLHS324 + crLHS15*crLHS325; +const double crLHS327 = crLHS107*crLHS38; +const double crLHS328 = crLHS104*crLHS50 + crLHS324*crLHS52 + crLHS325*crLHS52; +const double crLHS329 = crLHS104*crLHS79 + crLHS324*crLHS81 + crLHS325*crLHS81; +const double crLHS330 = DN(3,0)*DN(3,0); +const double crLHS331 = crLHS104*crLHS107 + crLHS108*crLHS324 + crLHS108*crLHS325 + crLHS13*(N[3]*N[3]); +const double crLHS332 = DN(3,0)*crLHS10; +const double crLHS333 = DN(3,1)*crLHS332; +const double crLHS334 = DN(3,2)*crLHS332; +const double crLHS335 = w_gauss*(-N[3] + crLHS104*crLHS37 + crLHS327); +const double crLHS336 = crLHS105 + crLHS326; +const double crLHS337 = crLHS241 + crLHS328; +const double crLHS338 = crLHS295 + crLHS329; +const double crLHS339 = DN(3,1)*DN(3,1); +const double crLHS340 = DN(3,1)*DN(3,2)*crLHS10; +const double crLHS341 = DN(3,2)*DN(3,2); +const double crLHS342 = w_gauss*(N[3] + crLHS220); +rLHS(0,0)+=w_gauss*(DN(0,0)*crLHS0 + DN(0,1)*crLHS2 + DN(0,2)*crLHS4 + crLHS10*crLHS5 + crLHS22); +rLHS(0,1)+=w_gauss*(DN(0,0)*crLHS23 + DN(0,1)*crLHS25 + DN(0,2)*crLHS28 + crLHS30); +rLHS(0,2)+=w_gauss*(DN(0,0)*crLHS31 + DN(0,1)*crLHS33 + DN(0,2)*crLHS35 + crLHS36); +rLHS(0,3)+=DN(0,0)*crLHS40; +rLHS(0,4)+=w_gauss*(DN(0,0)*crLHS41 + DN(0,1)*crLHS43 + DN(0,2)*crLHS45 + crLHS49 + crLHS53); +rLHS(0,5)+=w_gauss*(DN(0,0)*crLHS54 + DN(0,1)*crLHS56 + DN(0,2)*crLHS59 + crLHS60); +rLHS(0,6)+=w_gauss*(DN(0,0)*crLHS61 + DN(0,1)*crLHS63 + DN(0,2)*crLHS65 + crLHS66); +rLHS(0,7)+=w_gauss*(DN(1,0)*crLHS39 - crLHS67 + crLHS68*crLHS69); +rLHS(0,8)+=w_gauss*(DN(0,0)*crLHS70 + DN(0,1)*crLHS72 + DN(0,2)*crLHS74 + crLHS78 + crLHS82); +rLHS(0,9)+=w_gauss*(DN(0,0)*crLHS83 + DN(0,1)*crLHS85 + DN(0,2)*crLHS88 + crLHS89); +rLHS(0,10)+=w_gauss*(DN(0,0)*crLHS90 + DN(0,1)*crLHS92 + DN(0,2)*crLHS94 + crLHS95); +rLHS(0,11)+=w_gauss*(DN(2,0)*crLHS39 + crLHS69*crLHS97 - crLHS96); +rLHS(0,12)+=w_gauss*(DN(0,0)*crLHS98 + DN(0,1)*crLHS100 + DN(0,2)*crLHS102 + crLHS106 + crLHS109); +rLHS(0,13)+=w_gauss*(DN(0,0)*crLHS110 + DN(0,1)*crLHS112 + DN(0,2)*crLHS115 + crLHS116); +rLHS(0,14)+=w_gauss*(DN(0,0)*crLHS117 + DN(0,1)*crLHS119 + DN(0,2)*crLHS121 + crLHS122); +rLHS(0,15)+=w_gauss*(DN(3,0)*crLHS39 - crLHS123 + crLHS124*crLHS69); +rLHS(1,0)+=w_gauss*(DN(0,0)*crLHS2 + DN(0,1)*crLHS125 + DN(0,2)*crLHS126 + crLHS30); +rLHS(1,1)+=w_gauss*(DN(0,0)*crLHS25 + DN(0,1)*crLHS127 + DN(0,2)*crLHS129 + crLHS10*crLHS130 + crLHS22); +rLHS(1,2)+=w_gauss*(DN(0,0)*crLHS33 + DN(0,1)*crLHS131 + DN(0,2)*crLHS133 + crLHS135); +rLHS(1,3)+=DN(0,1)*crLHS40; +rLHS(1,4)+=w_gauss*(DN(0,0)*crLHS43 + DN(0,1)*crLHS136 + DN(0,2)*crLHS137 + crLHS138); +rLHS(1,5)+=w_gauss*(DN(0,0)*crLHS56 + DN(0,1)*crLHS139 + DN(0,2)*crLHS141 + crLHS143 + crLHS144); +rLHS(1,6)+=w_gauss*(DN(0,0)*crLHS63 + DN(0,1)*crLHS145 + DN(0,2)*crLHS147 + crLHS148); +rLHS(1,7)+=w_gauss*(DN(1,1)*crLHS39 - crLHS149 + crLHS150*crLHS69); +rLHS(1,8)+=w_gauss*(DN(0,0)*crLHS72 + DN(0,1)*crLHS151 + DN(0,2)*crLHS152 + crLHS153); +rLHS(1,9)+=w_gauss*(DN(0,0)*crLHS85 + DN(0,1)*crLHS154 + DN(0,2)*crLHS156 + crLHS158 + crLHS159); +rLHS(1,10)+=w_gauss*(DN(0,0)*crLHS92 + DN(0,1)*crLHS160 + DN(0,2)*crLHS162 + crLHS163); +rLHS(1,11)+=w_gauss*(DN(2,1)*crLHS39 - crLHS164 + crLHS165*crLHS69); +rLHS(1,12)+=w_gauss*(DN(0,0)*crLHS100 + DN(0,1)*crLHS166 + DN(0,2)*crLHS167 + crLHS168); +rLHS(1,13)+=w_gauss*(DN(0,0)*crLHS112 + DN(0,1)*crLHS169 + DN(0,2)*crLHS171 + crLHS173 + crLHS174); +rLHS(1,14)+=w_gauss*(DN(0,0)*crLHS119 + DN(0,1)*crLHS175 + DN(0,2)*crLHS177 + crLHS178); +rLHS(1,15)+=w_gauss*(DN(3,1)*crLHS39 - crLHS179 + crLHS180*crLHS69); +rLHS(2,0)+=w_gauss*(DN(0,0)*crLHS4 + DN(0,1)*crLHS126 + DN(0,2)*crLHS181 + crLHS36); +rLHS(2,1)+=w_gauss*(DN(0,0)*crLHS28 + DN(0,1)*crLHS129 + DN(0,2)*crLHS182 + crLHS135); +rLHS(2,2)+=w_gauss*(DN(0,0)*crLHS35 + DN(0,1)*crLHS133 + DN(0,2)*crLHS183 + crLHS10*crLHS184 + crLHS22); +rLHS(2,3)+=DN(0,2)*crLHS40; +rLHS(2,4)+=w_gauss*(DN(0,0)*crLHS45 + DN(0,1)*crLHS137 + DN(0,2)*crLHS185 + crLHS187); +rLHS(2,5)+=w_gauss*(DN(0,0)*crLHS59 + DN(0,1)*crLHS141 + DN(0,2)*crLHS188 + crLHS189); +rLHS(2,6)+=w_gauss*(DN(0,0)*crLHS65 + DN(0,1)*crLHS147 + DN(0,2)*crLHS190 + crLHS144 + crLHS192); +rLHS(2,7)+=w_gauss*(DN(1,2)*crLHS39 - crLHS193 + crLHS194*crLHS69); +rLHS(2,8)+=w_gauss*(DN(0,0)*crLHS74 + DN(0,1)*crLHS152 + DN(0,2)*crLHS195 + crLHS196); +rLHS(2,9)+=w_gauss*(DN(0,0)*crLHS88 + DN(0,1)*crLHS156 + DN(0,2)*crLHS197 + crLHS198); +rLHS(2,10)+=w_gauss*(DN(0,0)*crLHS94 + DN(0,1)*crLHS162 + DN(0,2)*crLHS199 + crLHS159 + crLHS201); +rLHS(2,11)+=w_gauss*(DN(2,2)*crLHS39 - crLHS202 + crLHS203*crLHS69); +rLHS(2,12)+=w_gauss*(DN(0,0)*crLHS102 + DN(0,1)*crLHS167 + DN(0,2)*crLHS204 + crLHS205); +rLHS(2,13)+=w_gauss*(DN(0,0)*crLHS115 + DN(0,1)*crLHS171 + DN(0,2)*crLHS206 + crLHS207); +rLHS(2,14)+=w_gauss*(DN(0,0)*crLHS121 + DN(0,1)*crLHS177 + DN(0,2)*crLHS208 + crLHS174 + crLHS210); +rLHS(2,15)+=w_gauss*(DN(3,2)*crLHS39 - crLHS211 + crLHS212*crLHS69); +rLHS(3,0)+=DN(0,0)*crLHS214; +rLHS(3,1)+=DN(0,1)*crLHS214; +rLHS(3,2)+=DN(0,2)*crLHS214; +rLHS(3,3)+=crLHS215*(crLHS130 + crLHS184 + crLHS5); +rLHS(3,4)+=w_gauss*(DN(0,0)*crLHS216 + crLHS68); +rLHS(3,5)+=w_gauss*(DN(0,1)*crLHS216 + crLHS150); +rLHS(3,6)+=w_gauss*(DN(0,2)*crLHS216 + crLHS194); +rLHS(3,7)+=crLHS217; +rLHS(3,8)+=w_gauss*(DN(0,0)*crLHS218 + crLHS97); +rLHS(3,9)+=w_gauss*(DN(0,1)*crLHS218 + crLHS165); +rLHS(3,10)+=w_gauss*(DN(0,2)*crLHS218 + crLHS203); +rLHS(3,11)+=crLHS219; +rLHS(3,12)+=w_gauss*(DN(0,0)*crLHS220 + crLHS124); +rLHS(3,13)+=w_gauss*(DN(0,1)*crLHS220 + crLHS180); +rLHS(3,14)+=w_gauss*(DN(0,2)*crLHS220 + crLHS212); +rLHS(3,15)+=crLHS221; +rLHS(4,0)+=w_gauss*(DN(1,0)*crLHS0 + DN(1,1)*crLHS2 + DN(1,2)*crLHS4 + crLHS224 + crLHS49); +rLHS(4,1)+=w_gauss*(DN(1,0)*crLHS23 + DN(1,1)*crLHS25 + DN(1,2)*crLHS28 + crLHS138); +rLHS(4,2)+=w_gauss*(DN(1,0)*crLHS31 + DN(1,1)*crLHS33 + DN(1,2)*crLHS35 + crLHS187); +rLHS(4,3)+=w_gauss*(DN(0,0)*crLHS225 + crLHS67*crLHS69 - crLHS68); +rLHS(4,4)+=w_gauss*(DN(1,0)*crLHS41 + DN(1,1)*crLHS43 + DN(1,2)*crLHS45 + crLHS10*crLHS226 + crLHS227); +rLHS(4,5)+=w_gauss*(DN(1,0)*crLHS54 + DN(1,1)*crLHS56 + DN(1,2)*crLHS59 + crLHS229); +rLHS(4,6)+=w_gauss*(DN(1,0)*crLHS61 + DN(1,1)*crLHS63 + DN(1,2)*crLHS65 + crLHS230); +rLHS(4,7)+=DN(1,0)*crLHS231; +rLHS(4,8)+=w_gauss*(DN(1,0)*crLHS70 + DN(1,1)*crLHS72 + DN(1,2)*crLHS74 + crLHS234 + crLHS235); +rLHS(4,9)+=w_gauss*(DN(1,0)*crLHS83 + DN(1,1)*crLHS85 + DN(1,2)*crLHS88 + crLHS236); +rLHS(4,10)+=w_gauss*(DN(1,0)*crLHS90 + DN(1,1)*crLHS92 + DN(1,2)*crLHS94 + crLHS237); +rLHS(4,11)+=w_gauss*(DN(2,0)*crLHS225 - crLHS238 + crLHS239*crLHS69); +rLHS(4,12)+=w_gauss*(DN(1,0)*crLHS98 + DN(1,1)*crLHS100 + DN(1,2)*crLHS102 + crLHS242 + crLHS243); +rLHS(4,13)+=w_gauss*(DN(1,0)*crLHS110 + DN(1,1)*crLHS112 + DN(1,2)*crLHS115 + crLHS244); +rLHS(4,14)+=w_gauss*(DN(1,0)*crLHS117 + DN(1,1)*crLHS119 + DN(1,2)*crLHS121 + crLHS245); +rLHS(4,15)+=w_gauss*(DN(3,0)*crLHS225 - crLHS246 + crLHS247*crLHS69); +rLHS(5,0)+=w_gauss*(DN(1,0)*crLHS2 + DN(1,1)*crLHS125 + DN(1,2)*crLHS126 + crLHS60); +rLHS(5,1)+=w_gauss*(DN(1,0)*crLHS25 + DN(1,1)*crLHS127 + DN(1,2)*crLHS129 + crLHS143 + crLHS248); +rLHS(5,2)+=w_gauss*(DN(1,0)*crLHS33 + DN(1,1)*crLHS131 + DN(1,2)*crLHS133 + crLHS189); +rLHS(5,3)+=w_gauss*(DN(0,1)*crLHS225 + crLHS149*crLHS69 - crLHS150); +rLHS(5,4)+=w_gauss*(DN(1,0)*crLHS43 + DN(1,1)*crLHS136 + DN(1,2)*crLHS137 + crLHS229); +rLHS(5,5)+=w_gauss*(DN(1,0)*crLHS56 + DN(1,1)*crLHS139 + DN(1,2)*crLHS141 + crLHS10*crLHS249 + crLHS227); +rLHS(5,6)+=w_gauss*(DN(1,0)*crLHS63 + DN(1,1)*crLHS145 + DN(1,2)*crLHS147 + crLHS251); +rLHS(5,7)+=DN(1,1)*crLHS231; +rLHS(5,8)+=w_gauss*(DN(1,0)*crLHS72 + DN(1,1)*crLHS151 + DN(1,2)*crLHS152 + crLHS252); +rLHS(5,9)+=w_gauss*(DN(1,0)*crLHS85 + DN(1,1)*crLHS154 + DN(1,2)*crLHS156 + crLHS254 + crLHS255); +rLHS(5,10)+=w_gauss*(DN(1,0)*crLHS92 + DN(1,1)*crLHS160 + DN(1,2)*crLHS162 + crLHS256); +rLHS(5,11)+=w_gauss*(DN(2,1)*crLHS225 - crLHS257 + crLHS258*crLHS69); +rLHS(5,12)+=w_gauss*(DN(1,0)*crLHS100 + DN(1,1)*crLHS166 + DN(1,2)*crLHS167 + crLHS259); +rLHS(5,13)+=w_gauss*(DN(1,0)*crLHS112 + DN(1,1)*crLHS169 + DN(1,2)*crLHS171 + crLHS261 + crLHS262); +rLHS(5,14)+=w_gauss*(DN(1,0)*crLHS119 + DN(1,1)*crLHS175 + DN(1,2)*crLHS177 + crLHS263); +rLHS(5,15)+=w_gauss*(DN(3,1)*crLHS225 - crLHS264 + crLHS265*crLHS69); +rLHS(6,0)+=w_gauss*(DN(1,0)*crLHS4 + DN(1,1)*crLHS126 + DN(1,2)*crLHS181 + crLHS66); +rLHS(6,1)+=w_gauss*(DN(1,0)*crLHS28 + DN(1,1)*crLHS129 + DN(1,2)*crLHS182 + crLHS148); +rLHS(6,2)+=w_gauss*(DN(1,0)*crLHS35 + DN(1,1)*crLHS133 + DN(1,2)*crLHS183 + crLHS192 + crLHS248); +rLHS(6,3)+=w_gauss*(DN(0,2)*crLHS225 + crLHS193*crLHS69 - crLHS194); +rLHS(6,4)+=w_gauss*(DN(1,0)*crLHS45 + DN(1,1)*crLHS137 + DN(1,2)*crLHS185 + crLHS230); +rLHS(6,5)+=w_gauss*(DN(1,0)*crLHS59 + DN(1,1)*crLHS141 + DN(1,2)*crLHS188 + crLHS251); +rLHS(6,6)+=w_gauss*(DN(1,0)*crLHS65 + DN(1,1)*crLHS147 + DN(1,2)*crLHS190 + crLHS10*crLHS266 + crLHS227); +rLHS(6,7)+=DN(1,2)*crLHS231; +rLHS(6,8)+=w_gauss*(DN(1,0)*crLHS74 + DN(1,1)*crLHS152 + DN(1,2)*crLHS195 + crLHS268); +rLHS(6,9)+=w_gauss*(DN(1,0)*crLHS88 + DN(1,1)*crLHS156 + DN(1,2)*crLHS197 + crLHS269); +rLHS(6,10)+=w_gauss*(DN(1,0)*crLHS94 + DN(1,1)*crLHS162 + DN(1,2)*crLHS199 + crLHS255 + crLHS271); +rLHS(6,11)+=w_gauss*(DN(2,2)*crLHS225 - crLHS272 + crLHS273*crLHS69); +rLHS(6,12)+=w_gauss*(DN(1,0)*crLHS102 + DN(1,1)*crLHS167 + DN(1,2)*crLHS204 + crLHS274); +rLHS(6,13)+=w_gauss*(DN(1,0)*crLHS115 + DN(1,1)*crLHS171 + DN(1,2)*crLHS206 + crLHS275); +rLHS(6,14)+=w_gauss*(DN(1,0)*crLHS121 + DN(1,1)*crLHS177 + DN(1,2)*crLHS208 + crLHS262 + crLHS277); +rLHS(6,15)+=w_gauss*(DN(3,2)*crLHS225 - crLHS278 + crLHS279*crLHS69); +rLHS(7,0)+=w_gauss*(DN(1,0)*crLHS213 + crLHS67); +rLHS(7,1)+=w_gauss*(DN(1,1)*crLHS213 + crLHS149); +rLHS(7,2)+=w_gauss*(DN(1,2)*crLHS213 + crLHS193); +rLHS(7,3)+=crLHS217; +rLHS(7,4)+=DN(1,0)*crLHS280; +rLHS(7,5)+=DN(1,1)*crLHS280; +rLHS(7,6)+=DN(1,2)*crLHS280; +rLHS(7,7)+=crLHS215*(crLHS226 + crLHS249 + crLHS266); +rLHS(7,8)+=w_gauss*(DN(1,0)*crLHS218 + crLHS239); +rLHS(7,9)+=w_gauss*(DN(1,1)*crLHS218 + crLHS258); +rLHS(7,10)+=w_gauss*(DN(1,2)*crLHS218 + crLHS273); +rLHS(7,11)+=crLHS281; +rLHS(7,12)+=w_gauss*(DN(1,0)*crLHS220 + crLHS247); +rLHS(7,13)+=w_gauss*(DN(1,1)*crLHS220 + crLHS265); +rLHS(7,14)+=w_gauss*(DN(1,2)*crLHS220 + crLHS279); +rLHS(7,15)+=crLHS282; +rLHS(8,0)+=w_gauss*(DN(2,0)*crLHS0 + DN(2,1)*crLHS2 + DN(2,2)*crLHS4 + crLHS285 + crLHS78); +rLHS(8,1)+=w_gauss*(DN(2,0)*crLHS23 + DN(2,1)*crLHS25 + DN(2,2)*crLHS28 + crLHS153); +rLHS(8,2)+=w_gauss*(DN(2,0)*crLHS31 + DN(2,1)*crLHS33 + DN(2,2)*crLHS35 + crLHS196); +rLHS(8,3)+=w_gauss*(DN(0,0)*crLHS286 + crLHS69*crLHS96 - crLHS97); +rLHS(8,4)+=w_gauss*(DN(2,0)*crLHS41 + DN(2,1)*crLHS43 + DN(2,2)*crLHS45 + crLHS234 + crLHS287); +rLHS(8,5)+=w_gauss*(DN(2,0)*crLHS54 + DN(2,1)*crLHS56 + DN(2,2)*crLHS59 + crLHS252); +rLHS(8,6)+=w_gauss*(DN(2,0)*crLHS61 + DN(2,1)*crLHS63 + DN(2,2)*crLHS65 + crLHS268); +rLHS(8,7)+=w_gauss*(DN(1,0)*crLHS286 + crLHS238*crLHS69 - crLHS239); +rLHS(8,8)+=w_gauss*(DN(2,0)*crLHS70 + DN(2,1)*crLHS72 + DN(2,2)*crLHS74 + crLHS10*crLHS288 + crLHS289); +rLHS(8,9)+=w_gauss*(DN(2,0)*crLHS83 + DN(2,1)*crLHS85 + DN(2,2)*crLHS88 + crLHS291); +rLHS(8,10)+=w_gauss*(DN(2,0)*crLHS90 + DN(2,1)*crLHS92 + DN(2,2)*crLHS94 + crLHS292); +rLHS(8,11)+=DN(2,0)*crLHS293; +rLHS(8,12)+=w_gauss*(DN(2,0)*crLHS98 + DN(2,1)*crLHS100 + DN(2,2)*crLHS102 + crLHS296 + crLHS297); +rLHS(8,13)+=w_gauss*(DN(2,0)*crLHS110 + DN(2,1)*crLHS112 + DN(2,2)*crLHS115 + crLHS298); +rLHS(8,14)+=w_gauss*(DN(2,0)*crLHS117 + DN(2,1)*crLHS119 + DN(2,2)*crLHS121 + crLHS299); +rLHS(8,15)+=w_gauss*(DN(3,0)*crLHS286 - crLHS300 + crLHS301*crLHS69); +rLHS(9,0)+=w_gauss*(DN(2,0)*crLHS2 + DN(2,1)*crLHS125 + DN(2,2)*crLHS126 + crLHS89); +rLHS(9,1)+=w_gauss*(DN(2,0)*crLHS25 + DN(2,1)*crLHS127 + DN(2,2)*crLHS129 + crLHS158 + crLHS302); +rLHS(9,2)+=w_gauss*(DN(2,0)*crLHS33 + DN(2,1)*crLHS131 + DN(2,2)*crLHS133 + crLHS198); +rLHS(9,3)+=w_gauss*(DN(0,1)*crLHS286 + crLHS164*crLHS69 - crLHS165); +rLHS(9,4)+=w_gauss*(DN(2,0)*crLHS43 + DN(2,1)*crLHS136 + DN(2,2)*crLHS137 + crLHS236); +rLHS(9,5)+=w_gauss*(DN(2,0)*crLHS56 + DN(2,1)*crLHS139 + DN(2,2)*crLHS141 + crLHS254 + crLHS303); +rLHS(9,6)+=w_gauss*(DN(2,0)*crLHS63 + DN(2,1)*crLHS145 + DN(2,2)*crLHS147 + crLHS269); +rLHS(9,7)+=w_gauss*(DN(1,1)*crLHS286 + crLHS257*crLHS69 - crLHS258); +rLHS(9,8)+=w_gauss*(DN(2,0)*crLHS72 + DN(2,1)*crLHS151 + DN(2,2)*crLHS152 + crLHS291); +rLHS(9,9)+=w_gauss*(DN(2,0)*crLHS85 + DN(2,1)*crLHS154 + DN(2,2)*crLHS156 + crLHS10*crLHS304 + crLHS289); +rLHS(9,10)+=w_gauss*(DN(2,0)*crLHS92 + DN(2,1)*crLHS160 + DN(2,2)*crLHS162 + crLHS306); +rLHS(9,11)+=DN(2,1)*crLHS293; +rLHS(9,12)+=w_gauss*(DN(2,0)*crLHS100 + DN(2,1)*crLHS166 + DN(2,2)*crLHS167 + crLHS307); +rLHS(9,13)+=w_gauss*(DN(2,0)*crLHS112 + DN(2,1)*crLHS169 + DN(2,2)*crLHS171 + crLHS309 + crLHS310); +rLHS(9,14)+=w_gauss*(DN(2,0)*crLHS119 + DN(2,1)*crLHS175 + DN(2,2)*crLHS177 + crLHS311); +rLHS(9,15)+=w_gauss*(DN(3,1)*crLHS286 - crLHS312 + crLHS313*crLHS69); +rLHS(10,0)+=w_gauss*(DN(2,0)*crLHS4 + DN(2,1)*crLHS126 + DN(2,2)*crLHS181 + crLHS95); +rLHS(10,1)+=w_gauss*(DN(2,0)*crLHS28 + DN(2,1)*crLHS129 + DN(2,2)*crLHS182 + crLHS163); +rLHS(10,2)+=w_gauss*(DN(2,0)*crLHS35 + DN(2,1)*crLHS133 + DN(2,2)*crLHS183 + crLHS201 + crLHS302); +rLHS(10,3)+=w_gauss*(DN(0,2)*crLHS286 + crLHS202*crLHS69 - crLHS203); +rLHS(10,4)+=w_gauss*(DN(2,0)*crLHS45 + DN(2,1)*crLHS137 + DN(2,2)*crLHS185 + crLHS237); +rLHS(10,5)+=w_gauss*(DN(2,0)*crLHS59 + DN(2,1)*crLHS141 + DN(2,2)*crLHS188 + crLHS256); +rLHS(10,6)+=w_gauss*(DN(2,0)*crLHS65 + DN(2,1)*crLHS147 + DN(2,2)*crLHS190 + crLHS271 + crLHS303); +rLHS(10,7)+=w_gauss*(DN(1,2)*crLHS286 + crLHS272*crLHS69 - crLHS273); +rLHS(10,8)+=w_gauss*(DN(2,0)*crLHS74 + DN(2,1)*crLHS152 + DN(2,2)*crLHS195 + crLHS292); +rLHS(10,9)+=w_gauss*(DN(2,0)*crLHS88 + DN(2,1)*crLHS156 + DN(2,2)*crLHS197 + crLHS306); +rLHS(10,10)+=w_gauss*(DN(2,0)*crLHS94 + DN(2,1)*crLHS162 + DN(2,2)*crLHS199 + crLHS10*crLHS314 + crLHS289); +rLHS(10,11)+=DN(2,2)*crLHS293; +rLHS(10,12)+=w_gauss*(DN(2,0)*crLHS102 + DN(2,1)*crLHS167 + DN(2,2)*crLHS204 + crLHS316); +rLHS(10,13)+=w_gauss*(DN(2,0)*crLHS115 + DN(2,1)*crLHS171 + DN(2,2)*crLHS206 + crLHS317); +rLHS(10,14)+=w_gauss*(DN(2,0)*crLHS121 + DN(2,1)*crLHS177 + DN(2,2)*crLHS208 + crLHS310 + crLHS319); +rLHS(10,15)+=w_gauss*(DN(3,2)*crLHS286 - crLHS320 + crLHS321*crLHS69); +rLHS(11,0)+=w_gauss*(DN(2,0)*crLHS213 + crLHS96); +rLHS(11,1)+=w_gauss*(DN(2,1)*crLHS213 + crLHS164); +rLHS(11,2)+=w_gauss*(DN(2,2)*crLHS213 + crLHS202); +rLHS(11,3)+=crLHS219; +rLHS(11,4)+=w_gauss*(DN(2,0)*crLHS216 + crLHS238); +rLHS(11,5)+=w_gauss*(DN(2,1)*crLHS216 + crLHS257); +rLHS(11,6)+=w_gauss*(DN(2,2)*crLHS216 + crLHS272); +rLHS(11,7)+=crLHS281; +rLHS(11,8)+=DN(2,0)*crLHS322; +rLHS(11,9)+=DN(2,1)*crLHS322; +rLHS(11,10)+=DN(2,2)*crLHS322; +rLHS(11,11)+=crLHS215*(crLHS288 + crLHS304 + crLHS314); +rLHS(11,12)+=w_gauss*(DN(2,0)*crLHS220 + crLHS301); +rLHS(11,13)+=w_gauss*(DN(2,1)*crLHS220 + crLHS313); +rLHS(11,14)+=w_gauss*(DN(2,2)*crLHS220 + crLHS321); +rLHS(11,15)+=crLHS323; +rLHS(12,0)+=w_gauss*(DN(3,0)*crLHS0 + DN(3,1)*crLHS2 + DN(3,2)*crLHS4 + crLHS106 + crLHS326); +rLHS(12,1)+=w_gauss*(DN(3,0)*crLHS23 + DN(3,1)*crLHS25 + DN(3,2)*crLHS28 + crLHS168); +rLHS(12,2)+=w_gauss*(DN(3,0)*crLHS31 + DN(3,1)*crLHS33 + DN(3,2)*crLHS35 + crLHS205); +rLHS(12,3)+=w_gauss*(DN(0,0)*crLHS327 + crLHS123*crLHS69 - crLHS124); +rLHS(12,4)+=w_gauss*(DN(3,0)*crLHS41 + DN(3,1)*crLHS43 + DN(3,2)*crLHS45 + crLHS242 + crLHS328); +rLHS(12,5)+=w_gauss*(DN(3,0)*crLHS54 + DN(3,1)*crLHS56 + DN(3,2)*crLHS59 + crLHS259); +rLHS(12,6)+=w_gauss*(DN(3,0)*crLHS61 + DN(3,1)*crLHS63 + DN(3,2)*crLHS65 + crLHS274); +rLHS(12,7)+=w_gauss*(DN(1,0)*crLHS327 + crLHS246*crLHS69 - crLHS247); +rLHS(12,8)+=w_gauss*(DN(3,0)*crLHS70 + DN(3,1)*crLHS72 + DN(3,2)*crLHS74 + crLHS296 + crLHS329); +rLHS(12,9)+=w_gauss*(DN(3,0)*crLHS83 + DN(3,1)*crLHS85 + DN(3,2)*crLHS88 + crLHS307); +rLHS(12,10)+=w_gauss*(DN(3,0)*crLHS90 + DN(3,1)*crLHS92 + DN(3,2)*crLHS94 + crLHS316); +rLHS(12,11)+=w_gauss*(DN(2,0)*crLHS327 + crLHS300*crLHS69 - crLHS301); +rLHS(12,12)+=w_gauss*(DN(3,0)*crLHS98 + DN(3,1)*crLHS100 + DN(3,2)*crLHS102 + crLHS10*crLHS330 + crLHS331); +rLHS(12,13)+=w_gauss*(DN(3,0)*crLHS110 + DN(3,1)*crLHS112 + DN(3,2)*crLHS115 + crLHS333); +rLHS(12,14)+=w_gauss*(DN(3,0)*crLHS117 + DN(3,1)*crLHS119 + DN(3,2)*crLHS121 + crLHS334); +rLHS(12,15)+=DN(3,0)*crLHS335; +rLHS(13,0)+=w_gauss*(DN(3,0)*crLHS2 + DN(3,1)*crLHS125 + DN(3,2)*crLHS126 + crLHS116); +rLHS(13,1)+=w_gauss*(DN(3,0)*crLHS25 + DN(3,1)*crLHS127 + DN(3,2)*crLHS129 + crLHS173 + crLHS336); +rLHS(13,2)+=w_gauss*(DN(3,0)*crLHS33 + DN(3,1)*crLHS131 + DN(3,2)*crLHS133 + crLHS207); +rLHS(13,3)+=w_gauss*(DN(0,1)*crLHS327 + crLHS179*crLHS69 - crLHS180); +rLHS(13,4)+=w_gauss*(DN(3,0)*crLHS43 + DN(3,1)*crLHS136 + DN(3,2)*crLHS137 + crLHS244); +rLHS(13,5)+=w_gauss*(DN(3,0)*crLHS56 + DN(3,1)*crLHS139 + DN(3,2)*crLHS141 + crLHS261 + crLHS337); +rLHS(13,6)+=w_gauss*(DN(3,0)*crLHS63 + DN(3,1)*crLHS145 + DN(3,2)*crLHS147 + crLHS275); +rLHS(13,7)+=w_gauss*(DN(1,1)*crLHS327 + crLHS264*crLHS69 - crLHS265); +rLHS(13,8)+=w_gauss*(DN(3,0)*crLHS72 + DN(3,1)*crLHS151 + DN(3,2)*crLHS152 + crLHS298); +rLHS(13,9)+=w_gauss*(DN(3,0)*crLHS85 + DN(3,1)*crLHS154 + DN(3,2)*crLHS156 + crLHS309 + crLHS338); +rLHS(13,10)+=w_gauss*(DN(3,0)*crLHS92 + DN(3,1)*crLHS160 + DN(3,2)*crLHS162 + crLHS317); +rLHS(13,11)+=w_gauss*(DN(2,1)*crLHS327 + crLHS312*crLHS69 - crLHS313); +rLHS(13,12)+=w_gauss*(DN(3,0)*crLHS100 + DN(3,1)*crLHS166 + DN(3,2)*crLHS167 + crLHS333); +rLHS(13,13)+=w_gauss*(DN(3,0)*crLHS112 + DN(3,1)*crLHS169 + DN(3,2)*crLHS171 + crLHS10*crLHS339 + crLHS331); +rLHS(13,14)+=w_gauss*(DN(3,0)*crLHS119 + DN(3,1)*crLHS175 + DN(3,2)*crLHS177 + crLHS340); +rLHS(13,15)+=DN(3,1)*crLHS335; +rLHS(14,0)+=w_gauss*(DN(3,0)*crLHS4 + DN(3,1)*crLHS126 + DN(3,2)*crLHS181 + crLHS122); +rLHS(14,1)+=w_gauss*(DN(3,0)*crLHS28 + DN(3,1)*crLHS129 + DN(3,2)*crLHS182 + crLHS178); +rLHS(14,2)+=w_gauss*(DN(3,0)*crLHS35 + DN(3,1)*crLHS133 + DN(3,2)*crLHS183 + crLHS210 + crLHS336); +rLHS(14,3)+=w_gauss*(DN(0,2)*crLHS327 + crLHS211*crLHS69 - crLHS212); +rLHS(14,4)+=w_gauss*(DN(3,0)*crLHS45 + DN(3,1)*crLHS137 + DN(3,2)*crLHS185 + crLHS245); +rLHS(14,5)+=w_gauss*(DN(3,0)*crLHS59 + DN(3,1)*crLHS141 + DN(3,2)*crLHS188 + crLHS263); +rLHS(14,6)+=w_gauss*(DN(3,0)*crLHS65 + DN(3,1)*crLHS147 + DN(3,2)*crLHS190 + crLHS277 + crLHS337); +rLHS(14,7)+=w_gauss*(DN(1,2)*crLHS327 + crLHS278*crLHS69 - crLHS279); +rLHS(14,8)+=w_gauss*(DN(3,0)*crLHS74 + DN(3,1)*crLHS152 + DN(3,2)*crLHS195 + crLHS299); +rLHS(14,9)+=w_gauss*(DN(3,0)*crLHS88 + DN(3,1)*crLHS156 + DN(3,2)*crLHS197 + crLHS311); +rLHS(14,10)+=w_gauss*(DN(3,0)*crLHS94 + DN(3,1)*crLHS162 + DN(3,2)*crLHS199 + crLHS319 + crLHS338); +rLHS(14,11)+=w_gauss*(DN(2,2)*crLHS327 + crLHS320*crLHS69 - crLHS321); +rLHS(14,12)+=w_gauss*(DN(3,0)*crLHS102 + DN(3,1)*crLHS167 + DN(3,2)*crLHS204 + crLHS334); +rLHS(14,13)+=w_gauss*(DN(3,0)*crLHS115 + DN(3,1)*crLHS171 + DN(3,2)*crLHS206 + crLHS340); +rLHS(14,14)+=w_gauss*(DN(3,0)*crLHS121 + DN(3,1)*crLHS177 + DN(3,2)*crLHS208 + crLHS10*crLHS341 + crLHS331); +rLHS(14,15)+=DN(3,2)*crLHS335; +rLHS(15,0)+=w_gauss*(DN(3,0)*crLHS213 + crLHS123); +rLHS(15,1)+=w_gauss*(DN(3,1)*crLHS213 + crLHS179); +rLHS(15,2)+=w_gauss*(DN(3,2)*crLHS213 + crLHS211); +rLHS(15,3)+=crLHS221; +rLHS(15,4)+=w_gauss*(DN(3,0)*crLHS216 + crLHS246); +rLHS(15,5)+=w_gauss*(DN(3,1)*crLHS216 + crLHS264); +rLHS(15,6)+=w_gauss*(DN(3,2)*crLHS216 + crLHS278); +rLHS(15,7)+=crLHS282; +rLHS(15,8)+=w_gauss*(DN(3,0)*crLHS218 + crLHS300); +rLHS(15,9)+=w_gauss*(DN(3,1)*crLHS218 + crLHS312); +rLHS(15,10)+=w_gauss*(DN(3,2)*crLHS218 + crLHS320); +rLHS(15,11)+=crLHS323; +rLHS(15,12)+=DN(3,0)*crLHS342; +rLHS(15,13)+=DN(3,1)*crLHS342; +rLHS(15,14)+=DN(3,2)*crLHS342; +rLHS(15,15)+=crLHS215*(crLHS330 + crLHS339 + crLHS341); - auto &lhs = rData.lhs; - - const double clhs0 = C(0,0)*DN(0,0) + C(0,3)*DN(0,1) + C(0,5)*DN(0,2); -const double clhs1 = C(0,3)*DN(0,0); -const double clhs2 = C(3,3)*DN(0,1) + C(3,5)*DN(0,2) + clhs1; -const double clhs3 = C(0,5)*DN(0,0); -const double clhs4 = C(3,5)*DN(0,1) + C(5,5)*DN(0,2) + clhs3; -const double clhs5 = DN(0,0)*DN(0,0); -const double clhs6 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double clhs7 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double clhs8 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double clhs9 = rho*stab_c2*sqrt(clhs6*clhs6 + clhs7*clhs7 + clhs8*clhs8); -const double clhs10 = clhs9*h*1.0/stab_c1 + mu; -const double clhs11 = DN(0,0)*clhs6 + DN(0,1)*clhs7 + DN(0,2)*clhs8; -const double clhs12 = N[0]*rho; -const double clhs13 = bdf0*rho; -const double clhs14 = N[0]*bdf0; -const double clhs15 = clhs11 + clhs14; -const double clhs16 = 1.0*1.0/(clhs9*1.0/h + dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h)); -const double clhs17 = clhs16*(rho*rho); -const double clhs18 = clhs11*clhs17; -const double clhs19 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); -const double clhs20 = clhs17*clhs19; -const double clhs21 = N[0]*clhs20; -const double clhs22 = clhs11*clhs12 + clhs13*(N[0]*N[0]) + clhs15*clhs18 + clhs15*clhs21; -const double clhs23 = C(0,1)*DN(0,1) + C(0,4)*DN(0,2) + clhs1; -const double clhs24 = C(1,3)*DN(0,1); -const double clhs25 = C(3,3)*DN(0,0) + C(3,4)*DN(0,2) + clhs24; -const double clhs26 = C(3,5)*DN(0,0); -const double clhs27 = C(4,5)*DN(0,2); -const double clhs28 = C(1,5)*DN(0,1) + clhs26 + clhs27; -const double clhs29 = DN(0,0)*clhs10; -const double clhs30 = DN(0,1)*clhs29; -const double clhs31 = C(0,2)*DN(0,2) + C(0,4)*DN(0,1) + clhs3; -const double clhs32 = C(3,4)*DN(0,1); -const double clhs33 = C(2,3)*DN(0,2) + clhs26 + clhs32; -const double clhs34 = C(2,5)*DN(0,2); -const double clhs35 = C(4,5)*DN(0,1) + C(5,5)*DN(0,0) + clhs34; -const double clhs36 = DN(0,2)*clhs29; -const double clhs37 = clhs16*clhs19; -const double clhs38 = clhs16*rho; -const double clhs39 = clhs11*clhs38; -const double clhs40 = -N[0] + clhs12*clhs37 + clhs39; -const double clhs41 = C(0,0)*DN(1,0) + C(0,3)*DN(1,1) + C(0,5)*DN(1,2); -const double clhs42 = C(0,3)*DN(1,0); -const double clhs43 = C(3,3)*DN(1,1) + C(3,5)*DN(1,2) + clhs42; -const double clhs44 = C(0,5)*DN(1,0); -const double clhs45 = C(3,5)*DN(1,1) + C(5,5)*DN(1,2) + clhs44; -const double clhs46 = DN(0,0)*DN(1,0); -const double clhs47 = N[1]*rho; -const double clhs48 = clhs14*clhs47; -const double clhs49 = clhs10*clhs46 + clhs48; -const double clhs50 = DN(1,0)*clhs6 + DN(1,1)*clhs7 + DN(1,2)*clhs8; -const double clhs51 = N[1]*bdf0; -const double clhs52 = clhs50 + clhs51; -const double clhs53 = clhs12*clhs50 + clhs18*clhs52 + clhs21*clhs52; -const double clhs54 = C(0,1)*DN(1,1) + C(0,4)*DN(1,2) + clhs42; -const double clhs55 = C(1,3)*DN(1,1); -const double clhs56 = C(3,3)*DN(1,0) + C(3,4)*DN(1,2) + clhs55; -const double clhs57 = C(3,5)*DN(1,0); -const double clhs58 = C(4,5)*DN(1,2); -const double clhs59 = C(1,5)*DN(1,1) + clhs57 + clhs58; -const double clhs60 = DN(1,1)*clhs29; -const double clhs61 = C(0,2)*DN(1,2) + C(0,4)*DN(1,1) + clhs44; -const double clhs62 = C(3,4)*DN(1,1); -const double clhs63 = C(2,3)*DN(1,2) + clhs57 + clhs62; -const double clhs64 = C(2,5)*DN(1,2); -const double clhs65 = C(4,5)*DN(1,1) + C(5,5)*DN(1,0) + clhs64; -const double clhs66 = DN(1,2)*clhs29; -const double clhs67 = DN(0,0)*N[1]; -const double clhs68 = DN(1,0)*N[0]; -const double clhs69 = clhs19*clhs38; -const double clhs70 = C(0,0)*DN(2,0) + C(0,3)*DN(2,1) + C(0,5)*DN(2,2); -const double clhs71 = C(0,3)*DN(2,0); -const double clhs72 = C(3,3)*DN(2,1) + C(3,5)*DN(2,2) + clhs71; -const double clhs73 = C(0,5)*DN(2,0); -const double clhs74 = C(3,5)*DN(2,1) + C(5,5)*DN(2,2) + clhs73; -const double clhs75 = DN(0,0)*DN(2,0); -const double clhs76 = N[2]*rho; -const double clhs77 = clhs14*clhs76; -const double clhs78 = clhs10*clhs75 + clhs77; -const double clhs79 = DN(2,0)*clhs6 + DN(2,1)*clhs7 + DN(2,2)*clhs8; -const double clhs80 = N[2]*bdf0; -const double clhs81 = clhs79 + clhs80; -const double clhs82 = clhs12*clhs79 + clhs18*clhs81 + clhs21*clhs81; -const double clhs83 = C(0,1)*DN(2,1) + C(0,4)*DN(2,2) + clhs71; -const double clhs84 = C(1,3)*DN(2,1); -const double clhs85 = C(3,3)*DN(2,0) + C(3,4)*DN(2,2) + clhs84; -const double clhs86 = C(3,5)*DN(2,0); -const double clhs87 = C(4,5)*DN(2,2); -const double clhs88 = C(1,5)*DN(2,1) + clhs86 + clhs87; -const double clhs89 = DN(2,1)*clhs29; -const double clhs90 = C(0,2)*DN(2,2) + C(0,4)*DN(2,1) + clhs73; -const double clhs91 = C(3,4)*DN(2,1); -const double clhs92 = C(2,3)*DN(2,2) + clhs86 + clhs91; -const double clhs93 = C(2,5)*DN(2,2); -const double clhs94 = C(4,5)*DN(2,1) + C(5,5)*DN(2,0) + clhs93; -const double clhs95 = DN(2,2)*clhs29; -const double clhs96 = DN(0,0)*N[2]; -const double clhs97 = DN(2,0)*N[0]; -const double clhs98 = C(0,0)*DN(3,0) + C(0,3)*DN(3,1) + C(0,5)*DN(3,2); -const double clhs99 = C(0,3)*DN(3,0); -const double clhs100 = C(3,3)*DN(3,1) + C(3,5)*DN(3,2) + clhs99; -const double clhs101 = C(0,5)*DN(3,0); -const double clhs102 = C(3,5)*DN(3,1) + C(5,5)*DN(3,2) + clhs101; -const double clhs103 = DN(0,0)*DN(3,0); -const double clhs104 = N[3]*rho; -const double clhs105 = clhs104*clhs14; -const double clhs106 = clhs10*clhs103 + clhs105; -const double clhs107 = DN(3,0)*clhs6 + DN(3,1)*clhs7 + DN(3,2)*clhs8; -const double clhs108 = N[3]*bdf0 + clhs107; -const double clhs109 = clhs107*clhs12 + clhs108*clhs18 + clhs108*clhs21; -const double clhs110 = C(0,1)*DN(3,1) + C(0,4)*DN(3,2) + clhs99; -const double clhs111 = C(1,3)*DN(3,1); -const double clhs112 = C(3,3)*DN(3,0) + C(3,4)*DN(3,2) + clhs111; -const double clhs113 = C(3,5)*DN(3,0); -const double clhs114 = C(4,5)*DN(3,2); -const double clhs115 = C(1,5)*DN(3,1) + clhs113 + clhs114; -const double clhs116 = DN(3,1)*clhs29; -const double clhs117 = C(0,2)*DN(3,2) + C(0,4)*DN(3,1) + clhs101; -const double clhs118 = C(3,4)*DN(3,1); -const double clhs119 = C(2,3)*DN(3,2) + clhs113 + clhs118; -const double clhs120 = C(2,5)*DN(3,2); -const double clhs121 = C(4,5)*DN(3,1) + C(5,5)*DN(3,0) + clhs120; -const double clhs122 = DN(3,2)*clhs29; -const double clhs123 = DN(0,0)*N[3]; -const double clhs124 = DN(3,0)*N[0]; -const double clhs125 = C(0,1)*DN(0,0) + C(1,5)*DN(0,2) + clhs24; -const double clhs126 = C(0,4)*DN(0,0) + clhs27 + clhs32; -const double clhs127 = C(1,1)*DN(0,1) + C(1,3)*DN(0,0) + C(1,4)*DN(0,2); -const double clhs128 = C(1,4)*DN(0,1); -const double clhs129 = C(3,4)*DN(0,0) + C(4,4)*DN(0,2) + clhs128; -const double clhs130 = DN(0,1)*DN(0,1); -const double clhs131 = C(1,2)*DN(0,2) + C(1,5)*DN(0,0) + clhs128; -const double clhs132 = C(2,4)*DN(0,2); -const double clhs133 = C(4,4)*DN(0,1) + C(4,5)*DN(0,0) + clhs132; -const double clhs134 = DN(0,1)*clhs10; -const double clhs135 = DN(0,2)*clhs134; -const double clhs136 = C(0,1)*DN(1,0) + C(1,5)*DN(1,2) + clhs55; -const double clhs137 = C(0,4)*DN(1,0) + clhs58 + clhs62; -const double clhs138 = DN(1,0)*clhs134; -const double clhs139 = C(1,1)*DN(1,1) + C(1,3)*DN(1,0) + C(1,4)*DN(1,2); -const double clhs140 = C(1,4)*DN(1,1); -const double clhs141 = C(3,4)*DN(1,0) + C(4,4)*DN(1,2) + clhs140; -const double clhs142 = DN(0,1)*DN(1,1); -const double clhs143 = clhs10*clhs142; -const double clhs144 = clhs48 + clhs53; -const double clhs145 = C(1,2)*DN(1,2) + C(1,5)*DN(1,0) + clhs140; -const double clhs146 = C(2,4)*DN(1,2); -const double clhs147 = C(4,4)*DN(1,1) + C(4,5)*DN(1,0) + clhs146; -const double clhs148 = DN(1,2)*clhs134; -const double clhs149 = DN(0,1)*N[1]; -const double clhs150 = DN(1,1)*N[0]; -const double clhs151 = C(0,1)*DN(2,0) + C(1,5)*DN(2,2) + clhs84; -const double clhs152 = C(0,4)*DN(2,0) + clhs87 + clhs91; -const double clhs153 = DN(2,0)*clhs134; -const double clhs154 = C(1,1)*DN(2,1) + C(1,3)*DN(2,0) + C(1,4)*DN(2,2); -const double clhs155 = C(1,4)*DN(2,1); -const double clhs156 = C(3,4)*DN(2,0) + C(4,4)*DN(2,2) + clhs155; -const double clhs157 = DN(0,1)*DN(2,1); -const double clhs158 = clhs10*clhs157; -const double clhs159 = clhs77 + clhs82; -const double clhs160 = C(1,2)*DN(2,2) + C(1,5)*DN(2,0) + clhs155; -const double clhs161 = C(2,4)*DN(2,2); -const double clhs162 = C(4,4)*DN(2,1) + C(4,5)*DN(2,0) + clhs161; -const double clhs163 = DN(2,2)*clhs134; -const double clhs164 = DN(0,1)*N[2]; -const double clhs165 = DN(2,1)*N[0]; -const double clhs166 = C(0,1)*DN(3,0) + C(1,5)*DN(3,2) + clhs111; -const double clhs167 = C(0,4)*DN(3,0) + clhs114 + clhs118; -const double clhs168 = DN(3,0)*clhs134; -const double clhs169 = C(1,1)*DN(3,1) + C(1,3)*DN(3,0) + C(1,4)*DN(3,2); -const double clhs170 = C(1,4)*DN(3,1); -const double clhs171 = C(3,4)*DN(3,0) + C(4,4)*DN(3,2) + clhs170; -const double clhs172 = DN(0,1)*DN(3,1); -const double clhs173 = clhs10*clhs172; -const double clhs174 = clhs105 + clhs109; -const double clhs175 = C(1,2)*DN(3,2) + C(1,5)*DN(3,0) + clhs170; -const double clhs176 = C(2,4)*DN(3,2); -const double clhs177 = C(4,4)*DN(3,1) + C(4,5)*DN(3,0) + clhs176; -const double clhs178 = DN(3,2)*clhs134; -const double clhs179 = DN(0,1)*N[3]; -const double clhs180 = DN(3,1)*N[0]; -const double clhs181 = C(0,2)*DN(0,0) + C(2,3)*DN(0,1) + clhs34; -const double clhs182 = C(1,2)*DN(0,1) + C(2,3)*DN(0,0) + clhs132; -const double clhs183 = C(2,2)*DN(0,2) + C(2,4)*DN(0,1) + C(2,5)*DN(0,0); -const double clhs184 = DN(0,2)*DN(0,2); -const double clhs185 = C(0,2)*DN(1,0) + C(2,3)*DN(1,1) + clhs64; -const double clhs186 = DN(0,2)*clhs10; -const double clhs187 = DN(1,0)*clhs186; -const double clhs188 = C(1,2)*DN(1,1) + C(2,3)*DN(1,0) + clhs146; -const double clhs189 = DN(1,1)*clhs186; -const double clhs190 = C(2,2)*DN(1,2) + C(2,4)*DN(1,1) + C(2,5)*DN(1,0); -const double clhs191 = DN(0,2)*DN(1,2); -const double clhs192 = clhs10*clhs191; -const double clhs193 = DN(0,2)*N[1]; -const double clhs194 = DN(1,2)*N[0]; -const double clhs195 = C(0,2)*DN(2,0) + C(2,3)*DN(2,1) + clhs93; -const double clhs196 = DN(2,0)*clhs186; -const double clhs197 = C(1,2)*DN(2,1) + C(2,3)*DN(2,0) + clhs161; -const double clhs198 = DN(2,1)*clhs186; -const double clhs199 = C(2,2)*DN(2,2) + C(2,4)*DN(2,1) + C(2,5)*DN(2,0); -const double clhs200 = DN(0,2)*DN(2,2); -const double clhs201 = clhs10*clhs200; -const double clhs202 = DN(0,2)*N[2]; -const double clhs203 = DN(2,2)*N[0]; -const double clhs204 = C(0,2)*DN(3,0) + C(2,3)*DN(3,1) + clhs120; -const double clhs205 = DN(3,0)*clhs186; -const double clhs206 = C(1,2)*DN(3,1) + C(2,3)*DN(3,0) + clhs176; -const double clhs207 = DN(3,1)*clhs186; -const double clhs208 = C(2,2)*DN(3,2) + C(2,4)*DN(3,1) + C(2,5)*DN(3,0); -const double clhs209 = DN(0,2)*DN(3,2); -const double clhs210 = clhs10*clhs209; -const double clhs211 = DN(0,2)*N[3]; -const double clhs212 = DN(3,2)*N[0]; -const double clhs213 = clhs15*clhs38; -const double clhs214 = N[0] + clhs213; -const double clhs215 = clhs38*clhs52; -const double clhs216 = clhs16*(clhs142 + clhs191 + clhs46); -const double clhs217 = clhs38*clhs81; -const double clhs218 = clhs16*(clhs157 + clhs200 + clhs75); -const double clhs219 = clhs108*clhs38; -const double clhs220 = clhs16*(clhs103 + clhs172 + clhs209); -const double clhs221 = clhs17*clhs50; -const double clhs222 = N[1]*clhs20; -const double clhs223 = clhs11*clhs47 + clhs15*clhs221 + clhs15*clhs222; -const double clhs224 = clhs38*clhs50; -const double clhs225 = DN(1,0)*DN(1,0); -const double clhs226 = clhs13*(N[1]*N[1]) + clhs221*clhs52 + clhs222*clhs52 + clhs47*clhs50; -const double clhs227 = DN(1,0)*clhs10; -const double clhs228 = DN(1,1)*clhs227; -const double clhs229 = DN(1,2)*clhs227; -const double clhs230 = -N[1] + clhs224 + clhs37*clhs47; -const double clhs231 = DN(1,0)*DN(2,0); -const double clhs232 = clhs51*clhs76; -const double clhs233 = clhs10*clhs231 + clhs232; -const double clhs234 = clhs221*clhs81 + clhs222*clhs81 + clhs47*clhs79; -const double clhs235 = DN(2,1)*clhs227; -const double clhs236 = DN(2,2)*clhs227; -const double clhs237 = DN(1,0)*N[2]; -const double clhs238 = DN(2,0)*N[1]; -const double clhs239 = DN(1,0)*DN(3,0); -const double clhs240 = clhs104*clhs51; -const double clhs241 = clhs10*clhs239 + clhs240; -const double clhs242 = clhs107*clhs47 + clhs108*clhs221 + clhs108*clhs222; -const double clhs243 = DN(3,1)*clhs227; -const double clhs244 = DN(3,2)*clhs227; -const double clhs245 = DN(1,0)*N[3]; -const double clhs246 = DN(3,0)*N[1]; -const double clhs247 = clhs223 + clhs48; -const double clhs248 = DN(1,1)*DN(1,1); -const double clhs249 = DN(1,1)*clhs10; -const double clhs250 = DN(1,2)*clhs249; -const double clhs251 = DN(2,0)*clhs249; -const double clhs252 = DN(1,1)*DN(2,1); -const double clhs253 = clhs10*clhs252; -const double clhs254 = clhs232 + clhs234; -const double clhs255 = DN(2,2)*clhs249; -const double clhs256 = DN(1,1)*N[2]; -const double clhs257 = DN(2,1)*N[1]; -const double clhs258 = DN(3,0)*clhs249; -const double clhs259 = DN(1,1)*DN(3,1); -const double clhs260 = clhs10*clhs259; -const double clhs261 = clhs240 + clhs242; -const double clhs262 = DN(3,2)*clhs249; -const double clhs263 = DN(1,1)*N[3]; -const double clhs264 = DN(3,1)*N[1]; -const double clhs265 = DN(1,2)*DN(1,2); -const double clhs266 = DN(1,2)*clhs10; -const double clhs267 = DN(2,0)*clhs266; -const double clhs268 = DN(2,1)*clhs266; -const double clhs269 = DN(1,2)*DN(2,2); -const double clhs270 = clhs10*clhs269; -const double clhs271 = DN(1,2)*N[2]; -const double clhs272 = DN(2,2)*N[1]; -const double clhs273 = DN(3,0)*clhs266; -const double clhs274 = DN(3,1)*clhs266; -const double clhs275 = DN(1,2)*DN(3,2); -const double clhs276 = clhs10*clhs275; -const double clhs277 = DN(1,2)*N[3]; -const double clhs278 = DN(3,2)*N[1]; -const double clhs279 = N[1] + clhs215; -const double clhs280 = clhs16*(clhs231 + clhs252 + clhs269); -const double clhs281 = clhs16*(clhs239 + clhs259 + clhs275); -const double clhs282 = clhs17*clhs79; -const double clhs283 = N[2]*clhs20; -const double clhs284 = clhs11*clhs76 + clhs15*clhs282 + clhs15*clhs283; -const double clhs285 = clhs38*clhs79; -const double clhs286 = clhs282*clhs52 + clhs283*clhs52 + clhs50*clhs76; -const double clhs287 = DN(2,0)*DN(2,0); -const double clhs288 = clhs13*(N[2]*N[2]) + clhs282*clhs81 + clhs283*clhs81 + clhs76*clhs79; -const double clhs289 = DN(2,0)*clhs10; -const double clhs290 = DN(2,1)*clhs289; -const double clhs291 = DN(2,2)*clhs289; -const double clhs292 = -N[2] + clhs285 + clhs37*clhs76; -const double clhs293 = DN(2,0)*DN(3,0); -const double clhs294 = clhs104*clhs80; -const double clhs295 = clhs10*clhs293 + clhs294; -const double clhs296 = clhs107*clhs76 + clhs108*clhs282 + clhs108*clhs283; -const double clhs297 = DN(3,1)*clhs289; -const double clhs298 = DN(3,2)*clhs289; -const double clhs299 = DN(2,0)*N[3]; -const double clhs300 = DN(3,0)*N[2]; -const double clhs301 = clhs284 + clhs77; -const double clhs302 = clhs232 + clhs286; -const double clhs303 = DN(2,1)*DN(2,1); -const double clhs304 = DN(2,1)*clhs10; -const double clhs305 = DN(2,2)*clhs304; -const double clhs306 = DN(3,0)*clhs304; -const double clhs307 = DN(2,1)*DN(3,1); -const double clhs308 = clhs10*clhs307; -const double clhs309 = clhs294 + clhs296; -const double clhs310 = DN(3,2)*clhs304; -const double clhs311 = DN(2,1)*N[3]; -const double clhs312 = DN(3,1)*N[2]; -const double clhs313 = DN(2,2)*DN(2,2); -const double clhs314 = DN(2,2)*clhs10; -const double clhs315 = DN(3,0)*clhs314; -const double clhs316 = DN(3,1)*clhs314; -const double clhs317 = DN(2,2)*DN(3,2); -const double clhs318 = clhs10*clhs317; -const double clhs319 = DN(2,2)*N[3]; -const double clhs320 = DN(3,2)*N[2]; -const double clhs321 = N[2] + clhs217; -const double clhs322 = clhs16*(clhs293 + clhs307 + clhs317); -const double clhs323 = clhs107*clhs17; -const double clhs324 = N[3]*clhs20; -const double clhs325 = clhs104*clhs11 + clhs15*clhs323 + clhs15*clhs324; -const double clhs326 = clhs107*clhs38; -const double clhs327 = clhs104*clhs50 + clhs323*clhs52 + clhs324*clhs52; -const double clhs328 = clhs104*clhs79 + clhs323*clhs81 + clhs324*clhs81; -const double clhs329 = DN(3,0)*DN(3,0); -const double clhs330 = clhs104*clhs107 + clhs108*clhs323 + clhs108*clhs324 + clhs13*(N[3]*N[3]); -const double clhs331 = DN(3,0)*clhs10; -const double clhs332 = DN(3,1)*clhs331; -const double clhs333 = DN(3,2)*clhs331; -const double clhs334 = -N[3] + clhs104*clhs37 + clhs326; -const double clhs335 = clhs105 + clhs325; -const double clhs336 = clhs240 + clhs327; -const double clhs337 = clhs294 + clhs328; -const double clhs338 = DN(3,1)*DN(3,1); -const double clhs339 = DN(3,1)*DN(3,2)*clhs10; -const double clhs340 = DN(3,2)*DN(3,2); -const double clhs341 = N[3] + clhs219; -lhs(0,0)=DN(0,0)*clhs0 + DN(0,1)*clhs2 + DN(0,2)*clhs4 + clhs10*clhs5 + clhs22; -lhs(0,1)=DN(0,0)*clhs23 + DN(0,1)*clhs25 + DN(0,2)*clhs28 + clhs30; -lhs(0,2)=DN(0,0)*clhs31 + DN(0,1)*clhs33 + DN(0,2)*clhs35 + clhs36; -lhs(0,3)=DN(0,0)*clhs40; -lhs(0,4)=DN(0,0)*clhs41 + DN(0,1)*clhs43 + DN(0,2)*clhs45 + clhs49 + clhs53; -lhs(0,5)=DN(0,0)*clhs54 + DN(0,1)*clhs56 + DN(0,2)*clhs59 + clhs60; -lhs(0,6)=DN(0,0)*clhs61 + DN(0,1)*clhs63 + DN(0,2)*clhs65 + clhs66; -lhs(0,7)=DN(1,0)*clhs39 - clhs67 + clhs68*clhs69; -lhs(0,8)=DN(0,0)*clhs70 + DN(0,1)*clhs72 + DN(0,2)*clhs74 + clhs78 + clhs82; -lhs(0,9)=DN(0,0)*clhs83 + DN(0,1)*clhs85 + DN(0,2)*clhs88 + clhs89; -lhs(0,10)=DN(0,0)*clhs90 + DN(0,1)*clhs92 + DN(0,2)*clhs94 + clhs95; -lhs(0,11)=DN(2,0)*clhs39 + clhs69*clhs97 - clhs96; -lhs(0,12)=DN(0,0)*clhs98 + DN(0,1)*clhs100 + DN(0,2)*clhs102 + clhs106 + clhs109; -lhs(0,13)=DN(0,0)*clhs110 + DN(0,1)*clhs112 + DN(0,2)*clhs115 + clhs116; -lhs(0,14)=DN(0,0)*clhs117 + DN(0,1)*clhs119 + DN(0,2)*clhs121 + clhs122; -lhs(0,15)=DN(3,0)*clhs39 - clhs123 + clhs124*clhs69; -lhs(1,0)=DN(0,0)*clhs2 + DN(0,1)*clhs125 + DN(0,2)*clhs126 + clhs30; -lhs(1,1)=DN(0,0)*clhs25 + DN(0,1)*clhs127 + DN(0,2)*clhs129 + clhs10*clhs130 + clhs22; -lhs(1,2)=DN(0,0)*clhs33 + DN(0,1)*clhs131 + DN(0,2)*clhs133 + clhs135; -lhs(1,3)=DN(0,1)*clhs40; -lhs(1,4)=DN(0,0)*clhs43 + DN(0,1)*clhs136 + DN(0,2)*clhs137 + clhs138; -lhs(1,5)=DN(0,0)*clhs56 + DN(0,1)*clhs139 + DN(0,2)*clhs141 + clhs143 + clhs144; -lhs(1,6)=DN(0,0)*clhs63 + DN(0,1)*clhs145 + DN(0,2)*clhs147 + clhs148; -lhs(1,7)=DN(1,1)*clhs39 - clhs149 + clhs150*clhs69; -lhs(1,8)=DN(0,0)*clhs72 + DN(0,1)*clhs151 + DN(0,2)*clhs152 + clhs153; -lhs(1,9)=DN(0,0)*clhs85 + DN(0,1)*clhs154 + DN(0,2)*clhs156 + clhs158 + clhs159; -lhs(1,10)=DN(0,0)*clhs92 + DN(0,1)*clhs160 + DN(0,2)*clhs162 + clhs163; -lhs(1,11)=DN(2,1)*clhs39 - clhs164 + clhs165*clhs69; -lhs(1,12)=DN(0,0)*clhs100 + DN(0,1)*clhs166 + DN(0,2)*clhs167 + clhs168; -lhs(1,13)=DN(0,0)*clhs112 + DN(0,1)*clhs169 + DN(0,2)*clhs171 + clhs173 + clhs174; -lhs(1,14)=DN(0,0)*clhs119 + DN(0,1)*clhs175 + DN(0,2)*clhs177 + clhs178; -lhs(1,15)=DN(3,1)*clhs39 - clhs179 + clhs180*clhs69; -lhs(2,0)=DN(0,0)*clhs4 + DN(0,1)*clhs126 + DN(0,2)*clhs181 + clhs36; -lhs(2,1)=DN(0,0)*clhs28 + DN(0,1)*clhs129 + DN(0,2)*clhs182 + clhs135; -lhs(2,2)=DN(0,0)*clhs35 + DN(0,1)*clhs133 + DN(0,2)*clhs183 + clhs10*clhs184 + clhs22; -lhs(2,3)=DN(0,2)*clhs40; -lhs(2,4)=DN(0,0)*clhs45 + DN(0,1)*clhs137 + DN(0,2)*clhs185 + clhs187; -lhs(2,5)=DN(0,0)*clhs59 + DN(0,1)*clhs141 + DN(0,2)*clhs188 + clhs189; -lhs(2,6)=DN(0,0)*clhs65 + DN(0,1)*clhs147 + DN(0,2)*clhs190 + clhs144 + clhs192; -lhs(2,7)=DN(1,2)*clhs39 - clhs193 + clhs194*clhs69; -lhs(2,8)=DN(0,0)*clhs74 + DN(0,1)*clhs152 + DN(0,2)*clhs195 + clhs196; -lhs(2,9)=DN(0,0)*clhs88 + DN(0,1)*clhs156 + DN(0,2)*clhs197 + clhs198; -lhs(2,10)=DN(0,0)*clhs94 + DN(0,1)*clhs162 + DN(0,2)*clhs199 + clhs159 + clhs201; -lhs(2,11)=DN(2,2)*clhs39 - clhs202 + clhs203*clhs69; -lhs(2,12)=DN(0,0)*clhs102 + DN(0,1)*clhs167 + DN(0,2)*clhs204 + clhs205; -lhs(2,13)=DN(0,0)*clhs115 + DN(0,1)*clhs171 + DN(0,2)*clhs206 + clhs207; -lhs(2,14)=DN(0,0)*clhs121 + DN(0,1)*clhs177 + DN(0,2)*clhs208 + clhs174 + clhs210; -lhs(2,15)=DN(3,2)*clhs39 - clhs211 + clhs212*clhs69; -lhs(3,0)=DN(0,0)*clhs214; -lhs(3,1)=DN(0,1)*clhs214; -lhs(3,2)=DN(0,2)*clhs214; -lhs(3,3)=clhs16*(clhs130 + clhs184 + clhs5); -lhs(3,4)=DN(0,0)*clhs215 + clhs68; -lhs(3,5)=DN(0,1)*clhs215 + clhs150; -lhs(3,6)=DN(0,2)*clhs215 + clhs194; -lhs(3,7)=clhs216; -lhs(3,8)=DN(0,0)*clhs217 + clhs97; -lhs(3,9)=DN(0,1)*clhs217 + clhs165; -lhs(3,10)=DN(0,2)*clhs217 + clhs203; -lhs(3,11)=clhs218; -lhs(3,12)=DN(0,0)*clhs219 + clhs124; -lhs(3,13)=DN(0,1)*clhs219 + clhs180; -lhs(3,14)=DN(0,2)*clhs219 + clhs212; -lhs(3,15)=clhs220; -lhs(4,0)=DN(1,0)*clhs0 + DN(1,1)*clhs2 + DN(1,2)*clhs4 + clhs223 + clhs49; -lhs(4,1)=DN(1,0)*clhs23 + DN(1,1)*clhs25 + DN(1,2)*clhs28 + clhs138; -lhs(4,2)=DN(1,0)*clhs31 + DN(1,1)*clhs33 + DN(1,2)*clhs35 + clhs187; -lhs(4,3)=DN(0,0)*clhs224 + clhs67*clhs69 - clhs68; -lhs(4,4)=DN(1,0)*clhs41 + DN(1,1)*clhs43 + DN(1,2)*clhs45 + clhs10*clhs225 + clhs226; -lhs(4,5)=DN(1,0)*clhs54 + DN(1,1)*clhs56 + DN(1,2)*clhs59 + clhs228; -lhs(4,6)=DN(1,0)*clhs61 + DN(1,1)*clhs63 + DN(1,2)*clhs65 + clhs229; -lhs(4,7)=DN(1,0)*clhs230; -lhs(4,8)=DN(1,0)*clhs70 + DN(1,1)*clhs72 + DN(1,2)*clhs74 + clhs233 + clhs234; -lhs(4,9)=DN(1,0)*clhs83 + DN(1,1)*clhs85 + DN(1,2)*clhs88 + clhs235; -lhs(4,10)=DN(1,0)*clhs90 + DN(1,1)*clhs92 + DN(1,2)*clhs94 + clhs236; -lhs(4,11)=DN(2,0)*clhs224 - clhs237 + clhs238*clhs69; -lhs(4,12)=DN(1,0)*clhs98 + DN(1,1)*clhs100 + DN(1,2)*clhs102 + clhs241 + clhs242; -lhs(4,13)=DN(1,0)*clhs110 + DN(1,1)*clhs112 + DN(1,2)*clhs115 + clhs243; -lhs(4,14)=DN(1,0)*clhs117 + DN(1,1)*clhs119 + DN(1,2)*clhs121 + clhs244; -lhs(4,15)=DN(3,0)*clhs224 - clhs245 + clhs246*clhs69; -lhs(5,0)=DN(1,0)*clhs2 + DN(1,1)*clhs125 + DN(1,2)*clhs126 + clhs60; -lhs(5,1)=DN(1,0)*clhs25 + DN(1,1)*clhs127 + DN(1,2)*clhs129 + clhs143 + clhs247; -lhs(5,2)=DN(1,0)*clhs33 + DN(1,1)*clhs131 + DN(1,2)*clhs133 + clhs189; -lhs(5,3)=DN(0,1)*clhs224 + clhs149*clhs69 - clhs150; -lhs(5,4)=DN(1,0)*clhs43 + DN(1,1)*clhs136 + DN(1,2)*clhs137 + clhs228; -lhs(5,5)=DN(1,0)*clhs56 + DN(1,1)*clhs139 + DN(1,2)*clhs141 + clhs10*clhs248 + clhs226; -lhs(5,6)=DN(1,0)*clhs63 + DN(1,1)*clhs145 + DN(1,2)*clhs147 + clhs250; -lhs(5,7)=DN(1,1)*clhs230; -lhs(5,8)=DN(1,0)*clhs72 + DN(1,1)*clhs151 + DN(1,2)*clhs152 + clhs251; -lhs(5,9)=DN(1,0)*clhs85 + DN(1,1)*clhs154 + DN(1,2)*clhs156 + clhs253 + clhs254; -lhs(5,10)=DN(1,0)*clhs92 + DN(1,1)*clhs160 + DN(1,2)*clhs162 + clhs255; -lhs(5,11)=DN(2,1)*clhs224 - clhs256 + clhs257*clhs69; -lhs(5,12)=DN(1,0)*clhs100 + DN(1,1)*clhs166 + DN(1,2)*clhs167 + clhs258; -lhs(5,13)=DN(1,0)*clhs112 + DN(1,1)*clhs169 + DN(1,2)*clhs171 + clhs260 + clhs261; -lhs(5,14)=DN(1,0)*clhs119 + DN(1,1)*clhs175 + DN(1,2)*clhs177 + clhs262; -lhs(5,15)=DN(3,1)*clhs224 - clhs263 + clhs264*clhs69; -lhs(6,0)=DN(1,0)*clhs4 + DN(1,1)*clhs126 + DN(1,2)*clhs181 + clhs66; -lhs(6,1)=DN(1,0)*clhs28 + DN(1,1)*clhs129 + DN(1,2)*clhs182 + clhs148; -lhs(6,2)=DN(1,0)*clhs35 + DN(1,1)*clhs133 + DN(1,2)*clhs183 + clhs192 + clhs247; -lhs(6,3)=DN(0,2)*clhs224 + clhs193*clhs69 - clhs194; -lhs(6,4)=DN(1,0)*clhs45 + DN(1,1)*clhs137 + DN(1,2)*clhs185 + clhs229; -lhs(6,5)=DN(1,0)*clhs59 + DN(1,1)*clhs141 + DN(1,2)*clhs188 + clhs250; -lhs(6,6)=DN(1,0)*clhs65 + DN(1,1)*clhs147 + DN(1,2)*clhs190 + clhs10*clhs265 + clhs226; -lhs(6,7)=DN(1,2)*clhs230; -lhs(6,8)=DN(1,0)*clhs74 + DN(1,1)*clhs152 + DN(1,2)*clhs195 + clhs267; -lhs(6,9)=DN(1,0)*clhs88 + DN(1,1)*clhs156 + DN(1,2)*clhs197 + clhs268; -lhs(6,10)=DN(1,0)*clhs94 + DN(1,1)*clhs162 + DN(1,2)*clhs199 + clhs254 + clhs270; -lhs(6,11)=DN(2,2)*clhs224 - clhs271 + clhs272*clhs69; -lhs(6,12)=DN(1,0)*clhs102 + DN(1,1)*clhs167 + DN(1,2)*clhs204 + clhs273; -lhs(6,13)=DN(1,0)*clhs115 + DN(1,1)*clhs171 + DN(1,2)*clhs206 + clhs274; -lhs(6,14)=DN(1,0)*clhs121 + DN(1,1)*clhs177 + DN(1,2)*clhs208 + clhs261 + clhs276; -lhs(6,15)=DN(3,2)*clhs224 - clhs277 + clhs278*clhs69; -lhs(7,0)=DN(1,0)*clhs213 + clhs67; -lhs(7,1)=DN(1,1)*clhs213 + clhs149; -lhs(7,2)=DN(1,2)*clhs213 + clhs193; -lhs(7,3)=clhs216; -lhs(7,4)=DN(1,0)*clhs279; -lhs(7,5)=DN(1,1)*clhs279; -lhs(7,6)=DN(1,2)*clhs279; -lhs(7,7)=clhs16*(clhs225 + clhs248 + clhs265); -lhs(7,8)=DN(1,0)*clhs217 + clhs238; -lhs(7,9)=DN(1,1)*clhs217 + clhs257; -lhs(7,10)=DN(1,2)*clhs217 + clhs272; -lhs(7,11)=clhs280; -lhs(7,12)=DN(1,0)*clhs219 + clhs246; -lhs(7,13)=DN(1,1)*clhs219 + clhs264; -lhs(7,14)=DN(1,2)*clhs219 + clhs278; -lhs(7,15)=clhs281; -lhs(8,0)=DN(2,0)*clhs0 + DN(2,1)*clhs2 + DN(2,2)*clhs4 + clhs284 + clhs78; -lhs(8,1)=DN(2,0)*clhs23 + DN(2,1)*clhs25 + DN(2,2)*clhs28 + clhs153; -lhs(8,2)=DN(2,0)*clhs31 + DN(2,1)*clhs33 + DN(2,2)*clhs35 + clhs196; -lhs(8,3)=DN(0,0)*clhs285 + clhs69*clhs96 - clhs97; -lhs(8,4)=DN(2,0)*clhs41 + DN(2,1)*clhs43 + DN(2,2)*clhs45 + clhs233 + clhs286; -lhs(8,5)=DN(2,0)*clhs54 + DN(2,1)*clhs56 + DN(2,2)*clhs59 + clhs251; -lhs(8,6)=DN(2,0)*clhs61 + DN(2,1)*clhs63 + DN(2,2)*clhs65 + clhs267; -lhs(8,7)=DN(1,0)*clhs285 + clhs237*clhs69 - clhs238; -lhs(8,8)=DN(2,0)*clhs70 + DN(2,1)*clhs72 + DN(2,2)*clhs74 + clhs10*clhs287 + clhs288; -lhs(8,9)=DN(2,0)*clhs83 + DN(2,1)*clhs85 + DN(2,2)*clhs88 + clhs290; -lhs(8,10)=DN(2,0)*clhs90 + DN(2,1)*clhs92 + DN(2,2)*clhs94 + clhs291; -lhs(8,11)=DN(2,0)*clhs292; -lhs(8,12)=DN(2,0)*clhs98 + DN(2,1)*clhs100 + DN(2,2)*clhs102 + clhs295 + clhs296; -lhs(8,13)=DN(2,0)*clhs110 + DN(2,1)*clhs112 + DN(2,2)*clhs115 + clhs297; -lhs(8,14)=DN(2,0)*clhs117 + DN(2,1)*clhs119 + DN(2,2)*clhs121 + clhs298; -lhs(8,15)=DN(3,0)*clhs285 - clhs299 + clhs300*clhs69; -lhs(9,0)=DN(2,0)*clhs2 + DN(2,1)*clhs125 + DN(2,2)*clhs126 + clhs89; -lhs(9,1)=DN(2,0)*clhs25 + DN(2,1)*clhs127 + DN(2,2)*clhs129 + clhs158 + clhs301; -lhs(9,2)=DN(2,0)*clhs33 + DN(2,1)*clhs131 + DN(2,2)*clhs133 + clhs198; -lhs(9,3)=DN(0,1)*clhs285 + clhs164*clhs69 - clhs165; -lhs(9,4)=DN(2,0)*clhs43 + DN(2,1)*clhs136 + DN(2,2)*clhs137 + clhs235; -lhs(9,5)=DN(2,0)*clhs56 + DN(2,1)*clhs139 + DN(2,2)*clhs141 + clhs253 + clhs302; -lhs(9,6)=DN(2,0)*clhs63 + DN(2,1)*clhs145 + DN(2,2)*clhs147 + clhs268; -lhs(9,7)=DN(1,1)*clhs285 + clhs256*clhs69 - clhs257; -lhs(9,8)=DN(2,0)*clhs72 + DN(2,1)*clhs151 + DN(2,2)*clhs152 + clhs290; -lhs(9,9)=DN(2,0)*clhs85 + DN(2,1)*clhs154 + DN(2,2)*clhs156 + clhs10*clhs303 + clhs288; -lhs(9,10)=DN(2,0)*clhs92 + DN(2,1)*clhs160 + DN(2,2)*clhs162 + clhs305; -lhs(9,11)=DN(2,1)*clhs292; -lhs(9,12)=DN(2,0)*clhs100 + DN(2,1)*clhs166 + DN(2,2)*clhs167 + clhs306; -lhs(9,13)=DN(2,0)*clhs112 + DN(2,1)*clhs169 + DN(2,2)*clhs171 + clhs308 + clhs309; -lhs(9,14)=DN(2,0)*clhs119 + DN(2,1)*clhs175 + DN(2,2)*clhs177 + clhs310; -lhs(9,15)=DN(3,1)*clhs285 - clhs311 + clhs312*clhs69; -lhs(10,0)=DN(2,0)*clhs4 + DN(2,1)*clhs126 + DN(2,2)*clhs181 + clhs95; -lhs(10,1)=DN(2,0)*clhs28 + DN(2,1)*clhs129 + DN(2,2)*clhs182 + clhs163; -lhs(10,2)=DN(2,0)*clhs35 + DN(2,1)*clhs133 + DN(2,2)*clhs183 + clhs201 + clhs301; -lhs(10,3)=DN(0,2)*clhs285 + clhs202*clhs69 - clhs203; -lhs(10,4)=DN(2,0)*clhs45 + DN(2,1)*clhs137 + DN(2,2)*clhs185 + clhs236; -lhs(10,5)=DN(2,0)*clhs59 + DN(2,1)*clhs141 + DN(2,2)*clhs188 + clhs255; -lhs(10,6)=DN(2,0)*clhs65 + DN(2,1)*clhs147 + DN(2,2)*clhs190 + clhs270 + clhs302; -lhs(10,7)=DN(1,2)*clhs285 + clhs271*clhs69 - clhs272; -lhs(10,8)=DN(2,0)*clhs74 + DN(2,1)*clhs152 + DN(2,2)*clhs195 + clhs291; -lhs(10,9)=DN(2,0)*clhs88 + DN(2,1)*clhs156 + DN(2,2)*clhs197 + clhs305; -lhs(10,10)=DN(2,0)*clhs94 + DN(2,1)*clhs162 + DN(2,2)*clhs199 + clhs10*clhs313 + clhs288; -lhs(10,11)=DN(2,2)*clhs292; -lhs(10,12)=DN(2,0)*clhs102 + DN(2,1)*clhs167 + DN(2,2)*clhs204 + clhs315; -lhs(10,13)=DN(2,0)*clhs115 + DN(2,1)*clhs171 + DN(2,2)*clhs206 + clhs316; -lhs(10,14)=DN(2,0)*clhs121 + DN(2,1)*clhs177 + DN(2,2)*clhs208 + clhs309 + clhs318; -lhs(10,15)=DN(3,2)*clhs285 - clhs319 + clhs320*clhs69; -lhs(11,0)=DN(2,0)*clhs213 + clhs96; -lhs(11,1)=DN(2,1)*clhs213 + clhs164; -lhs(11,2)=DN(2,2)*clhs213 + clhs202; -lhs(11,3)=clhs218; -lhs(11,4)=DN(2,0)*clhs215 + clhs237; -lhs(11,5)=DN(2,1)*clhs215 + clhs256; -lhs(11,6)=DN(2,2)*clhs215 + clhs271; -lhs(11,7)=clhs280; -lhs(11,8)=DN(2,0)*clhs321; -lhs(11,9)=DN(2,1)*clhs321; -lhs(11,10)=DN(2,2)*clhs321; -lhs(11,11)=clhs16*(clhs287 + clhs303 + clhs313); -lhs(11,12)=DN(2,0)*clhs219 + clhs300; -lhs(11,13)=DN(2,1)*clhs219 + clhs312; -lhs(11,14)=DN(2,2)*clhs219 + clhs320; -lhs(11,15)=clhs322; -lhs(12,0)=DN(3,0)*clhs0 + DN(3,1)*clhs2 + DN(3,2)*clhs4 + clhs106 + clhs325; -lhs(12,1)=DN(3,0)*clhs23 + DN(3,1)*clhs25 + DN(3,2)*clhs28 + clhs168; -lhs(12,2)=DN(3,0)*clhs31 + DN(3,1)*clhs33 + DN(3,2)*clhs35 + clhs205; -lhs(12,3)=DN(0,0)*clhs326 + clhs123*clhs69 - clhs124; -lhs(12,4)=DN(3,0)*clhs41 + DN(3,1)*clhs43 + DN(3,2)*clhs45 + clhs241 + clhs327; -lhs(12,5)=DN(3,0)*clhs54 + DN(3,1)*clhs56 + DN(3,2)*clhs59 + clhs258; -lhs(12,6)=DN(3,0)*clhs61 + DN(3,1)*clhs63 + DN(3,2)*clhs65 + clhs273; -lhs(12,7)=DN(1,0)*clhs326 + clhs245*clhs69 - clhs246; -lhs(12,8)=DN(3,0)*clhs70 + DN(3,1)*clhs72 + DN(3,2)*clhs74 + clhs295 + clhs328; -lhs(12,9)=DN(3,0)*clhs83 + DN(3,1)*clhs85 + DN(3,2)*clhs88 + clhs306; -lhs(12,10)=DN(3,0)*clhs90 + DN(3,1)*clhs92 + DN(3,2)*clhs94 + clhs315; -lhs(12,11)=DN(2,0)*clhs326 + clhs299*clhs69 - clhs300; -lhs(12,12)=DN(3,0)*clhs98 + DN(3,1)*clhs100 + DN(3,2)*clhs102 + clhs10*clhs329 + clhs330; -lhs(12,13)=DN(3,0)*clhs110 + DN(3,1)*clhs112 + DN(3,2)*clhs115 + clhs332; -lhs(12,14)=DN(3,0)*clhs117 + DN(3,1)*clhs119 + DN(3,2)*clhs121 + clhs333; -lhs(12,15)=DN(3,0)*clhs334; -lhs(13,0)=DN(3,0)*clhs2 + DN(3,1)*clhs125 + DN(3,2)*clhs126 + clhs116; -lhs(13,1)=DN(3,0)*clhs25 + DN(3,1)*clhs127 + DN(3,2)*clhs129 + clhs173 + clhs335; -lhs(13,2)=DN(3,0)*clhs33 + DN(3,1)*clhs131 + DN(3,2)*clhs133 + clhs207; -lhs(13,3)=DN(0,1)*clhs326 + clhs179*clhs69 - clhs180; -lhs(13,4)=DN(3,0)*clhs43 + DN(3,1)*clhs136 + DN(3,2)*clhs137 + clhs243; -lhs(13,5)=DN(3,0)*clhs56 + DN(3,1)*clhs139 + DN(3,2)*clhs141 + clhs260 + clhs336; -lhs(13,6)=DN(3,0)*clhs63 + DN(3,1)*clhs145 + DN(3,2)*clhs147 + clhs274; -lhs(13,7)=DN(1,1)*clhs326 + clhs263*clhs69 - clhs264; -lhs(13,8)=DN(3,0)*clhs72 + DN(3,1)*clhs151 + DN(3,2)*clhs152 + clhs297; -lhs(13,9)=DN(3,0)*clhs85 + DN(3,1)*clhs154 + DN(3,2)*clhs156 + clhs308 + clhs337; -lhs(13,10)=DN(3,0)*clhs92 + DN(3,1)*clhs160 + DN(3,2)*clhs162 + clhs316; -lhs(13,11)=DN(2,1)*clhs326 + clhs311*clhs69 - clhs312; -lhs(13,12)=DN(3,0)*clhs100 + DN(3,1)*clhs166 + DN(3,2)*clhs167 + clhs332; -lhs(13,13)=DN(3,0)*clhs112 + DN(3,1)*clhs169 + DN(3,2)*clhs171 + clhs10*clhs338 + clhs330; -lhs(13,14)=DN(3,0)*clhs119 + DN(3,1)*clhs175 + DN(3,2)*clhs177 + clhs339; -lhs(13,15)=DN(3,1)*clhs334; -lhs(14,0)=DN(3,0)*clhs4 + DN(3,1)*clhs126 + DN(3,2)*clhs181 + clhs122; -lhs(14,1)=DN(3,0)*clhs28 + DN(3,1)*clhs129 + DN(3,2)*clhs182 + clhs178; -lhs(14,2)=DN(3,0)*clhs35 + DN(3,1)*clhs133 + DN(3,2)*clhs183 + clhs210 + clhs335; -lhs(14,3)=DN(0,2)*clhs326 + clhs211*clhs69 - clhs212; -lhs(14,4)=DN(3,0)*clhs45 + DN(3,1)*clhs137 + DN(3,2)*clhs185 + clhs244; -lhs(14,5)=DN(3,0)*clhs59 + DN(3,1)*clhs141 + DN(3,2)*clhs188 + clhs262; -lhs(14,6)=DN(3,0)*clhs65 + DN(3,1)*clhs147 + DN(3,2)*clhs190 + clhs276 + clhs336; -lhs(14,7)=DN(1,2)*clhs326 + clhs277*clhs69 - clhs278; -lhs(14,8)=DN(3,0)*clhs74 + DN(3,1)*clhs152 + DN(3,2)*clhs195 + clhs298; -lhs(14,9)=DN(3,0)*clhs88 + DN(3,1)*clhs156 + DN(3,2)*clhs197 + clhs310; -lhs(14,10)=DN(3,0)*clhs94 + DN(3,1)*clhs162 + DN(3,2)*clhs199 + clhs318 + clhs337; -lhs(14,11)=DN(2,2)*clhs326 + clhs319*clhs69 - clhs320; -lhs(14,12)=DN(3,0)*clhs102 + DN(3,1)*clhs167 + DN(3,2)*clhs204 + clhs333; -lhs(14,13)=DN(3,0)*clhs115 + DN(3,1)*clhs171 + DN(3,2)*clhs206 + clhs339; -lhs(14,14)=DN(3,0)*clhs121 + DN(3,1)*clhs177 + DN(3,2)*clhs208 + clhs10*clhs340 + clhs330; -lhs(14,15)=DN(3,2)*clhs334; -lhs(15,0)=DN(3,0)*clhs213 + clhs123; -lhs(15,1)=DN(3,1)*clhs213 + clhs179; -lhs(15,2)=DN(3,2)*clhs213 + clhs211; -lhs(15,3)=clhs220; -lhs(15,4)=DN(3,0)*clhs215 + clhs245; -lhs(15,5)=DN(3,1)*clhs215 + clhs263; -lhs(15,6)=DN(3,2)*clhs215 + clhs277; -lhs(15,7)=clhs281; -lhs(15,8)=DN(3,0)*clhs217 + clhs299; -lhs(15,9)=DN(3,1)*clhs217 + clhs311; -lhs(15,10)=DN(3,2)*clhs217 + clhs319; -lhs(15,11)=clhs322; -lhs(15,12)=DN(3,0)*clhs341; -lhs(15,13)=DN(3,1)*clhs341; -lhs(15,14)=DN(3,2)*clhs341; -lhs(15,15)=clhs16*(clhs329 + clhs338 + clhs340); - - - // Add intermediate results to local system - noalias(rLHS) += lhs * rData.Weight; } template <> @@ -1248,72 +1246,71 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &rhs = rData.rhs; - - const double crhs0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2]; -const double crhs1 = N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0); -const double crhs2 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)); -const double crhs3 = N[0]*rho; -const double crhs4 = bdf0*crhs3; -const double crhs5 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs6 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs7 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs8 = crhs5 + crhs6 + crhs7; -const double crhs9 = 1.0/dt; -const double crhs10 = crhs3*crhs9; -const double crhs11 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); -const double crhs12 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double crhs13 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double crhs14 = rho*(crhs11*crhs12 + crhs13*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))); -const double crhs15 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); -const double crhs16 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); -const double crhs17 = crhs15*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs16*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); -const double crhs18 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); -const double crhs19 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); -const double crhs20 = crhs18*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs19*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); -const double crhs21 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); -const double crhs22 = crhs11 + crhs21 - volume_error_ratio; -const double crhs23 = rho*stab_c2*sqrt(crhs12*crhs12 + crhs13*crhs13); -const double crhs24 = crhs22*(crhs23*h*1.0/stab_c1 + mu); -const double crhs25 = bdf0*rho; -const double crhs26 = crhs2*crhs25; -const double crhs27 = crhs9*rho; -const double crhs28 = 1.0*1.0/(crhs23*1.0/h + crhs27*dyn_tau + mu*stab_c1*1.0/(h*h)); -const double crhs29 = crhs28*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] - crhs1*rho + crhs14 - crhs20*rho + crhs26 + rho*(crhs17 + crhs5*crhs9 + crhs6*crhs9 + crhs7*crhs9)); -const double crhs30 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); -const double crhs31 = crhs3*crhs30; -const double crhs32 = rho*(DN(0,0)*crhs12 + DN(0,1)*crhs13); -const double crhs33 = N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1); -const double crhs34 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)); -const double crhs35 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs36 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs37 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs38 = crhs35 + crhs36 + crhs37; -const double crhs39 = rho*(crhs12*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1)) + crhs13*crhs21); -const double crhs40 = crhs15*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs16*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); -const double crhs41 = crhs18*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs19*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); -const double crhs42 = crhs25*crhs34; -const double crhs43 = crhs28*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] - crhs33*rho + crhs39 - crhs41*rho + crhs42 + rho*(crhs35*crhs9 + crhs36*crhs9 + crhs37*crhs9 + crhs40)); -const double crhs44 = N[1]*crhs27; -const double crhs45 = N[1]*rho; -const double crhs46 = crhs30*crhs45; -const double crhs47 = rho*(DN(1,0)*crhs12 + DN(1,1)*crhs13); -const double crhs48 = N[2]*crhs27; -const double crhs49 = N[2]*rho; -const double crhs50 = crhs30*crhs49; -const double crhs51 = rho*(DN(2,0)*crhs12 + DN(2,1)*crhs13); -rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs24 - DN(0,0)*stress[0] - DN(0,1)*stress[2] + N[0]*crhs1*rho - N[0]*crhs14 + N[0]*crhs20*rho - crhs10*crhs8 - crhs17*crhs3 - crhs2*crhs4 - crhs29*crhs31 - crhs29*crhs32; -rhs[1]=-DN(0,0)*stress[2] + DN(0,1)*crhs0 - DN(0,1)*crhs24 - DN(0,1)*stress[1] + N[0]*crhs33*rho - N[0]*crhs39 + N[0]*crhs41*rho - crhs10*crhs38 - crhs3*crhs40 - crhs31*crhs43 - crhs32*crhs43 - crhs34*crhs4; -rhs[2]=-DN(0,0)*crhs29 - DN(0,1)*crhs43 - N[0]*crhs22; -rhs[3]=DN(1,0)*crhs0 - DN(1,0)*crhs24 - DN(1,0)*stress[0] - DN(1,1)*stress[2] + N[1]*crhs1*rho - N[1]*crhs14 + N[1]*crhs20*rho - N[1]*crhs26 - crhs17*crhs45 - crhs29*crhs46 - crhs29*crhs47 - crhs44*crhs8; -rhs[4]=-DN(1,0)*stress[2] + DN(1,1)*crhs0 - DN(1,1)*crhs24 - DN(1,1)*stress[1] + N[1]*crhs33*rho - N[1]*crhs39 + N[1]*crhs41*rho - N[1]*crhs42 - crhs38*crhs44 - crhs40*crhs45 - crhs43*crhs46 - crhs43*crhs47; -rhs[5]=-DN(1,0)*crhs29 - DN(1,1)*crhs43 - N[1]*crhs22; -rhs[6]=DN(2,0)*crhs0 - DN(2,0)*crhs24 - DN(2,0)*stress[0] - DN(2,1)*stress[2] + N[2]*crhs1*rho - N[2]*crhs14 + N[2]*crhs20*rho - N[2]*crhs26 - crhs17*crhs49 - crhs29*crhs50 - crhs29*crhs51 - crhs48*crhs8; -rhs[7]=-DN(2,0)*stress[2] + DN(2,1)*crhs0 - DN(2,1)*crhs24 - DN(2,1)*stress[1] + N[2]*crhs33*rho - N[2]*crhs39 + N[2]*crhs41*rho - N[2]*crhs42 - crhs38*crhs48 - crhs40*crhs49 - crhs43*crhs50 - crhs43*crhs51; -rhs[8]=-DN(2,0)*crhs29 - DN(2,1)*crhs43 - N[2]*crhs22; - - - noalias(rRHS) += rData.Weight * rhs; + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; + + const double crRHS0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2]; +const double crRHS1 = rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)); +const double crRHS2 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)); +const double crRHS3 = N[0]*rho; +const double crRHS4 = bdf0*crRHS3; +const double crRHS5 = N[0]*(vn(0,0) - vnn(0,0)); +const double crRHS6 = N[1]*(vn(1,0) - vnn(1,0)); +const double crRHS7 = N[2]*(vn(2,0) - vnn(2,0)); +const double crRHS8 = crRHS5 + crRHS6 + crRHS7; +const double crRHS9 = 1.0/dt; +const double crRHS10 = crRHS3*crRHS9; +const double crRHS11 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); +const double crRHS12 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crRHS13 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crRHS14 = rho*(crRHS11*crRHS12 + crRHS13*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))); +const double crRHS15 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crRHS16 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crRHS17 = crRHS15*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crRHS16*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crRHS18 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); +const double crRHS19 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); +const double crRHS20 = rho*(crRHS18*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crRHS19*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))); +const double crRHS21 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); +const double crRHS22 = crRHS11 + crRHS21 - volume_error_ratio; +const double crRHS23 = rho*stab_c2*sqrt(crRHS12*crRHS12 + crRHS13*crRHS13); +const double crRHS24 = crRHS22*(crRHS23*h*1.0/stab_c1 + mu); +const double crRHS25 = bdf0*rho; +const double crRHS26 = crRHS2*crRHS25; +const double crRHS27 = crRHS9*rho; +const double crRHS28 = 1.0*1.0/(crRHS23*1.0/h + crRHS27*dyn_tau + mu*stab_c1*1.0/(h*h)); +const double crRHS29 = crRHS28*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] - crRHS1 + crRHS14 - crRHS20 + crRHS26 + rho*(crRHS17 + crRHS5*crRHS9 + crRHS6*crRHS9 + crRHS7*crRHS9)); +const double crRHS30 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1); +const double crRHS31 = crRHS3*crRHS30; +const double crRHS32 = rho*(DN(0,0)*crRHS12 + DN(0,1)*crRHS13); +const double crRHS33 = rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)); +const double crRHS34 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)); +const double crRHS35 = N[0]*(vn(0,1) - vnn(0,1)); +const double crRHS36 = N[1]*(vn(1,1) - vnn(1,1)); +const double crRHS37 = N[2]*(vn(2,1) - vnn(2,1)); +const double crRHS38 = crRHS35 + crRHS36 + crRHS37; +const double crRHS39 = rho*(crRHS12*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1)) + crRHS13*crRHS21); +const double crRHS40 = crRHS15*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crRHS16*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); +const double crRHS41 = rho*(crRHS18*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crRHS19*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))); +const double crRHS42 = crRHS25*crRHS34; +const double crRHS43 = crRHS28*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] - crRHS33 + crRHS39 - crRHS41 + crRHS42 + rho*(crRHS35*crRHS9 + crRHS36*crRHS9 + crRHS37*crRHS9 + crRHS40)); +const double crRHS44 = N[1]*crRHS27; +const double crRHS45 = N[1]*rho; +const double crRHS46 = crRHS30*crRHS45; +const double crRHS47 = rho*(DN(1,0)*crRHS12 + DN(1,1)*crRHS13); +const double crRHS48 = N[2]*crRHS27; +const double crRHS49 = N[2]*rho; +const double crRHS50 = crRHS30*crRHS49; +const double crRHS51 = rho*(DN(2,0)*crRHS12 + DN(2,1)*crRHS13); +rRHS[0]+=-w_gauss*(-DN(0,0)*crRHS0 + DN(0,0)*crRHS24 + DN(0,0)*stress[0] + DN(0,1)*stress[2] - N[0]*crRHS1 + N[0]*crRHS14 - N[0]*crRHS20 + crRHS10*crRHS8 + crRHS17*crRHS3 + crRHS2*crRHS4 + crRHS29*crRHS31 + crRHS29*crRHS32); +rRHS[1]+=-w_gauss*(DN(0,0)*stress[2] - DN(0,1)*crRHS0 + DN(0,1)*crRHS24 + DN(0,1)*stress[1] - N[0]*crRHS33 + N[0]*crRHS39 - N[0]*crRHS41 + crRHS10*crRHS38 + crRHS3*crRHS40 + crRHS31*crRHS43 + crRHS32*crRHS43 + crRHS34*crRHS4); +rRHS[2]+=-w_gauss*(DN(0,0)*crRHS29 + DN(0,1)*crRHS43 + N[0]*crRHS22); +rRHS[3]+=-w_gauss*(-DN(1,0)*crRHS0 + DN(1,0)*crRHS24 + DN(1,0)*stress[0] + DN(1,1)*stress[2] - N[1]*crRHS1 + N[1]*crRHS14 - N[1]*crRHS20 + N[1]*crRHS26 + crRHS17*crRHS45 + crRHS29*crRHS46 + crRHS29*crRHS47 + crRHS44*crRHS8); +rRHS[4]+=-w_gauss*(DN(1,0)*stress[2] - DN(1,1)*crRHS0 + DN(1,1)*crRHS24 + DN(1,1)*stress[1] - N[1]*crRHS33 + N[1]*crRHS39 - N[1]*crRHS41 + N[1]*crRHS42 + crRHS38*crRHS44 + crRHS40*crRHS45 + crRHS43*crRHS46 + crRHS43*crRHS47); +rRHS[5]+=-w_gauss*(DN(1,0)*crRHS29 + DN(1,1)*crRHS43 + N[1]*crRHS22); +rRHS[6]+=-w_gauss*(-DN(2,0)*crRHS0 + DN(2,0)*crRHS24 + DN(2,0)*stress[0] + DN(2,1)*stress[2] - N[2]*crRHS1 + N[2]*crRHS14 - N[2]*crRHS20 + N[2]*crRHS26 + crRHS17*crRHS49 + crRHS29*crRHS50 + crRHS29*crRHS51 + crRHS48*crRHS8); +rRHS[7]+=-w_gauss*(DN(2,0)*stress[2] - DN(2,1)*crRHS0 + DN(2,1)*crRHS24 + DN(2,1)*stress[1] - N[2]*crRHS33 + N[2]*crRHS39 - N[2]*crRHS41 + N[2]*crRHS42 + crRHS38*crRHS48 + crRHS40*crRHS49 + crRHS43*crRHS50 + crRHS43*crRHS51); +rRHS[8]+=-w_gauss*(DN(2,0)*crRHS29 + DN(2,1)*crRHS43 + N[2]*crRHS22); + } template <> @@ -1366,101 +1363,100 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &rhs = rData.rhs; - - const double crhs0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2] + N[3]*p[3]; -const double crhs1 = N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0); -const double crhs2 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)) + N[3]*(v(3,0) - vfrac(3,0)); -const double crhs3 = N[0]*rho; -const double crhs4 = bdf0*crhs3; -const double crhs5 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs6 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs7 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs8 = N[3]*(vn(3,0) - vnn(3,0)); -const double crhs9 = crhs5 + crhs6 + crhs7 + crhs8; -const double crhs10 = 1.0/dt; -const double crhs11 = crhs10*crhs3; -const double crhs12 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); -const double crhs13 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double crhs14 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double crhs15 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double crhs16 = rho*(crhs12*crhs13 + crhs14*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs15*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0))); -const double crhs17 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); -const double crhs18 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); -const double crhs19 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); -const double crhs20 = crhs17*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs18*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs19*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); -const double crhs21 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); -const double crhs22 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); -const double crhs23 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); -const double crhs24 = crhs21*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs22*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs23*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)); -const double crhs25 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); -const double crhs26 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); -const double crhs27 = crhs12 + crhs25 + crhs26 - volume_error_ratio; -const double crhs28 = rho*stab_c2*sqrt(crhs13*crhs13 + crhs14*crhs14 + crhs15*crhs15); -const double crhs29 = crhs27*(crhs28*h*1.0/stab_c1 + mu); -const double crhs30 = bdf0*rho; -const double crhs31 = crhs2*crhs30; -const double crhs32 = crhs10*rho; -const double crhs33 = 1.0*1.0/(crhs28*1.0/h + crhs32*dyn_tau + mu*stab_c1*1.0/(h*h)); -const double crhs34 = crhs33*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] - crhs1*rho + crhs16 - crhs24*rho + crhs31 + rho*(crhs10*crhs5 + crhs10*crhs6 + crhs10*crhs7 + crhs10*crhs8 + crhs20)); -const double crhs35 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); -const double crhs36 = crhs3*crhs35; -const double crhs37 = rho*(DN(0,0)*crhs13 + DN(0,1)*crhs14 + DN(0,2)*crhs15); -const double crhs38 = N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1); -const double crhs39 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)) + N[3]*(v(3,1) - vfrac(3,1)); -const double crhs40 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs41 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs42 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs43 = N[3]*(vn(3,1) - vnn(3,1)); -const double crhs44 = crhs40 + crhs41 + crhs42 + crhs43; -const double crhs45 = rho*(crhs13*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs14*crhs25 + crhs15*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1))); -const double crhs46 = crhs17*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs18*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs19*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); -const double crhs47 = crhs21*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs22*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs23*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)); -const double crhs48 = crhs30*crhs39; -const double crhs49 = crhs33*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] - crhs38*rho + crhs45 - crhs47*rho + crhs48 + rho*(crhs10*crhs40 + crhs10*crhs41 + crhs10*crhs42 + crhs10*crhs43 + crhs46)); -const double crhs50 = N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2); -const double crhs51 = N[0]*(v(0,2) - vfrac(0,2)) + N[1]*(v(1,2) - vfrac(1,2)) + N[2]*(v(2,2) - vfrac(2,2)) + N[3]*(v(3,2) - vfrac(3,2)); -const double crhs52 = N[0]*(vn(0,2) - vnn(0,2)); -const double crhs53 = N[1]*(vn(1,2) - vnn(1,2)); -const double crhs54 = N[2]*(vn(2,2) - vnn(2,2)); -const double crhs55 = N[3]*(vn(3,2) - vnn(3,2)); -const double crhs56 = crhs52 + crhs53 + crhs54 + crhs55; -const double crhs57 = rho*(crhs13*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs14*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs15*crhs26); -const double crhs58 = crhs17*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs18*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs19*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); -const double crhs59 = crhs21*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs22*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs23*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)); -const double crhs60 = crhs30*crhs51; -const double crhs61 = crhs33*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] - crhs50*rho + crhs57 - crhs59*rho + crhs60 + rho*(crhs10*crhs52 + crhs10*crhs53 + crhs10*crhs54 + crhs10*crhs55 + crhs58)); -const double crhs62 = N[1]*crhs32; -const double crhs63 = N[1]*rho; -const double crhs64 = crhs35*crhs63; -const double crhs65 = rho*(DN(1,0)*crhs13 + DN(1,1)*crhs14 + DN(1,2)*crhs15); -const double crhs66 = N[2]*crhs32; -const double crhs67 = N[2]*rho; -const double crhs68 = crhs35*crhs67; -const double crhs69 = rho*(DN(2,0)*crhs13 + DN(2,1)*crhs14 + DN(2,2)*crhs15); -const double crhs70 = N[3]*crhs32; -const double crhs71 = N[3]*rho; -const double crhs72 = crhs35*crhs71; -const double crhs73 = rho*(DN(3,0)*crhs13 + DN(3,1)*crhs14 + DN(3,2)*crhs15); -rhs[0]=DN(0,0)*crhs0 - DN(0,0)*crhs29 - DN(0,0)*stress[0] - DN(0,1)*stress[3] - DN(0,2)*stress[5] + N[0]*crhs1*rho - N[0]*crhs16 + N[0]*crhs24*rho - crhs11*crhs9 - crhs2*crhs4 - crhs20*crhs3 - crhs34*crhs36 - crhs34*crhs37; -rhs[1]=-DN(0,0)*stress[3] + DN(0,1)*crhs0 - DN(0,1)*crhs29 - DN(0,1)*stress[1] - DN(0,2)*stress[4] + N[0]*crhs38*rho - N[0]*crhs45 + N[0]*crhs47*rho - crhs11*crhs44 - crhs3*crhs46 - crhs36*crhs49 - crhs37*crhs49 - crhs39*crhs4; -rhs[2]=-DN(0,0)*stress[5] - DN(0,1)*stress[4] + DN(0,2)*crhs0 - DN(0,2)*crhs29 - DN(0,2)*stress[2] + N[0]*crhs50*rho - N[0]*crhs57 + N[0]*crhs59*rho - crhs11*crhs56 - crhs3*crhs58 - crhs36*crhs61 - crhs37*crhs61 - crhs4*crhs51; -rhs[3]=-DN(0,0)*crhs34 - DN(0,1)*crhs49 - DN(0,2)*crhs61 - N[0]*crhs27; -rhs[4]=DN(1,0)*crhs0 - DN(1,0)*crhs29 - DN(1,0)*stress[0] - DN(1,1)*stress[3] - DN(1,2)*stress[5] + N[1]*crhs1*rho - N[1]*crhs16 + N[1]*crhs24*rho - N[1]*crhs31 - crhs20*crhs63 - crhs34*crhs64 - crhs34*crhs65 - crhs62*crhs9; -rhs[5]=-DN(1,0)*stress[3] + DN(1,1)*crhs0 - DN(1,1)*crhs29 - DN(1,1)*stress[1] - DN(1,2)*stress[4] + N[1]*crhs38*rho - N[1]*crhs45 + N[1]*crhs47*rho - N[1]*crhs48 - crhs44*crhs62 - crhs46*crhs63 - crhs49*crhs64 - crhs49*crhs65; -rhs[6]=-DN(1,0)*stress[5] - DN(1,1)*stress[4] + DN(1,2)*crhs0 - DN(1,2)*crhs29 - DN(1,2)*stress[2] + N[1]*crhs50*rho - N[1]*crhs57 + N[1]*crhs59*rho - N[1]*crhs60 - crhs56*crhs62 - crhs58*crhs63 - crhs61*crhs64 - crhs61*crhs65; -rhs[7]=-DN(1,0)*crhs34 - DN(1,1)*crhs49 - DN(1,2)*crhs61 - N[1]*crhs27; -rhs[8]=DN(2,0)*crhs0 - DN(2,0)*crhs29 - DN(2,0)*stress[0] - DN(2,1)*stress[3] - DN(2,2)*stress[5] + N[2]*crhs1*rho - N[2]*crhs16 + N[2]*crhs24*rho - N[2]*crhs31 - crhs20*crhs67 - crhs34*crhs68 - crhs34*crhs69 - crhs66*crhs9; -rhs[9]=-DN(2,0)*stress[3] + DN(2,1)*crhs0 - DN(2,1)*crhs29 - DN(2,1)*stress[1] - DN(2,2)*stress[4] + N[2]*crhs38*rho - N[2]*crhs45 + N[2]*crhs47*rho - N[2]*crhs48 - crhs44*crhs66 - crhs46*crhs67 - crhs49*crhs68 - crhs49*crhs69; -rhs[10]=-DN(2,0)*stress[5] - DN(2,1)*stress[4] + DN(2,2)*crhs0 - DN(2,2)*crhs29 - DN(2,2)*stress[2] + N[2]*crhs50*rho - N[2]*crhs57 + N[2]*crhs59*rho - N[2]*crhs60 - crhs56*crhs66 - crhs58*crhs67 - crhs61*crhs68 - crhs61*crhs69; -rhs[11]=-DN(2,0)*crhs34 - DN(2,1)*crhs49 - DN(2,2)*crhs61 - N[2]*crhs27; -rhs[12]=DN(3,0)*crhs0 - DN(3,0)*crhs29 - DN(3,0)*stress[0] - DN(3,1)*stress[3] - DN(3,2)*stress[5] + N[3]*crhs1*rho - N[3]*crhs16 + N[3]*crhs24*rho - N[3]*crhs31 - crhs20*crhs71 - crhs34*crhs72 - crhs34*crhs73 - crhs70*crhs9; -rhs[13]=-DN(3,0)*stress[3] + DN(3,1)*crhs0 - DN(3,1)*crhs29 - DN(3,1)*stress[1] - DN(3,2)*stress[4] + N[3]*crhs38*rho - N[3]*crhs45 + N[3]*crhs47*rho - N[3]*crhs48 - crhs44*crhs70 - crhs46*crhs71 - crhs49*crhs72 - crhs49*crhs73; -rhs[14]=-DN(3,0)*stress[5] - DN(3,1)*stress[4] + DN(3,2)*crhs0 - DN(3,2)*crhs29 - DN(3,2)*stress[2] + N[3]*crhs50*rho - N[3]*crhs57 + N[3]*crhs59*rho - N[3]*crhs60 - crhs56*crhs70 - crhs58*crhs71 - crhs61*crhs72 - crhs61*crhs73; -rhs[15]=-DN(3,0)*crhs34 - DN(3,1)*crhs49 - DN(3,2)*crhs61 - N[3]*crhs27; - - - noalias(rRHS) += rData.Weight * rhs; + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; + + const double crRHS0 = N[0]*p[0] + N[1]*p[1] + N[2]*p[2] + N[3]*p[3]; +const double crRHS1 = rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)); +const double crRHS2 = N[0]*(v(0,0) - vfrac(0,0)) + N[1]*(v(1,0) - vfrac(1,0)) + N[2]*(v(2,0) - vfrac(2,0)) + N[3]*(v(3,0) - vfrac(3,0)); +const double crRHS3 = N[0]*rho; +const double crRHS4 = bdf0*crRHS3; +const double crRHS5 = N[0]*(vn(0,0) - vnn(0,0)); +const double crRHS6 = N[1]*(vn(1,0) - vnn(1,0)); +const double crRHS7 = N[2]*(vn(2,0) - vnn(2,0)); +const double crRHS8 = N[3]*(vn(3,0) - vnn(3,0)); +const double crRHS9 = crRHS5 + crRHS6 + crRHS7 + crRHS8; +const double crRHS10 = 1.0/dt; +const double crRHS11 = crRHS10*crRHS3; +const double crRHS12 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); +const double crRHS13 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crRHS14 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crRHS15 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crRHS16 = rho*(crRHS12*crRHS13 + crRHS14*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crRHS15*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0))); +const double crRHS17 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crRHS18 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crRHS19 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crRHS20 = crRHS17*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crRHS18*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crRHS19*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crRHS21 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); +const double crRHS22 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); +const double crRHS23 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); +const double crRHS24 = rho*(crRHS21*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crRHS22*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crRHS23*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))); +const double crRHS25 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); +const double crRHS26 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); +const double crRHS27 = crRHS12 + crRHS25 + crRHS26 - volume_error_ratio; +const double crRHS28 = rho*stab_c2*sqrt(crRHS13*crRHS13 + crRHS14*crRHS14 + crRHS15*crRHS15); +const double crRHS29 = crRHS27*(crRHS28*h*1.0/stab_c1 + mu); +const double crRHS30 = bdf0*rho; +const double crRHS31 = crRHS2*crRHS30; +const double crRHS32 = crRHS10*rho; +const double crRHS33 = 1.0*1.0/(crRHS28*1.0/h + crRHS32*dyn_tau + mu*stab_c1*1.0/(h*h)); +const double crRHS34 = crRHS33*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] - crRHS1 + crRHS16 - crRHS24 + crRHS31 + rho*(crRHS10*crRHS5 + crRHS10*crRHS6 + crRHS10*crRHS7 + crRHS10*crRHS8 + crRHS20)); +const double crRHS35 = DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2); +const double crRHS36 = crRHS3*crRHS35; +const double crRHS37 = rho*(DN(0,0)*crRHS13 + DN(0,1)*crRHS14 + DN(0,2)*crRHS15); +const double crRHS38 = rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)); +const double crRHS39 = N[0]*(v(0,1) - vfrac(0,1)) + N[1]*(v(1,1) - vfrac(1,1)) + N[2]*(v(2,1) - vfrac(2,1)) + N[3]*(v(3,1) - vfrac(3,1)); +const double crRHS40 = N[0]*(vn(0,1) - vnn(0,1)); +const double crRHS41 = N[1]*(vn(1,1) - vnn(1,1)); +const double crRHS42 = N[2]*(vn(2,1) - vnn(2,1)); +const double crRHS43 = N[3]*(vn(3,1) - vnn(3,1)); +const double crRHS44 = crRHS40 + crRHS41 + crRHS42 + crRHS43; +const double crRHS45 = rho*(crRHS13*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crRHS14*crRHS25 + crRHS15*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1))); +const double crRHS46 = crRHS17*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crRHS18*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crRHS19*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); +const double crRHS47 = rho*(crRHS21*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crRHS22*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crRHS23*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))); +const double crRHS48 = crRHS30*crRHS39; +const double crRHS49 = crRHS33*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] - crRHS38 + crRHS45 - crRHS47 + crRHS48 + rho*(crRHS10*crRHS40 + crRHS10*crRHS41 + crRHS10*crRHS42 + crRHS10*crRHS43 + crRHS46)); +const double crRHS50 = rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)); +const double crRHS51 = N[0]*(v(0,2) - vfrac(0,2)) + N[1]*(v(1,2) - vfrac(1,2)) + N[2]*(v(2,2) - vfrac(2,2)) + N[3]*(v(3,2) - vfrac(3,2)); +const double crRHS52 = N[0]*(vn(0,2) - vnn(0,2)); +const double crRHS53 = N[1]*(vn(1,2) - vnn(1,2)); +const double crRHS54 = N[2]*(vn(2,2) - vnn(2,2)); +const double crRHS55 = N[3]*(vn(3,2) - vnn(3,2)); +const double crRHS56 = crRHS52 + crRHS53 + crRHS54 + crRHS55; +const double crRHS57 = rho*(crRHS13*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crRHS14*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crRHS15*crRHS26); +const double crRHS58 = crRHS17*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crRHS18*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crRHS19*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crRHS59 = rho*(crRHS21*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crRHS22*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crRHS23*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))); +const double crRHS60 = crRHS30*crRHS51; +const double crRHS61 = crRHS33*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] - crRHS50 + crRHS57 - crRHS59 + crRHS60 + rho*(crRHS10*crRHS52 + crRHS10*crRHS53 + crRHS10*crRHS54 + crRHS10*crRHS55 + crRHS58)); +const double crRHS62 = N[1]*crRHS32; +const double crRHS63 = N[1]*rho; +const double crRHS64 = crRHS35*crRHS63; +const double crRHS65 = rho*(DN(1,0)*crRHS13 + DN(1,1)*crRHS14 + DN(1,2)*crRHS15); +const double crRHS66 = N[2]*crRHS32; +const double crRHS67 = N[2]*rho; +const double crRHS68 = crRHS35*crRHS67; +const double crRHS69 = rho*(DN(2,0)*crRHS13 + DN(2,1)*crRHS14 + DN(2,2)*crRHS15); +const double crRHS70 = N[3]*crRHS32; +const double crRHS71 = N[3]*rho; +const double crRHS72 = crRHS35*crRHS71; +const double crRHS73 = rho*(DN(3,0)*crRHS13 + DN(3,1)*crRHS14 + DN(3,2)*crRHS15); +rRHS[0]+=-w_gauss*(-DN(0,0)*crRHS0 + DN(0,0)*crRHS29 + DN(0,0)*stress[0] + DN(0,1)*stress[3] + DN(0,2)*stress[5] - N[0]*crRHS1 + N[0]*crRHS16 - N[0]*crRHS24 + crRHS11*crRHS9 + crRHS2*crRHS4 + crRHS20*crRHS3 + crRHS34*crRHS36 + crRHS34*crRHS37); +rRHS[1]+=-w_gauss*(DN(0,0)*stress[3] - DN(0,1)*crRHS0 + DN(0,1)*crRHS29 + DN(0,1)*stress[1] + DN(0,2)*stress[4] - N[0]*crRHS38 + N[0]*crRHS45 - N[0]*crRHS47 + crRHS11*crRHS44 + crRHS3*crRHS46 + crRHS36*crRHS49 + crRHS37*crRHS49 + crRHS39*crRHS4); +rRHS[2]+=-w_gauss*(DN(0,0)*stress[5] + DN(0,1)*stress[4] - DN(0,2)*crRHS0 + DN(0,2)*crRHS29 + DN(0,2)*stress[2] - N[0]*crRHS50 + N[0]*crRHS57 - N[0]*crRHS59 + crRHS11*crRHS56 + crRHS3*crRHS58 + crRHS36*crRHS61 + crRHS37*crRHS61 + crRHS4*crRHS51); +rRHS[3]+=-w_gauss*(DN(0,0)*crRHS34 + DN(0,1)*crRHS49 + DN(0,2)*crRHS61 + N[0]*crRHS27); +rRHS[4]+=-w_gauss*(-DN(1,0)*crRHS0 + DN(1,0)*crRHS29 + DN(1,0)*stress[0] + DN(1,1)*stress[3] + DN(1,2)*stress[5] - N[1]*crRHS1 + N[1]*crRHS16 - N[1]*crRHS24 + N[1]*crRHS31 + crRHS20*crRHS63 + crRHS34*crRHS64 + crRHS34*crRHS65 + crRHS62*crRHS9); +rRHS[5]+=-w_gauss*(DN(1,0)*stress[3] - DN(1,1)*crRHS0 + DN(1,1)*crRHS29 + DN(1,1)*stress[1] + DN(1,2)*stress[4] - N[1]*crRHS38 + N[1]*crRHS45 - N[1]*crRHS47 + N[1]*crRHS48 + crRHS44*crRHS62 + crRHS46*crRHS63 + crRHS49*crRHS64 + crRHS49*crRHS65); +rRHS[6]+=-w_gauss*(DN(1,0)*stress[5] + DN(1,1)*stress[4] - DN(1,2)*crRHS0 + DN(1,2)*crRHS29 + DN(1,2)*stress[2] - N[1]*crRHS50 + N[1]*crRHS57 - N[1]*crRHS59 + N[1]*crRHS60 + crRHS56*crRHS62 + crRHS58*crRHS63 + crRHS61*crRHS64 + crRHS61*crRHS65); +rRHS[7]+=-w_gauss*(DN(1,0)*crRHS34 + DN(1,1)*crRHS49 + DN(1,2)*crRHS61 + N[1]*crRHS27); +rRHS[8]+=-w_gauss*(-DN(2,0)*crRHS0 + DN(2,0)*crRHS29 + DN(2,0)*stress[0] + DN(2,1)*stress[3] + DN(2,2)*stress[5] - N[2]*crRHS1 + N[2]*crRHS16 - N[2]*crRHS24 + N[2]*crRHS31 + crRHS20*crRHS67 + crRHS34*crRHS68 + crRHS34*crRHS69 + crRHS66*crRHS9); +rRHS[9]+=-w_gauss*(DN(2,0)*stress[3] - DN(2,1)*crRHS0 + DN(2,1)*crRHS29 + DN(2,1)*stress[1] + DN(2,2)*stress[4] - N[2]*crRHS38 + N[2]*crRHS45 - N[2]*crRHS47 + N[2]*crRHS48 + crRHS44*crRHS66 + crRHS46*crRHS67 + crRHS49*crRHS68 + crRHS49*crRHS69); +rRHS[10]+=-w_gauss*(DN(2,0)*stress[5] + DN(2,1)*stress[4] - DN(2,2)*crRHS0 + DN(2,2)*crRHS29 + DN(2,2)*stress[2] - N[2]*crRHS50 + N[2]*crRHS57 - N[2]*crRHS59 + N[2]*crRHS60 + crRHS56*crRHS66 + crRHS58*crRHS67 + crRHS61*crRHS68 + crRHS61*crRHS69); +rRHS[11]+=-w_gauss*(DN(2,0)*crRHS34 + DN(2,1)*crRHS49 + DN(2,2)*crRHS61 + N[2]*crRHS27); +rRHS[12]+=-w_gauss*(-DN(3,0)*crRHS0 + DN(3,0)*crRHS29 + DN(3,0)*stress[0] + DN(3,1)*stress[3] + DN(3,2)*stress[5] - N[3]*crRHS1 + N[3]*crRHS16 - N[3]*crRHS24 + N[3]*crRHS31 + crRHS20*crRHS71 + crRHS34*crRHS72 + crRHS34*crRHS73 + crRHS70*crRHS9); +rRHS[13]+=-w_gauss*(DN(3,0)*stress[3] - DN(3,1)*crRHS0 + DN(3,1)*crRHS29 + DN(3,1)*stress[1] + DN(3,2)*stress[4] - N[3]*crRHS38 + N[3]*crRHS45 - N[3]*crRHS47 + N[3]*crRHS48 + crRHS44*crRHS70 + crRHS46*crRHS71 + crRHS49*crRHS72 + crRHS49*crRHS73); +rRHS[14]+=-w_gauss*(DN(3,0)*stress[5] + DN(3,1)*stress[4] - DN(3,2)*crRHS0 + DN(3,2)*crRHS29 + DN(3,2)*stress[2] - N[3]*crRHS50 + N[3]*crRHS57 - N[3]*crRHS59 + N[3]*crRHS60 + crRHS56*crRHS70 + crRHS58*crRHS71 + crRHS61*crRHS72 + crRHS61*crRHS73); +rRHS[15]+=-w_gauss*(DN(3,0)*crRHS34 + DN(3,1)*crRHS49 + DN(3,2)*crRHS61 + N[3]*crRHS27); + } template <> @@ -1518,132 +1514,128 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &V = rData.V; - auto &H = rData.H; - auto &Kee = rData.Kee; - auto &rhs_ee = rData.rhs_ee; - array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it - const double cV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double cV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double cV2 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1)); -const double cV3 = cV2*rho; -const double cV4 = cV3*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); -const double cV5 = N[0]*cV4; -const double cV6 = cV3*(DN(0,0)*cV0 + DN(0,1)*cV1); -const double cV7 = N[1]*cV4; -const double cV8 = cV3*(DN(1,0)*cV0 + DN(1,1)*cV1); -const double cV9 = N[2]*cV4; -const double cV10 = cV3*(DN(2,0)*cV0 + DN(2,1)*cV1); -V(0,0)=-DN(0,0)*Nenr[0] + DNenr(0,0)*cV5 + DNenr(0,0)*cV6; -V(0,1)=-DN(0,0)*Nenr[1] + DNenr(1,0)*cV5 + DNenr(1,0)*cV6; -V(0,2)=-DN(0,0)*Nenr[2] + DNenr(2,0)*cV5 + DNenr(2,0)*cV6; -V(1,0)=-DN(0,1)*Nenr[0] + DNenr(0,1)*cV5 + DNenr(0,1)*cV6; -V(1,1)=-DN(0,1)*Nenr[1] + DNenr(1,1)*cV5 + DNenr(1,1)*cV6; -V(1,2)=-DN(0,1)*Nenr[2] + DNenr(2,1)*cV5 + DNenr(2,1)*cV6; -V(2,0)=cV2*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); -V(2,1)=cV2*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); -V(2,2)=cV2*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); -V(3,0)=-DN(1,0)*Nenr[0] + DNenr(0,0)*cV7 + DNenr(0,0)*cV8; -V(3,1)=-DN(1,0)*Nenr[1] + DNenr(1,0)*cV7 + DNenr(1,0)*cV8; -V(3,2)=-DN(1,0)*Nenr[2] + DNenr(2,0)*cV7 + DNenr(2,0)*cV8; -V(4,0)=-DN(1,1)*Nenr[0] + DNenr(0,1)*cV7 + DNenr(0,1)*cV8; -V(4,1)=-DN(1,1)*Nenr[1] + DNenr(1,1)*cV7 + DNenr(1,1)*cV8; -V(4,2)=-DN(1,1)*Nenr[2] + DNenr(2,1)*cV7 + DNenr(2,1)*cV8; -V(5,0)=cV2*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); -V(5,1)=cV2*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); -V(5,2)=cV2*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); -V(6,0)=-DN(2,0)*Nenr[0] + DNenr(0,0)*cV10 + DNenr(0,0)*cV9; -V(6,1)=-DN(2,0)*Nenr[1] + DNenr(1,0)*cV10 + DNenr(1,0)*cV9; -V(6,2)=-DN(2,0)*Nenr[2] + DNenr(2,0)*cV10 + DNenr(2,0)*cV9; -V(7,0)=-DN(2,1)*Nenr[0] + DNenr(0,1)*cV10 + DNenr(0,1)*cV9; -V(7,1)=-DN(2,1)*Nenr[1] + DNenr(1,1)*cV10 + DNenr(1,1)*cV9; -V(7,2)=-DN(2,1)*Nenr[2] + DNenr(2,1)*cV10 + DNenr(2,1)*cV9; -V(8,0)=cV2*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); -V(8,1)=cV2*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); -V(8,2)=cV2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); - - - const double cH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double cH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double cH2 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1)); -const double cH3 = cH2*rho; -const double cH4 = cH3*(DN(0,0)*cH0 + DN(0,1)*cH1 + N[0]*bdf0); -const double cH5 = cH3*(DN(1,0)*cH0 + DN(1,1)*cH1 + N[1]*bdf0); -const double cH6 = cH3*(DN(2,0)*cH0 + DN(2,1)*cH1 + N[2]*bdf0); -H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH4; -H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH4; -H(0,2)=cH2*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); -H(0,3)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH5; -H(0,4)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH5; -H(0,5)=cH2*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); -H(0,6)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH6; -H(0,7)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH6; -H(0,8)=cH2*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); -H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH4; -H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH4; -H(1,2)=cH2*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); -H(1,3)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH5; -H(1,4)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH5; -H(1,5)=cH2*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); -H(1,6)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH6; -H(1,7)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH6; -H(1,8)=cH2*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); -H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH4; -H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH4; -H(2,2)=cH2*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); -H(2,3)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH5; -H(2,4)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH5; -H(2,5)=cH2*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); -H(2,6)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH6; -H(2,7)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH6; -H(2,8)=cH2*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); - - - const double cKee0 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1), 2))*1.0/h); -const double cKee1 = cKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1)); -const double cKee2 = cKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1)); -const double cKee3 = cKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1)); -Kee(0,0)=cKee0*(DNenr(0,0)*DNenr(0,0) + DNenr(0,1)*DNenr(0,1)); -Kee(0,1)=cKee1; -Kee(0,2)=cKee2; -Kee(1,0)=cKee1; -Kee(1,1)=cKee0*(DNenr(1,0)*DNenr(1,0) + DNenr(1,1)*DNenr(1,1)); -Kee(1,2)=cKee3; -Kee(2,0)=cKee2; -Kee(2,1)=cKee3; -Kee(2,2)=cKee0*(DNenr(2,0)*DNenr(2,0) + DNenr(2,1)*DNenr(2,1)); - - - const double crhs_ee0 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); -const double crhs_ee1 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); -const double crhs_ee2 = crhs_ee0 + crhs_ee1 - volume_error_ratio; -const double crhs_ee3 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); -const double crhs_ee4 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); -const double crhs_ee5 = N[0]*bdf0; -const double crhs_ee6 = N[1]*bdf0; -const double crhs_ee7 = N[2]*bdf0; -const double crhs_ee8 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double crhs_ee9 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double crhs_ee10 = 1.0/dt; -const double crhs_ee11 = N[0]*crhs_ee10; -const double crhs_ee12 = N[1]*crhs_ee10; -const double crhs_ee13 = N[2]*crhs_ee10; -const double crhs_ee14 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); -const double crhs_ee15 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); -const double crhs_ee16 = 1.0*1.0/(crhs_ee10*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee8*crhs_ee8 + crhs_ee9*crhs_ee9)); -const double crhs_ee17 = crhs_ee16*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] - rho*(crhs_ee3*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs_ee4*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)) + rho*(crhs_ee0*crhs_ee8 + crhs_ee5*(v(0,0) - vfrac(0,0)) + crhs_ee6*(v(1,0) - vfrac(1,0)) + crhs_ee7*(v(2,0) - vfrac(2,0)) + crhs_ee9*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))) + rho*(crhs_ee11*(vn(0,0) - vnn(0,0)) + crhs_ee12*(vn(1,0) - vnn(1,0)) + crhs_ee13*(vn(2,0) - vnn(2,0)) + crhs_ee14*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crhs_ee15*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)))); -const double crhs_ee18 = crhs_ee16*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] - rho*(crhs_ee3*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs_ee4*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)) + rho*(crhs_ee1*crhs_ee9 + crhs_ee5*(v(0,1) - vfrac(0,1)) + crhs_ee6*(v(1,1) - vfrac(1,1)) + crhs_ee7*(v(2,1) - vfrac(2,1)) + crhs_ee8*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1))) + rho*(crhs_ee11*(vn(0,1) - vnn(0,1)) + crhs_ee12*(vn(1,1) - vnn(1,1)) + crhs_ee13*(vn(2,1) - vnn(2,1)) + crhs_ee14*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crhs_ee15*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)))); -rhs_ee[0]=-DNenr(0,0)*crhs_ee17 - DNenr(0,1)*crhs_ee18 - Nenr[0]*crhs_ee2; -rhs_ee[1]=-DNenr(1,0)*crhs_ee17 - DNenr(1,1)*crhs_ee18 - Nenr[1]*crhs_ee2; -rhs_ee[2]=-DNenr(2,0)*crhs_ee17 - DNenr(2,1)*crhs_ee18 - Nenr[2]*crhs_ee2; - - - noalias(rV) += rData.Weight * V; - noalias(rH) += rData.Weight * H; - noalias(rKee) += rData.Weight * Kee; - noalias(rRHS_ee) += rData.Weight * rhs_ee; + // Add Enrichment Gauss point contribution + const double w_gauss = rData.Weight; + + const double crV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crV2 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crV0*crV0 + crV1*crV1)); +const double crV3 = crV2*rho; +const double crV4 = crV3*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crV5 = N[0]*crV4; +const double crV6 = crV3*(DN(0,0)*crV0 + DN(0,1)*crV1); +const double crV7 = crV2*w_gauss; +const double crV8 = N[1]*crV4; +const double crV9 = crV3*(DN(1,0)*crV0 + DN(1,1)*crV1); +const double crV10 = N[2]*crV4; +const double crV11 = crV3*(DN(2,0)*crV0 + DN(2,1)*crV1); +rV(0,0)+=w_gauss*(-DN(0,0)*Nenr[0] + DNenr(0,0)*crV5 + DNenr(0,0)*crV6); +rV(0,1)+=w_gauss*(-DN(0,0)*Nenr[1] + DNenr(1,0)*crV5 + DNenr(1,0)*crV6); +rV(0,2)+=w_gauss*(-DN(0,0)*Nenr[2] + DNenr(2,0)*crV5 + DNenr(2,0)*crV6); +rV(1,0)+=w_gauss*(-DN(0,1)*Nenr[0] + DNenr(0,1)*crV5 + DNenr(0,1)*crV6); +rV(1,1)+=w_gauss*(-DN(0,1)*Nenr[1] + DNenr(1,1)*crV5 + DNenr(1,1)*crV6); +rV(1,2)+=w_gauss*(-DN(0,1)*Nenr[2] + DNenr(2,1)*crV5 + DNenr(2,1)*crV6); +rV(2,0)+=crV7*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); +rV(2,1)+=crV7*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); +rV(2,2)+=crV7*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); +rV(3,0)+=w_gauss*(-DN(1,0)*Nenr[0] + DNenr(0,0)*crV8 + DNenr(0,0)*crV9); +rV(3,1)+=w_gauss*(-DN(1,0)*Nenr[1] + DNenr(1,0)*crV8 + DNenr(1,0)*crV9); +rV(3,2)+=w_gauss*(-DN(1,0)*Nenr[2] + DNenr(2,0)*crV8 + DNenr(2,0)*crV9); +rV(4,0)+=w_gauss*(-DN(1,1)*Nenr[0] + DNenr(0,1)*crV8 + DNenr(0,1)*crV9); +rV(4,1)+=w_gauss*(-DN(1,1)*Nenr[1] + DNenr(1,1)*crV8 + DNenr(1,1)*crV9); +rV(4,2)+=w_gauss*(-DN(1,1)*Nenr[2] + DNenr(2,1)*crV8 + DNenr(2,1)*crV9); +rV(5,0)+=crV7*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); +rV(5,1)+=crV7*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); +rV(5,2)+=crV7*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); +rV(6,0)+=w_gauss*(-DN(2,0)*Nenr[0] + DNenr(0,0)*crV10 + DNenr(0,0)*crV11); +rV(6,1)+=w_gauss*(-DN(2,0)*Nenr[1] + DNenr(1,0)*crV10 + DNenr(1,0)*crV11); +rV(6,2)+=w_gauss*(-DN(2,0)*Nenr[2] + DNenr(2,0)*crV10 + DNenr(2,0)*crV11); +rV(7,0)+=w_gauss*(-DN(2,1)*Nenr[0] + DNenr(0,1)*crV10 + DNenr(0,1)*crV11); +rV(7,1)+=w_gauss*(-DN(2,1)*Nenr[1] + DNenr(1,1)*crV10 + DNenr(1,1)*crV11); +rV(7,2)+=w_gauss*(-DN(2,1)*Nenr[2] + DNenr(2,1)*crV10 + DNenr(2,1)*crV11); +rV(8,0)+=crV7*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); +rV(8,1)+=crV7*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); +rV(8,2)+=crV7*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); + + + const double crH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crH2 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crH0*crH0 + crH1*crH1)); +const double crH3 = crH2*rho; +const double crH4 = crH3*(DN(0,0)*crH0 + DN(0,1)*crH1 + N[0]*bdf0); +const double crH5 = crH2*w_gauss; +const double crH6 = crH3*(DN(1,0)*crH0 + DN(1,1)*crH1 + N[1]*bdf0); +const double crH7 = crH3*(DN(2,0)*crH0 + DN(2,1)*crH1 + N[2]*bdf0); +rH(0,0)+=w_gauss*(DN(0,0)*Nenr[0] + DNenr(0,0)*crH4); +rH(0,1)+=w_gauss*(DN(0,1)*Nenr[0] + DNenr(0,1)*crH4); +rH(0,2)+=crH5*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1)); +rH(0,3)+=w_gauss*(DN(1,0)*Nenr[0] + DNenr(0,0)*crH6); +rH(0,4)+=w_gauss*(DN(1,1)*Nenr[0] + DNenr(0,1)*crH6); +rH(0,5)+=crH5*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1)); +rH(0,6)+=w_gauss*(DN(2,0)*Nenr[0] + DNenr(0,0)*crH7); +rH(0,7)+=w_gauss*(DN(2,1)*Nenr[0] + DNenr(0,1)*crH7); +rH(0,8)+=crH5*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1)); +rH(1,0)+=w_gauss*(DN(0,0)*Nenr[1] + DNenr(1,0)*crH4); +rH(1,1)+=w_gauss*(DN(0,1)*Nenr[1] + DNenr(1,1)*crH4); +rH(1,2)+=crH5*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1)); +rH(1,3)+=w_gauss*(DN(1,0)*Nenr[1] + DNenr(1,0)*crH6); +rH(1,4)+=w_gauss*(DN(1,1)*Nenr[1] + DNenr(1,1)*crH6); +rH(1,5)+=crH5*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1)); +rH(1,6)+=w_gauss*(DN(2,0)*Nenr[1] + DNenr(1,0)*crH7); +rH(1,7)+=w_gauss*(DN(2,1)*Nenr[1] + DNenr(1,1)*crH7); +rH(1,8)+=crH5*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1)); +rH(2,0)+=w_gauss*(DN(0,0)*Nenr[2] + DNenr(2,0)*crH4); +rH(2,1)+=w_gauss*(DN(0,1)*Nenr[2] + DNenr(2,1)*crH4); +rH(2,2)+=crH5*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1)); +rH(2,3)+=w_gauss*(DN(1,0)*Nenr[2] + DNenr(2,0)*crH6); +rH(2,4)+=w_gauss*(DN(1,1)*Nenr[2] + DNenr(2,1)*crH6); +rH(2,5)+=crH5*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1)); +rH(2,6)+=w_gauss*(DN(2,0)*Nenr[2] + DNenr(2,0)*crH7); +rH(2,7)+=w_gauss*(DN(2,1)*Nenr[2] + DNenr(2,1)*crH7); +rH(2,8)+=crH5*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1)); + + + const double crKee0 = 1.0*w_gauss*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1), 2))*1.0/h); +const double crKee1 = crKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1)); +const double crKee2 = crKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1)); +const double crKee3 = crKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1)); +rKee(0,0)+=crKee0*(DNenr(0,0)*DNenr(0,0) + DNenr(0,1)*DNenr(0,1)); +rKee(0,1)+=crKee1; +rKee(0,2)+=crKee2; +rKee(1,0)+=crKee1; +rKee(1,1)+=crKee0*(DNenr(1,0)*DNenr(1,0) + DNenr(1,1)*DNenr(1,1)); +rKee(1,2)+=crKee3; +rKee(2,0)+=crKee2; +rKee(2,1)+=crKee3; +rKee(2,2)+=crKee0*(DNenr(2,0)*DNenr(2,0) + DNenr(2,1)*DNenr(2,1)); + + + const double crRHS_ee0 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0); +const double crRHS_ee1 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1); +const double crRHS_ee2 = crRHS_ee0 + crRHS_ee1 - volume_error_ratio; +const double crRHS_ee3 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0); +const double crRHS_ee4 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1); +const double crRHS_ee5 = N[0]*bdf0; +const double crRHS_ee6 = N[1]*bdf0; +const double crRHS_ee7 = N[2]*bdf0; +const double crRHS_ee8 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crRHS_ee9 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crRHS_ee10 = 1.0/dt; +const double crRHS_ee11 = N[0]*crRHS_ee10; +const double crRHS_ee12 = N[1]*crRHS_ee10; +const double crRHS_ee13 = N[2]*crRHS_ee10; +const double crRHS_ee14 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crRHS_ee15 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crRHS_ee16 = 1.0*1.0/(crRHS_ee10*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crRHS_ee8*crRHS_ee8 + crRHS_ee9*crRHS_ee9)); +const double crRHS_ee17 = crRHS_ee16*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] - rho*(crRHS_ee3*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crRHS_ee4*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)) + rho*(crRHS_ee0*crRHS_ee8 + crRHS_ee5*(v(0,0) - vfrac(0,0)) + crRHS_ee6*(v(1,0) - vfrac(1,0)) + crRHS_ee7*(v(2,0) - vfrac(2,0)) + crRHS_ee9*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))) + rho*(crRHS_ee11*(vn(0,0) - vnn(0,0)) + crRHS_ee12*(vn(1,0) - vnn(1,0)) + crRHS_ee13*(vn(2,0) - vnn(2,0)) + crRHS_ee14*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)) + crRHS_ee15*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)))); +const double crRHS_ee18 = crRHS_ee16*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] - rho*(crRHS_ee3*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crRHS_ee4*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)) + rho*(crRHS_ee1*crRHS_ee9 + crRHS_ee5*(v(0,1) - vfrac(0,1)) + crRHS_ee6*(v(1,1) - vfrac(1,1)) + crRHS_ee7*(v(2,1) - vfrac(2,1)) + crRHS_ee8*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1))) + rho*(crRHS_ee11*(vn(0,1) - vnn(0,1)) + crRHS_ee12*(vn(1,1) - vnn(1,1)) + crRHS_ee13*(vn(2,1) - vnn(2,1)) + crRHS_ee14*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)) + crRHS_ee15*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)))); +rRHS_ee[0]+=-w_gauss*(DNenr(0,0)*crRHS_ee17 + DNenr(0,1)*crRHS_ee18 + Nenr[0]*crRHS_ee2); +rRHS_ee[1]+=-w_gauss*(DNenr(1,0)*crRHS_ee17 + DNenr(1,1)*crRHS_ee18 + Nenr[1]*crRHS_ee2); +rRHS_ee[2]+=-w_gauss*(DNenr(2,0)*crRHS_ee17 + DNenr(2,1)*crRHS_ee18 + Nenr[2]*crRHS_ee2); + + } template <> @@ -1700,229 +1692,224 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &V = rData.V; - auto &H = rData.H; - auto &Kee = rData.Kee; - auto &rhs_ee = rData.rhs_ee; + // Add Enrichment Gauss point contribution + const double w_gauss = rData.Weight; array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it - const double cV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double cV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double cV2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double cV3 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cV0*cV0 + cV1*cV1 + cV2*cV2)); -const double cV4 = cV3*rho; -const double cV5 = cV4*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); -const double cV6 = N[0]*cV5; -const double cV7 = cV4*(DN(0,0)*cV0 + DN(0,1)*cV1 + DN(0,2)*cV2); -const double cV8 = N[1]*cV5; -const double cV9 = cV4*(DN(1,0)*cV0 + DN(1,1)*cV1 + DN(1,2)*cV2); -const double cV10 = N[2]*cV5; -const double cV11 = cV4*(DN(2,0)*cV0 + DN(2,1)*cV1 + DN(2,2)*cV2); -const double cV12 = N[3]*cV5; -const double cV13 = cV4*(DN(3,0)*cV0 + DN(3,1)*cV1 + DN(3,2)*cV2); -V(0,0)=-DN(0,0)*Nenr[0] + DNenr(0,0)*cV6 + DNenr(0,0)*cV7; -V(0,1)=-DN(0,0)*Nenr[1] + DNenr(1,0)*cV6 + DNenr(1,0)*cV7; -V(0,2)=-DN(0,0)*Nenr[2] + DNenr(2,0)*cV6 + DNenr(2,0)*cV7; -V(0,3)=-DN(0,0)*Nenr[3] + DNenr(3,0)*cV6 + DNenr(3,0)*cV7; -V(1,0)=-DN(0,1)*Nenr[0] + DNenr(0,1)*cV6 + DNenr(0,1)*cV7; -V(1,1)=-DN(0,1)*Nenr[1] + DNenr(1,1)*cV6 + DNenr(1,1)*cV7; -V(1,2)=-DN(0,1)*Nenr[2] + DNenr(2,1)*cV6 + DNenr(2,1)*cV7; -V(1,3)=-DN(0,1)*Nenr[3] + DNenr(3,1)*cV6 + DNenr(3,1)*cV7; -V(2,0)=-DN(0,2)*Nenr[0] + DNenr(0,2)*cV6 + DNenr(0,2)*cV7; -V(2,1)=-DN(0,2)*Nenr[1] + DNenr(1,2)*cV6 + DNenr(1,2)*cV7; -V(2,2)=-DN(0,2)*Nenr[2] + DNenr(2,2)*cV6 + DNenr(2,2)*cV7; -V(2,3)=-DN(0,2)*Nenr[3] + DNenr(3,2)*cV6 + DNenr(3,2)*cV7; -V(3,0)=cV3*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); -V(3,1)=cV3*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); -V(3,2)=cV3*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); -V(3,3)=cV3*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); -V(4,0)=-DN(1,0)*Nenr[0] + DNenr(0,0)*cV8 + DNenr(0,0)*cV9; -V(4,1)=-DN(1,0)*Nenr[1] + DNenr(1,0)*cV8 + DNenr(1,0)*cV9; -V(4,2)=-DN(1,0)*Nenr[2] + DNenr(2,0)*cV8 + DNenr(2,0)*cV9; -V(4,3)=-DN(1,0)*Nenr[3] + DNenr(3,0)*cV8 + DNenr(3,0)*cV9; -V(5,0)=-DN(1,1)*Nenr[0] + DNenr(0,1)*cV8 + DNenr(0,1)*cV9; -V(5,1)=-DN(1,1)*Nenr[1] + DNenr(1,1)*cV8 + DNenr(1,1)*cV9; -V(5,2)=-DN(1,1)*Nenr[2] + DNenr(2,1)*cV8 + DNenr(2,1)*cV9; -V(5,3)=-DN(1,1)*Nenr[3] + DNenr(3,1)*cV8 + DNenr(3,1)*cV9; -V(6,0)=-DN(1,2)*Nenr[0] + DNenr(0,2)*cV8 + DNenr(0,2)*cV9; -V(6,1)=-DN(1,2)*Nenr[1] + DNenr(1,2)*cV8 + DNenr(1,2)*cV9; -V(6,2)=-DN(1,2)*Nenr[2] + DNenr(2,2)*cV8 + DNenr(2,2)*cV9; -V(6,3)=-DN(1,2)*Nenr[3] + DNenr(3,2)*cV8 + DNenr(3,2)*cV9; -V(7,0)=cV3*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); -V(7,1)=cV3*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); -V(7,2)=cV3*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); -V(7,3)=cV3*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); -V(8,0)=-DN(2,0)*Nenr[0] + DNenr(0,0)*cV10 + DNenr(0,0)*cV11; -V(8,1)=-DN(2,0)*Nenr[1] + DNenr(1,0)*cV10 + DNenr(1,0)*cV11; -V(8,2)=-DN(2,0)*Nenr[2] + DNenr(2,0)*cV10 + DNenr(2,0)*cV11; -V(8,3)=-DN(2,0)*Nenr[3] + DNenr(3,0)*cV10 + DNenr(3,0)*cV11; -V(9,0)=-DN(2,1)*Nenr[0] + DNenr(0,1)*cV10 + DNenr(0,1)*cV11; -V(9,1)=-DN(2,1)*Nenr[1] + DNenr(1,1)*cV10 + DNenr(1,1)*cV11; -V(9,2)=-DN(2,1)*Nenr[2] + DNenr(2,1)*cV10 + DNenr(2,1)*cV11; -V(9,3)=-DN(2,1)*Nenr[3] + DNenr(3,1)*cV10 + DNenr(3,1)*cV11; -V(10,0)=-DN(2,2)*Nenr[0] + DNenr(0,2)*cV10 + DNenr(0,2)*cV11; -V(10,1)=-DN(2,2)*Nenr[1] + DNenr(1,2)*cV10 + DNenr(1,2)*cV11; -V(10,2)=-DN(2,2)*Nenr[2] + DNenr(2,2)*cV10 + DNenr(2,2)*cV11; -V(10,3)=-DN(2,2)*Nenr[3] + DNenr(3,2)*cV10 + DNenr(3,2)*cV11; -V(11,0)=cV3*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); -V(11,1)=cV3*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); -V(11,2)=cV3*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); -V(11,3)=cV3*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); -V(12,0)=-DN(3,0)*Nenr[0] + DNenr(0,0)*cV12 + DNenr(0,0)*cV13; -V(12,1)=-DN(3,0)*Nenr[1] + DNenr(1,0)*cV12 + DNenr(1,0)*cV13; -V(12,2)=-DN(3,0)*Nenr[2] + DNenr(2,0)*cV12 + DNenr(2,0)*cV13; -V(12,3)=-DN(3,0)*Nenr[3] + DNenr(3,0)*cV12 + DNenr(3,0)*cV13; -V(13,0)=-DN(3,1)*Nenr[0] + DNenr(0,1)*cV12 + DNenr(0,1)*cV13; -V(13,1)=-DN(3,1)*Nenr[1] + DNenr(1,1)*cV12 + DNenr(1,1)*cV13; -V(13,2)=-DN(3,1)*Nenr[2] + DNenr(2,1)*cV12 + DNenr(2,1)*cV13; -V(13,3)=-DN(3,1)*Nenr[3] + DNenr(3,1)*cV12 + DNenr(3,1)*cV13; -V(14,0)=-DN(3,2)*Nenr[0] + DNenr(0,2)*cV12 + DNenr(0,2)*cV13; -V(14,1)=-DN(3,2)*Nenr[1] + DNenr(1,2)*cV12 + DNenr(1,2)*cV13; -V(14,2)=-DN(3,2)*Nenr[2] + DNenr(2,2)*cV12 + DNenr(2,2)*cV13; -V(14,3)=-DN(3,2)*Nenr[3] + DNenr(3,2)*cV12 + DNenr(3,2)*cV13; -V(15,0)=cV3*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); -V(15,1)=cV3*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); -V(15,2)=cV3*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); -V(15,3)=cV3*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); - - - const double cH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double cH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double cH2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double cH3 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(cH0*cH0 + cH1*cH1 + cH2*cH2)); -const double cH4 = cH3*rho; -const double cH5 = cH4*(DN(0,0)*cH0 + DN(0,1)*cH1 + DN(0,2)*cH2 + N[0]*bdf0); -const double cH6 = cH4*(DN(1,0)*cH0 + DN(1,1)*cH1 + DN(1,2)*cH2 + N[1]*bdf0); -const double cH7 = cH4*(DN(2,0)*cH0 + DN(2,1)*cH1 + DN(2,2)*cH2 + N[2]*bdf0); -const double cH8 = cH4*(DN(3,0)*cH0 + DN(3,1)*cH1 + DN(3,2)*cH2 + N[3]*bdf0); -H(0,0)=DN(0,0)*Nenr[0] + DNenr(0,0)*cH5; -H(0,1)=DN(0,1)*Nenr[0] + DNenr(0,1)*cH5; -H(0,2)=DN(0,2)*Nenr[0] + DNenr(0,2)*cH5; -H(0,3)=cH3*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); -H(0,4)=DN(1,0)*Nenr[0] + DNenr(0,0)*cH6; -H(0,5)=DN(1,1)*Nenr[0] + DNenr(0,1)*cH6; -H(0,6)=DN(1,2)*Nenr[0] + DNenr(0,2)*cH6; -H(0,7)=cH3*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); -H(0,8)=DN(2,0)*Nenr[0] + DNenr(0,0)*cH7; -H(0,9)=DN(2,1)*Nenr[0] + DNenr(0,1)*cH7; -H(0,10)=DN(2,2)*Nenr[0] + DNenr(0,2)*cH7; -H(0,11)=cH3*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); -H(0,12)=DN(3,0)*Nenr[0] + DNenr(0,0)*cH8; -H(0,13)=DN(3,1)*Nenr[0] + DNenr(0,1)*cH8; -H(0,14)=DN(3,2)*Nenr[0] + DNenr(0,2)*cH8; -H(0,15)=cH3*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); -H(1,0)=DN(0,0)*Nenr[1] + DNenr(1,0)*cH5; -H(1,1)=DN(0,1)*Nenr[1] + DNenr(1,1)*cH5; -H(1,2)=DN(0,2)*Nenr[1] + DNenr(1,2)*cH5; -H(1,3)=cH3*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); -H(1,4)=DN(1,0)*Nenr[1] + DNenr(1,0)*cH6; -H(1,5)=DN(1,1)*Nenr[1] + DNenr(1,1)*cH6; -H(1,6)=DN(1,2)*Nenr[1] + DNenr(1,2)*cH6; -H(1,7)=cH3*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); -H(1,8)=DN(2,0)*Nenr[1] + DNenr(1,0)*cH7; -H(1,9)=DN(2,1)*Nenr[1] + DNenr(1,1)*cH7; -H(1,10)=DN(2,2)*Nenr[1] + DNenr(1,2)*cH7; -H(1,11)=cH3*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); -H(1,12)=DN(3,0)*Nenr[1] + DNenr(1,0)*cH8; -H(1,13)=DN(3,1)*Nenr[1] + DNenr(1,1)*cH8; -H(1,14)=DN(3,2)*Nenr[1] + DNenr(1,2)*cH8; -H(1,15)=cH3*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); -H(2,0)=DN(0,0)*Nenr[2] + DNenr(2,0)*cH5; -H(2,1)=DN(0,1)*Nenr[2] + DNenr(2,1)*cH5; -H(2,2)=DN(0,2)*Nenr[2] + DNenr(2,2)*cH5; -H(2,3)=cH3*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); -H(2,4)=DN(1,0)*Nenr[2] + DNenr(2,0)*cH6; -H(2,5)=DN(1,1)*Nenr[2] + DNenr(2,1)*cH6; -H(2,6)=DN(1,2)*Nenr[2] + DNenr(2,2)*cH6; -H(2,7)=cH3*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); -H(2,8)=DN(2,0)*Nenr[2] + DNenr(2,0)*cH7; -H(2,9)=DN(2,1)*Nenr[2] + DNenr(2,1)*cH7; -H(2,10)=DN(2,2)*Nenr[2] + DNenr(2,2)*cH7; -H(2,11)=cH3*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); -H(2,12)=DN(3,0)*Nenr[2] + DNenr(2,0)*cH8; -H(2,13)=DN(3,1)*Nenr[2] + DNenr(2,1)*cH8; -H(2,14)=DN(3,2)*Nenr[2] + DNenr(2,2)*cH8; -H(2,15)=cH3*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); -H(3,0)=DN(0,0)*Nenr[3] + DNenr(3,0)*cH5; -H(3,1)=DN(0,1)*Nenr[3] + DNenr(3,1)*cH5; -H(3,2)=DN(0,2)*Nenr[3] + DNenr(3,2)*cH5; -H(3,3)=cH3*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); -H(3,4)=DN(1,0)*Nenr[3] + DNenr(3,0)*cH6; -H(3,5)=DN(1,1)*Nenr[3] + DNenr(3,1)*cH6; -H(3,6)=DN(1,2)*Nenr[3] + DNenr(3,2)*cH6; -H(3,7)=cH3*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); -H(3,8)=DN(2,0)*Nenr[3] + DNenr(3,0)*cH7; -H(3,9)=DN(2,1)*Nenr[3] + DNenr(3,1)*cH7; -H(3,10)=DN(2,2)*Nenr[3] + DNenr(3,2)*cH7; -H(3,11)=cH3*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); -H(3,12)=DN(3,0)*Nenr[3] + DNenr(3,0)*cH8; -H(3,13)=DN(3,1)*Nenr[3] + DNenr(3,1)*cH8; -H(3,14)=DN(3,2)*Nenr[3] + DNenr(3,2)*cH8; -H(3,15)=cH3*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); - - - const double cKee0 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1), 2) + pow(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2), 2))*1.0/h); -const double cKee1 = cKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1) + DNenr(0,2)*DNenr(1,2)); -const double cKee2 = cKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1) + DNenr(0,2)*DNenr(2,2)); -const double cKee3 = cKee0*(DNenr(0,0)*DNenr(3,0) + DNenr(0,1)*DNenr(3,1) + DNenr(0,2)*DNenr(3,2)); -const double cKee4 = cKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1) + DNenr(1,2)*DNenr(2,2)); -const double cKee5 = cKee0*(DNenr(1,0)*DNenr(3,0) + DNenr(1,1)*DNenr(3,1) + DNenr(1,2)*DNenr(3,2)); -const double cKee6 = cKee0*(DNenr(2,0)*DNenr(3,0) + DNenr(2,1)*DNenr(3,1) + DNenr(2,2)*DNenr(3,2)); -Kee(0,0)=cKee0*(DNenr(0,0)*DNenr(0,0) + DNenr(0,1)*DNenr(0,1) + DNenr(0,2)*DNenr(0,2)); -Kee(0,1)=cKee1; -Kee(0,2)=cKee2; -Kee(0,3)=cKee3; -Kee(1,0)=cKee1; -Kee(1,1)=cKee0*(DNenr(1,0)*DNenr(1,0) + DNenr(1,1)*DNenr(1,1) + DNenr(1,2)*DNenr(1,2)); -Kee(1,2)=cKee4; -Kee(1,3)=cKee5; -Kee(2,0)=cKee2; -Kee(2,1)=cKee4; -Kee(2,2)=cKee0*(DNenr(2,0)*DNenr(2,0) + DNenr(2,1)*DNenr(2,1) + DNenr(2,2)*DNenr(2,2)); -Kee(2,3)=cKee6; -Kee(3,0)=cKee3; -Kee(3,1)=cKee5; -Kee(3,2)=cKee6; -Kee(3,3)=cKee0*(DNenr(3,0)*DNenr(3,0) + DNenr(3,1)*DNenr(3,1) + DNenr(3,2)*DNenr(3,2)); - - - const double crhs_ee0 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); -const double crhs_ee1 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); -const double crhs_ee2 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); -const double crhs_ee3 = crhs_ee0 + crhs_ee1 + crhs_ee2 - volume_error_ratio; -const double crhs_ee4 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); -const double crhs_ee5 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); -const double crhs_ee6 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); -const double crhs_ee7 = N[0]*bdf0; -const double crhs_ee8 = N[1]*bdf0; -const double crhs_ee9 = N[2]*bdf0; -const double crhs_ee10 = N[3]*bdf0; -const double crhs_ee11 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double crhs_ee12 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double crhs_ee13 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double crhs_ee14 = 1.0/dt; -const double crhs_ee15 = N[0]*crhs_ee14; -const double crhs_ee16 = N[1]*crhs_ee14; -const double crhs_ee17 = N[2]*crhs_ee14; -const double crhs_ee18 = N[3]*crhs_ee14; -const double crhs_ee19 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); -const double crhs_ee20 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); -const double crhs_ee21 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); -const double crhs_ee22 = 1.0*1.0/(crhs_ee14*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crhs_ee11*crhs_ee11 + crhs_ee12*crhs_ee12 + crhs_ee13*crhs_ee13)); -const double crhs_ee23 = crhs_ee22*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + DNenr(3,0)*penr[3] - rho*(crhs_ee4*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs_ee5*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs_ee6*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)) + rho*(crhs_ee0*crhs_ee11 + crhs_ee10*(v(3,0) - vfrac(3,0)) + crhs_ee12*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crhs_ee13*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0)) + crhs_ee7*(v(0,0) - vfrac(0,0)) + crhs_ee8*(v(1,0) - vfrac(1,0)) + crhs_ee9*(v(2,0) - vfrac(2,0))) + rho*(crhs_ee15*(vn(0,0) - vnn(0,0)) + crhs_ee16*(vn(1,0) - vnn(1,0)) + crhs_ee17*(vn(2,0) - vnn(2,0)) + crhs_ee18*(vn(3,0) - vnn(3,0)) + crhs_ee19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crhs_ee20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crhs_ee21*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)))); -const double crhs_ee24 = crhs_ee22*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + DNenr(3,1)*penr[3] - rho*(crhs_ee4*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs_ee5*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs_ee6*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)) + rho*(crhs_ee1*crhs_ee12 + crhs_ee10*(v(3,1) - vfrac(3,1)) + crhs_ee11*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crhs_ee13*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1)) + crhs_ee7*(v(0,1) - vfrac(0,1)) + crhs_ee8*(v(1,1) - vfrac(1,1)) + crhs_ee9*(v(2,1) - vfrac(2,1))) + rho*(crhs_ee15*(vn(0,1) - vnn(0,1)) + crhs_ee16*(vn(1,1) - vnn(1,1)) + crhs_ee17*(vn(2,1) - vnn(2,1)) + crhs_ee18*(vn(3,1) - vnn(3,1)) + crhs_ee19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crhs_ee20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crhs_ee21*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)))); -const double crhs_ee25 = crhs_ee22*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] + DNenr(0,2)*penr[0] + DNenr(1,2)*penr[1] + DNenr(2,2)*penr[2] + DNenr(3,2)*penr[3] - rho*(crhs_ee4*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs_ee5*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs_ee6*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))) - rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)) + rho*(crhs_ee10*(v(3,2) - vfrac(3,2)) + crhs_ee11*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crhs_ee12*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crhs_ee13*crhs_ee2 + crhs_ee7*(v(0,2) - vfrac(0,2)) + crhs_ee8*(v(1,2) - vfrac(1,2)) + crhs_ee9*(v(2,2) - vfrac(2,2))) + rho*(crhs_ee15*(vn(0,2) - vnn(0,2)) + crhs_ee16*(vn(1,2) - vnn(1,2)) + crhs_ee17*(vn(2,2) - vnn(2,2)) + crhs_ee18*(vn(3,2) - vnn(3,2)) + crhs_ee19*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crhs_ee20*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crhs_ee21*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)))); -rhs_ee[0]=-DNenr(0,0)*crhs_ee23 - DNenr(0,1)*crhs_ee24 - DNenr(0,2)*crhs_ee25 - Nenr[0]*crhs_ee3; -rhs_ee[1]=-DNenr(1,0)*crhs_ee23 - DNenr(1,1)*crhs_ee24 - DNenr(1,2)*crhs_ee25 - Nenr[1]*crhs_ee3; -rhs_ee[2]=-DNenr(2,0)*crhs_ee23 - DNenr(2,1)*crhs_ee24 - DNenr(2,2)*crhs_ee25 - Nenr[2]*crhs_ee3; -rhs_ee[3]=-DNenr(3,0)*crhs_ee23 - DNenr(3,1)*crhs_ee24 - DNenr(3,2)*crhs_ee25 - Nenr[3]*crhs_ee3; - - - noalias(rV) += rData.Weight * V; - noalias(rH) += rData.Weight * H; - noalias(rKee) += rData.Weight * Kee; - noalias(rRHS_ee) += rData.Weight * rhs_ee; + const double crV0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crV1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crV2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crV3 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crV0*crV0 + crV1*crV1 + crV2*crV2)); +const double crV4 = crV3*rho; +const double crV5 = crV4*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crV6 = N[0]*crV5; +const double crV7 = crV4*(DN(0,0)*crV0 + DN(0,1)*crV1 + DN(0,2)*crV2); +const double crV8 = crV3*w_gauss; +const double crV9 = N[1]*crV5; +const double crV10 = crV4*(DN(1,0)*crV0 + DN(1,1)*crV1 + DN(1,2)*crV2); +const double crV11 = N[2]*crV5; +const double crV12 = crV4*(DN(2,0)*crV0 + DN(2,1)*crV1 + DN(2,2)*crV2); +const double crV13 = N[3]*crV5; +const double crV14 = crV4*(DN(3,0)*crV0 + DN(3,1)*crV1 + DN(3,2)*crV2); +rV(0,0)+=w_gauss*(-DN(0,0)*Nenr[0] + DNenr(0,0)*crV6 + DNenr(0,0)*crV7); +rV(0,1)+=w_gauss*(-DN(0,0)*Nenr[1] + DNenr(1,0)*crV6 + DNenr(1,0)*crV7); +rV(0,2)+=w_gauss*(-DN(0,0)*Nenr[2] + DNenr(2,0)*crV6 + DNenr(2,0)*crV7); +rV(0,3)+=w_gauss*(-DN(0,0)*Nenr[3] + DNenr(3,0)*crV6 + DNenr(3,0)*crV7); +rV(1,0)+=w_gauss*(-DN(0,1)*Nenr[0] + DNenr(0,1)*crV6 + DNenr(0,1)*crV7); +rV(1,1)+=w_gauss*(-DN(0,1)*Nenr[1] + DNenr(1,1)*crV6 + DNenr(1,1)*crV7); +rV(1,2)+=w_gauss*(-DN(0,1)*Nenr[2] + DNenr(2,1)*crV6 + DNenr(2,1)*crV7); +rV(1,3)+=w_gauss*(-DN(0,1)*Nenr[3] + DNenr(3,1)*crV6 + DNenr(3,1)*crV7); +rV(2,0)+=w_gauss*(-DN(0,2)*Nenr[0] + DNenr(0,2)*crV6 + DNenr(0,2)*crV7); +rV(2,1)+=w_gauss*(-DN(0,2)*Nenr[1] + DNenr(1,2)*crV6 + DNenr(1,2)*crV7); +rV(2,2)+=w_gauss*(-DN(0,2)*Nenr[2] + DNenr(2,2)*crV6 + DNenr(2,2)*crV7); +rV(2,3)+=w_gauss*(-DN(0,2)*Nenr[3] + DNenr(3,2)*crV6 + DNenr(3,2)*crV7); +rV(3,0)+=crV8*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); +rV(3,1)+=crV8*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); +rV(3,2)+=crV8*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); +rV(3,3)+=crV8*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); +rV(4,0)+=w_gauss*(-DN(1,0)*Nenr[0] + DNenr(0,0)*crV10 + DNenr(0,0)*crV9); +rV(4,1)+=w_gauss*(-DN(1,0)*Nenr[1] + DNenr(1,0)*crV10 + DNenr(1,0)*crV9); +rV(4,2)+=w_gauss*(-DN(1,0)*Nenr[2] + DNenr(2,0)*crV10 + DNenr(2,0)*crV9); +rV(4,3)+=w_gauss*(-DN(1,0)*Nenr[3] + DNenr(3,0)*crV10 + DNenr(3,0)*crV9); +rV(5,0)+=w_gauss*(-DN(1,1)*Nenr[0] + DNenr(0,1)*crV10 + DNenr(0,1)*crV9); +rV(5,1)+=w_gauss*(-DN(1,1)*Nenr[1] + DNenr(1,1)*crV10 + DNenr(1,1)*crV9); +rV(5,2)+=w_gauss*(-DN(1,1)*Nenr[2] + DNenr(2,1)*crV10 + DNenr(2,1)*crV9); +rV(5,3)+=w_gauss*(-DN(1,1)*Nenr[3] + DNenr(3,1)*crV10 + DNenr(3,1)*crV9); +rV(6,0)+=w_gauss*(-DN(1,2)*Nenr[0] + DNenr(0,2)*crV10 + DNenr(0,2)*crV9); +rV(6,1)+=w_gauss*(-DN(1,2)*Nenr[1] + DNenr(1,2)*crV10 + DNenr(1,2)*crV9); +rV(6,2)+=w_gauss*(-DN(1,2)*Nenr[2] + DNenr(2,2)*crV10 + DNenr(2,2)*crV9); +rV(6,3)+=w_gauss*(-DN(1,2)*Nenr[3] + DNenr(3,2)*crV10 + DNenr(3,2)*crV9); +rV(7,0)+=crV8*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); +rV(7,1)+=crV8*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); +rV(7,2)+=crV8*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); +rV(7,3)+=crV8*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); +rV(8,0)+=w_gauss*(-DN(2,0)*Nenr[0] + DNenr(0,0)*crV11 + DNenr(0,0)*crV12); +rV(8,1)+=w_gauss*(-DN(2,0)*Nenr[1] + DNenr(1,0)*crV11 + DNenr(1,0)*crV12); +rV(8,2)+=w_gauss*(-DN(2,0)*Nenr[2] + DNenr(2,0)*crV11 + DNenr(2,0)*crV12); +rV(8,3)+=w_gauss*(-DN(2,0)*Nenr[3] + DNenr(3,0)*crV11 + DNenr(3,0)*crV12); +rV(9,0)+=w_gauss*(-DN(2,1)*Nenr[0] + DNenr(0,1)*crV11 + DNenr(0,1)*crV12); +rV(9,1)+=w_gauss*(-DN(2,1)*Nenr[1] + DNenr(1,1)*crV11 + DNenr(1,1)*crV12); +rV(9,2)+=w_gauss*(-DN(2,1)*Nenr[2] + DNenr(2,1)*crV11 + DNenr(2,1)*crV12); +rV(9,3)+=w_gauss*(-DN(2,1)*Nenr[3] + DNenr(3,1)*crV11 + DNenr(3,1)*crV12); +rV(10,0)+=w_gauss*(-DN(2,2)*Nenr[0] + DNenr(0,2)*crV11 + DNenr(0,2)*crV12); +rV(10,1)+=w_gauss*(-DN(2,2)*Nenr[1] + DNenr(1,2)*crV11 + DNenr(1,2)*crV12); +rV(10,2)+=w_gauss*(-DN(2,2)*Nenr[2] + DNenr(2,2)*crV11 + DNenr(2,2)*crV12); +rV(10,3)+=w_gauss*(-DN(2,2)*Nenr[3] + DNenr(3,2)*crV11 + DNenr(3,2)*crV12); +rV(11,0)+=crV8*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); +rV(11,1)+=crV8*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); +rV(11,2)+=crV8*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); +rV(11,3)+=crV8*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); +rV(12,0)+=w_gauss*(-DN(3,0)*Nenr[0] + DNenr(0,0)*crV13 + DNenr(0,0)*crV14); +rV(12,1)+=w_gauss*(-DN(3,0)*Nenr[1] + DNenr(1,0)*crV13 + DNenr(1,0)*crV14); +rV(12,2)+=w_gauss*(-DN(3,0)*Nenr[2] + DNenr(2,0)*crV13 + DNenr(2,0)*crV14); +rV(12,3)+=w_gauss*(-DN(3,0)*Nenr[3] + DNenr(3,0)*crV13 + DNenr(3,0)*crV14); +rV(13,0)+=w_gauss*(-DN(3,1)*Nenr[0] + DNenr(0,1)*crV13 + DNenr(0,1)*crV14); +rV(13,1)+=w_gauss*(-DN(3,1)*Nenr[1] + DNenr(1,1)*crV13 + DNenr(1,1)*crV14); +rV(13,2)+=w_gauss*(-DN(3,1)*Nenr[2] + DNenr(2,1)*crV13 + DNenr(2,1)*crV14); +rV(13,3)+=w_gauss*(-DN(3,1)*Nenr[3] + DNenr(3,1)*crV13 + DNenr(3,1)*crV14); +rV(14,0)+=w_gauss*(-DN(3,2)*Nenr[0] + DNenr(0,2)*crV13 + DNenr(0,2)*crV14); +rV(14,1)+=w_gauss*(-DN(3,2)*Nenr[1] + DNenr(1,2)*crV13 + DNenr(1,2)*crV14); +rV(14,2)+=w_gauss*(-DN(3,2)*Nenr[2] + DNenr(2,2)*crV13 + DNenr(2,2)*crV14); +rV(14,3)+=w_gauss*(-DN(3,2)*Nenr[3] + DNenr(3,2)*crV13 + DNenr(3,2)*crV14); +rV(15,0)+=crV8*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); +rV(15,1)+=crV8*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); +rV(15,2)+=crV8*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); +rV(15,3)+=crV8*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); + + + const double crH0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crH1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crH2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crH3 = 1.0*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crH0*crH0 + crH1*crH1 + crH2*crH2)); +const double crH4 = crH3*rho; +const double crH5 = crH4*(DN(0,0)*crH0 + DN(0,1)*crH1 + DN(0,2)*crH2 + N[0]*bdf0); +const double crH6 = crH3*w_gauss; +const double crH7 = crH4*(DN(1,0)*crH0 + DN(1,1)*crH1 + DN(1,2)*crH2 + N[1]*bdf0); +const double crH8 = crH4*(DN(2,0)*crH0 + DN(2,1)*crH1 + DN(2,2)*crH2 + N[2]*bdf0); +const double crH9 = crH4*(DN(3,0)*crH0 + DN(3,1)*crH1 + DN(3,2)*crH2 + N[3]*bdf0); +rH(0,0)+=w_gauss*(DN(0,0)*Nenr[0] + DNenr(0,0)*crH5); +rH(0,1)+=w_gauss*(DN(0,1)*Nenr[0] + DNenr(0,1)*crH5); +rH(0,2)+=w_gauss*(DN(0,2)*Nenr[0] + DNenr(0,2)*crH5); +rH(0,3)+=crH6*(DN(0,0)*DNenr(0,0) + DN(0,1)*DNenr(0,1) + DN(0,2)*DNenr(0,2)); +rH(0,4)+=w_gauss*(DN(1,0)*Nenr[0] + DNenr(0,0)*crH7); +rH(0,5)+=w_gauss*(DN(1,1)*Nenr[0] + DNenr(0,1)*crH7); +rH(0,6)+=w_gauss*(DN(1,2)*Nenr[0] + DNenr(0,2)*crH7); +rH(0,7)+=crH6*(DN(1,0)*DNenr(0,0) + DN(1,1)*DNenr(0,1) + DN(1,2)*DNenr(0,2)); +rH(0,8)+=w_gauss*(DN(2,0)*Nenr[0] + DNenr(0,0)*crH8); +rH(0,9)+=w_gauss*(DN(2,1)*Nenr[0] + DNenr(0,1)*crH8); +rH(0,10)+=w_gauss*(DN(2,2)*Nenr[0] + DNenr(0,2)*crH8); +rH(0,11)+=crH6*(DN(2,0)*DNenr(0,0) + DN(2,1)*DNenr(0,1) + DN(2,2)*DNenr(0,2)); +rH(0,12)+=w_gauss*(DN(3,0)*Nenr[0] + DNenr(0,0)*crH9); +rH(0,13)+=w_gauss*(DN(3,1)*Nenr[0] + DNenr(0,1)*crH9); +rH(0,14)+=w_gauss*(DN(3,2)*Nenr[0] + DNenr(0,2)*crH9); +rH(0,15)+=crH6*(DN(3,0)*DNenr(0,0) + DN(3,1)*DNenr(0,1) + DN(3,2)*DNenr(0,2)); +rH(1,0)+=w_gauss*(DN(0,0)*Nenr[1] + DNenr(1,0)*crH5); +rH(1,1)+=w_gauss*(DN(0,1)*Nenr[1] + DNenr(1,1)*crH5); +rH(1,2)+=w_gauss*(DN(0,2)*Nenr[1] + DNenr(1,2)*crH5); +rH(1,3)+=crH6*(DN(0,0)*DNenr(1,0) + DN(0,1)*DNenr(1,1) + DN(0,2)*DNenr(1,2)); +rH(1,4)+=w_gauss*(DN(1,0)*Nenr[1] + DNenr(1,0)*crH7); +rH(1,5)+=w_gauss*(DN(1,1)*Nenr[1] + DNenr(1,1)*crH7); +rH(1,6)+=w_gauss*(DN(1,2)*Nenr[1] + DNenr(1,2)*crH7); +rH(1,7)+=crH6*(DN(1,0)*DNenr(1,0) + DN(1,1)*DNenr(1,1) + DN(1,2)*DNenr(1,2)); +rH(1,8)+=w_gauss*(DN(2,0)*Nenr[1] + DNenr(1,0)*crH8); +rH(1,9)+=w_gauss*(DN(2,1)*Nenr[1] + DNenr(1,1)*crH8); +rH(1,10)+=w_gauss*(DN(2,2)*Nenr[1] + DNenr(1,2)*crH8); +rH(1,11)+=crH6*(DN(2,0)*DNenr(1,0) + DN(2,1)*DNenr(1,1) + DN(2,2)*DNenr(1,2)); +rH(1,12)+=w_gauss*(DN(3,0)*Nenr[1] + DNenr(1,0)*crH9); +rH(1,13)+=w_gauss*(DN(3,1)*Nenr[1] + DNenr(1,1)*crH9); +rH(1,14)+=w_gauss*(DN(3,2)*Nenr[1] + DNenr(1,2)*crH9); +rH(1,15)+=crH6*(DN(3,0)*DNenr(1,0) + DN(3,1)*DNenr(1,1) + DN(3,2)*DNenr(1,2)); +rH(2,0)+=w_gauss*(DN(0,0)*Nenr[2] + DNenr(2,0)*crH5); +rH(2,1)+=w_gauss*(DN(0,1)*Nenr[2] + DNenr(2,1)*crH5); +rH(2,2)+=w_gauss*(DN(0,2)*Nenr[2] + DNenr(2,2)*crH5); +rH(2,3)+=crH6*(DN(0,0)*DNenr(2,0) + DN(0,1)*DNenr(2,1) + DN(0,2)*DNenr(2,2)); +rH(2,4)+=w_gauss*(DN(1,0)*Nenr[2] + DNenr(2,0)*crH7); +rH(2,5)+=w_gauss*(DN(1,1)*Nenr[2] + DNenr(2,1)*crH7); +rH(2,6)+=w_gauss*(DN(1,2)*Nenr[2] + DNenr(2,2)*crH7); +rH(2,7)+=crH6*(DN(1,0)*DNenr(2,0) + DN(1,1)*DNenr(2,1) + DN(1,2)*DNenr(2,2)); +rH(2,8)+=w_gauss*(DN(2,0)*Nenr[2] + DNenr(2,0)*crH8); +rH(2,9)+=w_gauss*(DN(2,1)*Nenr[2] + DNenr(2,1)*crH8); +rH(2,10)+=w_gauss*(DN(2,2)*Nenr[2] + DNenr(2,2)*crH8); +rH(2,11)+=crH6*(DN(2,0)*DNenr(2,0) + DN(2,1)*DNenr(2,1) + DN(2,2)*DNenr(2,2)); +rH(2,12)+=w_gauss*(DN(3,0)*Nenr[2] + DNenr(2,0)*crH9); +rH(2,13)+=w_gauss*(DN(3,1)*Nenr[2] + DNenr(2,1)*crH9); +rH(2,14)+=w_gauss*(DN(3,2)*Nenr[2] + DNenr(2,2)*crH9); +rH(2,15)+=crH6*(DN(3,0)*DNenr(2,0) + DN(3,1)*DNenr(2,1) + DN(3,2)*DNenr(2,2)); +rH(3,0)+=w_gauss*(DN(0,0)*Nenr[3] + DNenr(3,0)*crH5); +rH(3,1)+=w_gauss*(DN(0,1)*Nenr[3] + DNenr(3,1)*crH5); +rH(3,2)+=w_gauss*(DN(0,2)*Nenr[3] + DNenr(3,2)*crH5); +rH(3,3)+=crH6*(DN(0,0)*DNenr(3,0) + DN(0,1)*DNenr(3,1) + DN(0,2)*DNenr(3,2)); +rH(3,4)+=w_gauss*(DN(1,0)*Nenr[3] + DNenr(3,0)*crH7); +rH(3,5)+=w_gauss*(DN(1,1)*Nenr[3] + DNenr(3,1)*crH7); +rH(3,6)+=w_gauss*(DN(1,2)*Nenr[3] + DNenr(3,2)*crH7); +rH(3,7)+=crH6*(DN(1,0)*DNenr(3,0) + DN(1,1)*DNenr(3,1) + DN(1,2)*DNenr(3,2)); +rH(3,8)+=w_gauss*(DN(2,0)*Nenr[3] + DNenr(3,0)*crH8); +rH(3,9)+=w_gauss*(DN(2,1)*Nenr[3] + DNenr(3,1)*crH8); +rH(3,10)+=w_gauss*(DN(2,2)*Nenr[3] + DNenr(3,2)*crH8); +rH(3,11)+=crH6*(DN(2,0)*DNenr(3,0) + DN(2,1)*DNenr(3,1) + DN(2,2)*DNenr(3,2)); +rH(3,12)+=w_gauss*(DN(3,0)*Nenr[3] + DNenr(3,0)*crH9); +rH(3,13)+=w_gauss*(DN(3,1)*Nenr[3] + DNenr(3,1)*crH9); +rH(3,14)+=w_gauss*(DN(3,2)*Nenr[3] + DNenr(3,2)*crH9); +rH(3,15)+=crH6*(DN(3,0)*DNenr(3,0) + DN(3,1)*DNenr(3,1) + DN(3,2)*DNenr(3,2)); + + + const double crKee0 = 1.0*w_gauss*1.0/(dyn_tau*rho*1.0/dt + mu*stab_c1*1.0/(h*h) + rho*stab_c2*sqrt(pow(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0), 2) + pow(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1), 2) + pow(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2), 2))*1.0/h); +const double crKee1 = crKee0*(DNenr(0,0)*DNenr(1,0) + DNenr(0,1)*DNenr(1,1) + DNenr(0,2)*DNenr(1,2)); +const double crKee2 = crKee0*(DNenr(0,0)*DNenr(2,0) + DNenr(0,1)*DNenr(2,1) + DNenr(0,2)*DNenr(2,2)); +const double crKee3 = crKee0*(DNenr(0,0)*DNenr(3,0) + DNenr(0,1)*DNenr(3,1) + DNenr(0,2)*DNenr(3,2)); +const double crKee4 = crKee0*(DNenr(1,0)*DNenr(2,0) + DNenr(1,1)*DNenr(2,1) + DNenr(1,2)*DNenr(2,2)); +const double crKee5 = crKee0*(DNenr(1,0)*DNenr(3,0) + DNenr(1,1)*DNenr(3,1) + DNenr(1,2)*DNenr(3,2)); +const double crKee6 = crKee0*(DNenr(2,0)*DNenr(3,0) + DNenr(2,1)*DNenr(3,1) + DNenr(2,2)*DNenr(3,2)); +rKee(0,0)+=crKee0*(DNenr(0,0)*DNenr(0,0) + DNenr(0,1)*DNenr(0,1) + DNenr(0,2)*DNenr(0,2)); +rKee(0,1)+=crKee1; +rKee(0,2)+=crKee2; +rKee(0,3)+=crKee3; +rKee(1,0)+=crKee1; +rKee(1,1)+=crKee0*(DNenr(1,0)*DNenr(1,0) + DNenr(1,1)*DNenr(1,1) + DNenr(1,2)*DNenr(1,2)); +rKee(1,2)+=crKee4; +rKee(1,3)+=crKee5; +rKee(2,0)+=crKee2; +rKee(2,1)+=crKee4; +rKee(2,2)+=crKee0*(DNenr(2,0)*DNenr(2,0) + DNenr(2,1)*DNenr(2,1) + DNenr(2,2)*DNenr(2,2)); +rKee(2,3)+=crKee6; +rKee(3,0)+=crKee3; +rKee(3,1)+=crKee5; +rKee(3,2)+=crKee6; +rKee(3,3)+=crKee0*(DNenr(3,0)*DNenr(3,0) + DNenr(3,1)*DNenr(3,1) + DNenr(3,2)*DNenr(3,2)); + + + const double crRHS_ee0 = DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0); +const double crRHS_ee1 = DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1); +const double crRHS_ee2 = DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2); +const double crRHS_ee3 = crRHS_ee0 + crRHS_ee1 + crRHS_ee2 - volume_error_ratio; +const double crRHS_ee4 = N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0); +const double crRHS_ee5 = N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1); +const double crRHS_ee6 = N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2); +const double crRHS_ee7 = N[0]*bdf0; +const double crRHS_ee8 = N[1]*bdf0; +const double crRHS_ee9 = N[2]*bdf0; +const double crRHS_ee10 = N[3]*bdf0; +const double crRHS_ee11 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crRHS_ee12 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crRHS_ee13 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crRHS_ee14 = 1.0/dt; +const double crRHS_ee15 = N[0]*crRHS_ee14; +const double crRHS_ee16 = N[1]*crRHS_ee14; +const double crRHS_ee17 = N[2]*crRHS_ee14; +const double crRHS_ee18 = N[3]*crRHS_ee14; +const double crRHS_ee19 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crRHS_ee20 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crRHS_ee21 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crRHS_ee22 = 1.0*1.0/(crRHS_ee14*dyn_tau*rho + mu*stab_c1*1.0/(h*h) + rho*stab_c2*1.0/h*sqrt(crRHS_ee11*crRHS_ee11 + crRHS_ee12*crRHS_ee12 + crRHS_ee13*crRHS_ee13)); +const double crRHS_ee23 = crRHS_ee22*(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] + DNenr(0,0)*penr[0] + DNenr(1,0)*penr[1] + DNenr(2,0)*penr[2] + DNenr(3,0)*penr[3] - rho*(crRHS_ee4*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crRHS_ee5*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crRHS_ee6*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)) + rho*(crRHS_ee0*crRHS_ee11 + crRHS_ee10*(v(3,0) - vfrac(3,0)) + crRHS_ee12*(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)) + crRHS_ee13*(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0)) + crRHS_ee7*(v(0,0) - vfrac(0,0)) + crRHS_ee8*(v(1,0) - vfrac(1,0)) + crRHS_ee9*(v(2,0) - vfrac(2,0))) + rho*(crRHS_ee15*(vn(0,0) - vnn(0,0)) + crRHS_ee16*(vn(1,0) - vnn(1,0)) + crRHS_ee17*(vn(2,0) - vnn(2,0)) + crRHS_ee18*(vn(3,0) - vnn(3,0)) + crRHS_ee19*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)) + crRHS_ee20*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)) + crRHS_ee21*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)))); +const double crRHS_ee24 = crRHS_ee22*(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] + DNenr(0,1)*penr[0] + DNenr(1,1)*penr[1] + DNenr(2,1)*penr[2] + DNenr(3,1)*penr[3] - rho*(crRHS_ee4*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crRHS_ee5*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crRHS_ee6*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)) + rho*(crRHS_ee1*crRHS_ee12 + crRHS_ee10*(v(3,1) - vfrac(3,1)) + crRHS_ee11*(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)) + crRHS_ee13*(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1)) + crRHS_ee7*(v(0,1) - vfrac(0,1)) + crRHS_ee8*(v(1,1) - vfrac(1,1)) + crRHS_ee9*(v(2,1) - vfrac(2,1))) + rho*(crRHS_ee15*(vn(0,1) - vnn(0,1)) + crRHS_ee16*(vn(1,1) - vnn(1,1)) + crRHS_ee17*(vn(2,1) - vnn(2,1)) + crRHS_ee18*(vn(3,1) - vnn(3,1)) + crRHS_ee19*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)) + crRHS_ee20*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)) + crRHS_ee21*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)))); +const double crRHS_ee25 = crRHS_ee22*(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] + DNenr(0,2)*penr[0] + DNenr(1,2)*penr[1] + DNenr(2,2)*penr[2] + DNenr(3,2)*penr[3] - rho*(crRHS_ee4*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crRHS_ee5*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crRHS_ee6*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))) - rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)) + rho*(crRHS_ee10*(v(3,2) - vfrac(3,2)) + crRHS_ee11*(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)) + crRHS_ee12*(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)) + crRHS_ee13*crRHS_ee2 + crRHS_ee7*(v(0,2) - vfrac(0,2)) + crRHS_ee8*(v(1,2) - vfrac(1,2)) + crRHS_ee9*(v(2,2) - vfrac(2,2))) + rho*(crRHS_ee15*(vn(0,2) - vnn(0,2)) + crRHS_ee16*(vn(1,2) - vnn(1,2)) + crRHS_ee17*(vn(2,2) - vnn(2,2)) + crRHS_ee18*(vn(3,2) - vnn(3,2)) + crRHS_ee19*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)) + crRHS_ee20*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)) + crRHS_ee21*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)))); +rRHS_ee[0]+=-w_gauss*(DNenr(0,0)*crRHS_ee23 + DNenr(0,1)*crRHS_ee24 + DNenr(0,2)*crRHS_ee25 + Nenr[0]*crRHS_ee3); +rRHS_ee[1]+=-w_gauss*(DNenr(1,0)*crRHS_ee23 + DNenr(1,1)*crRHS_ee24 + DNenr(1,2)*crRHS_ee25 + Nenr[1]*crRHS_ee3); +rRHS_ee[2]+=-w_gauss*(DNenr(2,0)*crRHS_ee23 + DNenr(2,1)*crRHS_ee24 + DNenr(2,2)*crRHS_ee25 + Nenr[2]*crRHS_ee3); +rRHS_ee[3]+=-w_gauss*(DNenr(3,0)*crRHS_ee23 + DNenr(3,1)*crRHS_ee24 + DNenr(3,2)*crRHS_ee25 + Nenr[3]*crRHS_ee3); + } template @@ -2048,6 +2035,77 @@ ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNa { return Kratos::make_unique(pGeometry, rDistances); } +template <> +double TwoFluidNavierStokesFractional>::CalculateArtificialDynamicViscositySpecialization( + TwoFluidNavierStokesFractionalData<2, 3> &rData) const +{ + // Variables for artificial viscosity calculation + double artificial_mu = 0.0; + const double rho = rData.Density; + const double bdf0 = rData.bdf0; + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const auto &v = rData.Velocity; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const BoundedMatrix vconv = vn - vmesh; + const auto vfrac = rData.FractionalVelocity; + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const double art_dyn_visc_coeff = 0.8; + double grad_v_norm = 0.0; + + // Check that velocity gradient norm is non-zero + + //Substitute_artificial_mu_grad_v_norm_2D_3N + + if (grad_v_norm > 1.0e-12) { + // Calculate symbolic artificial viscosity + artificial_mu=0.5*art_dyn_visc_coeff*h*sqrt(pow(fabs(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + rho*((DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0))*(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0)) + (DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0))*(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1))) - rho*((DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0))*(N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0)) + (DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0))*(N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0)) + rho*(N[0]*(bdf0*v(0,0) - bdf0*vfrac(0,0)) + N[1]*(bdf0*v(1,0) - bdf0*vfrac(1,0)) + N[2]*(bdf0*v(2,0) - bdf0*vfrac(2,0))) + rho*(N[0]*(vn(0,0) - vnn(0,0))/dt + N[1]*(vn(1,0) - vnn(1,0))/dt + N[2]*(vn(2,0) - vnn(2,0))/dt + (DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0))*(N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0)) + (DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0))*(N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1)))), 2) + pow(fabs(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + rho*((DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1))*(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0)) + (DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1))*(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1))) - rho*((DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1))*(N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0)) + (DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1))*(N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1)) + rho*(N[0]*(bdf0*v(0,1) - bdf0*vfrac(0,1)) + N[1]*(bdf0*v(1,1) - bdf0*vfrac(1,1)) + N[2]*(bdf0*v(2,1) - bdf0*vfrac(2,1))) + rho*(N[0]*(vn(0,1) - vnn(0,1))/dt + N[1]*(vn(1,1) - vnn(1,1))/dt + N[2]*(vn(2,1) - vnn(2,1))/dt + (DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1))*(N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0)) + (DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1))*(N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1)))), 2))/sqrt(pow(fabs(DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0)), 2) + pow(fabs(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1)), 2) + pow(fabs(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0)), 2) + pow(fabs(DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1)), 2)); + + } + + return artificial_mu; +} + +template <> +double TwoFluidNavierStokesFractional>::CalculateArtificialDynamicViscositySpecialization( + TwoFluidNavierStokesFractionalData<3, 4> &rData) const +{ + // Variables for artificial viscosity calculation + double artificial_mu = 0.0; + const double rho = rData.Density; + const double bdf0 = rData.bdf0; + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const auto &v = rData.Velocity; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const BoundedMatrixvconv = vn - vmesh; + const auto vfrac = rData.FractionalVelocity; + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const double art_dyn_visc_coeff = 0.8; + double grad_v_norm = 0.0; + + // Check that velocity gradient norm is non-zero + + //Substitute_artificial_mu_grad_v_norm_3D_4N + + if (grad_v_norm > 1.0e-12) { + // Calculate symbolic artificial viscosity + artificial_mu=0.5*art_dyn_visc_coeff*h*sqrt(pow(fabs(DN(0,0)*p[0] + DN(1,0)*p[1] + DN(2,0)*p[2] + DN(3,0)*p[3] + rho*((DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0))*(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0)) + (DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0))*(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1)) + (DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0))*(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2))) - rho*((DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0))*(N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0)) + (DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0))*(N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1)) + (DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0))*(N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2))) - rho*(N[0]*f(0,0) + N[1]*f(1,0) + N[2]*f(2,0) + N[3]*f(3,0)) + rho*(N[0]*(bdf0*v(0,0) - bdf0*vfrac(0,0)) + N[1]*(bdf0*v(1,0) - bdf0*vfrac(1,0)) + N[2]*(bdf0*v(2,0) - bdf0*vfrac(2,0)) + N[3]*(bdf0*v(3,0) - bdf0*vfrac(3,0))) + rho*(N[0]*(vn(0,0) - vnn(0,0))/dt + N[1]*(vn(1,0) - vnn(1,0))/dt + N[2]*(vn(2,0) - vnn(2,0))/dt + N[3]*(vn(3,0) - vnn(3,0))/dt + (DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0))*(N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0)) + (DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0))*(N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1)) + (DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0))*(N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2)))), 2) + pow(fabs(DN(0,1)*p[0] + DN(1,1)*p[1] + DN(2,1)*p[2] + DN(3,1)*p[3] + rho*((DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1))*(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0)) + (DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1))*(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1)) + (DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1))*(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2))) - rho*((DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1))*(N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0)) + (DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1))*(N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1)) + (DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1))*(N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2))) - rho*(N[0]*f(0,1) + N[1]*f(1,1) + N[2]*f(2,1) + N[3]*f(3,1)) + rho*(N[0]*(bdf0*v(0,1) - bdf0*vfrac(0,1)) + N[1]*(bdf0*v(1,1) - bdf0*vfrac(1,1)) + N[2]*(bdf0*v(2,1) - bdf0*vfrac(2,1)) + N[3]*(bdf0*v(3,1) - bdf0*vfrac(3,1))) + rho*(N[0]*(vn(0,1) - vnn(0,1))/dt + N[1]*(vn(1,1) - vnn(1,1))/dt + N[2]*(vn(2,1) - vnn(2,1))/dt + N[3]*(vn(3,1) - vnn(3,1))/dt + (DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1))*(N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0)) + (DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1))*(N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1)) + (DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1))*(N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2)))), 2) + pow(fabs(DN(0,2)*p[0] + DN(1,2)*p[1] + DN(2,2)*p[2] + DN(3,2)*p[3] + rho*((DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2))*(N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0)) + (DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2))*(N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1)) + (DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2))*(N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2))) - rho*((DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2))*(N[0]*vfrac(0,0) + N[1]*vfrac(1,0) + N[2]*vfrac(2,0) + N[3]*vfrac(3,0)) + (DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2))*(N[0]*vfrac(0,1) + N[1]*vfrac(1,1) + N[2]*vfrac(2,1) + N[3]*vfrac(3,1)) + (DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2))*(N[0]*vfrac(0,2) + N[1]*vfrac(1,2) + N[2]*vfrac(2,2) + N[3]*vfrac(3,2))) - rho*(N[0]*f(0,2) + N[1]*f(1,2) + N[2]*f(2,2) + N[3]*f(3,2)) + rho*(N[0]*(bdf0*v(0,2) - bdf0*vfrac(0,2)) + N[1]*(bdf0*v(1,2) - bdf0*vfrac(1,2)) + N[2]*(bdf0*v(2,2) - bdf0*vfrac(2,2)) + N[3]*(bdf0*v(3,2) - bdf0*vfrac(3,2))) + rho*(N[0]*(vn(0,2) - vnn(0,2))/dt + N[1]*(vn(1,2) - vnn(1,2))/dt + N[2]*(vn(2,2) - vnn(2,2))/dt + N[3]*(vn(3,2) - vnn(3,2))/dt + (DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2))*(N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0)) + (DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2))*(N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1)) + (DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2))*(N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2)))), 2))/sqrt(pow(fabs(DN(0,0)*v(0,0) + DN(1,0)*v(1,0) + DN(2,0)*v(2,0) + DN(3,0)*v(3,0)), 2) + pow(fabs(DN(0,0)*v(0,1) + DN(1,0)*v(1,1) + DN(2,0)*v(2,1) + DN(3,0)*v(3,1)), 2) + pow(fabs(DN(0,0)*v(0,2) + DN(1,0)*v(1,2) + DN(2,0)*v(2,2) + DN(3,0)*v(3,2)), 2) + pow(fabs(DN(0,1)*v(0,0) + DN(1,1)*v(1,0) + DN(2,1)*v(2,0) + DN(3,1)*v(3,0)), 2) + pow(fabs(DN(0,1)*v(0,1) + DN(1,1)*v(1,1) + DN(2,1)*v(2,1) + DN(3,1)*v(3,1)), 2) + pow(fabs(DN(0,1)*v(0,2) + DN(1,1)*v(1,2) + DN(2,1)*v(2,2) + DN(3,1)*v(3,2)), 2) + pow(fabs(DN(0,2)*v(0,0) + DN(1,2)*v(1,0) + DN(2,2)*v(2,0) + DN(3,2)*v(3,0)), 2) + pow(fabs(DN(0,2)*v(0,1) + DN(1,2)*v(1,1) + DN(2,2)*v(2,1) + DN(3,2)*v(3,1)), 2) + pow(fabs(DN(0,2)*v(0,2) + DN(1,2)*v(1,2) + DN(2,2)*v(2,2) + DN(3,2)*v(3,2)), 2)); + + } + + return artificial_mu; +} template void TwoFluidNavierStokesFractional::CalculateStrainRate(TElementData& rData) const @@ -2159,41 +2217,67 @@ void TwoFluidNavierStokesFractional::load(Serializer &rSerializer) KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType); } - template void TwoFluidNavierStokesFractional::CalculateOnIntegrationPoints( const Variable &rVariable, - std::vector &rValues, - const ProcessInfo &rCurrentProcessInfo ) + std::vector &rOutput, + const ProcessInfo &rCurrentProcessInfo) { - if (rVariable == DIVERGENCE){ - - const auto& rGeom = this->GetGeometry(); - const GeometryType::IntegrationPointsArrayType& IntegrationPoints = rGeom.IntegrationPoints(GeometryData::IntegrationMethod::GI_GAUSS_2); - const unsigned int num_gauss = IntegrationPoints.size(); + // Create new temporary data container + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + + if (rOutput.size() != number_of_gauss_points){ + rOutput.resize(number_of_gauss_points); + } - if (rValues.size() != num_gauss){ - rValues.resize(num_gauss); + if (rVariable == ARTIFICIAL_DYNAMIC_VISCOSITY){ + // Iterate over integration points to evaluate the artificial viscosity at each Gauss point + for (unsigned int g = 0; g < number_of_gauss_points; ++g){ + this->UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + rOutput[g] = this->GetValue(ARTIFICIAL_DYNAMIC_VISCOSITY); } + } + else{ + FluidElement::CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); + } +} - Vector gauss_pts_jacobian_determinant = ZeroVector(num_gauss); - GeometryData::ShapeFunctionsGradientsType DN_DX; - rGeom.ShapeFunctionsIntegrationPointsGradients(DN_DX, gauss_pts_jacobian_determinant, GeometryData::IntegrationMethod::GI_GAUSS_2); - - for (unsigned int i_gauss = 0; i_gauss < num_gauss; ++i_gauss){ - - const Matrix gp_DN_DX = DN_DX[i_gauss]; - double DVi_DXi = 0.0; - - for(unsigned int nnode = 0; nnode < NumNodes; ++nnode){ +template +void TwoFluidNavierStokesFractional::Calculate( + const Variable &rVariable, + double &rOutput, + const ProcessInfo &rCurrentProcessInfo) +{ + // Create new temporary data container + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + rOutput = 0.0; + if (rVariable == ARTIFICIAL_DYNAMIC_VISCOSITY) + { - const array_1d vel = rGeom[nnode].GetSolutionStepValue(VELOCITY); - for(unsigned int ndim = 0; ndim < Dim; ++ndim){ - DVi_DXi += gp_DN_DX(nnode, ndim) * vel[ndim]; - } - } - rValues[i_gauss] = DVi_DXi; + // Iterate over integration points to evaluate the artificial viscosity at each Gauss point + for (unsigned int g = 0; g < number_of_gauss_points; ++g) + { + this->UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + rOutput += CalculateArtificialDynamicViscositySpecialization(data); } + + rOutput /= number_of_gauss_points; } } diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h index 159eef5f1a70..d3f05816858b 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional.h @@ -223,18 +223,21 @@ class TwoFluidNavierStokesFractional : public FluidElement ///@name Input and output ///@{ - /// Function to visualize the divergence field - /** - * @brief Get the Value On Integration Points object (used to visualize the divergence field) + * @brief Get the Value On Integration Points object (used to visualize the artificial viscosity field) * - * @param rVariable Variable to be retrieved (implementation supports DIVERGENCE) + * @param rVariable Variable to be retrieved (implementation supports ARTIFICIAL_VISCOSITY) * @param rValues Vector for the values at the Gauss integration points * @param rCurrentProcessInfo ProcessInfo object */ void CalculateOnIntegrationPoints( const Variable &rVariable, - std::vector &rValues, + std::vector &rOutput, + const ProcessInfo &rCurrentProcessInfo) override; + + void Calculate( + const Variable &rVariable, + double &rOutput, const ProcessInfo &rCurrentProcessInfo) override; ///@} @@ -365,6 +368,14 @@ class TwoFluidNavierStokesFractional : public FluidElement */ void CalculateStrainRate(TElementData &rData) const override; + /** + * @brief Calculate the artificial dynamic viscosity. + * In this function we calculate the artificial dynamic viscosity in each gauss point. + * @param rData Data container + */ + + double CalculateArtificialDynamicViscositySpecialization(TElementData &rData) const; + ///@} ///@name Protected Access ///@{ diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp index 6b78671480fd..2daedea9b030 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp @@ -168,8 +168,9 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, - MatrixType &rLHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + MatrixType &rLHS) { const double h = rData.ElementSize; @@ -187,83 +188,85 @@ namespace Kratos // Stabilization parameters constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; - const double clhs0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double clhs1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double clhs2 = DN(0,0)*clhs0 + DN(0,1)*clhs1; -const double clhs3 = N[0]*bdf0; -const double clhs4 = clhs2 + clhs3; -const double clhs5 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(clhs0*clhs0 + clhs1*clhs1)); -const double clhs6 = clhs5*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); -const double clhs7 = N[0]*clhs6; -const double clhs8 = clhs2*clhs5; -const double clhs9 = N[0]*clhs2 + bdf0*(N[0]*N[0]) + clhs4*clhs7 + clhs4*clhs8; -const double clhs10 = N[1]*clhs3; -const double clhs11 = DN(1,0)*clhs0 + DN(1,1)*clhs1; -const double clhs12 = N[1]*bdf0; -const double clhs13 = clhs11 + clhs12; -const double clhs14 = N[0]*clhs11 + clhs10 + clhs13*clhs7 + clhs13*clhs8; -const double clhs15 = N[2]*clhs3; -const double clhs16 = DN(2,0)*clhs0 + DN(2,1)*clhs1; -const double clhs17 = N[2]*bdf0 + clhs16; -const double clhs18 = N[0]*clhs16 + clhs15 + clhs17*clhs7 + clhs17*clhs8; -const double clhs19 = N[1]*clhs6; -const double clhs20 = clhs11*clhs5; -const double clhs21 = N[1]*clhs2 + clhs10 + clhs19*clhs4 + clhs20*clhs4; -const double clhs22 = N[1]*clhs11 + bdf0*(N[1]*N[1]) + clhs13*clhs19 + clhs13*clhs20; -const double clhs23 = N[2]*clhs12; -const double clhs24 = N[1]*clhs16 + clhs17*clhs19 + clhs17*clhs20 + clhs23; -const double clhs25 = N[2]*clhs6; -const double clhs26 = clhs16*clhs5; -const double clhs27 = N[2]*clhs2 + clhs15 + clhs25*clhs4 + clhs26*clhs4; -const double clhs28 = N[2]*clhs11 + clhs13*clhs25 + clhs13*clhs26 + clhs23; -const double clhs29 = N[2]*clhs16 + bdf0*(N[2]*N[2]) + clhs17*clhs25 + clhs17*clhs26; -lhs(0,0)=clhs9; -lhs(0,1)=0; -lhs(0,2)=clhs14; -lhs(0,3)=0; -lhs(0,4)=clhs18; -lhs(0,5)=0; -lhs(1,0)=0; -lhs(1,1)=clhs9; -lhs(1,2)=0; -lhs(1,3)=clhs14; -lhs(1,4)=0; -lhs(1,5)=clhs18; -lhs(2,0)=clhs21; -lhs(2,1)=0; -lhs(2,2)=clhs22; -lhs(2,3)=0; -lhs(2,4)=clhs24; -lhs(2,5)=0; -lhs(3,0)=0; -lhs(3,1)=clhs21; -lhs(3,2)=0; -lhs(3,3)=clhs22; -lhs(3,4)=0; -lhs(3,5)=clhs24; -lhs(4,0)=clhs27; -lhs(4,1)=0; -lhs(4,2)=clhs28; -lhs(4,3)=0; -lhs(4,4)=clhs29; -lhs(4,5)=0; -lhs(5,0)=0; -lhs(5,1)=clhs27; -lhs(5,2)=0; -lhs(5,3)=clhs28; -lhs(5,4)=0; -lhs(5,5)=clhs29; - - // Add intermediate results to local system. - noalias(rLHS) += lhs * rData.Weight; + // Add LHS Gauss point contribution + const double w_gauss =rData.Weight; + + const double crLHS0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crLHS1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crLHS2 = DN(0,0)*crLHS0 + DN(0,1)*crLHS1; +const double crLHS3 = N[0]*bdf0; +const double crLHS4 = crLHS2 + crLHS3; +const double crLHS5 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(crLHS0*crLHS0 + crLHS1*crLHS1)); +const double crLHS6 = crLHS5*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crLHS7 = N[0]*crLHS6; +const double crLHS8 = crLHS2*crLHS5; +const double crLHS9 = w_gauss*(N[0]*crLHS2 + bdf0*(N[0]*N[0]) + crLHS4*crLHS7 + crLHS4*crLHS8); +const double crLHS10 = N[1]*crLHS3; +const double crLHS11 = DN(1,0)*crLHS0 + DN(1,1)*crLHS1; +const double crLHS12 = N[1]*bdf0; +const double crLHS13 = crLHS11 + crLHS12; +const double crLHS14 = w_gauss*(N[0]*crLHS11 + crLHS10 + crLHS13*crLHS7 + crLHS13*crLHS8); +const double crLHS15 = N[2]*crLHS3; +const double crLHS16 = DN(2,0)*crLHS0 + DN(2,1)*crLHS1; +const double crLHS17 = N[2]*bdf0 + crLHS16; +const double crLHS18 = w_gauss*(N[0]*crLHS16 + crLHS15 + crLHS17*crLHS7 + crLHS17*crLHS8); +const double crLHS19 = N[1]*crLHS6; +const double crLHS20 = crLHS11*crLHS5; +const double crLHS21 = w_gauss*(N[1]*crLHS2 + crLHS10 + crLHS19*crLHS4 + crLHS20*crLHS4); +const double crLHS22 = w_gauss*(N[1]*crLHS11 + bdf0*(N[1]*N[1]) + crLHS13*crLHS19 + crLHS13*crLHS20); +const double crLHS23 = N[2]*crLHS12; +const double crLHS24 = w_gauss*(N[1]*crLHS16 + crLHS17*crLHS19 + crLHS17*crLHS20 + crLHS23); +const double crLHS25 = N[2]*crLHS6; +const double crLHS26 = crLHS16*crLHS5; +const double crLHS27 = w_gauss*(N[2]*crLHS2 + crLHS15 + crLHS25*crLHS4 + crLHS26*crLHS4); +const double crLHS28 = w_gauss*(N[2]*crLHS11 + crLHS13*crLHS25 + crLHS13*crLHS26 + crLHS23); +const double crLHS29 = w_gauss*(N[2]*crLHS16 + bdf0*(N[2]*N[2]) + crLHS17*crLHS25 + crLHS17*crLHS26); +rLHS(0,0)+=crLHS9; +rLHS(0,1)+=0; +rLHS(0,2)+=crLHS14; +rLHS(0,3)+=0; +rLHS(0,4)+=crLHS18; +rLHS(0,5)+=0; +rLHS(1,0)+=0; +rLHS(1,1)+=crLHS9; +rLHS(1,2)+=0; +rLHS(1,3)+=crLHS14; +rLHS(1,4)+=0; +rLHS(1,5)+=crLHS18; +rLHS(2,0)+=crLHS21; +rLHS(2,1)+=0; +rLHS(2,2)+=crLHS22; +rLHS(2,3)+=0; +rLHS(2,4)+=crLHS24; +rLHS(2,5)+=0; +rLHS(3,0)+=0; +rLHS(3,1)+=crLHS21; +rLHS(3,2)+=0; +rLHS(3,3)+=crLHS22; +rLHS(3,4)+=0; +rLHS(3,5)+=crLHS24; +rLHS(4,0)+=crLHS27; +rLHS(4,1)+=0; +rLHS(4,2)+=crLHS28; +rLHS(4,3)+=0; +rLHS(4,4)+=crLHS29; +rLHS(4,5)+=0; +rLHS(5,0)+=0; +rLHS(5,1)+=crLHS27; +rLHS(5,2)+=0; +rLHS(5,3)+=crLHS28; +rLHS(5,4)+=0; +rLHS(5,5)+=crLHS29; + + } /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, - MatrixType &rLHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + MatrixType &rLHS) { @@ -283,209 +286,210 @@ lhs(5,5)=clhs29; // Stabilization parameters constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; - - const double clhs0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double clhs1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double clhs2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double clhs3 = DN(0,0)*clhs0 + DN(0,1)*clhs1 + DN(0,2)*clhs2; -const double clhs4 = N[0]*bdf0; -const double clhs5 = clhs3 + clhs4; -const double clhs6 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(clhs0*clhs0 + clhs1*clhs1 + clhs2*clhs2)); -const double clhs7 = clhs6*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); -const double clhs8 = N[0]*clhs7; -const double clhs9 = clhs3*clhs6; -const double clhs10 = N[0]*clhs3 + bdf0*(N[0]*N[0]) + clhs5*clhs8 + clhs5*clhs9; -const double clhs11 = N[1]*clhs4; -const double clhs12 = DN(1,0)*clhs0 + DN(1,1)*clhs1 + DN(1,2)*clhs2; -const double clhs13 = N[1]*bdf0; -const double clhs14 = clhs12 + clhs13; -const double clhs15 = N[0]*clhs12 + clhs11 + clhs14*clhs8 + clhs14*clhs9; -const double clhs16 = N[2]*clhs4; -const double clhs17 = DN(2,0)*clhs0 + DN(2,1)*clhs1 + DN(2,2)*clhs2; -const double clhs18 = N[2]*bdf0; -const double clhs19 = clhs17 + clhs18; -const double clhs20 = N[0]*clhs17 + clhs16 + clhs19*clhs8 + clhs19*clhs9; -const double clhs21 = N[3]*clhs4; -const double clhs22 = DN(3,0)*clhs0 + DN(3,1)*clhs1 + DN(3,2)*clhs2; -const double clhs23 = N[3]*bdf0 + clhs22; -const double clhs24 = N[0]*clhs22 + clhs21 + clhs23*clhs8 + clhs23*clhs9; -const double clhs25 = N[1]*clhs7; -const double clhs26 = clhs12*clhs6; -const double clhs27 = N[1]*clhs3 + clhs11 + clhs25*clhs5 + clhs26*clhs5; -const double clhs28 = N[1]*clhs12 + bdf0*(N[1]*N[1]) + clhs14*clhs25 + clhs14*clhs26; -const double clhs29 = N[2]*clhs13; -const double clhs30 = N[1]*clhs17 + clhs19*clhs25 + clhs19*clhs26 + clhs29; -const double clhs31 = N[3]*clhs13; -const double clhs32 = N[1]*clhs22 + clhs23*clhs25 + clhs23*clhs26 + clhs31; -const double clhs33 = N[2]*clhs7; -const double clhs34 = clhs17*clhs6; -const double clhs35 = N[2]*clhs3 + clhs16 + clhs33*clhs5 + clhs34*clhs5; -const double clhs36 = N[2]*clhs12 + clhs14*clhs33 + clhs14*clhs34 + clhs29; -const double clhs37 = N[2]*clhs17 + bdf0*(N[2]*N[2]) + clhs19*clhs33 + clhs19*clhs34; -const double clhs38 = N[3]*clhs18; -const double clhs39 = N[2]*clhs22 + clhs23*clhs33 + clhs23*clhs34 + clhs38; -const double clhs40 = N[3]*clhs7; -const double clhs41 = clhs22*clhs6; -const double clhs42 = N[3]*clhs3 + clhs21 + clhs40*clhs5 + clhs41*clhs5; -const double clhs43 = N[3]*clhs12 + clhs14*clhs40 + clhs14*clhs41 + clhs31; -const double clhs44 = N[3]*clhs17 + clhs19*clhs40 + clhs19*clhs41 + clhs38; -const double clhs45 = N[3]*clhs22 + bdf0*(N[3]*N[3]) + clhs23*clhs40 + clhs23*clhs41; -lhs(0,0)=clhs10; -lhs(0,1)=0; -lhs(0,2)=0; -lhs(0,3)=clhs15; -lhs(0,4)=0; -lhs(0,5)=0; -lhs(0,6)=clhs20; -lhs(0,7)=0; -lhs(0,8)=0; -lhs(0,9)=clhs24; -lhs(0,10)=0; -lhs(0,11)=0; -lhs(1,0)=0; -lhs(1,1)=clhs10; -lhs(1,2)=0; -lhs(1,3)=0; -lhs(1,4)=clhs15; -lhs(1,5)=0; -lhs(1,6)=0; -lhs(1,7)=clhs20; -lhs(1,8)=0; -lhs(1,9)=0; -lhs(1,10)=clhs24; -lhs(1,11)=0; -lhs(2,0)=0; -lhs(2,1)=0; -lhs(2,2)=clhs10; -lhs(2,3)=0; -lhs(2,4)=0; -lhs(2,5)=clhs15; -lhs(2,6)=0; -lhs(2,7)=0; -lhs(2,8)=clhs20; -lhs(2,9)=0; -lhs(2,10)=0; -lhs(2,11)=clhs24; -lhs(3,0)=clhs27; -lhs(3,1)=0; -lhs(3,2)=0; -lhs(3,3)=clhs28; -lhs(3,4)=0; -lhs(3,5)=0; -lhs(3,6)=clhs30; -lhs(3,7)=0; -lhs(3,8)=0; -lhs(3,9)=clhs32; -lhs(3,10)=0; -lhs(3,11)=0; -lhs(4,0)=0; -lhs(4,1)=clhs27; -lhs(4,2)=0; -lhs(4,3)=0; -lhs(4,4)=clhs28; -lhs(4,5)=0; -lhs(4,6)=0; -lhs(4,7)=clhs30; -lhs(4,8)=0; -lhs(4,9)=0; -lhs(4,10)=clhs32; -lhs(4,11)=0; -lhs(5,0)=0; -lhs(5,1)=0; -lhs(5,2)=clhs27; -lhs(5,3)=0; -lhs(5,4)=0; -lhs(5,5)=clhs28; -lhs(5,6)=0; -lhs(5,7)=0; -lhs(5,8)=clhs30; -lhs(5,9)=0; -lhs(5,10)=0; -lhs(5,11)=clhs32; -lhs(6,0)=clhs35; -lhs(6,1)=0; -lhs(6,2)=0; -lhs(6,3)=clhs36; -lhs(6,4)=0; -lhs(6,5)=0; -lhs(6,6)=clhs37; -lhs(6,7)=0; -lhs(6,8)=0; -lhs(6,9)=clhs39; -lhs(6,10)=0; -lhs(6,11)=0; -lhs(7,0)=0; -lhs(7,1)=clhs35; -lhs(7,2)=0; -lhs(7,3)=0; -lhs(7,4)=clhs36; -lhs(7,5)=0; -lhs(7,6)=0; -lhs(7,7)=clhs37; -lhs(7,8)=0; -lhs(7,9)=0; -lhs(7,10)=clhs39; -lhs(7,11)=0; -lhs(8,0)=0; -lhs(8,1)=0; -lhs(8,2)=clhs35; -lhs(8,3)=0; -lhs(8,4)=0; -lhs(8,5)=clhs36; -lhs(8,6)=0; -lhs(8,7)=0; -lhs(8,8)=clhs37; -lhs(8,9)=0; -lhs(8,10)=0; -lhs(8,11)=clhs39; -lhs(9,0)=clhs42; -lhs(9,1)=0; -lhs(9,2)=0; -lhs(9,3)=clhs43; -lhs(9,4)=0; -lhs(9,5)=0; -lhs(9,6)=clhs44; -lhs(9,7)=0; -lhs(9,8)=0; -lhs(9,9)=clhs45; -lhs(9,10)=0; -lhs(9,11)=0; -lhs(10,0)=0; -lhs(10,1)=clhs42; -lhs(10,2)=0; -lhs(10,3)=0; -lhs(10,4)=clhs43; -lhs(10,5)=0; -lhs(10,6)=0; -lhs(10,7)=clhs44; -lhs(10,8)=0; -lhs(10,9)=0; -lhs(10,10)=clhs45; -lhs(10,11)=0; -lhs(11,0)=0; -lhs(11,1)=0; -lhs(11,2)=clhs42; -lhs(11,3)=0; -lhs(11,4)=0; -lhs(11,5)=clhs43; -lhs(11,6)=0; -lhs(11,7)=0; -lhs(11,8)=clhs44; -lhs(11,9)=0; -lhs(11,10)=0; -lhs(11,11)=clhs45; - - // Add intermediate results to local system. - noalias(rLHS) += lhs * rData.Weight; + // Add LHS Gauss point contribution + const double w_gauss =rData.Weight; + + const double crLHS0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crLHS1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crLHS2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crLHS3 = DN(0,0)*crLHS0 + DN(0,1)*crLHS1 + DN(0,2)*crLHS2; +const double crLHS4 = N[0]*bdf0; +const double crLHS5 = crLHS3 + crLHS4; +const double crLHS6 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(crLHS0*crLHS0 + crLHS1*crLHS1 + crLHS2*crLHS2)); +const double crLHS7 = crLHS6*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crLHS8 = N[0]*crLHS7; +const double crLHS9 = crLHS3*crLHS6; +const double crLHS10 = w_gauss*(N[0]*crLHS3 + bdf0*(N[0]*N[0]) + crLHS5*crLHS8 + crLHS5*crLHS9); +const double crLHS11 = N[1]*crLHS4; +const double crLHS12 = DN(1,0)*crLHS0 + DN(1,1)*crLHS1 + DN(1,2)*crLHS2; +const double crLHS13 = N[1]*bdf0; +const double crLHS14 = crLHS12 + crLHS13; +const double crLHS15 = w_gauss*(N[0]*crLHS12 + crLHS11 + crLHS14*crLHS8 + crLHS14*crLHS9); +const double crLHS16 = N[2]*crLHS4; +const double crLHS17 = DN(2,0)*crLHS0 + DN(2,1)*crLHS1 + DN(2,2)*crLHS2; +const double crLHS18 = N[2]*bdf0; +const double crLHS19 = crLHS17 + crLHS18; +const double crLHS20 = w_gauss*(N[0]*crLHS17 + crLHS16 + crLHS19*crLHS8 + crLHS19*crLHS9); +const double crLHS21 = N[3]*crLHS4; +const double crLHS22 = DN(3,0)*crLHS0 + DN(3,1)*crLHS1 + DN(3,2)*crLHS2; +const double crLHS23 = N[3]*bdf0 + crLHS22; +const double crLHS24 = w_gauss*(N[0]*crLHS22 + crLHS21 + crLHS23*crLHS8 + crLHS23*crLHS9); +const double crLHS25 = N[1]*crLHS7; +const double crLHS26 = crLHS12*crLHS6; +const double crLHS27 = w_gauss*(N[1]*crLHS3 + crLHS11 + crLHS25*crLHS5 + crLHS26*crLHS5); +const double crLHS28 = w_gauss*(N[1]*crLHS12 + bdf0*(N[1]*N[1]) + crLHS14*crLHS25 + crLHS14*crLHS26); +const double crLHS29 = N[2]*crLHS13; +const double crLHS30 = w_gauss*(N[1]*crLHS17 + crLHS19*crLHS25 + crLHS19*crLHS26 + crLHS29); +const double crLHS31 = N[3]*crLHS13; +const double crLHS32 = w_gauss*(N[1]*crLHS22 + crLHS23*crLHS25 + crLHS23*crLHS26 + crLHS31); +const double crLHS33 = N[2]*crLHS7; +const double crLHS34 = crLHS17*crLHS6; +const double crLHS35 = w_gauss*(N[2]*crLHS3 + crLHS16 + crLHS33*crLHS5 + crLHS34*crLHS5); +const double crLHS36 = w_gauss*(N[2]*crLHS12 + crLHS14*crLHS33 + crLHS14*crLHS34 + crLHS29); +const double crLHS37 = w_gauss*(N[2]*crLHS17 + bdf0*(N[2]*N[2]) + crLHS19*crLHS33 + crLHS19*crLHS34); +const double crLHS38 = N[3]*crLHS18; +const double crLHS39 = w_gauss*(N[2]*crLHS22 + crLHS23*crLHS33 + crLHS23*crLHS34 + crLHS38); +const double crLHS40 = N[3]*crLHS7; +const double crLHS41 = crLHS22*crLHS6; +const double crLHS42 = w_gauss*(N[3]*crLHS3 + crLHS21 + crLHS40*crLHS5 + crLHS41*crLHS5); +const double crLHS43 = w_gauss*(N[3]*crLHS12 + crLHS14*crLHS40 + crLHS14*crLHS41 + crLHS31); +const double crLHS44 = w_gauss*(N[3]*crLHS17 + crLHS19*crLHS40 + crLHS19*crLHS41 + crLHS38); +const double crLHS45 = w_gauss*(N[3]*crLHS22 + bdf0*(N[3]*N[3]) + crLHS23*crLHS40 + crLHS23*crLHS41); +rLHS(0,0)+=crLHS10; +rLHS(0,1)+=0; +rLHS(0,2)+=0; +rLHS(0,3)+=crLHS15; +rLHS(0,4)+=0; +rLHS(0,5)+=0; +rLHS(0,6)+=crLHS20; +rLHS(0,7)+=0; +rLHS(0,8)+=0; +rLHS(0,9)+=crLHS24; +rLHS(0,10)+=0; +rLHS(0,11)+=0; +rLHS(1,0)+=0; +rLHS(1,1)+=crLHS10; +rLHS(1,2)+=0; +rLHS(1,3)+=0; +rLHS(1,4)+=crLHS15; +rLHS(1,5)+=0; +rLHS(1,6)+=0; +rLHS(1,7)+=crLHS20; +rLHS(1,8)+=0; +rLHS(1,9)+=0; +rLHS(1,10)+=crLHS24; +rLHS(1,11)+=0; +rLHS(2,0)+=0; +rLHS(2,1)+=0; +rLHS(2,2)+=crLHS10; +rLHS(2,3)+=0; +rLHS(2,4)+=0; +rLHS(2,5)+=crLHS15; +rLHS(2,6)+=0; +rLHS(2,7)+=0; +rLHS(2,8)+=crLHS20; +rLHS(2,9)+=0; +rLHS(2,10)+=0; +rLHS(2,11)+=crLHS24; +rLHS(3,0)+=crLHS27; +rLHS(3,1)+=0; +rLHS(3,2)+=0; +rLHS(3,3)+=crLHS28; +rLHS(3,4)+=0; +rLHS(3,5)+=0; +rLHS(3,6)+=crLHS30; +rLHS(3,7)+=0; +rLHS(3,8)+=0; +rLHS(3,9)+=crLHS32; +rLHS(3,10)+=0; +rLHS(3,11)+=0; +rLHS(4,0)+=0; +rLHS(4,1)+=crLHS27; +rLHS(4,2)+=0; +rLHS(4,3)+=0; +rLHS(4,4)+=crLHS28; +rLHS(4,5)+=0; +rLHS(4,6)+=0; +rLHS(4,7)+=crLHS30; +rLHS(4,8)+=0; +rLHS(4,9)+=0; +rLHS(4,10)+=crLHS32; +rLHS(4,11)+=0; +rLHS(5,0)+=0; +rLHS(5,1)+=0; +rLHS(5,2)+=crLHS27; +rLHS(5,3)+=0; +rLHS(5,4)+=0; +rLHS(5,5)+=crLHS28; +rLHS(5,6)+=0; +rLHS(5,7)+=0; +rLHS(5,8)+=crLHS30; +rLHS(5,9)+=0; +rLHS(5,10)+=0; +rLHS(5,11)+=crLHS32; +rLHS(6,0)+=crLHS35; +rLHS(6,1)+=0; +rLHS(6,2)+=0; +rLHS(6,3)+=crLHS36; +rLHS(6,4)+=0; +rLHS(6,5)+=0; +rLHS(6,6)+=crLHS37; +rLHS(6,7)+=0; +rLHS(6,8)+=0; +rLHS(6,9)+=crLHS39; +rLHS(6,10)+=0; +rLHS(6,11)+=0; +rLHS(7,0)+=0; +rLHS(7,1)+=crLHS35; +rLHS(7,2)+=0; +rLHS(7,3)+=0; +rLHS(7,4)+=crLHS36; +rLHS(7,5)+=0; +rLHS(7,6)+=0; +rLHS(7,7)+=crLHS37; +rLHS(7,8)+=0; +rLHS(7,9)+=0; +rLHS(7,10)+=crLHS39; +rLHS(7,11)+=0; +rLHS(8,0)+=0; +rLHS(8,1)+=0; +rLHS(8,2)+=crLHS35; +rLHS(8,3)+=0; +rLHS(8,4)+=0; +rLHS(8,5)+=crLHS36; +rLHS(8,6)+=0; +rLHS(8,7)+=0; +rLHS(8,8)+=crLHS37; +rLHS(8,9)+=0; +rLHS(8,10)+=0; +rLHS(8,11)+=crLHS39; +rLHS(9,0)+=crLHS42; +rLHS(9,1)+=0; +rLHS(9,2)+=0; +rLHS(9,3)+=crLHS43; +rLHS(9,4)+=0; +rLHS(9,5)+=0; +rLHS(9,6)+=crLHS44; +rLHS(9,7)+=0; +rLHS(9,8)+=0; +rLHS(9,9)+=crLHS45; +rLHS(9,10)+=0; +rLHS(9,11)+=0; +rLHS(10,0)+=0; +rLHS(10,1)+=crLHS42; +rLHS(10,2)+=0; +rLHS(10,3)+=0; +rLHS(10,4)+=crLHS43; +rLHS(10,5)+=0; +rLHS(10,6)+=0; +rLHS(10,7)+=crLHS44; +rLHS(10,8)+=0; +rLHS(10,9)+=0; +rLHS(10,10)+=crLHS45; +rLHS(10,11)+=0; +rLHS(11,0)+=0; +rLHS(11,1)+=0; +rLHS(11,2)+=crLHS42; +rLHS(11,3)+=0; +rLHS(11,4)+=0; +rLHS(11,5)+=crLHS43; +rLHS(11,6)+=0; +rLHS(11,7)+=0; +rLHS(11,8)+=crLHS44; +rLHS(11,9)+=0; +rLHS(11,10)+=0; +rLHS(11,11)+=crLHS45; + + } /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, - VectorType &rRHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + VectorType &rRHS) { const double h = rData.ElementSize; @@ -505,57 +509,61 @@ lhs(11,11)=clhs45; const auto &N = rData.N; const auto &DN = rData.DN_DX; - auto &rhs = rData.rhs; - - const double crhs0 = 1.0/dt; -const double crhs1 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs2 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs3 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs4 = crhs1 + crhs2 + crhs3; -const double crhs5 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)); -const double crhs6 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); -const double crhs7 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); -const double crhs8 = crhs6*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crhs7*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); -const double crhs9 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); -const double crhs10 = crhs9*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)); -const double crhs11 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); -const double crhs12 = crhs11*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); -const double crhs13 = crhs10 + crhs12; -const double crhs14 = -crhs0*crhs1 - crhs0*crhs2 - crhs0*crhs3 - crhs10 - crhs12 + crhs5 + crhs8; -const double crhs15 = 1.0*1.0/(crhs0*dyn_tau + stab_c2*1.0/h*sqrt(crhs6*crhs6 + crhs7*crhs7)); -const double crhs16 = crhs15*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); -const double crhs17 = N[0]*crhs16; -const double crhs18 = crhs15*(DN(0,0)*crhs6 + DN(0,1)*crhs7); -const double crhs19 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs20 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs21 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs22 = crhs19 + crhs20 + crhs21; -const double crhs23 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)); -const double crhs24 = crhs6*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crhs7*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); -const double crhs25 = crhs9*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)); -const double crhs26 = crhs11*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); -const double crhs27 = crhs25 + crhs26; -const double crhs28 = -crhs0*crhs19 - crhs0*crhs20 - crhs0*crhs21 + crhs23 + crhs24 - crhs25 - crhs26; -const double crhs29 = N[1]*crhs16; -const double crhs30 = crhs15*(DN(1,0)*crhs6 + DN(1,1)*crhs7); -const double crhs31 = N[2]*crhs16; -const double crhs32 = crhs15*(DN(2,0)*crhs6 + DN(2,1)*crhs7); -rhs[0]=N[0]*crhs0*crhs4 + N[0]*crhs13 - N[0]*crhs5 - N[0]*crhs8 - crhs14*crhs17 - crhs14*crhs18; -rhs[1]=N[0]*crhs0*crhs22 - N[0]*crhs23 - N[0]*crhs24 + N[0]*crhs27 - crhs17*crhs28 - crhs18*crhs28; -rhs[2]=N[1]*crhs0*crhs4 + N[1]*crhs13 - N[1]*crhs5 - N[1]*crhs8 - crhs14*crhs29 - crhs14*crhs30; -rhs[3]=N[1]*crhs0*crhs22 - N[1]*crhs23 - N[1]*crhs24 + N[1]*crhs27 - crhs28*crhs29 - crhs28*crhs30; -rhs[4]=N[2]*crhs0*crhs4 + N[2]*crhs13 - N[2]*crhs5 - N[2]*crhs8 - crhs14*crhs31 - crhs14*crhs32; -rhs[5]=N[2]*crhs0*crhs22 - N[2]*crhs23 - N[2]*crhs24 + N[2]*crhs27 - crhs28*crhs31 - crhs28*crhs32; - - //Add intermediate results to local system. - noalias(rRHS) += rhs * rData.Weight; + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; + + const double crRHS0 = N[0]*(vn(0,0) - vnn(0,0)); +const double crRHS1 = N[1]*(vn(1,0) - vnn(1,0)); +const double crRHS2 = N[2]*(vn(2,0) - vnn(2,0)); +const double crRHS3 = crRHS0 + crRHS1 + crRHS2; +const double crRHS4 = 1.0/dt; +const double crRHS5 = N[0]*crRHS4; +const double crRHS6 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)); +const double crRHS7 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crRHS8 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crRHS9 = crRHS7*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crRHS8*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); +const double crRHS10 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crRHS11 = crRHS10*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)); +const double crRHS12 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crRHS13 = crRHS12*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crRHS14 = crRHS11 + crRHS13; +const double crRHS15 = -crRHS0*crRHS4 - crRHS1*crRHS4 - crRHS11 - crRHS13 - crRHS2*crRHS4 + crRHS6 + crRHS9; +const double crRHS16 = 1.0*1.0/(crRHS4*dyn_tau + stab_c2*1.0/h*sqrt(crRHS7*crRHS7 + crRHS8*crRHS8)); +const double crRHS17 = crRHS16*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crRHS18 = N[0]*crRHS17; +const double crRHS19 = crRHS16*(DN(0,0)*crRHS7 + DN(0,1)*crRHS8); +const double crRHS20 = N[0]*(vn(0,1) - vnn(0,1)); +const double crRHS21 = N[1]*(vn(1,1) - vnn(1,1)); +const double crRHS22 = N[2]*(vn(2,1) - vnn(2,1)); +const double crRHS23 = crRHS20 + crRHS21 + crRHS22; +const double crRHS24 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)); +const double crRHS25 = crRHS7*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crRHS8*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); +const double crRHS26 = crRHS10*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)); +const double crRHS27 = crRHS12*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); +const double crRHS28 = crRHS26 + crRHS27; +const double crRHS29 = -crRHS20*crRHS4 - crRHS21*crRHS4 - crRHS22*crRHS4 + crRHS24 + crRHS25 - crRHS26 - crRHS27; +const double crRHS30 = N[1]*crRHS4; +const double crRHS31 = N[1]*crRHS17; +const double crRHS32 = crRHS16*(DN(1,0)*crRHS7 + DN(1,1)*crRHS8); +const double crRHS33 = N[2]*crRHS4; +const double crRHS34 = N[2]*crRHS17; +const double crRHS35 = crRHS16*(DN(2,0)*crRHS7 + DN(2,1)*crRHS8); +rRHS[0]+=-w_gauss*(-N[0]*crRHS14 + N[0]*crRHS6 + N[0]*crRHS9 + crRHS15*crRHS18 + crRHS15*crRHS19 - crRHS3*crRHS5); +rRHS[1]+=-w_gauss*(N[0]*crRHS24 + N[0]*crRHS25 - N[0]*crRHS28 + crRHS18*crRHS29 + crRHS19*crRHS29 - crRHS23*crRHS5); +rRHS[2]+=-w_gauss*(-N[1]*crRHS14 + N[1]*crRHS6 + N[1]*crRHS9 + crRHS15*crRHS31 + crRHS15*crRHS32 - crRHS3*crRHS30); +rRHS[3]+=-w_gauss*(N[1]*crRHS24 + N[1]*crRHS25 - N[1]*crRHS28 - crRHS23*crRHS30 + crRHS29*crRHS31 + crRHS29*crRHS32); +rRHS[4]+=-w_gauss*(-N[2]*crRHS14 + N[2]*crRHS6 + N[2]*crRHS9 + crRHS15*crRHS34 + crRHS15*crRHS35 - crRHS3*crRHS33); +rRHS[5]+=-w_gauss*(N[2]*crRHS24 + N[2]*crRHS25 - N[2]*crRHS28 - crRHS23*crRHS33 + crRHS29*crRHS34 + crRHS29*crRHS35); + + } /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, - VectorType &rRHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + VectorType &rRHS) { @@ -575,77 +583,80 @@ rhs[5]=N[2]*crhs0*crhs22 - N[2]*crhs23 - N[2]*crhs24 + N[2]*crhs27 - crhs28*crhs const auto &N = rData.N; const auto &DN = rData.DN_DX; - auto &rhs = rData.rhs; - - const double crhs0 = 1.0/dt; -const double crhs1 = N[0]*(vn(0,0) - vnn(0,0)); -const double crhs2 = N[1]*(vn(1,0) - vnn(1,0)); -const double crhs3 = N[2]*(vn(2,0) - vnn(2,0)); -const double crhs4 = N[3]*(vn(3,0) - vnn(3,0)); -const double crhs5 = crhs1 + crhs2 + crhs3 + crhs4; -const double crhs6 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)) + N[3]*(bdf0*vfrac(3,0) + bdf1*vn(3,0) + bdf2*vnn(3,0)); -const double crhs7 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); -const double crhs8 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); -const double crhs9 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); -const double crhs10 = crhs7*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crhs8*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)) + crhs9*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)); -const double crhs11 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); -const double crhs12 = crhs11*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)); -const double crhs13 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); -const double crhs14 = crhs13*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)); -const double crhs15 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); -const double crhs16 = crhs15*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); -const double crhs17 = crhs12 + crhs14 + crhs16; -const double crhs18 = -crhs0*crhs1 - crhs0*crhs2 - crhs0*crhs3 - crhs0*crhs4 + crhs10 - crhs12 - crhs14 - crhs16 + crhs6; -const double crhs19 = 1.0*1.0/(crhs0*dyn_tau + stab_c2*1.0/h*sqrt(crhs7*crhs7 + crhs8*crhs8 + crhs9*crhs9)); -const double crhs20 = crhs19*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); -const double crhs21 = N[0]*crhs20; -const double crhs22 = crhs19*(DN(0,0)*crhs7 + DN(0,1)*crhs8 + DN(0,2)*crhs9); -const double crhs23 = N[0]*(vn(0,1) - vnn(0,1)); -const double crhs24 = N[1]*(vn(1,1) - vnn(1,1)); -const double crhs25 = N[2]*(vn(2,1) - vnn(2,1)); -const double crhs26 = N[3]*(vn(3,1) - vnn(3,1)); -const double crhs27 = crhs23 + crhs24 + crhs25 + crhs26; -const double crhs28 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)) + N[3]*(bdf0*vfrac(3,1) + bdf1*vn(3,1) + bdf2*vnn(3,1)); -const double crhs29 = crhs7*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crhs8*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)) + crhs9*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)); -const double crhs30 = crhs11*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)); -const double crhs31 = crhs13*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)); -const double crhs32 = crhs15*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); -const double crhs33 = crhs30 + crhs31 + crhs32; -const double crhs34 = -crhs0*crhs23 - crhs0*crhs24 - crhs0*crhs25 - crhs0*crhs26 + crhs28 + crhs29 - crhs30 - crhs31 - crhs32; -const double crhs35 = N[0]*(vn(0,2) - vnn(0,2)); -const double crhs36 = N[1]*(vn(1,2) - vnn(1,2)); -const double crhs37 = N[2]*(vn(2,2) - vnn(2,2)); -const double crhs38 = N[3]*(vn(3,2) - vnn(3,2)); -const double crhs39 = crhs35 + crhs36 + crhs37 + crhs38; -const double crhs40 = N[0]*(bdf0*vfrac(0,2) + bdf1*vn(0,2) + bdf2*vnn(0,2)) + N[1]*(bdf0*vfrac(1,2) + bdf1*vn(1,2) + bdf2*vnn(1,2)) + N[2]*(bdf0*vfrac(2,2) + bdf1*vn(2,2) + bdf2*vnn(2,2)) + N[3]*(bdf0*vfrac(3,2) + bdf1*vn(3,2) + bdf2*vnn(3,2)); -const double crhs41 = crhs7*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crhs8*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)) + crhs9*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)); -const double crhs42 = crhs11*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)); -const double crhs43 = crhs13*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)); -const double crhs44 = crhs15*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); -const double crhs45 = crhs42 + crhs43 + crhs44; -const double crhs46 = -crhs0*crhs35 - crhs0*crhs36 - crhs0*crhs37 - crhs0*crhs38 + crhs40 + crhs41 - crhs42 - crhs43 - crhs44; -const double crhs47 = N[1]*crhs20; -const double crhs48 = crhs19*(DN(1,0)*crhs7 + DN(1,1)*crhs8 + DN(1,2)*crhs9); -const double crhs49 = N[2]*crhs20; -const double crhs50 = crhs19*(DN(2,0)*crhs7 + DN(2,1)*crhs8 + DN(2,2)*crhs9); -const double crhs51 = N[3]*crhs20; -const double crhs52 = crhs19*(DN(3,0)*crhs7 + DN(3,1)*crhs8 + DN(3,2)*crhs9); -rhs[0]=N[0]*crhs0*crhs5 - N[0]*crhs10 + N[0]*crhs17 - N[0]*crhs6 - crhs18*crhs21 - crhs18*crhs22; -rhs[1]=N[0]*crhs0*crhs27 - N[0]*crhs28 - N[0]*crhs29 + N[0]*crhs33 - crhs21*crhs34 - crhs22*crhs34; -rhs[2]=N[0]*crhs0*crhs39 - N[0]*crhs40 - N[0]*crhs41 + N[0]*crhs45 - crhs21*crhs46 - crhs22*crhs46; -rhs[3]=N[1]*crhs0*crhs5 - N[1]*crhs10 + N[1]*crhs17 - N[1]*crhs6 - crhs18*crhs47 - crhs18*crhs48; -rhs[4]=N[1]*crhs0*crhs27 - N[1]*crhs28 - N[1]*crhs29 + N[1]*crhs33 - crhs34*crhs47 - crhs34*crhs48; -rhs[5]=N[1]*crhs0*crhs39 - N[1]*crhs40 - N[1]*crhs41 + N[1]*crhs45 - crhs46*crhs47 - crhs46*crhs48; -rhs[6]=N[2]*crhs0*crhs5 - N[2]*crhs10 + N[2]*crhs17 - N[2]*crhs6 - crhs18*crhs49 - crhs18*crhs50; -rhs[7]=N[2]*crhs0*crhs27 - N[2]*crhs28 - N[2]*crhs29 + N[2]*crhs33 - crhs34*crhs49 - crhs34*crhs50; -rhs[8]=N[2]*crhs0*crhs39 - N[2]*crhs40 - N[2]*crhs41 + N[2]*crhs45 - crhs46*crhs49 - crhs46*crhs50; -rhs[9]=N[3]*crhs0*crhs5 - N[3]*crhs10 + N[3]*crhs17 - N[3]*crhs6 - crhs18*crhs51 - crhs18*crhs52; -rhs[10]=N[3]*crhs0*crhs27 - N[3]*crhs28 - N[3]*crhs29 + N[3]*crhs33 - crhs34*crhs51 - crhs34*crhs52; -rhs[11]=N[3]*crhs0*crhs39 - N[3]*crhs40 - N[3]*crhs41 + N[3]*crhs45 - crhs46*crhs51 - crhs46*crhs52; - - - // Add intermediate results to local system. - noalias(rRHS) += rhs * rData.Weight; + // Add RHS Gauss point contribution + const double w_gauss =rData.Weight; + + const double crRHS0 = N[0]*(vn(0,0) - vnn(0,0)); +const double crRHS1 = N[1]*(vn(1,0) - vnn(1,0)); +const double crRHS2 = N[2]*(vn(2,0) - vnn(2,0)); +const double crRHS3 = N[3]*(vn(3,0) - vnn(3,0)); +const double crRHS4 = crRHS0 + crRHS1 + crRHS2 + crRHS3; +const double crRHS5 = 1.0/dt; +const double crRHS6 = N[0]*crRHS5; +const double crRHS7 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)) + N[3]*(bdf0*vfrac(3,0) + bdf1*vn(3,0) + bdf2*vnn(3,0)); +const double crRHS8 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crRHS9 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crRHS10 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crRHS11 = crRHS10*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)) + crRHS8*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crRHS9*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)); +const double crRHS12 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crRHS13 = crRHS12*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)); +const double crRHS14 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crRHS15 = crRHS14*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)); +const double crRHS16 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crRHS17 = crRHS16*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crRHS18 = crRHS13 + crRHS15 + crRHS17; +const double crRHS19 = -crRHS0*crRHS5 - crRHS1*crRHS5 + crRHS11 - crRHS13 - crRHS15 - crRHS17 - crRHS2*crRHS5 - crRHS3*crRHS5 + crRHS7; +const double crRHS20 = 1.0*1.0/(crRHS5*dyn_tau + stab_c2*1.0/h*sqrt(crRHS10*crRHS10 + crRHS8*crRHS8 + crRHS9*crRHS9)); +const double crRHS21 = crRHS20*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crRHS22 = N[0]*crRHS21; +const double crRHS23 = crRHS20*(DN(0,0)*crRHS8 + DN(0,1)*crRHS9 + DN(0,2)*crRHS10); +const double crRHS24 = N[0]*(vn(0,1) - vnn(0,1)); +const double crRHS25 = N[1]*(vn(1,1) - vnn(1,1)); +const double crRHS26 = N[2]*(vn(2,1) - vnn(2,1)); +const double crRHS27 = N[3]*(vn(3,1) - vnn(3,1)); +const double crRHS28 = crRHS24 + crRHS25 + crRHS26 + crRHS27; +const double crRHS29 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)) + N[3]*(bdf0*vfrac(3,1) + bdf1*vn(3,1) + bdf2*vnn(3,1)); +const double crRHS30 = crRHS10*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)) + crRHS8*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crRHS9*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)); +const double crRHS31 = crRHS12*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)); +const double crRHS32 = crRHS14*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)); +const double crRHS33 = crRHS16*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); +const double crRHS34 = crRHS31 + crRHS32 + crRHS33; +const double crRHS35 = -crRHS24*crRHS5 - crRHS25*crRHS5 - crRHS26*crRHS5 - crRHS27*crRHS5 + crRHS29 + crRHS30 - crRHS31 - crRHS32 - crRHS33; +const double crRHS36 = N[0]*(vn(0,2) - vnn(0,2)); +const double crRHS37 = N[1]*(vn(1,2) - vnn(1,2)); +const double crRHS38 = N[2]*(vn(2,2) - vnn(2,2)); +const double crRHS39 = N[3]*(vn(3,2) - vnn(3,2)); +const double crRHS40 = crRHS36 + crRHS37 + crRHS38 + crRHS39; +const double crRHS41 = N[0]*(bdf0*vfrac(0,2) + bdf1*vn(0,2) + bdf2*vnn(0,2)) + N[1]*(bdf0*vfrac(1,2) + bdf1*vn(1,2) + bdf2*vnn(1,2)) + N[2]*(bdf0*vfrac(2,2) + bdf1*vn(2,2) + bdf2*vnn(2,2)) + N[3]*(bdf0*vfrac(3,2) + bdf1*vn(3,2) + bdf2*vnn(3,2)); +const double crRHS42 = crRHS10*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)) + crRHS8*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crRHS9*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)); +const double crRHS43 = crRHS12*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)); +const double crRHS44 = crRHS14*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)); +const double crRHS45 = crRHS16*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crRHS46 = crRHS43 + crRHS44 + crRHS45; +const double crRHS47 = -crRHS36*crRHS5 - crRHS37*crRHS5 - crRHS38*crRHS5 - crRHS39*crRHS5 + crRHS41 + crRHS42 - crRHS43 - crRHS44 - crRHS45; +const double crRHS48 = N[1]*crRHS5; +const double crRHS49 = N[1]*crRHS21; +const double crRHS50 = crRHS20*(DN(1,0)*crRHS8 + DN(1,1)*crRHS9 + DN(1,2)*crRHS10); +const double crRHS51 = N[2]*crRHS5; +const double crRHS52 = N[2]*crRHS21; +const double crRHS53 = crRHS20*(DN(2,0)*crRHS8 + DN(2,1)*crRHS9 + DN(2,2)*crRHS10); +const double crRHS54 = N[3]*crRHS5; +const double crRHS55 = N[3]*crRHS21; +const double crRHS56 = crRHS20*(DN(3,0)*crRHS8 + DN(3,1)*crRHS9 + DN(3,2)*crRHS10); +rRHS[0]+=-w_gauss*(N[0]*crRHS11 - N[0]*crRHS18 + N[0]*crRHS7 + crRHS19*crRHS22 + crRHS19*crRHS23 - crRHS4*crRHS6); +rRHS[1]+=-w_gauss*(N[0]*crRHS29 + N[0]*crRHS30 - N[0]*crRHS34 + crRHS22*crRHS35 + crRHS23*crRHS35 - crRHS28*crRHS6); +rRHS[2]+=-w_gauss*(N[0]*crRHS41 + N[0]*crRHS42 - N[0]*crRHS46 + crRHS22*crRHS47 + crRHS23*crRHS47 - crRHS40*crRHS6); +rRHS[3]+=-w_gauss*(N[1]*crRHS11 - N[1]*crRHS18 + N[1]*crRHS7 + crRHS19*crRHS49 + crRHS19*crRHS50 - crRHS4*crRHS48); +rRHS[4]+=-w_gauss*(N[1]*crRHS29 + N[1]*crRHS30 - N[1]*crRHS34 - crRHS28*crRHS48 + crRHS35*crRHS49 + crRHS35*crRHS50); +rRHS[5]+=-w_gauss*(N[1]*crRHS41 + N[1]*crRHS42 - N[1]*crRHS46 - crRHS40*crRHS48 + crRHS47*crRHS49 + crRHS47*crRHS50); +rRHS[6]+=-w_gauss*(N[2]*crRHS11 - N[2]*crRHS18 + N[2]*crRHS7 + crRHS19*crRHS52 + crRHS19*crRHS53 - crRHS4*crRHS51); +rRHS[7]+=-w_gauss*(N[2]*crRHS29 + N[2]*crRHS30 - N[2]*crRHS34 - crRHS28*crRHS51 + crRHS35*crRHS52 + crRHS35*crRHS53); +rRHS[8]+=-w_gauss*(N[2]*crRHS41 + N[2]*crRHS42 - N[2]*crRHS46 - crRHS40*crRHS51 + crRHS47*crRHS52 + crRHS47*crRHS53); +rRHS[9]+=-w_gauss*(N[3]*crRHS11 - N[3]*crRHS18 + N[3]*crRHS7 + crRHS19*crRHS55 + crRHS19*crRHS56 - crRHS4*crRHS54); +rRHS[10]+=-w_gauss*(N[3]*crRHS29 + N[3]*crRHS30 - N[3]*crRHS34 - crRHS28*crRHS54 + crRHS35*crRHS55 + crRHS35*crRHS56); +rRHS[11]+=-w_gauss*(N[3]*crRHS41 + N[3]*crRHS42 - N[3]*crRHS46 - crRHS40*crRHS54 + crRHS47*crRHS55 + crRHS47*crRHS56); + + } /***********************************************************************************/ diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py index 247c8554f027..541cc0cfa6c5 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py @@ -42,6 +42,7 @@ nnodes = 4 strain_size = 6 impose_partion_of_unity = False + gauss_weight = sympy.Symbol('w_gauss', positive = True) N,DN = DefineShapeFunctions(nnodes, dim, impose_partion_of_unity) #define enrichment shape functions DNenr = DefineMatrix('DNenr',nnodes,dim) @@ -138,11 +139,11 @@ ## Compute LHS and RHS # For the RHS computation one wants the residual of the previous iteration (residual based formulation). rhs = Compute_RHS(rv.copy(), testfunc, do_simplifications) - rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) + rhs_out = OutputVector_CollectingFactors(gauss_weight*rhs, "rRHS", mode, assignment_op='+=') # Compute LHS (RHS(residual) differenctiation w.r.t. the DOFs) lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications) - lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode) + lhs_out = OutputMatrix_CollectingFactors(gauss_weight * lhs, "rLHS", mode, assignment_op='+=') ##################################################################### ##################################################################### diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py index 360248f61600..5c4169c17508 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_navier_stokes_fractional.py @@ -52,6 +52,7 @@ strain_size = 6 impose_partion_of_unity = False + gauss_weight = sympy.Symbol('w_gauss', positive = True) N,DN = DefineShapeFunctions(nnodes, dim, impose_partion_of_unity) #define enrichment shape functions @@ -224,7 +225,7 @@ # For the RHS computation one wants the residual of the previous iteration (residual based formulation). By this reason the stress is # included as a symbolic variable, which is assumed to be passed as an argument from the previous iteration database. rhs = Compute_RHS(rv.copy(), testfunc, do_simplifications) - rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) + rhs_out = OutputVector_CollectingFactors(gauss_weight*rhs, "rRHS", mode, assignment_op='+=') # Compute LHS (RHS(residual) differenctiation w.r.t. the DOFs) # Note that the 'stress' (symbolic variable) is substituted by 'C*grad_sym_v_voigt' for the LHS differenctiation. Otherwise the velocity terms @@ -232,8 +233,7 @@ # a velocity independent constant in the LHS. SubstituteMatrixValue(rhs, stress, C*grad_sym_v_voigt) lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications) # Compute the LHS (considering stress as C*(B*v) to derive w.r.t. v) - lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode) - + lhs_out = OutputMatrix_CollectingFactors(gauss_weight * lhs, "rLHS", mode, assignment_op='+=') #Enrichment Functional ## K V x = b + rhs_eV ## H Kee penr = rhs_ee @@ -275,10 +275,10 @@ rhs_ee, H = Compute_RHS_and_LHS(rv_enriched, testfunc_enr, dofs, do_simplifications) rhs_ee, Kee = Compute_RHS_and_LHS(rv_enriched, testfunc_enr, dofs_enr, do_simplifications) - V_out = OutputMatrix_CollectingFactors(V,"V",mode) - H_out = OutputMatrix_CollectingFactors(H,"H",mode) - Kee_out = OutputMatrix_CollectingFactors(Kee,"Kee",mode) - rhs_ee_out = OutputVector_CollectingFactors(rhs_ee,"rhs_ee",mode) + V_out = OutputMatrix_CollectingFactors(gauss_weight*V,"rV",mode,assignment_op='+=') + H_out = OutputMatrix_CollectingFactors(gauss_weight*H,"rH",mode,assignment_op='+=') + Kee_out = OutputMatrix_CollectingFactors(gauss_weight*Kee,"rKee",mode,assignment_op='+=') + rhs_ee_out = OutputVector_CollectingFactors(gauss_weight*rhs_ee,"rRHS_ee",mode,assignment_op='+=') # Calculate artificial dynamic viscosity in each Gauss point vel_residual_norm = vel_residual.norm() diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp index 0e2e63efe775..bba5e2e1e75f 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp @@ -168,8 +168,9 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, - MatrixType &rLHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + MatrixType &rLHS) { const double h = rData.ElementSize; @@ -187,17 +188,19 @@ namespace Kratos // Stabilization parameters constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; + // Add LHS Gauss point contribution + const double w_gauss =rData.Weight; + //substitute_lhs_2D - // Add intermediate results to local system. - noalias(rLHS) += lhs * rData.Weight; + } /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, - MatrixType &rLHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + MatrixType &rLHS) { @@ -217,19 +220,20 @@ namespace Kratos // Stabilization parameters constexpr double stab_c2 = 2.0; - auto &lhs = rData.lhs; + // Add LHS Gauss point contribution + const double w_gauss =rData.Weight; //substitute_lhs_3D - // Add intermediate results to local system. - noalias(rLHS) += lhs * rData.Weight; + } /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, - VectorType &rRHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + VectorType &rRHS) { const double h = rData.ElementSize; @@ -249,18 +253,19 @@ namespace Kratos const auto &N = rData.N; const auto &DN = rData.DN_DX; - auto &rhs = rData.rhs; - + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; + //substitute_rhs_2D - //Add intermediate results to local system. - noalias(rRHS) += rhs * rData.Weight; + } /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution(TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, - VectorType &rRHS) + void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + VectorType &rRHS) { @@ -280,12 +285,11 @@ namespace Kratos const auto &N = rData.N; const auto &DN = rData.DN_DX; - auto &rhs = rData.rhs; + // Add RHS Gauss point contribution + const double w_gauss =rData.Weight; //substitute_rhs_3D - // Add intermediate results to local system. - noalias(rRHS) += rhs * rData.Weight; } /***********************************************************************************/ diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp index 5391d1e1251e..aeb995c6828e 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_template.cpp @@ -357,12 +357,10 @@ void TwoFluidNavierStokesFractional>::C const auto &N = rData.N; const auto &DN = rData.DN_DX; - auto &lhs = rData.lhs; + // Add LHS Gauss point contribution + const double w_gauss = rData.Weight; //substitute_lhs_2D - - // Add intermediate results to local system - noalias(rLHS) += lhs * rData.Weight; } template <> @@ -387,13 +385,11 @@ void TwoFluidNavierStokesFractional>::C // Get shape function values const auto &N = rData.N; const auto &DN = rData.DN_DX; - - auto &lhs = rData.lhs; + + // Add LHS Gauss point contribution + const double w_gauss = rData.Weight; //substitute_lhs_3D - - // Add intermediate results to local system - noalias(rLHS) += lhs * rData.Weight; } template <> @@ -446,11 +442,10 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &rhs = rData.rhs; + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; //substitute_rhs_2D - - noalias(rRHS) += rData.Weight * rhs; } template <> @@ -503,11 +498,10 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &rhs = rData.rhs; + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; //substitute_rhs_3D - - noalias(rRHS) += rData.Weight * rhs; } template <> @@ -565,13 +559,11 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &V = rData.V; - auto &H = rData.H; - auto &Kee = rData.Kee; - auto &rhs_ee = rData.rhs_ee; - array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it + // Add Enrichment Gauss point contribution + const double w_gauss = rData.Weight; + //substitute_enrichment_V_2D //substitute_enrichment_H_2D @@ -580,10 +572,6 @@ void TwoFluidNavierStokesFractional>::C //substitute_enrichment_rhs_ee_2D - noalias(rV) += rData.Weight * V; - noalias(rH) += rData.Weight * H; - noalias(rKee) += rData.Weight * Kee; - noalias(rRHS_ee) += rData.Weight * rhs_ee; } template <> @@ -640,10 +628,8 @@ void TwoFluidNavierStokesFractional>::C volume_error_ratio = volume_error / previous_dt; } - auto &V = rData.V; - auto &H = rData.H; - auto &Kee = rData.Kee; - auto &rhs_ee = rData.rhs_ee; + // Add Enrichment Gauss point contribution + const double w_gauss = rData.Weight; array_1d penr = ZeroVector(NumNodes); //penriched is considered to be zero as we do not want to store it @@ -654,11 +640,6 @@ void TwoFluidNavierStokesFractional>::C //substitute_enrichment_Kee_3D //substitute_enrichment_rhs_ee_3D - - noalias(rV) += rData.Weight * V; - noalias(rH) += rData.Weight * H; - noalias(rKee) += rData.Weight * Kee; - noalias(rRHS_ee) += rData.Weight * rhs_ee; } template @@ -784,6 +765,75 @@ ModifiedShapeFunctions::UniquePointer TwoFluidNavierStokesFractional< TwoFluidNa { return Kratos::make_unique(pGeometry, rDistances); } +template <> +double TwoFluidNavierStokesFractional>::CalculateArtificialDynamicViscositySpecialization( + TwoFluidNavierStokesFractionalData<2, 3> &rData) const +{ + // Variables for artificial viscosity calculation + double artificial_mu = 0.0; + const double rho = rData.Density; + const double bdf0 = rData.bdf0; + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const auto &v = rData.Velocity; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const BoundedMatrix vconv = vn - vmesh; + const auto vfrac = rData.FractionalVelocity; + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const double art_dyn_visc_coeff = 0.8; + double grad_v_norm = 0.0; + + // Check that velocity gradient norm is non-zero + + //Substitute_artificial_mu_grad_v_norm_2D_3N + + if (grad_v_norm > 1.0e-12) { + // Calculate symbolic artificial viscosity + //substitute_artificial_mu_2D_3N + } + + return artificial_mu; +} + +template <> +double TwoFluidNavierStokesFractional>::CalculateArtificialDynamicViscositySpecialization( + TwoFluidNavierStokesFractionalData<3, 4> &rData) const +{ + // Variables for artificial viscosity calculation + double artificial_mu = 0.0; + const double rho = rData.Density; + const double bdf0 = rData.bdf0; + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const auto &v = rData.Velocity; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &f = rData.BodyForce; + const auto &p = rData.Pressure; + const BoundedMatrixvconv = vn - vmesh; + const auto vfrac = rData.FractionalVelocity; + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + const double art_dyn_visc_coeff = 0.8; + double grad_v_norm = 0.0; + + // Check that velocity gradient norm is non-zero + + //Substitute_artificial_mu_grad_v_norm_3D_4N + + if (grad_v_norm > 1.0e-12) { + // Calculate symbolic artificial viscosity + //substitute_artificial_mu_3D_4N + } + + return artificial_mu; +} template void TwoFluidNavierStokesFractional::CalculateStrainRate(TElementData& rData) const @@ -895,41 +945,67 @@ void TwoFluidNavierStokesFractional::load(Serializer &rSerializer) KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType); } - template void TwoFluidNavierStokesFractional::CalculateOnIntegrationPoints( const Variable &rVariable, - std::vector &rValues, - const ProcessInfo &rCurrentProcessInfo ) + std::vector &rOutput, + const ProcessInfo &rCurrentProcessInfo) { - if (rVariable == DIVERGENCE){ - - const auto& rGeom = this->GetGeometry(); - const GeometryType::IntegrationPointsArrayType& IntegrationPoints = rGeom.IntegrationPoints(GeometryData::IntegrationMethod::GI_GAUSS_2); - const unsigned int num_gauss = IntegrationPoints.size(); + // Create new temporary data container + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + + if (rOutput.size() != number_of_gauss_points){ + rOutput.resize(number_of_gauss_points); + } - if (rValues.size() != num_gauss){ - rValues.resize(num_gauss); + if (rVariable == ARTIFICIAL_DYNAMIC_VISCOSITY){ + // Iterate over integration points to evaluate the artificial viscosity at each Gauss point + for (unsigned int g = 0; g < number_of_gauss_points; ++g){ + this->UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + rOutput[g] = this->GetValue(ARTIFICIAL_DYNAMIC_VISCOSITY); } + } + else{ + FluidElement::CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo); + } +} - Vector gauss_pts_jacobian_determinant = ZeroVector(num_gauss); - GeometryData::ShapeFunctionsGradientsType DN_DX; - rGeom.ShapeFunctionsIntegrationPointsGradients(DN_DX, gauss_pts_jacobian_determinant, GeometryData::IntegrationMethod::GI_GAUSS_2); - - for (unsigned int i_gauss = 0; i_gauss < num_gauss; ++i_gauss){ - - const Matrix gp_DN_DX = DN_DX[i_gauss]; - double DVi_DXi = 0.0; - - for(unsigned int nnode = 0; nnode < NumNodes; ++nnode){ +template +void TwoFluidNavierStokesFractional::Calculate( + const Variable &rVariable, + double &rOutput, + const ProcessInfo &rCurrentProcessInfo) +{ + // Create new temporary data container + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + rOutput = 0.0; + if (rVariable == ARTIFICIAL_DYNAMIC_VISCOSITY) + { - const array_1d vel = rGeom[nnode].GetSolutionStepValue(VELOCITY); - for(unsigned int ndim = 0; ndim < Dim; ++ndim){ - DVi_DXi += gp_DN_DX(nnode, ndim) * vel[ndim]; - } - } - rValues[i_gauss] = DVi_DXi; + // Iterate over integration points to evaluate the artificial viscosity at each Gauss point + for (unsigned int g = 0; g < number_of_gauss_points; ++g) + { + this->UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + rOutput += CalculateArtificialDynamicViscositySpecialization(data); } + + rOutput /= number_of_gauss_points; } } From 451e8d370f3e1f5845dc50279d3aa53d9e9116ca Mon Sep 17 00:00:00 2001 From: uxuech Date: Mon, 30 Dec 2024 12:37:02 +0100 Subject: [PATCH 12/13] adding stabilization terms in .h eleemnt --- ...wo_fluid_navier_stokes_fractional_convection_element.cpp | 6 ------ ...o_fluid_navier_stokes_fractional_convection_template.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp index 2daedea9b030..510526587d48 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp @@ -185,9 +185,6 @@ namespace Kratos const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - // Add LHS Gauss point contribution const double w_gauss =rData.Weight; @@ -283,9 +280,6 @@ rLHS(5,5)+=crLHS29; const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - // Add LHS Gauss point contribution const double w_gauss =rData.Weight; diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp index bba5e2e1e75f..99535f8acd22 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp @@ -185,9 +185,6 @@ namespace Kratos const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - // Add LHS Gauss point contribution const double w_gauss =rData.Weight; @@ -217,9 +214,6 @@ namespace Kratos const auto &N = rData.N; const auto &DN = rData.DN_DX; - // Stabilization parameters - constexpr double stab_c2 = 2.0; - // Add LHS Gauss point contribution const double w_gauss =rData.Weight; From 26255678452b8b5df88016ae96f1811ae74382f0 Mon Sep 17 00:00:00 2001 From: uxuech Date: Tue, 7 Jan 2025 12:05:01 +0100 Subject: [PATCH 13/13] removiming "element" from the file name --- ...navier_stokes_fractional_convection_data.h | 112 +++ ...tokes_fractional_convection_element_data.h | 2 +- .../custom_elements/fluid_element.cpp | 1 - ...d_navier_stokes_fractional_convection.cpp} | 54 +- ...luid_navier_stokes_fractional_convection.h | 350 +++++++++ ...ier_stokes_fractional_convection_element.h | 22 +- .../fluid_dynamics_application.cpp | 8 +- .../fluid_dynamics_application.h | 8 +- ...enerate_two_fluid_convection_fractional.py | 2 +- ...id_navier_stokes_fractional_convection.cpp | 716 ++++++++++++++++++ ..._stokes_fractional_convection_template.cpp | 54 +- ...ectorial_convection_fractional_element.cpp | 6 +- 12 files changed, 1256 insertions(+), 79 deletions(-) create mode 100644 applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h rename applications/FluidDynamicsApplication/custom_elements/{two_fluid_navier_stokes_fractional_convection_element.cpp => two_fluid_navier_stokes_fractional_convection.cpp} (90%) create mode 100644 applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.h create mode 100644 applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection.cpp diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h new file mode 100644 index 000000000000..285bfd9269ad --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h @@ -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 +{ +public: + +///@name Type Definitions +///@{ + +using NodalScalarData = typename FluidElementData::NodalScalarData; +using NodalVectorData = typename FluidElementData::NodalVectorData; +using ShapeFunctionsType = typename FluidElementData::ShapeFunctionsType; +using ShapeDerivativesType = typename FluidElementData::ShapeDerivativesType; +using MatrixRowType = typename FluidElementData::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& rDN_DX) override +{ + FluidElementData::UpdateGeometryValues(IntegrationPointIndex, NewWeight,rN,rDN_DX); + ElementSize = ElementSizeCalculator::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; +} + +///@} + +}; + +///@} + +///@} + +} \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h index 7a1938094ca4..285bfd9269ad 100644 --- a/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h +++ b/applications/FluidDynamicsApplication/custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h @@ -26,7 +26,7 @@ namespace Kratos { ///@{ template< size_t TDim, size_t TNumNodes > -class TwoFluidNavierStokesFractionalConvectionElementData : public FluidElementData +class TwoFluidNavierStokesFractionalConvectionData : public FluidElementData { public: diff --git a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp index 5a8267588f95..40949ac9c692 100644 --- a/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/fluid_element.cpp @@ -26,7 +26,6 @@ #include "data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" #include "data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" #include "data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" -#include "data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h" #include "utilities/element_size_calculator.h" #include "custom_utilities/vorticity_utilities.h" diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.cpp similarity index 90% rename from applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp rename to applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.cpp index 510526587d48..8da5ba5716b2 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.cpp +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.cpp @@ -10,7 +10,7 @@ // Main author: Uxue Chasco // -#include "two_fluid_navier_stokes_fractional_convection_element.h" +#include "two_fluid_navier_stokes_fractional_convection.h" namespace Kratos { @@ -19,27 +19,27 @@ namespace Kratos /***********************************************************************************/ template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId) : Element(NewId) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId) : Element(NewId) { } template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) { } template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) { } template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) { } template - TwoFluidNavierStokesFractionalConvectionElement::~TwoFluidNavierStokesFractionalConvectionElement() + TwoFluidNavierStokesFractionalConvection::~TwoFluidNavierStokesFractionalConvection() { } @@ -47,35 +47,35 @@ namespace Kratos /***********************************************************************************/ template - Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvection::Create( IndexType NewId, NodesArrayType const &ThisNodes, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); } /***********************************************************************************/ template - Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvection::Create( IndexType NewId, GeometryType::Pointer pGeom, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, pGeom, pProperties); + return Kratos::make_intrusive(NewId, pGeom, pProperties); } /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + void TwoFluidNavierStokesFractionalConvection::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) { KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); } template - void TwoFluidNavierStokesFractionalConvectionElement::CalculateLocalSystem( + void TwoFluidNavierStokesFractionalConvection::CalculateLocalSystem( MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) @@ -111,7 +111,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::UpdateIntegrationPointData( + void TwoFluidNavierStokesFractionalConvection::UpdateIntegrationPointData( TElementData &rData, unsigned int IntegrationPointIndex, double Weight, @@ -125,7 +125,7 @@ namespace Kratos /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::AddTimeIntegratedSystem( + void TwoFluidNavierStokesFractionalConvection::AddTimeIntegratedSystem( TElementData &rData, MatrixType &rLHS, VectorType &rRHS) @@ -137,7 +137,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::CalculateGeometryData(Vector &rGaussWeights, + void TwoFluidNavierStokesFractionalConvection::CalculateGeometryData(Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionDerivativesArrayType &rDN_DX) const { @@ -168,8 +168,8 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionData<2, 3> &rData, MatrixType &rLHS) { @@ -261,8 +261,8 @@ rLHS(5,5)+=crLHS29; /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionData<3, 4> &rData, MatrixType &rLHS) { @@ -481,8 +481,8 @@ rLHS(11,11)+=crLHS45; /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionData<2, 3> &rData, VectorType &rRHS) { @@ -555,8 +555,8 @@ rRHS[5]+=-w_gauss*(N[2]*crRHS24 + N[2]*crRHS25 - N[2]*crRHS28 - crRHS23*crRHS33 /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionData<3, 4> &rData, VectorType &rRHS) { @@ -656,7 +656,7 @@ rRHS[11]+=-w_gauss*(N[3]*crRHS41 + N[3]*crRHS42 - N[3]*crRHS46 - crRHS40*crRHS54 /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::EquationIdVector( + void TwoFluidNavierStokesFractionalConvection::EquationIdVector( EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const { @@ -682,7 +682,7 @@ rRHS[11]+=-w_gauss*(N[3]*crRHS41 + N[3]*crRHS42 - N[3]*crRHS46 - crRHS40*crRHS54 /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::GetDofList( + void TwoFluidNavierStokesFractionalConvection::GetDofList( DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const { @@ -708,8 +708,8 @@ rRHS[11]+=-w_gauss*(N[3]*crRHS41 + N[3]*crRHS42 - N[3]*crRHS46 - crRHS40*crRHS54 /***********************************************************************************/ /***********************************************************************************/ - template class TwoFluidNavierStokesFractionalConvectionElement>; - template class TwoFluidNavierStokesFractionalConvectionElement>; + template class TwoFluidNavierStokesFractionalConvection>; + template class TwoFluidNavierStokesFractionalConvection>; /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.h new file mode 100644 index 000000000000..e1ef0eb6024f --- /dev/null +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection.h @@ -0,0 +1,350 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main authors: Uxue Chasco +// +// +// + +#pragma once + +// System includes + +// External includes + +// Project includes +#include "includes/ublas_interface.h" +#include "includes/variables.h" +#include "includes/cfd_variables.h" +#include "includes/convection_diffusion_settings.h" +#include "utilities/geometry_utilities.h" +#include "custom_elements/data_containers/fluid_element_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h" +#include "fluid_dynamics_application_variables.h" + +namespace Kratos +{ +/* + The "TwoFluidNavierStokesFractionalConvection" solves the convection problem of a vector field, specifically the fractional velocity, and convects this field using its own velocity. + This element is part of the two-fluid Navier-Stokes fractional element TwoFluidNavierStokesFractional. + The Navier-Stokes momentum conservation equation is split into two problems: the first one convects the fractional velocity (using this element), and the second one resolves the remaining terms of the Navier-Stokes momentum conservation. + Combining both problems in the continuous framework results in the original Navier-Stokes momentum equation + */ + +///@name Kratos Globals +///@{ +///@} +///@name Type Definitions +///@{ +///@} +///@name Enum's +///@{ +///@} +///@name Functions +///@{ +///@} +///@name Kratos Classes +///@{ +template +class TwoFluidNavierStokesFractionalConvection: public Element +{ +public: + ///@name Type Definitions + ///@{ + + /// Counted pointer of + KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractionalConvection); + + using ElementData = TElementData; + typedef GeometryType::ShapeFunctionsGradientsType ShapeFunctionDerivativesArrayType; + static constexpr unsigned int Dim = TElementData::Dim; + + static constexpr unsigned int NumNodes = TElementData::NumNodes; + + static constexpr unsigned int BlockSize = Dim; + + static constexpr unsigned int LocalSize = NumNodes * BlockSize; + + ///@} + ///@name Life Cycle + ///@{ + + /// Default constuctor. + /** + * @param NewId Index number of the new element (optional) + */ + TwoFluidNavierStokesFractionalConvection(IndexType NewId = 0); + + /** + * @brief Constructor using an array of nodes. + * @param NewId Index of the new element + * @param ThisNodes An array containing the nodes of the new element + */ + TwoFluidNavierStokesFractionalConvection( + IndexType NewId, + const NodesArrayType &ThisNodes); + + /** + * @brief Constructor using a geometry object. + * @param NewId Index of the new element + * @param pGeometry Pointer to a geometry object + */ + TwoFluidNavierStokesFractionalConvection( + IndexType NewId, + GeometryType::Pointer pGeometry); + + /** + * @brief 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 + */ + TwoFluidNavierStokesFractionalConvection( + IndexType NewId, + GeometryType::Pointer pGeometry, + Properties::Pointer pProperties); + + /// Destructor. + virtual ~TwoFluidNavierStokesFractionalConvection(); + + ///@} + ///@name Operators + ///@{ + + + ///@} + ///@name Operations + ///@{ + /** + @brief Returns a pointer to a new TwoFluidNavierStokesFractionalConvection element, created using given input. + * @param NewId the ID of the new element + * @param ThisNodes the nodes of the new element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create( + IndexType NewId, + NodesArrayType const& ThisNodes, + PropertiesType::Pointer pProperties) const override; + + + /** + * @brief Returns a pointer to a new FluidElement element, created using given input. + * @param NewId the ID of the new element + * @param pGeom a pointer to the geomerty to be used to create the element + * @param pProperties the properties assigned to the new element + * @return a Pointer to the new element + */ + Element::Pointer Create( + IndexType NewId, + GeometryType::Pointer pGeom, + PropertiesType::Pointer pProperties) const override; + + /** + * @brief Given a distance function, computes the time integrated Left Hand Side (LHS) + * and Right Hand Side elemental contributions for the two-fluid element. + * @param rLeftHandSideMatrix elemental stiffness matrix + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateLocalSystem( + MatrixType& rLeftHandSideMatrix, + VectorType& rRightHandSideVector, + const ProcessInfo& rCurrentProcessInfo) override; + + /** + * @brief Computes the LHS Gauss pt. contribution + * This method computes the contribution to the LHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + */ + virtual void ComputeGaussPointLHSContribution( + TElementData &rData, + MatrixType &rLHS); + + /** + * @brief Computes the RHS Gaus pt. contribution + * This method computes the contribution to the RHS of a Gauss pt. + * @param rData Reference to the element data container + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + virtual void ComputeGaussPointRHSContribution( + TElementData &rData, + VectorType &rRHS); + + /** + * @brief Sets on rResult the ID's of the element degrees of freedom + * @param rResult The result vector with the ID's of the DOF + * @param rCurrentProcessInfo the current process info instance + */ + void EquationIdVector( + EquationIdVectorType& rResult, + const ProcessInfo& rCurrentProcessInfo) const override; + + void GetDofList( + DofsVectorType &rElementalDofList, + const ProcessInfo &rCurrentProcessInfo) const override; + + /** + * @brief Given a distance function, computes the time integrated Right Hand Side (RHS) + * elemental contribution for the two-fluid element. + * @param rRightHandSideVector elemental residual vector + * @param rCurrentProcessInfo reference to the current process info + */ + void CalculateRightHandSide( + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) override; + + /** + * @brief Computes time integrated LHS and RHS arrays + * This method computes both the Left Hand Side and + * Right Hand Side time integrated contributions. + * @param rData Reference to the element data container + * @param rLHS Reference to the Left Hand Side matrix to be filled + * @param rRHS Reference to the Right Hand Side vector to be filled + */ + void AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS); + + /** + * @brief Set up the element's data and for the current integration point. + * @param[in/out] rData Container for the current element's data. + * @param[in] Weight Integration point weight. + * @param[in] rN Values of nodal shape functions at the integration point. + * @param[in] rDN_DX Values of nodal shape function gradients at the integration point. + */ + void UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const; + + /** + * @brief Computes shape function data for all the gauss points + * + * @param rGaussWeights Gauss point weights + * @param rNContainer Gauss point shape functions (each row corresponds to a specific gauss point) + * @param rDN_DX Gauss point shape function gradients (vector of matrices) + */ + virtual void CalculateGeometryData( + Vector &rGaussWeights, + Matrix &rNContainer, + ShapeFunctionDerivativesArrayType &rDN_DX) const; + + ///@} + ///@name Access + ///@{ + + + ///@} + ///@name Inquiry + ///@{ + + + ///@} + ///@name Input and output + ///@{ + + /// Turn back information as a string. + + std::string Info() const override + { + return "TwoFluidNavierStokesFractionalConvection #"; + } + + /// Print information about this object. + + void PrintInfo(std::ostream& rOStream) const override + { + rOStream << Info() << Id(); + } + + /// Print object's data. + // virtual void PrintData(std::ostream& rOStream) const; + + + ///@} + ///@name Friends + ///@{ + + + ///@} + +private: + ///@name Static Member Variables + ///@{ + static constexpr double stab_c2 = 2.0; + static constexpr double stab_c1= 4.0; + + + ///@} + ///@name Member Variables + ///@{ + + bool mElementTauNodal; // Flag to indicate if the stabilization tau is evaluated at each Gauss point or interpolated + + ///@} + ///@name Serialization + ///@{ + friend class Serializer; + // ASGS2D() : Element() + // { + // } + + void save(Serializer& rSerializer) const override + { + KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, Element); + } + + void load(Serializer& rSerializer) override + { + KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, Element); + } + + ///@} + + ///@name Private Operations + ///@{ + + + ///@} + ///@name Private Access + ///@{ + + + ///@} + ///@name Private Inquiry + ///@{ + + + ///@} + ///@name Un accessible methods + ///@{ + + + + + + ///@} + +}; + +///@} + +///@name Type Definitions +///@{ + + +///@} + + +} // namespace Kratos. diff --git a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h index 789bde7da7df..e1ef0eb6024f 100644 --- a/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h +++ b/applications/FluidDynamicsApplication/custom_elements/two_fluid_navier_stokes_fractional_convection_element.h @@ -25,13 +25,13 @@ #include "includes/convection_diffusion_settings.h" #include "utilities/geometry_utilities.h" #include "custom_elements/data_containers/fluid_element_data.h" -#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h" #include "fluid_dynamics_application_variables.h" namespace Kratos { /* - The "TwoFluidNavierStokesFractionalConvectionElement" solves the convection problem of a vector field, specifically the fractional velocity, and convects this field using its own velocity. + The "TwoFluidNavierStokesFractionalConvection" solves the convection problem of a vector field, specifically the fractional velocity, and convects this field using its own velocity. This element is part of the two-fluid Navier-Stokes fractional element TwoFluidNavierStokesFractional. The Navier-Stokes momentum conservation equation is split into two problems: the first one convects the fractional velocity (using this element), and the second one resolves the remaining terms of the Navier-Stokes momentum conservation. Combining both problems in the continuous framework results in the original Navier-Stokes momentum equation @@ -52,14 +52,14 @@ namespace Kratos ///@name Kratos Classes ///@{ template -class TwoFluidNavierStokesFractionalConvectionElement: public Element +class TwoFluidNavierStokesFractionalConvection: public Element { public: ///@name Type Definitions ///@{ /// Counted pointer of - KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractionalConvectionElement); + KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TwoFluidNavierStokesFractionalConvection); using ElementData = TElementData; typedef GeometryType::ShapeFunctionsGradientsType ShapeFunctionDerivativesArrayType; @@ -79,14 +79,14 @@ class TwoFluidNavierStokesFractionalConvectionElement: public Element /** * @param NewId Index number of the new element (optional) */ - TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId = 0); + TwoFluidNavierStokesFractionalConvection(IndexType NewId = 0); /** * @brief Constructor using an array of nodes. * @param NewId Index of the new element * @param ThisNodes An array containing the nodes of the new element */ - TwoFluidNavierStokesFractionalConvectionElement( + TwoFluidNavierStokesFractionalConvection( IndexType NewId, const NodesArrayType &ThisNodes); @@ -95,7 +95,7 @@ class TwoFluidNavierStokesFractionalConvectionElement: public Element * @param NewId Index of the new element * @param pGeometry Pointer to a geometry object */ - TwoFluidNavierStokesFractionalConvectionElement( + TwoFluidNavierStokesFractionalConvection( IndexType NewId, GeometryType::Pointer pGeometry); @@ -105,13 +105,13 @@ class TwoFluidNavierStokesFractionalConvectionElement: public Element * @param pGeometry Pointer to a geometry object * @param pProperties Pointer to the element's properties */ - TwoFluidNavierStokesFractionalConvectionElement( + TwoFluidNavierStokesFractionalConvection( IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties); /// Destructor. - virtual ~TwoFluidNavierStokesFractionalConvectionElement(); + virtual ~TwoFluidNavierStokesFractionalConvection(); ///@} ///@name Operators @@ -122,7 +122,7 @@ class TwoFluidNavierStokesFractionalConvectionElement: public Element ///@name Operations ///@{ /** - @brief Returns a pointer to a new TwoFluidNavierStokesFractionalConvectionElement element, created using given input. + @brief Returns a pointer to a new TwoFluidNavierStokesFractionalConvection element, created using given input. * @param NewId the ID of the new element * @param ThisNodes the nodes of the new element * @param pProperties the properties assigned to the new element @@ -258,7 +258,7 @@ class TwoFluidNavierStokesFractionalConvectionElement: public Element std::string Info() const override { - return "TwoFluidNavierStokesFractionalConvectionElement #"; + return "TwoFluidNavierStokesFractionalConvection #"; } /// Print information about this object. diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp index c950eef1295b..81e4aa928ca5 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.cpp @@ -170,8 +170,8 @@ KratosFluidDynamicsApplication::KratosFluidDynamicsApplication(): mTwoFluidNavierStokesWallCondition3D(0, Element::GeometryType::Pointer(new Triangle3D3(Element::GeometryType::PointsArrayType(3)))), mTwoFluidNavierStokesFractional2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), mTwoFluidNavierStokesFractional3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), - mTwoFluidNavierStokesFractionalConvectionElement2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), - mTwoFluidNavierStokesFractionalConvectionElement3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), + mTwoFluidNavierStokesFractionalConvection2D3N(0, Element::GeometryType::Pointer(new Triangle2D3(Element::GeometryType::PointsArrayType(3)))), + mTwoFluidNavierStokesFractionalConvection3D4N(0, Element::GeometryType::Pointer(new Tetrahedra3D4(Element::GeometryType::PointsArrayType(4)))), // Incompressbile Navier-Stokes div-stable elements mIncompressibleNavierStokesP2P1Continuous2D6N(0, Element::GeometryType::Pointer(new Triangle2D6(Element::GeometryType::PointsArrayType(6)))), mIncompressibleNavierStokesP2P1Continuous3D10N(0, Element::GeometryType::Pointer(new Tetrahedra3D10(Element::GeometryType::PointsArrayType(10)))), @@ -409,8 +409,8 @@ void KratosFluidDynamicsApplication::Register() { KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesAlphaMethod3D4N", mTwoFluidNavierStokesAlphaMethod3D4N); KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractional2D3N", mTwoFluidNavierStokesFractional2D3N); KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractional3D4N", mTwoFluidNavierStokesFractional3D4N); - KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractionalConvectionElement2D3N", mTwoFluidNavierStokesFractionalConvectionElement2D3N); - KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractionalConvectionElement3D4N", mTwoFluidNavierStokesFractionalConvectionElement3D4N); + KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractionalConvection2D3N", mTwoFluidNavierStokesFractionalConvection2D3N); + KRATOS_REGISTER_ELEMENT("TwoFluidNavierStokesFractionalConvection3D4N", mTwoFluidNavierStokesFractionalConvection3D4N); // Low Mach Navier-Stokes elements KRATOS_REGISTER_ELEMENT("LowMachNavierStokes2D3N",mLowMachNavierStokes2D3N); diff --git a/applications/FluidDynamicsApplication/fluid_dynamics_application.h b/applications/FluidDynamicsApplication/fluid_dynamics_application.h index a0d3cf85e72a..9a2d34ee4963 100644 --- a/applications/FluidDynamicsApplication/fluid_dynamics_application.h +++ b/applications/FluidDynamicsApplication/fluid_dynamics_application.h @@ -83,7 +83,7 @@ #include "custom_elements/two_fluid_navier_stokes.h" #include "custom_elements/two_fluid_navier_stokes_alpha_method.h" #include "custom_elements/two_fluid_navier_stokes_fractional.h" -#include "custom_elements/two_fluid_navier_stokes_fractional_convection_element.h" +#include "custom_elements/two_fluid_navier_stokes_fractional_convection.h" #include "custom_elements/data_containers/axisymmetric_navier_stokes/axisymmetric_navier_stokes_data.h" #include "custom_elements/data_containers/low_mach_navier_stokes/low_mach_navier_stokes_data.h" @@ -97,7 +97,7 @@ #include "custom_elements/data_containers/two_fluid_navier_stokes_alpha_method/two_fluid_navier_stokes_alpha_method_data.h" #include "custom_elements/data_containers/weakly_compressible_navier_stokes/weakly_compressible_navier_stokes_data.h" #include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_data.h" -#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_element_data.h" +#include "custom_elements/data_containers/two_fluid_fractional_navier_stokes/two_fluid_navier_stokes_fractional_convection_data.h" #include "custom_constitutive/bingham_3d_law.h" #include "custom_constitutive/euler_2d_law.h" @@ -471,8 +471,8 @@ class KRATOS_API(FLUID_DYNAMICS_APPLICATION) KratosFluidDynamicsApplication : pu const TwoFluidNavierStokesWallCondition<3,3> mTwoFluidNavierStokesWallCondition3D; const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional2D3N; const TwoFluidNavierStokesFractional> mTwoFluidNavierStokesFractional3D4N; - const TwoFluidNavierStokesFractionalConvectionElement> mTwoFluidNavierStokesFractionalConvectionElement2D3N; - const TwoFluidNavierStokesFractionalConvectionElement> mTwoFluidNavierStokesFractionalConvectionElement3D4N; + const TwoFluidNavierStokesFractionalConvection> mTwoFluidNavierStokesFractionalConvection2D3N; + const TwoFluidNavierStokesFractionalConvection> mTwoFluidNavierStokesFractionalConvection3D4N; /// Incompressible Navier-Stokes div-stable element const IncompressibleNavierStokesP2P1Continuous<2> mIncompressibleNavierStokesP2P1Continuous2D6N; diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py index 541cc0cfa6c5..e9ff501f825e 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/generate_two_fluid_convection_fractional.py @@ -20,7 +20,7 @@ adding_acceleration = True # Whether to add acceleration -output_filename = "two_fluid_navier_stokes_fractional_convection_element.cpp" +output_filename = "two_fluid_navier_stokes_fractional_convection.cpp" template_filename = "two_fluid_navier_stokes_fractional_convection_template.cpp" if (dim_to_compute == "2D"): diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection.cpp new file mode 100644 index 000000000000..8da5ba5716b2 --- /dev/null +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection.cpp @@ -0,0 +1,716 @@ +// | / | +// ' / __| _` | __| _ \ __| +// . \ | ( | | ( |\__ ` +// _|\_\_| \__,_|\__|\___/ ____/ +// Multi-Physics +// +// License: BSD License +// Kratos default license: kratos/license.txt +// +// Main author: Uxue Chasco +// + +#include "two_fluid_navier_stokes_fractional_convection.h" + +namespace Kratos +{ + + /***********************************************************************************/ + /***********************************************************************************/ + + template + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId) : Element(NewId) + { + } + + template + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + { + } + + template + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + { + } + + template + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + { + } + + template + TwoFluidNavierStokesFractionalConvection::~TwoFluidNavierStokesFractionalConvection() + { + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + Element::Pointer TwoFluidNavierStokesFractionalConvection::Create( + IndexType NewId, + NodesArrayType const &ThisNodes, + Properties::Pointer pProperties) const + { + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + } + + /***********************************************************************************/ + + template + Element::Pointer TwoFluidNavierStokesFractionalConvection::Create( + IndexType NewId, + GeometryType::Pointer pGeom, + Properties::Pointer pProperties) const + { + return Kratos::make_intrusive(NewId, pGeom, pProperties); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void TwoFluidNavierStokesFractionalConvection::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + { + KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); + } + + template + void TwoFluidNavierStokesFractionalConvection::CalculateLocalSystem( + MatrixType &rLeftHandSideMatrix, + VectorType &rRightHandSideVector, + const ProcessInfo &rCurrentProcessInfo) + { + + if (rLeftHandSideMatrix.size1() != LocalSize) + rLeftHandSideMatrix.resize(LocalSize, LocalSize, false); + + if (rRightHandSideVector.size() != LocalSize) + rRightHandSideVector.resize(LocalSize, false); + + noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize, LocalSize); + noalias(rRightHandSideVector) = ZeroVector(LocalSize); + + TElementData data; + data.Initialize(*this, rCurrentProcessInfo); + + // Iterate over integration points to evaluate local contribution + // Get Shape function data + Vector gauss_weights; + Matrix shape_functions; + ShapeFunctionDerivativesArrayType shape_derivatives; + this->CalculateGeometryData(gauss_weights, shape_functions, shape_derivatives); + const unsigned int number_of_gauss_points = gauss_weights.size(); + // Iterate over integration points to evaluate local contribution + for (unsigned int g = 0; g < number_of_gauss_points; ++g) + { + UpdateIntegrationPointData(data, g, gauss_weights[g], row(shape_functions, g), shape_derivatives[g]); + this->AddTimeIntegratedSystem(data, rLeftHandSideMatrix, rRightHandSideVector); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void TwoFluidNavierStokesFractionalConvection::UpdateIntegrationPointData( + TElementData &rData, + unsigned int IntegrationPointIndex, + double Weight, + const typename TElementData::MatrixRowType &rN, + const typename TElementData::ShapeDerivativesType &rDN_DX) const + { + rData.UpdateGeometryValues(IntegrationPointIndex, Weight, rN, rDN_DX); + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + void TwoFluidNavierStokesFractionalConvection::AddTimeIntegratedSystem( + TElementData &rData, + MatrixType &rLHS, + VectorType &rRHS) + { + this->ComputeGaussPointLHSContribution(rData, rLHS); + this->ComputeGaussPointRHSContribution(rData, rRHS); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void TwoFluidNavierStokesFractionalConvection::CalculateGeometryData(Vector &rGaussWeights, + Matrix &rNContainer, + ShapeFunctionDerivativesArrayType &rDN_DX) const + { + const GeometryData::IntegrationMethod integration_method = this->GetIntegrationMethod(); + const GeometryType &r_geometry = this->GetGeometry(); + const unsigned int number_of_gauss_points = r_geometry.IntegrationPointsNumber(integration_method); + + Vector DetJ; + r_geometry.ShapeFunctionsIntegrationPointsGradients(rDN_DX, DetJ, integration_method); + + if (rNContainer.size1() != number_of_gauss_points || rNContainer.size2() != NumNodes) + { + rNContainer.resize(number_of_gauss_points, NumNodes, false); + } + rNContainer = r_geometry.ShapeFunctionsValues(integration_method); + + const GeometryType::IntegrationPointsArrayType &IntegrationPoints = r_geometry.IntegrationPoints(integration_method); + + if (rGaussWeights.size() != number_of_gauss_points) + { + rGaussWeights.resize(number_of_gauss_points, false); + } + + for (unsigned int g = 0; g < number_of_gauss_points; g++) + rGaussWeights[g] = DetJ[g] * IntegrationPoints[g].Weight(); + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionData<2, 3> &rData, + MatrixType &rLHS) + { + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double dyn_tau = rData.DynamicTau; + const auto &vfrac = rData.FractionalVelocity; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = vfrac-vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Add LHS Gauss point contribution + const double w_gauss =rData.Weight; + + const double crLHS0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crLHS1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crLHS2 = DN(0,0)*crLHS0 + DN(0,1)*crLHS1; +const double crLHS3 = N[0]*bdf0; +const double crLHS4 = crLHS2 + crLHS3; +const double crLHS5 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(crLHS0*crLHS0 + crLHS1*crLHS1)); +const double crLHS6 = crLHS5*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crLHS7 = N[0]*crLHS6; +const double crLHS8 = crLHS2*crLHS5; +const double crLHS9 = w_gauss*(N[0]*crLHS2 + bdf0*(N[0]*N[0]) + crLHS4*crLHS7 + crLHS4*crLHS8); +const double crLHS10 = N[1]*crLHS3; +const double crLHS11 = DN(1,0)*crLHS0 + DN(1,1)*crLHS1; +const double crLHS12 = N[1]*bdf0; +const double crLHS13 = crLHS11 + crLHS12; +const double crLHS14 = w_gauss*(N[0]*crLHS11 + crLHS10 + crLHS13*crLHS7 + crLHS13*crLHS8); +const double crLHS15 = N[2]*crLHS3; +const double crLHS16 = DN(2,0)*crLHS0 + DN(2,1)*crLHS1; +const double crLHS17 = N[2]*bdf0 + crLHS16; +const double crLHS18 = w_gauss*(N[0]*crLHS16 + crLHS15 + crLHS17*crLHS7 + crLHS17*crLHS8); +const double crLHS19 = N[1]*crLHS6; +const double crLHS20 = crLHS11*crLHS5; +const double crLHS21 = w_gauss*(N[1]*crLHS2 + crLHS10 + crLHS19*crLHS4 + crLHS20*crLHS4); +const double crLHS22 = w_gauss*(N[1]*crLHS11 + bdf0*(N[1]*N[1]) + crLHS13*crLHS19 + crLHS13*crLHS20); +const double crLHS23 = N[2]*crLHS12; +const double crLHS24 = w_gauss*(N[1]*crLHS16 + crLHS17*crLHS19 + crLHS17*crLHS20 + crLHS23); +const double crLHS25 = N[2]*crLHS6; +const double crLHS26 = crLHS16*crLHS5; +const double crLHS27 = w_gauss*(N[2]*crLHS2 + crLHS15 + crLHS25*crLHS4 + crLHS26*crLHS4); +const double crLHS28 = w_gauss*(N[2]*crLHS11 + crLHS13*crLHS25 + crLHS13*crLHS26 + crLHS23); +const double crLHS29 = w_gauss*(N[2]*crLHS16 + bdf0*(N[2]*N[2]) + crLHS17*crLHS25 + crLHS17*crLHS26); +rLHS(0,0)+=crLHS9; +rLHS(0,1)+=0; +rLHS(0,2)+=crLHS14; +rLHS(0,3)+=0; +rLHS(0,4)+=crLHS18; +rLHS(0,5)+=0; +rLHS(1,0)+=0; +rLHS(1,1)+=crLHS9; +rLHS(1,2)+=0; +rLHS(1,3)+=crLHS14; +rLHS(1,4)+=0; +rLHS(1,5)+=crLHS18; +rLHS(2,0)+=crLHS21; +rLHS(2,1)+=0; +rLHS(2,2)+=crLHS22; +rLHS(2,3)+=0; +rLHS(2,4)+=crLHS24; +rLHS(2,5)+=0; +rLHS(3,0)+=0; +rLHS(3,1)+=crLHS21; +rLHS(3,2)+=0; +rLHS(3,3)+=crLHS22; +rLHS(3,4)+=0; +rLHS(3,5)+=crLHS24; +rLHS(4,0)+=crLHS27; +rLHS(4,1)+=0; +rLHS(4,2)+=crLHS28; +rLHS(4,3)+=0; +rLHS(4,4)+=crLHS29; +rLHS(4,5)+=0; +rLHS(5,0)+=0; +rLHS(5,1)+=crLHS27; +rLHS(5,2)+=0; +rLHS(5,3)+=crLHS28; +rLHS(5,4)+=0; +rLHS(5,5)+=crLHS29; + + + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionData<3, 4> &rData, + MatrixType &rLHS) + { + + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + + const double dyn_tau = rData.DynamicTau; + const auto &vfrac = rData.FractionalVelocity; + const auto &vmesh = rData.MeshVelocity; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Add LHS Gauss point contribution + const double w_gauss =rData.Weight; + + const double crLHS0 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crLHS1 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crLHS2 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crLHS3 = DN(0,0)*crLHS0 + DN(0,1)*crLHS1 + DN(0,2)*crLHS2; +const double crLHS4 = N[0]*bdf0; +const double crLHS5 = crLHS3 + crLHS4; +const double crLHS6 = 1.0*1.0/(dyn_tau*1.0/dt + stab_c2*1.0/h*sqrt(crLHS0*crLHS0 + crLHS1*crLHS1 + crLHS2*crLHS2)); +const double crLHS7 = crLHS6*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crLHS8 = N[0]*crLHS7; +const double crLHS9 = crLHS3*crLHS6; +const double crLHS10 = w_gauss*(N[0]*crLHS3 + bdf0*(N[0]*N[0]) + crLHS5*crLHS8 + crLHS5*crLHS9); +const double crLHS11 = N[1]*crLHS4; +const double crLHS12 = DN(1,0)*crLHS0 + DN(1,1)*crLHS1 + DN(1,2)*crLHS2; +const double crLHS13 = N[1]*bdf0; +const double crLHS14 = crLHS12 + crLHS13; +const double crLHS15 = w_gauss*(N[0]*crLHS12 + crLHS11 + crLHS14*crLHS8 + crLHS14*crLHS9); +const double crLHS16 = N[2]*crLHS4; +const double crLHS17 = DN(2,0)*crLHS0 + DN(2,1)*crLHS1 + DN(2,2)*crLHS2; +const double crLHS18 = N[2]*bdf0; +const double crLHS19 = crLHS17 + crLHS18; +const double crLHS20 = w_gauss*(N[0]*crLHS17 + crLHS16 + crLHS19*crLHS8 + crLHS19*crLHS9); +const double crLHS21 = N[3]*crLHS4; +const double crLHS22 = DN(3,0)*crLHS0 + DN(3,1)*crLHS1 + DN(3,2)*crLHS2; +const double crLHS23 = N[3]*bdf0 + crLHS22; +const double crLHS24 = w_gauss*(N[0]*crLHS22 + crLHS21 + crLHS23*crLHS8 + crLHS23*crLHS9); +const double crLHS25 = N[1]*crLHS7; +const double crLHS26 = crLHS12*crLHS6; +const double crLHS27 = w_gauss*(N[1]*crLHS3 + crLHS11 + crLHS25*crLHS5 + crLHS26*crLHS5); +const double crLHS28 = w_gauss*(N[1]*crLHS12 + bdf0*(N[1]*N[1]) + crLHS14*crLHS25 + crLHS14*crLHS26); +const double crLHS29 = N[2]*crLHS13; +const double crLHS30 = w_gauss*(N[1]*crLHS17 + crLHS19*crLHS25 + crLHS19*crLHS26 + crLHS29); +const double crLHS31 = N[3]*crLHS13; +const double crLHS32 = w_gauss*(N[1]*crLHS22 + crLHS23*crLHS25 + crLHS23*crLHS26 + crLHS31); +const double crLHS33 = N[2]*crLHS7; +const double crLHS34 = crLHS17*crLHS6; +const double crLHS35 = w_gauss*(N[2]*crLHS3 + crLHS16 + crLHS33*crLHS5 + crLHS34*crLHS5); +const double crLHS36 = w_gauss*(N[2]*crLHS12 + crLHS14*crLHS33 + crLHS14*crLHS34 + crLHS29); +const double crLHS37 = w_gauss*(N[2]*crLHS17 + bdf0*(N[2]*N[2]) + crLHS19*crLHS33 + crLHS19*crLHS34); +const double crLHS38 = N[3]*crLHS18; +const double crLHS39 = w_gauss*(N[2]*crLHS22 + crLHS23*crLHS33 + crLHS23*crLHS34 + crLHS38); +const double crLHS40 = N[3]*crLHS7; +const double crLHS41 = crLHS22*crLHS6; +const double crLHS42 = w_gauss*(N[3]*crLHS3 + crLHS21 + crLHS40*crLHS5 + crLHS41*crLHS5); +const double crLHS43 = w_gauss*(N[3]*crLHS12 + crLHS14*crLHS40 + crLHS14*crLHS41 + crLHS31); +const double crLHS44 = w_gauss*(N[3]*crLHS17 + crLHS19*crLHS40 + crLHS19*crLHS41 + crLHS38); +const double crLHS45 = w_gauss*(N[3]*crLHS22 + bdf0*(N[3]*N[3]) + crLHS23*crLHS40 + crLHS23*crLHS41); +rLHS(0,0)+=crLHS10; +rLHS(0,1)+=0; +rLHS(0,2)+=0; +rLHS(0,3)+=crLHS15; +rLHS(0,4)+=0; +rLHS(0,5)+=0; +rLHS(0,6)+=crLHS20; +rLHS(0,7)+=0; +rLHS(0,8)+=0; +rLHS(0,9)+=crLHS24; +rLHS(0,10)+=0; +rLHS(0,11)+=0; +rLHS(1,0)+=0; +rLHS(1,1)+=crLHS10; +rLHS(1,2)+=0; +rLHS(1,3)+=0; +rLHS(1,4)+=crLHS15; +rLHS(1,5)+=0; +rLHS(1,6)+=0; +rLHS(1,7)+=crLHS20; +rLHS(1,8)+=0; +rLHS(1,9)+=0; +rLHS(1,10)+=crLHS24; +rLHS(1,11)+=0; +rLHS(2,0)+=0; +rLHS(2,1)+=0; +rLHS(2,2)+=crLHS10; +rLHS(2,3)+=0; +rLHS(2,4)+=0; +rLHS(2,5)+=crLHS15; +rLHS(2,6)+=0; +rLHS(2,7)+=0; +rLHS(2,8)+=crLHS20; +rLHS(2,9)+=0; +rLHS(2,10)+=0; +rLHS(2,11)+=crLHS24; +rLHS(3,0)+=crLHS27; +rLHS(3,1)+=0; +rLHS(3,2)+=0; +rLHS(3,3)+=crLHS28; +rLHS(3,4)+=0; +rLHS(3,5)+=0; +rLHS(3,6)+=crLHS30; +rLHS(3,7)+=0; +rLHS(3,8)+=0; +rLHS(3,9)+=crLHS32; +rLHS(3,10)+=0; +rLHS(3,11)+=0; +rLHS(4,0)+=0; +rLHS(4,1)+=crLHS27; +rLHS(4,2)+=0; +rLHS(4,3)+=0; +rLHS(4,4)+=crLHS28; +rLHS(4,5)+=0; +rLHS(4,6)+=0; +rLHS(4,7)+=crLHS30; +rLHS(4,8)+=0; +rLHS(4,9)+=0; +rLHS(4,10)+=crLHS32; +rLHS(4,11)+=0; +rLHS(5,0)+=0; +rLHS(5,1)+=0; +rLHS(5,2)+=crLHS27; +rLHS(5,3)+=0; +rLHS(5,4)+=0; +rLHS(5,5)+=crLHS28; +rLHS(5,6)+=0; +rLHS(5,7)+=0; +rLHS(5,8)+=crLHS30; +rLHS(5,9)+=0; +rLHS(5,10)+=0; +rLHS(5,11)+=crLHS32; +rLHS(6,0)+=crLHS35; +rLHS(6,1)+=0; +rLHS(6,2)+=0; +rLHS(6,3)+=crLHS36; +rLHS(6,4)+=0; +rLHS(6,5)+=0; +rLHS(6,6)+=crLHS37; +rLHS(6,7)+=0; +rLHS(6,8)+=0; +rLHS(6,9)+=crLHS39; +rLHS(6,10)+=0; +rLHS(6,11)+=0; +rLHS(7,0)+=0; +rLHS(7,1)+=crLHS35; +rLHS(7,2)+=0; +rLHS(7,3)+=0; +rLHS(7,4)+=crLHS36; +rLHS(7,5)+=0; +rLHS(7,6)+=0; +rLHS(7,7)+=crLHS37; +rLHS(7,8)+=0; +rLHS(7,9)+=0; +rLHS(7,10)+=crLHS39; +rLHS(7,11)+=0; +rLHS(8,0)+=0; +rLHS(8,1)+=0; +rLHS(8,2)+=crLHS35; +rLHS(8,3)+=0; +rLHS(8,4)+=0; +rLHS(8,5)+=crLHS36; +rLHS(8,6)+=0; +rLHS(8,7)+=0; +rLHS(8,8)+=crLHS37; +rLHS(8,9)+=0; +rLHS(8,10)+=0; +rLHS(8,11)+=crLHS39; +rLHS(9,0)+=crLHS42; +rLHS(9,1)+=0; +rLHS(9,2)+=0; +rLHS(9,3)+=crLHS43; +rLHS(9,4)+=0; +rLHS(9,5)+=0; +rLHS(9,6)+=crLHS44; +rLHS(9,7)+=0; +rLHS(9,8)+=0; +rLHS(9,9)+=crLHS45; +rLHS(9,10)+=0; +rLHS(9,11)+=0; +rLHS(10,0)+=0; +rLHS(10,1)+=crLHS42; +rLHS(10,2)+=0; +rLHS(10,3)+=0; +rLHS(10,4)+=crLHS43; +rLHS(10,5)+=0; +rLHS(10,6)+=0; +rLHS(10,7)+=crLHS44; +rLHS(10,8)+=0; +rLHS(10,9)+=0; +rLHS(10,10)+=crLHS45; +rLHS(10,11)+=0; +rLHS(11,0)+=0; +rLHS(11,1)+=0; +rLHS(11,2)+=crLHS42; +rLHS(11,3)+=0; +rLHS(11,4)+=0; +rLHS(11,5)+=crLHS43; +rLHS(11,6)+=0; +rLHS(11,7)+=0; +rLHS(11,8)+=crLHS44; +rLHS(11,9)+=0; +rLHS(11,10)+=0; +rLHS(11,11)+=crLHS45; + + + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template <> + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionData<2, 3> &rData, + VectorType &rRHS) + { + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double bdf1 = rData.bdf1; + const double bdf2 = rData.bdf2; + const double dyn_tau = rData.DynamicTau; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; + // const auto &vnnn = rData.Velocity_OldStep3; #an bdf2 + const auto &vmesh = rData.MeshVelocity; + const auto &vfrac = rData.FractionalVelocity; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Add RHS Gauss point contribution + const double w_gauss = rData.Weight; + + const double crRHS0 = N[0]*(vn(0,0) - vnn(0,0)); +const double crRHS1 = N[1]*(vn(1,0) - vnn(1,0)); +const double crRHS2 = N[2]*(vn(2,0) - vnn(2,0)); +const double crRHS3 = crRHS0 + crRHS1 + crRHS2; +const double crRHS4 = 1.0/dt; +const double crRHS5 = N[0]*crRHS4; +const double crRHS6 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)); +const double crRHS7 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0); +const double crRHS8 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1); +const double crRHS9 = crRHS7*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0)) + crRHS8*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0)); +const double crRHS10 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0); +const double crRHS11 = crRHS10*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0)); +const double crRHS12 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1); +const double crRHS13 = crRHS12*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0)); +const double crRHS14 = crRHS11 + crRHS13; +const double crRHS15 = -crRHS0*crRHS4 - crRHS1*crRHS4 - crRHS11 - crRHS13 - crRHS2*crRHS4 + crRHS6 + crRHS9; +const double crRHS16 = 1.0*1.0/(crRHS4*dyn_tau + stab_c2*1.0/h*sqrt(crRHS7*crRHS7 + crRHS8*crRHS8)); +const double crRHS17 = crRHS16*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1)); +const double crRHS18 = N[0]*crRHS17; +const double crRHS19 = crRHS16*(DN(0,0)*crRHS7 + DN(0,1)*crRHS8); +const double crRHS20 = N[0]*(vn(0,1) - vnn(0,1)); +const double crRHS21 = N[1]*(vn(1,1) - vnn(1,1)); +const double crRHS22 = N[2]*(vn(2,1) - vnn(2,1)); +const double crRHS23 = crRHS20 + crRHS21 + crRHS22; +const double crRHS24 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)); +const double crRHS25 = crRHS7*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1)) + crRHS8*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1)); +const double crRHS26 = crRHS10*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1)); +const double crRHS27 = crRHS12*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1)); +const double crRHS28 = crRHS26 + crRHS27; +const double crRHS29 = -crRHS20*crRHS4 - crRHS21*crRHS4 - crRHS22*crRHS4 + crRHS24 + crRHS25 - crRHS26 - crRHS27; +const double crRHS30 = N[1]*crRHS4; +const double crRHS31 = N[1]*crRHS17; +const double crRHS32 = crRHS16*(DN(1,0)*crRHS7 + DN(1,1)*crRHS8); +const double crRHS33 = N[2]*crRHS4; +const double crRHS34 = N[2]*crRHS17; +const double crRHS35 = crRHS16*(DN(2,0)*crRHS7 + DN(2,1)*crRHS8); +rRHS[0]+=-w_gauss*(-N[0]*crRHS14 + N[0]*crRHS6 + N[0]*crRHS9 + crRHS15*crRHS18 + crRHS15*crRHS19 - crRHS3*crRHS5); +rRHS[1]+=-w_gauss*(N[0]*crRHS24 + N[0]*crRHS25 - N[0]*crRHS28 + crRHS18*crRHS29 + crRHS19*crRHS29 - crRHS23*crRHS5); +rRHS[2]+=-w_gauss*(-N[1]*crRHS14 + N[1]*crRHS6 + N[1]*crRHS9 + crRHS15*crRHS31 + crRHS15*crRHS32 - crRHS3*crRHS30); +rRHS[3]+=-w_gauss*(N[1]*crRHS24 + N[1]*crRHS25 - N[1]*crRHS28 - crRHS23*crRHS30 + crRHS29*crRHS31 + crRHS29*crRHS32); +rRHS[4]+=-w_gauss*(-N[2]*crRHS14 + N[2]*crRHS6 + N[2]*crRHS9 + crRHS15*crRHS34 + crRHS15*crRHS35 - crRHS3*crRHS33); +rRHS[5]+=-w_gauss*(N[2]*crRHS24 + N[2]*crRHS25 - N[2]*crRHS28 - crRHS23*crRHS33 + crRHS29*crRHS34 + crRHS29*crRHS35); + + + } + + /***********************************************************************************/ + /***********************************************************************************/ + template <> + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionData<3, 4> &rData, + VectorType &rRHS) + { + + + const double h = rData.ElementSize; + const double dt = rData.DeltaTime; + const double bdf0 = rData.bdf0; + const double bdf1 = rData.bdf1; + const double bdf2 = rData.bdf2; + const double dyn_tau = rData.DynamicTau; + const auto &vn = rData.VelocityOldStep1; + const auto &vnn = rData.VelocityOldStep2; + const auto &vmesh = rData.MeshVelocity; + const auto &vfrac = rData.FractionalVelocity; + const auto &vconv = vfrac - vmesh; + + // Get shape function values + const auto &N = rData.N; + const auto &DN = rData.DN_DX; + + // Add RHS Gauss point contribution + const double w_gauss =rData.Weight; + + const double crRHS0 = N[0]*(vn(0,0) - vnn(0,0)); +const double crRHS1 = N[1]*(vn(1,0) - vnn(1,0)); +const double crRHS2 = N[2]*(vn(2,0) - vnn(2,0)); +const double crRHS3 = N[3]*(vn(3,0) - vnn(3,0)); +const double crRHS4 = crRHS0 + crRHS1 + crRHS2 + crRHS3; +const double crRHS5 = 1.0/dt; +const double crRHS6 = N[0]*crRHS5; +const double crRHS7 = N[0]*(bdf0*vfrac(0,0) + bdf1*vn(0,0) + bdf2*vnn(0,0)) + N[1]*(bdf0*vfrac(1,0) + bdf1*vn(1,0) + bdf2*vnn(1,0)) + N[2]*(bdf0*vfrac(2,0) + bdf1*vn(2,0) + bdf2*vnn(2,0)) + N[3]*(bdf0*vfrac(3,0) + bdf1*vn(3,0) + bdf2*vnn(3,0)); +const double crRHS8 = N[0]*vconv(0,0) + N[1]*vconv(1,0) + N[2]*vconv(2,0) + N[3]*vconv(3,0); +const double crRHS9 = N[0]*vconv(0,1) + N[1]*vconv(1,1) + N[2]*vconv(2,1) + N[3]*vconv(3,1); +const double crRHS10 = N[0]*vconv(0,2) + N[1]*vconv(1,2) + N[2]*vconv(2,2) + N[3]*vconv(3,2); +const double crRHS11 = crRHS10*(DN(0,2)*vfrac(0,0) + DN(1,2)*vfrac(1,0) + DN(2,2)*vfrac(2,0) + DN(3,2)*vfrac(3,0)) + crRHS8*(DN(0,0)*vfrac(0,0) + DN(1,0)*vfrac(1,0) + DN(2,0)*vfrac(2,0) + DN(3,0)*vfrac(3,0)) + crRHS9*(DN(0,1)*vfrac(0,0) + DN(1,1)*vfrac(1,0) + DN(2,1)*vfrac(2,0) + DN(3,1)*vfrac(3,0)); +const double crRHS12 = N[0]*vn(0,0) + N[1]*vn(1,0) + N[2]*vn(2,0) + N[3]*vn(3,0); +const double crRHS13 = crRHS12*(DN(0,0)*vn(0,0) + DN(1,0)*vn(1,0) + DN(2,0)*vn(2,0) + DN(3,0)*vn(3,0)); +const double crRHS14 = N[0]*vn(0,1) + N[1]*vn(1,1) + N[2]*vn(2,1) + N[3]*vn(3,1); +const double crRHS15 = crRHS14*(DN(0,1)*vn(0,0) + DN(1,1)*vn(1,0) + DN(2,1)*vn(2,0) + DN(3,1)*vn(3,0)); +const double crRHS16 = N[0]*vn(0,2) + N[1]*vn(1,2) + N[2]*vn(2,2) + N[3]*vn(3,2); +const double crRHS17 = crRHS16*(DN(0,2)*vn(0,0) + DN(1,2)*vn(1,0) + DN(2,2)*vn(2,0) + DN(3,2)*vn(3,0)); +const double crRHS18 = crRHS13 + crRHS15 + crRHS17; +const double crRHS19 = -crRHS0*crRHS5 - crRHS1*crRHS5 + crRHS11 - crRHS13 - crRHS15 - crRHS17 - crRHS2*crRHS5 - crRHS3*crRHS5 + crRHS7; +const double crRHS20 = 1.0*1.0/(crRHS5*dyn_tau + stab_c2*1.0/h*sqrt(crRHS10*crRHS10 + crRHS8*crRHS8 + crRHS9*crRHS9)); +const double crRHS21 = crRHS20*(DN(0,0)*vconv(0,0) + DN(0,1)*vconv(0,1) + DN(0,2)*vconv(0,2) + DN(1,0)*vconv(1,0) + DN(1,1)*vconv(1,1) + DN(1,2)*vconv(1,2) + DN(2,0)*vconv(2,0) + DN(2,1)*vconv(2,1) + DN(2,2)*vconv(2,2) + DN(3,0)*vconv(3,0) + DN(3,1)*vconv(3,1) + DN(3,2)*vconv(3,2)); +const double crRHS22 = N[0]*crRHS21; +const double crRHS23 = crRHS20*(DN(0,0)*crRHS8 + DN(0,1)*crRHS9 + DN(0,2)*crRHS10); +const double crRHS24 = N[0]*(vn(0,1) - vnn(0,1)); +const double crRHS25 = N[1]*(vn(1,1) - vnn(1,1)); +const double crRHS26 = N[2]*(vn(2,1) - vnn(2,1)); +const double crRHS27 = N[3]*(vn(3,1) - vnn(3,1)); +const double crRHS28 = crRHS24 + crRHS25 + crRHS26 + crRHS27; +const double crRHS29 = N[0]*(bdf0*vfrac(0,1) + bdf1*vn(0,1) + bdf2*vnn(0,1)) + N[1]*(bdf0*vfrac(1,1) + bdf1*vn(1,1) + bdf2*vnn(1,1)) + N[2]*(bdf0*vfrac(2,1) + bdf1*vn(2,1) + bdf2*vnn(2,1)) + N[3]*(bdf0*vfrac(3,1) + bdf1*vn(3,1) + bdf2*vnn(3,1)); +const double crRHS30 = crRHS10*(DN(0,2)*vfrac(0,1) + DN(1,2)*vfrac(1,1) + DN(2,2)*vfrac(2,1) + DN(3,2)*vfrac(3,1)) + crRHS8*(DN(0,0)*vfrac(0,1) + DN(1,0)*vfrac(1,1) + DN(2,0)*vfrac(2,1) + DN(3,0)*vfrac(3,1)) + crRHS9*(DN(0,1)*vfrac(0,1) + DN(1,1)*vfrac(1,1) + DN(2,1)*vfrac(2,1) + DN(3,1)*vfrac(3,1)); +const double crRHS31 = crRHS12*(DN(0,0)*vn(0,1) + DN(1,0)*vn(1,1) + DN(2,0)*vn(2,1) + DN(3,0)*vn(3,1)); +const double crRHS32 = crRHS14*(DN(0,1)*vn(0,1) + DN(1,1)*vn(1,1) + DN(2,1)*vn(2,1) + DN(3,1)*vn(3,1)); +const double crRHS33 = crRHS16*(DN(0,2)*vn(0,1) + DN(1,2)*vn(1,1) + DN(2,2)*vn(2,1) + DN(3,2)*vn(3,1)); +const double crRHS34 = crRHS31 + crRHS32 + crRHS33; +const double crRHS35 = -crRHS24*crRHS5 - crRHS25*crRHS5 - crRHS26*crRHS5 - crRHS27*crRHS5 + crRHS29 + crRHS30 - crRHS31 - crRHS32 - crRHS33; +const double crRHS36 = N[0]*(vn(0,2) - vnn(0,2)); +const double crRHS37 = N[1]*(vn(1,2) - vnn(1,2)); +const double crRHS38 = N[2]*(vn(2,2) - vnn(2,2)); +const double crRHS39 = N[3]*(vn(3,2) - vnn(3,2)); +const double crRHS40 = crRHS36 + crRHS37 + crRHS38 + crRHS39; +const double crRHS41 = N[0]*(bdf0*vfrac(0,2) + bdf1*vn(0,2) + bdf2*vnn(0,2)) + N[1]*(bdf0*vfrac(1,2) + bdf1*vn(1,2) + bdf2*vnn(1,2)) + N[2]*(bdf0*vfrac(2,2) + bdf1*vn(2,2) + bdf2*vnn(2,2)) + N[3]*(bdf0*vfrac(3,2) + bdf1*vn(3,2) + bdf2*vnn(3,2)); +const double crRHS42 = crRHS10*(DN(0,2)*vfrac(0,2) + DN(1,2)*vfrac(1,2) + DN(2,2)*vfrac(2,2) + DN(3,2)*vfrac(3,2)) + crRHS8*(DN(0,0)*vfrac(0,2) + DN(1,0)*vfrac(1,2) + DN(2,0)*vfrac(2,2) + DN(3,0)*vfrac(3,2)) + crRHS9*(DN(0,1)*vfrac(0,2) + DN(1,1)*vfrac(1,2) + DN(2,1)*vfrac(2,2) + DN(3,1)*vfrac(3,2)); +const double crRHS43 = crRHS12*(DN(0,0)*vn(0,2) + DN(1,0)*vn(1,2) + DN(2,0)*vn(2,2) + DN(3,0)*vn(3,2)); +const double crRHS44 = crRHS14*(DN(0,1)*vn(0,2) + DN(1,1)*vn(1,2) + DN(2,1)*vn(2,2) + DN(3,1)*vn(3,2)); +const double crRHS45 = crRHS16*(DN(0,2)*vn(0,2) + DN(1,2)*vn(1,2) + DN(2,2)*vn(2,2) + DN(3,2)*vn(3,2)); +const double crRHS46 = crRHS43 + crRHS44 + crRHS45; +const double crRHS47 = -crRHS36*crRHS5 - crRHS37*crRHS5 - crRHS38*crRHS5 - crRHS39*crRHS5 + crRHS41 + crRHS42 - crRHS43 - crRHS44 - crRHS45; +const double crRHS48 = N[1]*crRHS5; +const double crRHS49 = N[1]*crRHS21; +const double crRHS50 = crRHS20*(DN(1,0)*crRHS8 + DN(1,1)*crRHS9 + DN(1,2)*crRHS10); +const double crRHS51 = N[2]*crRHS5; +const double crRHS52 = N[2]*crRHS21; +const double crRHS53 = crRHS20*(DN(2,0)*crRHS8 + DN(2,1)*crRHS9 + DN(2,2)*crRHS10); +const double crRHS54 = N[3]*crRHS5; +const double crRHS55 = N[3]*crRHS21; +const double crRHS56 = crRHS20*(DN(3,0)*crRHS8 + DN(3,1)*crRHS9 + DN(3,2)*crRHS10); +rRHS[0]+=-w_gauss*(N[0]*crRHS11 - N[0]*crRHS18 + N[0]*crRHS7 + crRHS19*crRHS22 + crRHS19*crRHS23 - crRHS4*crRHS6); +rRHS[1]+=-w_gauss*(N[0]*crRHS29 + N[0]*crRHS30 - N[0]*crRHS34 + crRHS22*crRHS35 + crRHS23*crRHS35 - crRHS28*crRHS6); +rRHS[2]+=-w_gauss*(N[0]*crRHS41 + N[0]*crRHS42 - N[0]*crRHS46 + crRHS22*crRHS47 + crRHS23*crRHS47 - crRHS40*crRHS6); +rRHS[3]+=-w_gauss*(N[1]*crRHS11 - N[1]*crRHS18 + N[1]*crRHS7 + crRHS19*crRHS49 + crRHS19*crRHS50 - crRHS4*crRHS48); +rRHS[4]+=-w_gauss*(N[1]*crRHS29 + N[1]*crRHS30 - N[1]*crRHS34 - crRHS28*crRHS48 + crRHS35*crRHS49 + crRHS35*crRHS50); +rRHS[5]+=-w_gauss*(N[1]*crRHS41 + N[1]*crRHS42 - N[1]*crRHS46 - crRHS40*crRHS48 + crRHS47*crRHS49 + crRHS47*crRHS50); +rRHS[6]+=-w_gauss*(N[2]*crRHS11 - N[2]*crRHS18 + N[2]*crRHS7 + crRHS19*crRHS52 + crRHS19*crRHS53 - crRHS4*crRHS51); +rRHS[7]+=-w_gauss*(N[2]*crRHS29 + N[2]*crRHS30 - N[2]*crRHS34 - crRHS28*crRHS51 + crRHS35*crRHS52 + crRHS35*crRHS53); +rRHS[8]+=-w_gauss*(N[2]*crRHS41 + N[2]*crRHS42 - N[2]*crRHS46 - crRHS40*crRHS51 + crRHS47*crRHS52 + crRHS47*crRHS53); +rRHS[9]+=-w_gauss*(N[3]*crRHS11 - N[3]*crRHS18 + N[3]*crRHS7 + crRHS19*crRHS55 + crRHS19*crRHS56 - crRHS4*crRHS54); +rRHS[10]+=-w_gauss*(N[3]*crRHS29 + N[3]*crRHS30 - N[3]*crRHS34 - crRHS28*crRHS54 + crRHS35*crRHS55 + crRHS35*crRHS56); +rRHS[11]+=-w_gauss*(N[3]*crRHS41 + N[3]*crRHS42 - N[3]*crRHS46 - crRHS40*crRHS54 + crRHS47*crRHS55 + crRHS47*crRHS56); + + + } + + /***********************************************************************************/ + /***********************************************************************************/ + template + void TwoFluidNavierStokesFractionalConvection::EquationIdVector( + EquationIdVectorType &rResult, + const ProcessInfo &rCurrentProcessInfo) const + { + const GeometryType &r_geometry = this->GetGeometry(); + + unsigned int LocalIndex = 0; + + if (rResult.size() != LocalSize) + rResult.resize(LocalSize, false); + + const unsigned int xpos = this->GetGeometry()[0].GetDofPosition(FRACTIONAL_VELOCITY_X); + + for (unsigned int i = 0; i < NumNodes; ++i) + { + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_X, xpos).EquationId(); + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Y, xpos + 1).EquationId(); + if constexpr (Dim == 3) + rResult[LocalIndex++] = r_geometry[i].GetDof(FRACTIONAL_VELOCITY_Z, xpos + 2).EquationId(); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + + template + void TwoFluidNavierStokesFractionalConvection::GetDofList( + DofsVectorType &rElementalDofList, + const ProcessInfo &rCurrentProcessInfo) const + { + const GeometryType &r_geometry = this->GetGeometry(); + + if (rElementalDofList.size() != LocalSize) + rElementalDofList.resize(LocalSize); + + const unsigned int xpos = this->GetGeometry()[0].GetDofPosition(FRACTIONAL_VELOCITY_X); + + unsigned int LocalIndex = 0; + for (unsigned int i = 0; i < NumNodes; ++i) + { + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_X, xpos); + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Y, xpos + 1); + if constexpr (Dim == 3) + rElementalDofList[LocalIndex++] = r_geometry[i].pGetDof(FRACTIONAL_VELOCITY_Z, xpos + 2); + } + } + + /***********************************************************************************/ + /***********************************************************************************/ + + /***********************************************************************************/ + /***********************************************************************************/ + template class TwoFluidNavierStokesFractionalConvection>; + template class TwoFluidNavierStokesFractionalConvection>; + + /***********************************************************************************/ + /***********************************************************************************/ +} \ No newline at end of file diff --git a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp index 99535f8acd22..d9290db99c8f 100644 --- a/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp +++ b/applications/FluidDynamicsApplication/symbolic_generation/two_fluid_navier_stokes_fractional/two_fluid_navier_stokes_fractional_convection_template.cpp @@ -10,7 +10,7 @@ // Main author: Uxue Chasco // -#include "two_fluid_navier_stokes_fractional_convection_element.h" +#include "two_fluid_navier_stokes_fractional_convection.h" namespace Kratos { @@ -19,27 +19,27 @@ namespace Kratos /***********************************************************************************/ template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId) : Element(NewId) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId) : Element(NewId) { } template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, const NodesArrayType &ThisNodes) : Element(NewId, ThisNodes) { } template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry) { } template - TwoFluidNavierStokesFractionalConvectionElement::TwoFluidNavierStokesFractionalConvectionElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) + TwoFluidNavierStokesFractionalConvection::TwoFluidNavierStokesFractionalConvection(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties) { } template - TwoFluidNavierStokesFractionalConvectionElement::~TwoFluidNavierStokesFractionalConvectionElement() + TwoFluidNavierStokesFractionalConvection::~TwoFluidNavierStokesFractionalConvection() { } @@ -47,35 +47,35 @@ namespace Kratos /***********************************************************************************/ template - Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvection::Create( IndexType NewId, NodesArrayType const &ThisNodes, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); + return Kratos::make_intrusive(NewId, this->GetGeometry().Create(ThisNodes), pProperties); } /***********************************************************************************/ template - Element::Pointer TwoFluidNavierStokesFractionalConvectionElement::Create( + Element::Pointer TwoFluidNavierStokesFractionalConvection::Create( IndexType NewId, GeometryType::Pointer pGeom, Properties::Pointer pProperties) const { - return Kratos::make_intrusive(NewId, pGeom, pProperties); + return Kratos::make_intrusive(NewId, pGeom, pProperties); } /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) + void TwoFluidNavierStokesFractionalConvection::CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) { KRATOS_THROW_ERROR(std::runtime_error, "CalculateRightHandSide not implemented", ""); } template - void TwoFluidNavierStokesFractionalConvectionElement::CalculateLocalSystem( + void TwoFluidNavierStokesFractionalConvection::CalculateLocalSystem( MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) @@ -111,7 +111,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::UpdateIntegrationPointData( + void TwoFluidNavierStokesFractionalConvection::UpdateIntegrationPointData( TElementData &rData, unsigned int IntegrationPointIndex, double Weight, @@ -125,7 +125,7 @@ namespace Kratos /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::AddTimeIntegratedSystem( + void TwoFluidNavierStokesFractionalConvection::AddTimeIntegratedSystem( TElementData &rData, MatrixType &rLHS, VectorType &rRHS) @@ -137,7 +137,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::CalculateGeometryData(Vector &rGaussWeights, + void TwoFluidNavierStokesFractionalConvection::CalculateGeometryData(Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionDerivativesArrayType &rDN_DX) const { @@ -168,8 +168,8 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionData<2, 3> &rData, MatrixType &rLHS) { @@ -195,8 +195,8 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointLHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointLHSContribution( + TwoFluidNavierStokesFractionalConvectionData<3, 4> &rData, MatrixType &rLHS) { @@ -225,8 +225,8 @@ namespace Kratos /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<2, 3> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionData<2, 3> &rData, VectorType &rRHS) { @@ -257,8 +257,8 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template <> - void TwoFluidNavierStokesFractionalConvectionElement>::ComputeGaussPointRHSContribution( - TwoFluidNavierStokesFractionalConvectionElementData<3, 4> &rData, + void TwoFluidNavierStokesFractionalConvection>::ComputeGaussPointRHSContribution( + TwoFluidNavierStokesFractionalConvectionData<3, 4> &rData, VectorType &rRHS) { @@ -289,7 +289,7 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::EquationIdVector( + void TwoFluidNavierStokesFractionalConvection::EquationIdVector( EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const { @@ -315,7 +315,7 @@ namespace Kratos /***********************************************************************************/ template - void TwoFluidNavierStokesFractionalConvectionElement::GetDofList( + void TwoFluidNavierStokesFractionalConvection::GetDofList( DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const { @@ -341,8 +341,8 @@ namespace Kratos /***********************************************************************************/ /***********************************************************************************/ - template class TwoFluidNavierStokesFractionalConvectionElement>; - template class TwoFluidNavierStokesFractionalConvectionElement>; + template class TwoFluidNavierStokesFractionalConvection>; + template class TwoFluidNavierStokesFractionalConvection>; /***********************************************************************************/ /***********************************************************************************/ diff --git a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp index 616cb425c332..1d01a55271ce 100644 --- a/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp +++ b/applications/FluidDynamicsApplication/tests/cpp_tests/test_vectorial_convection_fractional_element.cpp @@ -26,7 +26,7 @@ #include "utilities/normal_calculation_utils.h" // Application includes -#include "custom_elements/two_fluid_navier_stokes_fractional_convection_element.h" +#include "custom_elements/two_fluid_navier_stokes_fractional_convection.h" #include "processes/find_nodal_neighbours_process.h" #include "tests/cpp_tests/fluid_dynamics_fast_suite.h" @@ -76,7 +76,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional2D3N, FluidDynamic modelPart.CreateNewNode(2, 1.0, 0.0, 0.0); modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); std::vector elemNodes {1, 2, 3}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractionalConvectionElement2D3N", 1, elemNodes, pElemProp); + modelPart.CreateNewElement("TwoFluidNavierStokesFractionalConvection2D3N", 1, elemNodes, pElemProp); Element::Pointer pElement = modelPart.pGetElement(1); @@ -155,7 +155,7 @@ KRATOS_TEST_CASE_IN_SUITE(ElementVectorialConvectionFractional3D4N, FluidDynamic modelPart.CreateNewNode(3, 0.0, 1.0, 0.0); modelPart.CreateNewNode(4, 0.0, 0.0, 1.0); std::vector elemNodes {1, 2, 3, 4}; - modelPart.CreateNewElement("TwoFluidNavierStokesFractionalConvectionElement3D4N", 1, elemNodes, pElemProp); + modelPart.CreateNewElement("TwoFluidNavierStokesFractionalConvection3D4N", 1, elemNodes, pElemProp); Element::Pointer pElement = modelPart.pGetElement(1);