Kratos icon indicating copy to clipboard operation
Kratos copied to clipboard

Adding VariableUtils method: SetHistoricalVariableToPreviousInfo

Open AlejandroCornejo opened this issue 3 years ago • 6 comments

📝 Description Adding a new VariableUtils method:

    template< class TType >
    void SetHistoricalVariableToPreviousInfo(
        const Variable< TType >& rVariable,
        NodesContainerType& rNodes,
        const int PreviousStep = 1)
    {
        KRATOS_TRY
        block_for_each(rNodes, [&](Node<3> &rNode) {
            rNode.FastGetSolutionStepValue(rVariable) = rNode.FastGetSolutionStepValue(rVariable, PreviousStep);
        });
        KRATOS_CATCH("")
    }

This is closely related to https://github.com/KratosMultiphysics/Kratos/issues/4594

AlejandroCornejo avatar Dec 16 '21 08:12 AlejandroCornejo

If I'm not wrong, the same can be achieved with the CopyModelPartNodalVar. Besides this synchronization is missing.

hmm checking this method, I think that the previous time step issue is missing... Maybe adding DestinationBuffStep should be enough (we do not want equal BuffStep in this case)

AlejandroCornejo avatar Dec 16 '21 08:12 AlejandroCornejo

If I'm not wrong, the same can be achieved with the CopyModelPartNodalVar. Besides this synchronization is missing.

hmm checking this method, I think that the previous time step issue is missing... Maybe adding DestinationBuffStep should be enough (we do not want equal BuffStep in this case)

You're right. I'd do this for the sake of flexibility.

rubenzorrilla avatar Dec 16 '21 09:12 rubenzorrilla

@AlejandroCornejo have you taken a look at these lines?

https://github.com/KratosMultiphysics/Kratos/blob/66535071233657434d36941d6492a48613573dc9/kratos/python/add_model_part_to_python.cpp#L1012

https://github.com/KratosMultiphysics/Kratos/blob/66535071233657434d36941d6492a48613573dc9/kratos/sources/model_part.cpp#L179

If needed, this can be exported to python:

        .def("OverwriteSolutionStepData", [](){ModelPart::OverwriteSolutionStepData(1, 0);})

And this is also interesting: https://github.com/KratosMultiphysics/Kratos/blob/66535071233657434d36941d6492a48613573dc9/kratos/sources/model_part.cpp#L190

miguelmaso avatar Apr 22 '22 16:04 miguelmaso

@AlejandroCornejo have you taken a look at these lines?

https://github.com/KratosMultiphysics/Kratos/blob/66535071233657434d36941d6492a48613573dc9/kratos/python/add_model_part_to_python.cpp#L1012

https://github.com/KratosMultiphysics/Kratos/blob/66535071233657434d36941d6492a48613573dc9/kratos/sources/model_part.cpp#L179

If needed, this can be exported to python:

        .def("OverwriteSolutionStepData", [](){ModelPart::OverwriteSolutionStepData(1, 0);})

And this is also interesting:

https://github.com/KratosMultiphysics/Kratos/blob/66535071233657434d36941d6492a48613573dc9/kratos/sources/model_part.cpp#L190

yeah! Some time ago I needed somethign like that, honestly I do not remember why hah

AlejandroCornejo avatar Apr 25 '22 14:04 AlejandroCornejo

what is the status of this? @AlejandroCornejo @rubenzorrilla

ddiezrod avatar Sep 19 '22 08:09 ddiezrod

the status is "forgotten" haha

AlejandroCornejo avatar Sep 19 '22 09:09 AlejandroCornejo