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_homogeneous.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_HOMOGENEOUS
25 #define CSHAPEFUNCTION_GLOBAL_HOMOGENEOUS
26 
36 
40 template<typename T,typename Timg>
42 {
43 
44  public:
45 
46  std::vector<int> m_modHD;//Required Homogeneous Deformation modes
47  std::vector<int> m_range;//mode range
48 
50  {// constructor
51 
52  this->class_name = "CshapeFunction_global_homogeneous";
53 
54  }
55 
56  virtual void init(CParameterNetCDF &fp)
57  {//fill m_modHD vector with the indice of required Homogeneous deformation modes from parameter.nc
58 
59  //look for the Rigid Body set of required modes.
61 
62  //identify the Homogeneous Deformation modes withins this->m_mods[] and store them within m_modHD[]
63  m_modHD.clear();
64  m_range.clear();
66  for (int i=0; i<this->m_mods.size(); i++)
67  {//checking for rigid body modes
68  if (this->m_mods[i] == "D"){m_modHD.push_back(i);m_range.push_back(0);}
69  if (this->m_mods[i] == "Exx"){m_modHD.push_back(i);m_range.push_back(1);}
70  if (this->m_mods[i] == "Eyy"){m_modHD.push_back(i);m_range.push_back(2);}
71  if (this->m_mods[i] == "Ezz"){m_modHD.push_back(i);m_range.push_back(3);}
72  if (this->m_mods[i] == "Exy"){m_modHD.push_back(i);m_range.push_back(4);}
73  if (this->m_mods[i] == "Exz"){m_modHD.push_back(i);m_range.push_back(5);}
74  if (this->m_mods[i] == "Eyz"){m_modHD.push_back(i);m_range.push_back(6);}
75  }
76 
77  if (this->m_verbose){std::cout<<"\tmodes HD : [ ";for (int i=0; i<m_modHD.size(); i++){std::cout<<m_modHD[i]<<" ";}std::cout<<"]\n";}
78 
79  }
80 
81  virtual void exec(const CImg<Timg> &box, const std::vector<T> &x, CImgList<T> &N)
82  {// assign CImgList<T> N[dimensions][modes] for required Homogeneous Deformation and RB modes at coordonate (x,y,z)
83 
84  //RigidBody modes
86 
87  set(x, m_modHD, m_range, N);
88 
89  }
90 
91  void set(const std::vector<T> &x, const std::vector<int> &md, const std::vector<int> &rg, CImgList<T> &N)
92  {//should be improved, copy of CshapeFunction_global_rigidbody<T,Timg>::set
93 
94  cimglist_for(N,dim)
95  {//for every dimensions
96 
97  for(int mode=0; mode<md.size(); mode++)
98  {//for every modes
99 
100  N[dim][md[mode]] = shape(dim, rg[mode], x);
101  }
102 
103  }
104 
105  }
106 
107  T shape(const int &dim, const int &range, const std::vector<T> &x)
108  {//return shape
109 
110 
111  switch(dim)
112  {
113 
114  case 0:
115  switch(range)
116  {
117  case 0: return x[0]; break;
118  case 1: return x[0]; break;
119  case 2: return 0; break;
120  case 3: return 0; break;
121  case 4: return x[1]; break;
122  case 5: return x[2]; break;
123  case 6: return 0; break;
124  default:
125  {
126  std::cerr<<this->class_name<<"::"<<": error: mode="<<range<<" is unknown\n"<<std::flush;
127  return 0;
128  }
129 
130  }; break;
131  case 1:
132  switch(range)
133  {
134  case 0: return x[1]; break;
135  case 1: return 0; break;
136  case 2: return x[1]; break;
137  case 3: return 0; break;
138  case 4: return x[0]; break;
139  case 5: return 0; break;
140  case 6: return x[2]; break;
141  default:
142  {
143  std::cerr<<this->class_name<<"::"<<": error: mode="<<range<<" is unknown\n"<<std::flush;
144  return 0;
145  }
146  }; break;
147  case 2:
148  switch(range)
149  {
150  case 0: return x[2]; break;
151  case 1: return 0; break;
152  case 2: return 0; break;
153  case 3: return x[2]; break;
154  case 4: return 0; break;
155  case 5: return x[2]; break;
156  case 6: return x[1]; break;
157  default:
158  {
159  std::cerr<<this->class_name<<"::"<<": error: mode="<<range<<" is unknown\n"<<std::flush;
160  return 0;
161  }
162  }; break;
163  default:
164  {
165  std::cerr<<this->class_name<<"::"<<": error: dim="<<dim<<" is unknown\n"<<std::flush;
166  return 0;
167  }
168 
169  }
170 
171  }
172 
173 };
174 
175 #endif
This class implements Homogeneous deformation shape functions available for 2D and 3D cases...
Definition: CshapeFunction_global_homogeneous.h:41
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_homogeneous.h:56
This class implements Rigid Body shape functions available for 2D and 3D cases. It implements 3 rigid...
Definition: CshapeFunction_global_rigidBody.h:41
virtual void init(CParameterNetCDF &fp)
Definition: CshapeFunction_global_rigidBody.h:56