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

Writing OpenFoam header to the sampled output data to use as inlet b.c

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By CliftonReed
  • 3 Post By CliftonReed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 10, 2017, 03:19
Default Writing OpenFoam header to the sampled output data to use as inlet b.c
  #1
Member
 
Join Date: Apr 2016
Posts: 34
Rep Power: 10
Eman. is on a distinguished road
Hi,

I want to use the sample utility to get U and P and later use them as inlet values for another simulation using timeVaryingMappedFixedValue. The problem is the sampled data don't have any OpenFoam headers and the timeVaryingMappedFixedValue needs all the fields data to have proper headers. Is there any way to automatically write the headers while sampling the data?

Thanks
Eman. is offline   Reply With Quote

Old   January 26, 2017, 13:16
Default Writing OpenFoam header to the sampled output data to use as inlet b.c
  #2
New Member
 
Xander Walsh
Join Date: Jan 2012
Posts: 4
Rep Power: 14
CliftonReed is on a distinguished road
If you have access to Matlab I can provide a script that takes instantaneous data from multiple files and places it into time directories for the timeVaryingMappedFixedValue BC.
Eman. likes this.
CliftonReed is offline   Reply With Quote

Old   January 26, 2017, 13:43
Default
  #3
Member
 
Join Date: Apr 2016
Posts: 34
Rep Power: 10
Eman. is on a distinguished road
Quote:
Originally Posted by CliftonReed View Post
If you have access to Matlab I can provide a script that takes instantaneous data from multiple files and places it into time directories for the timeVaryingMappedFixedValue BC.
Hi Xander,

Thanks a lot for your response. It would be great if you could share your code.
Eman. is offline   Reply With Quote

Old   January 27, 2017, 06:08
Default
  #4
New Member
 
Xander Walsh
Join Date: Jan 2012
Posts: 4
Rep Power: 14
CliftonReed is on a distinguished road
The code is below. In this case j refers to the time step, k is the number of sampling positions. Also note that the necessary header has been placed in one column of the table.

I am not particularly experienced with Matlab and there may be less clunky solutions available.

%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%

clc
clear all
close all

for j=1:800

uOld = zeros(10,1);
for k=1:10

myfilename1 = sprintf('../samples/z%d_U.xy', k)

%%%%%%%%%%
%%%

data = importdata(myfilename1);

x{k} = data(j,1)*25;

u{k} = (data(j,2))*2;

t{k} = x{k};

v{k} =(data(j,3))*2;

w{k} =(data(j,4))*2;


end

headerLine = sprintf('FoamFile { version 2.0; format ascii; class vectorAverageField; object values; } (0 0 0) 10 (');

oldFolder = cd('C:\Users\restOfFilePath')

a = t{k}
s = num2str(a)

mkdir(s);
cd(s)

header = {headerLine;' ';' ';' '; '';' ';' ';' ';' ';' '};

oBracket = {'(';'(';'(';'(';'(';'(';'(';'(';'(';'('};
Ucol = [u{1};u{2};u{3};u{4};u{5};u{6};u{7};u{8};u{9};u{10}];
Vcol = [v{1};v{2};v{3};v{4};v{5};v{6};v{7};v{8};v{9};v{10}];
Wcol = [w{1};w{2};w{3};w{4};w{5};w{6};w{7};w{8};w{9};w{10}];
cBracket = {')';')';')';')';')';')';')';')';')'; ')'};
closeLine = {' ';' ';' ';' ';' ';' ';' ';' ';' ';' )'};

T = table( header, oBracket,Ucol,Vcol,Wcol,cBracket, closeLine)

writetable(T,'U','Delimiter','\t','WriteVariableNa mes',false)

movefile('U.txt','U')

cd(oldFolder)
end
CliftonReed is offline   Reply With Quote

Reply

Tags
header, openfoam, sample data, timevaryingfixedmapped


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
OpenFOAM - Control and Editing of Lagrangian Output Variables gmag OpenFOAM Programming & Development 1 June 25, 2019 13:29
How to get the output pressure of OpenFoam? IGH OpenFOAM Post-Processing 3 October 4, 2017 11:38
How to Mix AIR and WATER Elvis1991 FLUENT 12 December 1, 2016 13:28
outlet profiles of LES simulation as transient inlet b.c. for LES of a bend pipe Henny FLUENT 0 March 28, 2013 05:02
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 07:25


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