48 template <
unsigned int TDim,
unsigned int TNumNodes>
135 const Matrix& rdNdX)
const;
143 void static AddViscousTerms(
159 template<
class TDerivativesType>
202 const double WDerivative,
203 const double DetJDerivative,
204 const Matrix& rdNdXDerivative,
205 const double MassTermsDerivativesWeight = 1.0)
const
207 rResidualDerivative.
clear();
209 constexpr
double u_factor = TDerivativesType::VelocityDerivativeFactor;
210 constexpr
double p_factor = TDerivativesType::PressureDerivativeFactor;
212 const auto& r_geometry = rData.mpElement->
GetGeometry();
214 const TDerivativesType derivatives_type(
215 NodeIndex, r_geometry, W, rN, rdNdX,
216 WDerivative, DetJDerivative, rdNdXDerivative);
218 const auto& velocity_derivative = derivatives_type.CalculateEffectiveVelocityDerivative(rData.mVelocity);
219 const auto& element_length_derivative = derivatives_type.CalculateElementLengthDerivative(rData.mElementSize);
220 derivatives_type.CalculateStrainRateDerivative(rData.mStrainRateDerivative, rData.mNodalVelocity);
223 double effective_viscosity_derivative;
228 rData.mpConstitutiveLaw->
CalculateDerivative(rData.mConstitutiveLawValues, EFFECTIVE_VISCOSITY, derivatives_type.GetDerivativeVariable(), effective_viscosity_derivative);
229 effective_viscosity_derivative *= rN[NodeIndex];
234 double effective_viscosity_derivative_value;
235 ArrayD derivative_variable_gradient;
236 const auto& r_effective_viscosity_dependent_variables = derivatives_type.GetEffectiveViscosityDependentVariables();
237 for (
const auto& r_effective_viscosity_dependent_variable : r_effective_viscosity_dependent_variables) {
239 const auto& r_derivative_variable = std::get<0>(r_effective_viscosity_dependent_variable);
243 const auto& r_effective_viscosity_dependent_variable_gradient_component_list = std::get<1>(r_effective_viscosity_dependent_variable);
245 rData.mpConstitutiveLaw->
CalculateDerivative(rData.mConstitutiveLawValues, EFFECTIVE_VISCOSITY, *r_effective_viscosity_dependent_variable_gradient_component_list[
i], effective_viscosity_derivative_value);
246 effective_viscosity_derivative += effective_viscosity_derivative_value * (rdNdX(NodeIndex,
i) * (r_derivative_variable == derivatives_type.GetDerivativeVariable()));
247 effective_viscosity_derivative += effective_viscosity_derivative_value * (derivative_variable_gradient[
i]);
252 rData.mConvectiveVelocityNorm, rData.mConvectiveVelocity, velocity_derivative);
254 double tau_one_derivative, tau_two_derivative;
256 tau_one_derivative, tau_two_derivative, rData.mTauOne,
257 rData.mDensity, rData.mDynamicTau, rData.mDeltaTime,
258 rData.mElementSize, element_length_derivative,
259 rData.mEffectiveViscosity, effective_viscosity_derivative,
260 rData.mConvectiveVelocityNorm, velocity_norm_derivative);
262 ArrayD pressure_gradient_derivative;
265 r_geometry, rdNdXDerivative,
266 std::tie(pressure_gradient_derivative, PRESSURE),
267 std::tie(velocity_gradient_derivative, VELOCITY));
269 pressure_gradient_derivative[
l] += rdNdX(NodeIndex,
l) * p_factor;
273 double velocity_dot_nabla_derivative = 0.0;
276 velocity_dot_nabla_derivative += rData.mNodalVelocity(
a,
i) * rdNdXDerivative(
a,
i);
280 const ArrayD effective_velocity_derivative_dot_velocity_gradient =
prod(rData.mVelocityGradient, velocity_derivative);
281 const ArrayD effective_velocity_dot_velocity_gradient_derivative =
prod(velocity_gradient_derivative, rData.mConvectiveVelocity);
282 const VectorN convective_velocity_derivative_dot_dn_dx =
prod(rdNdX, velocity_derivative);
283 const VectorN relaxed_acceleration_dot_dn_dx_derivative =
prod(rdNdXDerivative, rData.mRelaxedAcceleration);
284 const VectorN convective_velocity_dot_dn_dx_derivative =
prod(rdNdXDerivative, rData.mConvectiveVelocity);
285 const VectorN effective_velocity_derivative_dot_velocity_gradient_dot_shape_gradient =
prod(rdNdX, effective_velocity_derivative_dot_velocity_gradient);
286 const VectorN effective_velocity_dot_velocity_gradient_derivative_dot_shape_gradient =
prod(rdNdX, effective_velocity_dot_velocity_gradient_derivative);
287 const VectorN effective_velocity_dot_velocity_gradient_dot_shape_gradient_derivative =
prod(rdNdXDerivative, rData.mEffectiveVelocityDotVelocityGradient);
288 const VectorN pressure_gradient_derivative_dot_shape_gradient =
prod(rdNdX, pressure_gradient_derivative);
289 const VectorN pressure_gradient_dot_shape_gradient_derivative =
prod(rdNdXDerivative, rData.mPressureGradient);
293 const double mass_projection_derivative = 0.0;
298 double forcing_derivative = 0.0;
304 value += rData.mDensity * W * tau_one_derivative * rData.mConvectiveVelocityDotDnDx[
a] * rData.mBodyForce[
i];
305 value += rData.mDensity * W * rData.mTauOne * convective_velocity_derivative_dot_dn_dx[
a] * rData.mBodyForce[
i];
306 value += rData.mDensity * W * rData.mTauOne * convective_velocity_dot_dn_dx_derivative[
a] * rData.mBodyForce[
i];
308 value -= rData.mDensity * W * tau_one_derivative * rData.mConvectiveVelocityDotDnDx[
a] * rData.mMomentumProjection[
i];
309 value -= rData.mDensity * W * rData.mTauOne * convective_velocity_derivative_dot_dn_dx[
a] * rData.mMomentumProjection[
i];
310 value -= rData.mDensity * W * rData.mTauOne * convective_velocity_dot_dn_dx_derivative[
a] * rData.mMomentumProjection[
i];
311 value -= rData.mDensity * W * rData.mTauOne * rData.mConvectiveVelocityDotDnDx[
a] * momentum_projection_derivative[
i];
313 value -= W * tau_two_derivative * rdNdX(
a,
i) * rData.mMassProjection;
314 value -= W * rData.mTauTwo * rdNdXDerivative(
a,
i) * rData.mMassProjection;
315 value -= W * rData.mTauTwo * rdNdX(
a,
i) * mass_projection_derivative;
317 forcing_derivative += rdNdXDerivative(
a,
i) * rData.mBodyForce[
i];
318 forcing_derivative -= rdNdXDerivative(
a,
i) * rData.mMomentumProjection[
i];
319 forcing_derivative -= rdNdX(
a,
i) * momentum_projection_derivative[
i];
322 value -= W * rData.mDensity * rN[
a] * effective_velocity_derivative_dot_velocity_gradient[
i];
323 value -= W * rData.mDensity * rN[
a] * effective_velocity_dot_velocity_gradient_derivative[
i];
325 value -= W * rData.mDensity * convective_velocity_derivative_dot_dn_dx[
a] * rData.mTauOne * rData.mDensity * rData.mEffectiveVelocityDotVelocityGradient[
i];
326 value -= W * rData.mDensity * convective_velocity_dot_dn_dx_derivative[
a] * rData.mTauOne * rData.mDensity * rData.mEffectiveVelocityDotVelocityGradient[
i];
327 value -= W * rData.mDensity * rData.mConvectiveVelocityDotDnDx[
a] * tau_one_derivative * rData.mDensity * rData.mEffectiveVelocityDotVelocityGradient[
i];
328 value -= W * rData.mDensity * rData.mConvectiveVelocityDotDnDx[
a] * rData.mTauOne * rData.mDensity * effective_velocity_derivative_dot_velocity_gradient[
i];
329 value -= W * rData.mDensity * rData.mConvectiveVelocityDotDnDx[
a] * rData.mTauOne * rData.mDensity * effective_velocity_dot_velocity_gradient_derivative[
i];
331 value -= W * tau_one_derivative * rData.mDensity * rData.mConvectiveVelocityDotDnDx[
a] * rData.mPressureGradient[
i];
332 value -= W * rData.mTauOne * rData.mDensity * convective_velocity_derivative_dot_dn_dx[
a] * rData.mPressureGradient[
i];
333 value -= W * rData.mTauOne * rData.mDensity * convective_velocity_dot_dn_dx_derivative[
a] * rData.mPressureGradient[
i];
334 value -= W * rData.mTauOne * rData.mDensity * rData.mConvectiveVelocityDotDnDx[
a] * pressure_gradient_derivative[
i];
336 value += W * rdNdXDerivative(
a,
i) * rData.mPressure;
337 value += W * rdNdX(
a,
i) * rN[NodeIndex] * p_factor;
339 value -= W * tau_two_derivative * rdNdX(
a,
i) * rData.mVelocityDotNabla;
340 value -= W * rData.mTauTwo * rdNdXDerivative(
a,
i) * rData.mVelocityDotNabla;
341 value -= W * rData.mTauTwo * rdNdX(
a,
i) * velocity_dot_nabla_derivative;
342 value -= W * rData.mTauTwo * rdNdX(
a,
i) * rdNdX(NodeIndex,
ComponentIndex) * u_factor;
346 value -= W * tau_one_derivative * rData.mDensity * rData.mDensity * rData.mConvectiveVelocityDotDnDx[
a] * rData.mRelaxedAcceleration[
i] * MassTermsDerivativesWeight;
347 value -= W * rData.mTauOne * rData.mDensity * rData.mDensity * convective_velocity_derivative_dot_dn_dx[
a] * rData.mRelaxedAcceleration[
i] * MassTermsDerivativesWeight;
348 value -= W * rData.mTauOne * rData.mDensity * rData.mDensity * convective_velocity_dot_dn_dx_derivative[
a] * rData.mRelaxedAcceleration[
i] * MassTermsDerivativesWeight;
350 rResidualDerivative[
row +
i] += value;
355 const double forcing = rData.mBodyForceDotDnDx[
a] - rData.mMomentumProjectionDotDnDx[
a];
356 value += W * tau_one_derivative * forcing;
357 value += W * rData.mTauOne * forcing_derivative;
359 value -= W * tau_one_derivative * rData.mDensity * rData.mEffectiveVelocityDotVelocityGradientDotShapeGradient[
a];
360 value -= W * rData.mTauOne * rData.mDensity * effective_velocity_derivative_dot_velocity_gradient_dot_shape_gradient[
a];
361 value -= W * rData.mTauOne * rData.mDensity * effective_velocity_dot_velocity_gradient_derivative_dot_shape_gradient[
a];
362 value -= W * rData.mTauOne * rData.mDensity * effective_velocity_dot_velocity_gradient_dot_shape_gradient_derivative[
a];
364 value -= W * rN[
a] * velocity_dot_nabla_derivative;
367 value -= W * tau_one_derivative * rData.mPressureGradientDotDnDx[
a];
368 value -= W * rData.mTauOne * pressure_gradient_derivative_dot_shape_gradient[
a];
369 value -= W * rData.mTauOne * pressure_gradient_dot_shape_gradient_derivative[
a];
372 value -= W * tau_one_derivative * rData.mDensity * rData.mRelaxedAccelerationDotDnDx[
a] * MassTermsDerivativesWeight;
373 value -= W * rData.mTauOne * rData.mDensity * relaxed_acceleration_dot_dn_dx_derivative[
a] * MassTermsDerivativesWeight;
375 rResidualDerivative[
row + TDim] += value;
379 rResidualDerivative, rData, WDerivative, rN, rdNdX);
384 rData.mShearStressDerivative.
clear();
388 rData.mpConstitutiveLaw->
CalculateDerivative(rData.mConstitutiveLawValues, CAUCHY_STRESS_VECTOR, *r_strain_rate_variables[
i], value);
389 noalias(rData.mShearStressDerivative) += value * rData.mStrainRateDerivative[
i];
392 rData.mpConstitutiveLaw->
CalculateDerivative(rData.mConstitutiveLawValues, CAUCHY_STRESS_VECTOR, EFFECTIVE_VISCOSITY, value);
393 noalias(rData.mShearStressDerivative) += value * effective_viscosity_derivative;
395 AddViscousDerivative(rData, rResidualDerivative, NodeIndex,
396 W, rN, rdNdX, WDerivative,
397 DetJDerivative, rdNdXDerivative);
425 void static AddViscousDerivative(
432 const double WDerivative,
433 const double DetJDerivative,
434 const Matrix& rdNdXDerivative)
439 const VectorF& rhs_contribution_derivative =
440 prod(
trans(rData.mStrainMatrix), rData.mShearStressDerivative) +
441 prod(
trans(strain_matrix_derivative), rData.mShearStress);
443 noalias(rResidualDerivative) -= rhs_contribution_derivative * W;
456 template<
unsigned int TComponentIndex>
477 const Matrix& rdNdX)
const;
519 double mConvectiveVelocityNorm;
520 double mEffectiveViscosity;
526 double mMassProjection;
527 double mDynamicViscosity;
529 double mVelocityDotNabla;
534 ArrayD mRelaxedAcceleration;
535 ArrayD mConvectiveVelocity;
536 ArrayD mMomentumProjection;
538 ArrayD mEffectiveVelocityDotVelocityGradient;
540 VectorN mConvectiveVelocityDotDnDx;
541 VectorN mRelaxedAccelerationDotDnDx;
542 VectorN mEffectiveVelocityDotVelocityGradientDotShapeGradient;
544 VectorN mMomentumProjectionDotDnDx;
545 VectorN mPressureGradientDotDnDx;
552 MatrixDD mEffectiveVelocityGradient;
564 Vector mStrainRateDerivative;
565 Vector mShearStressDerivative;
571 template<
class TDerivativesType>
574 template<
unsigned int TComponentIndex>
587 const double ValueNorm,
589 const Vector& ValueDerivative);
594 const double ElementSize,
595 const double Density,
596 const double Viscosity,
597 const double VelocityNorm,
598 const double DynamicTau,
599 const double DeltaTime);
602 double& TauOneDerivative,
603 double& TauTwoDerivative,
605 const double Density,
606 const double DynamicTau,
607 const double DeltaTime,
608 const double ElementSize,
609 const double ElementSizeDerivative,
610 const double Viscosity,
611 const double ViscosityDerivative,
612 const double VelocityNorm,
613 const double VelocityNormDerivative);
619 Matrix& rConstitutiveMatrix,
Definition: constitutive_law.h:47
virtual void CalculateDerivative(Parameters &rParameterValues, const Variable< double > &rFunctionVariable, const Variable< double > &rDerivativeVariable, double &rOutput)
Calculates derivatives of a given function.
Definition: constitutive_law.cpp:450
Base class for all Elements.
Definition: element.h:60
Properties PropertiesType
Definition: element.h:80
static void GetStrainMatrix(const ShapeDerivatives2DType &rDNDX, BoundedMatrix< double, VoigtVector2DSize, 3 *TNumNodes > &rStrainMatrix)
Definition: fluid_element_utilities.cpp:23
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
void clear()
Definition: amatrix_interface.h:284
This class defines the node.
Definition: node.h:65
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
static const std::array< const Variable< double > *, TStrainSize > GetStrainRateVariables()
Definition: qs_vms_residual_derivatives.h:483
static constexpr IndexType TResidualSize
Definition: qs_vms_residual_derivatives.h:492
void CalculateGaussPointData(const double W, const Vector &rN, const Matrix &rdNdX)
Definition: qs_vms_residual_derivatives.cpp:248
static constexpr IndexType TLNumNodes
Definition: qs_vms_residual_derivatives.h:490
void Initialize(const Element &rElement, ConstitutiveLaw &rConstitutiveLaw, const ProcessInfo &rProcessInfo)
Definition: qs_vms_residual_derivatives.cpp:186
static constexpr IndexType TBlockSize
Definition: qs_vms_residual_derivatives.h:488
Computes residual contributions.
Definition: qs_vms_residual_derivatives.h:117
constexpr static IndexType NumNodes
Definition: qs_vms_residual_derivatives.h:122
constexpr static IndexType BlockSize
Definition: qs_vms_residual_derivatives.h:124
void AddGaussPointResidualsContributions(VectorF &rResidual, QSVMSResidualData &rData, const double W, const Vector &rN, const Matrix &rdNdX) const
Definition: qs_vms_residual_derivatives.cpp:87
Computes second derivatives of the QS VMS residual.
Definition: qs_vms_residual_derivatives.h:458
constexpr static IndexType BlockSize
Definition: qs_vms_residual_derivatives.h:465
void CalculateGaussPointResidualsDerivativeContributions(VectorF &rResidualDerivative, QSVMSResidualData &rData, const int NodeIndex, const double W, const Vector &rN, const Matrix &rdNdX) const
Definition: qs_vms_residual_derivatives.cpp:158
constexpr static IndexType NumNodes
Definition: qs_vms_residual_derivatives.h:463
Computes QS VMS residual derivative residuals for given variable.
Definition: qs_vms_residual_derivatives.h:161
constexpr static IndexType BlockSize
Definition: qs_vms_residual_derivatives.h:168
constexpr static IndexType NumNodes
Definition: qs_vms_residual_derivatives.h:166
constexpr static IndexType ComponentIndex
Definition: qs_vms_residual_derivatives.h:172
void CalculateGaussPointResidualsDerivativeContributions(VectorF &rResidualDerivative, QSVMSResidualData &rData, const int NodeIndex, const double W, const Vector &rN, const Matrix &rdNdX, const double WDerivative, const double DetJDerivative, const Matrix &rdNdXDerivative, const double MassTermsDerivativesWeight=1.0) const
Computes gauss point residual derivatives for given NodeIndex.
Definition: qs_vms_residual_derivatives.h:195
constexpr static IndexType TDerivativeDimension
Definition: qs_vms_residual_derivatives.h:170
Computes the QSVMS residual derivatives.
Definition: qs_vms_residual_derivatives.h:50
static void InitializeConstitutiveLaw(ConstitutiveLaw::Parameters &rParameters, Vector &rStrainVector, Vector &rStressVector, Matrix &rConstitutiveMatrix, const GeometryType &rGeometry, const PropertiesType &rProperties, const ProcessInfo &rProcessInfo)
Definition: qs_vms_residual_derivatives.cpp:387
static void CalculateTauDerivative(double &TauOneDerivative, double &TauTwoDerivative, const double TauOne, const double Density, const double DynamicTau, const double DeltaTime, const double ElementSize, const double ElementSizeDerivative, const double Viscosity, const double ViscosityDerivative, const double VelocityNorm, const double VelocityNormDerivative)
Definition: qs_vms_residual_derivatives.cpp:354
typename Element::PropertiesType PropertiesType
Definition: qs_vms_residual_derivatives.h:61
std::size_t IndexType
Definition: qs_vms_residual_derivatives.h:55
static void CalculateTau(double &TauOne, double &TauTwo, const double ElementSize, const double Density, const double Viscosity, const double VelocityNorm, const double DynamicTau, const double DeltaTime)
Definition: qs_vms_residual_derivatives.cpp:333
constexpr static IndexType TElementLocalSize
Definition: qs_vms_residual_derivatives.h:68
constexpr static IndexType TNN
Definition: qs_vms_residual_derivatives.h:70
static void Check(const Element &rElement, const ProcessInfo &rProcessInfo)
Definition: qs_vms_residual_derivatives.cpp:35
constexpr static IndexType TStrainSize
Size of the strain and stress vectors (in Voigt notation) for the formulation.
Definition: qs_vms_residual_derivatives.h:66
static double CalculateNormDerivative(const double ValueNorm, const Vector &Value, const Vector &ValueDerivative)
Definition: qs_vms_residual_derivatives.cpp:320
static constexpr IndexType TBlockSize
Definition: qs_vms_residual_derivatives.h:63
static GeometryData::IntegrationMethod GetIntegrationMethod()
Definition: qs_vms_residual_derivatives.cpp:80
static void EvaluateGradientInPoint(const GeometryType &rGeometry, const Matrix &rShapeFunctionDerivatives, const int Step, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates gradients of given list of variable pairs at gauss point locations at step.
Definition: fluid_calculation_utilities.h:196
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
a
Definition: generate_stokes_twofluid_element.py:77
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17
Definition: constitutive_law.h:189