Save Data and boundaries and partitions

Numerical methods and mathematical models of Elmer
Post Reply
Martina
Posts: 39
Joined: 17 Apr 2013, 14:06
Antispam: Yes

Save Data and boundaries and partitions

Post by Martina »

Hi all,

I have a question about the ascii output of SaveData -> SaveScalars. I am running SaveData->SaveScalars over my whole parallel mesh, see below.
Some partitions of my mesh have one boundary condition more than the others (practically it's a glacier with some nunataks and some partitions contain a nunatak, others don't). That means that for some of the ascii output files I have one column more than for others, the ".names" file describing the columns doesn't fit for all of the ".dat.partition" files and it's difficult to identify in an automatic way which column represents for example the flux through the glacier surface, since it's not always column 4, but sometimes also number 5.
I have a whole set of simulations with slightly different set-ups, so I'm relying on scripts using the ascii output (in the end I need to sum the mass and the fluxes over all my partitions). In addition, unfortunatly one of the nunatak seems to be just on the partition limit, so somehow it doesn't belong always to the same partition (I haven't understood that yet fully, however). So basicly I have to check for each run by hand which are the .dat files with nunataks and which the ones without.
I was wondering if there was a simple solution to that? Would there be a possibility to have the same number of columns (flux 0 for "nonexisting" boundaries for example) in all .dat.partition files or to get right away only one .dat file to avoid all human errors that happen when counting and summing over the columns of the different .dat.partition files?
Maybe I could also run somehow not only once SaveData->SaveScalars, but running it 3 times: once for volume, once for the fluxes on nunataks and once for the fluxes on the other boundaries?

Thanks for your ideas,
Martina

Code: Select all

Solver 13
  Equation = "SaveData"
  Procedure = File "SaveData" "SaveScalars"
  Exec Solver = after timestep
  Filename =  "mass"$name".dat"
  File Append = Logical True     ! For transient simulation
  Variable 1 = String "Time"
  Variable 2 = String "Flow Solution"
  Operator 2 = String "Volume"
  Operator 3 = String "Convective Flux"
  Variable 3 = String "Flow Solution"
End 
raback
Site Admin
Posts: 4828
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Save Data and boundaries and partitions

Post by raback »

Hi Martina,

Ok, I see your problem and it should be corrected in the code.

Now what happens if you use "Parallel Reduce = Logical True". Does this give you what you need?

-Peter
Martina
Posts: 39
Joined: 17 Apr 2013, 14:06
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by Martina »

Hi Peter,

thanks for the not only quick, but nearly instantaneous answer!
That was the line that I was missing. It works perfect and I found (and corrected) right away still another error in my older counting and adding scripts :-(.

Martina
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by annier »

Hi Martina,
1. I am also doing a transient simulation.
Can you explain me about this? What does this file append mean?

Code: Select all

File Append = Logical True     ! For transient simulation
In other words, why do not we need to do file append for the steady state simulation?

2. Operator 2 and Operator 3 are just after Variable 2. Do they correspond to variable 2 and variable 3 respectively?


yours
annier
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
ygong
Posts: 15
Joined: 08 May 2013, 16:51
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by ygong »

Hi,
I just found this old post and thought it might be the place I should put my problem at because I am trying to do the same thing.

I have 2 separate bodies and I am trying to save volume from the flow solution for the 2 bodies respectively.

But It seems that no matter where I execute save scalars to compute the volume it always computes for the whole domain (There are no difference between the 2 output files). Anyone has any ideas about this ? Here is the relevent sentences.

Code: Select all

 Body 1
  Name = "body1"
  Equation = 1
  Body Force = 1
  Material = 1
  Initial Condition = 1
End
Body 2
  Name = "body2"
  Equation = 2
  Body Force = 1
  Material = 1
  Initial Condition = 1
End
...

  Solver 12
  Exec Solver = After TimeStep ! or whenever you want
  Procedure = "SaveData" "SaveScalars"
  Filename =  file $name"_Body1.txt"
  File Append = Logical True
  Parallel Reduce = Logical True
 
  Variable 1 = String "Flow Solution" ! just a dummy
  Operator 1 = String "Volume"
  Mask Name 2 = String "Save Flux body1"
  Variable 2 = String "Flow Solution"
  Operator 2 = String "Convective flux"
End
Solver 13
   Exec Solver = After TimeStep ! or whenever you want
  !Exec Solver = "Never"
  Procedure = "/homeappl/*/MySaveData" "SaveScalars"
  Filename =  file $name"_body2.txt"
  File Append = Logical True
  Parallel Reduce = Logical True

  Variable 1 = String "Flow Solution" ! just a dummy
  Operator 1 = String "Volume"
  Mask Name 2 = String "Save Flux body2"
  Variable 2 = String "Flow Solution"
  Operator 2 = String "Convective flux"
End
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! EQUATION                         !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Equation 1
!body1
  Active Solvers(9) = 1 2 3 4 8 9 10 11 12 
  Convection = Computed
  Flow Solution Name = String "Flow Solution"
  NS Convect = Logical False
End
Equation 2
!body2
  Active Solvers(9) = 1 2 3 4 8 9 10 11 13
  Convection = Computed
  Flow Solution Name = String "Flow Solution"
  NS Convect = Logical False
End
And the mask names are in boundary condition sectors. I wonder if I need to have two Navier-Stokes solvers to give two flow solutions for each body?

Thanks in advance.

Yongmei
annier
Posts: 1168
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by annier »

Hi Yongmei,
I am not sure about what you actually mean.
But what i know is: If there are two different bodies Body 1 and Body 2; then a same Navier-Stokes Solver 1 can be used in the two equations Equation 1 and Equation 2 correspoding to Body 1 and Body 2 .
viewtopic.php?f=3&t=3281&sid=24120c68b0 ... dcbf7d0a5b
Yours
Anil Kunwar
Anil Kunwar
Faculty of Mechanical Engineering, Silesian University of Technology, Gliwice
Martina
Posts: 39
Joined: 17 Apr 2013, 14:06
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by Martina »

Hi Yongmei,

if you look in the ElmerModelsManual it is written "The volume used by a given variable is obtained by operator volume".
It seems not to matter on which body you execute the solver, the volume is calculated accordingly to what the variable uses.
Since you have put in both of your SaveScalar Solvers Variable 1 = String "Flow Solution" you get both times the volume used by "Flow Solution", i.e. the volume of both of your bodies, since you execute the Navier-Stokes on both of them jointly.
You don't need to run twice the Navier-Stokes Solver separately (what probably also wouldn't work in your case), you just need to use another variable. It doesn't matter what kind of variable it is, it just needs to use the correct volume, so no need to stick to "Flow Solution"!
As I understand it, that's just what the example from Thomas (by email) last night is doing - here just the explanation + solution for others who might have the same problem.

Martina
ygong
Posts: 15
Joined: 08 May 2013, 16:51
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by ygong »

Hi Martina,

Thank you very much! And also Thomas (although he hasn't posted his code here.)
So, yes, the problem is with SaveScalar Solvers Variable 1 = String "Flow Solution" I used as Martina has said. So following the example given by Thomas I modified my code and it worked very happily. I put my code here in case someone has the same prob. The key point is that you need to have a dummy solver to give you a dummy variable name.

Code: Select all

Solver 4
  Exec Solver = "Before Simulation"
  Equation = "Dummy"
  Procedure = File "./DummySolver" "DummySolver"
  Variable = String "Dummy Flow Solution"
  Variable DOFs = 1
End
...
Solver 12
  Exec Solver = After TimeStep ! or whenever you want
  Procedure = "SaveData" "SaveScalars"
  Filename =  file "body1.txt"
  File Append = Logical True
  Parallel Reduce = Logical True
 
  Variable 1 = String "Dummy Flow Solution" ! the name of the dummy variable
  Operator 1 = String "Volume"
  
End
Solver 13
   Exec Solver = After TimeStep ! or whenever you want
  Procedure = "./MySaveData" "SaveScalars"  ! You need to have a another SaveData
  Filename =  file "body1&2.txt"
  File Append = Logical True
  Parallel Reduce = Logical True

  Variable 1 = String "Flow Solution" ! just a dummy
  Operator 1 = String "Volume"
   Variable 2 = String "Flow Solution"
  Operator 2 = String "Convective flux" ! It can compute the flux in all the boundaries depending on where you put "save scalars = Logically true" (or what ever mask you have defined; see the Elmer Manual)
End
Equation 1
!body1
  Active Solvers(2) = 4 12 ! this one computes only for body 1
  Convection = Computed
  Flow Solution Name = String "Flow Solution"
  NS Convect = Logical False
End
Equation 2
!body2
  Active Solvers(1) =  13 ! this one computes for body 1+ body 2
  Convection = Computed
  Flow Solution Name = String "Flow Solution"
  NS Convect = Logical False
End
Last edited by ygong on 03 Apr 2014, 14:15, edited 1 time in total.
tzwinger
Site Admin
Posts: 100
Joined: 24 Aug 2009, 12:20
Antispam: Yes

Re: Save Data and boundaries and partitions

Post by tzwinger »

Hi,
if I might add one comment to the presented solution. The DummySolver was just run on the body for which you want to have the volume computed in order to create a variable (DummyVar) that has the needed permutations (only existing on that very body). If you have such a variable already at hand, then just use this one and leave the DummySolver out.

Code for the DummySolver (if needed):

Code: Select all

RECURSIVE SUBROUTINE DummySolver( Model,Solver,Timestep,TransientSimulation )
  USE DefUtils
 
  IMPLICIT NONE


  !------------------------------------------------------------------------------
  !    External variables
  !------------------------------------------------------------------------------
  TYPE(Model_t)  :: Model
  TYPE(Solver_t), TARGET :: Solver
  LOGICAL :: TransientSimulation
  REAL(KIND=dp) :: Timestep
  !------------------------------------------------------------------------------
  !    Local variables
  !------------------------------------------------------------------------------
  TYPE(ValueList_t), Pointer :: BC
  TYPE(Variable_t), POINTER :: Var
  TYPE(Element_t),POINTER :: Element
  INTEGER, POINTER :: VarPerm(:)
  INTEGER :: VarDOFs, i, j, k, N, t
  REAL(KIND=dp), POINTER :: VarValues(:)
  LOGICAL :: GotIt
  PRINT *,"DummySolver"
  PRINT *,"***********************************"
  Var => Solver % Variable
  IF (ASSOCIATED(Var)) THEN
     VarPerm => Var % Perm
     VarDOFs =  Var % DOFs
     VarValues => Var % Values
  ELSE
     CALL FATAL('DummySolver','No Variable associated')
  END IF
  VarValues = 1.0_dp
  PRINT *, "Done"
END SUBROUTINE DummySolver
Best,

Thomas
Post Reply