Skip to content

Commit 4931670

Browse files
committed
Clean up input enums
1 parent 93d7507 commit 4931670

15 files changed

+158
-164
lines changed

src/porofluid_pressure_based/4C_porofluid_pressure_based_dyn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void porofluidmultiphase_dyn(int restart)
3838
// access the problem
3939
Global::Problem* problem = Global::Problem::instance();
4040

41-
// print problem type and logo
41+
// print problem type
4242
if (Core::Communication::my_mpi_rank(comm) == 0)
4343
{
4444
std::cout << "###################################################" << std::endl;

src/porofluid_pressure_based/4C_porofluid_pressure_based_input.cpp

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "4C_inpar_bio.hpp"
1111
#include "4C_io_input_spec_builders.hpp"
1212

13+
#include <Teuchos_Time.hpp>
14+
1315
FOUR_C_NAMESPACE_OPEN
1416

1517
void PoroPressureBased::set_valid_parameters_porofluid(
@@ -37,17 +39,18 @@ void PoroPressureBased::set_valid_parameters_porofluid(
3739

3840
deprecated_selection<TimeIntegrationScheme>("TIMEINTEGR",
3941
{
40-
{"One_Step_Theta", timeint_one_step_theta},
42+
{"One_Step_Theta", TimeIntegrationScheme::one_step_theta},
4143
},
42-
{.description = "Time Integration Scheme", .default_value = timeint_one_step_theta}),
44+
{.description = "Time Integration Scheme",
45+
.default_value = TimeIntegrationScheme::one_step_theta}),
4346

4447
deprecated_selection<CalcError>("CALCERROR",
4548
{
46-
{"No", calcerror_no},
47-
{"error_by_function", calcerror_byfunction},
49+
{"No", CalcError::no},
50+
{"error_by_function", CalcError::by_function},
4851
},
4952
{.description = "compute error compared to analytical solution",
50-
.default_value = calcerror_no}),
53+
.default_value = CalcError::no}),
5154

5255
parameter<int>("CALCERRORNO",
5356
{.description = "function number for porofluidmultiphase error computation",
@@ -77,11 +80,11 @@ void PoroPressureBased::set_valid_parameters_porofluid(
7780
// parameters for finite difference check
7881
deprecated_selection<FdCheck>("FDCHECK",
7982
{
80-
{"none", fdcheck_none},
81-
{"global", fdcheck_global},
83+
{"none", FdCheck::none},
84+
{"global", FdCheck::global},
8285
},
8386
{.description = "flag for finite difference check: none, local, or global",
84-
.default_value = fdcheck_none}),
87+
.default_value = FdCheck::none}),
8588
parameter<double>("FDCHECKEPS",
8689
{.description = "dof perturbation magnitude for finite difference check (1.e-6 "
8790
"seems to work very well, whereas smaller values don't)",
@@ -115,25 +118,25 @@ void PoroPressureBased::set_valid_parameters_porofluid(
115118

116119
deprecated_selection<VectorNorm>("VECTORNORM_RESF",
117120
{
118-
{"L1", PoroPressureBased::norm_l1},
119-
{"L1_Scaled", PoroPressureBased::norm_l1_scaled},
120-
{"L2", PoroPressureBased::norm_l2},
121-
{"Rms", PoroPressureBased::norm_rms},
122-
{"Inf", PoroPressureBased::norm_inf},
121+
{"L1", VectorNorm::l1},
122+
{"L1_Scaled", VectorNorm::l1_scaled},
123+
{"L2", VectorNorm::l2},
124+
{"Rms", VectorNorm::rms},
125+
{"Inf", VectorNorm::inf},
123126
},
124127
{.description = "type of norm to be applied to residuals",
125-
.default_value = PoroPressureBased::norm_l2}),
128+
.default_value = VectorNorm::l2}),
126129

127130
deprecated_selection<VectorNorm>("VECTORNORM_INC",
128131
{
129-
{"L1", PoroPressureBased::norm_l1},
130-
{"L1_Scaled", PoroPressureBased::norm_l1_scaled},
131-
{"L2", PoroPressureBased::norm_l2},
132-
{"Rms", PoroPressureBased::norm_rms},
133-
{"Inf", PoroPressureBased::norm_inf},
132+
{"L1", VectorNorm::l1},
133+
{"L1_Scaled", VectorNorm::l1_scaled},
134+
{"L2", VectorNorm::l2},
135+
{"Rms", VectorNorm::rms},
136+
{"Inf", VectorNorm::inf},
134137
},
135138
{.description = "type of norm to be applied to residuals",
136-
.default_value = PoroPressureBased::norm_l2}),
139+
.default_value = VectorNorm::l2}),
137140

138141
// Iterationparameters
139142
parameter<double>(
@@ -145,25 +148,25 @@ void PoroPressureBased::set_valid_parameters_porofluid(
145148

146149
deprecated_selection<InitialField>("INITIALFIELD",
147150
{
148-
{"zero_field", initfield_zero_field},
149-
{"field_by_function", initfield_field_by_function},
150-
{"field_by_condition", initfield_field_by_condition},
151+
{"zero_field", InitialField::zero},
152+
{"field_by_function", InitialField::by_function},
153+
{"field_by_condition", InitialField::by_condition},
151154
},
152-
{.description = "Initial Field for transport problem",
153-
.default_value = initfield_zero_field}),
155+
{.description = "Initial Field for the porofluid problem",
156+
.default_value = InitialField::zero}),
154157

155158
parameter<int>(
156159
"INITFUNCNO", {.description = "function number for scalar transport initial field",
157160
.default_value = -1}),
158161

159-
deprecated_selection<DivContAct>("DIVERCONT",
162+
deprecated_selection<DivergenceAction>("DIVERCONT",
160163
{
161-
{"stop", divcont_stop},
162-
{"continue", divcont_continue},
164+
{"stop", DivergenceAction::stop},
165+
{"continue", DivergenceAction::continue_anyway},
163166
},
164167
{.description =
165168
"What to do with time integration when Newton-Raphson iteration failed",
166-
.default_value = divcont_stop}),
169+
.default_value = DivergenceAction::stop}),
167170

168171
parameter<int>(
169172
"FLUX_PROJ_SOLVER", {.description = "Number of linear solver used for L2 projection",
@@ -172,11 +175,11 @@ void PoroPressureBased::set_valid_parameters_porofluid(
172175

173176
deprecated_selection<FluxReconstructionMethod>("FLUX_PROJ_METHOD",
174177
{
175-
{"none", gradreco_none},
176-
{"L2_projection", gradreco_l2},
178+
{"none", FluxReconstructionMethod::none},
179+
{"L2_projection", FluxReconstructionMethod::l2},
177180
},
178181
{.description = "Flag to (de)activate flux reconstruction.",
179-
.default_value = gradreco_none}),
182+
.default_value = FluxReconstructionMethod::none}),
180183

181184
// functions used for domain integrals
182185
parameter<std::string>("DOMAININT_FUNCT",

src/porofluid_pressure_based/4C_porofluid_pressure_based_input.hpp

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,65 +24,57 @@ FOUR_C_NAMESPACE_OPEN
2424
namespace PoroPressureBased
2525
{
2626
/// time integration schemes
27-
enum TimeIntegrationScheme
27+
enum class TimeIntegrationScheme
2828
{
29-
timeint_one_step_theta
29+
one_step_theta
3030
};
3131

3232
/// compute error compared to analytical solution
33-
enum CalcError
33+
enum class CalcError
3434
{
35-
calcerror_no,
36-
calcerror_byfunction
37-
};
38-
39-
//! type of norm to check for convergence
40-
enum ConvNorm
41-
{
42-
convnorm_abs, //!< absolute norm
43-
convnorm_rel, //!< relative norm
44-
convnorm_mix //!< mixed absolute-relative norm
35+
no,
36+
by_function
4537
};
4638

4739
//! type of vector norm used for error/residual vectors
48-
enum VectorNorm
40+
enum class VectorNorm
4941
{
50-
norm_undefined,
51-
norm_l1, //!< L1/linear norm
52-
norm_l1_scaled, //!< L1/linear norm scaled by length of vector
53-
norm_l2, //!< L2/Euclidean norm
54-
norm_rms, //!< root mean square (RMS) norm
55-
norm_inf //!< Maximum/infinity norm
42+
undefined,
43+
l1, //!< L1/linear norm
44+
l1_scaled, //!< L1/linear norm scaled by length of vector
45+
l2, //!< L2/Euclidean norm
46+
rms, //!< root mean square (RMS) norm
47+
inf //!< Maximum/infinity norm
5648
};
5749

5850
/// type of finite difference check
59-
enum FdCheck
51+
enum class FdCheck
6052
{
61-
fdcheck_none,
62-
fdcheck_global
53+
none,
54+
global
6355
};
6456

65-
/// initial field for scalar transport problem
66-
enum InitialField
57+
/// initial field
58+
enum class InitialField
6759
{
68-
initfield_zero_field,
69-
initfield_field_by_function,
70-
initfield_field_by_condition
60+
zero,
61+
by_function,
62+
by_condition
7163
};
7264

7365
/// Handling of non-converged nonlinear solver
74-
enum DivContAct
66+
enum class DivergenceAction
7567
{
76-
divcont_stop, ///< abort simulation
77-
divcont_continue ///< continue nevertheless
68+
stop, ///< abort simulation
69+
continue_anyway ///< continue anyway
7870
};
7971

8072
//! reconstruction type of gradients (e.g. velocity gradient)
81-
enum FluxReconstructionMethod
73+
enum class FluxReconstructionMethod
8274
{
83-
gradreco_none,
75+
none,
8476
// gradreco_spr, super-convergent patch recovery not activated yet
85-
gradreco_l2
77+
l2
8678
};
8779

8880
/// set the valid parameters

src/porofluid_pressure_based/4C_porofluid_pressure_based_timint_implicit.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PoroPressureBased::TimIntImpl::TimIntImpl(std::shared_ptr<Core::FE::Discretizati
6868
poroparams_, "FLUX_PROJ_METHOD")),
6969
fluxreconsolvernum_(poroparams_.get<int>("FLUX_PROJ_SOLVER")),
7070
divcontype_(
71-
Teuchos::getIntegralValue<PoroPressureBased::DivContAct>(poroparams_, "DIVERCONT")),
71+
Teuchos::getIntegralValue<PoroPressureBased::DivergenceAction>(poroparams_, "DIVERCONT")),
7272
fdcheck_(Teuchos::getIntegralValue<PoroPressureBased::FdCheck>(poroparams_, "FDCHECK")),
7373
fdcheckeps_(poroparams_.get<double>("FDCHECKEPS")),
7474
fdchecktol_(poroparams_.get<double>("FDCHECKTOL")),
@@ -498,7 +498,7 @@ void PoroPressureBased::TimIntImpl::time_loop()
498498
// -------------------------------------------------------------------
499499
// evaluate error for problems with analytical solution
500500
// -------------------------------------------------------------------
501-
if (calcerr_ != PoroPressureBased::calcerror_no) evaluate_error_compared_to_analytical_sol();
501+
if (calcerr_ != CalcError::no) evaluate_error_compared_to_analytical_sol();
502502

503503
// -------------------------------------------------------------------
504504
// output of solution
@@ -1357,7 +1357,7 @@ bool PoroPressureBased::TimIntImpl::abort_nonlin_iter(
13571357
{
13581358
switch (divcontype_)
13591359
{
1360-
case PoroPressureBased::divcont_continue:
1360+
case DivergenceAction::continue_anyway:
13611361
{
13621362
// warn if itemax is reached without convergence, but proceed to
13631363
// next timestep...
@@ -1373,7 +1373,7 @@ bool PoroPressureBased::TimIntImpl::abort_nonlin_iter(
13731373
}
13741374
break;
13751375
}
1376-
case PoroPressureBased::divcont_stop:
1376+
case DivergenceAction::stop:
13771377
{
13781378
FOUR_C_THROW("Porofluid multiphase solver not converged in itemax steps!");
13791379
break;
@@ -1509,7 +1509,7 @@ void PoroPressureBased::TimIntImpl::reconstruct_solid_pressures()
15091509
*--------------------------------------------------------------------------*/
15101510
void PoroPressureBased::TimIntImpl::reconstruct_flux()
15111511
{
1512-
if (fluxrecon_ == PoroPressureBased::gradreco_none) return;
1512+
if (fluxrecon_ == FluxReconstructionMethod::none) return;
15131513

15141514
// create the parameters for the discretization
15151515
Teuchos::ParameterList eleparams;
@@ -1527,7 +1527,7 @@ void PoroPressureBased::TimIntImpl::reconstruct_flux()
15271527

15281528
switch (fluxrecon_)
15291529
{
1530-
case PoroPressureBased::gradreco_l2:
1530+
case FluxReconstructionMethod::l2:
15311531
{
15321532
const auto& solverparams = Global::Problem::instance()->solver_params(fluxreconsolvernum_);
15331533
flux_ = Core::FE::compute_nodal_l2_projection(*discret_, "phinp_fluid", numvec, eleparams,
@@ -1804,7 +1804,7 @@ inline void PoroPressureBased::TimIntImpl::increment_time_and_step()
18041804
*----------------------------------------------------------------------*/
18051805
void PoroPressureBased::TimIntImpl::evaluate_error_compared_to_analytical_sol()
18061806
{
1807-
if (calcerr_ == PoroPressureBased::calcerror_no) return;
1807+
if (calcerr_ == CalcError::no) return;
18081808
FOUR_C_THROW("Error calculation not yet implemented! Element evaluation is missing.");
18091809

18101810
// create the parameters for the error calculation
@@ -1815,7 +1815,7 @@ void PoroPressureBased::TimIntImpl::evaluate_error_compared_to_analytical_sol()
18151815

18161816
switch (calcerr_)
18171817
{
1818-
case PoroPressureBased::calcerror_byfunction:
1818+
case CalcError::by_function:
18191819
{
18201820
const int errorfunctnumber = poroparams_.get<int>("CALCERRORNO");
18211821
if (errorfunctnumber < 1)
@@ -1898,7 +1898,7 @@ void PoroPressureBased::TimIntImpl::evaluate()
18981898
assemble_mat_and_rhs();
18991899

19001900
// perform finite difference check on time integrator level
1901-
if (fdcheck_ == PoroPressureBased::fdcheck_global) fd_check();
1901+
if (fdcheck_ == FdCheck::global) fd_check();
19021902

19031903
// Apply Dirichlet Boundary Condition
19041904
prepare_system_for_newton_solve();
@@ -2005,13 +2005,13 @@ void PoroPressureBased::TimIntImpl::set_initial_field(
20052005
{
20062006
switch (init)
20072007
{
2008-
case PoroPressureBased::initfield_zero_field:
2008+
case InitialField::zero:
20092009
{
20102010
phin_->put_scalar(0.0);
20112011
phinp_->put_scalar(0.0);
20122012
break;
20132013
}
2014-
case PoroPressureBased::initfield_field_by_function:
2014+
case InitialField::by_function:
20152015
{
20162016
const Core::LinAlg::Map* dofrowmap = discret_->dof_row_map();
20172017

@@ -2043,7 +2043,7 @@ void PoroPressureBased::TimIntImpl::set_initial_field(
20432043

20442044
break;
20452045
}
2046-
case PoroPressureBased::initfield_field_by_condition:
2046+
case InitialField::by_condition:
20472047
{
20482048
// set initial field for ALL existing scatra fields in condition
20492049
const std::string field = "PoroMultiFluid";

src/porofluid_pressure_based/4C_porofluid_pressure_based_timint_implicit.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,26 @@ namespace PoroPressureBased
230230

231231
/*--- set, prepare, and predict ------------------------------------------*/
232232

233-
//! set the initial scalar field phi
234-
virtual void set_initial_field(
235-
const PoroPressureBased::InitialField init, //!< type of initial field
236-
const int startfuncno //!< number of spatial function
233+
//! set the initial field
234+
virtual void set_initial_field(InitialField init, //!< type of initial field
235+
int startfuncno //!< number of spatial function
237236
);
238237

239238
/*--- query and output ---------------------------------------------------*/
240239

241-
//! return pressure field at time n+1
240+
//! return primary variable at time n+1
242241
std::shared_ptr<const Core::LinAlg::Vector<double>> phinp() const override { return phinp_; }
243242

244-
//! return scalar field phi at time n
243+
//! return primary variable at time n
245244
std::shared_ptr<const Core::LinAlg::Vector<double>> phin() const override { return phin_; }
246245

247-
//! return time derivative of scalar field phi at time n
246+
//! return time derivative of the primary variable at time n
248247
std::shared_ptr<const Core::LinAlg::Vector<double>> phidtn() const { return phidtn_; }
249248

250-
//! return time derivative of scalar field phi at time n+1
249+
//! return time derivative of the primary variable at time n+1
251250
std::shared_ptr<const Core::LinAlg::Vector<double>> phidtnp() const { return phidtnp_; }
252251

253-
//! return scalar field history
252+
//! return primary variable history
254253
std::shared_ptr<const Core::LinAlg::Vector<double>> hist() const { return hist_; }
255254

256255
//! return solid pressure field
@@ -526,7 +525,7 @@ namespace PoroPressureBased
526525
const int fluxreconsolvernum_;
527526

528527
//! what to do when nonlinear solution fails
529-
enum PoroPressureBased::DivContAct divcontype_;
528+
enum PoroPressureBased::DivergenceAction divcontype_;
530529

531530
//! flag for finite difference check
532531
const PoroPressureBased::FdCheck fdcheck_;

0 commit comments

Comments
 (0)