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 16 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions framework/include/actions/DumpObjectsAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "Action.h"

/**
* Uses the DumpObjectProblem to output the syntax
*/
class DumpObjectsAction : public Action
{
public:
static InputParameters validParams();

DumpObjectsAction(const InputParameters & params);

virtual void act() override;
};
25 changes: 18 additions & 7 deletions framework/include/problems/DumpObjectsProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ class DumpObjectsProblem : public FEProblemBase
/// output input blocks for all paths
void dumpAllGeneratedSyntax() const;

/// output data in solve
virtual void solve(unsigned int nl_sys_num) override;
/// output data in solve (if ever called)
virtual void solve(unsigned int /*nl_sys_num*/) override {}
virtual void solveLinearSystem(unsigned int /*linear_sys_num*/,
const Moose::PetscSupport::PetscOptions *) override
{
}

// output data (we expect to call this from the DumpObjectsAction)
void printObjects();

virtual void initialSetup() override {}
virtual void advanceState() override {}
Expand Down Expand Up @@ -77,8 +84,6 @@ class DumpObjectsProblem : public FEProblemBase
/// store input syntax to build objects generated by a specific action
std::map<std::string, std::map<std::string, std::string>> _generated_syntax;

std::shared_ptr<DumpObjectsNonlinearSystem> _nl_sys;

/// Whether to include all user-specified parameters in the dump or only parameters that differ from the default value
const bool _include_all_user_specified_params;

Expand All @@ -88,20 +93,25 @@ class DumpObjectsProblem : public FEProblemBase
captureDump(addAuxScalarKernel, "AuxScalarKernels")
captureDump(addAuxVariable, "AuxVariables")
captureDump(addBoundaryCondition, "BCs")
captureDump(addFVBC, "FVBCs")
captureDump(addConstraint, "Constraints")
captureDump(addDamper, "Dampers")
captureDump(addDGKernel, "DGKernels")
captureDump(addDiracKernel, "DiracKernels")
captureDump(addDistribution, "Distributions")
captureDump(addFunction, "Functions")
captureDump(addFunctorMaterial, "FunctorMaterials")
captureDump(addFVBC, "FVBCs")
captureDump(addFVInitialCondition, "FVICs")
captureDump(addFVInterfaceKernel, "FVInterfaceKernels")
captureDump(addFVKernel, "FVKernels")
captureDump(addHDGIntegratedBC, "HDGBCs")
captureDump(addHDGKernel, "HDGKernels")
captureDump(addIndicator, "Adaptivity/Indicators")
captureDump(addInitialCondition, "ICs")
captureDump(addFVInitialCondition, "FVICs")
captureDump(addInterfaceKernel, "InterfaceKernels")
captureDump(addFVInterfaceKernel, "FVInterfaceKernels")
captureDump(addKernel, "Kernels")
captureDump(addLinearFVBC, "LinearFVBCs")
captureDump(addLinearFVKernel, "LinearFVKernels")
captureDump(addMarker, "Adaptivity/Markers")
captureDump(addMaterial, "Materials")
captureDump(addMultiApp, "MultiApps")
Expand All @@ -111,6 +121,7 @@ class DumpObjectsProblem : public FEProblemBase
captureDump(addSampler, "Samplers")
captureDump(addScalarKernel, "ScalarKernels")
captureDump(addTransfer, "Transfers")
captureDump(addTimeIntegrator, "TimeIntegrators")
captureDump(addVariable, "Variables")
captureDump(addVectorPostprocessor, "VectorPostprocessors")
// clang-format off
Expand Down
10 changes: 5 additions & 5 deletions framework/include/problems/FEProblemBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ class FEProblemBase : public SubProblem, public Restartable
* @param linear_sys_num The number of the linear system (1,..,num. of lin. systems)
* @param po The petsc options for the solve, if not supplied, the defaults are used
*/
void solveLinearSystem(const unsigned int linear_sys_num,
const Moose::PetscSupport::PetscOptions * po = nullptr);
virtual void solveLinearSystem(const unsigned int linear_sys_num,
const Moose::PetscSupport::PetscOptions * po = nullptr);

///@{
/**
Expand Down Expand Up @@ -885,9 +885,9 @@ class FEProblemBase : public SubProblem, public Restartable
virtual void addInterfaceMaterial(const std::string & material_name,
const std::string & name,
InputParameters & parameters);
void addFunctorMaterial(const std::string & functor_material_name,
const std::string & name,
InputParameters & parameters);
virtual void addFunctorMaterial(const std::string & functor_material_name,
const std::string & name,
InputParameters & parameters);

/**
* Add the MooseVariables and the material properties that the current materials depend on to the
Expand Down
36 changes: 36 additions & 0 deletions framework/include/systems/DumpObjectsLinearSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "LinearSystem.h"

namespace libMesh
{
template <typename T>
class NumericVector;
}

/**
* Linear system for dumping objects
* TODO: consider creating a base class for LinearSystems to be able to create a more minimal linear
* system. For now the additional code complexity is not worth it
*/
class DumpObjectsLinearSystem : public LinearSystem
{
public:
DumpObjectsLinearSystem(FEProblemBase & problem, const std::string & name);

virtual void solve() override {}
virtual void stopSolve(const ExecFlagType &, const std::set<TagID> &) override {}
virtual bool converged() override { return true; }

protected:
NumericVector<Number> * _dummy;
};
31 changes: 31 additions & 0 deletions framework/src/actions/DumpObjectsAction.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "DumpObjectsAction.h"
#include "DumpObjectsProblem.h"

registerMooseAction("MooseApp", DumpObjectsAction, "dump_objects");

InputParameters
DumpObjectsAction::validParams()
{
InputParameters params = Action::validParams();
return params;
}

DumpObjectsAction::DumpObjectsAction(const InputParameters & params) : Action(params) {}

void
DumpObjectsAction::act()
{
mooseAssert(dynamic_cast<DumpObjectsProblem *>(_problem.get()),
"Problem should be DumpObjectProblem");
if (auto * const dop = dynamic_cast<DumpObjectsProblem *>(_problem.get()); dop)
dop->printObjects();
}
3 changes: 2 additions & 1 deletion framework/src/base/Moose.C
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ registerActions(Syntax & syntax,
{
Registry::registerActionsTo(action_factory, obj_labels);

// TODO: Why is this here?
// Add these actions here so they are always executed last, without setting any dependency
registerTask("dump_objects", false);
registerTask("finish_input_file_output", false);
}

Expand Down
43 changes: 39 additions & 4 deletions framework/src/problems/DumpObjectsProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "DumpObjectsProblem.h"
#include "DumpObjectsAction.h"
#include "DumpObjectsNonlinearSystem.h"
#include "DumpObjectsLinearSystem.h"
#include "AuxiliarySystem.h"
#include "InputParameters.h"
#include <sstream>

#include "libmesh/string_to_enum.h"
Expand All @@ -32,24 +35,56 @@ DumpObjectsProblem::validParams()
true,
"Whether to include all parameters that have been specified by a user in the dump, even if "
"they match the default value of the parameter in the Factory");

// Change the default because any complex solve or executioners needs the problem to perform its
// setup duties (all the calls in initialSetup()) which are skipped by the DumpObjectsProblem
params.addParam<bool>(
"solve",
false,
"Whether to attempt to solve the Problem. This will only cause additional outputs of the "
"objects and their parameters. This is unlikely to succeed with more complex executioners.");
return params;
}

DumpObjectsProblem::DumpObjectsProblem(const InputParameters & parameters)
: FEProblemBase(parameters),
_nl_sys(std::make_shared<DumpObjectsNonlinearSystem>(*this, "nl0")),
_include_all_user_specified_params(getParam<bool>("include_all_user_specified_params"))
{
_nl[0] = _nl_sys;
_solver_systems[0] = std::dynamic_pointer_cast<SolverSystem>(_nl[0]);
// Make dummy systems based on parameters passed
_solver_systems.resize(0);
for (const auto i : index_range(_nl_sys_names))
{
const auto & sys_name = _nl_sys_names[i];
const auto & new_sys = std::make_shared<DumpObjectsNonlinearSystem>(*this, sys_name);
_solver_systems.push_back(new_sys);
_nl[i] = new_sys;
}
for (const auto i : index_range(_linear_sys_names))
{
const auto & sys_name = _linear_sys_names[i];
const auto & new_sys = std::make_shared<DumpObjectsLinearSystem>(*this, sys_name);
_solver_systems.push_back(new_sys);
_linear_systems[i] = new_sys;
}
_aux = std::make_shared<AuxiliarySystem>(*this, "aux0");

// Create a dummy assembly for the systems at hand
newAssemblyArray(_solver_systems);

// Create extra vectors and matrices if any
createTagVectors();

// Create extra solution vectors if any
createTagSolutions();

// Add an action to call printObjects at the end of the action/tasks phase
// NOTE: We previously relied on problem.solve() but some executioners (SIMPLE in NavierStokes) do
// not support this
auto action_params = _app.getActionFactory().getValidParams("DumpObjectsAction");
action_params.applyParameters(parameters);
auto dump_objects_action =
_app.getActionFactory().create("DumpObjectsAction", "dump_objects", action_params);
_app.actionWarehouse().addActionBlock(dump_objects_action);
}

std::string
Expand Down Expand Up @@ -144,7 +179,7 @@ DumpObjectsProblem::dumpVariableHelper(const std::string & system,
}

void
DumpObjectsProblem::solve(unsigned int)
DumpObjectsProblem::printObjects()
{
const auto path = getParam<std::string>("dump_path");
if (path != "all")
Expand Down
16 changes: 16 additions & 0 deletions framework/src/systems/DumpObjectsLinearSystem.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "DumpObjectsLinearSystem.h"
#include "FEProblemBase.h"

DumpObjectsLinearSystem::DumpObjectsLinearSystem(FEProblemBase & problem, const std::string & name)
: LinearSystem(problem, name), _dummy(nullptr)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Navier Stokes Fluid Heat Transfer / WCNSLinearFVFluidHeatTransferPhysics

!syntax description /Physics/NavierStokes/FluidHeatTransferSegregated/WCNSLinearFVFluidHeatTransferPhysics

## Equation

This [Physics](Physics/index.md) object creates the kernels and boundary conditions to solve the advection-diffusion
equation for the fluid temperature.
For free flow in a non-porous media:

!equation
\dfrac{\partial \rho h}{\partial t} + \nabla \cdot (\rho h \mathbf{v}) - \nabla \cdot (k_f \nabla T_f) - Q + \alpha (T_f - T_{ambient}) = 0

!alert note
Porous medium treatment is not implemented for the linear finite volume discretization.

where:

- $h$ is the fluid enthalpy, computed from the specific heat $c_p$
- $\rho$ is the fluid density
- $\epsilon$ is the porosity
- $T_f$ is the fluid temperature
- \mathbf{v} is the advecting velocity (clean flow)
- \mathbf{v}_D is the advecting superficial velocity (porous media flow)
- $kappa_f$ the fluid effective thermal conductivity
- $Q$ is the source term, corresponding to energy deposited directly in the fluid
- $\alpha$ is the ambient convection volumetric heat transfer coefficient
- $T_{ambient}$ is the ambient temperature

The kernels created for flow in a non-porous medium are:

- [LinearFVEnergyAdvection.md] for advection
- [LinearFVDiffusion.md] for diffusion
- [LinearFVSource.md] for the energy source term
- [LinearFVVolumetricHeatTransfer.md] for the volumetric ambient convection term, if present


## Automatically defined variables

The `WCNSLinearFVFluidHeatTransferPhysics` automatically sets up the variables which are
necessary for solving the energy transport equation:

- Fluid temperature:

!listing include/base/NS.h line=std::string T_fluid

For the default names of other variables used in this action, visit [this site](include/base/NS.h).


## Coupling with other Physics

The heat advection equation can be solved concurrently with the flow equations by combining both the `WCNSLinearFVFluidHeatTransferPhysics`
and the [WCNSLinearFVFlowPhysics.md] using the [!param](/Physics/NavierStokes/FluidHeatTransferSegregated/WCNSLinearFVFluidHeatTransferPhysics/coupled_flow_physics) parameter.

!syntax parameters /Physics/NavierStokes/FluidHeatTransferSegregated/WCNSLinearFVFluidHeatTransferPhysics

!syntax inputs /Physics/NavierStokes/FluidHeatTransferSegregated/WCNSLinearFVFluidHeatTransferPhysics

!syntax children /Physics/NavierStokes/FluidHeatTransferSegregated/WCNSLinearFVFluidHeatTransferPhysics
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Navier Stokes Fluid Heat Transfer Physics

This syntax was created for the [WCNSLinearFVFlowPhysics.md] `Physics`.
This syntax was created for the [WCNSFVFluidHeatTransferPhysics.md] `Physics`.
The additional nesting is intended to allow the definition of multiple instances of this `Physics`,
with different block restrictions.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Navier Stokes Linear finite volume Fluid Heat Transfer Physics

This syntax was created for the [WCNSLinearFVFluidHeatTransferPhysics.md] `Physics`.
The additional nesting is intended to allow the definition of multiple instances of this `Physics`,
with different block restrictions.

!syntax list /Physics/NavierStokes/FluidHeatTransferSegregated objects=True actions=False subsystems=False

!syntax list /Physics/NavierStokes/FluidHeatTransferSegregated objects=False actions=False subsystems=True

!syntax list /Physics/NavierStokes/FluidHeatTransferSegregated objects=False actions=True subsystems=False
Loading