CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Viewing a constant/variable inside para view

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 17, 2013, 15:31
Default Problems writing temperature depentant variable
  #1
Member
 
Join Date: Aug 2013
Posts: 60
Rep Power: 13
sur4j is on a distinguished road
I am trying to view a variable within para view. I am working with solidDisplacementFoam, in this solver constants (E, nu) are specified within the constant file of the test case, these are read inside one of the solver header files and constant scalar fields are generated from these constants, one of the scalar field is defined as shown:
Code:
 volScalarField mu(E/(2.0*(1.0 + nu)));
I wanted to make the scalar field mu a function of temperature, with help the following code was added to the main .c file:

Code:
forAll(mu.internalField(), cellI)
 {   
mu.internalField()[cellI] = 100*T.internalField()[cellI];   
} 
mu.correctBoundaryConditions();
Firstly, the volScalarField mu is defined initially in the header file as show in the first code, it is then made a function of temperature only in the second code which is in the time loop of the source file, does this make the first formula pointless since it essentially gets overridden by the second piece of code?
Also, I now need to view this variable inside of para view, how would I alter the code to show this?

Last edited by sur4j; December 18, 2013 at 15:24. Reason: Making question more understandable
sur4j is offline   Reply With Quote

Old   December 18, 2013, 15:32
Default
  #2
Member
 
Join Date: Aug 2013
Posts: 60
Rep Power: 13
sur4j is on a distinguished road
I have been experimenting with the code and realised that if I add the following I get files for mu written every required time step:

Code:
if(runTime.outputTime())
{
mu.write();
}
The file in the time folder saves as the defined formula ((E|rho)|(2*(1+nu))) and the list of values shown inside the time step are shown correctly, by that I mean the variable at that time and cell is 100 times the temperature at that time and cell. This is great but I would also like to visualise this inside para view but when I run paraFoam it closes and I get the following error:

Code:
--> FOAM FATAL IO ERROR: 
wrong token type - expected word, found on line 14 the punctuation token '('

file: /home/sk/OpenFOAM/sk-2.2.2/run/plateHole/20/((E|rho)|(2*(1+nu))).object at line 14.

    From function operator>>(Istream&, word&)
    in file primitives/strings/word/wordIO.C at line 74.

FOAM exiting
I would really appreciate some help with this problem.
sur4j is offline   Reply With Quote

Old   December 19, 2013, 16:38
Default
  #3
Member
 
Join Date: Aug 2013
Posts: 60
Rep Power: 13
sur4j is on a distinguished road
I think that the error may have something to do with the file name printing as the formula ((E|rho)|(2*(1+nu))) in every time file, is there a way of changing this. I mean printing the file with a name such as "mu" for example?
Also, I have not told OpenFOAM to read this in the createFields.H file, when I tried this I got errors when compiling the solver. Is defining this in the header file required?

I have been spending hours changing so many things with this solver trying to make it work, I initially thought that this would be very simple all I want to do is make the constant mu a variable which changes as 100*Temperature, could someone please help me with this.
sur4j is offline   Reply With Quote

Old   December 20, 2013, 08:14
Default
  #4
Member
 
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 16
ARTem is on a distinguished road
hello, sur4j.
You're moving in the right direction.
Yes, it's possible for errors to occur in paraview while reading unsuitable characters.
You can use different constructors for your field:
Code:
volScalarField mu("mu", E/(2.0*(1.0 + nu)));
will force writing functions to use a "mu" name for operations with the file system.
Code:
volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    E/(2.0*(1.0 + nu))
)
without adding mu.write(); in the main code.
ARTem is offline   Reply With Quote

Old   December 20, 2013, 14:56
Default
  #5
Member
 
Join Date: Aug 2013
Posts: 60
Rep Power: 13
sur4j is on a distinguished road
Thank you so much for helping me.

I have tried the code but it still doesnt work. Inside the createFields.H file there is a if statement saying if(thermalStress){calculate T}, since I am solving a thermal problem I added the IOobject inside this if statement and the solver compiled fine, I then ran it on a test case and mu did not write out in any of the time step folders. I then went back into the header file and moved the IOobject mu from inside the IF statement to the start of the code and got an error saying redecleartion of the volScalarField mu which has already been defined inside of the readMechanicalProperties file.

So after having these problems I started changing things again, one of the changes was adding the mu.write with the force defined mu constructor code you had written, this compiled. I then set up a test case, this was to apply a temperature BC at the right wall of the plate hole tutorial, I ran the solver on this case and found that mu was written every time step. I then viewed the results inside of para view and got strange results:

Temperature: https://imageshack.com/i/ndscesp
mu: https://imageshack.com/i/162oysp

When I looked at mu inside of the time step folder uniform 9.79413e+06 BC's were set to the hole top and right, the list of values shown above that all look correct (100*T as set in the solver) so I think that it is just that 9.794....BC causing the values to change.

Again, I have spent a long time changing things and I am really stuck therefore I would appreciate any help at all with this. Thank you.
sur4j is offline   Reply With Quote

Old   December 21, 2013, 06:42
Default
  #6
Member
 
Join Date: Aug 2013
Posts: 60
Rep Power: 13
sur4j is on a distinguished road
Code:
volScalarField mu (    
IOobject     (       
"mu",         
runTime.timeName(),         
mesh,       
IOobject::NO_READ,      
IOobject::AUTO_WRITE    
),E/(2.0*(1.0 + nu)) 
)
Could you please explain to me what the formula at the end of the code does so that I know when to use it in case of future problems?

I have been trying this on different test cases and the results look much better so I think that the symmetry BC set on the plate tutorial was causing some of the problems. I now however have a new problem when I run the solver on the test case I get mu written in each time step folder, this is fine and all the values in the list look fine however, it shows the BC's at the bottom of the list and as explained above a uniform uniform 9.79413e+06 BC is set at the walls automatically (this is the value of mu which is calculated from the formula), how do I remove this BC so that I don't have to manually go and change this to zeroGradient every time?

Last edited by sur4j; December 22, 2013 at 08:41.
sur4j is offline   Reply With Quote

Old   December 24, 2013, 01:55
Default
  #7
Member
 
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 16
ARTem is on a distinguished road
Okay, it seems that we're done with postprocessing mu in paraview)
Next, you asked me about "E/(2.0*(1.0 + nu))", I just took it from your first message. And to tell the truth I don't know mathematical model of structure analysis model in OpenFOAM.
Can you explain what exactly do you want? Just add E=E(T), nu=nu(T) (I guess it's Young's modulus and Poisson's ratio) or add extra stress from material thermal expantion? If latter, you should look for mathematical models describing a process. If former, you can modify original code by changing E and nu from dimensionedScalar type to volScalarField type. After that at each iteration you should update your E=E(T), nu=nu(T) variables and mu(T) = E(T)/(2.0*(1.0 + nu(T))).
ARTem is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with viewing graphic view when running in UNIX pitisrisuk Main CFD Forum 1 April 15, 2016 12:39
Visible Gemometry to view the inside flow countour keby9 FLUENT 2 December 22, 2012 13:08
para view problem m.maneshi OpenFOAM 0 December 1, 2009 20:08
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
meshing F1 front wing Steve FLUENT 0 April 17, 2003 13:37


All times are GMT -4. The time now is 22:11.