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 245 forks source link

Annoying multiple repetitions of ReadMaterialsUtility warnings #8304

Closed riccardotosi closed 3 years ago

riccardotosi commented 3 years ago

Description I am running the following case:

  1. initialize and run problem on mesh 0
  2. refine using meshing application --> mesh 1
  3. initialize and run problem on mesh 1
  4. refine using meshing application --> mesh 2
  5. initialize and run problem on mesh 2
  6. etc.

Starting from stage 3., many warnings as

[WARNING] ReadMaterialsUtility: WARNING:: The properties ID: 1 in mesh ID: 0 is already defined. This will overwrite the existing values
[WARNING] ReadMaterialsUtility: WARNING:: The properties ID: 1 already has variables.
[WARNING] ReadMaterialsUtility: The properties ID: 1 already has CONDUCTIVITY.
Overwriting 1 with 1
[WARNING] ReadMaterialsUtility: The properties ID: 1 already has DENSITY.
Overwriting 1 with 1
[WARNING] ReadMaterialsUtility: The properties ID: 1 already has SPECIFIC_HEAT.
Overwriting 1 with 1

appear. This becomes quite annoying for my application of interest, since the workflow is repeated multiple times. Is there a way to avoid the printing of such warnings?

I already know that I could set

model.GetModelPart(model_part_name).ProcessInfo.SetValue(KratosMultiphysics.IS_RESTARTED, True)

but this does not work in my case.

I attach a zip folder with a simplified case. It only requires the ConvectionDiffusionApplication to be reproduced. As you may observe, when running the problem a second time (i.e. step 3.), the warnings appear. test_read_materials.zip

Scope Which areas of Kratos are involved E.g.

rubenzorrilla commented 3 years ago

There are two things to comment in here.

  1. You are defining the materials twice (in the mdpa and in the materials.json). Hence the overwriting warning must be there in order to let the user know about which material parameters are to be used (the ones in the materials.json) since these could be different.
  2. What I agree it that defining empty properties in the mdpa and then giving values in the materials.json is quite annoying. As this is always required in order to assign properties to elements in the preprocess, I'd only throw a warning if the properties in the mdpa are not empty.
loumalouomega commented 3 years ago

There are two things to comment in here.

1. You are defining the materials twice (in the mdpa and in the materials.json). Hence the overwriting warning must be there in order to let the user know about which material parameters are to be used (the ones in the materials.json) since these could be different.

2. What I agree it that defining empty properties in the mdpa and then giving values in the materials.json is quite annoying. As this is always required in order to assign properties to elements in the preprocess, I'd only throw a warning if the properties in the mdpa are not empty.

+1

riccardotosi commented 3 years ago

Hi @rubenzorrilla , I understand your point 1. However, setting empty properties does not change my issue, since the warnings appears in step 3.1. This is the sketch:

  1. initialize and run problem on mesh 0 1.1. No warnings about materials
  2. refine using meshing application --> mesh 1
  3. initialize and run problem on mesh 1 3.1. ReadMaterialsUtility warnings are printed
  4. refine using meshing application --> mesh 2
  5. initialize and run problem on mesh 2 5.1. ReadMaterialsUtility warnings are printed
  6. etc.

Please observe that in point 3. I am not reading again the mesh from file, but I am using the AMR model. Therefore, to the best of my understanding, the solution you propose in 2. does not work. Can you please elaborate your proposal?

philbucher commented 3 years ago

Why do you re-read the properties? If you already defined them then re reading them will lead to warnings, which should be like that

riccardotosi commented 3 years ago

Why do you re-read the properties? If you already defined them then re reading them will lead to warnings, which should be like that

Because in a Multilevel Monte Carlo algorithm you solve your problem on levels of different accuracy, namely multiple meshes. Then, you first run on the coarsest level, then you refine, then you solve the problem on the AMR mesh.

I agree that not re-reading properties would solve my issue, but I do not see this possibility in the solver I am using.

philbucher commented 3 years ago

Then the solver should be modified accordingly I do not agree about removing the warnings, those were added for a reason and must be printed in the standard workflow

riccardotosi commented 3 years ago

I do not agree about removing the warnings, those were added for a reason and must be printed in the standard workflow

Hi @philbucher, I am not commenting to remove the warnings from the core utility.

I am reporting an issue I have, and maybe some feature to solve my problem is already present in Kratos. If nothing is present in Kratos, also to me the easier solution is to modify the solvers of the applications I am using. But would this be a good solution?

philbucher commented 3 years ago

Ah sorry then I misunderstood

no also to my knowledge there is nothing that you could directly use

riccardotosi commented 3 years ago

Ok. If @rubenzorrilla and @loumalouomega agree, I will implement specific changes directly in the solver.

philbucher commented 3 years ago

In structual it is already possible not to read materials if you leave the materials file name empty it will do nothing

I would use the same concept to have it consistent

riccardotosi commented 3 years ago

Now that you mention, also the convection diffusion solver offers this possibility in here. I will try to use this feature!

philbucher commented 3 years ago

Now that you mention, also the convection diffusion solver offers this possibility in here. I will try to use this feature!

for once copy-paste payed off :D

riccardotosi commented 3 years ago

After discussing in #8336, the solution to remove warnings as

[WARNING] ReadMaterialsUtility: WARNING:: The properties ID: 0 in mesh ID: 0 is already defined. This will overwrite the existing values

is to use empty properties in the mdpa and to define properties in the material file with different property Id.

As discussed in this issue, to remove warnings as

[WARNING] ReadMaterialsUtility: The properties ID: 1 already has CONDUCTIVITY.
Overwriting 1 with 1
[WARNING] ReadMaterialsUtility: The properties ID: 1 already has DENSITY.
Overwriting 1 with 1
[WARNING] ReadMaterialsUtility: The properties ID: 1 already has SPECIFIC_HEAT.
Overwriting 1 with 1

it is enough to use of "" as materials filename.

riccardotosi commented 3 years ago

The issue will be closed when #8335 is merged.