Add/multiply two variables in SaveScalars

General discussion about Elmer
Post Reply
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Add/multiply two variables in SaveScalars

Post by fjimenez »

Quick question regarding SaveScalars. I want to integrate over a body a function of two variables. For instance, I want to integrate the complex current density in MagnetoDynamicsHarmonic2D. A simple way would be to combine two variables into a fictitious vector, get its magnitude, and then integrate this magnitude over a body. Is this possible? Is SaveScalars the place to to it? I can do this in paraview but I would like to avoid this extra step and rather do it directly in Elmer.

Thanks,

Francisco
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Add/multiply two variables in SaveScalars

Post by raback »

Hi

I think that to obtain a 0D result in SaveScalars from a field "Variable i" you can have "Operator i" and "Coefficient i". The last one is any multiplier for the integrand. So I guess you could just have operator "area" and define "Coefficient" using MATC so that it would be any function of anything in Elmer style using MATC/LUA/UDF. The operator "area" only uses the "Variable i" as a mask.

-Peter
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Re: Add/multiply two variables in SaveScalars

Post by fjimenez »

Thanks Peter, appreciate your input. I have two extra questions for you In case you have some spare time to share.

I have attached a toy problem to be more specific. The model is an axi-symmetrical case with a coil in air. I set up the current density (real and imag parts) to get 1 when you multiply it by the coil area. I am obviously doing something wrong since I am not getting the desired results from SaveScalars. I assume that int is not the right operators because I think this refers to volume integration, although I am not sure what the volume is if this was the case. It is probably considering the symmetry and integrating over the azimuth. My background is in volume methods so I am not sure what would be the right terminology for what I am trying to achieve here in the finite element world.
Q1: What the right operator be in this case?

Also, I would be interested in getting sqrt(Re^2+Im^2) and do a surface integration. In this particular problem, I would expect to obtain 1.4 from this operation.
Q2: is this possible to do with SaveScalars?

Cheers,

Francisco
coil.tgz
(212.29 KiB) Downloaded 63 times
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Add/multiply two variables in SaveScalars

Post by raback »

Hi

The integrals are 1d, 2d or 3d depending on the dimension of the mesh. Hence if you have 2D mesh it will always be a surface integral. Now in your case as you have axial symmetry this is multiplied by 2*pi*r inside save scalars. So this might not be what you want. You actually want an integral over the cross section. But the current density should I guess be the same that you order.

Btw, there is a way to get any keyword to be normalized by its area. Just say,

Code: Select all

Current Density = -distribute 1.0
and the current will be automatically be divided by the area that owns it. This is true for all Real valued keywords.

-Peter
fjimenez
Posts: 63
Joined: 27 Sep 2021, 23:40
Antispam: Yes

Re: Add/multiply two variables in SaveScalars

Post by fjimenez »

Thanks Peter. Just to close this topic, what about the other component of the question?
Can I create a new field that is a combination of other fields including some simple operations?

Francisco
Post Reply