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_rigidBody.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_RIGIDBODY
25 #define CSHAPEFUNCTION_GLOBAL_RIGIDBODY
26 
35 #include "CshapeFunction_global.h"
36 
40 template<typename T,typename Timg>
42 {
43 
44  public:
45 
46  std::vector<int> m_modRB;//Required RigidBody modes
47  std::vector<int> m_range;//mode range
48 
50  {//constructor
51 
52  this->class_name = "CshapeFunction_global_rigidBody";
53 
54  }
55 
56  virtual void init(CParameterNetCDF &fp)
57  {//fill m_modRB vector with the indice of required Rigid Body modes from parameter.nc
58 
59  //look for the entire set of required modes.
61 
62  //identify the RigidBody modes withins this->m_mods[] and store them within m_modRB[]
63  m_modRB.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] == "Tx"){m_modRB.push_back(i);m_range.push_back(0);}
69  if (this->m_mods[i] == "Ty"){m_modRB.push_back(i);m_range.push_back(1);}
70  if (this->m_mods[i] == "Tz"){m_modRB.push_back(i);m_range.push_back(2);}
71  if (this->m_mods[i] == "Rz"){m_modRB.push_back(i);m_range.push_back(3);}
72  if (this->m_mods[i] == "Ry"){m_modRB.push_back(i);m_range.push_back(4);}
73  if (this->m_mods[i] == "Rx"){m_modRB.push_back(i);m_range.push_back(5);}
74  }
75 
76  if (this->m_verbose){std::cout<<"\tmodes RB : [ ";for (int i=0; i<m_modRB.size(); i++){std::cout<<m_modRB[i]<<" ";}std::cout<<"]\n";}
77  if (this->m_verbose){std::cout<<"\trang RB : [ ";for (int i=0; i<m_range.size(); i++){std::cout<<m_range[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 rigid body modes at coordonate (x,y,z)
83 
84  set(x, m_modRB, m_range, N);
85 
86  }
87 
88  void set(const std::vector<T> &x, const std::vector<int> &md, const std::vector<int> &rg, CImgList<T> &N)
89  {
90 
91  cimglist_for(N,dim)
92  {//for every dimensions
93 
94  for(int mode=0; mode<md.size(); mode++)
95  {//for every modes
96 
97  N[dim][md[mode]] = shape(dim, rg[mode], x);
98  }
99 
100  }
101 
102  }
103 
104  T shape(const int &dim, const int &range, const std::vector<T> &x)
105  {//return shape
106 
107  switch(dim)
108  {
109 
110  case 0:
111  switch(range)
112  {
113  case 0: return 1; break;
114  case 1: return 0; break;
115  case 2: return 0; break;
116  case 3: return -x[1]; break;
117  case 4: return x[2]; break;
118  case 5: return 0; break;
119  default:
120  {
121  std::cerr<<this->class_name<<"::"<<": error: mode="<<range<<" is unknown\n"<<std::flush;
122  return 0;
123  }
124 
125  }; break;
126  case 1:
127  switch(range)
128  {
129  case 0: return 0; break;
130  case 1: return 1; break;
131  case 2: return 0; break;
132  case 3: return x[0]; break;
133  case 4: return 0; break;
134  case 5: return -x[2]; break;
135  default:
136  {
137  std::cerr<<this->class_name<<"::"<<": error: mode="<<range<<" is unknown\n"<<std::flush;
138  return 0;
139  }
140  }; break;
141  case 2:
142  switch(range)
143  {
144  case 0: return 0; break;
145  case 1: return 0; break;
146  case 2: return 1; break;
147  case 3: return 0; break;
148  case 4: return -x[0]; break;
149  case 5: return x[1]; break;
150  default:
151  {
152  std::cerr<<this->class_name<<"::"<<": error: mode="<<range<<" is unknown\n"<<std::flush;
153  return 0;
154  }
155  }; break;
156  default:
157  {
158  std::cerr<<this->class_name<<"::"<<": error: dim="<<dim<<" is unknown\n"<<std::flush;
159  return 0;
160  }
161 
162  }
163 
164  }
165 
166 };
167 
168 #endif
This is the mother class of global shape function objets (virtual pure). The vector which stores the ...
Definition: CshapeFunction_global.h:40
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