Problems creating volscalarfield
I am trying to modify the solidDisplacementFoam solver so that it has an additional temperature dependant variable within it in the form of a scalar field, this variable has been programmed as shown in the main .C file:
Code:
forAll(T.internalField(), cellI) Code:
volScalarField SC
Code:
--> FOAM FATAL ERROR: |
Hi,
1. If you'd like to construct volScalarField with NO_READ, you have to use different constructor, for example: Code:
volScalarField p Code:
volScalarField K 2. You create SCholder array inside the loop, so it won't be available after you exit the loop. Do you plan to use it outside forAll macro? And if you need dynamically allocated array, you can use Field type. Something like: Code:
Field SCholder(SC.size()) |
Thank you for your reply however, I am now confused on how I need to implement this in the solver. The code is in the time loop so every time step it will run through all nodes and will calculate:
base = (((T.internalField()[cellI]))) and then calculate SC by looking at the previous SC and adding 2/base onto this. It will then update SCholder so that on the next time loop the code can see the previous SC, SCholder is not used anywhere else in the code. Could you please guide me on how I should add this to the solver? |
From your post I did not get why you need two fields: SC and SCholder. If SC is just recalculated on every time step by addition certain values to it, why not just do this:
Code:
forAll(T, cellI) Code:
forAll(T, cellI) |
Thank you very much, that simplifies things for me. The part I am stuck with is the creation of the volScalarField for this case so that I can view the SC results from my simulation, I do not understand how to set up the constructor. I currently have:
Code:
volScalarField SC |
Then you can create the field with
Code:
volScalarField SC |
Thank you very much for your help.
When I try: Code:
forAll(T, cellI) { Code:
Making dependency list for source file cureFoam.C Code:
int exp; How do I get this to work with doubles rather than integers and also why is it only calculating the first cell and why is it constant in all time step folders? |
:D
^ operator in C/C++ is something different (http://en.wikipedia.org/wiki/Operato...wise_operators) If you need exponentiation, you have to use pow (http://www.cplusplus.com/reference/cmath/pow/) function. I did not pay attention to this as I thought expression you'd like to add to SC is valid. |
Thanks :)
It compiles fine now with but I am still having the same problem with only a single value appearing and only for the first cell in all time step files: Code:
FoamFile Code:
forAll(T.internalField(), cellI) |
OK. What is the meaning of that 100?
|
It is the temperature at which the reaction starts, I had tested this in excel a while back and it worked fine, just having problems adding it into openfoam.
|
Units?
You can plot 2/250*(pow(2,((100 - T)/10))) in paraFoam using Calculator filter and see what you're adding to SC. |
Ahh sorry about this, messed up on the brackets :D
Closed the denominator in brackets and works fine now. Thank you very much for your help! |
Hi guys,
Im facing the same "NO READ" problem. In twoPhaseEulerFoam, just like k-Epsilon model in this solver. I make the drag model very simple so I dump the template and make the GidaspowSchillerNaumann model into the main code. But its alike with the original one. Post all the code is tough, but something wrong is here: Code:
volScalarField K Code:
--> FOAM FATAL ERROR: |
Hi,
You error is NOT "the same" maybe it is similar. What is the type of Code:
0.75*Cds*phase2->rho()*bp/d1 |
All times are GMT -4. The time now is 05:30. |