|
[Sponsors] |
Writing OpenFoam header to the sampled output data to use as inlet b.c |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 10, 2017, 02:19 |
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 |
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 |
|
January 26, 2017, 12:16 |
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 |
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.
|
|
January 26, 2017, 12:43 |
|
#3 | |
Member
Join Date: Apr 2016
Posts: 34
Rep Power: 10 |
Quote:
Thanks a lot for your response. It would be great if you could share your code. |
||
January 27, 2017, 05:08 |
|
#4 |
New Member
Xander Walsh
Join Date: Jan 2012
Posts: 4
Rep Power: 14 |
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 |
|
Tags |
header, openfoam, sample data, timevaryingfixedmapped |
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 12:29 |
How to get the output pressure of OpenFoam? | IGH | OpenFOAM Post-Processing | 3 | October 4, 2017 10:38 |
How to Mix AIR and WATER | Elvis1991 | FLUENT | 12 | December 1, 2016 12:28 |
outlet profiles of LES simulation as transient inlet b.c. for LES of a bend pipe | Henny | FLUENT | 0 | March 28, 2013 04: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 06:25 |