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

3D DNS code in C with large arrays.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 1999, 08:25
Default 3D DNS code in C with large arrays.
  #1
S.Sri Govind
Guest
 
Posts: n/a
I've been trying to run this code that simulates turbulent spots for Couette flow.The code runs perfectly for a grid of 70*37*70, but gives a segmentation fault for a grid of 134*37*134. I've managed to track down the problem to a particular function, which is not able initialise the array (of the above size) fully.When I ask for the values to be printed before being sent to the function,the segmentation fault seems to occur when about 70 odd points are to be initialised.This occurs even when I Try to initialise only a part of the whole grid say 100*33*100.
  Reply With Quote

Old   July 5, 1999, 08:58
Default Re: 3D DNS code in C with large arrays.
  #2
Andrei Chernousov
Guest
 
Posts: n/a
You may use memory allocation function of the type:

#include <stdio.h> #include <process.h> #include <alloc.h>

/* Memory allocation procedure based on _nested_ pointers, w/o segmentation problems */

/************ * RECTMEM * For 2D (rectangular) array ************/ float **RectMem( int columns, int rows ) { float **x; int i;

if((x=(float**)farmalloc(columns*sizeof(float*)))= =NULL) {

printf("cannot allocate"); exit(0); } for( i = 0; i < columns; i++ )

if((x[i]=(float*)farmalloc(rows*sizeof(float)))==NULL) {

printf("cannot allocate"); exit(0);

} return x; } // end RectMem( )

// Good luck!
  Reply With Quote

Old   July 6, 1999, 04:00
Default Re: 3D DNS code in C with large arrays.
  #3
Andrei Chernousov
Guest
 
Posts: n/a
Excuse me, I posted message without preview

Memory allocation procedure based on _nested_ pointers, w/o segmentation problems (For 2D (rectangular) array):

include stdio.h

include stdlib.h

include alloc.h

float **RectMem( int columns, int rows )

{

float **x; int i;

if((x=(float**)farmalloc(columns*sizeof(float*)))= =NULL) { printf("cannot allocate"); exit(0); }

for( i = 0; i < columns; i++ )

if((x[i]=(float*)farmalloc(rows*sizeof(float)))==NULL) {

printf("cannot allocate"); exit(0);

}

return x;

} // end RectMem( )
  Reply With Quote

Old   July 23, 1999, 14:09
Default Re: 3D DNS code in C with large arrays.
  #4
clifford bradford
Guest
 
Posts: n/a
master i do not understand. could you explain what it is you're trying to do so that a plebian like myself can comprehend
  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
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 13:30
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 09:10
Free DNS code ? Dr. Jones Main CFD Forum 8 November 7, 2000 20:44
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07
State of the art in CFD technology Juan Carlos GARCIA SALAS Main CFD Forum 39 November 1, 1999 15:34


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