CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Preferred data type in C++ for structured mesh

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Continuum
  • 1 Post By requou

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 13, 2021, 22:30
Default Preferred data type in C++ for structured mesh
  #1
Member
 
Anders Aamodt Resell
Join Date: Dec 2021
Location: Oslo, Norway
Posts: 66
Rep Power: 5
ander is on a distinguished road
Hi

I am going to implement FVM for 2D Euler equations in C++. I wonder what data types I should consider using to store the conserved variables in each node (as well as other variables) One idea is to use c arrays in this fashion:
double U[ni][nj][4].
Another Idea I have is to store them in matrices, in a linalg library like Eigen, but not sure if Eigen supports rank 3 tensors. I have previously written a 2D Euler solver in Matlab using this approach.

Thanks!
ander is offline   Reply With Quote

Old   December 14, 2021, 08:28
Default
  #2
New Member
 
Continuum
Join Date: Aug 2009
Posts: 19
Rep Power: 17
Continuum is on a distinguished road
Suggest a class that carries i, j and k. Use k for future 3D if you evolve to that. I would not save in 2D vectors. I would devise a flattening method that works for you structured mesh. You could have a class method that returns the index for the flattened matrix based on ijk input indices.
ander likes this.
Continuum is offline   Reply With Quote

Old   December 14, 2021, 11:50
Default
  #3
New Member
 
Join Date: Nov 2019
Posts: 19
Rep Power: 7
requou is on a distinguished road
Using the Matrix class from Eigen is the best choice in my opinion.
ander likes this.
requou is offline   Reply With Quote

Old   December 15, 2021, 13:46
Default
  #4
Member
 
Anders Aamodt Resell
Join Date: Dec 2021
Location: Oslo, Norway
Posts: 66
Rep Power: 5
ander is on a distinguished road
Quote:
Originally Posted by Continuum View Post
Suggest a class that carries i, j and k. Use k for future 3D if you evolve to that. I would not save in 2D vectors. I would devise a flattening method that works for you structured mesh. You could have a class method that returns the index for the flattened matrix based on ijk input indices.
Thanks. Do you have an example or link to explain how this is done in more detail?
ander is offline   Reply With Quote

Reply

Tags
c++, compressible, euler equations, finite volume method


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
reactingMultiphaseEulerFoam tonnykz OpenFOAM Running, Solving & CFD 2 June 15, 2020 03:09
time step continuity error increases with time_SRFSimplefoam mostafa kamal OpenFOAM Running, Solving & CFD 7 October 2, 2019 03:00
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) Aadhavan OpenFOAM Meshing & Mesh Conversion 2 March 8, 2018 02:47
singularity? mihaipruna OpenFOAM Running, Solving & CFD 5 April 24, 2012 18:18
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55


All times are GMT -4. The time now is 12:03.