|
[Sponsors] |
July 5, 1999, 08:25 |
3D DNS code in C with large arrays.
|
#1 |
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.
|
|
July 5, 1999, 08:58 |
Re: 3D DNS code in C with large arrays.
|
#2 |
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! |
|
July 6, 1999, 04:00 |
Re: 3D DNS code in C with large arrays.
|
#3 |
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( ) |
|
July 23, 1999, 14:09 |
Re: 3D DNS code in C with large arrays.
|
#4 |
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
|
|
|
|
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 |