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
985 stars 242 forks source link

[Core] Add Accessor for Table Derivatives #12472

Open matekelemen opened 2 weeks ago

matekelemen commented 2 weeks ago

Add an Accessor that fetches the derivatives from a table instead of the values. Example use case is getting stiffnesses from a displacement-force table.

AlejandroCornejo commented 1 week ago

Do you think that we can generalize the original Table accessor to include your case? @RiccardoRossi

RiccardoRossi commented 1 week ago

Hi, i am not sure about how to achieve this without inducing a performance penalty...

@matekelemen how would you achieve that?

RiccardoRossi commented 1 week ago

Hi, i am not sure about how to achieve this without inducing a performance penalty...

@matekelemen how would you achieve that?

to answer myself, maybe we could template it in a "option" to be either get_value or get_derivative

AlejandroCornejo commented 1 week ago

Hi, i am not sure about how to achieve this without inducing a performance penalty... @matekelemen how would you achieve that?

to answer myself, maybe we could template it in a "option" to be either get_value or get_derivative

like

template <SizeType DerivativeOrder = 0>
GetValue()
{
    if constexpr (DerivativeOrder  == 0) {
        return table.GetValue();
    } else if constexpr  (DerivativeOrder  == 1)
     return table.GetFirstDerivative();
}

(disregard notation errors, just to get the point) ?

rubenzorrilla commented 1 week ago

Hi, i am not sure about how to achieve this without inducing a performance penalty... @matekelemen how would you achieve that?

to answer myself, maybe we could template it in a "option" to be either get_value or get_derivative

like

template <SizeType DerivativeOrder = 0>
GetValue()
{
    if constexpr (DerivativeOrder  == 0) {
        return table.GetValue();
    } else if constexpr  (DerivativeOrder  == 1)
     return table.GetFirstDerivative();
}

(disregard notation errors, just to get the point) ?

This will result in different GetValue methods when exporting to Python.

AlejandroCornejo commented 1 week ago

Hi, i am not sure about how to achieve this without inducing a performance penalty... @matekelemen how would you achieve that?

to answer myself, maybe we could template it in a "option" to be either get_value or get_derivative

like

template <SizeType DerivativeOrder = 0>
GetValue()
{
    if constexpr (DerivativeOrder  == 0) {
        return table.GetValue();
    } else if constexpr  (DerivativeOrder  == 1)
     return table.GetFirstDerivative();
}

(disregard notation errors, just to get the point) ?

This will result in different GetValue methods when exporting to Python.

yes indeed

RiccardoRossi commented 1 week ago

Looks ok to me

El lun, 24 jun 2024, 14:40, Alejandro Cornejo @.***> escribió:

Hi, i am not sure about how to achieve this without inducing a performance penalty... @matekelemen https://github.com/matekelemen how would you achieve that?

to answer myself, maybe we could template it in a "option" to be either get_value or get_derivative

like

template GetValue() { if constexpr (DerivativeOrder == 0) { return table.GetValue(); } else if constexpr (DerivativeOrder == 1) return table.GetFirstDerivative(); }

(disregard notation errors, just to get the point) ?

This will result in different GetValue methods when exporting to Python.

yes indeed

— Reply to this email directly, view it on GitHub https://github.com/KratosMultiphysics/Kratos/pull/12472#issuecomment-2186485529, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5PWENOYTAVY2C3NIZ5NJTZJAHSDAVCNFSM6AAAAABJTOMCXGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBWGQ4DKNJSHE . You are receiving this because you were mentioned.Message ID: @.***>