Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
- Better doxygen for ConvectedMeshPSPG
- Typo fix
- Better doxygen for _speed member
- Inline short methods in the header
- More doxygen for disp dot members in INSBase
- Switch i and qp loop order

Co-authored-by: Guillaume Giudicelli <[email protected]>
  • Loading branch information
lindsayad and GiudGiud committed Oct 27, 2023
1 parent 3ee3baa commit fd7f724
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 49 deletions.
42 changes: 42 additions & 0 deletions modules/fsi/include/interfacekernels/ADPenaltyVelocityContinuity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "InterfaceKernelBase.h"
#include "MooseVariableFE.h"

/**
* Interface kernel for enforcing continuity of stress and velocity
Expand Down Expand Up @@ -57,3 +58,44 @@ class ADPenaltyVelocityContinuity : public InterfaceKernelBase
/// Jump data member to avoid constant heap allocations
std::vector<ADRealVectorValue> _qp_jumps;
};

inline void
ADPenaltyVelocityContinuity::computeJacobian()
{
computeResidual();
}

inline void
ADPenaltyVelocityContinuity::computeResidualAndJacobian()
{
computeResidual();
}

inline void
ADPenaltyVelocityContinuity::computeElementOffDiagJacobian(const unsigned int jvar)
{
if (jvar == _velocity_var->number())
// Only need to do this once because AD does everything all at once
computeResidual();
}

inline void
ADPenaltyVelocityContinuity::computeNeighborOffDiagJacobian(unsigned int)
{
}

inline const MooseVariableFieldBase &
ADPenaltyVelocityContinuity::variable() const
{
return *_velocity_var;
}

inline const MooseVariableFieldBase &
ADPenaltyVelocityContinuity::neighborVariable() const
{
if (_displacements.empty() || !_displacements.front())
mooseError("The 'neighborVariable' method was called which requires that displacements be "
"actual variables.");

return *_displacements.front();
}
2 changes: 1 addition & 1 deletion modules/fsi/include/kernels/ConvectedMeshPSPG.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "INSBase.h"

/**
* This calculates the time derivative for a coupled variable
* Computes residual and Jacobian contributions for the PSPG stabilization term for mesh advection
**/
class ConvectedMeshPSPG : public INSBase
{
Expand Down
45 changes: 2 additions & 43 deletions modules/fsi/src/interfacekernels/ADPenaltyVelocityContinuity.C
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ ADPenaltyVelocityContinuity::computeResidual()
for (auto & r : _residuals)
r = 0;

for (const auto qp : make_range(_qrule->n_points()))
for (const auto i : index_range(phi))
for (const auto i : index_range(phi))
for (const auto qp : make_range(_qrule->n_points()))
_residuals[i] += phi[i][qp] * _qp_jumps[qp];

addResidualsAndJacobian(_assembly, _residuals, dof_indices, _velocity_var->scalingFactor());
Expand Down Expand Up @@ -106,44 +106,3 @@ ADPenaltyVelocityContinuity::computeResidual()
}
}
}

void
ADPenaltyVelocityContinuity::computeJacobian()
{
computeResidual();
}

void
ADPenaltyVelocityContinuity::computeResidualAndJacobian()
{
computeResidual();
}

void
ADPenaltyVelocityContinuity::computeElementOffDiagJacobian(const unsigned int jvar)
{
if (jvar == _velocity_var->number())
// Only need to do this once because AD does everything all at once
computeResidual();
}

void
ADPenaltyVelocityContinuity::computeNeighborOffDiagJacobian(unsigned int)
{
}

const MooseVariableFieldBase &
ADPenaltyVelocityContinuity::variable() const
{
return *_velocity_var;
}

const MooseVariableFieldBase &
ADPenaltyVelocityContinuity::neighborVariable() const
{
if (_displacements.empty() || !_displacements.front())
mooseError("The 'neighborVariable' method was called which requires that displacements be "
"actual variables.");

return *_displacements.front();
}
2 changes: 1 addition & 1 deletion modules/fsi/test/tests/2d-small-strain-transient/tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
exodiff = 'fsi_flat_channel_out.e'
detail = 'scalar field variables for velocity components and hand-coded Jacobians,'
# vel_x_solid is not accurate
# We mmay improve that in the future
# We may improve that in the future
rel_err = 1e-4
[]
[INSAD]
Expand Down
6 changes: 3 additions & 3 deletions modules/navier_stokes/include/kernels/INSBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class INSBase : public Kernel

/// Whether displacements are provided
const bool _disps_provided;
/// Time derivative of the x-displacement
/// Time derivative of the x-displacement, mesh velocity in the x-direction
const VariableValue & _disp_x_dot;
/// Time derivative of the y-displacement
/// Time derivative of the y-displacement, mesh velocity in the y-direction
const VariableValue & _disp_y_dot;
/// Time derivative of the z-displacement
/// Time derivative of the z-displacement, mesh velocity in the z-direction
const VariableValue & _disp_z_dot;
};
2 changes: 1 addition & 1 deletion modules/navier_stokes/include/materials/INSADTauMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class INSADTauMaterialTempl : public T
const unsigned int _vel_sys_number;

/// The speed of the medium. This is the norm of the relative velocity, e.g. the velocity minus
/// the mesh velocity
/// the mesh velocity, at the current _qp
ADReal _speed;

using T::_ad_q_point;
Expand Down

0 comments on commit fd7f724

Please sign in to comment.