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
Cfield.h
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 CFIELD
25 #define CFIELD
26 
27 
28 //-----------------------------CIMG_NETCDF-------------------------------
29 #define cimg_plugin "plugins/add_fileformat.h"
30 #define cimg_use_netcdf
31 
32 #ifdef cimg_use_netcdf
33  #include "../NetCDF.Tool/struct_parameter_NetCDF.h"
34 // #define cimg_plugin1 "plugins/netcdf_file_format4CImg1.h"
35 // #define cimglist_plugin1 "plugins/netcdf_file_format4CImgList1.h"
36  #define cimg_plugin2 "plugins/netcdf_file_format4CImg2.h"
37  #define cimglist_plugin2 "plugins/netcdf_file_format4CImgList2.h"
38  #include "../CImg.Tool/CImg_NetCDF.h"
39 #endif
40 //-----------------------------CIMG_NETCDF-------------------------------
41 
42 #include "Cimage.h"
43 #include "Cmesh_factory.h"
44 #include "CshapeFunction_factory.h"
45 
50 template<typename T, typename Timg>
51 class Cfield
52 {
53 
54  public:
55 
56  std::string class_name;
57  std::string m_type;
58  std::string m_name;
59 
60  int num_dim, m_threadNB;
61  int _3D;
62  bool m_verbose;
63  const char* m_paramPath;
64 
65  //optionnal
66  CImgList<T> m_field;
67  CImg<T> m_res;
68  CImg<T> m_def;
69  //store identified eigenvalues
70  CImgList<T> m_mode;
71  std::vector<T> m_meanRes;
72 
74  CImg<T> m_correlogram;
75  int m_storeCorrelo;
76  CshapeFunction<T,Timg>* m_pShape;
77  std::vector<T> m_ref;
78 
79  Cfield()
80  {// constructor
81 
82  class_name = "Field : mother";
83 
84  #pragma omp parallel
85  {//total number of thread required for reduction process
86  m_threadNB = omp_get_num_threads();
87  }
88 
89  }
90 
91 // ~Cfield()
92 // {// destructor
93  /*problem segmentation fault */
94 // delete m_pShape;
95 
96 // }
97 
98  virtual void init(CParameterNetCDF &fp) = 0;
99 
100  virtual void exec(const Cimage<Timg> &oImage, const Cmesh<T,Timg> &oMesh, CImgList<T> &modes_prev, CshapeFunction<T,Timg> &oShape_prev, const std::vector<T> &ref_prev, const CImgList<T> &nodes_prev)
101  {// assign this->m_fields, this->m_residue and this->m_def according to previous data and current mesh
102 
103  _3D = oMesh._3D;
104 
105  if (oImage.m_storeDef){m_def.assign(oImage.cur_dim(0), oImage.cur_dim(1), oImage.cur_dim(2), oImage.cur_dim(3), 0);}
106  if (oImage.m_storeRes){m_res.assign(oImage.cur_dim(0), oImage.cur_dim(1), oImage.cur_dim(2), oImage.cur_dim(3), 0);}
107  if (oImage.m_storeField){m_field.assign(oMesh.num_var(), oImage.cur_dim(0), oImage.cur_dim(1), oImage.cur_dim(2), oImage.cur_dim(3), 0);}
108 
109  m_meanRes.clear();
110 
111  if (!modes_prev.is_empty())
112  {
114  if (this->m_verbose){printf("Data projection\n");}
115  project(oMesh, oImage, modes_prev, oShape_prev, ref_prev, nodes_prev, this->m_mode);
116 
117  }
118  else
119  {
120  if (this->m_verbose){printf("The data are initialized to zero\n");}
121  }
122 
123 // oImage.save_netcdf(this->m_mode,"project",0);
124 
125  }
126 
127  virtual void project(const Cmesh<T,Timg> &oMesh, const Cimage<Timg> &oImage, CImgList<T> &modes_prev, CshapeFunction<T,Timg> &oShape_prev, const std::vector<T> &ref_prev, const CImgList<T> &nodes_prev, CImgList<T> &modes_cur) = 0;
128 
129 
130 
131  int num_var()
132  {// List of components
133 
134  return m_mode.size();
135 
136  }
137 
138  int grid_dims(const int &i)
139  {// grid dimensions
140 
141  switch(i)
142  {
143  case 0: return m_mode[0].width(); break;
144  case 1: return m_mode[0].height(); break;
145  case 2: return m_mode[0].depth(); break;
146  case 3: return m_mode[0].spectrum(); break;
147  default:
148  {
149  std::cerr<<class_name<<"::"<<__func__<<": error: id="<<i<<" is unknown as CImg dimensions\n"<<std::flush;
150  return 0;
151  }
152  }
153  }
154 
155 
156 };
157 
158 #endif
load image and mask from cdl and store fields. It also creates a resized version of data in the case ...
virtual void exec(const Cimage< Timg > &oImage, const Cmesh< T, Timg > &oMesh, CImgList< T > &modes_prev, CshapeFunction< T, Timg > &oShape_prev, const std::vector< T > &ref_prev, const CImgList< T > &nodes_prev)
Definition: Cfield.h:100
This is the mother class of shape function objets (virtual pure).
Definition: CshapeFunction.h:48
CImg< T > m_correlogram
to improve, they shouldn't be here//
Definition: Cfield.h:74
Definition: Cmesh.h:61
Definition: Cfield.h:51
Definition: Cimage.h:57