KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1k stars 243 forks source link

[Question] KRATOS_DOF_TRAITS macro? #11852

Open matekelemen opened 9 months ago

matekelemen commented 9 months ago

What on earth does KRATOS_DOF_TRAITS do?

https://github.com/KratosMultiphysics/Kratos/blob/86d7a1f8fe1ffbc14029a0fb89a94bf7b2ccd2f0/kratos/includes/dof.h#L32-L57

Preprocessor output:

template<class TDataType, class TVariableType = Variable<TDataType> >
struct DofTrait
{
    static const int Id;
};

template<class TDataType> struct DofTrait<TDataType, Variable<TDataType> >{ static const int Id = 0; };

It also appears in Dof::GetReference, but I have even less clue what it does there.

https://github.com/KratosMultiphysics/Kratos/blob/86d7a1f8fe1ffbc14029a0fb89a94bf7b2ccd2f0/kratos/includes/dof.h#L457-L481

Any hints?

roigcarlo commented 9 months ago

Seems the only function it has is to initialize the DofId to 0 ( I suspect this is legacy from pre C++11 where initializing static member variables directly inside the class was problematic)

Looks a little convoluted with modern C++. Imo, we could just change it to Id=0 in the definition and move along.

Ping @pooyan-dadvand.