/home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/ABLMesoscaleForcing.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/wind_energy/ABLMesoscaleForcing.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
ABLMesoscaleForcing.H
Go to the documentation of this file.
1#ifndef ABLMESOSCALEFORCING_H
2#define ABLMESOSCALEFORCING_H
3
4#include <string>
5#include "AMReX_REAL.H"
6#include "AMReX_Array.H"
7#include "AMReX_Vector.H"
8#include "amr-wind/CFDSim.H"
9
10using namespace amrex::literals;
11
12namespace amr_wind {
13
15{
16
17public:
18 ABLMesoscaleForcing(const CFDSim& sim, const std::string& identifier);
19
21
22 static void invert_mat(
23 const amrex::Array2D<amrex::Real, 0, 3, 0, 3>& m,
24 amrex::Array2D<amrex::Real, 0, 3, 0, 3>& im);
25
26protected:
28 const amrex::AmrCore& m_mesh;
29
30 int m_idx_time{0};
31 int m_axis{2};
32
33 // inputs
34 std::string m_forcing_scheme;
35 amrex::Real m_gain_coeff{
36 0.2_rt}; // relaxation factor for all forcing schemes
37 bool m_debug{false}; // print out profiles for debugging
38 bool m_tendency{false}; // check if tendency forcing
39
40 // planar averaging heights
41 amrex::Vector<amrex::Real> m_zht;
42 int m_nht{0}; // set by derived ABLMesoForcing[Mom|Temp] class
43
44 //
45 // regression vars for indirect forcing
46 //
47 // int m_ind_polyOrder;
48 int m_norm_zmax = 0;
49 amrex::Real m_scaleFact =
50 1.0e-3_rt; // to improve conditioning of regression matrix
51
52 amrex::Array2D<amrex::Real, 0, 3, 0, 3> m_im_zTz;
53
54 // - regression weighting profile inputs (these may be constant or the
55 // instantaneous value, if forcing_transition is specified)
60
61 amrex::Vector<amrex::Real> m_weighting_heights;
62 amrex::Vector<amrex::Real> m_weighting_values;
64
65 // - W(z) at planar averaging heights, for regression
66 amrex::Vector<amrex::Real> m_W;
67
68 // - blending heights (constant over time if the transition height is also
69 // constant)
70 amrex::Vector<amrex::Real> m_blending_heights;
71 amrex::Vector<amrex::Real> m_blending_values;
72
73 // - weights at planar averaging heights, for blending indirect-direct
74 // forcing profiles
75 amrex::Vector<amrex::Real> m_blend;
76
77 //
78 // weighting profile manipulation
79 //
80 void set_transition_weighting(); // will override weighting profile
81 void
82 update_weights(); // interpolate current profile to planar averaging heights
83
84 //
85 // forcing profile manipulation
86 //
88 {
89 return (amrex::toLower(m_forcing_transition) != "none");
90 }
91
93 {
94 // - check if m_forcing_transition ends with "Constant"
95 if (m_forcing_transition.length() < 8) {
96 return false;
97 }
98 return (
99 0 == m_forcing_transition.compare(
100 m_forcing_transition.length() - 8, 8, "Constant"));
101 }
102
103 // - slope varies linearly from the actual gradient of the forcing profile
104 // at m_transition_height
105 // to 0 at (m_transition_height + m_transition_thicnkess)
106 void constant_forcing_transition(amrex::Vector<amrex::Real>& error);
107
108 // - blend between a lower and upper forcing profile; the blending fraction
109 // is assumed to be
110 // equal to W(z), but this is not a requirement; W=1 and W=0 correspond to
111 // the lower and upper profiles, respectively
112 void blend_forcings(
113 const amrex::Vector<amrex::Real>& lower,
114 const amrex::Vector<amrex::Real>& upper,
115 amrex::Vector<amrex::Real>& error);
116};
117
118} // namespace amr_wind
119
120#endif
bool m_update_transition_height
Definition ABLMesoscaleForcing.H:58
void blend_forcings(const amrex::Vector< amrex::Real > &lower, const amrex::Vector< amrex::Real > &upper, amrex::Vector< amrex::Real > &error)
Definition ABLMesoscaleForcing.cpp:281
amrex::Vector< amrex::Real > m_zht
Definition ABLMesoscaleForcing.H:41
bool have_forcing_transition()
Definition ABLMesoscaleForcing.H:87
const SimTime & m_time
Definition ABLMesoscaleForcing.H:27
std::string m_forcing_transition
Definition ABLMesoscaleForcing.H:56
ABLMesoscaleForcing(const CFDSim &sim, const std::string &identifier)
Definition ABLMesoscaleForcing.cpp:14
void set_transition_weighting()
Definition ABLMesoscaleForcing.cpp:89
bool forcing_to_constant()
Definition ABLMesoscaleForcing.H:92
amrex::Real m_transition_height
Definition ABLMesoscaleForcing.H:57
amrex::Vector< amrex::Real > m_weighting_heights
Definition ABLMesoscaleForcing.H:61
amrex::Real m_scaleFact
Definition ABLMesoscaleForcing.H:49
int m_nht
Definition ABLMesoscaleForcing.H:42
bool m_debug
Definition ABLMesoscaleForcing.H:37
amrex::Vector< amrex::Real > m_blend
Definition ABLMesoscaleForcing.H:75
void indirect_forcing_init()
Definition ABLMesoscaleForcing.cpp:130
std::string m_forcing_scheme
Definition ABLMesoscaleForcing.H:34
bool m_user_specified_weighting
Definition ABLMesoscaleForcing.H:63
amrex::Vector< amrex::Real > m_blending_values
Definition ABLMesoscaleForcing.H:71
int m_axis
Definition ABLMesoscaleForcing.H:31
bool m_tendency
Definition ABLMesoscaleForcing.H:38
int m_norm_zmax
Definition ABLMesoscaleForcing.H:48
const amrex::AmrCore & m_mesh
Definition ABLMesoscaleForcing.H:28
amrex::Real m_gain_coeff
Definition ABLMesoscaleForcing.H:35
amrex::Array2D< amrex::Real, 0, 3, 0, 3 > m_im_zTz
Definition ABLMesoscaleForcing.H:52
int m_idx_time
Definition ABLMesoscaleForcing.H:30
void update_weights()
Definition ABLMesoscaleForcing.cpp:111
amrex::Vector< amrex::Real > m_W
Definition ABLMesoscaleForcing.H:66
static void invert_mat(const amrex::Array2D< amrex::Real, 0, 3, 0, 3 > &m, amrex::Array2D< amrex::Real, 0, 3, 0, 3 > &im)
Definition ABLMesoscaleForcing.cpp:175
amrex::Vector< amrex::Real > m_blending_heights
Definition ABLMesoscaleForcing.H:70
amrex::Vector< amrex::Real > m_weighting_values
Definition ABLMesoscaleForcing.H:62
void constant_forcing_transition(amrex::Vector< amrex::Real > &error)
Definition ABLMesoscaleForcing.cpp:224
amrex::Real m_transition_thickness
Definition ABLMesoscaleForcing.H:59
Definition CFDSim.H:54
Definition SimTime.H:33
This test case is intended as an evaluation of the momentum advection scheme.
Definition BCInterface.cpp:10