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.

Home Page:https://kratosmultiphysics.github.io/Kratos/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Mapping] Map Vector/Matrix Variables

ddiezrod opened this issue · comments

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

and
const Variable< array_1d<double, 3> >& rOriginVariable,
)

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:

  • ask for the Vector size to every node and check if size is the same for every node (and throw an error if that is not the case)
  • add the array_1d<double,6> interface in the mapper, and I use a variable of this type as an intermediary for STRESSES.

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

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).

@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.

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)

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

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!

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 ...