|
[Sponsors] |
January 18, 2011, 17:51 |
new scalar field in dynSmagorinsky
|
#1 |
New Member
Matt James
Join Date: Jun 2010
Location: Marinette,WI, USA
Posts: 25
Rep Power: 16 |
Hi all,
This seems like it could be really easy for some of you here... However, it evades me. I'm trying to declare a scalar field, I'll call it "j", within dynSmagorinsky.C I'd like to solve a transport equation for j, so i just need some way to define initial and boundary conditions. The rest of the code seems to compile fine...just not this seemingly mundane detail. I tried letting an H file open it up but it seems to complain about not knowing anything about the mesh, which i suppose makes sense to me. Correcting that problem was leading me down a dark and winding path. I thought surely there's an elegant way. Can anyone help me out here? Thanks a lot! |
|
January 20, 2011, 06:03 |
|
#2 |
Senior Member
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 16 |
Hi,
All such changes to field are made when they are defined in createFields.H Define your scalar field in this file just the way p or T are defined and everything should work fine. |
|
January 20, 2011, 16:14 |
|
#3 |
New Member
Matt James
Join Date: Jun 2010
Location: Marinette,WI, USA
Posts: 25
Rep Power: 16 |
Nakul,
Thank you very much for your reply. I would agree, and have done this when adding a field to solver. However, the fields in the dynSmagorinsky model code are generated within the code, since they are derived from the U and k fields. The problem thus arises in establishing a new field within the code. In short, there is no createFields.H included in dynSmagorinsky.C . Also, I tried to include a new H file to accomplish what createFields.H does in a solver, but to no avail. dynSmagorinsky.C includes dynSmagorinsky.H, which appears to collect the U, phi and k fields from somewhere (eventually the solver?). So, it seems I should be similarly declaring my new volScalarField here. Any thoughts? |
|
January 21, 2011, 03:34 |
|
#4 |
Member
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 16 |
Hi Matt,
I'm not sure how to do a scalar field, but this is how you can do a volVectorField: volVectorField j ( IOobject ( "j", U.time().constant(), U.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), U.mesh(), dimensionedVector("j",dimForce/dimVolume/dimDensity,vector::zero) ); Hope this helps you out. Tony |
|
January 21, 2011, 10:40 |
|
#5 |
Senior Member
Nakul
Join Date: Apr 2010
Location: India
Posts: 147
Rep Power: 16 |
Hi
I don't have this model in my version of OF so if you could just upload the source code of this solver and point out your problem, I'll have a look. |
|
January 27, 2012, 18:06 |
|
#6 |
New Member
David Theriault
Join Date: Jan 2012
Posts: 5
Rep Power: 14 |
Hi Matt & everyone
I was wondering if you have succeeded on what you're looking for. I'm also interested to add a new scalarfield in a sgs model which is computed by the solver and refreshed for each time step. So if you have any thoughts... Thx |
|
January 30, 2012, 05:02 |
|
#7 |
Member
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 17 |
Hi everyone.
Matt and David, I hope that you are succeeded up to now, but if you are not, this is the way how I did it. In .H file of your model I just added a new function: dimensionedScalar c1(const volSymmTensorField& D) const; and then in .C dimensionedScalar nameOfYourModel::c1(const volSymmTensorField& D) const { .... some code } At each time step I calculate c1, use this value to calculate some other variables which are later used for temperature equation... Maybe you can use something similar to this... |
|
January 31, 2012, 16:56 |
|
#8 |
New Member
David Theriault
Join Date: Jan 2012
Posts: 5
Rep Power: 14 |
Thank you for the answer.
But unfortunately, the scalarfield needed is computed by the solver and not in the sgs library itself. So I concluded that I need to modify LESModel.H and GenEddyVisc.H to transfer the information between the solver and the libraries used. I'll try this. David |
|
February 1, 2012, 03:28 |
|
#9 |
Member
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 17 |
No problem, it is straightforward.
First you have to add scalar field to turbulenceModel (add new variable, change constructor,...), then adjust LESModel, GenEddyVisc and finally your own model. Maybe also something else but I cannot remember at the moment. Just copy the whole folder (incompressible or compressible), change name, and inside you can do whatever you want... Dejan |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
dieselFoam problem!! trying to introduce a new heat transfer model | vivek070176 | OpenFOAM Programming & Development | 10 | December 24, 2014 00:48 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
from a vecor field to get a gradient of scalar | dusky.he | Main CFD Forum | 4 | March 30, 2007 10:08 |
How to create a vector field out of scalar fields | anja | OpenFOAM Pre-Processing | 7 | May 31, 2006 12:56 |