/home/runner/work/amr-wind/amr-wind/amr-wind/core/FieldUtils.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/core/FieldUtils.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
FieldUtils.H
Go to the documentation of this file.
1#ifndef FIELDUTILS_H
2#define FIELDUTILS_H
3
5#include "AMReX_MultiFab.H"
6#include "AMReX_Interpolater.H"
7
9
13inline amrex::IndexType index_type(const FieldLoc floc)
14{
15 switch (floc) {
16 case FieldLoc::CELL:
17 return amrex::IndexType::TheCellType();
18
19 case FieldLoc::NODE:
20 return amrex::IndexType::TheNodeType();
21
22 case FieldLoc::XFACE:
23 return amrex::IndexType(amrex::IntVect::TheDimensionVector(0));
24
25 case FieldLoc::YFACE:
26 return amrex::IndexType(amrex::IntVect::TheDimensionVector(1));
27
28 case FieldLoc::ZFACE:
29 return amrex::IndexType(amrex::IntVect::TheDimensionVector(2));
30 }
31
32 // Suppress warnings when compiling with CUDA
33 return amrex::IndexType::TheCellType();
34}
35
40inline std::string
41field_name_with_state(const std::string& fname, const FieldState fstate)
42{
43 switch (fstate) {
44 case FieldState::NP1:
45 return fname;
46
47 case FieldState::N:
48 return fname + "__FS_Old";
49
50 case FieldState::NM1:
51 return fname + "__FS_NM1";
52
53 case FieldState::NPH:
54 return fname + "__FS_NPH";
55
56 case FieldState::NMH:
57 return fname + "__FS_NMH";
58 }
59
60 // Suppress warnings when compiling with CUDA
61 return fname;
62}
63
73inline bool is_valid_field_name(const std::string& name)
74{
75 // Else make sure that our guard is not in the last 8 characters
76 auto found = name.rfind("__FS_");
77 return found == std::string::npos;
78}
79
84inline amrex::Interpolater*
86{
87 switch (itype) {
89 return &amrex::pc_interp;
90
92 return &amrex::cell_cons_interp;
93
95 return &amrex::node_bilinear_interp;
96
98 return &amrex::face_divfree_interp;
99
101 return &amrex::face_linear_interp;
102
103 default:
104 amrex::Abort("Unrecognized FieldInterpolator type");
105 }
106
107 return &amrex::cell_cons_interp;
108}
109
110inline FieldState dof_state(const FieldState fstate)
111{
112 return (fstate == FieldState::New) ? FieldState::New : FieldState::Old;
113}
114
115inline FieldState phi_state(const FieldState fstate)
116{
117 return (fstate == FieldState::Old) ? FieldState::Old : FieldState::NPH;
118}
119
120} // namespace amr_wind::field_impl
121
122#endif /* FIELDUTILS_H */
bool is_valid_field_name(const std::string &name)
Definition FieldUtils.H:73
amrex::Interpolater * get_interpolation_operator(const FieldInterpolator itype)
Definition FieldUtils.H:85
amrex::IndexType index_type(const FieldLoc floc)
Definition FieldUtils.H:13
std::string field_name_with_state(const std::string &fname, const FieldState fstate)
Definition FieldUtils.H:41
FieldLoc
Definition FieldDescTypes.H:27
FieldState
Definition FieldDescTypes.H:14
FieldInterpolator
Definition FieldDescTypes.H:37
@ NODE
Node-centered (e.g., for pressure)
@ ZFACE
Face-centered in z-direction.
@ XFACE
Face-centered in x-direction (e.g., face normal velocity)
@ CELL
Cell-centered (default)
@ YFACE
Face-centered in y-direction.
@ New
Same as FieldState::NP1.
@ NP1
Latest state, also aliased to New
@ NMH
State at (n - 1/2) timestep.
@ NPH
State at (n + 1/2) (intermediate) timestep.
@ N
Previous state, also aliased to Old
@ NM1
State at (n - 1) th timestep.
@ Old
Same as FieldState::N.
@ PiecewiseConstant
Constant across cell.
@ NodeBilinear
Bilinear nodal interpolation.
@ FaceLinear
Linear face interpolation.
@ FaceDivFree
Divergence free face interpolation.
@ CellConsLinear
Linear interpolation.
Definition FieldUtils.H:8
FieldState phi_state(const FieldState fstate)
Definition FieldUtils.H:115
FieldState dof_state(const FieldState fstate)
Definition FieldUtils.H:110