Skip to content

Commit

Permalink
correcting style Refs idaholab#29846
Browse files Browse the repository at this point in the history
  • Loading branch information
tanoret committed Feb 9, 2025
1 parent 81a7048 commit 8c858aa
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 139 deletions.
43 changes: 21 additions & 22 deletions framework/src/problems/FEProblemBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -4138,11 +4138,10 @@ FEProblemBase::addObjectParamsHelper(InputParameters & parameters,
const std::string & object_name,
const std::string & var_param_name)
{
const auto sys_num =
parameters.isParamValid(var_param_name) &&
&getSystem(parameters.varName(var_param_name, object_name))
? getSystem(parameters.varName(var_param_name, object_name)).number()
: (unsigned int)0;
const auto sys_num = parameters.isParamValid(var_param_name) &&
&getSystem(parameters.varName(var_param_name, object_name))
? getSystem(parameters.varName(var_param_name, object_name)).number()
: (unsigned int)0;

if (_displaced_problem && parameters.have_parameter<bool>("use_displaced_mesh") &&
parameters.get<bool>("use_displaced_mesh"))
Expand Down Expand Up @@ -7429,24 +7428,24 @@ FEProblemBase::computeLinearSystemTags(const NumericVector<Number> & soln,

_current_linear_sys->compute(EXEC_NONLINEAR);

/*
try
{
computeSystems(EXEC_NONLINEAR);
}
catch (MooseException & e)
{
_console << "\nA MooseException was raised during Auxiliary variable computation.\n"
<< "The next solve will fail, the timestep will be reduced, and we will try again.\n"
<< std::endl;
/*
try
{
computeSystems(EXEC_NONLINEAR);
}
catch (MooseException & e)
{
_console << "\nA MooseException was raised during Auxiliary variable computation.\n"
<< "The next solve will fail, the timestep will be reduced, and we will try again.\n"
<< std::endl;
// We know the next solve is going to fail, so there's no point in
// computing anything else after this. Plus, using incompletely
// computed AuxVariables in subsequent calculations could lead to
// other errors or unhandled exceptions being thrown.
return;
}
*/
// We know the next solve is going to fail, so there's no point in
// computing anything else after this. Plus, using incompletely
// computed AuxVariables in subsequent calculations could lead to
// other errors or unhandled exceptions being thrown.
return;
}
*/

computeUserObjects(EXEC_NONLINEAR, Moose::POST_AUX);
executeControls(EXEC_NONLINEAR);
Expand Down
1 change: 0 additions & 1 deletion framework/src/systems/LinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ LinearSystem::LinearSystem(FEProblemBase & fe_problem, const std::string & name)
// from the tagging interface can still be used without any nonlinear systems
_rhs_non_time_tag = _fe_problem.addVectorTag("NONTIME");


_linear_implicit_system.attach_assemble_function(Moose::compute_linear_system);
}

Expand Down
9 changes: 6 additions & 3 deletions modules/navier_stokes/include/base/NavierStokesMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@ divergence(const TensorValue<T> & gradient,
}

// Prevent implicit instantiation in other translation units where these classes are used
extern template Real findUStar<Real>(const Real & mu, const Real & rho, const Real & u, const Real dist);
extern template ADReal findUStar<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real dist);
extern template Real
findUStar<Real>(const Real & mu, const Real & rho, const Real & u, const Real dist);
extern template ADReal
findUStar<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real dist);

extern template Real findyPlus<Real>(const Real & mu, const Real & rho, const Real & u, Real dist);
extern template ADReal findyPlus<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, Real dist);
extern template ADReal
findyPlus<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, Real dist);

extern template Real computeSpeed<Real>(const libMesh::VectorValue<Real> & velocity);
extern template ADReal computeSpeed<ADReal>(const libMesh::VectorValue<ADReal> & velocity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class LinearFVTurbulentLimitedDiffusion : public LinearFVDiffusion
virtual void addRightHandSideContribution() override;

protected:

/// The functor for the scaling coefficient for the diffusion term
const Moose::Functor<Real> & _scaling_coeff;

Expand Down
3 changes: 2 additions & 1 deletion modules/navier_stokes/src/auxkernels/kEpsilonViscosityAux.C
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ kEpsilonViscosityAux::computeValue()
velocity(2) = (*_w_var)(current_argument, state);

// Compute the velocity and direction of the velocity component that is parallel to the wall
const auto parallel_speed = NS::computeSpeed<ADReal>(velocity - velocity * loc_normal * loc_normal);
const auto parallel_speed =
NS::computeSpeed<ADReal>(velocity - velocity * loc_normal * loc_normal);

// Switch for determining the near wall quantities
// wall_treatment can be: "eq_newton eq_incremental eq_linearized neq"
Expand Down
38 changes: 21 additions & 17 deletions modules/navier_stokes/src/base/NavierStokesMethods.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ prandtlPropertyDerivative(const Real & mu,
}

template <typename T>
T findUStar(const T & mu, const T & rho, const T & u, const Real dist)
T
findUStar(const T & mu, const T & rho, const T & u, const Real dist)
{
// usually takes about 3-4 iterations
constexpr int MAX_ITERS{50};
Expand All @@ -77,24 +78,22 @@ T findUStar(const T & mu, const T & rho, const T & u, const Real dist)

// Wall-function linearized guess
const Real a_c = 1 / NS::von_karman_constant;
const T b_c =
1.0 / NS::von_karman_constant * (std::log(NS::E_turb_constant * dist / mu) + 1.0);
const T b_c = 1.0 / NS::von_karman_constant * (std::log(NS::E_turb_constant * dist / mu) + 1.0);
const T & c_c = u;

/// This is important to reduce the number of nonlinear iterations
T u_star =
std::max(1e-20, (-b_c + std::sqrt(std::pow(b_c, 2) + 4.0 * a_c * c_c)) / (2.0 * a_c));
T u_star = std::max(1e-20, (-b_c + std::sqrt(std::pow(b_c, 2) + 4.0 * a_c * c_c)) / (2.0 * a_c));

// Newton-Raphson method to solve for u_star (friction velocity).
for (int i = 0; i < MAX_ITERS; ++i)
{
T residual =
u_star / NS::von_karman_constant * std::log(NS::E_turb_constant * u_star * dist / nu) - u;
T deriv =
(1.0 + std::log(NS::E_turb_constant * u_star * dist / nu)) / NS::von_karman_constant;
T deriv = (1.0 + std::log(NS::E_turb_constant * u_star * dist / nu)) / NS::von_karman_constant;
T new_u_star = std::max(1e-20, u_star - residual / deriv);

Real rel_err = std::abs(MetaPhysicL::raw_value(new_u_star - u_star) / MetaPhysicL::raw_value(new_u_star));
Real rel_err =
std::abs(MetaPhysicL::raw_value(new_u_star - u_star) / MetaPhysicL::raw_value(new_u_star));

u_star = new_u_star;
if (rel_err < REL_TOLERANCE)
Expand All @@ -112,10 +111,12 @@ T findUStar(const T & mu, const T & rho, const T & u, const Real dist)
")");
}
template Real findUStar<Real>(const Real & mu, const Real & rho, const Real & u, const Real dist);
template ADReal findUStar<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real dist);
template ADReal
findUStar<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real dist);

template <typename T>
T findyPlus(const T & mu, const T & rho, const T & u, const Real dist)
T
findyPlus(const T & mu, const T & rho, const T & u, const Real dist)
{
// Fixed point iteration method to find y_plus
// It should take 3 or 4 iterations
Expand Down Expand Up @@ -146,10 +147,12 @@ T findyPlus(const T & mu, const T & rho, const T & u, const Real dist)
return std::max(NS::min_y_plus, yPlus);
}
template Real findyPlus<Real>(const Real & mu, const Real & rho, const Real & u, Real dist);
template ADReal findyPlus<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, Real dist);
template ADReal
findyPlus<ADReal>(const ADReal & mu, const ADReal & rho, const ADReal & u, Real dist);

template <typename T>
T computeSpeed(const libMesh::VectorValue<T> & velocity)
T
computeSpeed(const libMesh::VectorValue<T> & velocity)
{
// if the velocity is zero, then the norm function call fails because AD tries to calculate the
// derivatives which causes a divide by zero - because d/dx(sqrt(f(x))) = 1/2/sqrt(f(x))*df/dx.
Expand All @@ -161,11 +164,12 @@ template Real computeSpeed<Real>(const libMesh::VectorValue<Real> & velocity);
template ADReal computeSpeed<ADReal>(const libMesh::VectorValue<ADReal> & velocity);

template <typename T>
T computeShearStrainRateNormSquared(const Moose::Functor<T> & u,
const Moose::Functor<T> * v,
const Moose::Functor<T> * w,
const Moose::ElemArg & elem_arg,
const Moose::StateArg & state)
T
computeShearStrainRateNormSquared(const Moose::Functor<T> & u,
const Moose::Functor<T> * v,
const Moose::Functor<T> * w,
const Moose::ElemArg & elem_arg,
const Moose::StateArg & state)
{
const auto & grad_u = u.gradient(elem_arg, state);
const T Sij_xx = 2.0 * grad_u(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,11 @@ LinearAssemblySegregatedSolve::solve()
Moose::PetscSupport::petscSetOptions(_turbulence_petsc_options, solver_params);
for (const auto i : index_range(_turbulence_system_names))
ns_residuals[momentum_residual.size() + 1 + _has_energy_system + i] =
solveAdvectedSystem(_turbulence_system_numbers[i],
*_turbulence_systems[i],
_turbulence_equation_relaxation[i],
_turbulence_linear_control,
_turbulence_l_abs_tol);
solveAdvectedSystem(_turbulence_system_numbers[i],
*_turbulence_systems[i],
_turbulence_equation_relaxation[i],
_turbulence_linear_control,
_turbulence_l_abs_tol);
}

_problem.execute(EXEC_NONLINEAR);
Expand Down
4 changes: 2 additions & 2 deletions modules/navier_stokes/src/executioners/SIMPLESolve.C
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ SIMPLESolve::checkIntegrity()
checkTimeKernels(*_energy_system);

if (_has_turbulence_systems)
for (const auto system : _turbulence_systems)
checkTimeKernels(*system);
for (const auto system : _turbulence_systems)
checkTimeKernels(*system);

if (_has_passive_scalar_systems)
for (const auto system : _passive_scalar_systems)
Expand Down
36 changes: 14 additions & 22 deletions modules/navier_stokes/src/executioners/SIMPLESolveBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ SIMPLESolveBase::validParams()
params.addParam<MultiMooseEnum>("turbulence_petsc_options",
Moose::PetscSupport::getCommonPetscFlags(),
"Singleton PETSc options for the turbulence equation(s)");
params.addParam<MultiMooseEnum>(
"turbulence_petsc_options_iname",
Moose::PetscSupport::getCommonPetscKeys(),
"Names of PETSc name/value pairs for the turbulence equation(s)");
params.addParam<MultiMooseEnum>("turbulence_petsc_options_iname",
Moose::PetscSupport::getCommonPetscKeys(),
"Names of PETSc name/value pairs for the turbulence equation(s)");
params.addParam<std::vector<std::string>>(
"turbulence_petsc_options_value",
"Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
Expand Down Expand Up @@ -325,16 +324,14 @@ SIMPLESolveBase::SIMPLESolveBase(Executioner & ex)
_passive_scalar_l_abs_tol(getParam<Real>("passive_scalar_l_abs_tol")),
_turbulence_system_names(getParam<std::vector<SolverSystemName>>("turbulence_systems")),
_has_turbulence_systems(!_turbulence_system_names.empty()),
_turbulence_equation_relaxation(
getParam<std::vector<Real>>("turbulence_equation_relaxation")),
_turbulence_equation_relaxation(getParam<std::vector<Real>>("turbulence_equation_relaxation")),
_turbulence_l_abs_tol(getParam<Real>("turbulence_l_abs_tol")),
_momentum_absolute_tolerance(getParam<Real>("momentum_absolute_tolerance")),
_pressure_absolute_tolerance(getParam<Real>("pressure_absolute_tolerance")),
_energy_absolute_tolerance(getParam<Real>("energy_absolute_tolerance")),
_passive_scalar_absolute_tolerance(
getParam<std::vector<Real>>("passive_scalar_absolute_tolerance")),
_turbulence_absolute_tolerance(
getParam<std::vector<Real>>("turbulence_absolute_tolerance")),
_turbulence_absolute_tolerance(getParam<std::vector<Real>>("turbulence_absolute_tolerance")),
_num_iterations(getParam<unsigned int>("num_iterations")),
_continue_on_max_its(getParam<bool>("continue_on_max_its")),
_print_fields(getParam<bool>("print_fields"))
Expand Down Expand Up @@ -437,8 +434,8 @@ SIMPLESolveBase::SIMPLESolveBase(Executioner & ex)
"passive_scalar_absolute_tolerance"},
false);

// We check for input errors with regards to the surrogate turbulence equations. At the same time, we
// set up the corresponding system numbers
// We check for input errors with regards to the surrogate turbulence equations. At the same time,
// we set up the corresponding system numbers
if (_has_turbulence_systems)
{
if (_turbulence_system_names.size() != _turbulence_equation_relaxation.size())
Expand All @@ -450,20 +447,15 @@ SIMPLESolveBase::SIMPLESolveBase(Executioner & ex)
"The number of absolute tolerances does not match the number of "
"passive scalar equations!");

const auto & turbulence_petsc_options =
getParam<MultiMooseEnum>("turbulence_petsc_options");
const auto & turbulence_petsc_options = getParam<MultiMooseEnum>("turbulence_petsc_options");
const auto & turbulence_petsc_pair_options = getParam<MooseEnumItem, std::string>(
"turbulence_petsc_options_iname", "turbulence_petsc_options_value");
Moose::PetscSupport::processPetscFlags(turbulence_petsc_options,
_turbulence_petsc_options);
Moose::PetscSupport::processPetscPairs(turbulence_petsc_pair_options,
_problem.mesh().dimension(),
_turbulence_petsc_options);

_turbulence_linear_control.real_valued_data["rel_tol"] =
getParam<Real>("turbulence_l_tol");
_turbulence_linear_control.real_valued_data["abs_tol"] =
getParam<Real>("turbulence_l_abs_tol");
Moose::PetscSupport::processPetscFlags(turbulence_petsc_options, _turbulence_petsc_options);
Moose::PetscSupport::processPetscPairs(
turbulence_petsc_pair_options, _problem.mesh().dimension(), _turbulence_petsc_options);

_turbulence_linear_control.real_valued_data["rel_tol"] = getParam<Real>("turbulence_l_tol");
_turbulence_linear_control.real_valued_data["abs_tol"] = getParam<Real>("turbulence_l_abs_tol");
_turbulence_linear_control.int_valued_data["max_its"] =
getParam<unsigned int>("turbulence_l_max_its");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ INSFVTurbulentViscosityWallFunction::boundaryValue(const FaceInfo & fi,
velocity(2) = (*_w_var)(current_argument, old_state);

// Compute the velocity and direction of the velocity component that is parallel to the wall
const auto parallel_speed = NS::computeSpeed<ADReal>(velocity - velocity * (fi.normal()) * (fi.normal()));
const auto parallel_speed =
NS::computeSpeed<ADReal>(velocity - velocity * (fi.normal()) * (fi.normal()));

// Switch for determining the near wall quantities
// wall_treatment can be: "eq_newton eq_incremental eq_linearized neq"
Expand Down
3 changes: 2 additions & 1 deletion modules/navier_stokes/src/fvbcs/INSFVWallFunctionBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ INSFVWallFunctionBC::computeStrongResidual()

// Compute the friction velocity and the wall shear stress
const auto rho = _rho(makeElemArg(&elem), state);
ADReal u_star = NS::findUStar<ADReal>(_mu(makeElemArg(&elem), state), rho, parallel_speed, dist.value());
ADReal u_star =
NS::findUStar<ADReal>(_mu(makeElemArg(&elem), state), rho, parallel_speed, dist.value());
ADReal tau = u_star * u_star * rho;
_a *= tau;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ LinearFVTKEDSourceSink::computeMatrixContribution()

// Compute production of TKE
const auto symmetric_strain_tensor_sq_norm =
NS::computeShearStrainRateNormSquared<Real>(_u_var, _v_var, _w_var, elem_arg, state);
NS::computeShearStrainRateNormSquared<Real>(_u_var, _v_var, _w_var, elem_arg, state);
Real production_k = _mu_t(elem_arg, state) * symmetric_strain_tensor_sq_norm;

// Limit TKE production (needed for flows with stagnation zones)
Expand All @@ -118,7 +118,7 @@ LinearFVTKEDSourceSink::computeMatrixContribution()
destruction = _C2_eps * rho * _var.getElemValue(*_current_elem_info, state) / TKE;

// Assign to matrix (term gets multiplied by TKED)
return (destruction - production*0.0) * _current_elem_volume;
return (destruction - production * 0.0) * _current_elem_volume;
}
}

Expand Down Expand Up @@ -185,8 +185,8 @@ LinearFVTKEDSourceSink::computeRightHandSideContribution()
const Elem * const loc_elem = defined_on_elem_side ? &fi->elem() : fi->neighborPtr();
const Moose::FaceArg facearg = {
fi, Moose::FV::LimiterType::CentralDifference, false, false, loc_elem, nullptr};
destruction += 2.0 * TKE * _mu(facearg, state) / rho /
Utility::pow<2>(distance_vec[i]) / tot_weight;
destruction +=
2.0 * TKE * _mu(facearg, state) / rho / Utility::pow<2>(distance_vec[i]) / tot_weight;
}
else
destruction += std::pow(_C_mu, 0.75) * std::pow(TKE, 1.5) /
Expand All @@ -203,8 +203,8 @@ LinearFVTKEDSourceSink::computeRightHandSideContribution()
return destruction * _current_elem_volume;
}
else
// Do nothing
// return 0.0;
// Do nothing
// return 0.0;
{
// Convenient definitions
const auto state = determineState();
Expand All @@ -217,7 +217,7 @@ LinearFVTKEDSourceSink::computeRightHandSideContribution()

// Compute production of TKE
const auto symmetric_strain_tensor_sq_norm =
NS::computeShearStrainRateNormSquared<Real>(_u_var, _v_var, _w_var, elem_arg, state);
NS::computeShearStrainRateNormSquared<Real>(_u_var, _v_var, _w_var, elem_arg, state);
Real production_k = _mu_t(elem_arg, state) * symmetric_strain_tensor_sq_norm;

// Limit TKE production (needed for flows with stagnation zones)
Expand Down
Loading

0 comments on commit 8c858aa

Please sign in to comment.