CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Adding a user application class (http://www.cfd-online.com/Forums/openfoam-pre-processing/62158-adding-user-application-class.html)

Rasmus Gjesing (Gjesing) May 24, 2004 08:41

I have problems with adding a
 
I have problems with adding a user application class, so it is visible in FoamX. The application class is running fine, but I would like to use FoamX for preprocessing.
It must be something with placing some files and folders in $FOAMX_USER_CONFIG, but how should the structure be, so FoamX discovers the new application class???

Mattijs Janssens (Mattijs) May 24, 2004 09:31

The FOAMX_USER_CONFIG is trea
 
The FOAMX_USER_CONFIG is treated in the same way as the FOAMX_SYSTEM_CONFIG. Have a look at the files in $FOAMX_SYSTEM_CONFIG/applications (setup for Foam applications).

Take one of the application directories from under there, rename it and put it in a similar tree under $FOAMX_USER_CONFIG.

Mattijs

Rasmus Gjesing (Gjesing) May 26, 2004 04:18

Thanks for the help! My appli
 
Thanks for the help! My application class is now visible in FoamX.

By the way, are you editing your source code in a simple text-editor or in Kdevelop. I miss a little overview over Foam even though the Doxygen documentation are provided.

Rasmus Gjesing

Mattijs Janssens (Mattijs) May 26, 2004 05:39

We use text editors and a lot
 
We use text editors and a lot of 'grep'ing through header files in $FOAM_SRC/foam/lnInclude. (I have an environment variable called 'I' set to that directory to save typing ;-)

Also all the other libraries in $FOAM_SRC (sampling, turbulenceModels, ...) can be searched in their lnInclude/ directory which contains links to all the source files.

Thirdly I tend to program by example. Especially the utilities directory ($FOAM_UTILITIES) contains a lot of interesting code (for my purpose).

Last but not least there is the documentation on the website (programmers guide) which can be terse but quite useful.

Mattijs

vvqf October 26, 2005 10:38

How to do this with version 1.
 
How to do this with version 1.2 ?
I did as Release Notes-1.2 tells, but can't make my own application visible in FoamX. ie. I can't creat a case with the user solver, because it is not in the application list.

newbee February 28, 2006 06:04

Hi, I want to make the appl
 
Hi,

I want to make the application rhoSimpleFoam visible in FaomX. I Guess I can do somthing similar to what is stated in previus discusion under this topic but I dont know where the pathes $FOAMX_USER_CONFIG and FOAMX_SYSTEM_CONFIG points to.

The big question is:

How do I add this solver or alternativly create a case and modify it without the help of GUI.

regards
Erik

eugene February 28, 2006 07:03

There is a tutorial case for r
 
There is a tutorial case for rhoTurbFoam the equivalent transient solver. Copy the config files and initial fields from there, modify as necessary, change the time scheme to steadyState (fvSchemes) and add a SIMLPE entry and relaxation factors to fvSolutions (check the simpleFoam tutorial case to see what kind of stuff is needed).

Then you just run "rhoSimpleFoam <root> <case>", and it should work.

gschaider February 28, 2006 07:10

Hello Erik! One simple way
 
Hello Erik!

One simple way to find out about the paths:
echo $FOAMX_USER_CONFIG
on the shell shows you were it points to.

Modifying cases is "easy" once you have understood chapter 4 of the user guide

newbee February 28, 2006 07:31

ok, thanks for the pointers fr
 
ok, thanks for the pointers from both of you. I will try do these modifications.

When typing "echo $FOAM_USER_CONFIG" I just receive a empty line as answer....?

I will digg further down in problem.
/Erik

newbee February 28, 2006 08:34

I have tried to copy the whole
 
I have tried to copy the whole turbFoam tutorial case "cavity" and I have done the modifications mentionded above. When trying to run the case I got the following error:

erik@compadre:~/OpenFOAM/erik-1.2/run/tutorials/rhoSimpleFoam$ rhoSimpleFoam . cavity
/*---------------------------------------------------------------------------*\
| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 1.2 |
| \ / A nd | Web: http://www.openfoam.org |
| \/ M anipulation | |
\*---------------------------------------------------------------------------*/

Exec : rhoSimpleFoam . cavity
Date : Feb 28 2006
Time : 14:17:17
Host : compadre
PID : 9361
Root : /home/erik/OpenFOAM/erik-1.2/run/tutorials/rhoSimpleFoam
Case : cavity
Nprocs : 1
Create time

Create mesh for time = 0

Reading thermophysical properties

Selecting thermodynamics package hThermo<puremixture<consttransport<speciethermo<hc onstthermo<perfectgas>>>>>
Reading field U

Reading/calculating face flux field phi



--> FOAM FATAL IO ERROR : keyword pRefCell is undefined in dictionary "/home/erik/OpenFOAM/erik-1.2/run/tutorials/rhoSimpleFoam/cavity/system/fvSoluti on::SIMPLE"

file: /home/erik/OpenFOAM/erik-1.2/run/tutorials/rhoSimpleFoam/cavity/system/fvSolutio n::SIMPLE from line 47 to line 47.

From function dictionary::lookupEntry(const word& keyword) const
in file db/dictionary/dictionary.C at line 152.

FOAM exiting



please tell me what I have done wrong or if there are more modifications that needs to be done.

It would be nice to get it visible in FoamX but that might be to much to hope for with my limitations in OpenFAOM.

Thanks /Erik

newbee February 28, 2006 08:41

never mind, I got the "pref" &
 
never mind, I got the "pref" & "pvalue" problem

newbee March 9, 2006 04:08

Hello! sorry for my frequen
 
Hello!

sorry for my frequent messaging, but im stuck!!

I've managed to combine turbfoam and simplefoam tutorials cases to run rhosimplefoam.

Now I need to go a step further and modify the code in rhosimplefoam (application) to handle incompressibe flow.

Could anyone please give me a pointer of how or perhaps which files in rhosimplefoam that needs to be changed?

kind regards

eugene March 9, 2006 06:19

Look in pEqn.H near the end. Y
 
Look in pEqn.H near the end. You will find rho being updated. Remove this line. Remember to fix rho to your constant value during initialization.

If you want to solve incompressible flow, why arent you just using simpleFoam? If you want the heat transfer capabilities of rhoSimpleFoam, a much better (and less costly) option would be to add a temperature or enthalpy transport equation to simpleFoam.

newbee March 9, 2006 06:45

Hi Eugene! Thanks alot for
 
Hi Eugene!

Thanks alot for your quick respons!

I have thought of both alternatives, but since I doent have much experiance with this software I might have made a bad decision in this subject.

Im happy to hear you say that altering simpleFoam in the following way is easier because it has produced a seemingly correct flow description of what im trieng to modell. Which is modelling of flows inside a nuclear reactor.

I will now try to edit the simpleFoam application insted.

Thank you
Erik

eugene March 9, 2006 07:04

This code I wrote for a temper
 
This code I wrote for a temperature transport equation might be useful. Just replace the rho field with a constant rho and remove the ddt(T) term for a steady solution.

//lookup Prt, k, R, p0
dimensionedScalar Prt = transportProperties.lookup("Prt");
dimensionedScalar p0 = transportProperties.lookup("p0");
dimensionedScalar R = transportProperties.lookup("R");
dimensionedScalar k = transportProperties.lookup("k");
dimensionedScalar Cp = transportProperties.lookup("Cp");

volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
p0/(T*R)
);


Info << "Creating alphaEff." << endl;
volScalarField alphaEff
(
IOobject
(
"alphaEff",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
turbulence().nut()()/Prt + k/(Cp*rho)
);

for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
solve
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(alphaEff, T)
);
}

newbee March 10, 2006 09:24

Thanks for your code and advic
 
Thanks for your code and advice!

I have modefied the code in the following way and included it in the end of my main code of my application:


IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
//lookup Prt, k, R, p0
dimensionedScalar Prt = transportProperties.lookup("Prt");
dimensionedScalar p0 = transportProperties.lookup("p0");
dimensionedScalar R = transportProperties.lookup("R");
dimensionedScalar k = transportProperties.lookup("k");
dimensionedScalar Cp = transportProperties.lookup("Cp");

volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
/*
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
p0/(T*R)
);
*/
double rho = 1000;

Info << "Creating alphaEff." << endl;
volScalarField alphaEff
(
IOobject
(
"alphaEff",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
turbulence().nut()()/Prt + k/(Cp*rho)
);



for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
solve
(
fvm::div(phi, T)
- fvm::laplacian(alphaEff, T)
);
}
------------------------------------------------

It compiles whithout anyproblems but when I try to run my case with it I get the following error message:

/*---------------------------------------------------------------------------*\
| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 1.2 |
| \ / A nd | Web: http://www.openfoam.org |
| \/ M anipulation | |
\*---------------------------------------------------------------------------*/

Exec : hSimpleFoam . PD112
Date : Mar 10 2006
Time : 14:45:27
Host : compadre
PID : 9547
Root : /home/erik/OpenFOAM/erik-1.2/run/tutorials/hSimpleFoam
Case : PD112
Nprocs : 1
Create time

Create mesh for time = 0

Reading field p

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting turbulence model kEpsilon

Starting time loop

Time = 0.1

BICCG: Solving for Ux, Initial residual = 0.99814, Final residual = 0.0339303, No Iterations 1
BICCG: Solving for Uy, Initial residual = 0.999487, Final residual = 0.0253859, No Iterations 1
BICCG: Solving for Uz, Initial residual = 1, Final residual = 0.0529838, No Iterations 1
ICCG: Solving for p, Initial residual = 1, Final residual = 0.00570935, No Iterations 183
time step continuity errors : sum local = 1.35731e-05, global = 8.6597e-10, cumulative = 8.6597e-10


--> FOAM FATAL IO ERROR : keyword Prt is undefined in dictionary "/home/erik/OpenFOAM/erik-1.2/run/tutorials/hSimpleFoam/PD112/constant/transport Properties"

file: /home/erik/OpenFOAM/erik-1.2/run/tutorials/hSimpleFoam/PD112/constant/transportP roperties from line 27 to line 44.

From function dictionary::lookupEntry(const word& keyword) const
in file db/dictionary/dictionary.C at line 152.

FOAM exiting

------------------------------------------------

I dont know what Ptr is or how to correctly add it to the transportProperties file.

could anyone please give me a hint on what to do.

Once again I apolegize for for insufficient programming knowlege.

kind regards
/Erik

newbee March 13, 2006 04:33

God morning! Im experementi
 
God morning!

Im experementing with the code above and ran into a problem.

when calculating "alphaeff" the dimensions doesnt match up in the following row:

turbulence().nut()()/Prt + k/(Cp*rho)

This calculation gives the following error message when running a case:

--> FOAM FATAL ERROR : LHS and RHS of + have different dimensions
dimensions : [0 2 -1 0 0 0 0] + [0 0 0 1 0 0 0]


From function operator+(const dimensionSet& ds1, const dimensionSet& ds2)
in file dimensionSet/dimensionSet.C at line 359.

FOAM aborting

I would be vary thankful for some help concerning how to modify alphaeff.

regards
/erik

niklas March 13, 2006 06:53

nut -> m^2/s Prt -> dimension
 
nut -> m^2/s
Prt -> dimensionless
nut/Prt = m^2/s = 0 2 -1 0 0

just make sure your input parameters k and Cp
dimensions match and all will be well.

as you can see now the dimensions of the RHS is Kelvin = 0 0 0 1 0 0

and if you dont know what the order of the dimensions are, its
mass length time temperature ...

N

newbee March 13, 2006 10:03

Hi Niklas Thank U for the t
 
Hi Niklas

Thank U for the tip!

Your recomendation worked well and now I can run my case.

Im only confused about the dimension I had to set the Cp to.

Because "turbulence().nut()()/Prt" has the dimension
[0 2 -1 0 0 0 0]

and k = [0 2 -2 0 0 0 0]
and rho = [1 -3 0 0 0 0 0]

which gives Cp = [-1 3 -1 0 0 0 0] =m/(kg*s)
for the equation to work.

But some searching on the internet tells me that the dimension rather should be [0 2 -2 -1 0 0 0] = J/(kg*K) according to the homepage:
http://physics.nist.gov/Pubs/SP811/sec04.html

Do you know were my misstake lies?

regards
Erik

niklas March 13, 2006 10:15

Well, what if k is really kapp
 
Well, what if k is really kappa (Watt/(mK)) = m kg / ( s^3 K)?

I've never seen k (turbulent kinetic energy) before.
cp is usually used with kappa/lambda http://www.cfd-online.com/OpenFOAM_D...part/happy.gif


All times are GMT -4. The time now is 20:24.