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

Adding a configuration option to read a file

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 29, 2019, 15:38
Default Adding a configuration option to read a file
  #1
New Member
 
Marc Latour
Join Date: Jul 2019
Posts: 4
Rep Power: 2
mlatour is on a distinguished road
Hi everyone,

I'm currently working on adding body force modeling capabilities to SU2, which would require the reading of a file (see attachment) with values so that they can be stored in an array and used in the numerics class. I understand how to add simple list, double, or string options to the source code, but am having difficulty understanding how to read a file and store it in an array that can be used in the numerics class.

A new class will have to be created, but where would I add this? A file is read for the inlet profile option, but that code is quite extensive and more complicated to understand.

Any help would be appreciated.

Kind Regards,
Marc
Attached Files
File Type: txt normal_values.txt (123 Bytes, 1 views)
mlatour is offline   Reply With Quote

Old   August 31, 2019, 16:30
Default
  #2
pcg
Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 59
Rep Power: 3
pcg is on a distinguished road
Would those values be used to compute some source term? Are they constant over time and space? Or do you have different values for different nodes/regions?

If the answers to the above are: yes, yes, no. Then:

Look into numerics_direct_mean.cpp and CSourceXXXX

If you can get away with modifying an existing class it would save you some time, for example take CSourceBodyForce, read your file in its constructor and then modify the ComputeResidual method.

Source term numerics are used by method CEulerSolver::Source_Residual, this method of the solver goes over all nodes, passes some data of each node to the numerics class and then calls ComputeResidual on it.
Make sure this method is passing all the data you need to the numerics class.
pcg is offline   Reply With Quote

Old   September 3, 2019, 14:30
Default
  #3
New Member
 
Marc Latour
Join Date: Jul 2019
Posts: 4
Rep Power: 2
mlatour is on a distinguished road
Hey Pedro,

The source term values are spatially varying and I have been able to hard-code an implementation that seems to be working. I've adapted the CSourceBodyForce code to compute my force at each node according to the theory.

I was thinking of having CSourceBodyForce read the file, but wouldn't this mean it will be done at every node? Although it may only be a simple file, this would add more computational time to each loop. Is there a way to have it read the file outside this loop and then have the CSourceBodyForce class accept an additional variable, in this case an array with the data from the file?

Regards,
Marc
mlatour is offline   Reply With Quote

Old   September 5, 2019, 06:49
Default
  #4
pcg
Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 59
Rep Power: 3
pcg is on a distinguished road
Hi Marc,

Ah! That is why I asked if they are constant.

There is no automated way...
The numerics classes get their data from CGeometry and CVariable, the "SU2 way" to do what you want is to add the fields you need to CVariable (since they vary with space) and then set the data in numerics in the SourceResidual loop.

You could read and set that data in CVariable in the solver constructor (executed only once) or in the solver preprocessing method (executed every iteration).
If you just want to prototype you could also avoid CVariable and add a few vectors directly to CSolver...

Cheers,
Pedro
pcg is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 74 October 11, 2018 04:30
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
Custom Thermophysical Properties wsmith02 OpenFOAM 3 July 27, 2015 05:37
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 06:42
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 12:41


All times are GMT -4. The time now is 16:58.