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, 21:30
Default Preferred data type in C++ for structured mesh
  #1
Member
 
Anders Aamodt Resell
Join Date: Dec 2021
Location: Oslo, Norway
Posts: 65
Rep Power: 4
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, 07:28
Default
  #2
New Member
 
Continuum
Join Date: Aug 2009
Posts: 19
Rep Power: 16
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, 10:50
Default
  #3
New Member
 
Join Date: Nov 2019
Posts: 19
Rep Power: 6
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, 12:46
Default
  #4
Member
 
Anders Aamodt Resell
Join Date: Dec 2021
Location: Oslo, Norway
Posts: 65
Rep Power: 4
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 02:09
time step continuity error increases with time_SRFSimplefoam mostafa kamal OpenFOAM Running, Solving & CFD 7 October 2, 2019 02:00
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) Aadhavan OpenFOAM Meshing & Mesh Conversion 2 March 8, 2018 01:47
singularity? mihaipruna OpenFOAM Running, Solving & CFD 5 April 24, 2012 17:18
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


All times are GMT -4. The time now is 02:07.