YaDICs  V04.14.a
Yet another Digital Image Correlation software: platform dedicated to 2/3D Fluid and Solid kinematics field measurements.
 All Classes Files Functions Variables Pages
CshapeFunction_global_blade.h
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (C) 2012, The YaDICs Project Developers.
3  * See the COPYRIGHT file at the top-level directory of this distribution ./COPYRIGHT.
4  * See ./COPYING file for copying and redistribution conditions.
5  *
6  * This file is part of YaDICs.
7  * YaDICs is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * YaDICs is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with YaDICs. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Information about how to use the software are provided at http://yadic.univ-lille1.fr/
21  **********************************************************************/
22 
23 
24 #ifndef CSHAPEFUNCTION_GLOBAL_BLADE
25 #define CSHAPEFUNCTION_GLOBAL_BLADE
26 
27 
37 
43 template<typename T,typename Timg>
45 {
46 
47  public:
48 
49  std::vector<int> m_modFlex, m_modComp;//Required Flexion and compresion modes
50  std::vector<float> m_lambda;
51  int m_p;
52  float m_length;//power for shape function and blade length
53 
55  {// constructor
56 
57  this->class_name = "CshapeFunction_global_blade";
58 
59  }
60 
61  virtual void init(CParameterNetCDF &fp)
62  {//fill m_modFlex vector with the indice of required Blade Flexion mode from parameter.nc
63 
65 
66  m_modFlex.clear();
68  for (int i=0; i<this->m_mods.size(); i++){if (this->m_mods[i].compare(0,1,"F") == 0){m_modFlex.push_back(i);}}
69  if (this->m_verbose){std::cout<<"\tmodes Flex : [ ";for (int i=0; i<m_modFlex.size(); i++){std::cout<<m_modFlex[i]<<" ";}std::cout<<"]\n";}
70 
71  m_modComp.clear();
73  for (int i=0; i<this->m_mods.size(); i++){if (this->m_mods[i].compare(0,1,"C") == 0){m_modComp.push_back(i);}}
74  if (this->m_verbose){std::cout<<"\tmodes Comp : [ ";for (int i=0; i<m_modComp.size(); i++){std::cout<<m_modComp[i]<<" ";}std::cout<<"]\n";}
75 
76  std::string att_name("length");
77  int error = fp.loadAttribute(att_name,m_length);
78  if (this->m_verbose){std::cout<<"\tblade length : "<<m_length<<"\n";}
79 
80  m_p = 1;//power
81 
82  lambda(m_modFlex);
83 
84  }
85 
86  virtual void exec(const CImg<Timg> &box, const std::vector<T> &x, CImgList<T> &N)
87  {// assign CImgList<T> N[dimensions][modes] for required Flexion and RB modes at coordonate (x,y,z)
88 
96  double xx = x[0];
97  double yy = x[1];
98 
99  //fill Rigid Body mods
101 
102  //fill flexion mods
103  for (int mod=0; mod<m_modFlex.size(); mod++)
104  {
105  N(0, m_modFlex[mod]) = -yy*dflex( xx, mod, m_lambda, m_length, m_p);
106  N(1, m_modFlex[mod]) = flex(xx, mod, m_lambda, m_length, m_p);
107  }
108 
109  //fill compression mods
110  for (int mod=0; mod<m_modComp.size(); mod++)
111  {
112  N(0, m_modComp[mod]) = compress( xx, mod, m_length, m_p);
113  N(1, m_modComp[mod]) = 0;
114  }
115 
116  }
117 
118  void lambda(const std::vector<int> &modFlex)
119  {// fill lambda vector
120 
126  m_lambda.clear();
127 
128  for (int i=0; i<modFlex.size(); i++)
129  {
130  switch(i)
131  {
132  case 0: m_lambda.push_back(1.8751); break;
133  case 1: m_lambda.push_back(4.6940); break;
134  default: m_lambda.push_back( (2*(i+1)-1)*this->m_pi/2 ); break;//periodic solution over 2 mode
135  }
136  }
137 
138  }
139 
140  T flex(const double &x, const int &mod, const std::vector<float> &lambda, const float &L, const int &pow = 1) const
141  {// implement flexion shape function for a specific mode
142 
143  double a(lambda[mod]/L);
144 
145  return std::pow( std::sin(a*x) - std::sinh(a*x) - (std::sin(lambda[mod]) + std::sinh(lambda[mod]))/(std::cos(lambda[mod]) + std::cosh(lambda[mod]))*(std::cos(a*x) - std::cosh(a*x)) ,pow);
146 
147  }
148 
149  T dflex(const double &x, const int &mod, const std::vector<float> &lambda, const float &L, const int &pow = 1) const
150  {// implement the first derivative of flexion shape function for a specific mode
151 
152  double a(lambda[mod]/L);
153 
154  return std::pow( a*(std::cos(a*x) - std::cosh(a*x) - (std::sin(lambda[mod]) + std::sinh(lambda[mod]))/(std::cos(lambda[mod]) + std::cosh(lambda[mod]))*(-std::sin(a*x)-std::sinh(a*x)) ), pow);
155 
156  }
157 
158  T d2flex(const double &x, const int &mod, const std::vector<float> &lambda, const float &L, const int &pow = 1) const
159  {// implement the second derivative of flexion shape function for a specific mode
160 
161  T a(lambda[mod]/L);
162 
163  return std::pow( std::pow(a,2) * ( -std::sin(a*x) - std::sinh(a*x) - (std::sin(lambda[mod])+std::sinh(lambda[mod]))/(std::cos(lambda[mod])+std::cosh(lambda[mod])) *(-std::cos(a*x)-std::cosh(a*x)) ), pow);
164 
165  }
166 
167  T compress(const double &x, const int &mod, const float &L, const int &pow = 1) const
168  {// implement compression shape function for a specific mode
169 
170  return std::pow(std::sin((2*(mod+1)-1)*this->m_pi/2*x/L) ,pow);
171 
172  }
173 
174 };
175 
176 #endif
void lambda(const std::vector< int > &modFlex)
Definition: CshapeFunction_global_blade.h:118
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_blade.h:61
virtual void exec(const CImg< Timg > &box, const std::vector< T > &x, CImgList< T > &N)
Definition: CshapeFunction_global_blade.h:86
This class implements Rigid Body shape functions available for 2D and 3D cases. It implements 3 rigid...
Definition: CshapeFunction_global_rigidBody.h:41
This class implements Blade flexion and compression shape functions available for 2D case (CL encastr...
Definition: CshapeFunction_global_blade.h:44
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_rigidBody.h:56