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

[Mapping] Map Vector/Matrix Variables #12386

Closed ddiezrod closed 2 months ago

ddiezrod commented 2 months ago

I'm working on a project where we want to map STRESSES (Vector variable) from one model part to another to use it as Initial Stresses for another simulation.

I have found (please correct me if Im wrong) that Mapper works only with doubles and array_1d with size 3. (See https://github.com/KratosMultiphysics/Kratos/blob/d759e7f2bc72f4507506b1fd610f8c900a5ee08b/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h#L156 and https://github.com/KratosMultiphysics/Kratos/blob/d759e7f2bc72f4507506b1fd610f8c900a5ee08b/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h#L172)

I understand that one of the difficulties for this is that you cannot know the size of the Vector in advance until you ask the node. I only see two ways to solve this:

Pinging everyone to hear their opinions @KratosMultiphysics/altair @KratosMultiphysics/technical-committee @philbucher @KratosMultiphysics/implementation-committee

matekelemen commented 2 months ago

I'd go with the second option (extend the interface with array_1d<double,6>).

I think we could also go with a limited support for "dynamic" arrays by extending the interface with bounded_array. Sure, it's a lot of overhead but it's definitely safer (and maybe even faster) than asking the size of each node's Vector (or, god forbid, assuming all nodes have Vectors of the same size).

ddiezrod commented 2 months ago

@matekelemen I think I'm going to start with the second option as there is no harm in it, but we can maybe try to think about something else for the future.

jcotela commented 2 months ago

Just a note: the mapper works with variable components (which are Variable<double> internally) so you can already kind-of support other array types. I have already used that in the past to map array_1d<double, 6> variables one component at a time. You just need to loop over components on your side when calling the map function (which is the same the mapper already does for array-3 anyway)

ddiezrod commented 2 months ago

@jcotela hmm you are right, I think I will just use it like that, thanks for the suggestion!

ddiezrod commented 2 months ago

I'll close this for the moment as @jcotela solution with the workaround of creating an array_1d6 intermediary variable is working fine for me. Thanks all!

philbucher commented 1 month ago

Yep as @jcotela says I am anyway doing it component wise: https://github.com/KratosMultiphysics/Kratos/blob/master/applications/MappingApplication/custom_mappers/interpolative_mapper_base.h#L473-L487

If you want the interface could be extended to array_1d6, I dont see a problem as long as it is fixed size Dynamic size is different though, not sure if it is worth the pain and hassle ...