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

Using database files in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2014, 21:50
Default Using database files in OpenFOAM
  #1
New Member
 
Join Date: Sep 2013
Posts: 9
Rep Power: 13
menonshyam is on a distinguished road
Hello all,

I am trying to use sql database files (.db) with OpenFOAM for my application. I am able to run codes that successfully read from the database files during the simulation. It also works with parallel processors. However, I suspect that the simulation slows down since all processors are accessing the database file from the same location (in my case folder). Is there perhaps a way to distribute the database file in each processor folder so as to speed up operation. I tried copying the database file to each processor folder but it is not being read. I use the following code in "main" to open the database file:

Code:
	if (sqlite3_open("Database.db", &db) != SQLITE_OK) 
	{
		std::cerr << "Could not open database.\n";
		return 1;
	}
Is there a way to specify a path in the sqlite3_open statement that could point to the database file in each specific processor folder?

Thanks!
Shyam
menonshyam is offline   Reply With Quote

Old   August 16, 2014, 04:01
Default
  #2
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Hi Shyam,

I've had a somewhat similar problem and switched from a SQLite database to a mySQL database, for that very reason. This database is not hosted on the machines I use to run the simulations on, which distributes the IO.

Further on I created a data structure that takes care of the data being only read once *and* only by the master process (Pstream::master()). I then use Pstream::scatterList, to scatter the data, which is stored in a List<T>, to all processes.

Maybe this helps.

Jens
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 16, 2014, 12:38
Default Using database files in OpenFOAM
  #3
New Member
 
Join Date: Sep 2013
Posts: 9
Rep Power: 13
menonshyam is on a distinguished road
Hello Jens,

Thank you for your reply.

It seems that mySQL is installed and available on the processors i use to run my simulations. I'll have to see how much of the SQL programming code i need to change to go from SQLite to mySQL!

However, in my code i go through cell and patch arrays and query the table in a sequential manner every time step. Since the queries themselves change every time step, I do not think i can query just once like in your simulation. Else, I would have to carry around a lot of data which is something i want to avoid.

I am still hoping that there is a way to allow each processor to access their own copy of the database. There appears to be a distributed data option in OF. Not sure if that can accomplish what i need.

Thanks!
Shyam
menonshyam is offline   Reply With Quote

Old   August 16, 2014, 16:28
Default
  #4
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Hi,

code change: I would strongly suggest, that you create a class hierarchy, that wraps the database communication in a separate layer. Doing so enables you to change the type of database later on, without affecting the rest of the code.

mySQL vs SQLite: I doubt that you would have to change a lot of the SQL syntax.

Querying: I do the same stuff, basically. That's why I cache the data on the master node. Otherwise the database communication - in the case of my application - way to dominant. The entire process would be slow as hell.

Access: If you can really separate the data on down to each processor, you should be fairly safe. mySQL can handle quite a lot of queries.
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Reply


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
[Commercial meshers] how to convert the .db (ansys database) file to openfoam? stickjohnson OpenFOAM Meshing & Mesh Conversion 2 December 4, 2015 16:08
[OpenFOAM] ParaView can't find OpenFOAM files SoftJohn ParaView 13 January 8, 2015 18:36
Uninstalling OpenFOAM and reinstalling fresh problem with dot files Poormanphysics OpenFOAM 3 August 1, 2013 03:36
separate .vtk files + OpenFOAM fields: synchronous time tomislav_maric OpenFOAM Post-Processing 4 November 21, 2011 10:34
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 14:43


All times are GMT -4. The time now is 14:54.