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