'Coarse and fine grid

Please see below the code and guide me.

I want to create coarse and fine mesh. For 1st set of loop and given limits, result is 5*3 matrix (coarse mesh). For the 2nd set of loop and given limits, result is 5*3 matrix. However, I want to convert the 2nd result in 10*6 matrix without changing the limit (if (i >= 0 && i < 5 && j >= 2 && j <5)).

Code is as follows:

#define NX 5
#define NY 5

using namespace std;

int main() 
{
    for (int i = 0; i < NX; i++)
    {
        for (int j = 0; j < NY; j++)
        {
        if (i >= 0 && i < 5  && j >= 0 && j <3)
            {
            int count =i* NY+ j;
            cout << count << " ";
            }
        }
    }

    for (int i = 0; i < NX; i++)
    {
        for (int j = 0; j < NY; j++)
        {
        if (i >= 0 && i < 5  && j >= 2 && j <5)
            {
            int count =i* NY+ j;
            cout << count << " ";
            }
        }
    }
}

first set of loop, result is

0 1 2
5 6 7
10 11 12
15 16 17
20 21 22

2nd set of loop, result is

2 3 4
7 8 9
12 13 14
17 18 19
22 23 24

I want the 2nd loop result to be 10*6 matrix to generate fine mesh.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source