|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Rida
Join Date: Mar 2021
Posts: 1
Rep Power: 0 ![]() |
Hello everyone,
I am working on a OpenFoam simulation with the energy equation. My problem is very simple. When setting initial boundary conditions for temperature, I aim to give specific values of temperature to each point of the mesh (or face ) from an external csv file containting ( xpos, ypos, zpos, T(xpos,ypos,zpos) ). I wrote this part of the code, but I get a warrning : " attempt to read beyond EOF " which I dont understand what It really means. CODE : boundaryField { ".*" { type codedFixedValue; code #{ std::ifstream file(file_temperature); if (file.is_open() ) { for ( long row=1 ; row<=csv_total_rows ; row++ ) { for(long column=1; column<=csv_total_columns; column++) { long index = (row-1)*csv_total_columns+column-1; scalar xpos = csv_data[index].nodeposition[0]; scalar ypos = csv_data[index].nodeposition[1]; scalar zpos = csv_data[index].nodeposition[2]; pos(xpos, ypos, zpos); scalar T = csv_data[index].nodeposition[3]; } } file.close(); } #}; codeInclude #{ #include <cmath> #include <iostream> #include <fstream> #}; } } I hope I can get some answers, thank you very much |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Giovanni Luddeni
Join Date: Jan 2021
Posts: 14
Rep Power: 5 ![]() |
Hi, I'm not sure if I can help you, but I can share some thoughts.
First, the warning means that you are trying to read past the end of file (EOF). Maybe check the loop by printing the row every step and see exactly when the error arises. Another thing, is this something you just want to do when you initialize the simulation? A coded BC is useful if you need it to run every timestep; there are better ways to impose a field in preprocessing. Another thing, I think there is no point where you actually apply the values you read. To update the boundary you should use something like: Code:
(*this)[faceID]=Temperature_scalar; Code:
const volScalarField& Temp = db().lookupObject<volScalarField>("Temp"); Temp[cellID]==Temperature_scalar; I'm not sure if this is helpful, I hope so ![]() PS: to improve readability, you can put code in a CODE tag, you find it in the toolbar at the # button. |
|
![]() |
![]() |
![]() |
Tags |
boundary conditions, csv files |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 03:30 |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 16:02 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 06:28 |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 05:18 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |