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
1.02k stars 244 forks source link

Retrieving the TEMPERATURE in the CLs #6068

Open thelfer opened 4 years ago

thelfer commented 4 years ago

I woud like to have an example of how to retrieve the temperature in constitutive laws.

AlejandroCornejo commented 4 years ago

Hi! I've been on this in the branch Structural/adding-initial-strain-thermal inside the elastic_isotropic_3d.cpp. In here you'll find the method:

void ElasticIsotropic3D::AddThermalEffect(
    ConstitutiveLaw::Parameters& rValues,
    Vector& rStrainVector
    )

This method is work in progress (I had not time to advance more) but you'll find how to get the nodal TEMPERATURE and how to interpolate them to the Gauss point (const double gauss_point_temperature = ConstitutiveLawUtilities<VoigtSize>:: GetNodalVariableOnIntegrationPoint(TEMPERATURE, rValues);).

Regards,

Alejandro

thelfer commented 4 years ago

Thanks Alejandro. I'll have a look at that. Thomas

thelfer commented 4 years ago

So the magic is here:

    const auto &r_geometry = rValues.GetElementGeometry();
    if (r_geometry[0].SolutionStepsDataHas(TEMPERATURE)) {
          const double gauss_point_temperature = ConstitutiveLawUtilities<VoigtSize>::
                GetNodalVariableOnIntegrationPoint(TEMPERATURE, rValues);

which gives me the temperature at the end of the time step. Great.

This is consistent with how strain is treated. However the temperature must be initialized and the a default value such as 0 is not meaningful (I do work in the SI unit, so the initial temperature is usually 293.15, i.e. standard room temperature).

What could be done about this ?

rubenzorrilla commented 4 years ago

@thelfer you can add an extra process to initialize it in your processes list. The interval of the process must be ' "interval": [0.0,0.0]. I think that this should do the job.

thelfer commented 4 years ago

@rubenzorrilla If I may, an example would be nice to figure out what it means (I must admit that I am a complete Kratos newbie).

loumalouomega commented 4 years ago

So the magic is here:

    const auto &r_geometry = rValues.GetElementGeometry();
    if (r_geometry[0].SolutionStepsDataHas(TEMPERATURE)) {
          const double gauss_point_temperature = ConstitutiveLawUtilities<VoigtSize>::
                GetNodalVariableOnIntegrationPoint(TEMPERATURE, rValues);

which gives me the temperature at the end of the time step. Great.

This is consistent with how strain is treated. However the temperature must be initialized and the a default value such as 0 is not meaningful (I do work in the SI unit, so the initial temperature is usually 293.15, i.e. standard room temperature).

What could be done about this ?

What you mean is to fill the buiffer with meaningful values, we are fixing this in #5901

rubenzorrilla commented 4 years ago

So the magic is here:

    const auto &r_geometry = rValues.GetElementGeometry();
    if (r_geometry[0].SolutionStepsDataHas(TEMPERATURE)) {
          const double gauss_point_temperature = ConstitutiveLawUtilities<VoigtSize>::
                GetNodalVariableOnIntegrationPoint(TEMPERATURE, rValues);

which gives me the temperature at the end of the time step. Great. This is consistent with how strain is treated. However the temperature must be initialized and the a default value such as 0 is not meaningful (I do work in the SI unit, so the initial temperature is usually 293.15, i.e. standard room temperature). What could be done about this ?

What you mean is to fill the buiffer with meaningful values, we are fixing this in #5901

If the time derivatives are not required, I think that there is no need to "properly" fill the buffer. I think this is the case @thelfer is pointing to in here.

rubenzorrilla commented 4 years ago

@rubenzorrilla If I may, an example would be nice to figure out what it means (I must admit that I am a complete Kratos newbie).

{
    "python_module" : "assign_scalar_variable_process",
    "kratos_module" : "KratosMultiphysics",
    "Parameters"    : {
        "model_part_name": "MainModelPart.your_model_part_of_interest",
        "variable_name": "TEMPERATURE",
        "constrained": false,
        "value":  293.15,
        "interval": [0.0,0.0]
    }
}

I think that adding this to your process list can do the job :wink:

thelfer commented 4 years ago

@rubenzorrilla I may be wrong, but I assume that this initializes the temperature before the mehanical application. That's great, but how shall I get this initial value in the CL ? I mean the CL is called at each time step and does not know a priori if it is the firt time or not.

rubenzorrilla commented 4 years ago

I think I didn't get your point. So your idea is to restart the temperature before solving each time step? If this is the case, the same process above should do the work if you change the interval to `"interval: [0.0, "End"]".

thelfer commented 4 years ago

@rubenzorrilla I surely wasn't clear enought. Most solvers provides the temperature at the beginning of the time step and at the end of the time step.This is important for time-variable temperature loading and in partcular coupled thermo-mecanichal resolutions.

I have understood that @AlejandroCornejo showed how to get the temperature at the end of the time step. This means that I need to keep the previous temperature (unless there is a method in Kratos to retrieve this value), but I can't figure out to initialize the "first preceeding value" as the CLs does not know if it is called for the first time or not.

RiccardoRossi commented 4 years ago

Hi Thomas,

you have full access to the nodal time database.

for example geom[0].GetSolutionStepValue(TEMPERATURE,1) gives you back 1 step in the past (0 means the current)

you may also want to take a look at https://github.com/KratosMultiphysics/Kratos/wiki/How-to-Access-DataBase

the DELTA_TIME and TIME can be accessed from the processinfo

On Sat, Dec 14, 2019, 9:54 AM thelfer notifications@github.com wrote:

@rubenzorrilla https://github.com/rubenzorrilla I surely wasn't clear enought. Most solvers provides the temperature at the beginning of the time step and at the end of the time step.This is important for time-variable temperature loading and in partcular coupled thermo-mecanichal resolutions.

I have understood that @AlejandroCornejo https://github.com/AlejandroCornejo showed how to get the temperature at the end of the time step. This means that I need to keep the previous temperature (unless there is a method in Kratos to retrieve this value), but I can't figure out to initialize the "first preceeding value" as the CLs does not know if it is called for the first time or not.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/KratosMultiphysics/Kratos/issues/6068?email_source=notifications&email_token=AB5PWEOHVPNG5Z7AFYBOTP3QYSNLVA5CNFSM4JZLTYUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG354HY#issuecomment-565698079, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5PWEMDL6TJMAXQUEWSDS3QYSNLVANCNFSM4JZLTYUA .

loumalouomega commented 4 years ago

I would like to add a small explanation. GetSolutionStepValue retrieves historical variables stored in the buffer. Depending of the size of you buffer you can store different number of step solutions ass @RiccardoRossi explained. Additionally there are non-historical variables, that are stored with SetValue and retrieved with GetValue. This can be done with elements and conditions too