Skip to content

Cleanup bit flags #770

@pcarruscag

Description

@pcarruscag

We have quite a few common booleans we use in many places of the code.
Some of them are very simple, like checking for compressible vs incompressible, or for FSI.
But when we want to express something more complicated like is it SA or SST, is the mesh moving or deforming, is this FEM or FVM or FEA, and so on, things are not so simple anymore and we end up with long conditionals repeated in many places.

Since that logic is all built up from data in config I propose that we create a custom type akin to a bit-field that we can get from config and query whatever flag we want.
We move all the logic of setting up / updating this object to the config so that for example this:

  unsigned short Kind_Solver = config->GetKind_Solver();
  bool flow = ((Kind_Solver == DISC_ADJ_EULER)          ||
               (Kind_Solver == DISC_ADJ_RANS)           ||
               (Kind_Solver == DISC_ADJ_NAVIER_STOKES)  ||
               (Kind_Solver == ADJ_EULER)               ||
               (Kind_Solver == ADJ_NAVIER_STOKES)       ||
               (Kind_Solver == ADJ_RANS));

Can become bool flow = config->GetFlags().flow();, or similar.

If we move this kind of logic to a separate object we can possibly make the config lighter, not so many methods etc.
This flags class can be absolutely tiny if the bits are packed (8 times tinier than storing bools).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions