GRINS-0.8.0
averaged_fan_base.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // This class
28 
29 // GRINS
31 
32 // libMesh
33 
34 namespace GRINS
35 {
36 
37  template<class Mu>
38  AveragedFanBase<Mu>::AveragedFanBase( const std::string& physics_name, const GetPot& input )
39  : IncompressibleNavierStokesBase<Mu>(physics_name,
40  PhysicsNaming::incompressible_navier_stokes(), /* "core" Physics name */
41  input),
42  base_velocity_function(""),
43  local_vertical_function(""),
44  lift_function(""),
45  drag_function(""),
46  chord_function(""),
47  area_swept_function(""),
48  aoa_function("")
49  {
50  this->read_input_options(input);
51  }
52 
53  template<class Mu>
54  void AveragedFanBase<Mu>::read_input_options( const GetPot& input )
55  {
56  this->set_parameter(base_velocity_function, input,
57  "Physics/"+PhysicsNaming::averaged_fan()+"/base_velocity",
58  this->zero_vector_function);
59 
60  if (base_velocity_function.expression() == this->zero_vector_function)
61  libmesh_error_msg("Error! Zero AveragedFan specified!" <<
62  std::endl);
63 
64  this->set_parameter(local_vertical_function, input,
65  "Physics/"+PhysicsNaming::averaged_fan()+"/local_vertical",
66  this->zero_vector_function);
67 
68  if (local_vertical_function.expression() == this->zero_vector_function)
69  libmesh_error_msg("Error! Zero LocalVertical specified!" <<
70  std::endl);
71 
72  this->set_parameter(lift_function, input,
73  "Physics/"+PhysicsNaming::averaged_fan()+"/lift",
74  "0");
75 
76  if (lift_function.expression() == "0")
77  std::cout << "Warning! Zero lift function specified!" << std::endl;
78 
79  this->set_parameter(drag_function, input,
80  "Physics/"+PhysicsNaming::averaged_fan()+"/drag",
81  "0");
82 
83  if (drag_function.expression() == "0")
84  std::cout << "Warning! Zero drag function specified!" << std::endl;
85 
86  this->set_parameter(chord_function, input,
87  "Physics/"+PhysicsNaming::averaged_fan()+"/chord_length",
88  "0");
89 
90  if (chord_function.expression() == "0")
91  libmesh_error_msg("Error! Zero chord function specified!" <<
92  std::endl);
93 
94  this->set_parameter(area_swept_function, input,
95  "Physics/"+PhysicsNaming::averaged_fan()+"/area_swept",
96  "0");
97 
98  if (area_swept_function.expression() == "0")
99  libmesh_error_msg("Error! Zero area_swept_function specified!" <<
100  std::endl);
101 
102  this->set_parameter(aoa_function, input,
103  "Physics/"+PhysicsNaming::averaged_fan()+"/angle_of_attack",
104  "00000");
105 
106  if (aoa_function.expression() == "00000")
107  libmesh_error_msg("Error! No angle-of-attack specified!" <<
108  std::endl);
109  }
110 
111  template<class Mu>
113  ( const libMesh::Point& point,
114  const libMesh::Real time,
115  const libMesh::NumberVectorValue& U,
116  libMesh::NumberVectorValue& F,
117  libMesh::NumberTensorValue *dFdU)
118  {
119  // Find base velocity of moving fan at this point
120  libMesh::DenseVector<libMesh::Number> output_vec(3);
121 
122  base_velocity_function(point, time,
123  output_vec);
124 
125  const libMesh::NumberVectorValue U_B(output_vec(0),
126  output_vec(1),
127  output_vec(2));
128 
129  const libMesh::Number U_B_size = U_B.norm();
130 
131  // If there's no base velocity there's no fan
132  if (!U_B_size)
133  return false;
134 
135  // Normal in fan velocity direction
136  const libMesh::NumberVectorValue N_B =
137  libMesh::NumberVectorValue(U_B/U_B_size);
138 
139  local_vertical_function(point, time,
140  output_vec);
141 
142  // Normal in fan vertical direction
143  const libMesh::NumberVectorValue N_V(output_vec(0),
144  output_vec(1),
145  output_vec(2));
146 
147  // Normal in radial direction (or opposite radial direction,
148  // for fans turning clockwise!)
149  const libMesh::NumberVectorValue N_R = N_B.cross(N_V);
150 
151  // Fan-wing-plane component of local relative velocity
152  const libMesh::NumberVectorValue U_P = U - (U*N_R)*N_R - U_B;
153 
154  const libMesh::Number U_P_size = U_P.norm();
155 
156  // If there's no flow in the fan's frame of reference, there's no
157  // lift or drag. FIXME - should we account for drag in the
158  // out-of-plane direction?
159  if (!U_P_size)
160  return false;
161 
162  // Direction opposing drag
163  const libMesh::NumberVectorValue N_drag =
164  libMesh::NumberVectorValue(-U_P/U_P_size);
165 
166  // Direction opposing lift
167  const libMesh::NumberVectorValue N_lift = N_drag.cross(N_R);
168 
169  // "Forward" velocity
170  const libMesh::Number u_fwd = -(U_P * N_B);
171 
172  // "Upward" velocity
173  const libMesh::Number u_up = U_P * N_V;
174 
175  // If there's no forward or upward velocity we should have already
176  // returned false
177  libmesh_assert (u_up || u_fwd);
178 
179  // Angle WRT fan velocity direction
180  const libMesh::Number part_angle = std::atan2(u_up, u_fwd);
181 
182  // Angle WRT fan chord
183  const libMesh::Number angle = part_angle +
184  aoa_function(point, time);
185 
186  const libMesh::Number C_lift = lift_function(point, angle);
187  const libMesh::Number C_drag = drag_function(point, angle);
188 
189  const libMesh::Number chord = chord_function(point, time);
190  const libMesh::Number area = area_swept_function(point, time);
191 
192  const libMesh::Number v_sq = U_P*U_P;
193 
194  const libMesh::Number LDfactor = 0.5 * this->_rho * v_sq * chord / area;
195  const libMesh::Number lift = C_lift * LDfactor;
196  const libMesh::Number drag = C_drag * LDfactor;
197 
198  // Force
199  F = lift * N_lift + drag * N_drag;
200 
201  if (dFdU)
202  {
203  // FIXME: Jacobians here are very inexact!
204  // Dropping all AoA dependence on U terms!
205  const libMesh::NumberVectorValue LDderivfactor =
206  (N_lift*C_lift+N_drag*C_drag) *
207  this->_rho * chord / area;
208 
209  for (unsigned int i=0; i != 3; ++i)
210  for (unsigned int j=0; j != 3; ++j)
211  (*dFdU)(i,j) = LDderivfactor(i) * U_P(j);
212  }
213 
214  return true;
215  }
216 
217 } // namespace GRINS
218 
219 // Instantiate
220 INSTANTIATE_INC_NS_SUBCLASS(AveragedFanBase);
Physics class for Incompressible Navier-Stokes.
static PhysicsName averaged_fan()
bool compute_force(const libMesh::Point &point, const libMesh::Real time, const libMesh::NumberVectorValue &U, libMesh::NumberVectorValue &F, libMesh::NumberTensorValue *dFdU=NULL)
INSTANTIATE_INC_NS_SUBCLASS(AveragedFanBase)
GRINS namespace.
void read_input_options(const GetPot &input)
Read options from GetPot input file.

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1