Hi,
I'm trying to create a 2D grid that would allow me to use fluid properties in each cell of the grid, which is defined by a struct.

I have 3 grids:

Grid2D <fluidProperties> grid1;
Grid2D <fluidProperties> grid2;
Grid2D < fluidProperties> grid3;

My struct fluidProperties contains 12 different properties:

struct fluidProperties {

float foo;
float bar;
                 // ...etc.,
}

For each grid, I only want to use 6-8 of the variables contained in fluidProperties. Is there a way I can disable the use of some of the properties, depending on the type of grid I create?

For example, I may not want grid1 to be able to access

grid1.bar

Am I going about it the wrong way? Any help would be appreciated.

Since it appears that your Grid2D is a template class that you then specify by telling it what to use internally, it should be sufficient to declare the actual struct-type you need for each specific grid:

struct fluidProperties1 {
  float foo;
  float bar;
};

struct fluidProperties2 {
  float foo;
};

struct fluidProperties3 {
  float bar;
  float baz;
};

Grid2D<fluidProperties1> grid1;
Grid2D<fluidProperties2> grid2;
Grid2D<fluidProperties2> grid3;

If this isn't what you had in mind, please clarify your use case a bit more.

Thank you, that's an easy enough solution to my problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.