/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
13AMREX_INLINE 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
40AMREX_INLINE 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
73AMREX_INLINE 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
84AMREX_INLINE 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
110AMREX_INLINE FieldState dof_state(const FieldState fstate)
111{
112 return (fstate == FieldState::New) ? FieldState::New : FieldState::Old;
113}
114
115AMREX_INLINE 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 */
AMREX_INLINE bool is_valid_field_name(const std::string &name)
Definition FieldUtils.H:73
AMREX_INLINE amrex::Interpolater * get_interpolation_operator(const FieldInterpolator itype)
Definition FieldUtils.H:85
AMREX_INLINE std::string field_name_with_state(const std::string &fname, const FieldState fstate)
Definition FieldUtils.H:41
AMREX_INLINE amrex::IndexType index_type(const FieldLoc floc)
Definition FieldUtils.H:13
FieldState
Definition FieldDescTypes.H:16
FieldLoc
Definition FieldDescTypes.H:29
FieldInterpolator
Coarse-to-fine field interpolation options.
Definition FieldDescTypes.H:39
@ New
Same as FieldState::NP1.
Definition FieldDescTypes.H:22
@ NP1
Latest state, also aliased to New
Definition FieldDescTypes.H:17
@ NMH
State at (n - 1/2) timestep.
Definition FieldDescTypes.H:21
@ NPH
State at (n + 1/2) (intermediate) timestep.
Definition FieldDescTypes.H:20
@ N
Previous state, also aliased to Old
Definition FieldDescTypes.H:18
@ NM1
State at (n - 1) th timestep.
Definition FieldDescTypes.H:19
@ Old
Same as FieldState::N.
Definition FieldDescTypes.H:23
@ NODE
Node-centered (e.g., for pressure)
Definition FieldDescTypes.H:31
@ ZFACE
Face-centered in z-direction.
Definition FieldDescTypes.H:34
@ XFACE
Face-centered in x-direction (e.g., face normal velocity)
Definition FieldDescTypes.H:32
@ CELL
Cell-centered (default)
Definition FieldDescTypes.H:30
@ YFACE
Face-centered in y-direction.
Definition FieldDescTypes.H:33
@ PiecewiseConstant
Constant across cell.
Definition FieldDescTypes.H:40
@ NodeBilinear
Bilinear nodal interpolation.
Definition FieldDescTypes.H:42
@ FaceLinear
Linear face interpolation.
Definition FieldDescTypes.H:44
@ FaceDivFree
Divergence free face interpolation.
Definition FieldDescTypes.H:43
@ CellConsLinear
Linear interpolation.
Definition FieldDescTypes.H:41
Definition FieldUtils.H:8
AMREX_INLINE FieldState phi_state(const FieldState fstate)
Definition FieldUtils.H:115
AMREX_INLINE FieldState dof_state(const FieldState fstate)
Definition FieldUtils.H:110