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
Ccorrelation_opticalFlow_fem_newton.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 CCORRELATION_OPTICALFLOW_FEM_NEWTON
25 #define CCORRELATION_OPTICALFLOW_FEM_NEWTON
26 
27 
39 
40 
41 
42 template<typename T,typename Timg>
44 {
45 
46  public:
47 
49  {// constructor
50 
51  this->class_name = "Correlation : Optical Flow Finite Element Method using Newton strategy";
52 
53  }
54 
55  virtual void solve(CImgList<T> &K, const Cmesh<T,Timg> &oMesh, CImgList<T> &solution)
56  {// K.U = F
57 
59  std::vector<int> count;
60  CImgList<T> Kc(2);
61  count.clear();
62 
63  for (int nd = 0; nd<oMesh.m_node[0].size(); nd++)
64  {
65  if (K[1][oMesh.num_var()*nd] != 0)
66  {
67  count.push_back(nd);
68  }
69  }
70 
71  if (count.size()*oMesh.num_var() != K[0].width())
72  {
74  if(this->m_verbose)
75  {
76  printf("Stiffness tensor densification required (because of mask)\n");
77  std::cout<<"Densification : from "<<count.size()*oMesh.num_var()<<" to "<<K[0].width()<<" \n";
78  }
79 
80  //assign compact k and f matrix
81  Kc[0].assign(count.size()*oMesh.num_var(), count.size()*oMesh.num_var(), 1, 1, 0);
82  Kc[1].assign(1, count.size()*oMesh.num_var(), 1, 1, 0);
83 
84  for (int dim=0; dim<oMesh.num_var(); dim++)
85  {
86  for (int i=0; i<count.size(); i++)
87  {//transfert porous K and F matrix data within compact k and f ones
88  for (int j=0; j<count.size(); j++)
89  {
90  Kc[0](i*oMesh.num_var()+dim,j*oMesh.num_var()+dim) = K[0](count[i]*oMesh.num_var()+dim, count[j]*oMesh.num_var()+dim);
91  }
92  Kc[1][i*oMesh.num_var()+dim] = K[1][count[i]*oMesh.num_var()+dim];
93  }
94  }
95 
96  }
97  else
98  {
99  Kc = K.get_shared();
100  }
101 
102  Kc[1].solve(Kc[0]);
103 
104  for (int node=0; node<count.size(); node++)
105  {//put solution vector in oField.m_mode[dim][node] framework
106  for (int dim=0; dim<oMesh.num_var(); dim++)
107  {
108  solution[dim][count[node]] += Kc[1][node*oMesh.num_var()+dim];
109  }
110  }
111 
112  }
113 
114  virtual void assignG(const Cmesh<T,Timg> &oMesh, CImgList<T> &K, CImgList<T> &Ke)
115  {//assign approriate size for Ke and Fe tensors
116 
118 
119  K[0].assign(oMesh.num_node()*oMesh.num_var(),oMesh.num_node()*oMesh.num_var(),1,1, 0);
120  K[1].assign(1,oMesh.num_node()*oMesh.num_var(),1,1, 0);
121 
122  Ke[0].assign(oMesh.num_mod(),oMesh.num_mod(),oMesh.num_var(),this->m_threadNB, 0);
123  Ke[1].assign(1,oMesh.num_mod(),oMesh.num_var(),this->m_threadNB, 0);
124 
125  }
126 
127  virtual void assembly(const int &thread, const Cmesh<T,Timg> &oMesh, const int &elem, const CImgList<T> &Ke, CImgList<T> &K)
128  {//perform the assembly of K and F
129 
130  //Ke[0] = Ke[modi, modj, dims]
131  //Ke[1] = Fe[1, modi, dims]
132 
133  cimg_forZ(Ke[0], dim)
134  {
135  cimg_forX(Ke[0], modi)
136  {
137  cimg_forY(Ke[0], modj)
138  {
139  #pragma omp critical
140  {
141  K[0](oMesh.m_connect[elem][modi]*Ke[0].depth()+dim,oMesh.m_connect[elem][modj]*Ke[0].depth()+dim) += Ke[0](modi,modj,dim,thread);
142  }
143  }
144 
145  #pragma omp critical
146  {
147  K[1][oMesh.m_connect[elem][modi]*Ke[0].depth()+dim] += Ke[1](0,modi,dim,thread);
148  }
149  }
150  }
151 
152  }
153 
154 
155 };
156 
157 #endif
It implements optical flow strategy for FEM method.
This is the mother class of Optical Flow strategies: It implements different steps required for the i...
Definition: Ccorrelation_opticalFlow.h:53
Definition: Ccorrelation_opticalFlow_fem_newton.h:43
Definition: Cmesh.h:61
virtual void solve(CImgList< T > &K, const Cmesh< T, Timg > &oMesh, CImgList< T > &solution)
Definition: Ccorrelation_opticalFlow_fem_newton.h:55
Definition: Ccorrelation_opticalFlow_fem.h:43