1 #include "lift_drag.hpp" 5 template <
int dim,
int nspecies,
int nstate,
typename real,
typename MeshType>
10 :
Functional<dim,nspecies,nstate,real,MeshType>(dg_input)
11 , functional_type(functional_type)
12 , euler_fad_fad(dynamic_cast< Physics::Euler<dim,nspecies,dim+2,
FadFadType> &>(*(this->physics_fad_fad)))
13 , angle_of_attack(this->euler_fad_fad.angle_of_attack)
14 , rotation_matrix(initialize_rotation_matrix(this->angle_of_attack))
15 , lift_vector(initialize_lift_vector(this->rotation_matrix))
16 , drag_vector(initialize_drag_vector(this->rotation_matrix))
17 , force_dimensionalization_factor(this->initialize_force_dimensionalization_factor())
18 , all_parameters(dg_input->all_parameters)
20 switch(functional_type) {
21 case Functional_types::lift : this->force_vector = lift_vector;
break;
22 case Functional_types::drag : this->force_vector = drag_vector;
break;
27 template <
int dim,
int nspecies,
int nstate,
typename real,
typename MeshType>
31 const double ref_length = this->euler_fad_fad.ref_length;
32 const double dynamic_pressure_inf = this->euler_fad_fad.dynamic_pressure_inf;
34 return 1.0 / (ref_length * dynamic_pressure_inf);
37 template <
int dim,
int nspecies,
int nstate,
typename real,
typename MeshType>
41 dealii::Tensor<2,dim,double> rotation_matrix;
42 if constexpr (dim == 1) {
46 rotation_matrix[0][0] = cos(angle_of_attack);
47 rotation_matrix[0][1] = -sin(angle_of_attack);
48 rotation_matrix[1][0] = sin(angle_of_attack);
49 rotation_matrix[1][1] = cos(angle_of_attack);
51 if constexpr (dim == 3) {
52 rotation_matrix[0][2] = 0.0;
53 rotation_matrix[1][2] = 0.0;
55 rotation_matrix[2][0] = 0.0;
56 rotation_matrix[2][1] = 0.0;
57 rotation_matrix[2][2] = 1.0;
60 return rotation_matrix;
63 template <
int dim,
int nspecies,
int nstate,
typename real,
typename MeshType>
67 dealii::Tensor<1,dim,double> lift_direction;
68 lift_direction[0] = 0.0;
69 lift_direction[1] = 1.0;
71 if constexpr (dim == 1) {
74 if constexpr (dim == 3) {
75 lift_direction[2] = 0.0;
78 dealii::Tensor<1,dim,double> vec;
79 vec = rotation_matrix * lift_direction;
84 template <
int dim,
int nspecies,
int nstate,
typename real,
typename MeshType>
88 dealii::Tensor<1,dim,double> drag_direction;
89 drag_direction[0] = 1.0;
90 drag_direction[1] = 0.0;
92 if constexpr (dim == 1) {
95 if constexpr (dim == 3) {
96 drag_direction[2] = 0.0;
99 dealii::Tensor<1,dim,double> vec;
100 vec = rotation_matrix * drag_direction;
105 template <
int dim,
int nspecies,
int nstate,
typename real,
typename MeshType>
108 const bool compute_dIdX,
109 const bool compute_d2I)
116 #if PHILIP_DIM!=1 && PHILIP_SPECIES==1 Files for the baseline physics.
virtual real evaluate_functional(const bool compute_dIdW=false, const bool compute_dIdX=false, const bool compute_d2I=false)
Evaluates the functional derivative with respect to the solution variable.
dealii::Tensor< 1, dim, double > initialize_drag_vector(const dealii::Tensor< 2, dim, double > &rotation_matrix)
Initialize drag vector with given rotation matrix based on angle of attack.
dealii::Tensor< 2, dim, double > initialize_rotation_matrix(const double angle_of_attack)
Initialize rotation matrix based on given angle of attack.
dealii::Tensor< 1, dim, double > initialize_lift_vector(const dealii::Tensor< 2, dim, double > &rotation_matrix)
Initialize lift vector with given rotation matrix based on angle of attack.
double initialize_force_dimensionalization_factor()
Compute force dimensionalization factor.
Functional_types
Switch between lift and drag functional types.
DGBase is independent of the number of state variables.
real evaluate_functional(const bool compute_dIdW=false, const bool compute_dIdX=false, const bool compute_d2I=false) override
Destructor.
LiftDragFunctional(std::shared_ptr< DGBase< dim, nspecies, real, MeshType >> dg_input, const Functional_types functional_type)
Constructor.
Sacado::Fad::DFad< FadType > FadFadType
Sacado AD type that allows 2nd derivatives.