Dear All, I am in need of s
I am in need of some help regarding writing a new add on for foamCalc, called "wakeField". The function is to perform a very simple calculation:
wakeField = 1 - Ux / U(farfield).
I used the folder "components" as a starting point and modified step by step until I ran into problems.
I was able to perform : wakeField = Ux / U(farfield). However, next is that I do 1- Ux/U(farfield) by adding the following in the writeWakeField.C:
scalar(1) - (field.component(i) / scalar(5))
wmake libso works well but running the utility (foamCalc wakeField U) gives the next error:
LHS and RHS of - have different dimensions
dimensions : [0 0 0 0 0 0 0] - [0 1 -1 0 0 0 0]
Well, this is a very clear error message: the "1" has no dimensions while a U field has. But I do not know how to solve this problem.
Furthermore: so far I assumed for simplicity that my farfield velocity is 5. However this should be read from the time directory/U file under the head belonging to the inlet patch.
So as extra input I would ask the user for "inletPatchName". The utility should search in this inlet patch for the correct U value. How to program this?
I hope I made myself clear enough and anyone is able to comment,
Hi Mark, You should use a d
You should use a dimensioned variable to define U(farfield) (after all, it has velocity units, right?). Then, the Ux/U(farfield) division will be dimensionless as the subtracting operation.
At this time, define it in your code as:
"Ufarfield", // the name
[0 1 -1 0 0 0 0], // its dimensions (L / T)
5.0 // the value
I suppose you will have to change or create a code for the boundary condition if you want to read Ufarfield from the 'time/U' file. If not, probably, there is an easy way to read this variable, but I don't know it (and it would take some time for me to dig it out). Let's see if someone out there knows it better.
On the other hand, if 'Ufarfield' is a variable that does not change in time, you could store it in a file in the constant directory...
Hope it helped,
Hi Luiz, Thanks for your ef
Thanks for your effort. Unfortunately it did not work for me, I probably have not enough knowledge about C++ qualifiers etc. However your comments brought me a step further again.
And yes, you're right: the value 5 shall be read from the time directory.
I should incorporate something like:
dimensionedscalar("Ufarfield", [0 1 -1 0 0 0 0], 5.0)
in the main .C file (wakeField.C). But so far I did not succeed. I have to tell the utility that has to read the value from the entry:
value uniform (5 0 0);
Any help would be greatly appreciated.
Hi Mark, Maybe you can hav
Maybe you can have a look at the channelOodles solver (solvers/DNSandLES/channelOodles).
In this solver at each time step a scalar (gradP) is written in runTime.path()/runTime.timeName()/
And when you start your calculation, the solver read this file.
So you can adapt it to your case, write it every time step and read it not only when you start the calculation but at each time step.
I hope I've got well understand your problem and that it will help
Cedric, All little pieces h
All little pieces help, thanks for your advice. However, channelOodles reads a datafile (gradP.raw), which works a little different from reading a BC file.
Well, for the experienced C programmers here it will surely be something simple, but I get stuck here.
Hello All, The utility is f
The utility is finished. I made a simple stand-alone though, so it is not available via foamCalc.
For reference the files are attached here:
Thanks for the assistance,
|All times are GMT -4. The time now is 12:56.|