forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetupDarcySimulation.C
108 lines (92 loc) · 3.83 KB
/
SetupDarcySimulation.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//* 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 "SetupDarcySimulation.h"
// MOOSE includes
#include "FEProblem.h"
#include "AuxiliarySystem.h"
// libMesh includes
#include "libmesh/fe.h"
registerMooseAction("DarcyThermoMechApp", SetupDarcySimulation, "setup_darcy");
InputParameters
SetupDarcySimulation::validParams()
{
InputParameters params = Action::validParams();
params.addParam<VariableName>("pressure", "pressure", "The pressure variable.");
params.addParam<VariableName>("temperature", "temperature", "The temperature variable.");
params.addParam<bool>(
"compute_velocity", true, "Enable the auxiliary calculation of velocity from pressure.");
params.addParam<bool>("compute_pressure", true, "Enable the computation of pressure.");
params.addParam<bool>("compute_temperature", true, "Enable the computation of temperature.");
return params;
}
SetupDarcySimulation::SetupDarcySimulation(const InputParameters & parameters)
: Action(parameters),
_compute_velocity(getParam<bool>("compute_velocity")),
_compute_pressure(getParam<bool>("compute_pressure")),
_compute_temperature(getParam<bool>("compute_temperature"))
{
}
void
SetupDarcySimulation::act()
{
// Actual names of input variables
const std::string pressure = getParam<VariableName>("pressure");
const std::string temperature = getParam<VariableName>("temperature");
// Velocity AuxVariables
if (_compute_velocity && _current_task == "add_aux_variable")
{
InputParameters var_params = _factory.getValidParams("VectorMooseVariable");
var_params.set<MooseEnum>("family") = "MONOMIAL_VEC";
var_params.set<MooseEnum>("order") = "CONSTANT";
_problem->addAuxVariable("VectorMooseVariable", "velocity", var_params);
}
// Velocity AuxKernels
else if (_compute_velocity && _current_task == "add_aux_kernel")
{
InputParameters params = _factory.getValidParams("DarcyVelocity");
params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
params.set<std::vector<VariableName>>("pressure") = {pressure};
params.set<AuxVariableName>("variable") = "velocity";
_problem->addAuxKernel("DarcyVelocity", "velocity", params);
}
// Kernels
else if (_current_task == "add_kernel")
{
// Flags for aux variables
const bool is_pressure_aux = _problem->getAuxiliarySystem().hasVariable(pressure);
const bool is_temperature_aux = _problem->getAuxiliarySystem().hasVariable(temperature);
// Pressure
if (_compute_pressure && !is_pressure_aux)
{
InputParameters params = _factory.getValidParams("DarcyPressure");
params.set<NonlinearVariableName>("variable") = pressure;
_problem->addKernel("DarcyPressure", "darcy_pressure", params);
}
// Temperature
if (_compute_temperature && !is_temperature_aux)
{
{
InputParameters params = _factory.getValidParams("ADHeatConduction");
params.set<NonlinearVariableName>("variable") = temperature;
_problem->addKernel("ADHeatConduction", "heat_conduction", params);
}
{
InputParameters params = _factory.getValidParams("ADHeatConductionTimeDerivative");
params.set<NonlinearVariableName>("variable") = temperature;
_problem->addKernel("ADHeatConductionTimeDerivative", "heat_conduction_time", params);
}
{
InputParameters params = _factory.getValidParams("DarcyAdvection");
params.set<NonlinearVariableName>("variable") = temperature;
params.set<std::vector<VariableName>>("pressure") = {pressure};
_problem->addKernel("DarcyAdvection", "heat_advection", params);
}
}
}
}