Author Topic: Definition of flags in an application  (Read 1021 times)

DanielB

  • Newbie
  • *
  • Posts: 17
Definition of flags in an application
« on: April 11, 2016, 03:03:26 PM »
Hi there,

is there a way to define KRATOS_FLAGS not globally but locally in my application?

If not what is the recommended practice to introduce a nodal flag variable (In my case I want to identify as "is_on_symmetry_plane"). I understand I could define a scalar variable and ask if its 1 or 0 but I was wondering if there is a "cleaner" way.

Thanks and best regards
Daniel

riccardo

  • Global Moderator
  • Newbie
  • *****
  • Posts: 47
Re: Definition of flags in an application
« Reply #1 on: April 11, 2016, 05:03:22 PM »
Hi Daniel,

it is possible to define "local flags" but their usage must be purely local since essentially you are giving a name to a bit, but someone may give another name to same bit somewhere else.
In short my suggestion is NOT to do it.

can u describe a bit better what is the use you would like to make of this info? than maybe we can advise a strategy

cheers
Riccardo

Miguel Angel Celigueta

  • Administrator
  • Newbie
  • *****
  • Posts: 38
Re: Definition of flags in an application
« Reply #2 on: April 11, 2016, 05:15:27 PM »
Hi,
I agree with Riccardo's advice. If you are still curious, in the DEM application we use local flags. They are created using the macros:

 KRATOS_DEFINE_LOCAL_FLAG  (you can find how we use it in DEM_application_variables.h)
 KRATOS_CREATE_LOCAL_FLAG (you can find it in DEM_application.cpp)

The problem arises when you are coupling two different applications, both sharing some nodes and both decided to use the second bit of the flags of the node for their own purpose. For instance, SolidMechanics uses the second bit for IS_CALCULATED, but Thermal uses the second bit for IS_BOUNDARY_CONDITION. If the plan is to use the same object in different applications you can get into trouble.

Best regards,

Miguel Angel

DanielB

  • Newbie
  • *
  • Posts: 17
Re: Definition of flags in an application
« Reply #3 on: April 12, 2016, 10:43:09 AM »
Hi all,

first thank you for that feedback. So I would not go for a flag here.
What I need it for is the following:

I want to have some flags with which I can tag nodes in the modelling process. The nodes shall be tagged such that when i loop over all of them and do some cacluations using nodal quantities, I can identify how I need to do the compuation. E.g. I want to identify a node as "is_symmetry_node" such that I can make sure its surface normal lies within the symmetry plane. Or e.g. I need to identify a node as "to_be_excluded" which allows me to exclude it from my interal compuations (I am doing shape optimization and want to set specific shape_updates or sensitivities zero).

The point is, this is totally a modeling problem and the user will decide in every case if and which points have to be treated in the above mentioned specific manner.

If there is nothing that I can or that I am supposed to use for this straight away, I would just introduce locally some nodal variables and set them 1/0 in the mdpa. That is perfectly fine for me. Any suggestions to do better is warmly welcome though.

Thanks!

Cheers
Daniel

Josep Maria

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 50
Re: Definition of flags in an application
« Reply #4 on: April 12, 2016, 04:14:03 PM »
Hi Daniel,

   Take a look on the global flags definition.  You have to use it carefully, and check if they are used in another application setting them for a different use.
But maybe you can use some of them to set and check the nodes according to your purposes.

Here comes the list of global flags. Common for every application:

      STRUCTURE
      FLUID
      THERMAL
      VISITED
      SELECTED
      BOUNDARY
      INLET
      OUTLET
      SLIP
      INTERFACE
      CONTACT
      TO_SPLIT
      TO_ERASE
      TO_REFINE
      NEW_ENTITY
      OLD_ENTITY
      ACTIVE
      MODIFIED
      RIGID
      SOLID
      MPI_BOUNDARY
      INTERACTION
      ISOLATED
      MASTER
      SLAVE
      INSIDE
      FREE_SURFACE
      BLOCKED
      MARKER

DanielB

  • Newbie
  • *
  • Posts: 17
Re: Definition of flags in an application
« Reply #5 on: April 12, 2016, 05:53:31 PM »
Thanks for the hint. I already saw them and in fact I could use some of them. But can I also set them in the mdpa file?
Something like:

Begin Flags
1 SET
2 SET
3 ...
End Flags

Cheers,
Daniel

pooyan

  • Global Moderator
  • Newbie
  • *****
  • Posts: 33
Re: Definition of flags in an application
« Reply #6 on: April 13, 2016, 10:46:54 AM »
Another possible solution would be to create a Kratos variable like SHAPE_OPTIMIZER_FLAGS with Flags as type and then try to keep track of your optimizer flags using this flag:
Code: [Select]
node.GetValue(SHAPE_OPTIMIZER_FLAGS).Is(IS_ON_SYMMETRY_PLANE)
So you nobody would write over your local flags in this variable.

The obvious drawback would be the performance which will be as slow as the GetValue. Nevertheless you can get the value once and check for different flags if you want. The advantage would be using less memory for all your flags.