title: Jacobi Iteration object in fluid c++
body: <p>I'm writing a program that calculates the velocity of a certain current around an object like for example a square. Now, I use the Jacobi Iteration method and when I run it the results aren't what I'm expecting. I have no idea what I'am doing wrong. I have 2 classes, one that makes a Grid that I cant adjust, and another that creates an object with a parameter 'voneindig'.</p>
  
  <p>If I make a square and a grid and run the Iterate() function it seems to happen that my square object becomes bigger. ( I get more and more zero's around my original square )</p>
  
  <p>the member function getStatusElement() is a grid I've made with one's where the square is located and zero's elsewhere.</p>
  
  <pre><code>    void Object::Iterate()
  {
  double gem=1, jacobielement, som; //locale variabelen
  double epsilon=pow(10,-5); //convergentiecriterium
  const int d= grid1.GetDimension(); //dimension of the grid
  while(gem &gt; epsilon)
  {
    for( int i = 0; i &lt; d; i++ )
    {
      for( int j = 0; j &lt; d; j++ )
      {
      grid2.SetElement(i,j,grid1.GetElement(i,j));
      }
    }
  
    for(int i=1; i&lt;d-1; ++ i)
    {
      for(int j=1; j&lt;d-1; ++ j)
      {
          if( grid1.getStatusElement(i,j) == 0 )
          {//jacobie
          jacobielement= (grid1.GetElement(i,j+1) + grid1.GetElement(i,j-1) + grid1.GetElement(i+1,j) + grid1.GetElement(i-1,j))/4;
  
          grid1.SetElement(i,j,jacobielement);
          }
      }
    }
    som=0;
    for(int i=0; i&lt;d; ++ i){
      for(int j=0;j&lt;d; ++ j){
      //Convergention
      som=som+std::abs(grid1.GetElement(i,j)-grid2.GetElement(i,j));
      }
    }
    gem= som/pow(d,2);
  }
  }
  </code></pre>
  
  <p>I hope I've given enoug information for this problem, otherwise I can give you all my code.
  Thanks alot!</p>