CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Setting initial fields using a data file for positions

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 9, 2013, 00:21
Default Setting initial fields using a data file for positions
  #1
Member
 
Christian Butcher
Join Date: Jul 2013
Location: Japan
Posts: 85
Rep Power: 13
chrisb2244 is on a distinguished road
Hi,

So I'm currently trying to set the initial conditions on my temperature and/or alpha1 fields using funkySetFields.

The case is 2D (or at least, empty on the back and front) and is basically split horizontally in the middle, with a step function for alpha1, and possibly temperature if I try and use it (I have a modified interFoam solver that seems to be working)

I want to perturb my interface based on a summation of cos waves at different wavenumbers. I have funkySetFields working if I want to use something like

Code:
{
	variables "Curve=cos ((2*pos().x*pi*1)/(max(pos().x)-min(pos().x)));";
		field alpha1;
		condition "((pos().y - ((((max(pos().y)-min(pos().y))/2.0)+min(pos().y)) - 0.005*Curve)) < 0)
but this as far as I can tell only allows one wavelength/number.

I wrote a c++ program to sum up the effects of multiple wavenumbers, giving me a position for each value of x that OpenFoam will ask for (although I don't know how many decimal places that OF uses...), then tried to use those as variables - I have since realised this is likely flawed from the get-go since I would need funkySetFields to read in the pos().x variable, and then after that check for variables to substitute.

Having decided that approach is unlikely to work, I now am trying to see if I can in some way write out my data to be interpreted as a vector, and index my vector by cell location. My thoughts are something like (for a 600 cell wide computational volume/area)

datafile:
Code:
defaultVariables (
"value[0 (or 1?)]=1.234;"
"value[1]=1.252;"
"value[2]=...;"
"value[599 (or 600?)] = 1.102;"
);
with funkySetFieldsDict:
Code:
header...

#include "../valuesfile"

expressions
(
sectiontobechanged
    {
          variables $defaultVariables;
          field alpha1;
          condition "((pos().y - value[(pos().x*600)]) < 0";
          expression "1";
    }
);
This might still never work, since I guess it will still have to run through in order to give a value to pos().x, and the variable to be chosen (assuming it will allow a vector/array) would need to be selected afterwards.

If anyone knows of a way I could make this work, or alternatively, has some better implementation, please let me know

Christian
chrisb2244 is offline   Reply With Quote

Reply

Tags
funkysetfields, initial conditions, initialisation, openfoam 2.2, swak4foam


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
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 14:12
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 06:18
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24


All times are GMT -4. The time now is 21:35.