Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Physics for linear FV + mixture model #29614

Draft
wants to merge 18 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
da82bcd
Make addkernels and bcs routines in WCNS actions more generic
GiudGiud Jan 31, 2025
14b3029
Add time derivative kernels for the linear finite volume physics in NS
GiudGiud Jan 31, 2025
5bc5ad2
Add a 3D test for linear flow physics
GiudGiud Jan 31, 2025
f32da72
Add support for more object dumping in DumpObjectsProblem
GiudGiud Jan 31, 2025
9bb5404
Add a 1D scalar advection test
GiudGiud Jan 31, 2025
15bed65
Add a 2D boussinesq channel test for Physics syntax
GiudGiud Feb 1, 2025
9fd593c
Add boussinesq treatment to linear FV flow Physics
GiudGiud Feb 1, 2025
31bb1d6
Add a Physics for linear finite volume for two phase flow
GiudGiud Dec 24, 2024
d326bb9
Adapt slip material and use of slip velocity to linear variables
GiudGiud Dec 24, 2024
cf50d28
Add parameter setting routines for two phase mixtures to be shared be…
GiudGiud Dec 24, 2024
4555636
Add support for active scalars in linear fv segregated assembly solve…
GiudGiud Dec 24, 2024
6c2e861
Avoid thinking the pressure pin works in linear finite volume through…
GiudGiud Feb 1, 2025
cc685a6
Add an input for lid-driven + linear FV
GiudGiud Dec 24, 2024
7ef3456
Add linear system summary output to header and mesh-changed console o…
GiudGiud Feb 1, 2025
e77de0d
Request cell gradients when using the slip velocities
GiudGiud Feb 1, 2025
21744b7
Add face side element to linear fv advection so that advection by fun…
GiudGiud Feb 1, 2025
39f9d47
Remove transient term for now from slip velocity
GiudGiud Feb 1, 2025
3753516
Output exceptions in linear system
GiudGiud Feb 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions framework/include/outputs/ConsoleUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ std::string outputMeshInformation(FEProblemBase & problem, bool verbose = true);
std::string outputAuxiliarySystemInformation(FEProblemBase & problem);

/**
* Output the Nonlinear system information
* Output a solver system information
*/
std::string outputNonlinearSystemInformation(FEProblemBase & problem,
const unsigned int nl_sys_num);
std::string outputSolverSystemInformation(FEProblemBase & problem,
const unsigned int solver_sys_num);

/**
* Output action RelationshipManager information
Expand Down
16 changes: 14 additions & 2 deletions framework/include/problems/DumpObjectsProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class DumpObjectsNonlinearSystem;
FEProblemBase::method_name(type, name, parameters); \
}

#define captureDumpUO(method_name, path) \
std::vector<std::shared_ptr<UserObject>> method_name( \
const std::string & type, const std::string & name, InputParameters & parameters) override \
{ \
dumpObjectHelper(path, type, name, parameters); \
FEProblemBase::method_name(type, name, parameters); \
return std::vector<std::shared_ptr<UserObject>>(); \
}

/**
* Specialization of SubProblem for dumping generated objects as input file syntax
*/
Expand Down Expand Up @@ -94,6 +103,7 @@ class DumpObjectsProblem : public FEProblemBase
captureDump(addAuxVariable, "AuxVariables")
captureDump(addBoundaryCondition, "BCs")
captureDump(addConstraint, "Constraints")
captureDump(addConvergence, "Convergence")
captureDump(addDamper, "Dampers")
captureDump(addDGKernel, "DGKernels")
captureDump(addDiracKernel, "DiracKernels")
Expand All @@ -110,18 +120,20 @@ class DumpObjectsProblem : public FEProblemBase
captureDump(addInitialCondition, "ICs")
captureDump(addInterfaceKernel, "InterfaceKernels")
captureDump(addKernel, "Kernels")
captureDump(addLinearFVBC, "LinearFVBCs")
captureDump(addLinearFVBC, "LinearFVBCs")
captureDump(addLinearFVKernel, "LinearFVKernels")
captureDump(addMarker, "Adaptivity/Markers")
captureDump(addMaterial, "Materials")
captureDump(addMeshDivision, "MeshDivisions")
captureDump(addMultiApp, "MultiApps")
captureDump(addNodalKernel, "NodalKernels")
captureDump(addPostprocessor, "Postprocessors")
captureDump(addPredictor, "Executioner/Predictor")
captureDump(addSampler, "Samplers")
captureDump(addScalarKernel, "ScalarKernels")
captureDump(addTransfer, "Transfers")
captureDump(addTimeIntegrator, "TimeIntegrators")
captureDump(addTimeIntegrator, "Executioner/TimeIntegrators")
captureDumpUO(addUserObject, "UserObjects")
captureDump(addVariable, "Variables")
captureDump(addVectorPostprocessor, "VectorPostprocessors")
// clang-format off
Expand Down
2 changes: 1 addition & 1 deletion framework/include/problems/FEProblemBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class FEProblemBase : public SubProblem, public Restartable
virtual Function & getFunction(const std::string & name, const THREAD_ID tid = 0);

/// Add a MeshDivision
void
virtual void
addMeshDivision(const std::string & type, const std::string & name, InputParameters & params);
/// Get a MeshDivision
MeshDivision & getMeshDivision(const std::string & name, const THREAD_ID tid = 0) const;
Expand Down
33 changes: 29 additions & 4 deletions framework/src/outputs/Console.C
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ Console::validParams()
"the average residual it is colored yellow.");

// System information controls
MultiMooseEnum info("framework mesh aux nonlinear relationship execution output",
"framework mesh aux nonlinear execution");
MultiMooseEnum info("framework mesh aux nonlinear linear relationship execution output",
"framework mesh aux nonlinear linear execution");
params.addParam<MultiMooseEnum>("system_info",
info,
"List of information types to display "
Expand Down Expand Up @@ -712,7 +712,7 @@ Console::outputSystemInformation()
{
for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
{
std::string output = ConsoleUtils::outputNonlinearSystemInformation(*_problem_ptr, i);
std::string output = ConsoleUtils::outputSolverSystemInformation(*_problem_ptr, i);
if (!output.empty())
_console << "Nonlinear System" +
(_problem_ptr->numNonlinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
Expand All @@ -721,6 +721,20 @@ Console::outputSystemInformation()
}
}

if (_system_info_flags.isValueSet("linear"))
{
for (const auto i : make_range(_problem_ptr->numLinearSystems()))
{
std::string output = ConsoleUtils::outputSolverSystemInformation(
*_problem_ptr, _problem_ptr->numNonlinearSystems() + i);
if (!output.empty())
_console << "Linear System" +
(_problem_ptr->numLinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
":\n"
<< output;
}
}

if (_system_info_flags.isValueSet("aux"))
{
std::string output = ConsoleUtils::outputAuxiliarySystemInformation(*_problem_ptr);
Expand Down Expand Up @@ -771,14 +785,25 @@ Console::meshChanged()
std::string output;
for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
{
output = ConsoleUtils::outputNonlinearSystemInformation(*_problem_ptr, i);
output = ConsoleUtils::outputSolverSystemInformation(*_problem_ptr, i);
if (!output.empty())
_console << "Nonlinear System" +
(_problem_ptr->numNonlinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
":\n"
<< output;
}

for (const auto i : make_range(_problem_ptr->numLinearSystems()))
{
output = ConsoleUtils::outputSolverSystemInformation(*_problem_ptr,
_problem_ptr->numNonlinearSystems() + i);
if (!output.empty())
_console << "Linear System" +
(_problem_ptr->numLinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
":\n"
<< output;
}

output = ConsoleUtils::outputAuxiliarySystemInformation(*_problem_ptr);
if (!output.empty())
_console << "Auxiliary System:\n" << output;
Expand Down
4 changes: 2 additions & 2 deletions framework/src/outputs/ConsoleUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ outputSystemInformationHelper(std::stringstream & oss, System & system)
}

std::string
outputNonlinearSystemInformation(FEProblemBase & problem, const unsigned int nl_sys_num)
outputSolverSystemInformation(FEProblemBase & problem, const unsigned int sys_num)
{
std::stringstream oss;
oss << std::left;

return outputSystemInformationHelper(oss, problem.getNonlinearSystemBase(nl_sys_num).system());
return outputSystemInformationHelper(oss, problem.getSolverSystem(sys_num).system());
}

std::string
Expand Down
1 change: 1 addition & 0 deletions framework/src/systems/LinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ LinearSystem::computeLinearSystemTags(const std::set<TagID> & vector_tags,
}
catch (MooseException & e)
{
_console << "Exception detected " << e.what() << std::endl;
// The buck stops here, we have already handled the exception by
// calling stopSolve(), it is now up to PETSc to return a
// "diverged" reason during the next solve.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,39 @@ class LinearAssemblySegregatedSolve : public SIMPLESolveBase
/// Pointer(s) to the system(s) corresponding to the passive scalar equation(s)
std::vector<LinearSystem *> _passive_scalar_systems;

/// Pointer(s) to the system(s) corresponding to the active scalar equation(s)
std::vector<LinearSystem *> _active_scalar_systems;

/// Pointer to the segregated RhieChow interpolation object
RhieChowMassFlux * _rc_uo;

/// Shortcut to every linear system that we solve for here
std::vector<LinearSystem *> _systems_to_solve;

// ************************ Active Scalar Variables ************************ //

/// The names of the active scalar systems
const std::vector<SolverSystemName> & _active_scalar_system_names;

/// Boolean for easy check if a active scalar systems shall be solved or not
const bool _has_active_scalar_systems;

// The number(s) of the system(s) corresponding to the active scalar equation(s)
std::vector<unsigned int> _active_scalar_system_numbers;

/// The user-defined relaxation parameter(s) for the active scalar equation(s)
const std::vector<Real> _active_scalar_equation_relaxation;

/// Options which hold the petsc settings for the active scalar equation(s)
Moose::PetscSupport::PetscOptions _active_scalar_petsc_options;

/// Options for the linear solver of the active scalar equation(s)
SIMPLESolverConfiguration _active_scalar_linear_control;

/// Absolute linear tolerance for the active scalar equation(s). We need to store this, because
/// it needs to be scaled with a representative flux.
const Real _active_scalar_l_abs_tol;

/// The user-defined absolute tolerance for determining the convergence in active scalars
const std::vector<Real> _active_scalar_absolute_tolerance;
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class WCNSFV2PSlipVelocityFunctorMaterial : public FunctorMaterial
const unsigned int _dim;

/// x-velocity
const INSFVVelocityVariable * const _u_var;
MooseVariableField<Real> * const _u_var;
/// y-velocity
const INSFVVelocityVariable * const _v_var;
MooseVariableField<Real> * const _v_var;
/// z-velocity
const INSFVVelocityVariable * const _w_var;
MooseVariableField<Real> * const _w_var;

/// Continuous phase density
const Moose::Functor<ADReal> & _rho_mixture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ class LinearFVScalarAdvection : public LinearFVFluxKernel
/// matrix and right hand side contribution
Real _volumetric_face_flux;

/// slip velocity in direction x
const Moose::Functor<ADReal> * const _u_slip;
/// slip velocity in direction y
const Moose::Functor<ADReal> * const _v_slip;
/// slip velocity in direction z
const Moose::Functor<ADReal> * const _w_slip;

/// Whether to use an additional slip velocity to compute the face flux
bool _add_slip_model;

/// The interpolation method to use for the advected quantity
Moose::FV::InterpMethod _advected_interp_method;
};
32 changes: 15 additions & 17 deletions modules/navier_stokes/include/physics/WCNSFVFlowPhysics.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,32 @@ class WCNSFVFlowPhysics final : public WCNSFVFlowPhysicsBase
virtual void addUserObjects() override;
virtual void addCorrectors() override;

/// Function adding kernels for the time derivative term of the weakly compressible continuity equation
void addMassTimeKernels();
/// Function adding kernels for the incompressible continuity equation
void addINSMassKernels();
void addMassKernels();
/// Function adding the pressure constraint
void addINSPressurePinKernel();
void addPressurePinKernel();

/**
* Functions adding kernels for the incompressible momentum equation
* If the material properties are not constant, these can be used for
* weakly-compressible simulations (except the Boussinesq kernel) as well.
*/
void addINSMomentumTimeKernels();
void addINSMomentumViscousDissipationKernels();
void addINSMomentumMixingLengthKernels();
void addINSMomentumAdvectionKernels();
void addINSMomentumPressureKernels() override;
void addINSMomentumGravityKernels() override;
void addINSMomentumBoussinesqKernels() override;
void addINSMomentumFrictionKernels();

/// Functions which add time kernels for transient, weakly-compressible simulations.
void addWCNSMassTimeKernels();
void addWCNSMomentumTimeKernels();
void addMomentumTimeKernels() override;
void addMomentumViscousDissipationKernels();
void addMomentumMixingLengthKernels();
void addMomentumAdvectionKernels();
void addMomentumPressureKernels() override;
void addMomentumGravityKernels() override;
void addMomentumBoussinesqKernels() override;
void addMomentumFrictionKernels();

/// Functions adding boundary conditions for the incompressible simulation.
/// These are used for weakly-compressible simulations as well.
void addINSInletBC() override;
void addINSOutletBC() override;
void addINSWallsBC() override;
void addInletBC() override;
void addOutletBC() override;
void addWallsBC() override;

/// Return whether a Forchheimer friction model is in use
bool hasForchheimerFriction() const override;
Expand Down
13 changes: 7 additions & 6 deletions modules/navier_stokes/include/physics/WCNSFVFlowPhysicsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ class WCNSFVFlowPhysicsBase : public NavierStokesPhysicsBase
* If the material properties are not constant, these can be used for
* weakly-compressible simulations (except the Boussinesq kernel) as well.
*/
virtual void addINSMomentumPressureKernels() = 0;
virtual void addINSMomentumGravityKernels() = 0;
virtual void addINSMomentumBoussinesqKernels() = 0;
virtual void addMomentumTimeKernels() = 0;
virtual void addMomentumPressureKernels() = 0;
virtual void addMomentumGravityKernels() = 0;
virtual void addMomentumBoussinesqKernels() = 0;

/// Functions adding boundary conditions for the incompressible simulation.
/// These are used for weakly-compressible simulations as well.
virtual void addINSInletBC() = 0;
virtual void addINSOutletBC() = 0;
virtual void addINSWallsBC() = 0;
virtual void addInletBC() = 0;
virtual void addOutletBC() = 0;
virtual void addWallsBC() = 0;

/// Return whether a Forchheimer friction model is in use
virtual bool hasForchheimerFriction() const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ class WCNSFVFluidHeatTransferPhysics final : public WCNSFVFluidHeatTransferPhysi
* If the material properties are not constant, some of these can be used for
* weakly-compressible simulations as well.
*/
void addINSEnergyTimeKernels() override;
void addWCNSEnergyTimeKernels() override;
void addINSEnergyHeatConductionKernels() override;
void addINSEnergyAdvectionKernels() override;
void addINSEnergyAmbientConvection() override;
void addINSEnergyExternalHeatSource() override;
void addEnergyTimeKernels() override;
void addEnergyHeatConductionKernels() override;
void addEnergyAdvectionKernels() override;
void addEnergyAmbientConvection() override;
void addEnergyExternalHeatSource() override;

/// Functions adding boundary conditions for the incompressible simulation.
/// These are used for weakly-compressible simulations as well.
void addINSEnergyInletBC() override;
void addINSEnergyWallBC() override;
void addINSEnergyOutletBC() override {}
void addEnergyInletBC() override;
void addEnergyWallBC() override;
void addEnergyOutletBC() override {}
};
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ class WCNSFVFluidHeatTransferPhysicsBase : public NavierStokesPhysicsBase,
* If the material properties are not constant, some of these can be used for
* weakly-compressible simulations as well.
*/
virtual void addINSEnergyTimeKernels() = 0;
virtual void addWCNSEnergyTimeKernels() = 0;
virtual void addINSEnergyHeatConductionKernels() = 0;
virtual void addINSEnergyAdvectionKernels() = 0;
virtual void addINSEnergyAmbientConvection() = 0;
virtual void addINSEnergyExternalHeatSource() = 0;
virtual void addEnergyTimeKernels() = 0;
virtual void addEnergyHeatConductionKernels() = 0;
virtual void addEnergyAdvectionKernels() = 0;
virtual void addEnergyAmbientConvection() = 0;
virtual void addEnergyExternalHeatSource() = 0;

/// Functions adding boundary conditions for the incompressible simulation.
/// These are used for weakly-compressible simulations as well.
virtual void addINSEnergyInletBC() = 0;
virtual void addINSEnergyWallBC() = 0;
virtual void addINSEnergyOutletBC() = 0;
virtual void addEnergyInletBC() = 0;
virtual void addEnergyWallBC() = 0;
virtual void addEnergyOutletBC() = 0;

/// Process thermal conductivity (multiple functor input options are available).
/// Return true if we have vector thermal conductivity and false if scalar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class WCNSFVTwoPhaseMixturePhysics final : public WCNSFVScalarTransportPhysics
{
public:
static InputParameters validParams();
static InputParameters commonMixtureParams();
static void renamePassiveScalarToMixtureParams(InputParameters & params);

WCNSFVTwoPhaseMixturePhysics(const InputParameters & parameters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ class WCNSLinearFVFlowPhysics final : public WCNSFVFlowPhysicsBase
virtual void addUserObjects() override;

/// Function adding kernels for the incompressible pressure correction equation
void addINSPressureCorrectionKernels();
void addPressureCorrectionKernels();

/**
* Functions adding kernels for the incompressible momentum equation
* If the material properties are not constant, these can be used for
* weakly-compressible simulations (except the Boussinesq kernel) as well.
*/
void addINSMomentumFluxKernels();
virtual void addINSMomentumPressureKernels() override;
virtual void addINSMomentumGravityKernels() override;
virtual void addINSMomentumBoussinesqKernels() override;
void addMomentumTimeKernels() override;
void addMomentumFluxKernels();
virtual void addMomentumPressureKernels() override;
virtual void addMomentumGravityKernels() override;
virtual void addMomentumBoussinesqKernels() override;

virtual void addINSInletBC() override;
virtual void addINSOutletBC() override;
virtual void addINSWallsBC() override;
virtual void addInletBC() override;
virtual void addOutletBC() override;
virtual void addWallsBC() override;

virtual bool hasForchheimerFriction() const override { return false; };

Expand Down
Loading